#include <KDTreeMutable_fwd.hpp>
A k-d tree data structure that supports dynamic insertions and lazy-removal.
This class is a wrapper around nanoflann k-d tree implementation. For specific behavior please refer to nanoflann docs.
If dynamic structure is not needed, a faster static KDTree structure can be used.
Usage example:
Definition at line 18 of file HalfLinksRefine_fwd.hpp.
Public Member Functions | |
KDTreeMutable (const Range< vec_t > &points) | |
Constructor that builds the search tree for the given points. More... | |
KDTreeMutable () | |
Creates an empty k-d tree. More... | |
void | reset (const Range< vec_t > &points) |
Grows a new tree with new points. More... | |
void | insert (const vec_t &point) |
Insert a point into the tree. More... | |
void | insert (const Range< vec_t > &points) |
Inserts a sequence of points. More... | |
bool | existsPointInSphere (const vec_t &p, scalar_t r) |
Check if any point exists in sphere centered at p with radius r . More... | |
void | remove (int index) |
Removes a point with given index from the tree. More... | |
int | size () const |
Returns number of points in the tree. More... | |
std::pair< mm::Range< int >, mm::Range< double > > | query (const vec_t &point, int k=1) |
Find k nearest neighbors to given point. More... | |
Public Types | |
enum | { dim = vec_t::dim } |
Store dimension of the space. More... | |
typedef vec_t | vector_t |
Vector type used. More... | |
typedef vector_t::scalar_t | scalar_t |
Scalar type used. More... | |
Friends | |
template<class V > | |
std::ostream & | operator<< (std::ostream &os, const KDTreeMutable< V > &tree) |
Output basic info about given tree. More... | |
Private Types | |
typedef nanoflann::KDTreeSingleIndexDynamicAdaptor< nanoflann::L2_Simple_Adaptor< scalar_t, kdtree_internal::PointCloud< vec_t > >, kdtree_internal::PointCloud< vec_t >, dim > | kd_tree_t |
Tree type. More... | |
Private Attributes | |
kdtree_internal::PointCloud< vec_t > | points_ |
Points, contained in the tree. More... | |
int | size_ |
Number of points in the tree. More... | |
kd_tree_t | tree |
Actual tree build over points. More... | |
anonymous enum |
Store dimension of the space.
Enumerator | |
---|---|
dim | Dimensionality of the space. |
Definition at line 41 of file KDTreeMutable_fwd.hpp.
|
inlineexplicit |
Constructor that builds the search tree for the given points.
points | A collection of points. |
Definition at line 58 of file KDTreeMutable_fwd.hpp.
|
inline |
Creates an empty k-d tree.
Definition at line 63 of file KDTreeMutable_fwd.hpp.
|
inline |
Check if any point exists in sphere centered at p
with radius r
.
Definition at line 88 of file KDTreeMutable_fwd.hpp.
void mm::KDTreeMutable< vec_t >::insert | ( | const Range< vec_t > & | points | ) |
Inserts a sequence of points.
Definition at line 33 of file KDTreeMutable.hpp.
void mm::KDTreeMutable< vec_t >::insert | ( | const vec_t & | point | ) |
Insert a point into the tree.
point | Point to be inserted into the tree. |
Definition at line 24 of file KDTreeMutable.hpp.
std::pair< mm::Range< int >, mm::Range< double > > mm::KDTreeMutable< vec_t >::query | ( | const vec_t & | point, |
int | k = 1 |
||
) |
Find k
nearest neighbors to given point.
point | Find closest points to this point. |
k | How many nearest points to find. |
k
containing indices of nearest neighbors and squared distances to said neighbors. Assertion | fails if there are not enough points in the tree. |
Definition at line 45 of file KDTreeMutable.hpp.
|
inline |
Removes a point with given index from the tree.
The indexes of the points are given sequentially at insertion and do not change. The removal is lazy and point still takes up memory.
Definition at line 98 of file KDTreeMutable_fwd.hpp.
|
inline |
Grows a new tree with new points.
This function deletes the old points and the old tree and builds a new one with the given points.
points | A new container of points. |
Definition at line 73 of file KDTreeMutable_fwd.hpp.
|
inline |
Returns number of points in the tree.
Definition at line 103 of file KDTreeMutable_fwd.hpp.
|
friend |
Output basic info about given tree.
Definition at line 17 of file KDTreeMutable.hpp.
|
private |
Points, contained in the tree.
Definition at line 49 of file KDTreeMutable_fwd.hpp.
|
private |
Number of points in the tree.
Definition at line 50 of file KDTreeMutable_fwd.hpp.
|
private |
Actual tree build over points.
Definition at line 51 of file KDTreeMutable_fwd.hpp.