Loading...
Searching...
No Matches
ompl::NearestNeighborsFLANN< _T, _Dist > Class Template Reference

Wrapper class for nearest neighbor data structures in the FLANN library. More...

#include <ompl/datastructures/NearestNeighborsFLANN.h>

Inheritance diagram for ompl::NearestNeighborsFLANN< _T, _Dist >:

Public Member Functions

 NearestNeighborsFLANN (std::shared_ptr< flann::IndexParams > params)
 
void clear () override
 Clear the datastructure.
 
bool reportsSortedResults () const override
 Return true if the solutions reported by this data structure are sorted, when calling nearestK / nearestR.
 
void setDistanceFunction (const typename NearestNeighbors< _T >::DistanceFunction &distFun) override
 
void add (const _T &data) override
 Add an element to the datastructure.
 
void add (const std::vector< _T > &data) override
 Add a vector of points.
 
bool remove (const _T &data) override
 Remove an element from the datastructure.
 
_T nearest (const _T &data) const override
 Get the nearest neighbor of a point.
 
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)
 
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_.sorted==true (the default)
 
std::size_t size () const override
 Get the number of elements in the datastructure.
 
void list (std::vector< _T > &data) const override
 Get all the elements in the datastructure.
 
virtual void setIndexParams (const std::shared_ptr< flann::IndexParams > &params)
 Set the FLANN index parameters.
 
virtual const std::shared_ptr< flann::IndexParams > & getIndexParams () const
 Get the FLANN parameters used to build the current index.
 
virtual void setSearchParams (const flann::SearchParams &searchParams)
 Set the FLANN parameters to be used during nearest neighbor searches.
 
flann::SearchParams & getSearchParams ()
 Get the FLANN parameters used during nearest neighbor searches.
 
const flann::SearchParams & getSearchParams () const
 Get the FLANN parameters used during nearest neighbor searches.
 
unsigned int getContainerSize () const
 
- Public Member Functions inherited from ompl::NearestNeighbors< _T >
virtual void setDistanceFunction (const DistanceFunction &distFun)
 Set the distance function to use.
 
const DistanceFunctiongetDistanceFunction () const
 Get the distance function used.
 

Protected Member Functions

void createIndex (const flann::Matrix< _T > &mat)
 Internal function to construct nearest neighbor data structure with initial elements stored in mat.
 
void rebuildIndex (unsigned int capacity=0)
 Rebuild the nearest neighbor data structure (necessary when changing the distance function or index parameters).
 
void createIndex (const flann::Matrix< double > &mat)
 

Protected Attributes

std::vector< _T > data_
 vector of data stored in FLANN's index. FLANN only indexes references, so we need store the original data.
 
flann::Index< _Dist > * index_
 The FLANN index (the actual index type depends on params_).
 
std::shared_ptr< flann::IndexParams > params_
 The FLANN index parameters. This contains both the type of index and the parameters for that type.
 
flann::SearchParams searchParams_
 The parameters used to seach for nearest neighbors.
 
unsigned int dimension_
 If each element has an array-like structure that is exposed to FLANN, then the dimension_ needs to be set to the length of this array.
 
- Protected Attributes inherited from ompl::NearestNeighbors< _T >
DistanceFunction distFun_
 The used distance function.
 

Additional Inherited Members

- Public Types inherited from ompl::NearestNeighbors< _T >
using DistanceFunction = std::function< double(const _T &, const _T &)>
 The definition of a distance function.
 

Detailed Description

template<typename _T, typename _Dist = FLANNDistance<_T>>
class ompl::NearestNeighborsFLANN< _T, _Dist >

Wrapper class for nearest neighbor data structures in the FLANN library.

See: M. Muja and D.G. Lowe, "Fast Approximate Nearest Neighbors with Automatic Algorithm Configuration", in International Conference on Computer Vision Theory and Applications (VISAPP'09), 2009. https://github.com/mariusmuja/flann

Definition at line 87 of file NearestNeighborsFLANN.h.

Constructor & Destructor Documentation

◆ NearestNeighborsFLANN()

template<typename _T , typename _Dist = FLANNDistance<_T>>
ompl::NearestNeighborsFLANN< _T, _Dist >::NearestNeighborsFLANN ( std::shared_ptr< flann::IndexParams >  params)
inline

Definition at line 90 of file NearestNeighborsFLANN.h.

◆ ~NearestNeighborsFLANN()

template<typename _T , typename _Dist = FLANNDistance<_T>>
ompl::NearestNeighborsFLANN< _T, _Dist >::~NearestNeighborsFLANN ( )
inlineoverride

Definition at line 95 of file NearestNeighborsFLANN.h.

Member Function Documentation

◆ add() [1/2]

template<typename _T , typename _Dist = FLANNDistance<_T>>
void ompl::NearestNeighborsFLANN< _T, _Dist >::add ( const _T &  data)
inlineoverridevirtual

Add an element to the datastructure.

Implements ompl::NearestNeighbors< _T >.

Definition at line 122 of file NearestNeighborsFLANN.h.

◆ add() [2/2]

template<typename _T , typename _Dist = FLANNDistance<_T>>
void ompl::NearestNeighborsFLANN< _T, _Dist >::add ( const std::vector< _T > &  data)
inlineoverridevirtual

Add a vector of points.

Reimplemented from ompl::NearestNeighbors< _T >.

Definition at line 137 of file NearestNeighborsFLANN.h.

◆ clear()

template<typename _T , typename _Dist = FLANNDistance<_T>>
void ompl::NearestNeighborsFLANN< _T, _Dist >::clear ( )
inlineoverridevirtual

Clear the datastructure.

Implements ompl::NearestNeighbors< _T >.

Definition at line 101 of file NearestNeighborsFLANN.h.

◆ createIndex() [1/2]

template<typename _T , typename _Dist = FLANNDistance<_T>>
void ompl::NearestNeighborsFLANN< _T, _Dist >::createIndex ( const flann::Matrix< _T > &  mat)
inlineprotected

Internal function to construct nearest neighbor data structure with initial elements stored in mat.

Definition at line 282 of file NearestNeighborsFLANN.h.

◆ createIndex() [2/2]

void ompl::NearestNeighborsFLANN< double, flann::L2< double > >::createIndex ( const flann::Matrix< double > &  mat)
inlineprotected

Definition at line 324 of file NearestNeighborsFLANN.h.

◆ getContainerSize()

template<typename _T , typename _Dist = FLANNDistance<_T>>
unsigned int ompl::NearestNeighborsFLANN< _T, _Dist >::getContainerSize ( ) const
inline

Definition at line 274 of file NearestNeighborsFLANN.h.

◆ getIndexParams()

template<typename _T , typename _Dist = FLANNDistance<_T>>
virtual const std::shared_ptr< flann::IndexParams > & ompl::NearestNeighborsFLANN< _T, _Dist >::getIndexParams ( ) const
inlinevirtual

Get the FLANN parameters used to build the current index.

Definition at line 248 of file NearestNeighborsFLANN.h.

◆ getSearchParams() [1/2]

template<typename _T , typename _Dist = FLANNDistance<_T>>
flann::SearchParams & ompl::NearestNeighborsFLANN< _T, _Dist >::getSearchParams ( )
inline

Get the FLANN parameters used during nearest neighbor searches.

Definition at line 262 of file NearestNeighborsFLANN.h.

◆ getSearchParams() [2/2]

template<typename _T , typename _Dist = FLANNDistance<_T>>
const flann::SearchParams & ompl::NearestNeighborsFLANN< _T, _Dist >::getSearchParams ( ) const
inline

Get the FLANN parameters used during nearest neighbor searches.

Definition at line 269 of file NearestNeighborsFLANN.h.

◆ list()

template<typename _T , typename _Dist = FLANNDistance<_T>>
void ompl::NearestNeighborsFLANN< _T, _Dist >::list ( std::vector< _T > &  data) const
inlineoverridevirtual

Get all the elements in the datastructure.

Implements ompl::NearestNeighbors< _T >.

Definition at line 222 of file NearestNeighborsFLANN.h.

◆ nearest()

template<typename _T , typename _Dist = FLANNDistance<_T>>
_T ompl::NearestNeighborsFLANN< _T, _Dist >::nearest ( const _T &  data) const
inlineoverridevirtual

Get the nearest neighbor of a point.

Implements ompl::NearestNeighbors< _T >.

Definition at line 177 of file NearestNeighborsFLANN.h.

◆ nearestK()

template<typename _T , typename _Dist = FLANNDistance<_T>>
void ompl::NearestNeighborsFLANN< _T, _Dist >::nearestK ( const _T &  data,
std::size_t  k,
std::vector< _T > &  nbh 
) const
inlineoverridevirtual

Return the k nearest neighbors in sorted order if searchParams_.sorted==true (the default)

Implements ompl::NearestNeighbors< _T >.

Definition at line 192 of file NearestNeighborsFLANN.h.

◆ nearestR()

template<typename _T , typename _Dist = FLANNDistance<_T>>
void ompl::NearestNeighborsFLANN< _T, _Dist >::nearestR ( const _T &  data,
double  radius,
std::vector< _T > &  nbh 
) const
inlineoverridevirtual

Return the nearest neighbors within distance radius in sorted order if searchParams_.sorted==true (the default)

Implements ompl::NearestNeighbors< _T >.

Definition at line 205 of file NearestNeighborsFLANN.h.

◆ rebuildIndex()

template<typename _T , typename _Dist = FLANNDistance<_T>>
void ompl::NearestNeighborsFLANN< _T, _Dist >::rebuildIndex ( unsigned int  capacity = 0)
inlineprotected

Rebuild the nearest neighbor data structure (necessary when changing the distance function or index parameters).

Definition at line 290 of file NearestNeighborsFLANN.h.

◆ remove()

template<typename _T , typename _Dist = FLANNDistance<_T>>
bool ompl::NearestNeighborsFLANN< _T, _Dist >::remove ( const _T &  data)
inlineoverridevirtual

Remove an element from the datastructure.

Implements ompl::NearestNeighbors< _T >.

Definition at line 160 of file NearestNeighborsFLANN.h.

◆ reportsSortedResults()

template<typename _T , typename _Dist = FLANNDistance<_T>>
bool ompl::NearestNeighborsFLANN< _T, _Dist >::reportsSortedResults ( ) const
inlineoverridevirtual

Return true if the solutions reported by this data structure are sorted, when calling nearestK / nearestR.

Implements ompl::NearestNeighbors< _T >.

Definition at line 111 of file NearestNeighborsFLANN.h.

◆ setDistanceFunction()

template<typename _T , typename _Dist = FLANNDistance<_T>>
void ompl::NearestNeighborsFLANN< _T, _Dist >::setDistanceFunction ( const typename NearestNeighbors< _T >::DistanceFunction distFun)
inlineoverride

Definition at line 116 of file NearestNeighborsFLANN.h.

◆ setIndexParams()

template<typename _T , typename _Dist = FLANNDistance<_T>>
virtual void ompl::NearestNeighborsFLANN< _T, _Dist >::setIndexParams ( const std::shared_ptr< flann::IndexParams > &  params)
inlinevirtual

Set the FLANN index parameters.

The parameters determine the type of nearest neighbor data structure to be constructed.

Definition at line 241 of file NearestNeighborsFLANN.h.

◆ setSearchParams()

template<typename _T , typename _Dist = FLANNDistance<_T>>
virtual void ompl::NearestNeighborsFLANN< _T, _Dist >::setSearchParams ( const flann::SearchParams &  searchParams)
inlinevirtual

Set the FLANN parameters to be used during nearest neighbor searches.

Definition at line 255 of file NearestNeighborsFLANN.h.

◆ size()

template<typename _T , typename _Dist = FLANNDistance<_T>>
std::size_t ompl::NearestNeighborsFLANN< _T, _Dist >::size ( ) const
inlineoverridevirtual

Get the number of elements in the datastructure.

Implements ompl::NearestNeighbors< _T >.

Definition at line 217 of file NearestNeighborsFLANN.h.

Member Data Documentation

◆ data_

template<typename _T , typename _Dist = FLANNDistance<_T>>
std::vector<_T> ompl::NearestNeighborsFLANN< _T, _Dist >::data_
protected

vector of data stored in FLANN's index. FLANN only indexes references, so we need store the original data.

Definition at line 305 of file NearestNeighborsFLANN.h.

◆ dimension_

template<typename _T , typename _Dist = FLANNDistance<_T>>
unsigned int ompl::NearestNeighborsFLANN< _T, _Dist >::dimension_
protected

If each element has an array-like structure that is exposed to FLANN, then the dimension_ needs to be set to the length of this array.

Definition at line 320 of file NearestNeighborsFLANN.h.

◆ index_

template<typename _T , typename _Dist = FLANNDistance<_T>>
flann::Index<_Dist>* ompl::NearestNeighborsFLANN< _T, _Dist >::index_
protected

The FLANN index (the actual index type depends on params_).

Definition at line 308 of file NearestNeighborsFLANN.h.

◆ params_

template<typename _T , typename _Dist = FLANNDistance<_T>>
std::shared_ptr<flann::IndexParams> ompl::NearestNeighborsFLANN< _T, _Dist >::params_
protected

The FLANN index parameters. This contains both the type of index and the parameters for that type.

Definition at line 312 of file NearestNeighborsFLANN.h.

◆ searchParams_

template<typename _T , typename _Dist = FLANNDistance<_T>>
flann::SearchParams ompl::NearestNeighborsFLANN< _T, _Dist >::searchParams_
mutableprotected

The parameters used to seach for nearest neighbors.

Definition at line 315 of file NearestNeighborsFLANN.h.


The documentation for this class was generated from the following file: