Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boost::geometry::intersection produces wrong result #510

Open
olologin opened this issue Sep 21, 2018 · 2 comments
Open

boost::geometry::intersection produces wrong result #510

olologin opened this issue Sep 21, 2018 · 2 comments

Comments

@olologin
Copy link

olologin commented Sep 21, 2018

Hi everyone. I've just noticed unit test which produced correct result on boost 1.55, but it fails on 1.67
Is that known? No matter if clippingRegion is defined in CW or CCW direction, it always gives me 2 lines as a result of intersection. But with the same input old boost gave me 1 (but very small) correct subsegment as a result.

Could you please help with that?

#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/multi/geometries/multi_polygon.hpp>
using namespace boost::geometry::model;
using namespace boost::geometry;

typedef d2::point_xy<double>				BoostPoint;
typedef polygon<BoostPoint >				BoostPolygon;
typedef linestring<BoostPoint>				BoostPolyline;

int main(void)
{
	BoostPolyline polyToClip;
	std::vector<BoostPolyline> clippingResult;

	polyToClip.push_back(BoostPoint(-7.7866132709658586e-005, 6.0810736257569502));
	polyToClip.push_back(BoostPoint(-7.7866132709658586e-005, -6.0811651098339610));


	multi_polygon<BoostPolygon> clippingRegion;
	BoostPolygon curPolygon;
	append(curPolygon, BoostPoint(0.084821928797522289, 1.9999244955432876));
	append(curPolygon, BoostPoint(1.8813618198054716e-016, 2.0001895226089994));
	append(curPolygon, BoostPoint(-7.7866133709978802e-005, 1.9997988605928652));
	append(curPolygon, BoostPoint(0.00000000000000000, 1.9994081985767305));
	append(curPolygon, BoostPoint(0.00000000000000000, -2.0001895226089998));
	append(curPolygon, BoostPoint(0.084821928797522289, 1.9999244955432876));
	clippingRegion.push_back(curPolygon);
	reverse(clippingRegion);

	intersection(clippingRegion, polyToClip, clippingResult);
	return 0;
}

Here you can see how polyToClip (red and pink) gets separated by point 2 of clippingRegion (green). But even If I change direction of clippingRegion - it still produces the same result.

image

@olologin
Copy link
Author

Same result is produced by boost::geometry::intersection from 1.68

@DaveBy
Copy link

DaveBy commented Oct 9, 2018

I also have wrong intersection result. Polygons: "MULTIPOLYGON( ( (-2 -2,-2 2,2 2,2 -2) ) )" and "MULTIPOLYGON( ( (-20 -1,-2 1,2 2,2 -1) ) )". boost version is 1.68

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants