diff options
author | clifford <clifford@b57f626f-c46c-0410-a088-ec61d464b74c> | 2010-02-01 12:12:41 (GMT) |
---|---|---|
committer | clifford <clifford@b57f626f-c46c-0410-a088-ec61d464b74c> | 2010-02-01 12:12:41 (GMT) |
commit | d8615943fd1ed1efe0d9f0e72907ded5d19efab9 (patch) | |
tree | 97ad5f0f0e10dc0a91f85682477692fa1499d981 /src/dxftess-cgal.cc | |
parent | 51ae2483733a75c8e7fbaa8abe7f7b0a999c1db0 (diff) |
Clifford Wolf:
Improved/Fixed cgal tesselation code
git-svn-id: http://svn.clifford.at/openscad/trunk@407 b57f626f-c46c-0410-a088-ec61d464b74c
Diffstat (limited to 'src/dxftess-cgal.cc')
-rw-r--r-- | src/dxftess-cgal.cc | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/dxftess-cgal.cc b/src/dxftess-cgal.cc index 241043f..68b85db 100644 --- a/src/dxftess-cgal.cc +++ b/src/dxftess-cgal.cc @@ -209,6 +209,10 @@ void dxf_tesselate(PolySet *ps, DxfData *dxf, double rot, bool up, bool /* do_tr for (int i = 0; i < far_left_p->triangles.size(); i++) { int idx = far_left_p->triangles[i]; + + if (tri[idx].is_marked) + continue; + point_info_t *p0 = &point_info.data(tri[idx].p[0].x, tri[idx].p[0].y); point_info_t *p1 = &point_info.data(tri[idx].p[1].x, tri[idx].p[1].y); point_info_t *p2 = &point_info.data(tri[idx].p[2].x, tri[idx].p[2].y); @@ -231,7 +235,7 @@ void dxf_tesselate(PolySet *ps, DxfData *dxf, double rot, bool up, bool /* do_tr if (mp->neigh_next == np1 && mp->neigh_prev == np2) { mark_inner_outer(tri, point_info, edge_to_triangle, edge_to_path, idx, true); - break; + goto found_and_marked_inner; } if (mp->neigh_next == np1) @@ -241,16 +245,33 @@ void dxf_tesselate(PolySet *ps, DxfData *dxf, double rot, bool up, bool /* do_tr tp = np1; if (tp != NULL) { + double z0 = (mp->neigh_next->x - mp->x) * (mp->neigh_prev->y - mp->y) - + (mp->neigh_prev->x - mp->x) * (mp->neigh_next->y - mp->y); double z1 = (mp->neigh_next->x - mp->x) * (tp->y - mp->y) - (tp->x - mp->x) * (mp->neigh_next->y - mp->y); double z2 = (tp->x - mp->x) * (mp->neigh_prev->y - mp->y) - (mp->neigh_prev->x - mp->x) * (tp->y - mp->y); - if (z1 < 0 && z2 < 0) { + if ((z0 < 0 && z1 < 0 && z2 < 0) || (z0 > 0 && z1 > 0 && z2 > 0)) { mark_inner_outer(tri, point_info, edge_to_triangle, edge_to_path, idx, true); - break; + goto found_and_marked_inner; } } } + + // far left point is in the middle of a vertical segment + // -> it is ok to use any unmarked triangle connected to this point + for (int i = 0; i < far_left_p->triangles.size(); i++) + { + int idx = far_left_p->triangles[i]; + + if (tri[idx].is_marked) + continue; + + mark_inner_outer(tri, point_info, edge_to_triangle, edge_to_path, idx, true); + break; + } + + found_and_marked_inner:; } // add all inner triangles to target polyset |