31 #ifndef FLANN_COMPOSITE_INDEX_H_
32 #define FLANN_COMPOSITE_INDEX_H_
52 (*this)[
"trees"] = trees;
54 (*this)[
"branching"] = branching;
56 (*this)[
"iterations"] = iterations;
58 (*this)[
"centers_init"] = centers_init;
60 (*this)[
"cb_index"] = cb_index;
70 template <
typename Distance>
104 kmeans_index_(other.kmeans_index_), kdtree_index_(other.kdtree_index_)
116 delete kdtree_index_;
117 delete kmeans_index_;
138 return kdtree_index_->size();
146 return kdtree_index_->veclen();
154 return kmeans_index_->usedMemory() + kdtree_index_->usedMemory();
164 kmeans_index_->buildIndex();
166 kdtree_index_->buildIndex();
171 kmeans_index_->addPoints(
points, rebuild_threshold);
172 kdtree_index_->addPoints(
points, rebuild_threshold);
177 kmeans_index_->removePoint(index);
178 kdtree_index_->removePoint(index);
188 kmeans_index_->saveIndex(stream);
189 kdtree_index_->saveIndex(stream);
198 kmeans_index_->loadIndex(stream);
199 kdtree_index_->loadIndex(stream);
207 kmeans_index_->findNeighbors(
result, vec, searchParams);
208 kdtree_index_->findNeighbors(
result, vec, searchParams);
214 std::swap(kmeans_index_, other.kmeans_index_);
215 std::swap(kdtree_index_, other.kdtree_index_);
double Distance(const Point3D< Real > &p1, const Point3D< Real > &p2)
cmdLineReadable * params[]
void swap(CompositeIndex &other)
Distance::ResultType DistanceType
void findNeighbors(ResultSet< DistanceType > &result, const ElementType *vec, const SearchParams &searchParams) const
Method that searches for nearest-neighbours.
CompositeIndex(const IndexParams ¶ms=CompositeIndexParams(), Distance d=Distance())
CompositeIndex(const CompositeIndex &other)
void loadIndex(FILE *stream)
Loads the index from a stream.
CompositeIndex & operator=(CompositeIndex other)
NNIndex< Distance > BaseClass
flann_algorithm_t getType() const
BaseClass * clone() const
Distance::ElementType ElementType
void addPoints(const Matrix< ElementType > &points, float rebuild_threshold=2)
Incrementally add points to the index.
virtual ~CompositeIndex()
bool needs_kdtree_distance
void saveIndex(FILE *stream)
Saves the index to a stream.
void removePoint(size_t index)
void buildIndex()
Builds the index.
CompositeIndex(const Matrix< ElementType > &inputData, const IndexParams ¶ms=CompositeIndexParams(), Distance d=Distance())
static int info(const char *fmt,...)
std::map< std::string, any > IndexParams
void swap(cloudViewer::core::SmallVectorImpl< T > &LHS, cloudViewer::core::SmallVectorImpl< T > &RHS)
Implement std::swap in terms of SmallVector swap.
CompositeIndexParams(int trees=4, int branching=32, int iterations=11, flann_centers_init_t centers_init=FLANN_CENTERS_RANDOM, float cb_index=0.2)