[Boost-bugs] [Boost C++ Libraries] #10658: sym_difference yields bad result for int polygons

Subject: [Boost-bugs] [Boost C++ Libraries] #10658: sym_difference yields bad result for int polygons
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-10-15 15:28:23


#10658: sym_difference yields bad result for int polygons
-------------------------------------------------+-------------------------
 Reporter: Volker Schöch <vschoech@…> | Owner:
     Type: Bugs | barendgehrels
Milestone: To Be Determined | Status: new
  Version: Boost 1.56.0 | Component: geometry
 Keywords: sym_difference, polygon, large | Severity: Regression
  numbers, domain of definition, integer |
-------------------------------------------------+-------------------------
 My "_TPolygon" type is actually a '''multi-polygon''', based on a polygon
 type that is oriented '''counter-clockwise''' and '''open''' (not closed).
 Please consider the following example, which apparently works fine:
 {{{
 _TPolygon<double> polygonA; // _TPolygon<...> is actually a MULTIPOLYGON,
 with polygons oriented COUNTER-CLOCKWISE and OPEN (not closed).
 boost::geometry::read_wkt("MULTIPOLYGON(((516 1608,1308 1932,2094
 2466,2094 32767,516 32767,516 1608)))", polygonA); // does not throw
 boost::geometry::correct(polygonA); // read_wkt(...) does not deal
 correctly with closing point

 _TPolygon<double> polygonB;
 boost::geometry::read_wkt("MULTIPOLYGON(((516 2484,1308 3066,2094
 3150,2094 32767,516 32767,516 2484)))", polygonB); // does not throw
 boost::geometry::correct(polygonB); // read_wkt(...) does not deal
 correctly with closing point

 _TPolygon<double> polygonC;
 boost::geometry::sym_difference(polygonA, polygonB, polygonC); // does not
 throw
 // polygonC is now "MULTIPOLYGON(((516 2484,516 1608,1308 1932,2094
 2466,2094 3150,1308 3066,516 2484)))"
 }}}

 Now, simply replace '''double''' by '''int''':
 {{{
 _TPolygon<int> polygonA; // _TPolygon<...> is actually a MULTIPOLYGON,
 with polygons oriented COUNTER-CLOCKWISE and OPEN (not closed).
 boost::geometry::read_wkt("MULTIPOLYGON(((516 1608,1308 1932,2094
 2466,2094 32767,516 32767,516 1608)))", polygonA); // does not throw
 boost::geometry::correct(polygonA); // read_wkt(...) does not deal
 correctly with closing point

 _TPolygon<int> polygonB;
 boost::geometry::read_wkt("MULTIPOLYGON(((516 2484,1308 3066,2094
 3150,2094 32767,516 32767,516 2484)))", polygonB); // does not throw
 boost::geometry::correct(polygonB); // read_wkt(...) does not deal
 correctly with closing point

 _TPolygon<int> polygonC;
 boost::geometry::sym_difference(polygonA, polygonB, polygonC); // does not
 throw
 // polygonC is now "MULTIPOLYGON(((516 2484,516 1608,1308 1932,2094
 2466,2094 *!*32725*!*,1308 3066,516 2484)))"
 }}}

 As you can see, one value is completely off. This seems to happen reliably
 whenever the input is based on int and contains large numbers. However,
 the particular example '''worked well with boost 1.55.0'''.

 This issue may be related to Ticket #8380.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/10658>
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:17 UTC