[Boost-bugs] [Boost C++ Libraries] #13096: boost::geometry::intersection results depend on polypoints inputorder

Subject: [Boost-bugs] [Boost C++ Libraries] #13096: boost::geometry::intersection results depend on polypoints inputorder
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-06-26 11:59:02


#13096: boost::geometry::intersection results depend on polypoints inputorder
------------------------------+---------------------------
 Reporter: kle@… | Owner: barendgehrels
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: geometry
  Version: Boost 1.64.0 | Severity: Problem
 Keywords: intersection |
------------------------------+---------------------------
 Hello,

 when calculating the intersection of the givin polygons, the result
 depends on the order of the inputpoints.

 {{{

 #include <boost/geometry/geometry.hpp>
 #include <boost/geometry/geometries/polygon.hpp>
 #include <boost/geometry/geometries/point_xy.hpp>

 int main(int argc, char* argv[])
 {
   typedef
 boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double>>
 boost_polygon;

   boost_polygon RedPoly, GreenPoly, RedPolyReverted, GreenPolyReverted;
   boost::geometry::read_wkt("POLYGON((864.11024748062812
 524.94908797221251, 881.01048034069004 524.77831898197212,
 877.68802698783907 501.82023487475703, 860.75736496460991
 501.99865072086430, 864.11024748062812 524.94908797221251))", RedPoly);
   boost::geometry::read_wkt("POLYGON((864.62221751510151
 524.94391475320754, 868.20628459909278 524.90769942280622,
 864.93694798456659 502.47800172931238, 861.34657616182551
 502.51580174027310, 864.62221751510151 524.94391475320754))", GreenPoly);
   boost::geometry::read_wkt("POLYGON((860.75736496460991
 501.99865072086430, 877.68802698783907 501.82023487475703,
 881.01048034069004 524.77831898197212, 864.11024748062812
 524.94908797221251, 860.75736496460991 501.99865072086430))",
 RedPolyReverted);
   boost::geometry::read_wkt("POLYGON((861.34657616182551
 502.51580174027310, 864.93694798456659 502.47800172931238,
 868.20628459909278 524.90769942280622, 864.62221751510151
 524.94391475320754, 861.34657616182551 502.51580174027310))",
 GreenPolyReverted);

   boost::geometry::correct(RedPoly);
   boost::geometry::correct(GreenPoly);
   boost::geometry::correct(RedPolyReverted); // reverts order of points
 and is now equal it RedPoly
   boost::geometry::correct(GreenPolyReverted); // reverts order of points
 and is now equal it GreenPoly

   std::list<boost_polygon> output;
   boost::geometry::intersection(RedPoly, GreenPoly, output); // error:
 output is empty

   std::list<boost_polygon> outputReverted;
   boost::geometry::intersection(RedPolyReverted, GreenPolyReverted,
 outputReverted); // correct: outputReverted.front equals GreenPoly

   return 0;
 }
 }}}

--
Ticket URL: <https://svn.boost.org/trac10/boost/ticket/13096>
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-06-26 12:02:20 UTC