Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Slic3r::TriangleSelectorWrapper Class Reference

#include <src/libslic3r/TriangleSelectorWrapper.hpp>

+ Collaboration diagram for Slic3r::TriangleSelectorWrapper:

Public Member Functions

 TriangleSelectorWrapper (const TriangleMesh &mesh, const Transform3d &mesh_transform)
 
void enforce_spot (const Vec3f &point, const Vec3f &origin, float radius)
 

Public Attributes

const TriangleMeshmesh
 
const Transform3dmesh_transform
 
TriangleSelector selector
 
AABBTreeIndirect::Tree< 3, float > triangles_tree
 

Detailed Description

Constructor & Destructor Documentation

◆ TriangleSelectorWrapper()

Slic3r::TriangleSelectorWrapper::TriangleSelectorWrapper ( const TriangleMesh mesh,
const Transform3d mesh_transform 
)
6 :
9}
indexed_triangle_set its
Definition TriangleMesh.hpp:155
const Transform3d & mesh_transform
Definition TriangleSelectorWrapper.hpp:19
const TriangleMesh & mesh
Definition TriangleSelectorWrapper.hpp:18
TriangleSelector selector
Definition TriangleSelectorWrapper.hpp:20
AABBTreeIndirect::Tree< 3, float > triangles_tree
Definition TriangleSelectorWrapper.hpp:21
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)
Definition AABBTreeIndirect.hpp:672
std::vector< stl_vertex > vertices
Definition stl.h:165
std::vector< stl_triangle_vertex_indices > indices
Definition stl.h:164

Member Function Documentation

◆ enforce_spot()

void Slic3r::TriangleSelectorWrapper::enforce_spot ( const Vec3f point,
const Vec3f origin,
float  radius 
)
11 {
12 std::vector<igl::Hit> hits;
13 Vec3f dir = (point - origin).normalized();
14 static constexpr const auto eps_angle = 89.99f;
15 Transform3d trafo_no_translate = mesh_transform;
16 trafo_no_translate.translation() = Vec3d::Zero();
18 Vec3d(origin.cast<double>()),
19 Vec3d(dir.cast<double>()),
20 hits)) {
21 for (int hit_idx = hits.size() - 1; hit_idx >= 0; --hit_idx) {
22 const igl::Hit &hit = hits[hit_idx];
23 Vec3f pos = origin + dir * hit.t;
25 if ((point - pos).norm() < radius && face_normal.dot(dir) < 0) {
26 std::unique_ptr<TriangleSelector::Cursor> cursor = std::make_unique<TriangleSelector::Sphere>(
27 pos, origin, radius, this->mesh_transform, TriangleSelector::ClippingPlane { });
28 selector.select_patch(hit.id, std::move(cursor), EnforcerBlockerType::ENFORCER, trafo_no_translate,
29 true, eps_angle);
30 break;
31 }
32 }
33 } else {
34 size_t hit_idx_out;
35 Vec3f hit_point_out;
37 triangles_tree, point, hit_idx_out, hit_point_out);
38 if (dist < radius) {
39 std::unique_ptr<TriangleSelector::Cursor> cursor = std::make_unique<TriangleSelector::Sphere>(
40 point, origin, radius, this->mesh_transform, TriangleSelector::ClippingPlane { });
41 selector.select_patch(hit_idx_out, std::move(cursor), EnforcerBlockerType::ENFORCER,
42 trafo_no_translate,
43 true, eps_angle);
44 }
45 }
46}
void select_patch(int facet_start, std::unique_ptr< Cursor > &&cursor, EnforcerBlockerType new_state, const Transform3d &trafo_no_translate, bool triangle_splitting, float highlight_by_angle_deg=0.f)
Definition TriangleSelector.cpp:233
EIGEN_DEVICE_FUNC ConstTranslationPart translation() const
Definition Transform.h:410
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)
Definition AABBTreeIndirect.hpp:755
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)
Definition AABBTreeIndirect.hpp:796
T dist(const boost::polygon::point_data< T > &p1, const boost::polygon::point_data< T > &p2)
Definition Geometry.cpp:280
Vec3d pos(const Pt &p)
Definition ReprojectPointsOnMesh.hpp:14
Eigen::Transform< double, 3, Eigen::Affine, Eigen::DontAlign > Transform3d
Definition Point.hpp:81
Eigen::Matrix< float, 3, 1, Eigen::DontAlign > Vec3f
Definition Point.hpp:49
Vec3f face_normal(const stl_vertex vertex[3])
Definition TriangleMesh.hpp:309
Eigen::Matrix< double, 3, 1, Eigen::DontAlign > Vec3d
Definition Point.hpp:52
Vec3f its_face_normal(const indexed_triangle_set &its, const stl_triangle_vertex_indices face)
Definition TriangleMesh.hpp:311
float t
Definition Hit.h:22
int id
Definition Hit.h:19
Definition Hit.h:18

References Slic3r::ENFORCER, Slic3r::face_normal(), igl::Hit::id, indexed_triangle_set::indices, Slic3r::AABBTreeIndirect::intersect_ray_all_hits(), Slic3r::TriangleMesh::its, Slic3r::its_face_normal(), mesh, mesh_transform, Slic3r::TriangleSelector::select_patch(), selector, Slic3r::AABBTreeIndirect::squared_distance_to_indexed_triangle_set(), igl::Hit::t, Eigen::Transform< _Scalar, _Dim, _Mode, _Options >::translation(), triangles_tree, and indexed_triangle_set::vertices.

+ Here is the call graph for this function:

Member Data Documentation

◆ mesh

const TriangleMesh& Slic3r::TriangleSelectorWrapper::mesh

◆ mesh_transform

const Transform3d& Slic3r::TriangleSelectorWrapper::mesh_transform

Referenced by enforce_spot().

◆ selector

TriangleSelector Slic3r::TriangleSelectorWrapper::selector

Referenced by enforce_spot().

◆ triangles_tree

AABBTreeIndirect::Tree<3, float> Slic3r::TriangleSelectorWrapper::triangles_tree

Referenced by enforce_spot().


The documentation for this class was generated from the following files: