add healing to open top polys if ends are close. update support union call

This commit is contained in:
Stewart Allen 2020-11-23 10:52:20 -05:00
commit 6470be92ca
2 changed files with 7 additions and 2 deletions

View file

@ -688,8 +688,8 @@
}
}
// undo temp del/used marks
for (let i=0; i<stack.length; i++) stack[i].del = false;
// stack.forEach(function(p) { p.del = false });
}
// emit a polygon if it can be cleaned and still have 2 or more points

View file

@ -388,6 +388,11 @@
last = top_poly.clone(true);
top.shells = last;
} else {
// heal top open polygons if the ends are close (benchy tilt test)
top_poly.forEach(p => { if (p.open) {
let dist = p.first().distTo2D(p.last());
if (dist < 1) p.open = false;
} });
if (opt.thin) {
top.thin_fill = [];
let oso = {z, count, gaps: [], outs: [], minArea: 0.05};
@ -963,7 +968,7 @@
if (!supports) return;
// union supports
supports = POLY.union(supports);
supports = POLY.union(supports, undefined, true);
// trim to clip offsets
if (slice.offsets) POLY.subtract(supports, slice.offsets, nsB, null, slice.z, min);