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
234 }
335 : NearestNeighborsFLANN<_T, _Dist>(std::shared_ptr<flann::LinearIndexParams>(new flann::LinearIndexParams()))
337 }
349 };
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:234
virtual void setSearchParams(const flann::SearchParams &searchParams)
Set the FLANN parameters to be used during nearest neighbor searches.
Definition: NearestNeighborsFLANN.h:284
void add(const _T &data) override
Add an element to the datastructure.
Definition: NearestNeighborsFLANN.h:152
flann::SearchParams searchParams_
The parameters used to seach for nearest neighbors.
Definition: NearestNeighborsFLANN.h:344
bool remove(const _T &data) override
Remove an element from the datastructure.
Definition: NearestNeighborsFLANN.h:189
std::function< double(const _T &, const _T &)> DistanceFunction
The definition of a distance function.
Definition: NearestNeighbors.h:112
void rebuildIndex(unsigned int capacity=0)
Rebuild the nearest neighbor data structure (necessary when changing the distance function or index p...
Definition: NearestNeighborsFLANN.h:319
flann::Index< _Dist > * index_
The FLANN index (the actual index type depends on params_).
Definition: NearestNeighborsFLANN.h:337
void createIndex(const flann::Matrix< _T > &mat)
Internal function to construct nearest neighbor data structure with initial elements stored in mat.
Definition: NearestNeighborsFLANN.h:311
_T nearest(const _T &data) const override
Get the nearest neighbor of a point.
Definition: NearestNeighborsFLANN.h:206
Abstract representation of a container that can perform nearest neighbors queries.
Definition: NearestNeighbors.h:77
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:349
bool reportsSortedResults() const override
Return true if the solutions reported by this data structure are sorted, when calling nearestK / near...
Definition: NearestNeighborsFLANN.h:141
void list(std::vector< _T > &data) const override
Get all the elements in the datastructure.
Definition: NearestNeighborsFLANN.h:251
Wrapper class for nearest neighbor data structures in the FLANN library.
Definition: NearestNeighborsFLANN.h:117
flann::SearchParams & getSearchParams()
Get the FLANN parameters used during nearest neighbor searches.
Definition: NearestNeighborsFLANN.h:291
virtual void setIndexParams(const std::shared_ptr< flann::IndexParams > ¶ms)
Set the FLANN index parameters.
Definition: NearestNeighborsFLANN.h:270
std::size_t size() const override
Get the number of elements in the datastructure.
Definition: NearestNeighborsFLANN.h:246
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:334
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:341
virtual const std::shared_ptr< flann::IndexParams > & getIndexParams() const
Get the FLANN parameters used to build the current index.
Definition: NearestNeighborsFLANN.h:277
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:221
virtual void setDistanceFunction(const DistanceFunction &distFun)
Set the distance function to use.
Definition: NearestNeighbors.h:119