4 #include <CDT/delaunay.h>
5 #include <CDT/inputPLC.h>
11 const std::vector<double>& V,
13 const std::vector<uint32_t>& F,
18 const_cast<double*
>(V.data()),
20 const_cast<uint32_t*
>(F.data()),
28 plc.addBoundingBoxVertices();
31 cdt::TetMesh* tin =
new cdt::TetMesh;
32 tin->init_vertices(plc.coordinates.data(), plc.numVertices());
37 cdt::PLCx Steiner_plc(*tin, plc.triangle_vertices.data(), plc.numTriangles());
41 Steiner_plc.segmentRecovery_HSi(
true);
44 bool sisMethodWorks = Steiner_plc.faceRecovery(
true);
49 uint32_t num_inner_tets = (uint32_t)Steiner_plc.markInnerTets();
56 std::vector<std::array<bool, 4>>& local_f_on_input,
57 std::vector<std::array<int64_t, 4>>& T_final,
58 std::vector<std::array<std::string, 3>>& V_final,
61 std::vector<std::array<int64_t, 4>> T;
62 std::vector<std::array<std::string, 3>> V;
65 for (uint32_t i = 0; i < tin.numTets(); ++i) {
66 if (tin.mark_tetrahedra[i] == 2) {
71 for (uint32_t i = 0; i < tin.numVertices(); ++i) {
72 cdt::bigrational c[3];
73 tin.vertices[i]->getExactXYZCoordinates(c[0], c[1], c[2]);
75 std::array<std::string, 3> v;
77 #ifdef USE_GNU_GMP_CLASSES
78 v[0].init(c[0].get_mpq_t());
79 v[1].init(c[1].get_mpq_t());
80 v[2].init(c[2].get_mpq_t());
82 v[0] = c[0].get_str();
83 v[1] = c[1].get_str();
84 v[2] = c[2].get_str();
90 for (uint32_t i = 0; i < tin.numTets(); ++i) {
91 if (tin.mark_tetrahedra[i] == 2) {
93 {{tin.tet_node[i * 4],
94 tin.tet_node[i * 4 + 1],
95 tin.tet_node[i * 4 + 2],
96 tin.tet_node[i * 4 + 3]}});
100 std::array<bool, 4> on_input = {{
false,
false,
false,
false}};
101 for (uint64_t j = i; j < i + 4; ++j) {
102 if (tin.mark_tetrahedra[tin.tet_neigh[j] >> 2] != tin.mark_tetrahedra[j >> 2]) {
103 on_input[j - i] =
true;
107 local_f_on_input.push_back(on_input);
114 for (uint32_t i = 0; i < tin.numTets(); ++i) {
115 if (!tin.isGhost(i) && tin.mark_tetrahedra[i] != 2) {
117 {{tin.tet_node[i * 4],
118 tin.tet_node[i * 4 + 1],
119 tin.tet_node[i * 4 + 2],
120 tin.tet_node[i * 4 + 3]}});
124 std::array<bool, 4> on_input = {{
false,
false,
false,
false}};
125 for (uint64_t j = i; j < i + 4; ++j) {
126 if (tin.mark_tetrahedra[tin.tet_neigh[j] >> 2] != tin.mark_tetrahedra[j >> 2]) {
131 local_f_on_input.push_back(on_input);
139 std::vector<int> v_is_used_in_tet(V.size(), 0);
140 for (int64_t i = 0; i < T.size(); ++i) {
141 for (int64_t j = 0; j < 4; ++j) {
142 v_is_used_in_tet[T[i][j]] = 1;
146 int64_t v_used_cnt = std::count(v_is_used_in_tet.begin(), v_is_used_in_tet.end(), 1);
148 std::map<int64_t, int64_t> v_map;
150 for (int64_t i = 0; i < V.size(); ++i) {
151 if (v_is_used_in_tet[i]) {
152 v_map[i] = V_final.size();
153 V_final.push_back(V[i]);
159 for (int64_t i = 0; i < T.size(); ++i) {
160 for (int64_t j = 0; j < 4; ++j) {
161 T_final[i][j] = v_map[T[i][j]];
167 const std::vector<double>& V,
169 const std::vector<uint32_t>& F,
171 std::vector<std::array<bool, 4>>& local_f_on_input,
172 std::vector<std::array<int64_t, 4>>& T_final,
173 std::vector<std::array<std::string, 3>>& V_final,
void cdt_to_string(const std::vector< double > &V, const uint32_t npts, const std::vector< uint32_t > &F, const uint32_t ntri, std::vector< std::array< bool, 4 >> &local_f_on_input, std::vector< std::array< int64_t, 4 >> &T_final, std::vector< std::array< std::string, 3 >> &V_final, bool inner_only)
void convert_trimesh_to_input_plc(const std::vector< double > &V, const uint32_t npts, const std::vector< uint32_t > &F, const uint32_t ntri, cdt::inputPLC &plc)
cdt::TetMesh * createSteinerCDT(cdt::inputPLC &plc, bool bbox, bool snap)
void convert_cdt_to_stl(cdt::TetMesh &tin, std::vector< std::array< bool, 4 >> &local_f_on_input, std::vector< std::array< int64_t, 4 >> &T_final, std::vector< std::array< std::string, 3 >> &V_final, bool inner_only)