You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of, thank you for providing us with such a great library @AngusJohnson!
EDIT: Doing some more tests with another port of Clipper2 library showed that the problem described below is probably in our code.
Here is another thread with equal name, but different problem.
Now to the question: we are getting buggy behavior when on polygon with hole, that should contain 2 new polygons added with Union operation. I am not sure if the problem is in our code (we are using Clipper with Ruby), or it is actually a Clipper bug (using the same Ruby code with Clipper 1 works as expected, see below). Here is the sketch:
Polygon 1 is the subject polygon that contains hole, polygons 2 and 3 are clip polygons. The result we get when performing union is this:
This is our test code:
# POLYGON 1outer_1=[[0,0],[10,0],[10,10],[0,10]]# note reversed orderinner_1=[[1,1],[1,9],[9,9],[9,1]]polygon_1=[outer_1,inner_1]# POLYGON 2 (inside polygon 1)polygon_2=[[4,4],[6,4],[6,6],[4,6]]# POLYGON 3 (outside polygon 1)polygon_3=[[11,11],[12,11],[12,12],[11,12]]# Initialize new Clipper objectc=Clipper.new# add subject POLYGON 1 (the one with the hole)c.add_subject_polygons(polygon_1)# add clip polygons POLYGON 2, POLYGON 3c.add_clip_polygons([polygon_2,polygon_3])# print union resultputsc.union(:even_odd,:even_odd,POLYTREE).inspect# Clipper 1[[# polygon 1 with hole[[10.0,10.0],[0.0,10.0],[0.0,0.0],[10.0,0.0]],[[1.0,1.0],[1.0,9.0],[9.0,9.0],[9.0,1.0]]],[# polygon 2[[6.0,6.0],[4.0,6.0],[4.0,4.0],[6.0,4.0]]],[# polygon 3[[12.0,12.0],[11.0,12.0],[11.0,11.0],[12.0,11.0]]],]# Clipper 2[[# polygon 1 with hole[[10.0,10.0],[0.0,10.0],[0.0,0.0],[10.0,0.0]],[[1.0,1.0],[1.0,9.0],[9.0,9.0],[9.0,1.0]]],[# polygon 3[[12.0,12.0],[11.0,12.0],[11.0,11.0],[12.0,11.0]]],]
As you can see above, the POLYGON 2 is missing when calling Union on Clipper2. We are using Polytree as a solution. If we use Paths solution, all the polygons are there, but unordered (which means we would first need to find the holes, and then also find out to which polygon the hole corresponds to... not a good option.
Can somebody please check if this error can be reproduced using pure Clipper2 or some other well tested binding to it? Is it a bug, or are we not getting it right?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
First of, thank you for providing us with such a great library @AngusJohnson!
EDIT: Doing some more tests with another port of Clipper2 library showed that the problem described below is probably in our code.
Here is another thread with equal name, but different problem.
Now to the question: we are getting buggy behavior when on polygon with hole, that should contain 2 new polygons added with Union operation. I am not sure if the problem is in our code (we are using Clipper with Ruby), or it is actually a Clipper bug (using the same Ruby code with Clipper 1 works as expected, see below). Here is the sketch:
Polygon 1 is the subject polygon that contains hole, polygons 2 and 3 are clip polygons. The result we get when performing union is this:
This is our test code:
As you can see above, the POLYGON 2 is missing when calling Union on Clipper2. We are using Polytree as a solution. If we use Paths solution, all the polygons are there, but unordered (which means we would first need to find the holes, and then also find out to which polygon the hole corresponds to... not a good option.
Can somebody please check if this error can be reproduced using pure Clipper2 or some other well tested binding to it? Is it a bug, or are we not getting it right?
Thanks in advance,
Jernej
Beta Was this translation helpful? Give feedback.
All reactions