-
Notifications
You must be signed in to change notification settings - Fork 215
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
Incorrect results of boost::geometry::difference (using mpq_rational) #1212
Comments
Thanks for the data and for opening the issue. Could you please share a minimal piece of C++ code to reproduce the above situation? |
Sure, you can probably reproduce the problem and visualize it using the following code.
The version of Boost I currently use is 1.81.0, compiled with Visual Studio 2017. Thanks for your reply and efforts! |
You can also use the following data to generate polygon pA for simplification.
|
Thanks @lxily I can reproduce your issue. Indeed the issue seems to be combinatorial and not numerical. Also, it seems that the issue is related to the fact that pB and the hole of pA touch on a common segment. If they only touch on a common point e.g. by using the following pB
then the result seems correct. |
That's true, but I'm wondering if the difference() operations in the geometry library should support this situation/combinatorial. Actually, I can get the correct results using the CGAL. |
Yes, it should. |
Just checked it on my side (verifying some other new fixes).
Correct runs (for double - I cannot use bm in these visualizations yet) |
Hi~, under version 1.83 (same as 1.81), I seem to have encountered an operation result error of boost::geometry::difference(r1, r2, res). The following is the corresponding polygon data:
r1 = POLYGON((850000 0,1330000 320000,1350000 500000,1180000 1280000,790000 1280000,290000 1270000,220000 1190000,160000 1120000,30000 770000,20000 620000,0 110000,850000 0),(510711 675561,620711 945561,680711 735561,510711 675561),(1035911 461661,835911 421661,715911 361661,725911 381661,795911 411661,655911 501661,655911 541661,715911 591661,755911 691661,815911 821661,695911 761661,705911 781661,775911 811661,635911 901661,635911 941661,695911 991661,735911 1091661,795911 1221661,656523 1221661,526523 1241661,846523 1221661,925911 1221661,1025911 1201661,855911 1071661,735911 1031661,779571 1009831,915911 941661,1055911 971661,1065911 761661,1045911 801661,875911 671661,755911 631661,935911 541661,1075911 571661,1085911 361661,1035911 461661));
r2 = POLYGON((711861 626536,741861 656536,651861 836536,711861 626536))
Among them, polygon r1 is a polygon containing two holes, and r2 is a simple polygon, as shown in the following figure:
The operation directly caused one of the holes to disappear, as shown in the figure below:
It is worth mentioning that the coordinates of all vertices of these two polygons are integers, and I use boost::multiprecision::mpq_rational as my basic data type, so in theory, there is no calculation precision error.
The possible problem is that the polygon r2 is in touch with two holes of polygon r1 simultaneously, forming a complex polygon Boolean operation that leads to wrong results.
Could you reproduce this situation?
The text was updated successfully, but these errors were encountered: