Replies: 1 comment 2 replies
-
This is how Clipper works. Holes are represented as opposite winding order compared to the polygon in which they are enclosed (https://angusj.com/clipper2/Docs/Units/Clipper/Types/FillRule.htm). You'd need to re-keyhole the second entity. Keyholing isn't something that Clipper offers. In general terms, you can project normals from each edge of the 'hole' polygon and look for the shortest edge. Then you can offset that open path to create a cutter to chop a keyhole out. The way I do this in my stuff is to also take advantage of integer snapping. That is to say, I take my Clipper output and size it up, converting to a floating-point representation in the process (PathD), if necessary. I then do the edge projection to find the shortest cutter. I use offset to make the thinnest 'legal' cutter. I union the cutter and the hole, and then perform a Clipper difference against the outer. Finally, I scale everything back to an integer representation (Path64) and convert back to PathD after this if required. This conversion introduces the rounding that makes the keyhole zero width in the resulting output. This will have the consequence that any further Clipper operations will lose the keyhole again, but it can be easily re-computed. |
Beta Was this translation helpful? Give feedback.
-
Here's my interpretation of the translated text:
Here is my input:
First set of polygons:
20 20
30 20
30 30
20 30
20 20
NEXT
Second set of polygons:
0 0
10 0
10 10
0 10
0 8
2 8
8 8
8 2
2 2
2 8
0 8
0 0
NEXT
The result I obtained:
30, 30
20, 30
20, 20
30, 20
NEXT
10, 10
0, 10
0, 0
10, 0
NEXT
8, 8
8, 2
2, 2
2, 8
NEXT
I observed that the result separated the second set of polygons into an outer counterclockwise polygon and an inner clockwise polygon. However, this representation is different from the input. Is there a method to express the output with a hole in the polygon using a single polygon format?
Thank you very much!
Beta Was this translation helpful? Give feedback.
All reactions