From bdc7f5ac40a3bcb8653e801eb1cf50f617f087a7 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Thu, 4 Mar 2021 19:35:27 -0500 Subject: [PATCH] fix premature solid optimization --- src/mode/fdm/slice.js | 55 ++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/src/mode/fdm/slice.js b/src/mode/fdm/slice.js index b41e59e2..ef96d4d0 100644 --- a/src/mode/fdm/slice.js +++ b/src/mode/fdm/slice.js @@ -26,7 +26,8 @@ }, PROTO = Object.clone(COLOR), bwcomp = (1 / Math.cos(Math.PI/4)), - getRangeParameters = FDM.getRangeParameters; + getRangeParameters = FDM.getRangeParameters, + debug = false; let isThin = false; // force line rendering let isFlat = false; // force flat rendering @@ -477,13 +478,13 @@ .setLayer("gaps", COLOR.gaps) .addPolys(top.gaps, vopt({ offset, height, thin: true })); - // if (isThin && debug) { - // slice.output() - // .setLayer('offset', { face: 0, line: 0x888888 }) - // .addPolys(top.fill_off) - // .setLayer('last', { face: 0, line: 0x008888 }) - // .addPolys(top.last); - // } + if (isThin && debug) { + slice.output() + .setLayer('offset', { face: 0, line: 0x888888 }) + .addPolys(top.fill_off) + .setLayer('last', { face: 0, line: 0x008888 }) + .addPolys(top.last); + } if (top.fill_lines && top.fill_lines.length) output .setLayer("fill", isSynth ? COLOR.support : COLOR.fill) @@ -496,15 +497,22 @@ if (top.thin_fill) output .setLayer("fill", COLOR.fill) .addLines(top.thin_fill, vopt({ offset, height })); - - // emit solid areas - // if (isThin && debug) { - // output - // .setLayer("solids", { face: 0x00dd00 }) - // .addAreas(slice.solids); - // } }); + if (isThin && debug) { + if (slice.solids) output + .setLayer("solids", { face: 0x00dd00 }) + .addAreas(slice.solids); + + if (slice.bridges) output + .setLayer("bridges", { face: 0x00aaaa, line: 0x00aaaa }) + .addAreas(slice.bridges); + + if (slice.flats) output + .setLayer("flats", { face: 0xaa00aa, line: 0xaa00aa }) + .addAreas(slice.flats); + } + if (slice.supports) output .setLayer("support", COLOR.support) .addPolys(slice.supports, vopt({ offset, height })); @@ -515,16 +523,6 @@ .addLines(poly.fill, vopt({ offset, height })); }); - // if (isThin && debug) { - // output - // .setLayer("bridges", { face: 0x00aaaa, line: 0x00aaaa }) - // .addAreas(top.bridges); - // - // output - // .setLayer("flats", { face: 0xaa00aa, line: 0xaa00aa }) - // .addAreas(top.flats); - // } - // console.log(slice.index, slice.render.stats); } @@ -939,18 +937,15 @@ if (solids.length === 0) return false; if (unioned.length === 0) return false; - let masks, - trims = [], + let trims = [], inner = isSLA ? slice.topPolys() : slice.topFillOff(); // trim each solid to the inner bounds unioned.forEach(function(p) { p.setZ(slice.z); inner.forEach(function(i) { - if (p.del) return; - masks = p.mask(i); + let masks = p.mask(i); if (masks && masks.length > 0) { - p.del = true; trims.appendAll(masks); } });