77 class Derived,
typename num_t = float,
91 return *
static_cast<const Derived*
>(
this);
94 inline Derived&
derived() {
return *
static_cast<Derived*
>(
this); }
126 float x0,
float y0,
float& out_x,
float& out_y,
127 float& out_dist_sqr)
const
134 const size_t knn = 1;
137 resultSet.
init(&ret_index, &out_dist_sqr);
146 out_x =
derived().kdtree_get_pt(ret_index, 0);
147 out_y =
derived().kdtree_get_pt(ret_index, 1);
155 float x0,
float y0,
float& out_dist_sqr)
const
162 const size_t knn = 1;
165 resultSet.
init(&ret_index, &out_dist_sqr);
183 static_cast<float>(p0.
x),
static_cast<float>(p0.
y), dmy1, dmy2,
195 float closerx, closery, closer_dist;
203 static_cast<float>(p0.
x),
static_cast<float>(p0.
y));
227 float x0,
float y0,
float& out_x1,
float& out_y1,
float& out_x2,
228 float& out_y2,
float& out_dist_sqr1,
float& out_dist_sqr2)
const
235 const size_t knn = 2;
236 size_t ret_indexes[2];
239 resultSet.
init(&ret_indexes[0], &ret_sqdist[0]);
248 out_x1 =
derived().kdtree_get_pt(ret_indexes[0], 0);
249 out_y1 =
derived().kdtree_get_pt(ret_indexes[0], 1);
250 out_dist_sqr1 = ret_sqdist[0];
252 out_x2 =
derived().kdtree_get_pt(ret_indexes[1], 0);
253 out_y2 =
derived().kdtree_get_pt(ret_indexes[1], 1);
254 out_dist_sqr2 = ret_sqdist[0];
261 float& outDistSqr1,
float& outDistSqr2)
const
263 float dmy1, dmy2, dmy3, dmy4;
265 p0.
x, p0.
y, dmy1, dmy2, dmy3, dmy4, outDistSqr1, outDistSqr2);
266 pOut1.
x =
static_cast<double>(dmy1);
267 pOut1.
y =
static_cast<double>(dmy2);
268 pOut2.
x =
static_cast<double>(dmy3);
269 pOut2.
y =
static_cast<double>(dmy4);
294 float x0,
float y0,
size_t knn, std::vector<float>& out_x,
295 std::vector<float>& out_y, std::vector<float>& out_dist_sqr)
const
302 std::vector<size_t> ret_indexes(knn);
305 out_dist_sqr.resize(knn);
308 resultSet.
init(&ret_indexes[0], &out_dist_sqr[0]);
316 for (
size_t i = 0; i < knn; i++)
318 out_x[i] =
derived().kdtree_get_pt(ret_indexes[i], 0);
319 out_y[i] =
derived().kdtree_get_pt(ret_indexes[i], 1);
326 const TPoint2D& p0,
size_t N, std::vector<TPoint2D>& pOut,
327 std::vector<float>& outDistSqr)
const
329 std::vector<float> dmy1, dmy2;
331 static_cast<float>(p0.
x),
static_cast<float>(p0.
y), N, dmy1, dmy2,
333 pOut.resize(dmy1.size());
334 for (
size_t i = 0; i < dmy1.size(); i++)
336 pOut[i].x =
static_cast<double>(dmy1[i]);
337 pOut[i].y =
static_cast<double>(dmy2[i]);
359 float x0,
float y0,
size_t knn, std::vector<size_t>& out_idx,
360 std::vector<float>& out_dist_sqr)
const
368 out_dist_sqr.resize(knn);
370 resultSet.
init(&out_idx[0], &out_dist_sqr[0]);
381 const TPoint2D& p0,
size_t N, std::vector<size_t>& outIdx,
382 std::vector<float>& outDistSqr)
const
385 static_cast<float>(p0.
x),
static_cast<float>(p0.
y), N, outIdx,
409 float x0,
float y0,
float z0,
float& out_x,
float& out_y,
float& out_z,
410 float& out_dist_sqr)
const
417 const size_t knn = 1;
420 resultSet.
init(&ret_index, &out_dist_sqr);
430 out_x =
derived().kdtree_get_pt(ret_index, 0);
431 out_y =
derived().kdtree_get_pt(ret_index, 1);
432 out_z =
derived().kdtree_get_pt(ret_index, 2);
440 float x0,
float y0,
float z0,
float& out_dist_sqr)
const
447 const size_t knn = 1;
450 resultSet.
init(&ret_index, &out_dist_sqr);
467 float dmy1, dmy2, dmy3;
469 static_cast<float>(p0.
x),
static_cast<float>(p0.
y),
470 static_cast<float>(p0.
z), dmy1, dmy2, dmy3, outDistSqr);
471 pOut.
x =
static_cast<double>(dmy1);
472 pOut.
y =
static_cast<double>(dmy2);
473 pOut.
z =
static_cast<double>(dmy3);
500 float x0,
float y0,
float z0,
size_t knn, std::vector<float>& out_x,
501 std::vector<float>& out_y, std::vector<float>& out_z,
502 std::vector<float>& out_dist_sqr)
const
509 std::vector<size_t> ret_indexes(knn);
513 out_dist_sqr.resize(knn);
516 resultSet.
init(&ret_indexes[0], &out_dist_sqr[0]);
525 for (
size_t i = 0; i < knn; i++)
527 out_x[i] =
derived().kdtree_get_pt(ret_indexes[i], 0);
528 out_y[i] =
derived().kdtree_get_pt(ret_indexes[i], 1);
529 out_z[i] =
derived().kdtree_get_pt(ret_indexes[i], 2);
558 float x0,
float y0,
float z0,
size_t knn, std::vector<float>& out_x,
559 std::vector<float>& out_y, std::vector<float>& out_z,
560 std::vector<size_t>& out_idx, std::vector<float>& out_dist_sqr)
const
571 out_dist_sqr.resize(knn);
574 resultSet.
init(&out_idx[0], &out_dist_sqr[0]);
583 for (
size_t i = 0; i < knn; i++)
585 out_x[i] =
derived().kdtree_get_pt(out_idx[i], 0);
586 out_y[i] =
derived().kdtree_get_pt(out_idx[i], 1);
587 out_z[i] =
derived().kdtree_get_pt(out_idx[i], 2);
593 const TPoint3D& p0,
size_t N, std::vector<TPoint3D>& pOut,
594 std::vector<float>& outDistSqr)
const
596 std::vector<float> dmy1, dmy2, dmy3;
598 static_cast<float>(p0.
x),
static_cast<float>(p0.
y),
599 static_cast<float>(p0.
z), N, dmy1, dmy2, dmy3, outDistSqr);
600 pOut.resize(dmy1.size());
601 for (
size_t i = 0; i < dmy1.size(); i++)
603 pOut[i].x =
static_cast<double>(dmy1[i]);
604 pOut[i].y =
static_cast<double>(dmy2[i]);
605 pOut[i].z =
static_cast<double>(dmy3[i]);
627 const num_t x0,
const num_t y0,
const num_t z0,
628 const num_t maxRadiusSqr,
629 std::vector<std::pair<size_t, num_t>>& out_indices_dist)
const
633 out_indices_dist.clear();
636 const num_t xyz[3] = {x0, y0, z0};
638 &xyz[0], maxRadiusSqr, out_indices_dist,
641 return out_indices_dist.size();
662 const num_t x0,
const num_t y0,
const num_t maxRadiusSqr,
663 std::vector<std::pair<size_t, num_t>>& out_indices_dist)
const
667 out_indices_dist.clear();
670 const num_t xyz[2] = {x0, y0};
672 &xyz[0], maxRadiusSqr, out_indices_dist,
675 return out_indices_dist.size();
697 float x0,
float y0,
float z0,
size_t knn, std::vector<size_t>& out_idx,
698 std::vector<float>& out_dist_sqr)
const
706 out_dist_sqr.resize(knn);
708 resultSet.
init(&out_idx[0], &out_dist_sqr[0]);
720 const TPoint3D& p0,
size_t N, std::vector<size_t>& outIdx,
721 std::vector<float>& outDistSqr)
const
724 static_cast<float>(p0.
x),
static_cast<float>(p0.
y),
725 static_cast<float>(p0.
z), N, outIdx, outDistSqr);
740 template <
int _DIM = -1>
753 if (&o !=
this)
clear();
763 std::unique_ptr<kdtree_index_t>
index;
795 const size_t N =
derived().kdtree_get_point_count();
829 const size_t N =
derived().kdtree_get_point_count();