1
0
mirror of git://projects.qi-hardware.com/cae-tools.git synced 2024-12-22 23:51:08 +02:00

poly2d/: try to work around spurious aborts in CGAL::create_interior_skeleton_and_offset_polygons_with_holes_2

cameo encountered spurious aborts with the following message:

  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

These aborts come and go even if just the coordinate origin is slightly
changed. Setting CGAL_POLYGON_NO_PRECONDITIONS in p2d_area_holes.cpp
made them go away in some cases, but cameo could still run into an
assertion violation (in CGAL).

We now check all the polygons, outer boundary and holes, being sent to
CGAL::create_interior_skeleton_and_offset_polygons_with_holes_2 for
simplicity, and stop recursing if there is any hint of a problem.

This seems to avoid trouble for now, but the issue deserves further
investigation.
This commit is contained in:
Werner Almesberger 2012-08-22 11:46:36 -03:00
parent 072b7804ee
commit 53fe70950d

View File

@ -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 <vector>
@ -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);