diff options
author | clifford <clifford@b57f626f-c46c-0410-a088-ec61d464b74c> | 2010-01-13 10:48:30 (GMT) |
---|---|---|
committer | clifford <clifford@b57f626f-c46c-0410-a088-ec61d464b74c> | 2010-01-13 10:48:30 (GMT) |
commit | d724385dd003f871c0b1218392387e6ab87db28f (patch) | |
tree | a8e6b507f01e0dc77304585d848519a182623aba | |
parent | e56c8832e175c0160445eb0fe15f4ea145f07f15 (diff) |
Clifford Wolf:
Do not crash on bogus polygon() calls
git-svn-id: http://svn.clifford.at/openscad/trunk@273 b57f626f-c46c-0410-a088-ec61d464b74c
-rw-r--r-- | TODO.txt | 1 | ||||
-rw-r--r-- | primitives.cc | 14 |
2 files changed, 10 insertions, 5 deletions
@@ -5,7 +5,6 @@ o Some invalid DXF data gets pass the import checks and breaks the tessing code o Broken polyhedron() entities are not correctly detected and cause CGAL segfaults o Tesselation via GLU sometimes produces strange results o Non-manifold objects make CGAL crash (e.g. two cubes which touch at one edge) -o crash: polygon(paths=[[0,0],[10,0],[0,10]]) o crash: rotate([0,1,0])import_dxf("../openscad-tess/testdata/polygon.dxf"); USER INTERFACE diff --git a/primitives.cc b/primitives.cc index 7e6a9e1..95bd3b8 100644 --- a/primitives.cc +++ b/primitives.cc @@ -481,11 +481,17 @@ sphere_next_r2: dd.paths.append(DxfData::Path()); for (int j=0; j<paths.vec[i]->vec.size(); j++) { int idx = paths.vec[i]->vec[j]->num; - DxfData::Point *p = &dd.points[idx]; - dd.paths.last().points.append(p); + if (idx < dd.points.size()) { + DxfData::Point *p = &dd.points[idx]; + dd.paths.last().points.append(p); + } + } + if (dd.paths.last().points.isEmpty()) { + dd.paths.removeLast(); + } else { + dd.paths.last().points.append(dd.paths.last().points.first()); + dd.paths.last().is_closed = true; } - dd.paths.last().points.append(dd.paths.last().points.first()); - dd.paths.last().is_closed = true; } } |