Ticket #6958 (closed Bugs: fixed)
boost::geometry::intersection on two polygons creates self-intersecting polygon
Reported by: | anonymous | Owned by: | barendgehrels |
---|---|---|---|
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; }
Attachments
Change History
comment:3 Changed 5 years ago by Craig Schroeder <snubdodecahedron@…>
- Summary changed from boost::geometry::intersection on two triangles creates self-intersecting polygon to boost::geometry::intersection on two polygons creates self-intersecting polygon
comment:4 Changed 5 years ago by anonymous
Thanks for the report - I can reproduce your problem but it is not yet fixed
comment:5 Changed 5 years ago by barendgehrels
- Status changed from new to assigned
- Milestone changed from To Be Determined to Boost 1.51.0
comment:7 Changed 4 years ago by barendgehrels
- Status changed from assigned to closed
- Resolution set to fixed
- Milestone changed from Boost 1.51.0 to Boost 1.55.0
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.