Incorrect result from edge-case with clip type Difference
Boolean operations and offsetting library in Javascript
Brought to you by:
timo23414
Instead of getting back one ctDifference polygon, the solution is the subj and clip themselves.
Subj:
[[-437.47255605566346,-183.30866842550915, -447.69480823970554,125.6314763404805, 282.75734425657726,139.42603777258753, 280.6935968250169,40.57186335327072, -123.48183916055294,44.17981749578284, -121.90478411058025,-127.58383300720253, 276.65517714915984,-152.86975499135247, 274.67923250764426,-247.51814715802786]]
Clip:
[[168.382,-146.001, -87.455,-129.77, 167.904,-183.622]]
Thanks for contacting. Could you test, what result gives C# Clipper, from which JS Clipper is ported?
Meanwhile you can use a workaround. After ctDifference operation, apply a little negative offset to the solution, eg. -0.001. See the documentation: https://sourceforge.net/p/jsclipper/wiki/documentation/#clipperlibclipperoffsetexecute or the example: http://jsclipper.sourceforge.net/6.2.1.2/index.html?p=sources_as_text/starter_offset.txt.
I hoped for a similar demo in C# Clipper where I could just put in custom samples, but it seems to only provide random-generating shapes. Guess I have to figure out how to write a demo myself then.
The workaround did it by using offset -0.006 in this specific case, but Im not comfortable using this offset in all similar cases.
Last edit: Arve Waltin 2017-07-04
After looking some more at the main demo, it appears to me that the result actually is a polygon with hole and main demo is illustrating this correctly when clicking at solution's points cell. As the solution consists of two polygons, how does the demo know that the second subpolygon is a hole and not an ordinar polygon next to the other one?
Last edit: Arve Waltin 2017-07-04
Ok so I figured out that solution has to be converted to ExPolygons to get this information, ref https://sourceforge.net/p/jsclipper/wiki/ExPolygons%20and%20PolyTree%206/. :)