improve efficiency of wasm poly diff

This commit is contained in:
Stewart Allen 2021-06-23 11:13:45 -04:00
commit 14ee94311d
5 changed files with 60 additions and 54 deletions

View file

@ -309,45 +309,40 @@
return to;
}
// expensive but worth it?
clip.StrictlySimple = true;
const JS = true;
if (outA) {
if (JS) {
if (JS) {
// expensive but worth it?
clip.StrictlySimple = true;
if (outA) {
clip.AddPaths(sp1, ptyp.ptSubject, true);
clip.AddPaths(sp2, ptyp.ptClip, true);
if (clip.Execute(ctyp.ctDifference, ctre, cfil.pftEvenOdd, cfil.pftEvenOdd)) {
cleanClipperTree(ctre);
filter(fromClipperTree(ctre, z, null, null, min), outA);
}
} else {
let woutA = filter(geo.poly.diff(setA, setB, z));
outA.appendAll(woutA);
// console.log({outA, woutA});
}
}
if (outB) {
if (outA) {
ctre.Clear();
clip.Clear();
}
if (JS) {
if (outB) {
if (outA) {
ctre.Clear();
clip.Clear();
}
clip.AddPaths(sp2, ptyp.ptSubject, true);
clip.AddPaths(sp1, ptyp.ptClip, true);
if (clip.Execute(ctyp.ctDifference, ctre, cfil.pftEvenOdd, cfil.pftEvenOdd)) {
cleanClipperTree(ctre);
filter(fromClipperTree(ctre, z, null, null, min), outB);
}
} else {
let woutB = filter(geo.poly.diff(setB, setA, z));
outB.appendAll(woutB);
// console.log({outB, woutB});
}
} else {
let oA = outA ? [] : undefined;
let oB = outB ? [] : undefined;
geo.wasm.js.diff(setA, setB, z, oA, oB);
if (oA) {
outA.appendAll(filter(oA));
}
if (oB) {
outB.appendAll(filter(oB));
}
}