# Simple Polygon Difference Results in Non-Simple Polygon

4 messages
Open this post in threaded view
|

## Simple Polygon Difference Results in Non-Simple Polygon

 When taking the difference between a /simple/ Polygon_set_2 and a /simple/ Polygon_2, the result may be non-simple. This appears to occur when one would expect the difference to result in two polygons with holes that share a point. I use the following definitions: - A Polygon_set_2 is simple if the Polygon_with_holes_2s composing it are simple. - A Polygon_with_holes_2 is simple if its outer boundary and holes are simple. Here's a minimum working example:         CGAL::Polygon_2 poly1;         poly1.push_back(CGAL::Point_2(0, 0));         poly1.push_back(CGAL::Point_2(2, 0));         poly1.push_back(CGAL::Point_2(2, 1));         poly1.push_back(CGAL::Point_2(1, 1));         poly1.push_back(CGAL::Point_2(1, 2));         poly1.push_back(CGAL::Point_2(0, 2));         CGAL::Polygon_set_2 poly_set(poly1);         CGAL::Polygon_2 hole;         hole.push_back(CGAL::Point_2(0, 0));         hole.push_back(CGAL::Point_2(1, 0));         hole.push_back(CGAL::Point_2(1, 1));         hole.push_back(CGAL::Point_2(0, 1));         poly_set.difference(hole); Note: I have only tested with the EPEC Kernel. The above code results in poly_set containing the following polygon: (0, 1), (1, 1), (1, 0), (2, 0), (2, 1), (1, 1), (1, 2), (0, 2) I would expect it to contain the following polygons: (1, 0), (2, 0), (2, 1), (1, 1)         and (0, 1), (1, 1), (1, 2), (0, 2) -- 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
Open this post in threaded view
|

## Re: Simple Polygon Difference Results in Non-Simple Polygon

 I haven't tested it myself, but if you meant to say:The above code results in poly_set containing a polygon with holes with the following outer boundary: (0, 1), (1, 1), (1, 0), (2, 0), (2, 1), (1, 1), (1, 2), (0, 2)Then there is no problem, cause according to the rules the boundary is a relatively simple polygon; see https://doc.cgal.org/latest/Boolean_set_operations_2/index.html   ____  _        ____             _  /_____/_) o    /__________  __  // (____ (   (    (    (_/ (_/-(-'_(/                         _/On Wed, 20 Feb 2019 at 06:17, Bryant <[hidden email]> wrote:When taking the difference between a /simple/ Polygon_set_2 and a /simple/ Polygon_2, the result may be non-simple. This appears to occur when one would expect the difference to result in two polygons with holes that share a point. I use the following definitions: - A Polygon_set_2 is simple if the Polygon_with_holes_2s composing it are simple. - A Polygon_with_holes_2 is simple if its outer boundary and holes are simple. Here's a minimum working example:         CGAL::Polygon_2 poly1;         poly1.push_back(CGAL::Point_2(0, 0));         poly1.push_back(CGAL::Point_2(2, 0));         poly1.push_back(CGAL::Point_2(2, 1));         poly1.push_back(CGAL::Point_2(1, 1));         poly1.push_back(CGAL::Point_2(1, 2));         poly1.push_back(CGAL::Point_2(0, 2));         CGAL::Polygon_set_2 poly_set(poly1);         CGAL::Polygon_2 hole;         hole.push_back(CGAL::Point_2(0, 0));         hole.push_back(CGAL::Point_2(1, 0));         hole.push_back(CGAL::Point_2(1, 1));         hole.push_back(CGAL::Point_2(0, 1));         poly_set.difference(hole); Note: I have only tested with the EPEC Kernel. The above code results in poly_set containing the following polygon: (0, 1), (1, 1), (1, 0), (2, 0), (2, 1), (1, 1), (1, 2), (0, 2) I would expect it to contain the following polygons: (1, 0), (2, 0), (2, 1), (1, 1)         and (0, 1), (1, 1), (1, 2), (0, 2) -- 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