diff --git a/poly2d/f2d_tri_holes.cpp b/poly2d/f2d_tri_holes.cpp index e8406bd..e5fc7df 100644 --- a/poly2d/f2d_tri_holes.cpp +++ b/poly2d/f2d_tri_holes.cpp @@ -186,31 +186,40 @@ static struct f2d *make_face(CDT::Finite_faces_iterator fit, const struct p2d *p, const struct p2d *holes) { struct f2d *f; + const struct v2d *v[3]; const struct p2d *h; - int i; + int i, j; - f = alloc_type(struct f2d); for (i = 0; i != 3; i++) { Point point = fit->vertex(i)->point(); const struct v2d *m; m = find_point(p, point.x(), point.y()); if (m) { - f->v[i] = m; - f->p[i] = p; + v[i] = m; continue; } for (h = holes; h; h = h->next) { m = find_point(h, point.x(), point.y()); if (!m) continue; - f->v[i] = m; - f->p[i] = h; + v[i] = m; break; } assert(m); } + + f = alloc_type(struct f2d); + for (i = 0; i != 3; i++) { + f->x[i] = v[i]->x; + f->y[i] = v[i]->y; + j = i+1; + if (j == 3) + j = 0; + f->side[i] = v[i]->next == v[j] || v[j]->next == v[i]; + } f->next = NULL; + return f; } diff --git a/poly2d/poly2d.h b/poly2d/poly2d.h index e802386..407994f 100644 --- a/poly2d/poly2d.h +++ b/poly2d/poly2d.h @@ -14,6 +14,7 @@ #ifndef POLY2D_H #define POLY2D_H +#include #include @@ -30,8 +31,9 @@ struct p2d { }; struct f2d { - const struct v2d *v[3]; /* vertices forming the face */ - const struct p2d *p[3]; /* polygons vertices belong to */ + double x[3]; /* vertices forming the face */ + double y[3]; + bool side[3]; /* side[i] if v[i] and v[(i+1) mod 3] are on polygon */ struct f2d *next; };