From 49cde21201857919f70b221efdc0964af71f80e6 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Sun, 1 Nov 2020 23:01:43 -0500 Subject: [PATCH] fix thin lines and fill offset. fix noodle render and z layer moves --- src/geo/polygon.js | 4 ++-- src/geo/polygons.js | 6 +----- src/kiri/slice.js | 8 +++++++- src/mode/fdm/driver.js | 3 ++- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/geo/polygon.js b/src/geo/polygon.js index 9de197e6..99c57e53 100644 --- a/src/geo/polygon.js +++ b/src/geo/polygon.js @@ -502,8 +502,8 @@ /** * @returns {number} z value of first point */ - PRO.getZ = function() { - return this.points[0].z; + PRO.getZ = function(i) { + return this.points[i || 0].z; }; /** diff --git a/src/geo/polygons.js b/src/geo/polygons.js index 10f2bb58..0735f0e6 100644 --- a/src/geo/polygons.js +++ b/src/geo/polygons.js @@ -528,6 +528,7 @@ opt.gaps.push(suba); } + // if offset fails, consider last polygons as gap areas if (opt.gaps && !polys.length) { opt.gaps.push(orig); } @@ -547,11 +548,6 @@ } } - // if the polys fail to offset at the top level, consider them gaps - if (opt.gaps && polys.length === 0 && depth === 0) { - opt.gaps.push(orig); - } - return polys; } diff --git a/src/kiri/slice.js b/src/kiri/slice.js index 40e46ae2..8d86fb8d 100644 --- a/src/kiri/slice.js +++ b/src/kiri/slice.js @@ -392,8 +392,12 @@ oso.outs.forEach((polys, i) => { polys.forEach(p => { p.depth = i; + if (p.inner) { + p.inner.forEach(pi => pi.depth = i); + } top.traces.push(p); }); + last = polys; }); // slice.solids.trimmed = slice.solids.trimmed || []; @@ -624,7 +628,9 @@ // fill intersected areas if (inter.length) { scope.isSparseFill = true; - if (!top.fill_lines) top.fill_lines = []; + if (!top.fill_lines) { + top.fill_lines = []; + } inter.forEach(p => { p.forEachSegment((p1, p2) => { top.fill_lines.push(p1, p2); diff --git a/src/mode/fdm/driver.js b/src/mode/fdm/driver.js index 0b25d366..b01b9fd1 100644 --- a/src/mode/fdm/driver.js +++ b/src/mode/fdm/driver.js @@ -1371,7 +1371,8 @@ if (opt.aslines) { emits.poly(poly, opt.color || color, false, true); } else { - emits.noodle_open(poly, off - 0.02, color, 0x0, poly.getZ()); + // first point may be from the layer below, so use second point + emits.noodle_open(poly, off - 0.02, color, 0x0, poly.getZ(1)); } }); emits.renderAll();