Go to the documentation of this file.
   32 #ifndef __NABO_PRIVATE_H 
   33 #define __NABO_PRIVATE_H 
   42         #define __CL_ENABLE_EXCEPTIONS 
   48         #define _UNUSED __attribute__ ((unused)) 
   64         template<
typename T, 
typename A, 
typename B>
 
   65         inline T 
dist2(
const A& v0, 
const B& v1)
 
   67                 return (v0 - v1).squaredNorm();
 
   71         template<
typename T, 
typename CloudType = Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> >
 
   88                 virtual unsigned long knn(
const Matrix& query, 
IndexMatrix& indices, 
Matrix& dists2, 
const Index k, 
const T epsilon, 
const unsigned optionFlags, 
const T maxRadius) 
const;
 
   89                 virtual unsigned long knn(
const Matrix& query, 
IndexMatrix& indices, 
Matrix& dists2, 
const Vector& maxRadii, 
const Index k = 1, 
const T epsilon = 0, 
const unsigned optionFlags = 0) 
const;
 
   93         template<
typename T, 
typename Heap, 
typename CloudType = Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> >
 
  129                 inline uint32_t 
getDim(
const uint32_t dimChildBucketSize)
 const 
  130                 { 
return dimChildBucketSize & 
dimMask; }
 
  197                 unsigned long onePointKnn(
const Matrix& query, 
IndexMatrix& indices, 
Matrix& dists2, 
int i, Heap& heap, std::vector<T>& off, 
const T maxError, 
const T maxRadius2, 
const bool allowSelfMatch, 
const bool collectStatistics, 
const bool sortResults) 
const;
 
  208                 template<
bool allowSelfMatch, 
bool collectStatistics>
 
  209                 unsigned long recurseKnn(
const T* query, 
const unsigned n, T rd, Heap& heap, std::vector<T>& off, 
const T maxError, 
const T maxRadius2) 
const;
 
  214                 virtual unsigned long knn(
const Matrix& query, 
IndexMatrix& indices, 
Matrix& dists2, 
const Index k, 
const T epsilon, 
const unsigned optionFlags, 
const T maxRadius) 
const;
 
  215                 virtual unsigned long knn(
const Matrix& query, 
IndexMatrix& indices, 
Matrix& dists2, 
const Vector& maxRadii, 
const Index k = 1, 
const T epsilon = 0, 
const unsigned optionFlags = 0) 
const;
 
  221         template<
typename T, 
typename CloudType = Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> >
 
  236                 const cl_device_type deviceType; 
 
  237                 cl::Context& context; 
 
  238                 mutable cl::Kernel knnKernel; 
 
  239                 cl::CommandQueue queue; 
 
  243                 OpenCLSearch(
const CloudType& cloud, 
const Index dim, 
const unsigned creationOptionFlags, 
const cl_device_type deviceType);
 
  249                 void initOpenCL(
const char* clFileName, 
const char* kernelName, 
const std::string& additionalDefines = 
"");
 
  252                 virtual unsigned long knn(
const Matrix& query, IndexMatrix& indices, Matrix& dists2, 
const Index k, 
const T epsilon, 
const unsigned optionFlags, 
const T maxRadius) 
const;
 
  253                 virtual unsigned long knn(
const Matrix& query, IndexMatrix& indices, Matrix& dists2, 
const Vector& maxRadii, 
const Index k = 1, 
const T epsilon = 0, 
const unsigned optionFlags = 0) 
const;
 
  257         template<
typename T, 
typename CloudType = Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> >
 
  258         struct BruteForceSearchOpenCL: 
public OpenCLSearch<T, CloudType>
 
  264                 using OpenCLSearch<T, CloudType>::initOpenCL;
 
  267                 BruteForceSearchOpenCL(
const CloudType& cloud, 
const Index dim, 
const unsigned creationOptionFlags, 
const cl_device_type deviceType);
 
  271         template<
typename T, 
typename CloudType = Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> >
 
  272         struct KDTreeBalancedPtInLeavesStackOpenCL: 
public OpenCLSearch<T, CloudType>
 
  286                 using OpenCLSearch<T, CloudType>::context;
 
  287                 using OpenCLSearch<T, CloudType>::knnKernel;
 
  289                 using OpenCLSearch<T, CloudType>::initOpenCL;
 
  297                         BuildPoint(
const Vector& pos =  Vector(), 
const size_t index = 0): pos(pos), index(index) {}
 
  301                 typedef std::vector<BuildPoint> BuildPoints;
 
  303                 typedef typename BuildPoints::iterator BuildPointsIt;
 
  305                 typedef typename BuildPoints::const_iterator BuildPointsCstIt;
 
  311                         CompareDim(
const size_t dim):dim(dim){}
 
  314                         bool operator() (
const BuildPoint& p0, 
const BuildPoint& p1) { 
return p0.pos(dim) < p1.pos(dim); }
 
  322                         Node(
const int dim = -1, 
const T cutVal = 0):dim(dim), cutVal(cutVal) {}
 
  326                 typedef std::vector<Node> Nodes;
 
  332                 inline size_t childLeft(
size_t pos)
 const { 
return 2*pos + 1; } 
 
  333                 inline size_t childRight(
size_t pos)
 const { 
return 2*pos + 2; } 
 
  334                 inline size_t parent(
size_t pos)
 const { 
return (pos-1)/2; } 
 
  335                 size_t getTreeDepth(
size_t size) 
const; 
 
  336                 size_t getTreeSize(
size_t size) 
const; 
 
  339                 void buildNodes(
const BuildPointsIt first, 
const BuildPointsIt last, 
const size_t pos, 
const Vector minValues, 
const Vector maxValues);
 
  343                 KDTreeBalancedPtInLeavesStackOpenCL(
const CloudType& cloud, 
const Index dim, 
const unsigned creationOptionFlags, 
const cl_device_type deviceType);
 
  347         template<
typename T, 
typename CloudType = Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> >
 
  348         struct KDTreeBalancedPtInNodesStackOpenCL: 
public OpenCLSearch<T, CloudType>
 
  362                 using OpenCLSearch<T, CloudType>::context;
 
  363                 using OpenCLSearch<T, CloudType>::knnKernel;
 
  365                 using OpenCLSearch<T, CloudType>::initOpenCL;
 
  369                 typedef Index BuildPoint;
 
  371                 typedef std::vector<BuildPoint> BuildPoints;
 
  373                 typedef typename BuildPoints::iterator BuildPointsIt;
 
  375                 typedef typename BuildPoints::const_iterator BuildPointsCstIt;
 
  380                         const CloudType& cloud; 
 
  382                         CompareDim(
const CloudType& cloud, 
const size_t dim): cloud(cloud), dim(dim){}
 
  385                         bool operator() (
const BuildPoint& p0, 
const BuildPoint& p1) { 
return cloud.coeff(dim, p0) < cloud.coeff(dim, p1); }
 
  393                         Node(
const int dim = -2, 
const Index index = 0):dim(dim), index(index) {}
 
  397                 typedef std::vector<Node> Nodes;
 
  403                 inline size_t childLeft(
size_t pos)
 const { 
return 2*pos + 1; } 
 
  404                 inline size_t childRight(
size_t pos)
 const { 
return 2*pos + 2; } 
 
  405                 inline size_t parent(
size_t pos)
 const { 
return (pos-1)/2; } 
 
  406                 size_t getTreeDepth(
size_t size) 
const; 
 
  407                 size_t getTreeSize(
size_t size) 
const; 
 
  410                 void buildNodes(
const BuildPointsIt first, 
const BuildPointsIt last, 
const size_t pos, 
const Vector minValues, 
const Vector maxValues);
 
  414                 KDTreeBalancedPtInNodesStackOpenCL(
const CloudType& cloud, 
const Index dim, 
const unsigned creationOptionFlags, 
const cl_device_type deviceType);
 
  417         #endif // HAVE_OPENCL 
  
BuildPoints::const_iterator BuildPointsCstIt
const-iterator to indices of points during kd-tree construction
T cutVal
for split node, split value
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
BucketEntry(const T *pt=0, const Index index=0)
create a new bucket entry for a point in the data
NearestNeighbourSearch< T, CloudType >::IndexVector IndexVector
std::vector< Node > Nodes
dense vector of search nodes, provides better memory performances than many small objects
KDTree, unbalanced, points in leaves, stack, implicit bounds, ANN_KD_SL_MIDPT, optimised implementati...
Node(const uint32_t bucketSize, const uint32_t bucketIndex)
construct a leaf node
const uint32_t dimBitCount
number of bits required to store dimension index + number of dimensions
KDTreeUnbalancedPtInLeavesImplicitBoundsStackOpt(const CloudType &cloud, const Index dim, const unsigned creationOptionFlags, const Parameters &additionalParameters)
constructor, calls NearestNeighbourSearch<T>(cloud)
const CloudType & cloud
the reference to the data-point cloud, which must remain valid during the lifetime of the NearestNeig...
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > CloudType
a column-major Eigen matrix in which each column is a point; this matrix has dim rows
NearestNeighbourSearch< T, CloudType >::Vector Vector
const unsigned creationOptionFlags
creation options
const T * pt
pointer to first value of point data, 0 if end of bucket
std::vector< Index > BuildPoints
indices of points during kd-tree construction
NearestNeighbourSearch< T, CloudType >::Vector Vector
uint32_t createDimChildBucketSize(const uint32_t dim, const uint32_t childIndex) const
create the compound index containing the dimension and the index of the child or the bucket size
Index index
index of point
unsigned long onePointKnn(const Matrix &query, IndexMatrix &indices, Matrix &dists2, int i, Heap &heap, std::vector< T > &off, const T maxError, const T maxRadius2, const bool allowSelfMatch, const bool collectStatistics, const bool sortResults) const
search one point, call recurseKnn with the correct template parameters
Nearest neighbour search interface, templatized on scalar type.
unsigned long recurseKnn(const T *query, const unsigned n, T rd, Heap &heap, std::vector< T > &off, const T maxError, const T maxRadius2) const
recursive search, strongly inspired by ANN and [Arya & Mount, Algorithms for fast vector quantization...
const uint32_t dimMask
mask to access dim
T dist2(const A &v0, const B &v1)
Euclidean distance.
std::vector< BucketEntry > Buckets
bucket data
Node(const uint32_t dimChild, const T cutVal)
construct a split node
virtual unsigned long knn(const Matrix &query, IndexMatrix &indices, Matrix &dists2, const Index k, const T epsilon, const unsigned optionFlags, const T maxRadius) const
NearestNeighbourSearch< T, CloudType >::IndexMatrix IndexMatrix
uint32_t getDim(const uint32_t dimChildBucketSize) const
get the dimension out of the compound index
NearestNeighbourSearch< T, CloudType >::IndexVector IndexVector
uint32_t getChildBucketSize(const uint32_t dimChildBucketSize) const
get the child index or the bucket size out of the coumpount index
const unsigned bucketSize
size of bucket
unsigned buildNodes(const BuildPointsIt first, const BuildPointsIt last, const Vector minValues, const Vector maxValues)
construct nodes for points [first..last[ inside the hyperrectangle [minValues..maxValues]
uint32_t dimChildBucketSize
cut dimension for split nodes (dimBitCount lsb), index of right node or number of bucket(rest)....
BuildPoints::iterator BuildPointsIt
iterator to indices of points during kd-tree construction
NearestNeighbourSearch< T, CloudType >::Matrix Matrix
NearestNeighbourSearch< T, CloudType >::Index Index
uint32_t bucketIndex
for leaf node, pointer to bucket
NearestNeighbourSearch< T, CloudType >::IndexMatrix IndexMatrix
NearestNeighbourSearch< T, CloudType >::Matrix Matrix
std::pair< T, T > getBounds(const BuildPointsIt first, const BuildPointsIt last, const unsigned dim)
return the bounds of points from [first..last[ on dimension dim
Brute-force nearest neighbour.
NearestNeighbourSearch< T, CloudType >::Index Index
BruteForceSearch(const CloudType &cloud, const Index dim, const unsigned creationOptionFlags)
constructor, calls NearestNeighbourSearch<T>(cloud)
mp2p_icp
Author(s): 
autogenerated on Mon May 26 2025 02:45:50