6 #ifndef MESH_POLYMESH_H
7 #define MESH_POLYMESH_H
23 Vertex(
double x,
double y,
double z,
int _d = -1)
67 for(
auto it :
hedges)
delete it;
68 for(
auto it :
faces)
delete it;
76 sprintf(name,
"polyMesh%d.pos", debugTag);
77 FILE *
f = fopen(name,
"w");
78 fprintf(
f,
"View \" %s \"{\n", name);
79 for(
auto it :
faces) {
83 fprintf(
f,
"ST(%g,%g,0,%g,%g,0,%g,%g,0){%d,%d,%d};\n",
86 it->data, it->data, it->data);
91 fprintf(
f,
"SL(%g,%g,0,%g,%g,0){%d,%d};\n", he->
v->
position.
x(),
108 if(he == NULL)
return -1;
111 }
while(he != v->
he);
122 }
while(he != start);
134 if(he == NULL)
return -1;
137 }
while(he != v->
he);
146 if(he->
next->
v == v1)
return he;
148 if(he == NULL)
return NULL;
150 }
while(he != v0->
he);
170 he0->
f = he1->
f = he2->
f =
f;
200 if(heo0 == NULL)
return -1;
221 if(heo ==
nullptr)
return -1;
242 to_delete->
he =
nullptr;
248 std::vector<Vertex *> uv;
260 std::vector<HalfEdge *> uh;
272 std::vector<Face *> uf;
292 if(he1m ==
nullptr)
return -1;
294 Vertex *mid =
new Vertex(position.
x(), position.
y(), position.
z(), data);
334 Face *f0m2 = he0m->
f;
335 Face *f1m3 = he1m->
f;
338 faces.push_back(f2m1);
339 faces.push_back(f3m0);
341 createFace(f0m2, v0, mid, v2, he0m, hem2, he20);
342 createFace(f1m3, v1, mid, v3, he1m, hem3, he31);
343 createFace(f2m1, v2, mid, v1, he2m, hem1, he12);
344 createFace(f3m0, v3, mid, v0, he3m, hem0, he03);
381 createFace(f0, v_mm, v_MM, v_Mm, mm_MM, MM_Mm, Mm_mm);
391 createFace(f1, v_MM, v_mm, v_mM, MM_mm, mm_mM, mM_MM);
400 std::vector<HalfEdge *> *_t = NULL)
450 std::stack<HalfEdge *> _stack;
454 std::vector<HalfEdge *> _touched;
455 while(!_stack.empty()) {
457 _touched.push_back(he);
462 if(doSwap(he, data) == 1) {
468 for(
int k = 0; k < 2; k++) {
469 if(H[k] == NULL)
continue;
473 if(std::find(_touched.begin(), _touched.end(), heb) ==
475 std::find(_touched.begin(), _touched.end(), hebo) ==
483 if(std::find(_touched.begin(), _touched.end(), hec) ==
485 std::find(_touched.begin(), _touched.end(), heco) ==
492 if(_t) *_t = _touched;
505 if(l10 < l20)
return true;
506 if(l10 > l20)
return false;
507 if(l11 > l21)
return true;
519 if(l10 == l20 && l11 == l21)
return true;