Template Class KDTreeSingleIndexDynamicAdaptor
Defined in File nanoflann.hpp
Class Documentation
-
template<typename Distance, class DatasetAdaptor, int32_t DIM = -1, typename IndexType = uint32_t>
class KDTreeSingleIndexDynamicAdaptor kd-tree dynaimic index
class to create multiple static index and merge their results to behave as single dynamic index as proposed in Logarithmic Approach.
Example of usage: examples/dynamic_pointcloud_example.cpp
- Template Parameters:
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.
DIM – Dimensionality of data points (e.g. 3 for 3D points)
IndexType – Will be typically size_t or int
Public Types
-
using Offset = typename KDTreeSingleIndexDynamicAdaptor_<Distance, DatasetAdaptor, DIM>::Offset
-
using Size = typename KDTreeSingleIndexDynamicAdaptor_<Distance, DatasetAdaptor, DIM>::Size
-
using Dimension = typename KDTreeSingleIndexDynamicAdaptor_<Distance, DatasetAdaptor, DIM>::Dimension
Public Functions
-
inline const std::vector<index_container_t> &getAllIndices() const
Get a const ref to the internal list of indices; the number of indices is adapted dynamically as the dataset grows in size.
-
inline explicit KDTreeSingleIndexDynamicAdaptor(const int dimensionality, const DatasetAdaptor &inputData, const KDTreeSingleIndexAdaptorParams ¶ms = KDTreeSingleIndexAdaptorParams(), const size_t maximumPointCount = 1000000000U)
KDTree constructor
Refer to docs in README.md or online in https://github.com/jlblancoc/nanoflann
The KD-Tree point dimension (the length of each point in the datase, e.g. 3 for 3D points) is determined by means of:
The DIM template parameter if >0 (highest priority)
Otherwise, the dimensionality parameter of this constructor.
- Parameters:
inputData – Dataset with the input features. Its lifetime must be equal or longer than that of the instance of this class.
params – Basically, the maximum leaf node size
-
explicit KDTreeSingleIndexDynamicAdaptor(const KDTreeSingleIndexDynamicAdaptor<Distance, DatasetAdaptor, DIM, IndexType>&) = delete
Deleted copy constructor
-
inline void addPoints(IndexType start, IndexType end)
Add points to the set, Inserts all points from [start, end]
-
inline void removePoint(size_t idx)
Remove a point from the set (Lazy Deletion)
-
template<typename RESULTSET>
inline bool findNeighbors(RESULTSET &result, const ElementType *vec, const SearchParameters &searchParams = {}) const 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
See also
knnSearch, radiusSearch
Note
If L2 norms are used, all returned distances are actually squared distances.
- Template Parameters:
RESULTSET – Should be any ResultSet<DistanceType>
- Returns:
True if the requested neighbors could be found.
Protected Types
-
using index_container_t = KDTreeSingleIndexDynamicAdaptor_<Distance, DatasetAdaptor, DIM, IndexType>
Protected Attributes
-
const DatasetAdaptor &dataset_
The source of our data.
The dataset used by this index
-
std::vector<int> treeIndex_
treeIndex[idx] is the index of tree in which point at idx is stored. treeIndex[idx]=-1 means that point has been removed.
-
std::unordered_set<int> removedPoints_
-
KDTreeSingleIndexAdaptorParams index_params_
-
std::vector<index_container_t> index_