From d724385dd003f871c0b1218392387e6ab87db28f Mon Sep 17 00:00:00 2001 From: clifford Date: Wed, 13 Jan 2010 10:48:30 +0000 Subject: Clifford Wolf: Do not crash on bogus polygon() calls git-svn-id: http://svn.clifford.at/openscad/trunk@273 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/TODO.txt b/TODO.txt index bfcf775..8f4dbc4 100644 --- a/TODO.txt +++ b/TODO.txt @@ -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; jvec.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; } } -- cgit v0.10.1