From e6989526ca1514a4b6e04354040c0292d0bbc8d1 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Sat, 25 Apr 2015 15:20:09 -0400 Subject: [PATCH] #1325 Fixed crash when polygons with > 3 indices turn out to be degenerate --- src/polyset-utils.cc | 5 ++++- testdata/scad/3D/issues/issue1325.scad | 10 ++++++++++ .../cgalpngtest/issue1325-expected.png | Bin 0 -> 4408 bytes .../monotonepngtest/issue1325-expected.png | Bin 0 -> 4408 bytes .../opencsgtest/issue1325-expected.png | Bin 0 -> 4408 bytes .../throwntogethertest/issue1325-expected.png | Bin 0 -> 4408 bytes .../xcshareddata/xcschemes/OpenSCAD.app.xcscheme | 12 +++++++----- 7 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 testdata/scad/3D/issues/issue1325.scad create mode 100644 tests/regression/cgalpngtest/issue1325-expected.png create mode 100644 tests/regression/monotonepngtest/issue1325-expected.png create mode 100644 tests/regression/opencsgtest/issue1325-expected.png create mode 100644 tests/regression/throwntogethertest/issue1325-expected.png diff --git a/src/polyset-utils.cc b/src/polyset-utils.cc index 3b3e19b2..57671a76 100644 --- a/src/polyset-utils.cc +++ b/src/polyset-utils.cc @@ -77,7 +77,10 @@ namespace PolysetUtils { if (currface.empty() || idx != currface.back()) currface.push_back(idx); } if (currface.front() == currface.back()) currface.pop_back(); - if (currface.size() < 3) faces.pop_back(); // Cull empty triangles + if (currface.size() < 3) { + faces.pop_back(); // Cull empty triangles + if (faces.empty()) polygons.pop_back(); // All faces were culled + } } // Tessellate indexed mesh diff --git a/testdata/scad/3D/issues/issue1325.scad b/testdata/scad/3D/issues/issue1325.scad new file mode 100644 index 00000000..c1d12b1f --- /dev/null +++ b/testdata/scad/3D/issues/issue1325.scad @@ -0,0 +1,10 @@ +polyhedron(points = [ +[0, -4, 1], +[0, -5, 1], +[0, -5, 2], +[0, -4, 0] +], +faces = [ +[1, 2, 2, 1], +[0, 0, 3, 3] +]); diff --git a/tests/regression/cgalpngtest/issue1325-expected.png b/tests/regression/cgalpngtest/issue1325-expected.png new file mode 100644 index 0000000000000000000000000000000000000000..08ee92b2216f45ca6b83efbc3b78c9fdabf45a71 GIT binary patch literal 4408 zcmeAS@N?(olHy`uVBq!ia0y~yU;;9k7&t&wwUqN(1_puuo-U3d6^w7MGV(Gg@Gv_b z*za4?v*2+)UsdcS+v4fU4h;;A^A5apoi>Akk%?tr1LFsF77l?9E{TSWk4eG`4hI;1 z0L3|6Sa}?_RBYrFP)K0-15&w&iA^DD&kdkj1BSW=phzGivw&_~4p6NGgFVR96%C9X zV)|x4wLA^-3JwhpAqN;-y2WP$)v_Jn7f^6e&`MxfbhO(SsGIo#JBNURfT#h(#Yacg z92$VmU>Akk%?tr1LFsF77l?9E{TSWk4eG`4hI;1 z0L3|6Sa}?_RBYrFP)K0-15&w&iA^DD&kdkj1BSW=phzGivw&_~4p6NGgFVR96%C9X zV)|x4wLA^-3JwhpAqN;-y2WP$)v_Jn7f^6e&`MxfbhO(SsGIo#JBNURfT#h(#Yacg z92$VmU>Akk%?tr1LFsF77l?9E{TSWk4eG`4hI;1 z0L3|6Sa}?_RBYrFP)K0-15&w&iA^DD&kdkj1BSW=phzGivw&_~4p6NGgFVR96%C9X zV)|x4wLA^-3JwhpAqN;-y2WP$)v_Jn7f^6e&`MxfbhO(SsGIo#JBNURfT#h(#Yacg z92$VmU>Akk%?tr1LFsF77l?9E{TSWk4eG`4hI;1 z0L3|6Sa}?_RBYrFP)K0-15&w&iA^DD&kdkj1BSW=phzGivw&_~4p6NGgFVR96%C9X zV)|x4wLA^-3JwhpAqN;-y2WP$)v_Jn7f^6e&`MxfbhO(SsGIo#JBNURfT#h(#Yacg z92$VmU> - + + isEnabled = "NO"> + argument = "issue1276.scad" + isEnabled = "YES"> - +