Boost logo

Geometry :

Subject: Re: [geometry] Accuray issue with geometry::difference() in version Boost 1.57
From: Mikkel B. Stegmann (mikkel.stegmann_at_[hidden])
Date: 2015-04-17 04:47:00


Hi Menalaos,

somehow the results and code (including input data) got stripped in the
mail-version of my post. Here it is without raw-tags:

Result using Boost v1.55:

         249.232 761.09
         249.232 760.98
          265.89 760.98
          265.89 729.219
          94.021 729.219
          94.021 761.09
         249.232 761.09

Result using Boost v1.57:

249.232003466816 761.09
         249.232 760.98
          265.89 760.979984987659
          265.89 729.219
          94.021 729.219
          94.021 761.09
249.232003466816 761.09

----
#include <boost/foreach.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry.hpp>
#include <cstdio>
#include <assert.h>
int main() {
  // 2D point with double precision
  typedef boost::geometry::model::d2::point_xy<double> BoostPoint;
  // 2D polygon, ring type: clockwise, closed ("the first point must be
spatially equal to the last point")
  typedef boost::geometry::model::polygon<BoostPoint> BoostPolygon;
  BoostPolygon rectangleA;
  rectangleA.outer().push_back(BoostPoint( 94.021, 729.219)); // clock-wise
points
  rectangleA.outer().push_back(BoostPoint( 94.021, 761.090));
  rectangleA.outer().push_back(BoostPoint(265.890, 761.090));
  rectangleA.outer().push_back(BoostPoint(265.890, 729.219));
  rectangleA.outer().push_back(BoostPoint( 94.021, 729.219)); // close
  BoostPolygon rectangleB;
  rectangleB.outer().push_back(BoostPoint(249.232, 760.980)); // clock-wise
points
  rectangleB.outer().push_back(BoostPoint(249.232, 780.980));
  rectangleB.outer().push_back(BoostPoint(319.232, 780.980));
  rectangleB.outer().push_back(BoostPoint(319.232, 760.980));
  rectangleB.outer().push_back(BoostPoint(249.232, 760.980)); // close
  std::list<BoostPolygon> differencePolygons;
  boost::geometry::difference(rectangleA, rectangleB, differencePolygons);
  assert(differencePolygons.size()==1);
  BOOST_FOREACH(const BoostPoint &point, differencePolygons.front().outer())
{
    printf("%16.15g %16.15g\n", point.x(), point.y());
  }
  return 0;
}
--
View this message in context: http://boost-geometry.203548.n3.nabble.com/Accuray-issue-with-geometry-difference-in-version-Boost-1-57-tp4026545p4026547.html
Sent from the Boost Geometry mailing list archive at Nabble.com.

Geometry list run by mateusz at loskot.net