58 static_cast<std::runtime_error&
>(*this) = std::runtime_error(ss.str());
68 template<
typename T,
typename CloudType>
71 dim(min(dim, int(cloud.rows()))),
72 creationOptionFlags(creationOptionFlags),
73 minBound(
Vector::Constant(this->dim, numeric_limits<T>::max())),
74 maxBound(
Vector::Constant(this->dim, numeric_limits<T>::min()))
76 if (
cloud.cols() == 0)
78 if (
cloud.rows() == 0)
82 template<
typename T,
typename CloudType>
86 const Eigen::Map<const Matrix> queryMatrix(&query.coeff(0,0), dim, 1);
88 const Eigen::Map<Matrix> queryMatrix(&query.coeff(0,0), dim, 1);
96 const unsigned long stats = knn(queryMatrix, indexMatrix, dists2Matrix, k, epsilon, optionFlags, maxRadius);
97 indices = indexMatrix.col(0);
98 dists2 = dists2Matrix.col(0);
102 template<
typename T,
typename CloudType>
108 if (k > cloud.cols())
109 throw runtime_error() <<
"Requesting more points (" << k <<
") than available in cloud (" << cloud.cols() <<
")";
113 if (k > cloud.cols()-1)
114 throw runtime_error() <<
"Requesting more points (" << k <<
") than available in cloud minus 1 (" << cloud.cols()-1 <<
") (as self match is forbidden)";
116 if (query.rows() < dim)
117 throw runtime_error() <<
"Query has less dimensions (" << query.rows() <<
") than requested for cloud (" << dim <<
")";
118 if (indices.rows() != k)
119 throw runtime_error() <<
"Index matrix has a different number of rows (" << indices.rows() <<
") than k (" << k <<
")";
120 if (indices.cols() != query.cols())
121 throw runtime_error() <<
"Index matrix has a different number of columns (" << indices.rows() <<
") than query (" << query.cols() <<
")";
122 if (dists2.rows() != k)
123 throw runtime_error() <<
"Distance matrix has a different number of rows (" << dists2.rows() <<
") than k (" << k <<
")";
124 if (dists2.cols() != query.cols())
125 throw runtime_error() <<
"Distance matrix has a different number of columns (" << dists2.rows() <<
") than query (" << query.cols() <<
")";
126 if (maxRadii && (maxRadii->size() != query.cols()))
127 throw runtime_error() <<
"Maximum radii vector has not the same length (" << maxRadii->size() <<
") than query has columns (" << k <<
")";
128 const unsigned maxOptionFlagsValue(ALLOW_SELF_MATCH|SORT_RESULTS);
129 if (optionFlags > maxOptionFlagsValue)
130 throw runtime_error() <<
"OR-ed value of option flags (" << optionFlags <<
") is larger than maximal valid value (" << maxOptionFlagsValue <<
")";
134 template<
typename T,
typename CloudType>
138 throw runtime_error() <<
"Your space must have at least one dimension";
139 switch (preferedType)
145 case KDTREE_CL_PT_IN_NODES:
return new KDTreeBalancedPtInNodesStackOpenCL<T, CloudType>(cloud, dim, creationOptionFlags, CL_DEVICE_TYPE_GPU);
146 case KDTREE_CL_PT_IN_LEAVES:
return new KDTreeBalancedPtInLeavesStackOpenCL<T, CloudType>(cloud, dim, creationOptionFlags, CL_DEVICE_TYPE_GPU);
147 case BRUTE_FORCE_CL:
return new BruteForceSearchOpenCL<T, CloudType>(cloud, dim, creationOptionFlags, CL_DEVICE_TYPE_GPU);
149 case KDTREE_CL_PT_IN_NODES:
throw runtime_error() <<
"OpenCL not found during compilation";
150 case KDTREE_CL_PT_IN_LEAVES:
throw runtime_error() <<
"OpenCL not found during compilation";
151 case BRUTE_FORCE_CL:
throw runtime_error() <<
"OpenCL not found during compilation";
152 #endif // HAVE_OPENCL
157 template<
typename T,
typename CloudType>
161 throw runtime_error() <<
"Your space must have at least one dimension";
165 template<
typename T,
typename CloudType>
169 throw runtime_error() <<
"Your space must have at least one dimension";
173 template<
typename T,
typename CloudType>
177 throw runtime_error() <<
"Your space must have at least one dimension";