#include <nanoflann.hpp>
Classes | |
struct | BranchStruct |
struct | Interval |
struct | Node |
Public Types | |
typedef Distance::DistanceType | DistanceType |
typedef Distance::ElementType | ElementType |
Public Member Functions | |
void | buildIndex () |
KDTreeSingleIndexAdaptor (const int dimensionality, const DatasetAdaptor &inputData, const KDTreeSingleIndexAdaptorParams ¶ms=KDTreeSingleIndexAdaptorParams()) | |
size_t | size () const |
size_t | usedMemory () const |
size_t | veclen () const |
~KDTreeSingleIndexAdaptor () | |
Query methods | |
template<typename RESULTSET > | |
void | findNeighbors (RESULTSET &result, const ElementType *vec, const SearchParams &searchParams) const |
void | knnSearch (const ElementType *query_point, const size_t num_closest, IndexType *out_indices, DistanceType *out_distances_sq, const int nChecks_IGNORED=10) const |
size_t | radiusSearch (const ElementType *query_point, const DistanceType radius, std::vector< std::pair< IndexType, DistanceType > > &IndicesDists, const SearchParams &searchParams) const |
Public Attributes | |
Distance | distance |
Protected Types | |
typedef std::vector< Interval > | BoundingBox |
typedef BranchSt * | Branch |
typedef BranchStruct< NodePtr, DistanceType > | BranchSt |
typedef Node * | NodePtr |
Protected Attributes | |
const DatasetAdaptor & | dataset |
The source of our data. More... | |
int | dim |
Dimensionality of each data point. More... | |
const KDTreeSingleIndexAdaptorParams | index_params |
size_t | m_leaf_max_size |
size_t | m_size |
PooledAllocator | pool |
BoundingBox | root_bbox |
NodePtr | root_node |
std::vector< IndexType > | vind |
Private Member Functions | |
void | computeBoundingBox (BoundingBox &bbox) |
DistanceType | computeInitialDistances (const ElementType *vec, std::vector< DistanceType > &dists) const |
void | computeMinMax (IndexType *ind, IndexType count, int element, ElementType &min_elem, ElementType &max_elem) |
ElementType | dataset_get (size_t idx, int component) const |
Helper accessor to the dataset points: More... | |
NodePtr | divideTree (const IndexType left, const IndexType right, BoundingBox &bbox) |
void | init_vind () |
void | load_tree (FILE *stream, NodePtr &tree) |
void | loadIndex (FILE *stream) |
void | middleSplit (IndexType *ind, IndexType count, IndexType &index, int &cutfeat, DistanceType &cutval, const BoundingBox &bbox) |
void | middleSplit_ (IndexType *ind, IndexType count, IndexType &index, int &cutfeat, DistanceType &cutval, const BoundingBox &bbox) |
void | planeSplit (IndexType *ind, const IndexType count, int cutfeat, DistanceType cutval, IndexType &lim1, IndexType &lim2) |
void | save_tree (FILE *stream, NodePtr tree) |
void | saveIndex (FILE *stream) |
template<class RESULTSET > | |
void | searchLevel (RESULTSET &result_set, const ElementType *vec, const NodePtr node, DistanceType mindistsq, std::vector< DistanceType > &dists, const float epsError) const |
kd-tree index
Contains the k-d trees and other information for indexing a set of points for nearest-neighbor matching.
The class "DatasetAdaptor" must provide the following interface (can be non-virtual, inlined methods):
IndexType | Will be typically size_t or int |
Definition at line 604 of file nanoflann.hpp.
|
protected |
Definition at line 666 of file nanoflann.hpp.
|
protected |
Definition at line 693 of file nanoflann.hpp.
|
protected |
Definition at line 692 of file nanoflann.hpp.
typedef Distance::DistanceType nanoflann::KDTreeSingleIndexAdaptor< Distance, DatasetAdaptor, DIM, IndexType >::DistanceType |
Definition at line 608 of file nanoflann.hpp.
typedef Distance::ElementType nanoflann::KDTreeSingleIndexAdaptor< Distance, DatasetAdaptor, DIM, IndexType >::ElementType |
Definition at line 607 of file nanoflann.hpp.
|
protected |
Definition at line 658 of file nanoflann.hpp.
|
inline |
KDTree constructor
Params: inputData = dataset with the input features params = parameters passed to the kdtree algorithm (see http://code.google.com/p/nanoflann/ for help choosing the parameters)
Definition at line 717 of file nanoflann.hpp.
|
inline |
Standard destructor
Definition at line 735 of file nanoflann.hpp.
|
inline |
Builds the index
Definition at line 742 of file nanoflann.hpp.
|
inlineprivate |
Definition at line 881 of file nanoflann.hpp.
|
inlineprivate |
Definition at line 1100 of file nanoflann.hpp.
|
inlineprivate |
Definition at line 964 of file nanoflann.hpp.
|
inlineprivate |
Helper accessor to the dataset points:
Definition at line 851 of file nanoflann.hpp.
|
inlineprivate |
Create a tree node that subdivides the list of vecs from vind[first] to vind[last]. The routine is called recursively on each sublist. Place a pointer to this new tree node in the location pTree.
Params: pTree = the new node to create first = index of the first vector last = index of the last vector
Definition at line 914 of file nanoflann.hpp.
|
inline |
Find set of nearest neighbors to vec[0:dim-1]. Their indices are stored inside the result object.
Params: result = the result object in which the indices of the nearest-neighbors are stored vec = the vector for which to search the nearest neighbors
RESULTSET | Should be any ResultSet<DistanceType> |
Definition at line 789 of file nanoflann.hpp.
|
inlineprivate |
Make sure the auxiliary list vind has the same size than the current dataset, and re-generate if size has changed.
Definition at line 839 of file nanoflann.hpp.
|
inline |
Find the "num_closest" nearest neighbors to the query_point[0:dim-1]. Their indices are stored inside the result object.
Definition at line 805 of file nanoflann.hpp.
|
inlineprivate |
Definition at line 868 of file nanoflann.hpp.
|
inlineprivate |
Definition at line 1184 of file nanoflann.hpp.
|
inlineprivate |
Definition at line 975 of file nanoflann.hpp.
|
inlineprivate |
Definition at line 1020 of file nanoflann.hpp.
|
inlineprivate |
Subdivide the list of points by a plane perpendicular on axe corresponding to the 'cutfeat' dimension at 'cutval' position.
On return: dataset[ind[0..lim1-1]][cutfeat]<cutval dataset[ind[lim1..lim2-1]][cutfeat]==cutval dataset[ind[lim2..count]][cutfeat]>cutval
Definition at line 1071 of file nanoflann.hpp.
|
inline |
Find all the neighbors to query_point[0:dim-1] within a maximum radius. The output is given as a vector of pairs, of which the first element is a point index and the second the corresponding distance. Previous contents of IndicesDists are cleared.
If searchParams.sorted==true, the output list is sorted by ascending distances.
For a better performance, it is advisable to do a .reserve() on the vector if you have any wild guess about the number of expected matches.
Definition at line 824 of file nanoflann.hpp.
|
inlineprivate |
Definition at line 856 of file nanoflann.hpp.
|
inlineprivate |
Definition at line 1174 of file nanoflann.hpp.
|
inlineprivate |
Performs an exact search in the tree starting from a node.
RESULTSET | Should be any ResultSet<DistanceType> |
Definition at line 1124 of file nanoflann.hpp.
|
inline |
Returns size of index.
Definition at line 752 of file nanoflann.hpp.
|
inline |
Computes the inde memory usage Returns: memory used by the index
Definition at line 769 of file nanoflann.hpp.
|
inline |
Returns the length of an index feature.
Definition at line 760 of file nanoflann.hpp.
|
protected |
The source of our data.
The dataset used by this index
Definition at line 622 of file nanoflann.hpp.
|
protected |
Dimensionality of each data point.
Definition at line 627 of file nanoflann.hpp.
Distance nanoflann::KDTreeSingleIndexAdaptor< Distance, DatasetAdaptor, DIM, IndexType >::distance |
Definition at line 708 of file nanoflann.hpp.
|
protected |
Definition at line 624 of file nanoflann.hpp.
|
protected |
Definition at line 616 of file nanoflann.hpp.
|
protected |
Definition at line 626 of file nanoflann.hpp.
|
protected |
Pooled memory allocator.
Using a pooled memory allocator is more efficient than allocating memory directly when there is a large number small of memory allocations.
Definition at line 704 of file nanoflann.hpp.
|
protected |
Definition at line 695 of file nanoflann.hpp.
|
protected |
Array of k-d trees used to find neighbours.
Definition at line 691 of file nanoflann.hpp.
|
protected |
Array of indices to vectors in the dataset.
Definition at line 614 of file nanoflann.hpp.