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
336 : NearestNeighborsFLANN<_T, _Dist>(std::shared_ptr<flann::LinearIndexParams>(new flann::LinearIndexParams()))
Wrapper class to allow FLANN access to the NearestNeighbors::distFun_ callback function.
Definition: NearestNeighborsFLANN.h:58
Wrapper class for nearest neighbor data structures in the FLANN library.
Definition: NearestNeighborsFLANN.h:88
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:205
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:312
bool reportsSortedResults() const override
Return true if the solutions reported by this data structure are sorted, when calling nearestK / near...
Definition: NearestNeighborsFLANN.h:111
virtual const std::shared_ptr< flann::IndexParams > & getIndexParams() const
Get the FLANN parameters used to build the current index.
Definition: NearestNeighborsFLANN.h:248
void add(const _T &data) override
Add an element to the datastructure.
Definition: NearestNeighborsFLANN.h:122
flann::SearchParams & getSearchParams()
Get the FLANN parameters used during nearest neighbor searches.
Definition: NearestNeighborsFLANN.h:262
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:305
virtual void setSearchParams(const flann::SearchParams &searchParams)
Set the FLANN parameters to be used during nearest neighbor searches.
Definition: NearestNeighborsFLANN.h:255
void list(std::vector< _T > &data) const override
Get all the elements in the datastructure.
Definition: NearestNeighborsFLANN.h:222
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:320
const flann::SearchParams & getSearchParams() const
Get the FLANN parameters used during nearest neighbor searches.
Definition: NearestNeighborsFLANN.h:269
void rebuildIndex(unsigned int capacity=0)
Rebuild the nearest neighbor data structure (necessary when changing the distance function or index p...
Definition: NearestNeighborsFLANN.h:290
virtual void setIndexParams(const std::shared_ptr< flann::IndexParams > ¶ms)
Set the FLANN index parameters.
Definition: NearestNeighborsFLANN.h:241
_T nearest(const _T &data) const override
Get the nearest neighbor of a point.
Definition: NearestNeighborsFLANN.h:177
bool remove(const _T &data) override
Remove an element from the datastructure.
Definition: NearestNeighborsFLANN.h:160
void createIndex(const flann::Matrix< _T > &mat)
Internal function to construct nearest neighbor data structure with initial elements stored in mat.
Definition: NearestNeighborsFLANN.h:282
flann::SearchParams searchParams_
The parameters used to seach for nearest neighbors.
Definition: NearestNeighborsFLANN.h:315
flann::Index< _Dist > * index_
The FLANN index (the actual index type depends on params_).
Definition: NearestNeighborsFLANN.h:308
std::size_t size() const override
Get the number of elements in the datastructure.
Definition: NearestNeighborsFLANN.h:217
void add(const std::vector< _T > &data) override
Add a vector of points.
Definition: NearestNeighborsFLANN.h:137
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:192
Abstract representation of a container that can perform nearest neighbors queries.
Definition: NearestNeighbors.h:48
std::function< double(const _T &, const _T &)> DistanceFunction
The definition of a distance function.
Definition: NearestNeighbors.h:51
virtual void setDistanceFunction(const DistanceFunction &distFun)
Set the distance function to use.
Definition: NearestNeighbors.h:58