RTree

class RTree

Implementation of R-Tree, a multidimensional bounding rectangle tree.

This is ported to D C++ version by Yariv Barkan.

class RTree (
DataType
ElemType
alias NumDims
ElemTypeReal
alias int MaxNodes = 8
alias int MinNodes = MaxNodes / 2
) {}

Constructors

this
this()
Undocumented in source.

Destructor

~this
~this()
Undocumented in source.

Members

Functions

AddBranch
bool AddBranch(Branch* a_branch, Node* a_node, Node** a_newNode)
Undocumented in source. Be warned that the author may not have intended to support it.
AllocListNode
ListNode* AllocListNode()
Undocumented in source. Be warned that the author may not have intended to support it.
AllocNode
Node* AllocNode()
Undocumented in source. Be warned that the author may not have intended to support it.
CalcRectVolume
ElemTypeReal CalcRectVolume(Rect* a_rect)
Undocumented in source. Be warned that the author may not have intended to support it.
ChoosePartition
void ChoosePartition(PartitionVars* a_parVars, int a_minFill)
Undocumented in source. Be warned that the author may not have intended to support it.
Classify
void Classify(int a_index, int a_group, PartitionVars* a_parVars)
Undocumented in source. Be warned that the author may not have intended to support it.
CombineRect
Rect CombineRect(Rect* a_rectA, Rect* a_rectB)
Undocumented in source. Be warned that the author may not have intended to support it.
CountRec
void CountRec(Node* a_node, int a_count)
Undocumented in source. Be warned that the author may not have intended to support it.
DisconnectBranch
void DisconnectBranch(Node* a_node, int a_index)
Undocumented in source. Be warned that the author may not have intended to support it.
FreeListNode
void FreeListNode(ListNode* a_listNode)
Undocumented in source. Be warned that the author may not have intended to support it.
FreeNode
void FreeNode(Node* a_node)
Undocumented in source. Be warned that the author may not have intended to support it.
GetBranches
void GetBranches(Node* a_node, Branch* a_branch, PartitionVars* a_parVars)
Undocumented in source. Be warned that the author may not have intended to support it.
InitNode
void InitNode(Node* a_node)
Undocumented in source. Be warned that the author may not have intended to support it.
InitParVars
void InitParVars(PartitionVars* a_parVars, int a_maxRects, int a_minFill)
Undocumented in source. Be warned that the author may not have intended to support it.
InitRect
void InitRect(Rect* a_rect)
Undocumented in source. Be warned that the author may not have intended to support it.
InsertRect
bool InsertRect(Branch a_branch, Node** a_root, int a_level)
Undocumented in source. Be warned that the author may not have intended to support it.
InsertRectRec
bool InsertRectRec(Branch a_branch, Node* a_node, Node** a_newNode, int a_level)
Undocumented in source. Be warned that the author may not have intended to support it.
LoadNodes
void LoadNodes(Node* a_nodeA, Node* a_nodeB, PartitionVars* a_parVars)
Undocumented in source. Be warned that the author may not have intended to support it.
NodeCover
Rect NodeCover(Node* a_node)
Undocumented in source. Be warned that the author may not have intended to support it.
Overlap
bool Overlap(Rect* a_rectA, Rect* a_rectB)
Undocumented in source. Be warned that the author may not have intended to support it.
PickBranch
int PickBranch(Rect* a_rect, Node* a_node)
Undocumented in source. Be warned that the author may not have intended to support it.
PickSeeds
void PickSeeds(PartitionVars* a_parVars)
Undocumented in source. Be warned that the author may not have intended to support it.
ReInsert
void ReInsert(Node* a_node, ListNode** a_listNode)
Undocumented in source. Be warned that the author may not have intended to support it.
RectSphericalVolume
ElemTypeReal RectSphericalVolume(Rect* a_rect)
Undocumented in source. Be warned that the author may not have intended to support it.
RectVolume
ElemTypeReal RectVolume(Rect* a_rect)
Undocumented in source. Be warned that the author may not have intended to support it.
RemoveAllRec
void RemoveAllRec(Node* a_node)
Undocumented in source. Be warned that the author may not have intended to support it.
RemoveRect
bool RemoveRect(Rect* a_rect, DataType a_id, Node** a_root)
Undocumented in source. Be warned that the author may not have intended to support it.
RemoveRectRec
bool RemoveRectRec(Rect* a_rect, DataType a_id, Node* a_node, ListNode** a_listNode)
Undocumented in source. Be warned that the author may not have intended to support it.
Reset
void Reset()
Undocumented in source. Be warned that the author may not have intended to support it.
Search
bool Search(Node* a_node, Rect* a_rect, Array!DataType result)
Undocumented in source. Be warned that the author may not have intended to support it.
SplitNode
void SplitNode(Node* a_node, Branch* a_branch, Node** a_newNode)
Undocumented in source. Be warned that the author may not have intended to support it.
count
int count()

Count the data elements in this container. This is slow as no internal counter is maintained.

insert
void insert(ElemType[NumDims] a_min, ElemType[NumDims] a_max, DataType a_dataId)

Insert entry

remove
void remove(ElemType[NumDims] a_min, ElemType[NumDims] a_max, DataType a_dataId)

Remove entry

removeAll
void removeAll()

Remove all entries from tree

search
Array!DataType search(ElemType[NumDims] a_min, ElemType[NumDims] a_max)

Find all within query rectangle

Imports

Array (from std.container.array)
public import std.container.array : Array;
Undocumented in source.

Manifest constants

unitSphereVolume
enum unitSphereVolume;
Undocumented in source.

Structs

Branch
struct Branch
Undocumented in source.
ListNode
struct ListNode
Undocumented in source.
Node
struct Node
Undocumented in source.
PartitionVars
struct PartitionVars
Undocumented in source.
Rect
struct Rect
Undocumented in source.

Variables

UnitSphereVolume
enum float[] UnitSphereVolume;
Undocumented in source.
m_root
Node* m_root;
Undocumented in source.

Parameters

DataType

Referenced data, should be int, void*, obj* etc. no larger than (void*).sizeof and simple type

ElemType

Type of element such as int or float

NumDims

Number of dimensions such as 2 or 3

ElemTypeReal

Type of element that allows fractional and large values such as float or double, for use in volume calcs

Examples

// a 3-dimensional tree
alias MyTree = RTree!(StructPtr, float, 3);
auto my_tree = new MyTree();

Notes: Inserting and removing data requires the knowledge of its constant Minimal Bounding Rectangle. This version uses new/delete for nodes, I recommend using a fixed size allocator for efficiency. Instead of using a callback function for returned results, I recommend use efficient pre-sized, grow-only memory array similar to MFC CArray or STL Vector for returning search query result.

Meta