Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Slic3r::AABBTreeIndirect Namespace Reference

Namespaces

namespace  detail
 

Classes

class  BoundingBoxWrapper
 
struct  Intersecting
 
struct  Intersecting< Eigen::AlignedBox< CoordType, NumD > >
 
class  Tree
 
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 &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 > &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 >

◆ Slic3r::AABBTreeIndirect::Within

struct Slic3r::AABBTreeIndirect::Within
template<class G>
struct Slic3r::AABBTreeIndirect::Within< G >

Typedef Documentation

◆ Tree2d

using Slic3r::AABBTreeIndirect::Tree2d = typedef Tree<2, double>

◆ Tree2f

using Slic3r::AABBTreeIndirect::Tree2f = typedef Tree<2, float>

◆ Tree3d

using Slic3r::AABBTreeIndirect::Tree3d = typedef Tree<3, double>

◆ Tree3f

using Slic3r::AABBTreeIndirect::Tree3f = typedef Tree<3, float>

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
864{
866 { vertices, faces, tree, point };
867
868 if(tree.empty())
869 {
870 return {};
871 }
872
873 std::vector<size_t> found_triangles{};
874 detail::indexed_primitives_within_distance_squared_recurisve(distancer, size_t(0), max_distance_squared, found_triangles);
875 return found_triangles;
876}

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
679{
681// using CoordType = typename TreeType::CoordType;
682 using VectorType = typename TreeType::VectorType;
683 using BoundingBox = typename TreeType::BoundingBox;
684
685 struct InputType {
686 size_t idx() const { return m_idx; }
687 const BoundingBox& bbox() const { return m_bbox; }
688 const VectorType& centroid() const { return m_centroid; }
689
690 size_t m_idx;
691 BoundingBox m_bbox;
692 VectorType m_centroid;
693 };
694
695 std::vector<InputType> input;
696 input.reserve(faces.size());
697 const VectorType veps(eps, eps, eps);
698 for (size_t i = 0; i < faces.size(); ++ i) {
699 const IndexedFaceType &face = faces[i];
700 const VertexType &v1 = vertices[face(0)];
701 const VertexType &v2 = vertices[face(1)];
702 const VertexType &v3 = vertices[face(2)];
703 InputType n;
704 n.m_idx = i;
705 n.m_centroid = (1./3.) * (v1 + v2 + v3);
706 n.m_bbox = BoundingBox(v1, v1);
707 n.m_bbox.extend(v2);
708 n.m_bbox.extend(v3);
709 n.m_bbox.min() -= veps;
710 n.m_bbox.max() += veps;
711 input.emplace_back(n);
712 }
713
714 TreeType out;
715 out.build(std::move(input));
716 return out;
717}
Definition AABBTreeIndirect.hpp:40
Definition BoundingBox.hpp:181
static int input(void)

References input().

Referenced by Slic3r::SeamPlacerImpl::compute_global_occlusion(), Slic3r::SeamPlacerImpl::gather_enforcers_blockers(), and Slic3r::AABBMesh::AABBImpl::init().

+ Here is the call graph for this function:
+ 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 
)
883{
884 if (tree.empty() || ! tree.node(node_idx).bbox.contains(v))
885 return;
886
887 decltype(tree.node(node_idx)) node = tree.node(node_idx);
888 static_assert(std::is_reference<decltype(node)>::value,
889 "Nodes shall be addressed by reference.");
890 assert(node.is_valid());
891 assert(node.bbox.contains(v));
892
893 if (! node.is_leaf()) {
894 if (tree.left_child(node_idx).bbox.contains(v))
895 get_candidate_idxs(tree, v, candidates, tree.left_child_idx(node_idx));
896 if (tree.right_child(node_idx).bbox.contains(v))
897 get_candidate_idxs(tree, v, candidates, tree.right_child_idx(node_idx));
898 } else
899 candidates.push_back(node.idx);
900
901 return;
902}
void get_candidate_idxs(const TreeType &tree, const VectorType &v, std::vector< size_t > &candidates, size_t node_idx=0)
Definition AABBTreeIndirect.hpp:882

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 > &  hits,
const double  eps = 0.000001 
)
inline
770{
772 { vertices, faces, {tree},
773 origin, dir, VectorType(dir.cwiseInverse()),
774 eps }
775 };
776 if (tree.empty()) {
777 hits.clear();
778 } else {
779 // Reusing the output memory if there is some memory already pre-allocated.
780 ray_intersector.hits = std::move(hits);
781 ray_intersector.hits.clear();
782 ray_intersector.hits.reserve(8);
783 detail::intersect_ray_recursive_all_hits(ray_intersector, 0);
784 hits = std::move(ray_intersector.hits);
785 std::sort(hits.begin(), hits.end(), [](const auto &l, const auto &r) { return l.t < r.t; });
786 }
787 return ! hits.empty();
788}
Definition AABBTreeIndirect.hpp:259
std::vector< igl::Hit > hits
Definition AABBTreeIndirect.hpp:260

References Slic3r::AABBTreeIndirect::detail::RayIntersectorHits< VertexType, IndexedFaceType, TreeType, VectorType >::hits, and Slic3r::AABBTreeIndirect::detail::intersect_ray_recursive_all_hits().

Referenced by Slic3r::TriangleSelectorWrapper::enforce_spot(), and Slic3r::AABBMesh::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 hit,
const double  eps = 0.000001 
)
inline
738{
739 using Scalar = typename VectorType::Scalar;
741 vertices, faces, tree,
742 origin, dir, VectorType(dir.cwiseInverse()),
743 eps
744 };
745 return ! tree.empty() && detail::intersect_ray_recursive_first_hit(
746 ray_intersector, size_t(0), std::numeric_limits<Scalar>::infinity(), hit);
747}
Definition AABBTreeIndirect.hpp:240

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

Referenced by Slic3r::AABBMesh::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)
920{ return Intersecting<G>{g}; }
Definition AABBTreeIndirect.hpp:905

◆ 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
833{
834 using Scalar = typename VectorType::Scalar;
836 { vertices, faces, tree, point };
837
838 size_t hit_idx;
839 VectorType hit_point = VectorType::Ones() * (NaN<typename VectorType::Scalar>);
840
841 if(tree.empty())
842 {
843 return false;
844 }
845
846 detail::squared_distance_to_indexed_primitives_recursive(distancer, size_t(0), Scalar(0), max_distance_squared, hit_idx, hit_point);
847
848 return hit_point.allFinite();
849}

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

+ Here is the call 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
809{
810 using Scalar = typename VectorType::Scalar;
812 { vertices, faces, tree, point };
813 return tree.empty() ? Scalar(-1) :
814 detail::squared_distance_to_indexed_primitives_recursive(distancer, size_t(0), Scalar(0), std::numeric_limits<Scalar>::infinity(), hit_idx_out, hit_point_out);
815}
STL namespace.

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

Referenced by Slic3r::TriangleSelectorWrapper::enforce_spot(), and Slic3r::AABBMesh::AABBImpl::squared_distance().

+ 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 
)
982{
983 if (tree.empty()) return;
984
985 detail::traverse_recurse(tree, size_t(0), std::forward<Predicate>(pred),
986 std::forward<Fn>(callback));
987}
bool empty() const
Definition AABBTreeIndirect.hpp:106

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

Referenced by 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)
937{ return Within<G>{g}; }
Definition AABBTreeIndirect.hpp:922