![]() |
OpenLB 1.7
|
kd-tree index More...
#include <nanoflann.hpp>
Classes | |
struct | BranchStruct |
This record represents a branch point when finding neighbors in the tree. More... | |
struct | Interval |
struct | Node |
Public Types | |
typedef Distance::ElementType | ElementType |
typedef Distance::DistanceType | DistanceType |
Public Member Functions | |
KDTreeSingleIndexAdaptor (const int dimensionality, const DatasetAdaptor &inputData, const KDTreeSingleIndexAdaptorParams ¶ms=KDTreeSingleIndexAdaptorParams()) | |
KDTree constructor. | |
void | init () |
~KDTreeSingleIndexAdaptor () | |
Standard destructor. | |
void | freeIndex () |
Frees the previously-built index. | |
void | buildIndex () |
Builds the index. | |
size_t | size () const |
Returns size of index. | |
size_t | veclen () const |
Returns the length of an index feature. | |
size_t | usedMemory () const |
Computes the inde memory usage Returns: memory used by the index. | |
void | saveIndex (FILE *stream) |
Stores the index in a binary file. | |
void | loadIndex (FILE *stream) |
Loads a previous index from a binary file. | |
Query methods | |
template<typename RESULTSET > | |
void | findNeighbors (RESULTSET &result, const ElementType *vec, const SearchParams &searchParams) const |
Find set of nearest neighbors to vec[0:dim-1]. | |
void | knnSearch (const ElementType *query_point, const size_t num_closest, IndexType *out_indices, DistanceType *out_distances_sq, const int=10) const |
Find the "num_closest" nearest neighbors to the query_point[0:dim-1]. | |
size_t | radiusSearch (const ElementType *query_point, const DistanceType radius, std::vector< std::pair< IndexType, DistanceType > > &IndicesDists, const SearchParams &searchParams) const |
Find all the neighbors to query_point[0:dim-1] within a maximum radius. | |
size_t | radiusSearch (const ElementType *query_point, const DistanceType radius, std::list< IndexType > &IndicesDists, const SearchParams &searchParams) const |
Public Attributes | |
Distance | distance |
Protected Types | |
typedef Node * | NodePtr |
typedef array_or_vector_selector< DIM, Interval >::container_t | BoundingBox |
Define "BoundingBox" as a fixed-size or variable-size container depending on "DIM". | |
typedef array_or_vector_selector< DIM, DistanceType >::container_t | distance_vector_t |
Define "distance_vector_t" as a fixed-size or variable-size container depending on "DIM". | |
typedef BranchStruct< NodePtr, DistanceType > | BranchSt |
typedef BranchSt * | Branch |
Protected Attributes | |
std::vector< IndexType > | vind |
Array of indices to vectors in the dataset. | |
size_t | m_leaf_max_size |
const DatasetAdaptor & | dataset |
The dataset used by this index. | |
const KDTreeSingleIndexAdaptorParams | index_params |
size_t | m_size |
int | dim |
Dimensionality of each data point. | |
NodePtr | root_node |
Array of k-d trees used to find neighbours. | |
BoundingBox | root_bbox |
PooledAllocator | pool |
Pooled memory allocator. | |
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):
DatasetAdaptor | The user-provided adaptor (see comments above). |
Distance | The distance metric to use: nanoflann::metric_L1, nanoflann::metric_L2, nanoflann::metric_L2_Simple, etc. |
IndexType | Will be typically size_t or int |
Definition at line 869 of file nanoflann.hpp.
|
protected |
Define "BoundingBox" as a fixed-size or variable-size container depending on "DIM".
Definition at line 928 of file nanoflann.hpp.
|
protected |
Definition at line 959 of file nanoflann.hpp.
|
protected |
Definition at line 958 of file nanoflann.hpp.
|
protected |
Define "distance_vector_t" as a fixed-size or variable-size container depending on "DIM".
Definition at line 931 of file nanoflann.hpp.
typedef Distance::DistanceType nanoflann::KDTreeSingleIndexAdaptor< Distance, DatasetAdaptor, DIM, IndexType >::DistanceType |
Definition at line 876 of file nanoflann.hpp.
typedef Distance::ElementType nanoflann::KDTreeSingleIndexAdaptor< Distance, DatasetAdaptor, DIM, IndexType >::ElementType |
Definition at line 875 of file nanoflann.hpp.
|
protected |
Definition at line 921 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 983 of file nanoflann.hpp.
|
inline |
|
inline |
Builds the index.
Definition at line 1026 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 1073 of file nanoflann.hpp.
References nanoflann::CArray< T, N >::assign(), and nanoflann::SearchParams::eps.
|
inline |
Frees the previously-built index.
Automatically called within buildIndex().
Definition at line 1018 of file nanoflann.hpp.
|
inline |
Definition at line 1004 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 1093 of file nanoflann.hpp.
References nanoflann::KNNResultSet< DistanceType, IndexType, CountType >::init().
|
inline |
Loads a previous index from a binary file.
IMPORTANT NOTE: The set of data points is NOT stored in the file, so the index object must be constructed associated to the same source of data points used while building the index. See the example: examples/saveload_example.cpp
Definition at line 1507 of file nanoflann.hpp.
References nanoflann::load_value().
|
inline |
Definition at line 1127 of file nanoflann.hpp.
References nanoflann::RadiusResultList< DistanceType, IndexType >::size(), and nanoflann::SearchParams::sorted.
|
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 1114 of file nanoflann.hpp.
References nanoflann::RadiusResultSet< DistanceType, IndexType >::size(), and nanoflann::SearchParams::sorted.
|
inline |
Stores the index in a binary file.
IMPORTANT NOTE: The set of data points is NOT stored in the file, so when loading the index object it must be constructed associated to the same source of data points used while building it. See the example: examples/saveload_example.cpp
Definition at line 1494 of file nanoflann.hpp.
References nanoflann::save_value().
|
inline |
Returns size of index.
Definition at line 1038 of file nanoflann.hpp.
|
inline |
Computes the inde memory usage Returns: memory used by the index.
Definition at line 1053 of file nanoflann.hpp.
|
inline |
Returns the length of an index feature.
Definition at line 1045 of file nanoflann.hpp.
|
protected |
The dataset used by this index.
The source of our data
Definition at line 889 of file nanoflann.hpp.
|
protected |
Dimensionality of each data point.
Definition at line 894 of file nanoflann.hpp.
Distance nanoflann::KDTreeSingleIndexAdaptor< Distance, DatasetAdaptor, DIM, IndexType >::distance |
Definition at line 974 of file nanoflann.hpp.
|
protected |
Definition at line 891 of file nanoflann.hpp.
|
protected |
Definition at line 884 of file nanoflann.hpp.
|
protected |
Definition at line 893 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 970 of file nanoflann.hpp.
|
protected |
Definition at line 961 of file nanoflann.hpp.
|
protected |
Array of k-d trees used to find neighbours.
Definition at line 957 of file nanoflann.hpp.
|
protected |
Array of indices to vectors in the dataset.
Definition at line 882 of file nanoflann.hpp.