From 4120846d18c1a7ce5a51169feb1babb0603bddc0 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Sat, 5 Nov 2011 18:07:56 +0100 Subject: Catch a CGAL assert caused by a subtraction resulting in non-manifold geometry. see testdata/scad/bugs/rotate-diff-nonmanifold-crash.scad diff --git a/src/CGAL_Nef_polyhedron.cc b/src/CGAL_Nef_polyhedron.cc index 975c9a4..ccfde24 100644 --- a/src/CGAL_Nef_polyhedron.cc +++ b/src/CGAL_Nef_polyhedron.cc @@ -25,8 +25,16 @@ CGAL_Nef_polyhedron& CGAL_Nef_polyhedron::operator*=(const CGAL_Nef_polyhedron & CGAL_Nef_polyhedron& CGAL_Nef_polyhedron::operator-=(const CGAL_Nef_polyhedron &other) { - if (this->dim == 2) (*this->p2) -= (*other.p2); - else if (this->dim == 3) (*this->p3) -= (*other.p3); + // Triggered by testdata/scad/bugs/rotate-diff-nonmanifold-crash.scad + CGAL::Failure_behaviour old_behaviour = CGAL::set_error_behaviour(CGAL::THROW_EXCEPTION); + try { + if (this->dim == 2) (*this->p2) -= (*other.p2); + else if (this->dim == 3) (*this->p3) -= (*other.p3); + } + catch (CGAL::Assertion_exception e) { + PRINTF("CGAL error in CGAL_Nef_polyhedron::operator-=(): %s", e.what()); + } + CGAL::set_error_behaviour(old_behaviour); return *this; } diff --git a/testdata/scad/bugs/rotate-diff-nonmanifold-crash.scad b/testdata/scad/bugs/rotate-diff-nonmanifold-crash.scad new file mode 100644 index 0000000..d7011d9 --- /dev/null +++ b/testdata/scad/bugs/rotate-diff-nonmanifold-crash.scad @@ -0,0 +1,4 @@ +difference() { + rotate_extrude($fn=5) translate([4,0,0]) square([10, 10], center=true); + translate([6,6,6]) sphere(r=10); +} -- cgit v0.10.1