Thanks a lot for this great library I've noticed some problems when using union, in particular on polygons with holes. I was able to repro on Demo:
Custom poly line:
[[100,100, 200,100, 170,150, 100,40, 120,40, 190,150]]
Offsetting: OpenRound, PolyType: Subject, Join: Round, Delta: 4.000
And compare Clip type: No versus Clip type: Union
Desired behavior: we're just unioning the polygon (produced by offsetting a line) with itself so it shouldn't change.
On the other hand I can't reproduce it in the c# version of the library:
If I replace contents of GenerateRandomPolygon with
(crude, I know)
It doesn't do anything strange when choosing union.
Thanks for reporting. Did you test the library itself? The demo is a bit complicated when using open paths (if I remember right, it doesn't support them or if supports you cannot change the order of operations boolean/offset). The JS libary itself supports open paths. You can try using as a base eg. http://jsclipper.sourceforge.net/6.4.2.2/index.html?p=open_closed.html (code: http://jsclipper.sourceforge.net/6.4.2.2/index.html?p=sources_as_text/open_closed.txt) or even simpler http://jsclipper.sourceforge.net/6.4.2.2/index.html?p=starter_offset.html (code: http://jsclipper.sourceforge.net/6.4.2.2/index.html?p=sources_as_text/starter_offset.txt).
Hi Timo, thanks for responding so quickly. You're right it's something weird in the demo. However, I'm still facing the issue in my actual code. I've tried to simplify the paths. To reproduce, copy this in to starter_offset.html:
or this for the c# library
they both produce the same (so there is no bug in your library), but I don't like the output. I have two lines, produce 2 polygons that are line offset of these lines and union them. I expect to get one polygon in return without any holes. But for some reason the area where they overlap is returned as a second (hole) polygon.
Can you help me understand what am I doing wrong?
I've found the problem. Even though the documentation says
you really need both subject and clip sets. So, the fix was to add the second polygon as ptClip and then the union works correctly