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

Namespaces

namespace  cgal
 

Typedefs

using MapMatrixXfUnaligned = Eigen::Map< const Eigen::Matrix< float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor|Eigen::DontAlign > >
 
using MapMatrixXiUnaligned = Eigen::Map< const Eigen::Matrix< int, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor|Eigen::DontAlign > >
 
using EigenMesh = std::pair< Eigen::MatrixXd, Eigen::MatrixXi >
 

Functions

TriangleMesh eigen_to_triangle_mesh (const EigenMesh &emesh)
 
EigenMesh triangle_mesh_to_eigen (const TriangleMesh &mesh)
 
void minus (EigenMesh &A, const EigenMesh &B)
 
void minus (TriangleMesh &A, const TriangleMesh &B)
 
void self_union (EigenMesh &A)
 
void self_union (TriangleMesh &mesh)
 

Typedef Documentation

◆ EigenMesh

using Slic3r::MeshBoolean::EigenMesh = typedef std::pair<Eigen::MatrixXd, Eigen::MatrixXi>

◆ MapMatrixXfUnaligned

◆ MapMatrixXiUnaligned

Function Documentation

◆ eigen_to_triangle_mesh()

TriangleMesh Slic3r::MeshBoolean::eigen_to_triangle_mesh ( const EigenMesh emesh)
24{
25 auto &VC = emesh.first; auto &FC = emesh.second;
26
28 its.vertices.reserve(size_t(VC.rows()));
29 its.indices.reserve(size_t(FC.rows()));
30
31 for (Eigen::Index i = 0; i < VC.rows(); ++i)
32 its.vertices.emplace_back(VC.row(i).cast<float>());
33
34 for (Eigen::Index i = 0; i < FC.rows(); ++i)
35 its.indices.emplace_back(FC.row(i));
36
37 return TriangleMesh { std::move(its) };
38}
Definition TriangleMesh.hpp:88
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:33
Definition stl.h:157
std::vector< stl_vertex > vertices
Definition stl.h:165
std::vector< stl_triangle_vertex_indices > indices
Definition stl.h:164

References indexed_triangle_set::indices, and indexed_triangle_set::vertices.

Referenced by minus(), and self_union().

+ Here is the caller graph for this function:

◆ minus() [1/2]

void Slic3r::MeshBoolean::minus ( EigenMesh A,
const EigenMesh B 
)
54{
55 auto &[VA, FA] = A;
56 auto &[VB, FB] = B;
57
58 Eigen::MatrixXd VC;
59 Eigen::MatrixXi FC;
61 igl::copyleft::cgal::mesh_boolean(VA, FA, VB, FB, boolean_type, VC, FC);
62
63 VA = std::move(VC); FA = std::move(FC);
64}
IGL_INLINE bool mesh_boolean(const Eigen::MatrixBase< DerivedVA > &VA, const Eigen::MatrixBase< DerivedFA > &FA, const Eigen::MatrixBase< DerivedVB > &VB, const Eigen::MatrixBase< DerivedFB > &FB, const MeshBooleanType &type, Eigen::PlainObjectBase< DerivedVC > &VC, Eigen::PlainObjectBase< DerivedFC > &FC, Eigen::PlainObjectBase< DerivedJ > &J)
Definition mesh_boolean.cpp:43
MeshBooleanType
Definition MeshBooleanType.h:13
@ MESH_BOOLEAN_TYPE_MINUS
Definition MeshBooleanType.h:16

References igl::copyleft::cgal::mesh_boolean(), and igl::MESH_BOOLEAN_TYPE_MINUS.

Referenced by minus().

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

◆ minus() [2/2]

void Slic3r::MeshBoolean::minus ( TriangleMesh A,
const TriangleMesh B 
)
67{
71}
EigenMesh triangle_mesh_to_eigen(const TriangleMesh &mesh)
Definition MeshBoolean.cpp:40
void minus(EigenMesh &A, const EigenMesh &B)
Definition MeshBoolean.cpp:53
std::pair< Eigen::MatrixXd, Eigen::MatrixXi > EigenMesh
Definition MeshBoolean.hpp:14
TriangleMesh eigen_to_triangle_mesh(const EigenMesh &emesh)
Definition MeshBoolean.cpp:23

References eigen_to_triangle_mesh(), minus(), and triangle_mesh_to_eigen().

+ Here is the call graph for this function:

◆ self_union() [1/2]

void Slic3r::MeshBoolean::self_union ( EigenMesh A)
74{
75 EigenMesh result;
76 auto &[V, F] = A;
77 auto &[VC, FC] = result;
78
80 igl::copyleft::cgal::mesh_boolean(V, F, Eigen::MatrixXd(), Eigen::MatrixXi(), boolean_type, VC, FC);
81
82 A = std::move(result);
83}
@ F
Definition libslic3r.h:102
@ MESH_BOOLEAN_TYPE_UNION
Definition MeshBooleanType.h:14

References Slic3r::F, igl::copyleft::cgal::mesh_boolean(), and igl::MESH_BOOLEAN_TYPE_UNION.

Referenced by self_union().

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

◆ self_union() [2/2]

void Slic3r::MeshBoolean::self_union ( TriangleMesh mesh)
86{
87 auto eM = triangle_mesh_to_eigen(mesh);
88 self_union(eM);
89 mesh = eigen_to_triangle_mesh(eM);
90}
void self_union(EigenMesh &A)
Definition MeshBoolean.cpp:73

References eigen_to_triangle_mesh(), self_union(), and triangle_mesh_to_eigen().

+ Here is the call graph for this function:

◆ triangle_mesh_to_eigen()

EigenMesh Slic3r::MeshBoolean::triangle_mesh_to_eigen ( const TriangleMesh mesh)
41{
42 EigenMesh emesh;
43 emesh.first = MapMatrixXfUnaligned(mesh.its.vertices.front().data(),
44 Eigen::Index(mesh.its.vertices.size()),
45 3).cast<double>();
46
47 emesh.second = MapMatrixXiUnaligned(mesh.its.indices.front().data(),
48 Eigen::Index(mesh.its.indices.size()),
49 3);
50 return emesh;
51}
A matrix or vector expression mapping an existing array of data.
Definition Map.h:96
indexed_triangle_set its
Definition TriangleMesh.hpp:155

References indexed_triangle_set::indices, Slic3r::TriangleMesh::its, and indexed_triangle_set::vertices.

Referenced by minus(), and self_union().

+ Here is the caller graph for this function: