class for kd-tree data structure. More...
Public Member Functions | |
KdTree (int stack_size=10) | |
void | clear (void) |
int | exist (const T *) |
int | exist (const T *, T1 &) |
template<class T2 > | |
int | hNeighbor (const T *, T1 &, T2, int n=0, int l=0) |
template<class T2 > | |
int | hNeighbor (const T *, T2, bool, int n=0, int l=0) |
template<class T2 > | |
void | hNeighbors (const T *, T2, std::vector< T1 > *, std::vector< T1 > *, int n=0, int l=0) |
void | insert (T *) |
void | insert (T *, T1 &) |
Public Attributes | |
int | MAXSTK |
int | n_nodes |
std::vector< KdNode< T, T1 > > | nodes |
class for kd-tree data structure.
Sort vertices in a d-dimensional Euclidean space into a kd-tree structure.
Template parameters are:
Template parameters can be any type fulfilling the following requirements:
Definition at line 83 of file SortAlgorithms.hpp.
bitpit::KdTree< d, T, T1 >::KdTree | ( | int | maxstack = 10 | ) |
Default constructor for class KdTree.
Initialize an empty kd-tree structure and reserve memory for the insertion of maxstack nodes.
[in] | maxstack | memory reserve (in terms of number of elements) |
Definition at line 162 of file KdTree.tpp.
void bitpit::KdTree< d, T, T1 >::clear | ( | void | ) |
Clear current content without freeing memory.
Definition at line 196 of file KdTree.tpp.
int bitpit::KdTree< d, T, T1 >::exist | ( | const T * | P_ | ) |
Check whether a given vertex already exist in the kd-tree. Check is performed via lexicographical comparison of vertex coordinates.
[in] | P_ | pointer to container storing the coordinates of the vertex to be checked. |
Definition at line 235 of file KdTree.tpp.
int bitpit::KdTree< d, T, T1 >::exist | ( | const T * | P_, |
T1 & | label ) |
Check whether a given vertex already exist in the kd-tree. Check is performed via lexicographical comparison of vertex coordinates.
[in] | P_ | pointer to container storing the coordinates of the vertex to be checked. |
[in,out] | label | on output stores the label associated with the KdNode (if any) whose coordinates match those of the input vector |
Definition at line 295 of file KdTree.tpp.
int bitpit::KdTree< d, T, T1 >::hNeighbor | ( | const T * | P_, |
T1 & | label, | ||
T2 | h, | ||
int | next_ = 0, | ||
int | lev = 0 ) |
Given an input vertex P, returns the index of the first node encountered in the kd-tree which is in the 1-ball centered on P and having a radius of h. The 1-ball is defined as: B1(x; h) = {y: norm_1(y-x) <= h}
[in] | P_ | pointer to container storing the coordinates of P |
[in,out] | label | on output stores the label of the KdNode in the 1-ball centered on P (if any). |
[in] | h | 1-ball radius |
[in] | next_ | (default = 0) index of element in the kd tree used as starting point by the kd-tree search algorithm |
[in] | lev | (default = 0) level in kd-tree of node used as starting point by the kd-tree search algorithm. |
Definition at line 432 of file KdTree.tpp.
int bitpit::KdTree< d, T, T1 >::hNeighbor | ( | const T * | P_, |
T2 | h, | ||
bool | debug, | ||
int | next_ = 0, | ||
int | lev = 0 ) |
Given an input vertex P, returns the index of the first node encountered in the kd-tree which is in the 1-ball centered on P and having a radius of h. The 1-ball is defined as: B1(x; h) = {y: norm_1(y-x) <= h}
[in] | P_ | pointer to container storing the coordinates of P |
[in] | h | 1-ball radius |
[in] | debug | (default = false) flag for running the search in debug mode |
[in] | next_ | (default = 0) index of element in the kd tree used as starting point by the kd-tree search algorithm |
[in] | lev | (default = 0) level in kd-tree of node used as starting point by the kd-tree search algorithm. |
Definition at line 361 of file KdTree.tpp.
void bitpit::KdTree< d, T, T1 >::hNeighbors | ( | const T * | P_, |
T2 | h, | ||
std::vector< T1 > * | L_, | ||
std::vector< T1 > * | EX_, | ||
int | next_ = 0, | ||
int | lev = 0 ) |
Given an input vertex P, returns the labels of all the nodes encountered in the kd-tree which are in the 1-ball centered on P and having a radius of h. The 1-ball is defined as: B1(x; h) = {y: norm_1(y-x) <= h}
[in] | P_ | pointer to container storing the coordinates of P |
[in] | h | 1-ball radius |
[out] | L_ | pointer to container filled with labels of the kd-nodes encountered in the tree which lies in the 1-ball centered on P. |
[in] | EX_ | pointers to vector with labels to be excluded from the results |
[in] | next_ | (default = 0) index of element in the kd tree used as starting point by the kd-tree search algorithm |
[in] | lev | (default = 0) level in kd-tree of node used as starting point by the kd-tree search algorithm. |
Definition at line 733 of file KdTree.tpp.
void bitpit::KdTree< d, T, T1 >::insert | ( | T * | P_ | ) |
Insert a new vertex in the kd-tree.
[in] | P_ | pointer to container storing vertex coordinates. |
Definition at line 488 of file KdTree.tpp.
void bitpit::KdTree< d, T, T1 >::insert | ( | T * | P_, |
T1 & | label ) |
Insert a new vertex and the associated label into kd-tree.
[in] | P_ | pointer to container storing vertex coordinates. |
[in] | label | label associated to P_ |
Definition at line 562 of file KdTree.tpp.
int bitpit::KdTree< d, T, T1 >::MAXSTK |
max stack size
Definition at line 87 of file SortAlgorithms.hpp.
int bitpit::KdTree< d, T, T1 >::n_nodes |
number of nodes
Definition at line 88 of file SortAlgorithms.hpp.
std::vector< KdNode<T, T1> > bitpit::KdTree< d, T, T1 >::nodes |
kd-tree nodes
Definition at line 89 of file SortAlgorithms.hpp.