Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
igl::copyleft::cork Namespace Reference

Functions

template<typename DerivedV , typename DerivedF >
IGL_INLINE void from_cork_mesh (const CorkTriMesh &mesh, Eigen::PlainObjectBase< DerivedV > &V, Eigen::PlainObjectBase< DerivedF > &F)
 
template<typename DerivedVA , typename DerivedFA , typename DerivedVB , typename DerivedFB , typename DerivedVC , typename DerivedFC >
IGL_INLINE void mesh_boolean (const Eigen::PlainObjectBase< DerivedVA > &VA, const Eigen::PlainObjectBase< DerivedFA > &FA, const Eigen::PlainObjectBase< DerivedVB > &VB, const Eigen::PlainObjectBase< DerivedFB > &FB, const MeshBooleanType &type, Eigen::PlainObjectBase< DerivedVC > &VC, Eigen::PlainObjectBase< DerivedFC > &FC)
 
template<typename DerivedV , typename DerivedF >
IGL_INLINE void to_cork_mesh (const Eigen::PlainObjectBase< DerivedV > &V, const Eigen::PlainObjectBase< DerivedF > &F, CorkTriMesh &mesh)
 

Function Documentation

◆ from_cork_mesh()

template<typename DerivedV , typename DerivedF >
IGL_INLINE void igl::copyleft::cork::from_cork_mesh ( const CorkTriMesh &  mesh,
Eigen::PlainObjectBase< DerivedV > &  V,
Eigen::PlainObjectBase< DerivedF > &  F 
)
17{
18 using namespace std;
19 F.resize(mesh.n_triangles,3);
20 V.resize(mesh.n_vertices,3);
21 for(size_t v = 0;v<mesh.n_vertices;v++)
22 {
23 for(size_t c = 0;c<3;c++)
24 {
25 V(v,c) = mesh.vertices[v*3+c];
26 }
27 }
28 for(size_t f = 0;f<mesh.n_triangles;f++)
29 {
30 for(size_t c = 0;c<3;c++)
31 {
32 F(f,c) = mesh.triangles[f*3+c];
33 }
34 }
35}
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void resize(Index rows, Index cols)
Definition PlainObjectBase.h:279
STL namespace.

References Eigen::PlainObjectBase< Derived >::resize().

Referenced by mesh_boolean().

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

◆ mesh_boolean()

template<typename DerivedVA , typename DerivedFA , typename DerivedVB , typename DerivedFB , typename DerivedVC , typename DerivedFC >
IGL_INLINE void igl::copyleft::cork::mesh_boolean ( const Eigen::PlainObjectBase< DerivedVA > &  VA,
const Eigen::PlainObjectBase< DerivedFA > &  FA,
const Eigen::PlainObjectBase< DerivedVB > &  VB,
const Eigen::PlainObjectBase< DerivedFB > &  FB,
const MeshBooleanType type,
Eigen::PlainObjectBase< DerivedVC > &  VC,
Eigen::PlainObjectBase< DerivedFC > &  FC 
)
27{
28 CorkTriMesh A,B,C;
29 // pointer to output so it's easy to redirect on degenerate cases
30 CorkTriMesh *ret = &C;
31 to_cork_mesh(VA,FA,A);
32 to_cork_mesh(VB,FB,B);
33 switch(type)
34 {
36 if(A.n_triangles == 0)
37 {
38 ret = &B;
39 }else if(B.n_triangles == 0)
40 {
41 ret = &A;
42 }else
43 {
44 computeUnion(A,B,ret);
45 }
46 break;
47 case MESH_BOOLEAN_TYPE_INTERSECT:
48 if(A.n_triangles == 0 || B.n_triangles == 0)
49 {
50 ret->n_triangles = 0;
51 ret->n_vertices = 0;
52 }else
53 {
54 computeIntersection(A,B,ret);
55 }
56 break;
58 if(A.n_triangles == 0)
59 {
60 ret->n_triangles = 0;
61 ret->n_vertices = 0;
62 }else if(B.n_triangles == 0)
63 {
64 ret = &A;
65 }else
66 {
67 computeDifference(A,B,ret);
68 }
69 break;
71 if(A.n_triangles == 0)
72 {
73 ret = &B;
74 }else if(B.n_triangles == 0)
75 {
76 ret = &A;
77 }else
78 {
79 computeSymmetricDifference(A,B,&C);
80 }
81 break;
83 resolveIntersections(A,B,&C);
84 break;
85 default:
86 assert(false && "Unknown type");
87 return;
88 }
89 from_cork_mesh(*ret,VC,FC);
90 freeCorkTriMesh(&A);
91 freeCorkTriMesh(&B);
92 freeCorkTriMesh(&C);
93}
IGL_INLINE void to_cork_mesh(const Eigen::PlainObjectBase< DerivedV > &V, const Eigen::PlainObjectBase< DerivedF > &F, CorkTriMesh &mesh)
Definition to_cork_mesh.cpp:12
IGL_INLINE void from_cork_mesh(const CorkTriMesh &mesh, Eigen::PlainObjectBase< DerivedV > &V, Eigen::PlainObjectBase< DerivedF > &F)
Definition from_cork_mesh.cpp:13
@ MESH_BOOLEAN_TYPE_MINUS
Definition MeshBooleanType.h:16
@ MESH_BOOLEAN_TYPE_XOR
Definition MeshBooleanType.h:17
@ MESH_BOOLEAN_TYPE_UNION
Definition MeshBooleanType.h:14
@ MESH_BOOLEAN_TYPE_RESOLVE
Definition MeshBooleanType.h:18

References from_cork_mesh(), igl::MESH_BOOLEAN_TYPE_INTERSECT, igl::MESH_BOOLEAN_TYPE_MINUS, igl::MESH_BOOLEAN_TYPE_RESOLVE, igl::MESH_BOOLEAN_TYPE_UNION, igl::MESH_BOOLEAN_TYPE_XOR, and to_cork_mesh().

+ Here is the call graph for this function:

◆ to_cork_mesh()

template<typename DerivedV , typename DerivedF >
IGL_INLINE void igl::copyleft::cork::to_cork_mesh ( const Eigen::PlainObjectBase< DerivedV > &  V,
const Eigen::PlainObjectBase< DerivedF > &  F,
CorkTriMesh &  mesh 
)
16{
17 using namespace std;
18 assert((F.cols() == 0 || F.cols() == 3) && "Facets should be triangles.");
19 assert((V.cols() == 0 || V.cols() == 3) && "Vertices should be in 3D.");
20 mesh.n_triangles = F.rows();
21 mesh.n_vertices = V.rows();
22 mesh.vertices = new float[mesh.n_vertices*3];
23 mesh.triangles = new uint[mesh.n_triangles*3];
24 for(size_t v = 0;v<mesh.n_vertices;v++)
25 {
26 for(size_t c = 0;c<3;c++)
27 {
28 mesh.vertices[v*3+c] = V(v,c);
29 }
30 }
31 for(size_t f = 0;f<mesh.n_triangles;f++)
32 {
33 for(size_t c = 0;c<3;c++)
34 {
35 mesh.triangles[f*3+c] = F(f,c);
36 }
37 }
38}
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index cols() const
Definition PlainObjectBase.h:153
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index rows() const
Definition PlainObjectBase.h:151

References Eigen::PlainObjectBase< Derived >::cols(), and Eigen::PlainObjectBase< Derived >::rows().

Referenced by mesh_boolean().

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