fix premature solid optimization

This commit is contained in:
Stewart Allen 2021-03-04 19:35:27 -05:00
commit bdc7f5ac40

View file

@ -26,7 +26,8 @@
}, },
PROTO = Object.clone(COLOR), PROTO = Object.clone(COLOR),
bwcomp = (1 / Math.cos(Math.PI/4)), bwcomp = (1 / Math.cos(Math.PI/4)),
getRangeParameters = FDM.getRangeParameters; getRangeParameters = FDM.getRangeParameters,
debug = false;
let isThin = false; // force line rendering let isThin = false; // force line rendering
let isFlat = false; // force flat rendering let isFlat = false; // force flat rendering
@ -477,13 +478,13 @@
.setLayer("gaps", COLOR.gaps) .setLayer("gaps", COLOR.gaps)
.addPolys(top.gaps, vopt({ offset, height, thin: true })); .addPolys(top.gaps, vopt({ offset, height, thin: true }));
// if (isThin && debug) { if (isThin && debug) {
// slice.output() slice.output()
// .setLayer('offset', { face: 0, line: 0x888888 }) .setLayer('offset', { face: 0, line: 0x888888 })
// .addPolys(top.fill_off) .addPolys(top.fill_off)
// .setLayer('last', { face: 0, line: 0x008888 }) .setLayer('last', { face: 0, line: 0x008888 })
// .addPolys(top.last); .addPolys(top.last);
// } }
if (top.fill_lines && top.fill_lines.length) output if (top.fill_lines && top.fill_lines.length) output
.setLayer("fill", isSynth ? COLOR.support : COLOR.fill) .setLayer("fill", isSynth ? COLOR.support : COLOR.fill)
@ -496,15 +497,22 @@
if (top.thin_fill) output if (top.thin_fill) output
.setLayer("fill", COLOR.fill) .setLayer("fill", COLOR.fill)
.addLines(top.thin_fill, vopt({ offset, height })); .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 if (slice.supports) output
.setLayer("support", COLOR.support) .setLayer("support", COLOR.support)
.addPolys(slice.supports, vopt({ offset, height })); .addPolys(slice.supports, vopt({ offset, height }));
@ -515,16 +523,6 @@
.addLines(poly.fill, vopt({ offset, height })); .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); // console.log(slice.index, slice.render.stats);
} }
@ -939,18 +937,15 @@
if (solids.length === 0) return false; if (solids.length === 0) return false;
if (unioned.length === 0) return false; if (unioned.length === 0) return false;
let masks, let trims = [],
trims = [],
inner = isSLA ? slice.topPolys() : slice.topFillOff(); inner = isSLA ? slice.topPolys() : slice.topFillOff();
// trim each solid to the inner bounds // trim each solid to the inner bounds
unioned.forEach(function(p) { unioned.forEach(function(p) {
p.setZ(slice.z); p.setZ(slice.z);
inner.forEach(function(i) { inner.forEach(function(i) {
if (p.del) return; let masks = p.mask(i);
masks = p.mask(i);
if (masks && masks.length > 0) { if (masks && masks.length > 0) {
p.del = true;
trims.appendAll(masks); trims.appendAll(masks);
} }
}); });