[Boost-bugs] [Boost C++ Libraries] #11725: union_ fails to create holes

Subject: [Boost-bugs] [Boost C++ Libraries] #11725: union_ fails to create holes
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-10-14 16:06:25


#11725: union_ fails to create holes
------------------------------+-----------------------
 Reporter: jan.kleemann@… | Owner: marshall
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: algorithm
  Version: Boost 1.59.0 | Severity: Problem
 Keywords: |
------------------------------+-----------------------
 When uniting 2 polygons union_ does not create holes when it can also
 express the resulting polygon as a single ring, even if that ring has
 self-tangencies, which makes the polygon invalid.

 The following code

 {{{

 typedef double FloatType;
 typedef model::d2::point_xy<FloatType> Point;
 typedef model::polygon<Point> Polygon;
 typedef model::multi_polygon<Polygon> MultiPolygon;
 typedef model::ring<Point> Ring;
 typedef model::box<Point> Box;
 typedef model::linestring<Point> LineString;


 int main(int argc, char *argv[])
 {
    using namespace std;

    Polygon p1, p2;
    boost::geometry::read_wkt("POLYGON((0 0, 0 1, 3 1, 3 0, 0 0))", p1);
    boost::geometry::read_wkt("POLYGON((0 1, 0 3, 3 3, 3 1, 2 2, 1 2 , 1 1,
 0 1))", p2);

    boost::geometry::correct(p1);
    boost::geometry::correct(p2);

    MultiPolygon p3;
    boost::geometry::union_(p1, p2, p3);
    boost::geometry::correct(p3);

    cout << "p1: " << boost::geometry::wkt(p1) << endl;
    cout << "p2: " << boost::geometry::wkt(p2) << endl;
    cout << "p3: " << boost::geometry::wkt(p3) << endl;

    cout << "is_simple(p1): " << boost::geometry::is_simple(p1) << endl;
    cout << "is_simple(p2): " << boost::geometry::is_simple(p2) << endl;
    cout << "is_simple(p3): " << boost::geometry::is_simple(p3) << endl;
    cout << "is_valid(p1): " << boost::geometry::is_valid(p1) << endl;
    cout << "is_valid(p2): " << boost::geometry::is_valid(p2) << endl;
    cout << "is_valid(p3): " << boost::geometry::is_valid(p3) << endl;
    return 0;
 }
 }}}

 has the output
 {{{
 p1: POLYGON((0 0,0 1,3 1,3 0,0 0))
 p2: POLYGON((0 1,0 3,3 3,3 1,2 2,1 2,1 1,0 1))
 p3: MULTIPOLYGON(((0 1,0 3,3 3,3 1,2 2,1 2,1 1,3 1,3 0,0 0,0 1)))
 is_simple(p1): 1
 is_simple(p2): 1
 is_simple(p3): 1
 is_valid(p1): 1
 is_valid(p2): 1
 is_valid(p3): 0
 }}}

 but p3 should be
 {{{
 MULTIPOLYGON(((0 1,0 3,3 3,3 0,0 0,0 1),(3 1,2 2,1 2,1 1,3 1)))
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/11725>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:19 UTC