diff --git a/poly2d/p2d_area_holes.cpp b/poly2d/p2d_area_holes.cpp index 7118766..28bd9ef 100644 --- a/poly2d/p2d_area_holes.cpp +++ b/poly2d/p2d_area_holes.cpp @@ -23,6 +23,21 @@ extern "C" { #include "poly2d.h" } +/* + * @@@ Prevent spurious aborts with + * + * terminate called after throwing an instance of 'CGAL::Precondition_exception' + * what(): CGAL ERROR: precondition violation! + * Expr: is_simple_2(first, last, traits) + * File: /usr/include/CGAL/Polygon_2/Polygon_2_algorithms_impl.h + * Line: 420 + * + * Note that we also need to check the polygons for simplicity in recurse_area, + * or this may still lead to assertion failures. + */ + +#define CGAL_POLYGON_NO_PRECONDITIONS + #include "cgal_helper.h" #include @@ -55,6 +70,14 @@ static void append_poly(Polygon_2 poly, struct p2d ***last) static void recurse_area(Polygon_with_holes poly, double current, double next, struct p2d ***last) { + if (!poly.outer_boundary().is_simple()) + return; + for (Polygon_with_holes::Hole_const_iterator + hit = poly.holes_begin(); + hit != poly.holes_end(); ++hit) + if (!hit->is_simple()) + return; + PolygonPtrVector tmp = CGAL::create_interior_skeleton_and_offset_polygons_with_holes_2( current, poly);