OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::AABBTreeIndirect::detail Namespace Reference

Classes

struct  RayIntersector
struct  RayIntersectorHits
struct  IndexedTriangleSetDistancer

Functions

template<typename Derivedsource, typename Deriveddir, typename Scalar>
bool ray_box_intersect_invdir (const Eigen::MatrixBase< Derivedsource > &origin, const Eigen::MatrixBase< Deriveddir > &inv_dir, Eigen::AlignedBox< Scalar, 3 > box, const Scalar &t0, const Scalar &t1)
template<typename V, typename W>
std::enable_if_t< std::is_same< typename V::Scalar, double >::value &&std::is_same< typename W::Scalar, double >::value, bool > intersect_triangle (const V &orig, const V &dir, const W &vert0, const W &vert1, const W &vert2, double &t, double &u, double &v, double eps)
template<typename V, typename W>
std::enable_if_t< std::is_same< typename V::Scalar, double >::value &&!std::is_same< typename W::Scalar, double >::value, bool > intersect_triangle (const V &origin, const V &dir, const W &v0, const W &v1, const W &v2, double &t, double &u, double &v, double eps)
template<typename V, typename W>
std::enable_if_t<! std::is_same< typename V::Scalar, double >::value &&std::is_same< typename W::Scalar, double >::value, bool > intersect_triangle (const V &origin, const V &dir, const W &v0, const W &v1, const W &v2, double &t, double &u, double &v, double eps)
template<typename V, typename W>
std::enable_if_t<! std::is_same< typename V::Scalar, double >::value &&! std::is_same< typename W::Scalar, double >::value, bool > intersect_triangle (const V &origin, const V &dir, const W &v0, const W &v1, const W &v2, double &t, double &u, double &v, double eps)
template<typename Tree>
double intersect_triangle_epsilon (const Tree &tree)
template<typename RayIntersectorType, typename Scalar>
static bool intersect_ray_recursive_first_hit (RayIntersectorType &ray_intersector, size_t node_idx, Scalar min_t, igl::Hit< float > &hit)
template<typename RayIntersectorType>
static void intersect_ray_recursive_all_hits (RayIntersectorType &ray_intersector, size_t node_idx)
template<typename Vector>
static Vector closest_point_to_triangle (const Vector &p, const Vector &a, const Vector &b, const Vector &c)
template<typename IndexedPrimitivesDistancerType, typename Scalar>
static Scalar squared_distance_to_indexed_primitives_recursive (IndexedPrimitivesDistancerType &distancer, size_t node_idx, Scalar low_sqr_d, Scalar up_sqr_d, size_t &i, Eigen::PlainObjectBase< typename IndexedPrimitivesDistancerType::VectorType > &c)
template<typename IndexedPrimitivesDistancerType, typename Scalar>
static void indexed_primitives_within_distance_squared_recurisve (const IndexedPrimitivesDistancerType &distancer, size_t node_idx, Scalar squared_distance_limit, std::vector< size_t > &found_primitives_indices)
template<int Dims, typename T, typename Pred, typename Fn>
bool traverse_recurse (const Tree< Dims, T > &tree, size_t idx, Pred &&pred, Fn &&callback)

Class Documentation

◆ Slic3r::AABBTreeIndirect::detail::RayIntersector

struct Slic3r::AABBTreeIndirect::detail::RayIntersector
template<typename AVertexType, typename AIndexedFaceType, typename ATreeType, typename AVectorType>
struct Slic3r::AABBTreeIndirect::detail::RayIntersector< AVertexType, AIndexedFaceType, ATreeType, AVectorType >
Inheritance diagram for Slic3r::AABBTreeIndirect::detail::RayIntersector< AVertexType, AIndexedFaceType, ATreeType, AVectorType >:
Collaboration diagram for Slic3r::AABBTreeIndirect::detail::RayIntersector< AVertexType, AIndexedFaceType, ATreeType, AVectorType >:
Class Members
typedef AIndexedFaceType IndexedFaceType AIndexedFaceType
typedef ATreeType TreeType ATreeType
typedef AVectorType VectorType AVectorType
typedef AVertexType VertexType AVertexType
Class Members
const VectorType dir
const double eps
const vector< IndexedFaceType > & faces
const VectorType invdir
const VectorType origin
const TreeType & tree
const vector< VertexType > & vertices

Function Documentation

◆ closest_point_to_triangle()

template<typename Vector>
Vector Slic3r::AABBTreeIndirect::detail::closest_point_to_triangle ( const Vector & p,
const Vector & a,
const Vector & b,
const Vector & c )
inlinestatic
481 {
482 using Scalar = typename Vector::Scalar;
483 // Check if P in vertex region outside A
484 Vector ab = b - a;
485 Vector ac = c - a;
486 Vector ap = p - a;
487 Scalar d1 = ab.dot(ap);
488 Scalar d2 = ac.dot(ap);
489 if (d1 <= 0 && d2 <= 0)
490 return a;
491 // Check if P in vertex region outside B
492 Vector bp = p - b;
493 Scalar d3 = ab.dot(bp);
494 Scalar d4 = ac.dot(bp);
495 if (d3 >= 0 && d4 <= d3)
496 return b;
497 // Check if P in edge region of AB, if so return projection of P onto AB
498 Scalar vc = d1*d4 - d3*d2;
499 if (a != b && vc <= 0 && d1 >= 0 && d3 <= 0) {
500 Scalar v = d1 / (d1 - d3);
501 return a + v * ab;
502 }
503 // Check if P in vertex region outside C
504 Vector cp = p - c;
505 Scalar d5 = ab.dot(cp);
506 Scalar d6 = ac.dot(cp);
507 if (d6 >= 0 && d5 <= d6)
508 return c;
509 // Check if P in edge region of AC, if so return projection of P onto AC
510 Scalar vb = d5*d2 - d1*d6;
511 if (vb <= 0 && d2 >= 0 && d6 <= 0) {
512 Scalar w = d2 / (d2 - d6);
513 return a + w * ac;
514 }
515 // Check if P in edge region of BC, if so return projection of P onto BC
516 Scalar va = d3*d6 - d5*d4;
517 if (va <= 0 && (d4 - d3) >= 0 && (d5 - d6) >= 0) {
518 Scalar w = (d4 - d3) / ((d4 - d3) + (d5 - d6));
519 return b + w * (c - b);
520 }
521 // P inside face region. Compute Q through its barycentric coordinates (u,v,w)
522 Scalar denom = Scalar(1.0) / (va + vb + vc);
523 Scalar v = vb * denom;
524 Scalar w = vc * denom;
525 return a + ab * v + ac * w; // = u*a + v*b + w*c, u = va * denom = 1.0-v-w
526 };
Point Vector
Definition Point.hpp:42

Referenced by Slic3r::AABBTreeIndirect::detail::IndexedTriangleSetDistancer< AVertexType, AIndexedFaceType, ATreeType, AVectorType >::closest_point_to_origin().

Here is the caller graph for this function:

◆ indexed_primitives_within_distance_squared_recurisve()

template<typename IndexedPrimitivesDistancerType, typename Scalar>
void Slic3r::AABBTreeIndirect::detail::indexed_primitives_within_distance_squared_recurisve ( const IndexedPrimitivesDistancerType & distancer,
size_t node_idx,
Scalar squared_distance_limit,
std::vector< size_t > & found_primitives_indices )
inlinestatic
644 {
645 const auto &node = distancer.tree.node(node_idx);
646 assert(node.is_valid());
647 if (node.is_leaf()) {
648 Scalar sqr_dist;
649 distancer.closest_point_to_origin(node.idx, sqr_dist);
650 if (sqr_dist < squared_distance_limit) { found_primitives_indices.push_back(node.idx); }
651 } else {
652 size_t left_node_idx = node_idx * 2 + 1;
653 size_t right_node_idx = left_node_idx + 1;
654 const auto &node_left = distancer.tree.node(left_node_idx);
655 const auto &node_right = distancer.tree.node(right_node_idx);
656 assert(node_left.is_valid());
657 assert(node_right.is_valid());
658
659 if (node_left.bbox.squaredExteriorDistance(distancer.origin) < squared_distance_limit) {
660 indexed_primitives_within_distance_squared_recurisve(distancer, left_node_idx, squared_distance_limit,
661 found_primitives_indices);
662 }
663 if (node_right.bbox.squaredExteriorDistance(distancer.origin) < squared_distance_limit) {
664 indexed_primitives_within_distance_squared_recurisve(distancer, right_node_idx, squared_distance_limit,
665 found_primitives_indices);
666 }
667 }
668 }
static void indexed_primitives_within_distance_squared_recurisve(const IndexedPrimitivesDistancerType &distancer, size_t node_idx, Scalar squared_distance_limit, std::vector< size_t > &found_primitives_indices)
Definition AABBTreeIndirect.hpp:640

References indexed_primitives_within_distance_squared_recurisve().

Referenced by Slic3r::AABBTreeLines::all_lines_in_radius(), Slic3r::AABBTreeIndirect::all_triangles_in_radius(), and indexed_primitives_within_distance_squared_recurisve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ intersect_ray_recursive_all_hits()

template<typename RayIntersectorType>
void Slic3r::AABBTreeIndirect::detail::intersect_ray_recursive_all_hits ( RayIntersectorType & ray_intersector,
size_t node_idx )
inlinestatic
449 {
450 using Scalar = typename RayIntersectorType::VectorType::Scalar;
451
452 const auto &node = ray_intersector.tree.node(node_idx);
453 assert(node.is_valid());
454
455 if (! ray_box_intersect_invdir(ray_intersector.origin, ray_intersector.invdir, node.bbox.template cast<Scalar>(),
456 Scalar(0), std::numeric_limits<Scalar>::infinity()))
457 return;
458
459 if (node.is_leaf()) {
460 auto face = ray_intersector.faces[node.idx];
461 double t, u, v;
463 ray_intersector.origin, ray_intersector.dir,
464 ray_intersector.vertices[face(0)], ray_intersector.vertices[face(1)], ray_intersector.vertices[face(2)],
465 t, u, v, ray_intersector.eps)
466 && t > 0.) {
467 ray_intersector.hits.emplace_back(igl::Hit<float>{ int(node.idx), -1, float(u), float(v), float(t) });
468 }
469 } else {
470 // Left / right child node index.
471 size_t left = node_idx * 2 + 1;
472 size_t right = left + 1;
473 intersect_ray_recursive_all_hits(ray_intersector, left);
474 intersect_ray_recursive_all_hits(ray_intersector, right);
475 }
476 }
bool ray_box_intersect_invdir(const Eigen::MatrixBase< Derivedsource > &origin, const Eigen::MatrixBase< Deriveddir > &inv_dir, Eigen::AlignedBox< Scalar, 3 > box, const Scalar &t0, const Scalar &t1)
Definition AABBTreeIndirect.hpp:274
static void intersect_ray_recursive_all_hits(RayIntersectorType &ray_intersector, size_t node_idx)
Definition AABBTreeIndirect.hpp:448
std::enable_if_t< std::is_same< typename V::Scalar, double >::value &&std::is_same< typename W::Scalar, double >::value, bool > intersect_triangle(const V &orig, const V &dir, const W &vert0, const W &vert1, const W &vert2, double &t, double &u, double &v, double eps)
Definition AABBTreeIndirect.hpp:321
auto cast(const BoundingBoxBase< Tin > &b)
Definition BoundingBox.hpp:299

References Slic3r::cast(), intersect_ray_recursive_all_hits(), intersect_triangle(), and ray_box_intersect_invdir().

Referenced by Slic3r::AABBTreeIndirect::intersect_ray_all_hits(), and intersect_ray_recursive_all_hits().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ intersect_ray_recursive_first_hit()

template<typename RayIntersectorType, typename Scalar>
bool Slic3r::AABBTreeIndirect::detail::intersect_ray_recursive_first_hit ( RayIntersectorType & ray_intersector,
size_t node_idx,
Scalar min_t,
igl::Hit< float > & hit )
inlinestatic
406 {
407 const auto &node = ray_intersector.tree.node(node_idx);
408 assert(node.is_valid());
409
410 if (! ray_box_intersect_invdir(ray_intersector.origin, ray_intersector.invdir, node.bbox.template cast<Scalar>(), Scalar(0), min_t))
411 return false;
412
413 if (node.is_leaf()) {
414 // shoot ray, record hit
415 auto face = ray_intersector.faces[node.idx];
416 double t, u, v;
418 ray_intersector.origin, ray_intersector.dir,
419 ray_intersector.vertices[face(0)], ray_intersector.vertices[face(1)], ray_intersector.vertices[face(2)],
420 t, u, v, ray_intersector.eps)
421 && t > 0.) {
422 hit = igl::Hit<float> { int(node.idx), -1, float(u), float(v), float(t) };
423 return true;
424 } else
425 return false;
426 } else {
427 // Left / right child node index.
428 size_t left = node_idx * 2 + 1;
429 size_t right = left + 1;
430 igl::Hit<float> left_hit;
431 igl::Hit<float> right_hit;
432 bool left_ret = intersect_ray_recursive_first_hit(ray_intersector, left, min_t, left_hit);
433 if (left_ret && left_hit.t < min_t) {
434 min_t = left_hit.t;
435 hit = left_hit;
436 } else
437 left_ret = false;
438 bool right_ret = intersect_ray_recursive_first_hit(ray_intersector, right, min_t, right_hit);
439 if (right_ret && right_hit.t < min_t)
440 hit = right_hit;
441 else
442 right_ret = false;
443 return left_ret || right_ret;
444 }
445 }
static bool intersect_ray_recursive_first_hit(RayIntersectorType &ray_intersector, size_t node_idx, Scalar min_t, igl::Hit< float > &hit)
Definition AABBTreeIndirect.hpp:401

References Slic3r::cast(), intersect_ray_recursive_first_hit(), intersect_triangle(), and ray_box_intersect_invdir().

Referenced by Slic3r::AABBTreeIndirect::intersect_ray_first_hit(), and intersect_ray_recursive_first_hit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ intersect_triangle() [1/4]

template<typename V, typename W>
std::enable_if_t< std::is_same< typename V::Scalar, double >::value &&std::is_same< typename W::Scalar, double >::value, bool > Slic3r::AABBTreeIndirect::detail::intersect_triangle ( const V & orig,
const V & dir,
const W & vert0,
const W & vert1,
const W & vert2,
double & t,
double & u,
double & v,
double eps )
322 {
323 // find vectors for two edges sharing vert0
324 const V edge1 = vert1 - vert0;
325 const V edge2 = vert2 - vert0;
326 // begin calculating determinant - also used to calculate U parameter
327 const V pvec = dir.cross(edge2);
328 // if determinant is near zero, ray lies in plane of triangle
329 const double det = edge1.dot(pvec);
330 V qvec;
331
332 if (det > eps) {
333 // calculate distance from vert0 to ray origin
334 V tvec = orig - vert0;
335 // calculate U parameter and test bounds
336 u = tvec.dot(pvec);
337 if (u < 0.0 || u > det)
338 return false;
339 // prepare to test V parameter
340 qvec = tvec.cross(edge1);
341 // calculate V parameter and test bounds
342 v = dir.dot(qvec);
343 if (v < 0.0 || u + v > det)
344 return false;
345 } else if (det < -eps) {
346 // calculate distance from vert0 to ray origin
347 V tvec = orig - vert0;
348 // calculate U parameter and test bounds
349 u = tvec.dot(pvec);
350 if (u > 0.0 || u < det)
351 return false;
352 // prepare to test V parameter
353 qvec = tvec.cross(edge1);
354 // calculate V parameter and test bounds
355 v = dir.dot(qvec);
356 if (v > 0.0 || u + v < det)
357 return false;
358 } else
359 // ray is parallel to the plane of the triangle
360 return false;
361
362 double inv_det = 1.0 / det;
363 // calculate t, ray intersects triangle
364 t = edge2.dot(qvec) * inv_det;
365 u *= inv_det;
366 v *= inv_det;
367 return true;
368 }

Referenced by intersect_ray_recursive_all_hits(), intersect_ray_recursive_first_hit(), intersect_triangle(), and Slic3r::anonymous_namespace{Model.cpp}::mesh_contains_point_linear().

Here is the caller graph for this function:

◆ intersect_triangle() [2/4]

template<typename V, typename W>
std::enable_if_t<! std::is_same< typename V::Scalar, double >::value &&! std::is_same< typename W::Scalar, double >::value, bool > Slic3r::AABBTreeIndirect::detail::intersect_triangle ( const V & origin,
const V & dir,
const W & v0,
const W & v1,
const W & v2,
double & t,
double & u,
double & v,
double eps )
384 {
385 return intersect_triangle(origin.template cast<double>(), dir.template cast<double>(), v0.template cast<double>(), v1.template cast<double>(), v2.template cast<double>(), t, u, v, eps);
386 }

References Slic3r::cast(), and intersect_triangle().

Here is the call graph for this function:

◆ intersect_triangle() [3/4]

template<typename V, typename W>
std::enable_if_t<! std::is_same< typename V::Scalar, double >::value &&std::is_same< typename W::Scalar, double >::value, bool > Slic3r::AABBTreeIndirect::detail::intersect_triangle ( const V & origin,
const V & dir,
const W & v0,
const W & v1,
const W & v2,
double & t,
double & u,
double & v,
double eps )
378 {
379 return intersect_triangle(origin.template cast<double>(), dir.template cast<double>(), v0, v1, v2, t, u, v, eps);
380 }

References Slic3r::cast(), and intersect_triangle().

Here is the call graph for this function:

◆ intersect_triangle() [4/4]

template<typename V, typename W>
std::enable_if_t< std::is_same< typename V::Scalar, double >::value &&!std::is_same< typename W::Scalar, double >::value, bool > Slic3r::AABBTreeIndirect::detail::intersect_triangle ( const V & origin,
const V & dir,
const W & v0,
const W & v1,
const W & v2,
double & t,
double & u,
double & v,
double eps )
372 {
373 return intersect_triangle(origin, dir, v0.template cast<double>(), v1.template cast<double>(), v2.template cast<double>(), t, u, v, eps);
374 }

References Slic3r::cast(), and intersect_triangle().

Here is the call graph for this function:

◆ intersect_triangle_epsilon()

template<typename Tree>
double Slic3r::AABBTreeIndirect::detail::intersect_triangle_epsilon ( const Tree & tree)
389 {
390 double eps = 0.000001;
391 if (! tree.empty()) {
392 const typename Tree::BoundingBox &bbox = tree.nodes().front().bbox;
393 double l = (bbox.max() - bbox.min()).cwiseMax();
394 if (l > 0)
395 eps /= (l * l);
396 }
397 return eps;
398 }
const std::vector< Node > & nodes() const
Definition AABBTreeIndirect.hpp:109
bool empty() const
Definition AABBTreeIndirect.hpp:111
Eigen::AlignedBox< CoordType, NumDimensions > BoundingBox
Definition AABBTreeIndirect.hpp:50

References Slic3r::AABBTreeIndirect::Tree< ANumDimensions, ACoordType >::empty(), and Slic3r::AABBTreeIndirect::Tree< ANumDimensions, ACoordType >::nodes().

Here is the call graph for this function:

◆ ray_box_intersect_invdir()

template<typename Derivedsource, typename Deriveddir, typename Scalar>
bool Slic3r::AABBTreeIndirect::detail::ray_box_intersect_invdir ( const Eigen::MatrixBase< Derivedsource > & origin,
const Eigen::MatrixBase< Deriveddir > & inv_dir,
Eigen::AlignedBox< Scalar, 3 > box,
const Scalar & t0,
const Scalar & t1 )
inline
279 {
280 // http://people.csail.mit.edu/amy/papers/box-jgt.pdf
281 // "An Efficient and Robust Ray–Box Intersection Algorithm"
282 if (inv_dir.x() < 0)
283 std::swap(box.min().x(), box.max().x());
284 if (inv_dir.y() < 0)
285 std::swap(box.min().y(), box.max().y());
286 Scalar tmin = (box.min().x() - origin.x()) * inv_dir.x();
287 Scalar tymax = (box.max().y() - origin.y()) * inv_dir.y();
288 if (tmin > tymax)
289 return false;
290 Scalar tmax = (box.max().x() - origin.x()) * inv_dir.x();
291 Scalar tymin = (box.min().y() - origin.y()) * inv_dir.y();
292 if (tymin > tmax)
293 return false;
294 if (tymin > tmin)
295 tmin = tymin;
296 if (tymax < tmax)
297 tmax = tymax;
298 if (inv_dir.z() < 0)
299 std::swap(box.min().z(), box.max().z());
300 Scalar tzmin = (box.min().z() - origin.z()) * inv_dir.z();
301 if (tzmin > tmax)
302 return false;
303 Scalar tzmax = (box.max().z() - origin.z()) * inv_dir.z();
304 if (tmin > tzmax)
305 return false;
306 if (tzmin > tmin)
307 tmin = tzmin;
308 if (tzmax < tmax)
309 tmax = tzmax;
310 return tmin < t1 && tmax > t0;
311 }

Referenced by intersect_ray_recursive_all_hits(), and intersect_ray_recursive_first_hit().

Here is the caller graph for this function:

◆ squared_distance_to_indexed_primitives_recursive()

template<typename IndexedPrimitivesDistancerType, typename Scalar>
Scalar Slic3r::AABBTreeIndirect::detail::squared_distance_to_indexed_primitives_recursive ( IndexedPrimitivesDistancerType & distancer,
size_t node_idx,
Scalar low_sqr_d,
Scalar up_sqr_d,
size_t & i,
Eigen::PlainObjectBase< typename IndexedPrimitivesDistancerType::VectorType > & c )
inlinestatic
564 {
565 using Vector = typename IndexedPrimitivesDistancerType::VectorType;
566
567 if (low_sqr_d > up_sqr_d)
568 return low_sqr_d;
569
570 // Save the best achieved hit.
571 auto set_min = [&i, &c, &up_sqr_d](const Scalar sqr_d_candidate, const size_t i_candidate, const Vector &c_candidate) {
572 if (sqr_d_candidate < up_sqr_d) {
573 i = i_candidate;
574 c = c_candidate;
575 up_sqr_d = sqr_d_candidate;
576 }
577 };
578
579 const auto &node = distancer.tree.node(node_idx);
580 assert(node.is_valid());
581 if (node.is_leaf())
582 {
583 Scalar sqr_dist;
584 Vector c_candidate = distancer.closest_point_to_origin(node.idx, sqr_dist);
585 set_min(sqr_dist, node.idx, c_candidate);
586 }
587 else
588 {
589 size_t left_node_idx = node_idx * 2 + 1;
590 size_t right_node_idx = left_node_idx + 1;
591 const auto &node_left = distancer.tree.node(left_node_idx);
592 const auto &node_right = distancer.tree.node(right_node_idx);
593 assert(node_left.is_valid());
594 assert(node_right.is_valid());
595
596 bool looked_left = false;
597 bool looked_right = false;
598 const auto &look_left = [&]()
599 {
600 size_t i_left;
601 Vector c_left = c;
602 Scalar sqr_d_left = squared_distance_to_indexed_primitives_recursive(distancer, left_node_idx, low_sqr_d, up_sqr_d, i_left, c_left);
603 set_min(sqr_d_left, i_left, c_left);
604 looked_left = true;
605 };
606 const auto &look_right = [&]()
607 {
608 size_t i_right;
609 Vector c_right = c;
610 Scalar sqr_d_right = squared_distance_to_indexed_primitives_recursive(distancer, right_node_idx, low_sqr_d, up_sqr_d, i_right, c_right);
611 set_min(sqr_d_right, i_right, c_right);
612 looked_right = true;
613 };
614
615 // must look left or right if in box
616 using BBoxScalar = typename IndexedPrimitivesDistancerType::TreeType::BoundingBox::Scalar;
617 if (node_left.bbox.contains(distancer.origin.template cast<BBoxScalar>()))
618 look_left();
619 if (node_right.bbox.contains(distancer.origin.template cast<BBoxScalar>()))
620 look_right();
621 // if haven't looked left and could be less than current min, then look
622 Scalar left_up_sqr_d = node_left.bbox.squaredExteriorDistance(distancer.origin);
623 Scalar right_up_sqr_d = node_right.bbox.squaredExteriorDistance(distancer.origin);
624 if (left_up_sqr_d < right_up_sqr_d) {
625 if (! looked_left && left_up_sqr_d < up_sqr_d)
626 look_left();
627 if (! looked_right && right_up_sqr_d < up_sqr_d)
628 look_right();
629 } else {
630 if (! looked_right && right_up_sqr_d < up_sqr_d)
631 look_right();
632 if (! looked_left && left_up_sqr_d < up_sqr_d)
633 look_left();
634 }
635 }
636 return up_sqr_d;
637 }
static Scalar squared_distance_to_indexed_primitives_recursive(IndexedPrimitivesDistancerType &distancer, size_t node_idx, Scalar low_sqr_d, Scalar up_sqr_d, size_t &i, Eigen::PlainObjectBase< typename IndexedPrimitivesDistancerType::VectorType > &c)
Definition AABBTreeIndirect.hpp:557
typename Traits< remove_cvref_t< L > >::Scalar Scalar
Definition Line.hpp:39

References Slic3r::cast(), and squared_distance_to_indexed_primitives_recursive().

Referenced by Slic3r::AABBTreeIndirect::is_any_triangle_in_radius(), Slic3r::AABBTreeLines::squared_distance_to_indexed_lines(), squared_distance_to_indexed_primitives_recursive(), and Slic3r::AABBTreeIndirect::squared_distance_to_indexed_triangle_set().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ traverse_recurse()

template<int Dims, typename T, typename Pred, typename Fn>
bool Slic3r::AABBTreeIndirect::detail::traverse_recurse ( const Tree< Dims, T > & tree,
size_t idx,
Pred && pred,
Fn && callback )
953{
954 assert(tree.node(idx).is_valid());
955
956 if (!pred(tree.node(idx)))
957 // Continue traversal.
958 return true;
959
960 if (tree.node(idx).is_leaf()) {
961 // Callback returns true to continue traversal, false to stop traversal.
962 return callback(tree.node(idx));
963 } else {
964
965 // call this with left and right node idx:
966 auto trv = [&](size_t idx) -> bool {
967 return traverse_recurse(tree, idx, std::forward<Pred>(pred),
968 std::forward<Fn>(callback));
969 };
970
971 // Left / right child node index.
972 // Returns true if both children allow the traversal to continue.
973 return trv(Tree<Dims, T>::left_child_idx(idx)) &&
975 }
976}
const Node & node(size_t idx) const
Definition AABBTreeIndirect.hpp:110
static size_t left_child_idx(size_t idx)
Definition AABBTreeIndirect.hpp:114
static size_t right_child_idx(size_t idx)
Definition AABBTreeIndirect.hpp:115
bool traverse_recurse(const Tree< Dims, T > &tree, size_t idx, Pred &&pred, Fn &&callback)
Definition AABBTreeIndirect.hpp:949
bool is_leaf() const
Definition AABBTreeIndirect.hpp:70
bool is_valid() const
Definition AABBTreeIndirect.hpp:68

References Slic3r::AABBTreeIndirect::Tree< ANumDimensions, ACoordType >::Node::is_leaf(), Slic3r::AABBTreeIndirect::Tree< ANumDimensions, ACoordType >::Node::is_valid(), Slic3r::AABBTreeIndirect::Tree< ANumDimensions, ACoordType >::left_child_idx(), Slic3r::AABBTreeIndirect::Tree< ANumDimensions, ACoordType >::node(), Slic3r::AABBTreeIndirect::Tree< ANumDimensions, ACoordType >::right_child_idx(), and traverse_recurse().

Referenced by Slic3r::AABBTreeIndirect::traverse(), and traverse_recurse().

Here is the call graph for this function:
Here is the caller graph for this function: