summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorclifford <clifford@b57f626f-c46c-0410-a088-ec61d464b74c>2010-02-01 06:12:26 (GMT)
committerclifford <clifford@b57f626f-c46c-0410-a088-ec61d464b74c>2010-02-01 06:12:26 (GMT)
commitc1b747f6c2af34a61a2015fd00b33df088d1a98c (patch)
treef27d38618bd63d38a130bb5be42a0a6ba357772d
parent2e6946fd5ae35e751a92e8fba23ac2c4c83518dd (diff)
Clifford Wolf:
Improved robustness of src/dxftess-cgal.cc git-svn-id: http://svn.clifford.at/openscad/trunk@403 b57f626f-c46c-0410-a088-ec61d464b74c
-rw-r--r--src/dxftess-cgal.cc33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/dxftess-cgal.cc b/src/dxftess-cgal.cc
index 2653527..241043f 100644
--- a/src/dxftess-cgal.cc
+++ b/src/dxftess-cgal.cc
@@ -113,35 +113,42 @@ void dxf_tesselate(PolySet *ps, DxfData *dxf, double rot, bool up, bool /* do_tr
double x = dxf->paths[i].points[j]->x;
double y = dxf->paths[i].points[j]->y;
+ if (point_info.has(x, y)) {
+ // FIXME: How can the same path set contain the same point twice?
+ // ..maybe it would be better to assert here. But this would
+ // break compatibility with the glu tesselator that handled such
+ // cases just fine.
+ continue;
+ }
+
struct point_info_t *pi = &point_info.align(x, y);
*pi = point_info_t(x, y, i, j, dxf->paths[i].points.count()-1);
- if (j == 1) {
+ Vertex_handle vh = cdt.insert(CDTPoint(x, y));
+ if (first_pi == NULL) {
first_pi = pi;
+ first = vh;
} else {
prev_pi->neigh_next = pi;
pi->neigh_prev = prev_pi;
edge_to_path[edge_t(prev_pi, pi)] = 1;
edge_to_path[edge_t(pi, prev_pi)] = 1;
- }
- prev_pi = pi;
-
- Vertex_handle vh = cdt.insert(CDTPoint(x, y));
- if (j == 1) {
- first = vh;
- } else {
cdt.insert_constraint(prev, vh);
}
+ prev_pi = pi;
prev = vh;
}
- prev_pi->neigh_next = first_pi;
- first_pi->neigh_prev = prev_pi;
+ if (first_pi != NULL && first_pi != prev_pi)
+ {
+ prev_pi->neigh_next = first_pi;
+ first_pi->neigh_prev = prev_pi;
- edge_to_path[edge_t(first_pi, prev_pi)] = 1;
- edge_to_path[edge_t(prev_pi, first_pi)] = 1;
+ edge_to_path[edge_t(first_pi, prev_pi)] = 1;
+ edge_to_path[edge_t(prev_pi, first_pi)] = 1;
- cdt.insert_constraint(prev, first);
+ cdt.insert_constraint(prev, first);
+ }
}
// run delaunay triangulation
contact: Jan Huwald // Impressum