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

Functions

template<typename DerivedV , typename DerivedE , typename DerivedWV , typename DerivedWF , typename DerivedWE , typename DerivedJ >
IGL_INLINE void cdt (const Eigen::MatrixBase< DerivedV > &V, const Eigen::MatrixBase< DerivedE > &E, const std::string &flags, Eigen::PlainObjectBase< DerivedWV > &WV, Eigen::PlainObjectBase< DerivedWF > &WF, Eigen::PlainObjectBase< DerivedWE > &WE, Eigen::PlainObjectBase< DerivedJ > &J)
 
template<typename DerivedV , typename DerivedE , typename DerivedH , typename DerivedV2 , typename DerivedF2 >
IGL_INLINE void triangulate (const Eigen::MatrixBase< DerivedV > &V, const Eigen::MatrixBase< DerivedE > &E, const Eigen::MatrixBase< DerivedH > &H, const std::string flags, Eigen::PlainObjectBase< DerivedV2 > &V2, Eigen::PlainObjectBase< DerivedF2 > &F2)
 
template<typename DerivedV , typename DerivedE , typename DerivedH , typename DerivedVM , typename DerivedEM , typename DerivedV2 , typename DerivedF2 , typename DerivedVM2 , typename DerivedEM2 >
IGL_INLINE void triangulate (const Eigen::MatrixBase< DerivedV > &V, const Eigen::MatrixBase< DerivedE > &E, const Eigen::MatrixBase< DerivedH > &H, const Eigen::MatrixBase< DerivedVM > &VM, const Eigen::MatrixBase< DerivedEM > &EM, const std::string flags, Eigen::PlainObjectBase< DerivedV2 > &V2, Eigen::PlainObjectBase< DerivedF2 > &F2, Eigen::PlainObjectBase< DerivedVM2 > &VM2, Eigen::PlainObjectBase< DerivedEM2 > &EM2)
 

Function Documentation

◆ cdt()

template<typename DerivedV , typename DerivedE , typename DerivedWV , typename DerivedWF , typename DerivedWE , typename DerivedJ >
IGL_INLINE void igl::triangle::cdt ( const Eigen::MatrixBase< DerivedV > &  V,
const Eigen::MatrixBase< DerivedE > &  E,
const std::string &  flags,
Eigen::PlainObjectBase< DerivedWV > &  WV,
Eigen::PlainObjectBase< DerivedWF > &  WF,
Eigen::PlainObjectBase< DerivedWE > &  WE,
Eigen::PlainObjectBase< DerivedJ > &  J 
)
23{
24 assert(V.cols() == 2);
25 assert(E.cols() == 2);
26 typedef typename DerivedV::Scalar Scalar;
28 //MatrixX2S BV;
29 //Eigen::MatrixXi BE;
30 //igl::bounding_box(V,BV,BE);
31 //WV.resize(V.rows()+BV.rows(),2);
32 //WV<<V,BV;
33 //WE.resize(E.rows()+BE.rows(),2);
34 //WE<<E,(BE.array()+V.rows());
35 WV = V;
36 WE = E;
37 Eigen::VectorXi _;
38 igl::remove_duplicate_vertices(DerivedWV(WV),DerivedWE(WE),1e-10,WV,_,J,WE);
39 // Remove degenerate edges
40 igl::slice_mask(DerivedWE(WE),(WE.array().col(0) != WE.array().col(1)).eval(),1,WE);
41 // c flag must be present
42 igl::triangle::triangulate(DerivedWV(WV),WE,DerivedWV(),flags,WV,WF);
43 Eigen::VectorXi UJ;
44 igl::remove_unreferenced(DerivedV(WV),Eigen::MatrixXi(WF),WV,WF,UJ);
45 for(int i=0;i<WE.rows();i++) for(int j=0;j<WE.cols();j++) WE(i,j)=UJ(WE(i,j));
46 // Remove edges from box
47 //WE.conservativeResize(WE.rows()-BE.rows(),2);
48 for(int i=0;i<J.size();i++) J(i)=UJ(J(i));
49 //J.conservativeResize(J.size()-BV.rows());
50}
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:180
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
#define _(msgid)
Definition getopt.c:87
IGL_INLINE void triangulate(const Eigen::MatrixBase< DerivedV > &V, const Eigen::MatrixBase< DerivedE > &E, const Eigen::MatrixBase< DerivedH > &H, const std::string flags, Eigen::PlainObjectBase< DerivedV2 > &V2, Eigen::PlainObjectBase< DerivedF2 > &F2)
Definition triangulate.cpp:51
IGL_INLINE void remove_unreferenced(const Eigen::MatrixBase< DerivedV > &V, const Eigen::MatrixBase< DerivedF > &F, Eigen::PlainObjectBase< DerivedNV > &NV, Eigen::PlainObjectBase< DerivedNF > &NF, Eigen::PlainObjectBase< DerivedI > &I)
Definition remove_unreferenced.cpp:18
IGL_INLINE void slice_mask(const Eigen::DenseBase< DerivedX > &X, const Eigen::Array< bool, Eigen::Dynamic, 1 > &R, const Eigen::Array< bool, Eigen::Dynamic, 1 > &C, Eigen::PlainObjectBase< DerivedY > &Y)
Definition slice_mask.cpp:14
IGL_INLINE void remove_duplicate_vertices(const Eigen::MatrixBase< DerivedV > &V, const double epsilon, Eigen::PlainObjectBase< DerivedSV > &SV, Eigen::PlainObjectBase< DerivedSVI > &SVI, Eigen::PlainObjectBase< DerivedSVJ > &SVJ)
Definition remove_duplicate_vertices.cpp:20

References _, Eigen::PlainObjectBase< Derived >::cols(), igl::remove_duplicate_vertices(), igl::remove_unreferenced(), Eigen::PlainObjectBase< Derived >::rows(), igl::slice_mask(), and triangulate().

+ Here is the call graph for this function:

◆ triangulate() [1/2]

template<typename DerivedV , typename DerivedE , typename DerivedH , typename DerivedVM , typename DerivedEM , typename DerivedV2 , typename DerivedF2 , typename DerivedVM2 , typename DerivedEM2 >
IGL_INLINE void igl::triangle::triangulate ( const Eigen::MatrixBase< DerivedV > &  V,
const Eigen::MatrixBase< DerivedE > &  E,
const Eigen::MatrixBase< DerivedH > &  H,
const Eigen::MatrixBase< DerivedVM > &  VM,
const Eigen::MatrixBase< DerivedEM > &  EM,
const std::string  flags,
Eigen::PlainObjectBase< DerivedV2 > &  V2,
Eigen::PlainObjectBase< DerivedF2 > &  F2,
Eigen::PlainObjectBase< DerivedVM2 > &  VM2,
Eigen::PlainObjectBase< DerivedEM2 > &  EM2 
)
84{
85 using namespace std;
86 using namespace Eigen;
87
88 assert( (VM.size() == 0 || V.rows() == VM.size()) &&
89 "Vertex markers must be empty or same size as V");
90 assert( (EM.size() == 0 || E.rows() == EM.size()) &&
91 "Segment markers must be empty or same size as E");
92 assert(V.cols() == 2);
93 assert(E.size() == 0 || E.cols() == 2);
94 assert(H.size() == 0 || H.cols() == 2);
95
96 // Prepare the flags
97 string full_flags = flags + "pz" + (EM.size() || VM.size() ? "" : "B");
98
101
102 // Prepare the input struct
103 triangulateio in;
104 in.numberofpoints = V.rows();
105 in.pointlist = (double*)calloc(V.size(),sizeof(double));
106 {
107 MapXdr inpl(in.pointlist,V.rows(),V.cols());
108 inpl = V.template cast<double>();
109 }
110
111 in.numberofpointattributes = 0;
112 in.pointmarkerlist = (int*)calloc(V.size(),sizeof(int)) ;
113 for(unsigned i=0;i<V.rows();++i) in.pointmarkerlist[i] = VM.size()?VM(i):1;
114
115 in.trianglelist = NULL;
116 in.numberoftriangles = 0;
117 in.numberofcorners = 0;
118 in.numberoftriangleattributes = 0;
119 in.triangleattributelist = NULL;
120
121 in.numberofsegments = E.size()?E.rows():0;
122 in.segmentlist = (int*)calloc(E.size(),sizeof(int));
123 {
124 MapXir insl(in.segmentlist,E.rows(),E.cols());
125 insl = E.template cast<int>();
126 }
127 in.segmentmarkerlist = (int*)calloc(E.rows(),sizeof(int));
128 for (unsigned i=0;i<E.rows();++i) in.segmentmarkerlist[i] = EM.size()?EM(i):1;
129
130 in.numberofholes = H.size()?H.rows():0;
131 in.holelist = (double*)calloc(H.size(),sizeof(double));
132 {
133 MapXdr inhl(in.holelist,H.rows(),H.cols());
134 inhl = H.template cast<double>();
135 }
136 in.numberofregions = 0;
137
138 // Prepare the output struct
139 triangulateio out;
140 out.pointlist = NULL;
141 out.trianglelist = NULL;
142 out.segmentlist = NULL;
143 out.segmentmarkerlist = NULL;
144 out.pointmarkerlist = NULL;
145
146 // Call triangle
147 ::triangulate(const_cast<char*>(full_flags.c_str()), &in, &out, 0);
148
149 // Return the mesh
150 V2 = MapXdr(out.pointlist,out.numberofpoints,2).cast<typename DerivedV2::Scalar>();
151 F2 = MapXir(out.trianglelist,out.numberoftriangles,3).cast<typename DerivedF2::Scalar>();
152 if(VM.size())
153 {
154 VM2 = MapXir(out.pointmarkerlist,out.numberofpoints,1).cast<typename DerivedVM2::Scalar>();
155 }
156 if(EM.size())
157 {
158 EM2 = MapXir(out.segmentmarkerlist,out.numberofsegments,1).cast<typename DerivedEM2::Scalar>();
159 }
160
161 // Cleanup in
162 free(in.pointlist);
163 free(in.pointmarkerlist);
164 free(in.segmentlist);
165 free(in.segmentmarkerlist);
166 free(in.holelist);
167 // Cleanup out
168 free(out.pointlist);
169 free(out.trianglelist);
170 free(out.segmentlist);
171 free(out.segmentmarkerlist);
172 free(out.pointmarkerlist);
173}
A matrix or vector expression mapping an existing array of data.
Definition Map.h:96
void free(void *)
Definition LDLT.h:16
STL namespace.

References free().

+ Here is the call graph for this function:

◆ triangulate() [2/2]

template<typename DerivedV , typename DerivedE , typename DerivedH , typename DerivedV2 , typename DerivedF2 >
IGL_INLINE void igl::triangle::triangulate ( const Eigen::MatrixBase< DerivedV > &  V,
const Eigen::MatrixBase< DerivedE > &  E,
const Eigen::MatrixBase< DerivedH > &  H,
const std::string  flags,
Eigen::PlainObjectBase< DerivedV2 > &  V2,
Eigen::PlainObjectBase< DerivedF2 > &  F2 
)
58{
59 Eigen::VectorXi VM,EM,VM2,EM2;
60 return triangulate(V,E,H,VM,EM,flags,V2,F2,VM2,EM2);
61}

References triangulate().

Referenced by cdt(), and triangulate().

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