diff --git a/src/kiri/print.js b/src/kiri/print.js index a10ac733..86056a1a 100644 --- a/src/kiri/print.js +++ b/src/kiri/print.js @@ -568,9 +568,6 @@ if (slice.index < 0) { return false; } - if (opt.danger) { - return retractRequired(p1, p2); - } let int = false; slice.topPolysFlat().forEach(function(poly) { if (!int) poly.forEachSegment(function(s1, s2) { @@ -579,12 +576,16 @@ } }); }); + // if intersecting, look for a route around + if (int && opt.danger) { + return !routeAround(p1, p2); + } return int; } // returns true if no path around and retract required // returns false if routed around or no retract - function retractRequired(p1, p2) { + function routeAround(p1, p2) { const dbug = false; if (dbug === slice.index) console.log(slice.index, {p1, p2, d: p1.distTo2D(p2)}); @@ -632,6 +633,7 @@ return true; } // mark invalid intersect pairs (low or zero dist, etc) + // TODO: only if this is the outer pair and there are closer inner pairs if (i1.ip.distTo2D(i2.ip) < retractDist) { if (dbug === slice.index) console.log(slice.index, {int_dist_too_small: i1.ip.distTo2D(i2.ip), retractDist}); ints[i] = undefined; diff --git a/src/kiri/slice.js b/src/kiri/slice.js index 6419e787..2e2ef02c 100644 --- a/src/kiri/slice.js +++ b/src/kiri/slice.js @@ -111,7 +111,7 @@ if (this.topFlatPolys) { return this.topFlatPolys; } - return this.topFlatPolys = POLY.flatten(this.topPolys()).clone(true); + return this.topFlatPolys = POLY.flatten(this.topPolys().clone(true), [], true); }; // FDM retract path routing using first shell @@ -119,7 +119,8 @@ if (this.topFlatRoutes) { return this.topFlatRoutes; } - return this.topFlatRoutes = POLY.flatten(this.tops.map(top => top.shells[0]).clone(true), [], true); + let topShells0 = this.tops.map(top => top.shells[0]).filter(p => p); + return this.topFlatRoutes = POLY.flatten(topShells0.clone(true), [], true); } // CAM only diff --git a/src/mode/fdm/slice.js b/src/mode/fdm/slice.js index 6eed5231..22b2a426 100644 --- a/src/mode/fdm/slice.js +++ b/src/mode/fdm/slice.js @@ -534,7 +534,7 @@ .setLayer("gaps", COLOR.gaps) .addPolys(top.gaps, vopt({ offset, height, thin: true })); - if (isThin && devel) { + if (isThin && devel && top.fill_off && top.fill_off.length) { slice.output() .setLayer('fill inset', { face: 0, line: 0xaaaaaa, check: 0xaaaaaa }) .addPolys(top.fill_off);