44 template<
typename T,
typename CloudType>
49 const_cast<Vector&
>(this->
minBound) = cloud.topRows(this->dim).rowwise().minCoeff();
50 const_cast<Vector&
>(this->
maxBound) = cloud.topRows(this->dim).rowwise().maxCoeff();
53 for (
int i = 0; i < cloud.cols(); ++i)
55 const Vector& v(cloud.block(0,i,this->dim,1));
63 template<
typename T,
typename CloudType>
66 const Vector maxRadii(Vector::Constant(query.cols(), maxRadius));
67 return knn(query, indices, dists2, maxRadii, k, epsilon, optionFlags);
70 template<
typename T,
typename CloudType>
73 checkSizesKnn(query, indices, dists2, k, optionFlags, &maxRadii);
81 for (
int c = 0; c < query.cols(); ++c)
83 const T maxRadius(maxRadii[c]);
84 const T maxRadius2(maxRadius * maxRadius);
87 for (
int i = 0; i < this->
cloud.cols(); ++i)
89 const T dist(dist2<T>(this->
cloud.block(0,i,
dim,1),
q));
90 if ((dist <= maxRadius2) &&
92 (allowSelfMatch || (dist > numeric_limits<T>::epsilon())))
97 heap.
getData(indices.col(c), dists2.col(c));
99 if (collectStatistics)
100 return (
unsigned long)query.cols() * (
unsigned long)this->
cloud.cols();
const unsigned creationOptionFlags
creation options
NearestNeighbourSearch< T, CloudType >::IndexMatrix IndexMatrix
void sort()
sort the entries, from the smallest to the largest
void getData(const Eigen::MatrixBase< DI > &indices, const Eigen::MatrixBase< DV > &values) const
get the data from the heap
implementation of index heaps
void checkSizesKnn(const Matrix &query, const IndexMatrix &indices, const Matrix &dists2, const Index k, const unsigned optionFlags, const Vector *maxRadii=0) const
Make sure that the output matrices have the right sizes. Throw an exception otherwise.
Nearest neighbour search interface, templatized on scalar type.
const VT & headValue() const
get the largest value of the heap
NearestNeighbourSearch< T, CloudType >::Vector Vector
const CloudType & cloud
the reference to the data-point cloud, which must remain valid during the lifetime of the NearestNeig...
void reset()
reset to the empty heap
Brute-force nearest neighbour.
void replaceHead(const Index index, const Value value)
put value into heap, replace the largest value if full
const Vector maxBound
the high bound of the search space (axis-aligned bounding box)
NearestNeighbourSearch< T, CloudType >::Matrix Matrix
balanced-tree implementation of heap
const Vector minBound
the low bound of the search space (axis-aligned bounding box)
const Index dim
the dimensionality of the data-point cloud
virtual unsigned long knn(const Matrix &query, IndexMatrix &indices, Matrix &dists2, const Index k, const T epsilon, const unsigned optionFlags, const T maxRadius) const
BruteForceSearch(const CloudType &cloud, const Index dim, const unsigned creationOptionFlags)
constructor, calls NearestNeighbourSearch<T>(cloud)
NearestNeighbourSearch< T, CloudType >::Index Index
header for implementation