Opened 10 years ago
Closed 9 years ago
#6958 closed Bugs (fixed)
boost::geometry::intersection on two polygons creates self-intersecting polygon
| Reported by: | anonymous | Owned by: | Barend Gehrels |
|---|---|---|---|
| Milestone: | Boost 1.55.0 | Component: | geometry |
| Version: | Boost Development Trunk | Severity: | Problem |
| Keywords: | Cc: | snubdodecahedron@… |
Description
This program intersects two non-self-intersecting polygons and receives a self-intersecting polygon as output. The expected result was a polygon that does not intersect itself. I tested this on SVN revision 78784, and it failed with:
A B terminate called after throwing an instance of 'boost::geometry::overlay_invalid_input_exception'
what(): Boost.Geometry Overlay invalid input exception
Aborted
Thanks! Craig
#include <cstdio>
#include <vector>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/geometries/register/point.hpp>
#include <boost/geometry/geometries/register/ring.hpp>
#include <boost/geometry/io/wkt/wkt.hpp>
#include <boost/geometry/multi/geometries/multi_polygon.hpp>
typedef boost::geometry::model::d2::point_xy<double> pt;
typedef boost::geometry::model::polygon<pt> polygon;
typedef boost::geometry::model::multi_polygon<polygon> multi_polygon;
int main()
{
polygon green, blue;
multi_polygon output;
boost::geometry::read_wkt(
"POLYGON((0.63872330997599124913 0.25963790394761232516 ,"
" 0.51901482278481125832 0.36860892060212790966 ,"
" 0.24443514109589159489 0.62663296470418572426 ,"
" 0.41175117865081167778 0.47178476291601745274 ,"
" 0.63872330997599124913 0.25963790394761232516))", green);
boost::geometry::read_wkt(
"POLYGON((0.52364358028948876367 0.36823021165656988352 ,"
" 0.7762673462275415659 0.13443113025277850237 ,"
" 0.59446187055393329146 0.29992923303868185281 ,"
" 0.52364358028948876367 0.36823021165656988352))",blue);
boost::geometry::correct(green);
boost::geometry::correct(blue);
boost::geometry::detail::overlay::has_self_intersections(green);
boost::geometry::detail::overlay::has_self_intersections(blue);
printf("A\n");
boost::geometry::intersection(green,blue,output);
printf("B\n");
boost::geometry::detail::overlay::has_self_intersections(output);
printf("C\n");
return 0;
}
Change History (7)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
| Cc: | added |
|---|
comment:3 by , 10 years ago
| Summary: | boost::geometry::intersection on two triangles creates self-intersecting polygon → boost::geometry::intersection on two polygons creates self-intersecting polygon |
|---|
comment:4 by , 10 years ago
Thanks for the report - I can reproduce your problem but it is not yet fixed
comment:5 by , 10 years ago
| Milestone: | To Be Determined → Boost 1.51.0 |
|---|---|
| Status: | new → assigned |
comment:7 by , 9 years ago
| Milestone: | Boost 1.51.0 → Boost 1.55.0 |
|---|---|
| Resolution: | → fixed |
| Status: | assigned → closed |
Fixed in commit 85451, was caused by a generated spike. I will add a unit-test-case for this issue to avoid future regressions. It will be released in Boost 1.55

Try to claim my bug report so I get correspondence.