#include <KDTree_fwd.hpp>
Class representing a static k-d tree data structure.
This class is a wrapper around nanoflann library for nearest neighbours. For specific behaviors please refer to nanoflann documentation.
If dynamic insertions and removals are needed, use KDTreeMutable.
Usage example:
Definition at line 36 of file KDTree_fwd.hpp.
Public Member Functions | |
| KDTree (const Range< vec_t > &points) | |
| Constructor that builds the search tree for the given points. More... | |
| KDTree () | |
| Creates an empty KDTree. The tree may later be filled using KDTree::resetTree. More... | |
| void | reset (const Range< vec_t > &points) |
| Grows a new tree with new points. More... | |
| std::pair< Range< int >, Range< scalar_t > > | query (const vec_t &point, int k=1) const |
Find k nearest neighbors to given point. More... | |
| std::pair< Range< int >, Range< scalar_t > > | query (const vec_t &point, const scalar_t &radius_squared) const |
Find neighbors of point in given radius. More... | |
| vec_t | get (int index) const |
| Get the coordinates of a point in the tree. More... | |
| Range< vec_t > | get (const Range< int > &indexes) const |
| Vectorized version of KDTree::get. More... | |
| int | size () const |
| Returns number of points in this tree. 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 KDTree< V > &tree) |
| Output basic info about given tree. More... | |
Private Types | |
| typedef nanoflann::KDTreeSingleIndexAdaptor< nanoflann::L2_Simple_Adaptor< scalar_t, kdtree_internal::PointCloud< vec_t > >, kdtree_internal::PointCloud< vec_t >, dim, int > | kd_tree_t |
| k-d tree type. More... | |
Private Attributes | |
| kdtree_internal::PointCloud< vec_t > | points_ |
| Points, contained 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 KDTree_fwd.hpp.
|
inlineexplicit |
Constructor that builds the search tree for the given points.
| points | A collection of points. |
Definition at line 56 of file KDTree_fwd.hpp.
|
inline |
Creates an empty KDTree. The tree may later be filled using KDTree::resetTree.
Definition at line 62 of file KDTree_fwd.hpp.
|
inline |
Vectorized version of KDTree::get.
Definition at line 116 of file KDTree_fwd.hpp.
|
inline |
Get the coordinates of a point in the tree.
Given the index of a point as it appeared in the original list this function returns a its coordinates.
Example:
| index | Index of the point as given in the constructor. |
index-th point. Definition at line 113 of file KDTree_fwd.hpp.
| std::pair< Range< int >, Range< typename vec_t::scalar_t > > mm::KDTree< vec_t >::query | ( | const vec_t & | point, |
| const scalar_t & | radius_squared | ||
| ) | const |
Find neighbors of point in given radius.
| point | Find closest points to this point. |
| radius_squared | Maximum distance (squared) to search. |
point to its neighbours. Definition at line 28 of file KDTree.hpp.
| std::pair< Range< int >, Range< typename vec_t::scalar_t > > mm::KDTree< vec_t >::query | ( | const vec_t & | point, |
| int | k = 1 |
||
| ) | const |
Find k nearest neighbors to given point.
This method uses ANN query function.
| point | Find closest points to this point. |
| k | How many nearest points to find. |
k containing indices of nearest neighbors and squared distances from point to its neighbours. Definition at line 16 of file KDTree.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 71 of file KDTree_fwd.hpp.
|
inline |
Returns number of points in this tree.
Definition at line 126 of file KDTree_fwd.hpp.
|
friend |
Output basic info about given tree.
Definition at line 42 of file KDTree.hpp.
|
private |
Points, contained in the tree.
Definition at line 48 of file KDTree_fwd.hpp.
|
private |
Actual tree build over points.
Definition at line 49 of file KDTree_fwd.hpp.