Opened 7 years ago
Last modified 6 years ago
#11576 reopened Bugs
boost::geometry::intersection wrong results
Reported by: | Owned by: | Barend Gehrels | |
---|---|---|---|
Milestone: | Boost 1.61.0 | Component: | geometry |
Version: | Boost 1.61.0 | Severity: | Problem |
Keywords: | intersection | Cc: |
Description
Here is a code of intersection of two 2d triangles. boost::geometry::intersection (inside get_poly_intersection_area_S_2d function) gives empty result. It was ok in boost 1.55.0 version.
// boost_geom.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <time.h> #include <deque> #include <boost/geometry.hpp> #include <boost/geometry/geometries/point_xy.hpp> #include <boost/geometry/geometries/polygon.hpp> #include <boost/foreach.hpp> bool get_poly_intersection_area_S_2d( const double *poly_x_1, const int poly_n_1, const double *poly_x_2, const int poly_n_2, double *S) { // intersects two 2d polygons using boost::geometry library // polygons are in 3d format [(x0, y0, 0.0) (x1, y1, 0.0) .... (xn, yn, 0.0) ] // S is resulting area of intersection // returns true if intersection exists (area > DBL_EPSILON) and false otherwise typedef boost::geometry::model::d2::point_xy<double> bg_point; typedef boost::geometry::model::polygon< bg_point, false, false > bg_polygon; *S = 0.0; bg_polygon bg_poly_1, bg_poly_2; // init boost 2d polygons by our double 3D polygons for(int i=0; i<poly_n_1; i++) bg_poly_1.outer().push_back(bg_point(poly_x_1[i*3], poly_x_1[i*3+1])); for(int i=0; i<poly_n_2; i++) bg_poly_2.outer().push_back(bg_point(poly_x_2[i*3], poly_x_2[i*3+1])); // correct polygons boost::geometry::correct(bg_poly_1); boost::geometry::correct(bg_poly_2); // call intersection std::deque<bg_polygon> output; bool res = boost::geometry::intersection(bg_poly_1, bg_poly_2, output); if(!res) return false; // for each polygon of intersection we add area BOOST_FOREACH(bg_polygon const& p, output) { double s = boost::geometry::area(p); *S += s; } // no intersection if(fabs(*S) <= DBL_EPSILON) return false; // intersection > DBL_EPSILON return true; } int _tmain(int argc, _TCHAR* argv[]) { /*double p1[3 * 3] = {0.00000000000000000, -0.00000000000000000, 0.00000000000000000, 0.0025482760575599476, 0.00000000000000000, 0.00000000000000000, 0.00053468140165232941, 0.0010376086029810613, 0.00000000000000000}; double p2[4 * 3] = {0.0030662413355881501, 0.0010051691098038377, 0.00000000000000000, 0.0019811507896907981, -0.0011005695262458440, 0.00000000000000000, -3.2443866216813556e-005, -6.2960923264770714e-005, 0.00000000000000000, 0.0010526466796805442, 0.0020427777127849226, 0.00000000000000000};*/ double p1[3 * 3]={ -0.00000000000000000 , 0.00000000000000000 , 0.00000000000000000 , 0.0030892383152813277, 0.00000000000000000 , 0.00000000000000000 , 0.0017033357506405240, 0.0015364430953530355, 0.00000000000000000 }; double p2[3 * 3] = { 0.0023117731015916947, 0.00082400923980274917, 0.00000000000000000, 0.00079878052059454633, 0.00072051609032968962, 0.00000000000000000, 0.0016845031281539609, 0.0015194556912103366, 0.00000000000000000 }; double s = 0; get_poly_intersection_area_S_2d(p1, 3, p2, 3, &s); return 0; }
Change History (2)
comment:1 by , 7 years ago
Milestone: | To Be Determined → Boost 1.61.0 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
comment:2 by , 6 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Version: | Boost 1.59.0 → Boost 1.61.0 |
Not fixed in 1.61.0. Still empty result of intersection.
Note:
See TracTickets
for help on using tickets.
Fixed in 1.61, thanks for the report