32 #ifndef __NABO_EXPERIMENTAL_H 33 #define __NABO_EXPERIMENTAL_H 35 #include "../nabo/nabo_private.h" 36 #include "../nabo/index_heap.h" 41 template<
typename T,
typename CloudType>
54 BuildPoint(
const Vector& pos =
Vector(),
const size_t index = 0): pos(pos), index(index) {}
72 Node(
const Vector& pos =
Vector(),
const int dim = -2,
const Index index = 0):pos(pos), dim(dim), index(index) {}
74 typedef std::vector<Node>
Nodes;
78 inline size_t childLeft(
size_t pos)
const {
return 2*pos + 1; }
79 inline size_t childRight(
size_t pos)
const {
return 2*pos + 2; }
80 inline size_t parent(
size_t pos)
const {
return (pos-1)/2; }
83 void buildNodes(
const BuildPointsIt first,
const BuildPointsIt last,
const size_t pos);
84 void dump(
const Vector minValues,
const Vector maxValues,
const size_t pos)
const;
91 template<
typename T,
typename CloudType>
112 SearchElement(
const size_t index,
const T minDist): index(index), minDist(minDist) {}
119 virtual IndexVector
knn(
const Vector& query,
const Index k,
const T epsilon,
const unsigned optionFlags);
123 template<
typename T,
typename CloudType>
141 void recurseKnn(
const Vector& query,
const size_t n, T rd, Heap& heap, Vector& off,
const T maxError,
const bool allowSelfMatch);
145 virtual IndexVector
knn(
const Vector& query,
const Index k,
const T epsilon,
const unsigned optionFlags);
150 template<
typename T,
typename CloudType>
168 BuildPoint(
const Vector& pos =
Vector(),
const size_t index = 0): pos(pos), index(index) {}
187 Node(
const int dim = -1,
const T cutVal = 0):
188 dim(dim), cutVal(cutVal) {}
194 inline size_t childLeft(
size_t pos)
const {
return 2*pos + 1; }
195 inline size_t childRight(
size_t pos)
const {
return 2*pos + 2; }
196 inline size_t parent(
size_t pos)
const {
return (pos-1)/2; }
198 void buildNodes(
const BuildPointsIt first,
const BuildPointsIt last,
const size_t pos,
const Vector minValues,
const Vector maxValues,
const bool balanceVariance);
199 void recurseKnn(
const Vector& query,
const size_t n, T rd, Heap& heap, Vector& off,
const T maxError,
const bool allowSelfMatch);
203 virtual IndexVector
knn(
const Vector& query,
const Index k,
const T epsilon,
const unsigned optionFlags);
207 template<
typename T,
typename Heap,
typename CloudType>
226 BuildPoint(
const Vector& pos =
Vector(),
const size_t index = 0): pos(pos), index(index) {}
243 INVALID_CHILD = 0xffffffff,
244 INVALID_PT = 0xffffffff
254 Node(
const int dim,
const T cutVal,
unsigned rightChild):
255 dim(dim), rightChild(rightChild), cutVal(cutVal) {}
256 Node(
const unsigned ptIndex = INVALID_PT):
257 dim(0), rightChild(INVALID_CHILD), ptIndex(ptIndex) {}
263 unsigned buildNodes(
const BuildPointsIt first,
const BuildPointsIt last,
const Vector minValues,
const Vector maxValues);
264 void recurseKnn(
const Vector& query,
const unsigned n, T rd, Heap& heap, Vector& off,
const T maxError,
const bool allowSelfMatch);
268 virtual IndexVector
knn(
const Vector& query,
const Index k,
const T epsilon,
const unsigned optionFlags);
269 virtual IndexMatrix knnM(
const Matrix& query,
const Index k,
const T epsilon,
const unsigned optionFlags);
273 template<
typename T,
typename CloudType>
292 BuildPoint(
const Vector& pos =
Vector(),
const size_t index = 0): pos(pos), index(index) {}
314 Node(
const int dim = -1,
const T cutVal = 0,
const T lowBound = 0,
const T highBound = 0,
unsigned rightChild = 0):
315 dim(dim), rightChild(rightChild), cutVal(cutVal), lowBound(lowBound), highBound(highBound) {}
321 unsigned buildNodes(
const BuildPointsIt first,
const BuildPointsIt last,
const Vector minValues,
const Vector maxValues);
322 void recurseKnn(
const Vector& query,
const size_t n, T rd, Heap& heap,
const T maxError,
const bool allowSelfMatch);
326 virtual IndexVector
knn(
const Vector& query,
const Index k,
const T epsilon,
const unsigned optionFlags);
NearestNeighbourSearch< T, CloudType >::Vector Vector
NearestNeighbourSearch< T, CloudType >::Index Index
std::vector< Node > Nodes
NearestNeighbourSearch< T, CloudType >::Matrix Matrix
size_t childRight(size_t pos) const
KDTreeBalancedPtInNodes< T, CloudType >::Nodes Nodes
Node(const unsigned ptIndex=INVALID_PT)
IndexHeapSTL< Index, T > Heap
NearestNeighbourSearch< T, CloudType >::IndexVector IndexVector
std::vector< Node > Nodes
std::vector< BuildPoint > BuildPoints
NearestNeighbourSearch< T, CloudType >::Index Index
BuildPoints::iterator BuildPointsIt
CompareDim(const size_t dim)
BuildPoint(const Vector &pos=Vector(), const size_t index=0)
NearestNeighbourSearch< T, CloudType >::Matrix Matrix
Nearest neighbour search interface, templatized on scalar type.
std::vector< BuildPoint > BuildPoints
KDTreeBalancedPtInNodes< T, CloudType >::Node Node
CompareDim(const size_t dim)
NearestNeighbourSearch< T, CloudType >::IndexVector IndexVector
IndexHeapSTL< Index, T > Heap
std::vector< Node > Nodes
NearestNeighbourSearch< T, CloudType >::Matrix Matrix
NearestNeighbourSearch< T, CloudType >::IndexMatrix IndexMatrix
size_t getTreeSize(size_t size) const
const CloudType & cloud
the reference to the data-point cloud, which must remain valid during the lifetime of the NearestNeig...
BuildPoints::const_iterator BuildPointsCstIt
NearestNeighbourSearch< T, CloudType >::Index Index
size_t childRight(size_t pos) const
NearestNeighbourSearch< T, CloudType >::IndexVector IndexVector
KDTreeBalancedPtInNodes< T, CloudType >::Node Node
size_t childLeft(size_t pos) const
Node(const int dim=-1, const T cutVal=0, const T lowBound=0, const T highBound=0, unsigned rightChild=0)
size_t childLeft(size_t pos) const
NearestNeighbourSearch< T, CloudType >::Vector Vector
NearestNeighbourSearch< T, CloudType >::Matrix Matrix
NearestNeighbourSearch< T, CloudType >::Vector Vector
size_t parent(size_t pos) const
void buildNodes(const BuildPointsIt first, const BuildPointsIt last, const size_t pos)
Node(const int dim, const T cutVal, unsigned rightChild)
NearestNeighbourSearch< T, CloudType >::IndexVector IndexVector
balanced-tree implementation of heap
BuildPoint(const Vector &pos=Vector(), const size_t index=0)
NearestNeighbourSearch< T, CloudType >::Vector Vector
KDTreeBalancedPtInNodes< T, CloudType >::Nodes Nodes
NearestNeighbourSearch< T, CloudType >::Matrix Matrix
KDTreeBalancedPtInNodes(const CloudType &cloud)
NearestNeighbourSearch< T, CloudType >::Index Index
BuildPoints::iterator BuildPointsIt
NearestNeighbourSearch< T, CloudType >::IndexVector IndexVector
NearestNeighbourSearch< T, CloudType >::IndexVector IndexVector
NearestNeighbourSearch< T, CloudType >::Matrix Matrix
NearestNeighbourSearch< T, CloudType >::Vector Vector
unsigned long knn(const Vector &query, IndexVector &indices, Vector &dists2, const Index k=1, const T epsilon=0, const unsigned optionFlags=0, const T maxRadius=std::numeric_limits< T >::infinity()) const
Find the k nearest neighbours of query.
std::vector< BuildPoint > BuildPoints
NearestNeighbourSearch< T, CloudType >::Index Index
BuildPoint(const Vector &pos=Vector(), const size_t index=0)
BuildPoints::const_iterator BuildPointsCstIt
CompareDim(const size_t dim)
size_t parent(size_t pos) const
IndexHeapSTL< Index, T > Heap
void dump(const Vector minValues, const Vector maxValues, const size_t pos) const
BuildPoints::const_iterator BuildPointsCstIt
IndexVector cloudIndexesFromNodesIndexes(const IndexVector &indexes) const
Node(const int dim=-1, const T cutVal=0)
std::vector< BuildPoint > BuildPoints
Node(const Vector &pos=Vector(), const int dim=-2, const Index index=0)
BuildPoint(const Vector &pos=Vector(), const size_t index=0)
CompareDim(const size_t dim)
CloudType CloudType
a column-major Eigen matrix in which each column is a point; this matrix has dim rows ...
friend bool operator<(const SearchElement &e0, const SearchElement &e1)
SearchElement(const size_t index, const T minDist)
NearestNeighbourSearch< T, CloudType >::Index Index
std::vector< Node > Nodes
BuildPoints::const_iterator BuildPointsCstIt
BuildPoints::iterator BuildPointsIt
NearestNeighbourSearch< T, CloudType >::Vector Vector
BuildPoints::iterator BuildPointsIt