NearestNeighborsFLANN.h
63 FLANNDistance(const typename NearestNeighbors<_T>::DistanceFunction &distFun) : distFun_(distFun)
68 ResultType operator()(Iterator1 a, Iterator2 b, size_t /*size*/, ResultType /*worst_dist*/ = -1) const
116 void setDistanceFunction(const typename NearestNeighbors<_T>::DistanceFunction &distFun) override
154 {
209 std::vector<std::vector<size_t>> indices;
294 std::vector<_T> data;
301 }
336 : NearestNeighborsFLANN<_T, _Dist>(std::shared_ptr<flann::LinearIndexParams>(new flann::LinearIndexParams()))
337 {
347 new flann::HierarchicalClusteringIndexParams()))
void nearestR(const _T &data, double radius, std::vector< _T > &nbh) const override
Return the nearest neighbors within distance radius in sorted order if searchParams_....
Definition: NearestNeighborsFLANN.h:237
virtual void setSearchParams(const flann::SearchParams &searchParams)
Set the FLANN parameters to be used during nearest neighbor searches.
Definition: NearestNeighborsFLANN.h:287
void add(const _T &data) override
Add an element to the datastructure.
Definition: NearestNeighborsFLANN.h:154
flann::SearchParams searchParams_
The parameters used to seach for nearest neighbors.
Definition: NearestNeighborsFLANN.h:347
bool remove(const _T &data) override
Remove an element from the datastructure.
Definition: NearestNeighborsFLANN.h:192
std::function< double(const _T &, const _T &)> DistanceFunction
The definition of a distance function.
Definition: NearestNeighbors.h:115
void rebuildIndex(unsigned int capacity=0)
Rebuild the nearest neighbor data structure (necessary when changing the distance function or index p...
Definition: NearestNeighborsFLANN.h:322
flann::Index< _Dist > * index_
The FLANN index (the actual index type depends on params_).
Definition: NearestNeighborsFLANN.h:340
void createIndex(const flann::Matrix< _T > &mat)
Internal function to construct nearest neighbor data structure with initial elements stored in mat.
Definition: NearestNeighborsFLANN.h:314
_T nearest(const _T &data) const override
Get the nearest neighbor of a point.
Definition: NearestNeighborsFLANN.h:209
Abstract representation of a container that can perform nearest neighbors queries.
Definition: NearestNeighbors.h:79
unsigned int dimension_
If each element has an array-like structure that is exposed to FLANN, then the dimension_ needs to be...
Definition: NearestNeighborsFLANN.h:352
bool reportsSortedResults() const override
Return true if the solutions reported by this data structure are sorted, when calling nearestK / near...
Definition: NearestNeighborsFLANN.h:143
void list(std::vector< _T > &data) const override
Get all the elements in the datastructure.
Definition: NearestNeighborsFLANN.h:254
Wrapper class for nearest neighbor data structures in the FLANN library.
Definition: NearestNeighborsFLANN.h:119
flann::SearchParams & getSearchParams()
Get the FLANN parameters used during nearest neighbor searches.
Definition: NearestNeighborsFLANN.h:294
virtual void setIndexParams(const std::shared_ptr< flann::IndexParams > ¶ms)
Set the FLANN index parameters.
Definition: NearestNeighborsFLANN.h:273
std::size_t size() const override
Get the number of elements in the datastructure.
Definition: NearestNeighborsFLANN.h:249
std::vector< _T > data_
vector of data stored in FLANN's index. FLANN only indexes references, so we need store the original ...
Definition: NearestNeighborsFLANN.h:337
std::shared_ptr< flann::IndexParams > params_
The FLANN index parameters. This contains both the type of index and the parameters for that type.
Definition: NearestNeighborsFLANN.h:344
virtual const std::shared_ptr< flann::IndexParams > & getIndexParams() const
Get the FLANN parameters used to build the current index.
Definition: NearestNeighborsFLANN.h:280
void nearestK(const _T &data, std::size_t k, std::vector< _T > &nbh) const override
Return the k nearest neighbors in sorted order if searchParams_.sorted==true (the default)
Definition: NearestNeighborsFLANN.h:224
Main namespace. Contains everything in this library.
Definition: MultiLevelPlanarManipulatorDemo.cpp:65
virtual void setDistanceFunction(const DistanceFunction &distFun)
Set the distance function to use.
Definition: NearestNeighbors.h:122