Cutline Holes / mono Polygon in Clipper2 #759
-
Hi dear Clippers, first, thank you Angus Johnson for providing this great Code, it truly helps out a ton! second, i tried searching this question in issues and discussions but it apears that i am unlucky. Should there be one, please point me to it. Is there a way for me to get a "mono Polygon" ?
I have found this on the Stack Sofar i have looked long into the documentation and couldnt find anything, the only thing that came close was EndType.Butt but this isnt an option for clipping. But the planed usecase is to have an unknown amount of holes. (here is one with 9) So i was wondering, is there a way for me to get this kind of result from Clipper? (if not, i will try to come up with some sort of path concatenation shenanigans, any pointers would be welcome) |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
No - you'll need to write your own keyholing code. I have done this in my personal stuff (https://github.com/philstopford/DesignLibs_GPL/). It can be quite complicated. In general, I work with floating point coordinates, so in the case of the keyholing I scale up the geometry to where scaling back down again will shrink the injected keyhole to a zero-impact edge. Having scaled up the input geometry:
Note that you may need to play a little with the approach to ensure overlap of line ends past the outer, otherwise the attempt to cut may fail. It was a fair amount of work to come up with something and you also have to be careful to note that the zero-width keyholes will disappear if you run the scaled-down solution through a clipping operation again, which means you need to defer scaling down until you are likely done with any other clipping operation, or accept repeated re-checks in case the keyholes were eliminated. |
Beta Was this translation helpful? Give feedback.
-
@philstopford thank you for the awnser. "No" |
Beta Was this translation helpful? Give feedback.
-
Well, i have a working solution. The requirements are:
About the island you mentioned, i cant rly add anything informative to that. In the current project there is no situation where island could occur. The player could force an "island" but those would turn into own polygons immidieatly. Thank you for the insights @philstopford . |
Beta Was this translation helpful? Give feedback.
No - you'll need to write your own keyholing code. I have done this in my personal stuff (https://github.com/philstopford/DesignLibs_GPL/). It can be quite complicated.
In general, I work with floating point coordinates, so in the case of the keyholing I scale up the geometry to where scaling back down again will shrink the injected keyhole to a zero-impact edge. Having scaled up the input geometry: