Polygon Difference - h->flag()!=NOT_VISITED Assertion Failure

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Polygon Difference - h->flag()!=NOT_VISITED Assertion Failure

Bryant
This post was updated on .
Hello!

I am trying to perform a boolean difference between a Polygon_with_holes_2
and a Polygon_2 (using the EPEC kernel) and I'm getting the following
assertion:
terminate called after throwing an instance of 'CGAL::Assertion_exception'
  what():  CGAL ERROR: assertion violation!
Expr: h->flag()!=NOT_VISITED
File: /home/bryant/geopipe/deps/CGAL-cmake/install/lib/cmake/CGAL/../../../include/CGAL/Boolean_set_operations_2/Gps_on_surface_base_2.h
Line: 1207
Aborted (core dumped)

Here is an MWE:
    Polygon_2<K> ob;
    ob.push_back(Point_2<K>(1, 1));
    ob.push_back(Point_2<K>(1, 0));
    ob.push_back(Point_2<K>(4, 0));
    ob.push_back(Point_2<K>(4, 4));
    ob.push_back(Point_2<K>(0, 4));
    ob.push_back(Point_2<K>(0, 1));

    Polygon_2<K> hole;
    hole.push_back(Point_2<K>(2, 1));
    hole.push_back(Point_2<K>(3, 1));
    hole.push_back(Point_2<K>(3, 2));
    hole.push_back(Point_2<K>(2, 2));
    hole.push_back(Point_2<K>(2, 1.75));
    hole.push_back(Point_2<K>(2, 1.25));

    Polygon_2<K> new_poly;
    new_poly.push_back(Point_2<K>(1, 1));
    new_poly.push_back(Point_2<K>(2, 1));
    new_poly.push_back(Point_2<K>(2, 2));
    new_poly.push_back(Point_2<K>(1, 2));

    {
        Polygon_set_2<K> inter(ob);
        inter.difference(hole);
        inter.difference(new_poly);
    }


I'm a little confused as I thought that this assertion is hit when trying to
perform a boolean operation on a polygon that is non-simple. Further, I do
not hit the assertion when first unioning hole and the new_poly together and
then subtracting it from ob.
     {
        Polygon_set_2<K> hole_set(hole);
        hole_set.join(new_poly);
        Polygon_set_2<K> inter(ob);
        inter.difference(hole_set);
    }

Edit: Using CGAL 4.13

--
Sent from: http://cgal-discuss.949826.n4.nabble.com/

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss


Reply | Threaded
Open this post in threaded view
|

Re: Polygon Difference - h->flag()!=NOT_VISITED Assertion Failure

Sebastien Loriot (GeometryFactory)
I think this was fixed by https://github.com/CGAL/cgal/pull/3774
that is part of CGAL-4.14, CGAL-4.12.2, and CGALL 4.13.1

Could you give it a try and let me know?

Thanks,

Sebastien.

On 5/1/19 6:55 PM, Bryant wrote:

> Missing MWE:
>      Polygon_2<K> ob;
>      ob.push_back(Point_2<K>(1, 1));
>      ob.push_back(Point_2<K>(1, 0));
>      ob.push_back(Point_2<K>(4, 0));
>      ob.push_back(Point_2<K>(4, 4));
>      ob.push_back(Point_2<K>(0, 4));
>      ob.push_back(Point_2<K>(0, 1));
>
>      Polygon_2<K> hole;
>      hole.push_back(Point_2<K>(2, 1));
>      hole.push_back(Point_2<K>(3, 1));
>      hole.push_back(Point_2<K>(3, 2));
>      hole.push_back(Point_2<K>(2, 2));
>      hole.push_back(Point_2<K>(2, 1.75));
>      hole.push_back(Point_2<K>(2, 1.25));
>
>      Polygon_2<K> new_poly;
>      new_poly.push_back(Point_2<K>(1, 1));
>      new_poly.push_back(Point_2<K>(2, 1));
>      new_poly.push_back(Point_2<K>(2, 2));
>      new_poly.push_back(Point_2<K>(1, 2));
>
>      {
>          Polygon_set_2<K> inter(ob);
>          inter.difference(hole);
>          inter.difference(new_poly);
>      }
>
> and followup union before subtraction:
>      {
>          Polygon_set_2<K> hole_set(hole);
>          hole_set.join(new_poly);
>          Polygon_set_2<K> inter(ob);
>          inter.difference(hole_set);
>      }
>
>
>
> --
> Sent from: http://cgal-discuss.949826.n4.nabble.com/
>

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss


Reply | Threaded
Open this post in threaded view
|

Re: Polygon Difference - h->flag()!=NOT_VISITED Assertion Failure

Bryant
I switched from using CGAL-4.13 to using CGAL-4.13.1 and this indeed resolved
the issue I was seeing. Thanks Sebastien Loriot!



--
Sent from: http://cgal-discuss.949826.n4.nabble.com/

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss