|
| | KDTreeSingleIndexAdaptor (const KDTreeSingleIndexAdaptor< Distance, DatasetAdaptor, DIM, index_t > &)=delete |
| template<class... Args> |
| | KDTreeSingleIndexAdaptor (const Dimension dimensionality, const DatasetAdaptor &inputData, const KDTreeSingleIndexAdaptorParams ¶ms, Args &&... args) |
|
| KDTreeSingleIndexAdaptor (const Dimension dimensionality, const DatasetAdaptor &inputData, const KDTreeSingleIndexAdaptorParams ¶ms={}) |
| void | buildIndex () |
| void | init_vind () |
|
bool | contains (const BoundingBox &bbox, IndexType idx) const |
| void | saveIndex (std::ostream &stream) const |
| void | loadIndex (std::istream &stream) |
| template<typename RESULTSET> |
| bool | findNeighbors (RESULTSET &result, const ElementType *vec, const SearchParameters &searchParams={}) const |
| template<typename RESULTSET> |
| NANOFLANN_NODISCARD Size | findWithinBox (RESULTSET &result, const BoundingBox &bbox) const |
| NANOFLANN_NODISCARD Size | knnSearch (const ElementType *query_point, const Size num_closest, IndexType *out_indices, DistanceType *out_distances) const |
| NANOFLANN_NODISCARD Size | radiusSearch (const ElementType *query_point, const DistanceType &radius, std::vector< ResultItem< IndexType, DistanceType > > &IndicesDists, const SearchParameters &searchParams={}) const |
| template<class SEARCH_CALLBACK> |
| NANOFLANN_NODISCARD Size | radiusSearchCustomCallback (const ElementType *query_point, SEARCH_CALLBACK &resultSet, const SearchParameters &searchParams={}) const |
| NANOFLANN_NODISCARD Size | rknnSearch (const ElementType *query_point, const Size num_closest, IndexType *out_indices, DistanceType *out_distances, const DistanceType &radius) const |
| void | freeIndex (KDTreeSingleIndexAdaptor< Distance, DatasetAdaptor, -1, uint32_t > &obj) |
| NANOFLANN_NODISCARD Size | size (const KDTreeSingleIndexAdaptor< Distance, DatasetAdaptor, -1, uint32_t > &obj) const noexcept |
| NANOFLANN_NODISCARD Size | veclen (const KDTreeSingleIndexAdaptor< Distance, DatasetAdaptor, -1, uint32_t > &obj) const noexcept |
|
ElementType | dataset_get (const KDTreeSingleIndexAdaptor< Distance, DatasetAdaptor, -1, uint32_t > &obj, IndexType element, Dimension component) const |
| | Helper accessor to the dataset points:
|
| NANOFLANN_NODISCARD Size | usedMemory (const KDTreeSingleIndexAdaptor< Distance, DatasetAdaptor, -1, uint32_t > &obj) const |
| void | computeMinMax (const KDTreeSingleIndexAdaptor< Distance, DatasetAdaptor, -1, uint32_t > &obj, Offset ind, Size count, Dimension element, ElementType &min_elem, ElementType &max_elem) const |
| NANOFLANN_NODISCARD bool | isActive (IndexType) const |
| void | computeBoundingBox (BoundingBox &bbox) |
| bool | searchLevel (RESULTSET &result_set, const ElementType *vec, const NodePtr node, DistanceType mindist, distance_vector_t &dists, const DistanceType epsError) const |
| bool | makeNode (KDTreeSingleIndexAdaptor< Distance, DatasetAdaptor, -1, uint32_t > &obj, NodePtr node, const Offset left, const Offset right, BoundingBox &bbox, Offset &idx, Dimension &cutfeat, DistanceType &cutval) |
| void | finalizeSplitNode (KDTreeSingleIndexAdaptor< Distance, DatasetAdaptor, -1, uint32_t > &obj, NodePtr node, const Dimension cutfeat, const BoundingBox &left_bbox, const BoundingBox &right_bbox, BoundingBox &bbox) |
|
NodePtr | divideTree (KDTreeSingleIndexAdaptor< Distance, DatasetAdaptor, -1, uint32_t > &obj, const Offset left, const Offset right, BoundingBox &bbox) |
| NodePtr | divideTreeConcurrent (KDTreeSingleIndexAdaptor< Distance, DatasetAdaptor, -1, uint32_t > &obj, const Offset left, const Offset right, BoundingBox &bbox, std::atomic< unsigned int > &thread_count, std::mutex &mutex) |
|
void | middleSplit_ (const KDTreeSingleIndexAdaptor< Distance, DatasetAdaptor, -1, uint32_t > &obj, const Offset ind, const Size count, Offset &index, Dimension &cutfeat, DistanceType &cutval, const BoundingBox &bbox) |
| void | planeSplit (const KDTreeSingleIndexAdaptor< Distance, DatasetAdaptor, -1, uint32_t > &obj, const Offset ind, const Size count, const Dimension cutfeat, const DistanceType &cutval, Offset &lim1, Offset &lim2) |
|
DistanceType | computeInitialDistances (const KDTreeSingleIndexAdaptor< Distance, DatasetAdaptor, -1, uint32_t > &obj, const ElementType *vec, distance_vector_t &dists) const |
| void | saveIndex (const KDTreeSingleIndexAdaptor< Distance, DatasetAdaptor, -1, uint32_t > &obj, std::ostream &stream) const |
| void | loadIndex (KDTreeSingleIndexAdaptor< Distance, DatasetAdaptor, -1, uint32_t > &obj, std::istream &stream) |
template<typename Distance, class DatasetAdaptor, int32_t DIM = -1, typename index_t = uint32_t>
class nanoflann::KDTreeSingleIndexAdaptor< Distance, DatasetAdaptor, DIM, index_t >
kd-tree static 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):
size_t kdtree_get_point_count() const { ... }
T kdtree_get_pt(const size_t idx, const size_t dim) const { ... }
bbox computation loop.
in "bb" so it can be avoided to redo it again.
for point clouds) template <class BBOX> bool kdtree_get_bbox(BBOX &bb) const
{
bb[0].low = ...; bb[0].high = ...;
bb[1].low = ...; bb[1].high = ...;
...
return true;
}
- Template Parameters
-
| DatasetAdaptor | The user-provided adaptor, which must be ensured to have a lifetime equal or longer than the instance of this class. |
| Distance | The distance metric to use: nanoflann::metric_L1, nanoflann::metric_L2, nanoflann::metric_L2_Simple, etc. |
| DIM | Dimensionality of data points (e.g. 3 for 3D points) |
| IndexType | Will be typically size_t or int |
- Note
- Threading guarantees:
- Index build: passing n_thread_build > 1 in the params parallelizes the build using std::async (unless NANOFLANN_NO_THREADS is defined, in which case requesting more than one thread throws).
- Queries (findNeighbors, knnSearch, radiusSearch, rknnSearch) are const and thread-safe for concurrent readers: multiple threads may query the same index simultaneously, as long as no thread is concurrently (re)building or modifying it.
- The internal PooledAllocator is NOT thread-safe; building an index from multiple threads, or mixing queries with a concurrent build, is not supported.