|
const PointList & | _getIndices (void) |
|
const NodeList & | _getNodes (void) |
|
const PointList & | _getPoints (void) |
|
const AxisAlignedBoxType & | aabb () const |
|
template<class VectorDerived > |
void | add (const VectorDerived &p) |
| Add a new vertex in the KdTree. More...
|
|
void | add (Scalar *position) |
|
template<int stackSize, typename Container = std::vector<VectorType>> |
void | doQueryDist (RangeQuery< stackSize > &query, Container &result) const |
| Performs distance query and return vector coordinates. More...
|
|
template<int stackSize, typename IndexContainer = std::vector<Index>> |
void | doQueryDistIndices (RangeQuery< stackSize > &query, IndexContainer &result) const |
| Performs distance query and return indices. More...
|
|
template<int stackSize, typename Functor > |
void | doQueryDistProcessIndices (RangeQuery< stackSize > &query, Functor f) const |
| Performs distance query and return indices. More...
|
|
template<int stackSize> |
std::pair< Index, Scalar > | doQueryRestrictedClosestIndex (RangeQuery< stackSize > &query, int currentId=-1) const |
| Finds the closest element index within the range [0:sqrt(sqdist)]. More...
|
|
void | finalize () |
| Finalize the creation of the KdTree. More...
|
|
| KdTree (const PointList &points, unsigned int nofPointsPerCell=KD_POINT_PER_CELL, unsigned int maxDepth=KD_MAX_DEPTH) |
| Create the Kd-Tree using memory copy. More...
|
|
| KdTree (unsigned int size=0, unsigned int nofPointsPerCell=KD_POINT_PER_CELL, unsigned int maxDepth=KD_MAX_DEPTH) |
| Create a void KdTree. More...
|
|
| ~KdTree () |
|
|
template<int stackSize, typename Functor > |
void | _doQueryDistIndicesWithFunctor (RangeQuery< stackSize > &query, Functor f) const |
| Performs distance query and pass the internal id to a functor. More...
|
|
void | createTree (unsigned int nodeId, unsigned int start, unsigned int end, unsigned int level, unsigned int targetCellsize, unsigned int targetMaxDepth) |
| Recursively builds the kdtree. More...
|
|
unsigned int | split (int start, int end, unsigned int dim, Scalar splitValue) |
| Used to build the tree: split the subset [start..end[ according to dim and splitValue, and returns the index of the first element of the second subset. More...
|
|
template<typename _Scalar, typename _Index = int>
class gr::KdTree< _Scalar, _Index >
3D Kdtree with reentrant queries
template<typename Scalar , typename Index >
template<int stackSize, typename Functor >
Performs distance query and pass the internal id to a functor.
- See also
- doQueryRestrictedClosestIndex For more information about the algorithm.
This function is an alternative to doQueryDist(const VectorType& queryPoint) that allow to perform the query by requesting a maximum distance instead of neighborhood size.
template<typename Scalar , typename Index >
Recursively builds the kdtree.
The heuristic is the following:
- if the number of points in the node is lower than targetCellsize then make a leaf
- else compute the AABB of the points of the node and split it at the middle of the largest AABB dimension.
This strategy might look not optimal because it does not explicitly prune empty space, unlike more advanced SAH-like techniques used for RT. On the other hand it leads to a shorter tree, faster to traverse and our experience shown that in the special case of kNN queries, this strategy is indeed more efficient (and much faster to build). Moreover, for volume data (e.g., fluid simulation) pruning the empty space is useless.
Actually, storing at each node the exact AABB (we therefore have a binary BVH) allows to prune only about 10% of the leaves, but the overhead of this pruning (ball/ABBB intersection) is more expensive than the gain it provides and the memory consumption is x4 higher !
template<typename Scalar , typename Index >
template<int stackSize>
Finds the closest element index within the range [0:sqrt(sqdist)].
This algorithm uses the simple distance to the split plane to prune nodes.
- Parameters
-
currentId | Index of the querypoint if it belongs to the tree |
A more elaborated approach consists to track the closest corner of the cell relatively to the current query point. This strategy allows to save about 5% of the leaves. However, in practice the slight overhead due to this tracking reduces the overall performance.
This algorithm also use a simple stack while a priority queue using the squared distances to the cells as a priority values allows to save about 10% of the leaves. But, again, priority queue insertions and deletions are quite involved, and therefore a simple stack is by far much faster.
The optionnal parameter currentId is used when the query point is stored in the tree, and must thus be avoided during the query