Re: [Boost-bugs] [Boost C++ Libraries] #5103: Boost Polygon: The union of these two polygon return an empty result.

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #5103: Boost Polygon: The union of these two polygon return an empty result.
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-02-06 20:07:05


#5103: Boost Polygon: The union of these two polygon return an empty result.
-------------------------------+----------------------
  Reporter: thai@… | Owner: ljsimons
      Type: Bugs | Status: reopened
 Milestone: To Be Determined | Component: polygon
   Version: Boost 1.53.0 | Severity: Problem
Resolution: | Keywords: Bug
-------------------------------+----------------------

Comment (by z@…):

 I just want to follow up with this bug and add a simple test program (see
 below) that demonstrates that union of two polygons returns empty result.

 Please note polygon A is a 45 degree and polygon B is an arbitrary with
 near 45 degree edge. I suspect that failure of polygon union has something
 to do with union of 45 degree polygon with a abutting arbitrary polygon
 that has near 45 degree edge. I also include an alternative polygon that
 has abutting near 45 degree edge and union of them seems to work. So the
 only difference between alternative and the original polygon is
 y-coordinate value of one of vertexes that has changed from 2214626 to
 2214625.


 {{{
 #include <vector>
 #include <boost/polygon/polygon.hpp>
 using namespace boost::polygon::operators;

 #define POLYGON_45

 #ifdef POLYGON_45
 int points_A_1[] =
 { // 45 degree polygon
                -92810838,3618230,
                -94606872,1822196,
                -94999302,2214626,
                -93203268,4010660};
 int points_A_1_size =4;

 #else
 int points_A_1[] =
 { // arbitrary polygon
                -92810838,3618230,
                -94606872,1822196,
                -94999302,2214625, // 2214626 -> 2214625, near 45 degree
 edge
                -93203268,4010660};
 int points_A_1_size =4;

 #endif

 int points_B_1[] =
 {
                -94739968,1676908,
                -94606618,1822450,
                -94999048,2214880,
                -95165164,2033778};
 int points_B_1_size =4;


 int
 main(int argc, char **argv)
 {
     typedef boost::polygon::polygon_data<int> Polygon;
     typedef boost::polygon::point_data<int> Point;
     typedef boost::polygon::polygon_set_data<int> PolygonSet;

     std::vector<Point> points;

     int count = points_A_1_size;
     for (int i = 0; i < count; ++i) {
         points.push_back(boost::polygon::construct<Point>(points_A_1[2 *
 i], points_A_1[2 * i+1]));
     }

     Polygon A;
     A.set(points.begin(), points.end());


     points.clear();
     count = points_B_1_size;
     for (int i = 0; i < count; ++i) {
         points.push_back(boost::polygon::construct<Point>(points_B_1[2 *
 i], points_B_1[2 * i+1]));
     }

     Polygon B;
     B.set(points.begin(), points.end());

     PolygonSet ps1, ps2, ps3;

     ps1 += A;
     ps2 += B;
     assign(ps3, ps1 + ps2);

     std::vector<Polygon> polygons;
     ps3.get(polygons);
     return 0;
 }
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/5103#comment:3>
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:15 UTC