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

Namespaces

namespace  detail

Classes

class  Tree
class  BoundingBoxWrapper
struct  Intersecting
struct  Intersecting< Eigen::AlignedBox< CoordType, NumD > >
struct  Within
struct  Within< Eigen::AlignedBox< CoordType, NumD > >

Typedefs

using Tree2f = Tree<2, float>
using Tree3f = Tree<3, float>
using Tree2d = Tree<2, double>
using Tree3d = Tree<3, double>

Functions

template<typename VertexType, typename IndexedFaceType>
Tree< 3, typename VertexType::Scalar > build_aabb_tree_over_indexed_triangle_set (const std::vector< VertexType > &vertices, const std::vector< IndexedFaceType > &faces, const typename VertexType::Scalar eps=0)
template<typename VertexType, typename IndexedFaceType, typename TreeType, typename VectorType>
bool intersect_ray_first_hit (const std::vector< VertexType > &vertices, const std::vector< IndexedFaceType > &faces, const TreeType &tree, const VectorType &origin, const VectorType &dir, igl::Hit< float > &hit, const double eps=0.000001)
template<typename VertexType, typename IndexedFaceType, typename TreeType, typename VectorType>
bool intersect_ray_all_hits (const std::vector< VertexType > &vertices, const std::vector< IndexedFaceType > &faces, const TreeType &tree, const VectorType &origin, const VectorType &dir, std::vector< igl::Hit< float > > &hits, const double eps=0.000001)
template<typename VertexType, typename IndexedFaceType, typename TreeType, typename VectorType>
VectorType::Scalar squared_distance_to_indexed_triangle_set (const std::vector< VertexType > &vertices, const std::vector< IndexedFaceType > &faces, const TreeType &tree, const VectorType &point, size_t &hit_idx_out, Eigen::PlainObjectBase< VectorType > &hit_point_out)
template<typename VertexType, typename IndexedFaceType, typename TreeType, typename VectorType>
bool is_any_triangle_in_radius (const std::vector< VertexType > &vertices, const std::vector< IndexedFaceType > &faces, const TreeType &tree, const VectorType &point, typename VectorType::Scalar &max_distance_squared)
template<typename VertexType, typename IndexedFaceType, typename TreeType, typename VectorType>
std::vector< size_t > all_triangles_in_radius (const std::vector< VertexType > &vertices, const std::vector< IndexedFaceType > &faces, const TreeType &tree, const VectorType &point, typename VectorType::Scalar max_distance_squared)
template<typename TreeType, typename VectorType>
void get_candidate_idxs (const TreeType &tree, const VectorType &v, std::vector< size_t > &candidates, size_t node_idx=0)
template<class G>
auto intersecting (const G &g)
template<class G>
auto within (const G &g)
template<int Dims, typename T, typename Predicate, typename Fn>
void traverse (const Tree< Dims, T > &tree, Predicate &&pred, Fn &&callback)

Class Documentation

◆ Slic3r::AABBTreeIndirect::Intersecting

struct Slic3r::AABBTreeIndirect::Intersecting
template<class G>
struct Slic3r::AABBTreeIndirect::Intersecting< G >
Inheritance diagram for Slic3r::AABBTreeIndirect::Intersecting< G >:

◆ Slic3r::AABBTreeIndirect::Within

struct Slic3r::AABBTreeIndirect::Within
template<class G>
struct Slic3r::AABBTreeIndirect::Within< G >
Inheritance diagram for Slic3r::AABBTreeIndirect::Within< G >:

Typedef Documentation

◆ Tree2d

◆ Tree2f

◆ Tree3d

◆ Tree3f

Function Documentation

◆ all_triangles_in_radius()

template<typename VertexType, typename IndexedFaceType, typename TreeType, typename VectorType>
std::vector< size_t > Slic3r::AABBTreeIndirect::all_triangles_in_radius ( const std::vector< VertexType > & vertices,
const std::vector< IndexedFaceType > & faces,
const TreeType & tree,
const VectorType & point,
typename VectorType::Scalar max_distance_squared )
inline
869{
871 { vertices, faces, tree, point };
872
873 if(tree.empty())
874 {
875 return {};
876 }
877
878 std::vector<size_t> found_triangles{};
879 detail::indexed_primitives_within_distance_squared_recurisve(distancer, size_t(0), max_distance_squared, found_triangles);
880 return found_triangles;
881}
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 Slic3r::AABBTreeIndirect::detail::indexed_primitives_within_distance_squared_recurisve().

Here is the call graph for this function:

◆ build_aabb_tree_over_indexed_triangle_set()

template<typename VertexType, typename IndexedFaceType>
Tree< 3, typename VertexType::Scalar > Slic3r::AABBTreeIndirect::build_aabb_tree_over_indexed_triangle_set ( const std::vector< VertexType > & vertices,
const std::vector< IndexedFaceType > & faces,
const typename VertexType::Scalar eps = 0 )
inline
684{
686// using CoordType = typename TreeType::CoordType;
687 using VectorType = typename TreeType::VectorType;
688 using BoundingBox = typename TreeType::BoundingBox;
689
690 struct InputType {
691 size_t idx() const { return m_idx; }
692 const BoundingBox& bbox() const { return m_bbox; }
693 const VectorType& centroid() const { return m_centroid; }
694
695 size_t m_idx;
696 BoundingBox m_bbox;
697 VectorType m_centroid;
698 };
699
700 std::vector<InputType> input;
701 input.reserve(faces.size());
702 const VectorType veps(eps, eps, eps);
703 for (size_t i = 0; i < faces.size(); ++ i) {
704 const IndexedFaceType &face = faces[i];
705 const VertexType &v1 = vertices[face(0)];
706 const VertexType &v2 = vertices[face(1)];
707 const VertexType &v3 = vertices[face(2)];
708 InputType n;
709 n.m_idx = i;
710 n.m_centroid = (1./3.) * (v1 + v2 + v3);
711 n.m_bbox = BoundingBox(v1, v1);
712 n.m_bbox.extend(v2);
713 n.m_bbox.extend(v3);
714 n.m_bbox.min() -= veps;
715 n.m_bbox.max() += veps;
716 input.emplace_back(n);
717 }
718
719 TreeType out;
720 out.build(std::move(input));
721 return out;
722}
Definition AABBTreeIndirect.hpp:45
Definition BoundingBox.hpp:212

Referenced by Slic3r::anonymous_namespace{TextureDisplacement.cpp}::build_texture_displacement_v2(), Slic3r::SeamPlacerImpl::compute_global_occlusion(), Slic3r::SeamPlacerImpl::gather_enforcers_blockers(), Slic3r::AABBMesh::AABBImpl::init(), Slic3r::sla::IndexedMesh::AABBImpl::init(), Slic3r::GUI::GLGizmoTextureDisplacement::prepare_mesh(), Slic3r::anonymous_namespace{TextureDisplacement.cpp}::prepare_sampleable_layers(), Slic3r::TriangleSelector::remap_painting(), Slic3r::tex2color::color_utils::remesh_mesh(), Slic3r::tex2color::repair_cluster_smooth(), Slic3r::transfer_facet_paint(), and Slic3r::transfer_uv_channel().

Here is the caller graph for this function:

◆ get_candidate_idxs()

template<typename TreeType, typename VectorType>
void Slic3r::AABBTreeIndirect::get_candidate_idxs ( const TreeType & tree,
const VectorType & v,
std::vector< size_t > & candidates,
size_t node_idx = 0 )
888{
889 if (tree.empty() || ! tree.node(node_idx).bbox.contains(v))
890 return;
891
892 decltype(tree.node(node_idx)) node = tree.node(node_idx);
893 static_assert(std::is_reference<decltype(node)>::value,
894 "Nodes shall be addressed by reference.");
895 assert(node.is_valid());
896 assert(node.bbox.contains(v));
897
898 if (! node.is_leaf()) {
899 if (tree.left_child(node_idx).bbox.contains(v))
900 get_candidate_idxs(tree, v, candidates, tree.left_child_idx(node_idx));
901 if (tree.right_child(node_idx).bbox.contains(v))
902 get_candidate_idxs(tree, v, candidates, tree.right_child_idx(node_idx));
903 } else
904 candidates.push_back(node.idx);
905
906 return;
907}
void get_candidate_idxs(const TreeType &tree, const VectorType &v, std::vector< size_t > &candidates, size_t node_idx=0)
Definition AABBTreeIndirect.hpp:887

References get_candidate_idxs().

Referenced by get_candidate_idxs().

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

◆ intersect_ray_all_hits()

template<typename VertexType, typename IndexedFaceType, typename TreeType, typename VectorType>
bool Slic3r::AABBTreeIndirect::intersect_ray_all_hits ( const std::vector< VertexType > & vertices,
const std::vector< IndexedFaceType > & faces,
const TreeType & tree,
const VectorType & origin,
const VectorType & dir,
std::vector< igl::Hit< float > > & hits,
const double eps = 0.000001 )
inline
775{
777 { vertices, faces, {tree},
778 origin, dir, VectorType(dir.cwiseInverse()),
779 eps }
780 };
781 if (tree.empty()) {
782 hits.clear();
783 } else {
784 // Reusing the output memory if there is some memory already pre-allocated.
785 ray_intersector.hits = std::move(hits);
786 ray_intersector.hits.clear();
787 ray_intersector.hits.reserve(8);
789 hits = std::move(ray_intersector.hits);
790 std::sort(hits.begin(), hits.end(), [](const auto &l, const auto &r) { return l.t < r.t; });
791 }
792 return ! hits.empty();
793}
static void intersect_ray_recursive_all_hits(RayIntersectorType &ray_intersector, size_t node_idx)
Definition AABBTreeIndirect.hpp:448
Definition AABBTreeIndirect.hpp:264

References Slic3r::AABBTreeIndirect::detail::intersect_ray_recursive_all_hits().

Referenced by Slic3r::AABBMesh::AABBImpl::intersect_ray(), and Slic3r::sla::IndexedMesh::AABBImpl::intersect_ray().

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

◆ intersect_ray_first_hit()

template<typename VertexType, typename IndexedFaceType, typename TreeType, typename VectorType>
bool Slic3r::AABBTreeIndirect::intersect_ray_first_hit ( const std::vector< VertexType > & vertices,
const std::vector< IndexedFaceType > & faces,
const TreeType & tree,
const VectorType & origin,
const VectorType & dir,
igl::Hit< float > & hit,
const double eps = 0.000001 )
inline
743{
744 using Scalar = typename VectorType::Scalar;
746 vertices, faces, tree,
747 origin, dir, VectorType(dir.cwiseInverse()),
748 eps
749 };
750 return ! tree.empty() && detail::intersect_ray_recursive_first_hit(
751 ray_intersector, size_t(0), std::numeric_limits<Scalar>::infinity(), hit);
752}
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
Definition AABBTreeIndirect.hpp:245

References Slic3r::AABBTreeIndirect::detail::intersect_ray_recursive_first_hit().

Referenced by Slic3r::AABBMesh::AABBImpl::intersect_ray(), and Slic3r::sla::IndexedMesh::AABBImpl::intersect_ray().

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

◆ intersecting()

template<class G>
auto Slic3r::AABBTreeIndirect::intersecting ( const G & g)
925{ return Intersecting<G>{g}; }
Definition AABBTreeIndirect.hpp:910

Referenced by Slic3r::SeamPlacerImpl::PaintedContour::crossings(), Slic3r::SeamPlacerImpl::fully_enforced_loop(), Slic3r::SeamContour::Resolver::query(), and Slic3r::TriangleSelector::remap_painting().

Here is the caller graph for this function:

◆ is_any_triangle_in_radius()

template<typename VertexType, typename IndexedFaceType, typename TreeType, typename VectorType>
bool Slic3r::AABBTreeIndirect::is_any_triangle_in_radius ( const std::vector< VertexType > & vertices,
const std::vector< IndexedFaceType > & faces,
const TreeType & tree,
const VectorType & point,
typename VectorType::Scalar & max_distance_squared )
inline
838{
839 using Scalar = typename VectorType::Scalar;
841 { vertices, faces, tree, point };
842
843 size_t hit_idx;
844 VectorType hit_point = VectorType::Ones() * (NaN<typename VectorType::Scalar>);
845
846 if(tree.empty())
847 {
848 return false;
849 }
850
851 detail::squared_distance_to_indexed_primitives_recursive(distancer, size_t(0), Scalar(0), max_distance_squared, hit_idx, hit_point);
852
853 return hit_point.allFinite();
854}
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
constexpr T NaN
Definition libslic3r.h:411

References Slic3r::NaN, and Slic3r::AABBTreeIndirect::detail::squared_distance_to_indexed_primitives_recursive().

Referenced by Slic3r::anonymous_namespace{TextureDisplacement.cpp}::build_texture_displacement_v2(), Slic3r::SeamPlacerImpl::GlobalModelInfo::is_blocked(), and Slic3r::SeamPlacerImpl::GlobalModelInfo::is_enforced().

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

◆ squared_distance_to_indexed_triangle_set()

template<typename VertexType, typename IndexedFaceType, typename TreeType, typename VectorType>
VectorType::Scalar Slic3r::AABBTreeIndirect::squared_distance_to_indexed_triangle_set ( const std::vector< VertexType > & vertices,
const std::vector< IndexedFaceType > & faces,
const TreeType & tree,
const VectorType & point,
size_t & hit_idx_out,
Eigen::PlainObjectBase< VectorType > & hit_point_out )
inline
814{
815 using Scalar = typename VectorType::Scalar;
817 { vertices, faces, tree, point };
818 return tree.empty() ? Scalar(-1) :
819 detail::squared_distance_to_indexed_primitives_recursive(distancer, size_t(0), Scalar(0), std::numeric_limits<Scalar>::infinity(), hit_idx_out, hit_point_out);
820}
Definition LifecycleEvents.hpp:174
STL namespace.

References Slic3r::AABBTreeIndirect::detail::squared_distance_to_indexed_primitives_recursive().

Referenced by Slic3r::anonymous_namespace{TextureDisplacement.cpp}::build_texture_displacement_v2(), Slic3r::anonymous_namespace{TextureDisplacement.cpp}::PatchRegion::contains(), Slic3r::AABBMesh::AABBImpl::squared_distance(), Slic3r::sla::IndexedMesh::AABBImpl::squared_distance(), and Slic3r::anonymous_namespace{TextureDisplacement.cpp}::LscmLookup::uv_at().

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

◆ traverse()

template<int Dims, typename T, typename Predicate, typename Fn>
void Slic3r::AABBTreeIndirect::traverse ( const Tree< Dims, T > & tree,
Predicate && pred,
Fn && callback )
987{
988 if (tree.empty()) return;
989
990 detail::traverse_recurse(tree, size_t(0), std::forward<Predicate>(pred),
991 std::forward<Fn>(callback));
992}
bool empty() const
Definition AABBTreeIndirect.hpp:111
bool traverse_recurse(const Tree< Dims, T > &tree, size_t idx, Pred &&pred, Fn &&callback)
Definition AABBTreeIndirect.hpp:949

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

Referenced by Slic3r::anonymous_namespace{ClipperUtils.cpp}::c2_attach_stray_holes(), Slic3r::connected_bodies(), Slic3r::SeamPlacerImpl::PaintedContour::crossings(), Slic3r::SeamPlacerImpl::fully_enforced_loop(), Slic3r::SeamContour::Resolver::query(), Slic3r::TriangleSelector::remap_painting(), Slic3r::Algorithm::sample_in_expolygons(), and Slic3r::RetractWhenCrossingPerimeters::travel_inside_internal_regions().

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

◆ within()

template<class G>
auto Slic3r::AABBTreeIndirect::within ( const G & g)
942{ return Within<G>{g}; }
Definition AABBTreeIndirect.hpp:927