fix for poly.union(). needs benchmarking and verification. roll back depth first change

This commit is contained in:
Stewart Allen 2020-11-04 01:00:05 -05:00
commit 74df1f946a
3 changed files with 14 additions and 5 deletions

View file

@ -1306,6 +1306,15 @@
if (clip.Execute(ctyp.ctUnion, ctre, cfil.pftEvenOdd, cfil.pftEvenOdd)) {
let union = POLY().fromClipperTreeUnion(ctre, poly.getZ(), minarea);
if (all) {
if (union.length === 2) {
// TODO look for faster equivalence check. area? perimeter?
let src = [this, poly].sort((a,b) => { return a.area() - b.area() });
let dst = union.sort((a,b) => { return a.area() - b.area() });
if (src[0].isEquivalent(dst[0]) && src[1].isEquivalent(dst[1])) {
return null;
}
return union;
}
return union;
}
if (union.length === 1) {
@ -1313,7 +1322,7 @@
union.fillang = fillang;
return union;
} else {
console.log({check_union_call_path: union});
console.log({check_union_call_path: union, this: this, poly});
}
}

View file

@ -1064,8 +1064,8 @@
// - it has more than one sibling
// - it has no parent (top/outer most)
// - it is offset from its parent by more than diameter
// if (poly.isOpen() || !poly.parent || poly.parent.innerCount() > 1 || !polygonWithinOffset(poly, poly.parent, offset)) {
if (poly.depth === 0) {
if (poly.isOpen() || !poly.parent || poly.parent.innerCount() > 1 || !polygonWithinOffset(poly, poly.parent, offset)) {
// if (poly.depth === 0) {
pools.push(poly);
poly.pool = [];
poly.poolsDown = [];

View file

@ -673,7 +673,6 @@
let flat = POLY.flatten(offset, [], true);
offset = POLY.setZ(POLY.nest(flat), slice.z);
// slice.tops[0].inner = offset;
// inset offset array by 1/2 diameter then by tool overlap %
slice.tops[0].traces =
@ -1027,8 +1026,9 @@
data.shadow = shadow.clone(true);
data.slice.camMode = CPRO.OUTLINE;
data.slice.shadow = data.shadow;
// data.slice.tops[0].inner = shadow;
slices.push(data.slice);
onupdate(0.2 + (index/total) * 0.1, "roughing");
onupdate(0.2 + (index/total) * 0.1, "outlines");
}, genso: true });
shellOutline = tshadow;