ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
flann::KDTreeIndex< Distance > Class Template Reference

#include <kdtree_index.h>

Inheritance diagram for flann::KDTreeIndex< Distance >:
Collaboration diagram for flann::KDTreeIndex< Distance >:

Public Types

typedef Distance::ElementType ElementType
 
typedef Distance::ResultType DistanceType
 
typedef NNIndex< DistanceBaseClass
 
typedef bool needs_kdtree_distance
 
- Public Types inherited from flann::NNIndex< Distance >
typedef Distance::ElementType ElementType
 
typedef Distance::ResultType DistanceType
 

Public Member Functions

 KDTreeIndex (const IndexParams &params=KDTreeIndexParams(), Distance d=Distance())
 
 KDTreeIndex (const Matrix< ElementType > &dataset, const IndexParams &params=KDTreeIndexParams(), Distance d=Distance())
 
 KDTreeIndex (const KDTreeIndex &other)
 
KDTreeIndexoperator= (KDTreeIndex other)
 
virtual ~KDTreeIndex ()
 
BaseClassclone () const
 
void addPoints (const Matrix< ElementType > &points, float rebuild_threshold=2)
 Incrementally add points to the index. More...
 
flann_algorithm_t getType () const
 
template<typename Archive >
void serialize (Archive &ar)
 
void saveIndex (FILE *stream)
 
void loadIndex (FILE *stream)
 
int usedMemory () const
 
void findNeighbors (ResultSet< DistanceType > &result, const ElementType *vec, const SearchParams &searchParams) const
 
virtual void buildIndex ()
 
virtual void buildIndex (const Matrix< ElementType > &dataset)
 
- Public Member Functions inherited from flann::NNIndex< Distance >
 NNIndex (Distance d)
 
 NNIndex (const IndexParams &params, Distance d)
 
 NNIndex (const NNIndex &other)
 
virtual ~NNIndex ()
 
virtual void buildIndex (const Matrix< ElementType > &dataset)
 
virtual void removePoint (size_t id)
 
virtual ElementTypegetPoint (size_t id)
 
size_t size () const
 
size_t veclen () const
 
IndexParams getParameters () const
 
template<typename Archive >
void serialize (Archive &ar)
 
virtual int knnSearch (const Matrix< ElementType > &queries, Matrix< size_t > &indices, Matrix< DistanceType > &dists, size_t knn, const SearchParams &params) const
 Perform k-nearest neighbor search. More...
 
int knnSearch (const Matrix< ElementType > &queries, Matrix< int > &indices, Matrix< DistanceType > &dists, size_t knn, const SearchParams &params) const
 
int knnSearch (const Matrix< ElementType > &queries, std::vector< std::vector< size_t > > &indices, std::vector< std::vector< DistanceType > > &dists, size_t knn, const SearchParams &params) const
 Perform k-nearest neighbor search. More...
 
int knnSearch (const Matrix< ElementType > &queries, std::vector< std::vector< int > > &indices, std::vector< std::vector< DistanceType > > &dists, size_t knn, const SearchParams &params) const
 
int radiusSearch (const Matrix< ElementType > &queries, Matrix< size_t > &indices, Matrix< DistanceType > &dists, float radius, const SearchParams &params) const
 Perform radius search. More...
 
int radiusSearch (const Matrix< ElementType > &queries, Matrix< int > &indices, Matrix< DistanceType > &dists, float radius, const SearchParams &params) const
 
int radiusSearch (const Matrix< ElementType > &queries, std::vector< std::vector< size_t > > &indices, std::vector< std::vector< DistanceType > > &dists, float radius, const SearchParams &params) const
 Perform radius search. More...
 
int radiusSearch (const Matrix< ElementType > &queries, std::vector< std::vector< int > > &indices, std::vector< std::vector< DistanceType > > &dists, float radius, const SearchParams &params) const
 
- Public Member Functions inherited from flann::IndexBase
virtual ~IndexBase ()
 

Protected Member Functions

void buildIndexImpl ()
 
void freeIndex ()
 
- Protected Member Functions inherited from flann::NNIndex< Distance >
size_t id_to_index (size_t id)
 
void indices_to_ids (const size_t *in, size_t *out, size_t size) const
 
void setDataset (const Matrix< ElementType > &dataset)
 
void extendDataset (const Matrix< ElementType > &new_points)
 
void cleanRemovedPoints ()
 
void swap (NNIndex &other)
 

Additional Inherited Members

- Protected Attributes inherited from flann::NNIndex< Distance >
Distance distance_
 
size_t last_id_
 
size_t size_
 
size_t size_at_build_
 
size_t veclen_
 
IndexParams index_params_
 
bool removed_
 
DynamicBitset removed_points_
 
size_t removed_count_
 
std::vector< size_t > ids_
 
std::vector< ElementType * > points_
 
ElementTypedata_ptr_
 

Detailed Description

template<typename Distance>
class flann::KDTreeIndex< Distance >

Randomized kd-tree index

Contains the k-d trees and other information for indexing a set of points for nearest-neighbor matching.

Definition at line 72 of file kdtree_index.h.

Member Typedef Documentation

◆ BaseClass

template<typename Distance >
typedef NNIndex<Distance> flann::KDTreeIndex< Distance >::BaseClass

Definition at line 78 of file kdtree_index.h.

◆ DistanceType

template<typename Distance >
typedef Distance::ResultType flann::KDTreeIndex< Distance >::DistanceType

Definition at line 76 of file kdtree_index.h.

◆ ElementType

template<typename Distance >
typedef Distance::ElementType flann::KDTreeIndex< Distance >::ElementType

Definition at line 75 of file kdtree_index.h.

◆ needs_kdtree_distance

template<typename Distance >
typedef bool flann::KDTreeIndex< Distance >::needs_kdtree_distance

Definition at line 80 of file kdtree_index.h.

Constructor & Destructor Documentation

◆ KDTreeIndex() [1/3]

template<typename Distance >
flann::KDTreeIndex< Distance >::KDTreeIndex ( const IndexParams params = KDTreeIndexParams(),
Distance  d = Distance() 
)
inline

KDTree constructor

Params: inputData = dataset with the input features params = parameters passed to the kdtree algorithm

Definition at line 90 of file kdtree_index.h.

References flann::get_param(), and flann::NNIndex< Distance >::index_params_.

Referenced by flann::KDTreeIndex< Distance >::clone().

◆ KDTreeIndex() [2/3]

template<typename Distance >
flann::KDTreeIndex< Distance >::KDTreeIndex ( const Matrix< ElementType > &  dataset,
const IndexParams params = KDTreeIndexParams(),
Distance  d = Distance() 
)
inline

KDTree constructor

Params: inputData = dataset with the input features params = parameters passed to the kdtree algorithm

Definition at line 104 of file kdtree_index.h.

References flann::get_param(), flann::NNIndex< Distance >::index_params_, and flann::NNIndex< Distance >::setDataset().

◆ KDTreeIndex() [3/3]

template<typename Distance >
flann::KDTreeIndex< Distance >::KDTreeIndex ( const KDTreeIndex< Distance > &  other)
inline

Definition at line 112 of file kdtree_index.h.

◆ ~KDTreeIndex()

template<typename Distance >
virtual flann::KDTreeIndex< Distance >::~KDTreeIndex ( )
inlinevirtual

Standard destructor

Definition at line 130 of file kdtree_index.h.

References flann::KDTreeIndex< Distance >::freeIndex().

Member Function Documentation

◆ addPoints()

template<typename Distance >
void flann::KDTreeIndex< Distance >::addPoints ( const Matrix< ElementType > &  points,
float  rebuild_threshold = 2 
)
inlinevirtual

Incrementally add points to the index.

Parameters
pointsMatrix with points to be added
rebuild_threshold

Reimplemented from flann::NNIndex< Distance >.

Definition at line 142 of file kdtree_index.h.

References flann::KDTreeIndex< Distance >::buildIndex(), flann::NNIndex< Distance >::extendDataset(), points, flann::NNIndex< Distance >::size_, flann::NNIndex< Distance >::size_at_build_, and flann::NNIndex< Distance >::veclen_.

◆ buildIndex() [1/2]

template<typename Distance >
virtual void flann::NNIndex< Distance >::buildIndex
inlinevirtual

Builds the index

Reimplemented from flann::NNIndex< Distance >.

Definition at line 125 of file nn_index.h.

Referenced by flann::KDTreeIndex< Distance >::addPoints().

◆ buildIndex() [2/2]

template<typename Distance >
virtual void flann::NNIndex< Distance >::buildIndex
inlinevirtual

Builds the index using the specified dataset

Parameters
datasetthe dataset to use

Reimplemented from flann::NNIndex< Distance >.

Definition at line 141 of file nn_index.h.

◆ buildIndexImpl()

template<typename Distance >
void flann::KDTreeIndex< Distance >::buildIndexImpl ( )
inlineprotectedvirtual

Builds the index

Implements flann::NNIndex< Distance >.

Definition at line 253 of file kdtree_index.h.

References flann::NNIndex< Distance >::size_, and flann::NNIndex< Distance >::veclen_.

◆ clone()

template<typename Distance >
BaseClass* flann::KDTreeIndex< Distance >::clone ( ) const
inlinevirtual

◆ findNeighbors()

template<typename Distance >
void flann::KDTreeIndex< Distance >::findNeighbors ( ResultSet< DistanceType > &  result,
const ElementType vec,
const SearchParams searchParams 
) const
inlinevirtual

Find set of nearest neighbors to vec. 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 maxCheck = the maximum number of restarts (in a best-bin-first manner)

Implements flann::NNIndex< Distance >.

Definition at line 225 of file kdtree_index.h.

References flann::SearchParams::checks, flann::SearchParams::eps, FLANN_CHECKS_UNLIMITED, flann::NNIndex< Distance >::removed_, and result.

◆ freeIndex()

template<typename Distance >
void flann::KDTreeIndex< Distance >::freeIndex ( )
inlineprotectedvirtual

◆ getType()

template<typename Distance >
flann_algorithm_t flann::KDTreeIndex< Distance >::getType ( ) const
inlinevirtual

Implements flann::IndexBase.

Definition at line 161 of file kdtree_index.h.

References FLANN_INDEX_KDTREE.

Referenced by flann::KDTreeIndex< Distance >::serialize().

◆ loadIndex()

template<typename Distance >
void flann::KDTreeIndex< Distance >::loadIndex ( FILE *  stream)
inlinevirtual

Implements flann::IndexBase.

Definition at line 200 of file kdtree_index.h.

References flann::KDTreeIndex< Distance >::freeIndex().

◆ operator=()

template<typename Distance >
KDTreeIndex& flann::KDTreeIndex< Distance >::operator= ( KDTreeIndex< Distance other)
inline

Definition at line 121 of file kdtree_index.h.

◆ saveIndex()

template<typename Distance >
void flann::KDTreeIndex< Distance >::saveIndex ( FILE *  stream)
inlinevirtual

Implements flann::IndexBase.

Definition at line 193 of file kdtree_index.h.

◆ serialize()

template<typename Distance >
template<typename Archive >
void flann::KDTreeIndex< Distance >::serialize ( Archive &  ar)
inline

◆ usedMemory()

template<typename Distance >
int flann::KDTreeIndex< Distance >::usedMemory ( ) const
inlinevirtual

Computes the inde memory usage Returns: memory used by the index

Implements flann::IndexBase.

Definition at line 211 of file kdtree_index.h.

References flann::NNIndex< Distance >::size_, flann::PooledAllocator::usedMemory, and flann::PooledAllocator::wastedMemory.


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