[Boost-bugs] [Boost C++ Libraries] #13072: boost::geometry::intersection different results for CCW and CW

Subject: [Boost-bugs] [Boost C++ Libraries] #13072: boost::geometry::intersection different results for CCW and CW
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-06-14 10:57:24


#13072: boost::geometry::intersection different results for CCW and CW
------------------------------+---------------------------
 Reporter: kle@… | Owner: barendgehrels
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: geometry
  Version: Boost 1.64.0 | Severity: Problem
 Keywords: |
------------------------------+---------------------------
 Hello,[[BR]]

 when calculating the intersection between these two polygons the results
 differ dependent on the orientation (CW vs CCW).

 {{{

 #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>,
 true, false > boost_polygon_CW_Open;
   typedef
 boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double>,
 false, false > boost_polygon_CCW_Open;

   const std::string strPoly1( "POLYGON((986.53314901320903
 603.61376367962623, 1014.6804499149767 602.74037774442763,
 1018.1411735073581 623.97665453539310, 990.14493850604447
 624.49725628790509))" );
   const std::string strPoly2( "POLYGON((986.77183669558929
 603.60635741124452, 998.79457181965154 603.23330253835934,
 1002.2613711877982 623.79581100129735, 990.30090761267468
 624.02156931285253))" );

   boost_polygon_CW_Open p1_cw_open, p2_cw_open;
   boost::geometry::read_wkt(strPoly1, p1_cw_open);
   boost::geometry::read_wkt(strPoly2, p2_cw_open);
   boost::geometry::correct(p1_cw_open); // reverts order of points
   boost::geometry::correct(p2_cw_open); // reverts order of points

   std::vector<boost_polygon_CW_Open> output_cw;
   boost::geometry::intersection(p1_cw_open, p2_cw_open, output_cw); //
 correct: output_cw.front equals poly2

   boost_polygon_CCW_Open p1_ccw_open, p2_ccw_open;
   boost::geometry::read_wkt(strPoly1, p1_ccw_open);
   boost::geometry::read_wkt(strPoly2, p2_ccw_open);
   boost::geometry::correct(p1_ccw_open); // no modification
   boost::geometry::correct(p2_ccw_open); // no modification

   std::vector<boost_polygon_CCW_Open> output_ccw;
   boost::geometry::intersection(p1_ccw_open, p2_ccw_open, output_ccw); //
 incorrect: output_cw is empty!!!

   return 0;
 }
 }}}

--
Ticket URL: <https://svn.boost.org/trac10/boost/ticket/13072>
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-14 11:01:24 UTC