Revert "simplify union to clipper wrappers"

This reverts commit f8cf66e7d5.
This commit is contained in:
Stewart Allen 2021-12-12 13:49:30 -05:00
commit 636bf653fc
2 changed files with 87 additions and 13 deletions

View file

@ -392,19 +392,31 @@
}
}
let clib = self.ClipperLib,
ctyp = clib.ClipType,
ptyp = clib.PolyType,
clip = new clib.Clipper(),
ctre = new clib.PolyTree();
let out = polys.slice(), i, j, union, uset = [];
clip.AddPaths(toClipper(polys), ptyp.ptSubject, true);
if (clip.Execute(ctyp.ctUnion, ctre)) {
return fromClipperTree(ctre, polys[0].getZ());
} else {
return [];
outer: for (i=0; i<out.length; i++) {
if (!out[i]) continue;
for (j=i+1; j<out.length; j++) {
if (!out[j]) continue;
union = out[i].union(out[j], minarea, all);
if (union) {
out[i] = null;
out[j] = null;
if (all) {
out.appendAll(union);
} else {
out.push(union);
}
continue outer;
}
}
}
for (i=0; i<out.length; i++) {
if (out[i]) uset.push(out[i]);
}
return uset;
}
/**