Union not joining adjacent rectangles
Boolean operations and offsetting library in Javascript
Brought to you by:
timo23414
Thank you so much for this library. However, having a couple small problems with joining multiple adjacent rectangles. If I have union'ed two adjacent rectangles, and attempt to then union a third rectangle in, in certain scenarios, it produces two solutions when I believe it should only produce one (and only produces one in the C++ version).
I attached a picture of my particular scenario (blue is ptClip, green is ptSubject).
Code is below
const sub = [{"X":-68,"Y":-75},{"X":137,"Y":-75},{"X":137,"Y":45},{"X":4,"Y":45},{"X":4,"Y":165},{"X":-140,"Y":165},{"X":-140,"Y":45},{"X":-68,"Y":45}]; const clp = [{"X":82,"Y":45},{"X":226,"Y":45},{"X":226,"Y":165},{"X":82,"Y":165}]; //get the union of the subject and clip polygons ... let initOption = 0; const clpr = new ClipperLib.Clipper(initOption); clpr.AddPath(sub, ClipperLib.PolyType.ptSubject, true); clpr.AddPath(clp, ClipperLib.PolyType.ptClip, true); const solution = new ClipperLib.Paths(); clpr.Execute(ClipperLib.ClipType.ctUnion, solution, ClipperLib.PolyFillType.pftEvenOdd, ClipperLib.PolyFillType.pftEvenOdd);
Solution has two arrays, where the two paths are still completely separate. Am I setting up clipper incorrectly?