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

Classes

struct  CDTParam
 

Functions

template<typename DerivedV , typename DerivedF , typename DerivedTV , typename DerivedTT , typename DerivedTF >
IGL_INLINE bool cdt (const Eigen::PlainObjectBase< DerivedV > &V, const Eigen::PlainObjectBase< DerivedF > &F, const CDTParam &param, Eigen::PlainObjectBase< DerivedTV > &TV, Eigen::PlainObjectBase< DerivedTT > &TT, Eigen::PlainObjectBase< DerivedTF > &TF)
 
IGL_INLINE bool mesh_to_tetgenio (const std::vector< std::vector< REAL > > &V, const std::vector< std::vector< int > > &F, tetgenio &in)
 
template<typename DerivedV , typename DerivedF >
IGL_INLINE bool mesh_to_tetgenio (const Eigen::PlainObjectBase< DerivedV > &V, const Eigen::PlainObjectBase< DerivedF > &F, tetgenio &in)
 
IGL_INLINE bool mesh_with_skeleton (const Eigen::MatrixXd &V, const Eigen::MatrixXi &F, const Eigen::MatrixXd &C, const Eigen::VectorXi &, const Eigen::MatrixXi &BE, const Eigen::MatrixXi &CE, const int samples_per_bone, const std::string &tetgen_flags, Eigen::MatrixXd &VV, Eigen::MatrixXi &TT, Eigen::MatrixXi &FF)
 
IGL_INLINE bool mesh_with_skeleton (const Eigen::MatrixXd &V, const Eigen::MatrixXi &F, const Eigen::MatrixXd &C, const Eigen::VectorXi &, const Eigen::MatrixXi &BE, const Eigen::MatrixXi &CE, const int samples_per_bone, Eigen::MatrixXd &VV, Eigen::MatrixXi &TT, Eigen::MatrixXi &FF)
 
IGL_INLINE bool read_into_tetgenio (const std::string &path, tetgenio &in)
 
IGL_INLINE bool tetgenio_to_tetmesh (const tetgenio &out, std::vector< std::vector< REAL > > &V, std::vector< std::vector< int > > &T, std::vector< std::vector< int > > &F)
 
IGL_INLINE bool tetgenio_to_tetmesh (const tetgenio &out, std::vector< std::vector< REAL > > &V, std::vector< std::vector< int > > &T)
 
template<typename DerivedV , typename DerivedT , typename DerivedF >
IGL_INLINE bool tetgenio_to_tetmesh (const tetgenio &out, Eigen::PlainObjectBase< DerivedV > &V, Eigen::PlainObjectBase< DerivedT > &T, Eigen::PlainObjectBase< DerivedF > &F)
 
template<typename DerivedV , typename DerivedT >
IGL_INLINE bool tetgenio_to_tetmesh (const tetgenio &out, Eigen::PlainObjectBase< DerivedV > &V, Eigen::PlainObjectBase< DerivedT > &T)
 
IGL_INLINE int tetrahedralize (const std::vector< std::vector< REAL > > &V, const std::vector< std::vector< int > > &F, const std::string switches, std::vector< std::vector< REAL > > &TV, std::vector< std::vector< int > > &TT, std::vector< std::vector< int > > &TF)
 
template<typename DerivedV , typename DerivedF , typename DerivedTV , typename DerivedTT , typename DerivedTF >
IGL_INLINE int tetrahedralize (const Eigen::PlainObjectBase< DerivedV > &V, const Eigen::PlainObjectBase< DerivedF > &F, const std::string switches, Eigen::PlainObjectBase< DerivedTV > &TV, Eigen::PlainObjectBase< DerivedTT > &TT, Eigen::PlainObjectBase< DerivedTF > &TF)
 
IGL_INLINE int tetrahedralize (const std::vector< std::vector< REAL > > &V, const std::vector< std::vector< int > > &F, const std::vector< int > &VM, const std::vector< int > &FM, const std::string switches, std::vector< std::vector< REAL > > &TV, std::vector< std::vector< int > > &TT, std::vector< std::vector< int > > &TF, std::vector< int > &TM)
 
template<typename DerivedV , typename DerivedF , typename DerivedVM , typename DerivedFM , typename DerivedTV , typename DerivedTT , typename DerivedTF , typename DerivedTM >
IGL_INLINE int tetrahedralize (const Eigen::PlainObjectBase< DerivedV > &V, const Eigen::PlainObjectBase< DerivedF > &F, const Eigen::PlainObjectBase< DerivedVM > &VM, const Eigen::PlainObjectBase< DerivedFM > &FM, const std::string switches, Eigen::PlainObjectBase< DerivedTV > &TV, Eigen::PlainObjectBase< DerivedTT > &TT, Eigen::PlainObjectBase< DerivedTF > &TF, Eigen::PlainObjectBase< DerivedTM > &TM)
 

Class Documentation

◆ igl::copyleft::tetgen::CDTParam

struct igl::copyleft::tetgen::CDTParam
+ Collaboration diagram for igl::copyleft::tetgen::CDTParam:
Class Members
double bounding_box_scale = 1.01
string flags = "Y"
bool use_bounding_box = false

Function Documentation

◆ cdt()

template<typename DerivedV , typename DerivedF , typename DerivedTV , typename DerivedTT , typename DerivedTF >
IGL_INLINE bool igl::copyleft::tetgen::cdt ( const Eigen::PlainObjectBase< DerivedV > &  V,
const Eigen::PlainObjectBase< DerivedF > &  F,
const CDTParam param,
Eigen::PlainObjectBase< DerivedTV > &  TV,
Eigen::PlainObjectBase< DerivedTT > &  TT,
Eigen::PlainObjectBase< DerivedTF > &  TF 
)
25{
26 using namespace Eigen;
27 using namespace std;
28 // Effective input mesh
29 DerivedV U;
30 DerivedF G;
31 if(param.use_bounding_box)
32 {
33 // Construct bounding box mesh
34 DerivedV BV;
35 DerivedF BF;
36 bounding_box(V,BV,BF);
37 // scale bounding box
38 const RowVector3d mid =
39 (BV.colwise().minCoeff() + BV.colwise().maxCoeff()).eval()*0.5;
40 BV.rowwise() -= mid;
41 assert(param.bounding_box_scale >= 1.);
42 BV.array() *= param.bounding_box_scale;
43 BV.rowwise() += mid;
44 // Append bounding box to mesh
45 U.resize(V.rows()+BV.rows(),V.cols());
46 U<<V,BV;
47 BF.array() += V.rows();
48 G.resize(F.rows()+BF.rows(),F.cols());
49 G<<F,BF;
50 }else
51 {
52 // needless copies
53 U = V;
54 G = F;
55 }
56 // effective flags;
57 string flags = param.flags + (param.use_bounding_box ? "" : "c");
58 return tetrahedralize(U,G,flags,TV,TT,TF);
59}
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
Definition LDLT.h:16
std::string flags
Definition cdt.h:35
double bounding_box_scale
Definition cdt.h:33
bool use_bounding_box
Definition cdt.h:30
IGL_INLINE void bounding_box(const Eigen::MatrixBase< DerivedV > &V, Eigen::PlainObjectBase< DerivedBV > &BV, Eigen::PlainObjectBase< DerivedBF > &BF)
Definition bounding_box.cpp:12
STL namespace.

References igl::bounding_box(), igl::copyleft::tetgen::CDTParam::bounding_box_scale, Eigen::PlainObjectBase< Derived >::cols(), igl::copyleft::tetgen::CDTParam::flags, Eigen::PlainObjectBase< Derived >::rows(), tetrahedralize(), and igl::copyleft::tetgen::CDTParam::use_bounding_box.

+ Here is the call graph for this function:

◆ mesh_to_tetgenio() [1/2]

template<typename DerivedV , typename DerivedF >
IGL_INLINE bool igl::copyleft::tetgen::mesh_to_tetgenio ( const Eigen::PlainObjectBase< DerivedV > &  V,
const Eigen::PlainObjectBase< DerivedF > &  F,
tetgenio &  in 
)
66{
67 using namespace std;
68 vector<vector<REAL> > vV;
69 vector<vector<int> > vF;
70 matrix_to_list(V,vV);
71 matrix_to_list(F,vF);
72 return mesh_to_tetgenio(vV,vF,in);
73}
IGL_INLINE bool mesh_to_tetgenio(const std::vector< std::vector< REAL > > &V, const std::vector< std::vector< int > > &F, tetgenio &in)
Definition mesh_to_tetgenio.cpp:16
IGL_INLINE void matrix_to_list(const Eigen::DenseBase< DerivedM > &M, std::vector< std::vector< typename DerivedM::Scalar > > &V)
Definition matrix_to_list.cpp:13

References igl::matrix_to_list(), and mesh_to_tetgenio().

+ Here is the call graph for this function:

◆ mesh_to_tetgenio() [2/2]

IGL_INLINE bool igl::copyleft::tetgen::mesh_to_tetgenio ( const std::vector< std::vector< REAL > > &  V,
const std::vector< std::vector< int > > &  F,
tetgenio &  in 
)
20{
21 using namespace std;
22 // all indices start from 0
23 in.firstnumber = 0;
24
25 in.numberofpoints = V.size();
26 in.pointlist = new REAL[in.numberofpoints * 3];
27 // loop over points
28 for(int i = 0; i < (int)V.size(); i++)
29 {
30 assert(V[i].size() == 3);
31 in.pointlist[i*3+0] = V[i][0];
32 in.pointlist[i*3+1] = V[i][1];
33 in.pointlist[i*3+2] = V[i][2];
34 }
35
36 in.numberoffacets = F.size();
37 in.facetlist = new tetgenio::facet[in.numberoffacets];
38 in.facetmarkerlist = new int[in.numberoffacets];
39
40 // loop over face
41 for(int i = 0;i < (int)F.size(); i++)
42 {
43 in.facetmarkerlist[i] = i;
44 tetgenio::facet * f = &in.facetlist[i];
45 f->numberofpolygons = 1;
46 f->polygonlist = new tetgenio::polygon[f->numberofpolygons];
47 f->numberofholes = 0;
48 f->holelist = NULL;
49 tetgenio::polygon * p = &f->polygonlist[0];
50 p->numberofvertices = F[i].size();
51 p->vertexlist = new int[p->numberofvertices];
52 // loop around face
53 for(int j = 0;j < (int)F[i].size(); j++)
54 {
55 p->vertexlist[j] = F[i][j];
56 }
57 }
58 return true;
59}
#define REAL
Definition triangulate.cpp:22

References REAL.

Referenced by mesh_to_tetgenio(), read_into_tetgenio(), tetrahedralize(), and tetrahedralize().

+ Here is the caller graph for this function:

◆ mesh_with_skeleton() [1/2]

IGL_INLINE bool igl::copyleft::tetgen::mesh_with_skeleton ( const Eigen::MatrixXd &  V,
const Eigen::MatrixXi &  F,
const Eigen::MatrixXd &  C,
const Eigen::VectorXi &  ,
const Eigen::MatrixXi &  BE,
const Eigen::MatrixXi &  CE,
const int  samples_per_bone,
const std::string &  tetgen_flags,
Eigen::MatrixXd &  VV,
Eigen::MatrixXi &  TT,
Eigen::MatrixXi &  FF 
)
31{
32 using namespace Eigen;
33 using namespace std;
34 const string eff_tetgen_flags =
35 (tetgen_flags.length() == 0?DEFAULT_TETGEN_FLAGS:tetgen_flags);
36 // Collect all edges that need samples:
37 MatrixXi BECE = cat(1,BE,CE);
38 MatrixXd S;
39 // Sample each edge with 10 samples. (Choice of 10 doesn't seem to matter so
40 // much, but could under some circumstances)
41 sample_edges(C,BECE,samples_per_bone,S);
42 // Vertices we'll constrain tet mesh to meet
43 MatrixXd VS = cat(1,V,S);
44 // Use tetgen to mesh the interior of surface, this assumes surface:
45 // * has no holes
46 // * has no non-manifold edges or vertices
47 // * has consistent orientation
48 // * has no self-intersections
49 // * has no 0-volume pieces
50 cerr<<"tetgen begin()"<<endl;
51 int status = tetrahedralize( VS,F,eff_tetgen_flags,VV,TT,FF);
52 cerr<<"tetgen end()"<<endl;
53 if(FF.rows() != F.rows())
54 {
55 // Issue a warning if the surface has changed
56 cerr<<"mesh_with_skeleton: Warning: boundary faces != input faces"<<endl;
57 }
58 if(status != 0)
59 {
60 cerr<<
61 "***************************************************************"<<endl<<
62 "***************************************************************"<<endl<<
63 "***************************************************************"<<endl<<
64 "***************************************************************"<<endl<<
65 "* mesh_with_skeleton: tetgen failed. Just meshing convex hull *"<<endl<<
66 "***************************************************************"<<endl<<
67 "***************************************************************"<<endl<<
68 "***************************************************************"<<endl<<
69 "***************************************************************"<<endl;
70 // If meshing convex hull then use more regular mesh
71 status = tetrahedralize(VS,F,"q1.414",VV,TT,FF);
72 // I suppose this will fail if the skeleton is outside the mesh
73 assert(FF.maxCoeff() < VV.rows());
74 if(status != 0)
75 {
76 cerr<<"mesh_with_skeleton: tetgen failed again."<<endl;
77 return false;
78 }
79 }
80
81 return true;
82}
static const std::string DEFAULT_TETGEN_FLAGS
Definition mesh_with_skeleton.cpp:17
IGL_INLINE int tetrahedralize(const std::vector< std::vector< REAL > > &V, const std::vector< std::vector< int > > &F, const std::string switches, std::vector< std::vector< REAL > > &TV, std::vector< std::vector< int > > &TT, std::vector< std::vector< int > > &TF)
Definition tetrahedralize.cpp:21
IGL_INLINE void sample_edges(const Eigen::MatrixXd &V, const Eigen::MatrixXi &E, const int k, Eigen::MatrixXd &S)
Definition sample_edges.cpp:10
IGL_INLINE void cat(const int dim, const Eigen::SparseMatrix< Scalar > &A, const Eigen::SparseMatrix< Scalar > &B, Eigen::SparseMatrix< Scalar > &C)
Definition cat.cpp:21

References igl::cat(), DEFAULT_TETGEN_FLAGS, igl::sample_edges(), and tetrahedralize().

Referenced by mesh_with_skeleton().

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

◆ mesh_with_skeleton() [2/2]

IGL_INLINE bool igl::copyleft::tetgen::mesh_with_skeleton ( const Eigen::MatrixXd &  V,
const Eigen::MatrixXi &  F,
const Eigen::MatrixXd &  C,
const Eigen::VectorXi &  P,
const Eigen::MatrixXi &  BE,
const Eigen::MatrixXi &  CE,
const int  samples_per_bone,
Eigen::MatrixXd &  VV,
Eigen::MatrixXi &  TT,
Eigen::MatrixXi &  FF 
)
95{
96 return mesh_with_skeleton(
97 V,F,C,P,BE,CE,samples_per_bone,DEFAULT_TETGEN_FLAGS,VV,TT,FF);
98}
IGL_INLINE bool mesh_with_skeleton(const Eigen::MatrixXd &V, const Eigen::MatrixXi &F, const Eigen::MatrixXd &C, const Eigen::VectorXi &, const Eigen::MatrixXi &BE, const Eigen::MatrixXi &CE, const int samples_per_bone, const std::string &tetgen_flags, Eigen::MatrixXd &VV, Eigen::MatrixXi &TT, Eigen::MatrixXi &FF)
Definition mesh_with_skeleton.cpp:19

References DEFAULT_TETGEN_FLAGS, and mesh_with_skeleton().

+ Here is the call graph for this function:

◆ read_into_tetgenio()

IGL_INLINE bool igl::copyleft::tetgen::read_into_tetgenio ( const std::string &  path,
tetgenio &  in 
)
31{
32 using namespace std;
33 // get file extension
34 string dirname,basename,ext,filename;
35 pathinfo(path,dirname,basename,ext,filename);
36 // convert to lower case for easy comparison
37 transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
38 bool success = false;
39
40 char basename_char[1024];
41 strcpy(basename_char,basename.c_str());
42
43 if(ext == "obj")
44 {
45 // read obj into vertex list and face list
46 vector<vector<REAL> > V,TC,N;
47 vector<vector<int> > F,FTC,FN;
48 success = readOBJ(path,V,TC,N,F,FTC,FN);
49 success &= mesh_to_tetgenio(V,F,in);
50 }else if(ext == "off")
51 {
52 success = in.load_off(basename_char);
53 }else if(ext == "node")
54 {
55 success = in.load_node(basename_char);
56 }else
57 {
58 if(ext.length() > 0)
59 {
60 cerr<<"^read_into_tetgenio Warning: Unsupported extension ("<<ext<<
61 "): try to load as basename..."<<endl;
62 }
63 // This changed as of (the so far unreleased) tetgen 1.5
64 //success = in.load_tetmesh(basename_char);
65 //int object = tetgenbehavior::NODES;
66 //if(ext == "mesh")
67 //{
68 // object = tetgenbehavior::MEDIT;
69 //}
70 success = in.load_tetmesh(basename_char,!tetgenbehavior::MEDIT);
71 }
72
73 return success;
74}
IGL_INLINE void pathinfo(const std::string &path, std::string &dirname, std::string &basename, std::string &extension, std::string &filename)
Definition pathinfo.cpp:16
IGL_INLINE std::string dirname(const std::string &path)
Definition dirname.cpp:13
IGL_INLINE bool readOBJ(const std::string obj_file_name, std::vector< std::vector< Scalar > > &V, std::vector< std::vector< Scalar > > &TC, std::vector< std::vector< Scalar > > &N, std::vector< std::vector< Index > > &F, std::vector< std::vector< Index > > &FTC, std::vector< std::vector< Index > > &FN)
Definition readOBJ.cpp:21
IGL_INLINE std::string basename(const std::string &path)
Definition basename.cpp:12

References igl::basename(), igl::dirname(), mesh_to_tetgenio(), igl::pathinfo(), and igl::readOBJ().

+ Here is the call graph for this function:

◆ tetgenio_to_tetmesh() [1/4]

template<typename DerivedV , typename DerivedT >
IGL_INLINE bool igl::copyleft::tetgen::tetgenio_to_tetmesh ( const tetgenio &  out,
Eigen::PlainObjectBase< DerivedV > &  V,
Eigen::PlainObjectBase< DerivedT > &  T 
)
138{
140 return tetgenio_to_tetmesh(out,V,T,F);
141}
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:180
IGL_INLINE bool tetgenio_to_tetmesh(const tetgenio &out, std::vector< std::vector< REAL > > &V, std::vector< std::vector< int > > &T, std::vector< std::vector< int > > &F)
Definition tetgenio_to_tetmesh.cpp:16

References tetgenio_to_tetmesh().

+ Here is the call graph for this function:

◆ tetgenio_to_tetmesh() [2/4]

template<typename DerivedV , typename DerivedT , typename DerivedF >
IGL_INLINE bool igl::copyleft::tetgen::tetgenio_to_tetmesh ( const tetgenio &  out,
Eigen::PlainObjectBase< DerivedV > &  V,
Eigen::PlainObjectBase< DerivedT > &  T,
Eigen::PlainObjectBase< DerivedF > &  F 
)
102{
103 using namespace std;
104 vector<vector<REAL> > vV;
105 vector<vector<int> > vT;
106 vector<vector<int> > vF;
107 bool success = tetgenio_to_tetmesh(out,vV,vT,vF);
108 if(!success)
109 {
110 return false;
111 }
112 bool V_rect = list_to_matrix(vV,V);
113 if(!V_rect)
114 {
115 // igl::list_to_matrix(vV,V) already printed error message to std err
116 return false;
117 }
118 bool T_rect = list_to_matrix(vT,T);
119 if(!T_rect)
120 {
121 // igl::list_to_matrix(vT,T) already printed error message to std err
122 return false;
123 }
124 bool F_rect = list_to_matrix(vF,F);
125 if(!F_rect)
126 {
127 return false;
128 }
129
130 return true;
131}
IGL_INLINE bool list_to_matrix(const std::vector< std::vector< T > > &V, Eigen::PlainObjectBase< Derived > &M)
Definition list_to_matrix.cpp:19

References igl::list_to_matrix(), and tetgenio_to_tetmesh().

+ Here is the call graph for this function:

◆ tetgenio_to_tetmesh() [3/4]

IGL_INLINE bool igl::copyleft::tetgen::tetgenio_to_tetmesh ( const tetgenio &  out,
std::vector< std::vector< REAL > > &  V,
std::vector< std::vector< int > > &  T 
)
91{
92 std::vector<std::vector<int> > F;
93 return tetgenio_to_tetmesh(out,V,T,F);
94}

References tetgenio_to_tetmesh().

+ Here is the call graph for this function:

◆ tetgenio_to_tetmesh() [4/4]

IGL_INLINE bool igl::copyleft::tetgen::tetgenio_to_tetmesh ( const tetgenio &  out,
std::vector< std::vector< REAL > > &  V,
std::vector< std::vector< int > > &  T,
std::vector< std::vector< int > > &  F 
)
21{
22 using namespace std;
23 // process points
24 if(out.pointlist == NULL)
25 {
26 cerr<<"^tetgenio_to_tetmesh Error: point list is NULL\n"<<endl;
27 return false;
28 }
29 V.resize(out.numberofpoints,vector<REAL>(3));
30 // loop over points
31 for(int i = 0;i < out.numberofpoints; i++)
32 {
33 V[i][0] = out.pointlist[i*3+0];
34 V[i][1] = out.pointlist[i*3+1];
35 V[i][2] = out.pointlist[i*3+2];
36 }
37
38
39 // process tets
40 if(out.tetrahedronlist == NULL)
41 {
42 cerr<<"^tetgenio_to_tetmesh Error: tet list is NULL\n"<<endl;
43 return false;
44 }
45
46 // When would this not be 4?
47 assert(out.numberofcorners == 4);
48 T.resize(out.numberoftetrahedra,vector<int>(out.numberofcorners));
49 int min_index = 1e7;
50 int max_index = -1e7;
51 // loop over tetrahedra
52 for(int i = 0; i < out.numberoftetrahedra; i++)
53 {
54 for(int j = 0; j<out.numberofcorners; j++)
55 {
56 int index = out.tetrahedronlist[i * out.numberofcorners + j];
57 T[i][j] = index;
58 min_index = (min_index > index ? index : min_index);
59 max_index = (max_index < index ? index : max_index);
60 }
61 }
62 assert(min_index >= 0);
63 assert(max_index >= 0);
64 assert(max_index < (int)V.size());
65
66 cout<<out.numberoftrifaces<<endl;
67
68 // When would this not be 4?
69 F.clear();
70 // loop over tetrahedra
71 for(int i = 0; i < out.numberoftrifaces; i++)
72 {
73 if(out.trifacemarkerlist[i]>=0)
74 {
75 vector<int> face(3);
76 for(int j = 0; j<3; j++)
77 {
78 face[j] = out.trifacelist[i * 3 + j];
79 }
80 F.push_back(face);
81 }
82 }
83
84 return true;
85}
@ F
Definition libslic3r.h:102

Referenced by tetgenio_to_tetmesh(), tetgenio_to_tetmesh(), tetgenio_to_tetmesh(), tetrahedralize(), and tetrahedralize().

+ Here is the caller graph for this function:

◆ tetrahedralize() [1/4]

template<typename DerivedV , typename DerivedF , typename DerivedVM , typename DerivedFM , typename DerivedTV , typename DerivedTT , typename DerivedTF , typename DerivedTM >
IGL_INLINE int igl::copyleft::tetgen::tetrahedralize ( const Eigen::PlainObjectBase< DerivedV > &  V,
const Eigen::PlainObjectBase< DerivedF > &  F,
const Eigen::PlainObjectBase< DerivedVM > &  VM,
const Eigen::PlainObjectBase< DerivedFM > &  FM,
const std::string  switches,
Eigen::PlainObjectBase< DerivedTV > &  TV,
Eigen::PlainObjectBase< DerivedTT > &  TT,
Eigen::PlainObjectBase< DerivedTF > &  TF,
Eigen::PlainObjectBase< DerivedTM > &  TM 
)
122{
123 using namespace std;
124 vector<vector<REAL> > vV,vTV;
125 vector<vector<int> > vF,vTT,vTF;
126 vector<int> vTM;
127
128 matrix_to_list(V,vV);
129 matrix_to_list(F,vF);
130 vector<int> vVM = matrix_to_list(VM);
131 vector<int> vFM = matrix_to_list(FM);
132 int e = tetrahedralize(vV,vF,vVM,vFM,switches,vTV,vTT,vTF,vTM);
133 if(e == 0)
134 {
135 bool TV_rect = list_to_matrix(vTV,TV);
136 if(!TV_rect)
137 {
138 return false;
139 }
140 bool TT_rect = list_to_matrix(vTT,TT);
141 if(!TT_rect)
142 {
143 return false;
144 }
145 bool TF_rect = list_to_matrix(vTF,TF);
146 if(!TF_rect)
147 {
148 return false;
149 }
150 bool TM_rect = list_to_matrix(vTM,TM);
151 if(!TM_rect)
152 {
153 return false;
154 }
155 }
156 return e;
157}

References igl::list_to_matrix(), igl::matrix_to_list(), and tetrahedralize().

+ Here is the call graph for this function:

◆ tetrahedralize() [2/4]

template<typename DerivedV , typename DerivedF , typename DerivedTV , typename DerivedTT , typename DerivedTF >
IGL_INLINE int igl::copyleft::tetgen::tetrahedralize ( const Eigen::PlainObjectBase< DerivedV > &  V,
const Eigen::PlainObjectBase< DerivedF > &  F,
const std::string  switches,
Eigen::PlainObjectBase< DerivedTV > &  TV,
Eigen::PlainObjectBase< DerivedTT > &  TT,
Eigen::PlainObjectBase< DerivedTF > &  TF 
)
75{
76 using namespace std;
77 vector<vector<REAL> > vV,vTV;
78 vector<vector<int> > vF,vTT,vTF;
79 matrix_to_list(V,vV);
80 matrix_to_list(F,vF);
81 int e = tetrahedralize(vV,vF,switches,vTV,vTT,vTF);
82 if(e == 0)
83 {
84 bool TV_rect = list_to_matrix(vTV,TV);
85 if(!TV_rect)
86 {
87 return 3;
88 }
89 bool TT_rect = list_to_matrix(vTT,TT);
90 if(!TT_rect)
91 {
92 return 3;
93 }
94 bool TF_rect = list_to_matrix(vTF,TF);
95 if(!TF_rect)
96 {
97 return 3;
98 }
99 }
100 return e;
101}

References igl::list_to_matrix(), igl::matrix_to_list(), and tetrahedralize().

+ Here is the call graph for this function:

◆ tetrahedralize() [3/4]

IGL_INLINE int igl::copyleft::tetgen::tetrahedralize ( const std::vector< std::vector< REAL > > &  V,
const std::vector< std::vector< int > > &  F,
const std::string  switches,
std::vector< std::vector< REAL > > &  TV,
std::vector< std::vector< int > > &  TT,
std::vector< std::vector< int > > &  TF 
)
28{
29 using namespace std;
30 tetgenio in,out;
31 bool success;
32 success = mesh_to_tetgenio(V,F,in);
33 if(!success)
34 {
35 return -1;
36 }
37 try
38 {
39 char * cswitches = new char[switches.size() + 1];
40 std::strcpy(cswitches,switches.c_str());
41 ::tetrahedralize(cswitches,&in, &out);
42 delete[] cswitches;
43 }catch(int e)
44 {
45 cerr<<"^"<<__FUNCTION__<<": TETGEN CRASHED... KABOOOM!!!"<<endl;
46 return 1;
47 }
48 if(out.numberoftetrahedra == 0)
49 {
50 cerr<<"^"<<__FUNCTION__<<": Tetgen failed to create tets"<<endl;
51 return 2;
52 }
53 success = tetgenio_to_tetmesh(out,TV,TT,TF);
54 if(!success)
55 {
56 return -1;
57 }
58 //boundary_facets(TT,TF);
59 return 0;
60}

References mesh_to_tetgenio(), and tetgenio_to_tetmesh().

Referenced by cdt(), mesh_with_skeleton(), tetrahedralize(), and tetrahedralize().

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

◆ tetrahedralize() [4/4]

IGL_INLINE int igl::copyleft::tetgen::tetrahedralize ( const std::vector< std::vector< REAL > > &  V,
const std::vector< std::vector< int > > &  F,
const std::vector< int > &  VM,
const std::vector< int > &  FM,
const std::string  switches,
std::vector< std::vector< REAL > > &  TV,
std::vector< std::vector< int > > &  TT,
std::vector< std::vector< int > > &  TF,
std::vector< int > &  TM 
)
168{
169 using namespace std;
170 tetgenio in,out;
171 bool success;
172 success = mesh_to_tetgenio(V,F,in);
173 if(!success)
174 {
175 return -1;
176 }
177 in.pointmarkerlist = new int[VM.size()];
178 for (int i = 0; i < VM.size(); ++i) {
179 in.pointmarkerlist[i] = VM[i];
180 }
181 // These have already been created in mesh_to_tetgenio.
182 // Reset them here.
183 for (int i = 0; i < FM.size(); ++i) {
184 in.facetmarkerlist[i] = FM[i];
185 }
186 try
187 {
188 char * cswitches = new char[switches.size() + 1];
189 std::strcpy(cswitches,switches.c_str());
190 ::tetrahedralize(cswitches,&in, &out);
191 delete[] cswitches;
192 }catch(int e)
193 {
194 cerr<<"^"<<__FUNCTION__<<": TETGEN CRASHED... KABOOOM!!!"<<endl;
195 return 1;
196 }
197 if(out.numberoftetrahedra == 0)
198 {
199 cerr<<"^"<<__FUNCTION__<<": Tetgen failed to create tets"<<endl;
200 return 2;
201 }
202 success = tetgenio_to_tetmesh(out,TV,TT,TF);
203 if(!success)
204 {
205 return -1;
206 }
207 TM.resize(out.numberofpoints);
208 for (int i = 0; i < out.numberofpoints; ++i) {
209 TM[i] = out.pointmarkerlist[i];
210 }
211 //boundary_facets(TT,TF);
212 return 0;
213}

References mesh_to_tetgenio(), and tetgenio_to_tetmesh().

+ Here is the call graph for this function: