diff --git a/src/geo/polygons.js b/src/geo/polygons.js index d9b62c9f..1c3c62d7 100644 --- a/src/geo/polygons.js +++ b/src/geo/polygons.js @@ -18,7 +18,6 @@ newPoint = BASE.newPoint; BASE.polygons = { - trace2count : trace2count, rayIntersect : rayIntersect, alignWindings : alignWindings, setWinding : setWinding, @@ -548,60 +547,7 @@ } } - return polys; - } - - /** - * @param {Polygon} poly input - * @param {Polygon[]} traces output - * @param {number} offset distance to offset - * @param {number} count number of offsets - * @param {number} depth current depth (count) into offsets - * @param {Polygon[]} [last] - * @param {Polygon[]} [first] - */ - function trace2count(poly, traces, offset, count, depth, last, first) { - if (count === 0) { - if (last) last.append(poly); - return; - } - - // offset polygon to outer traces array - let calcoff = depth === 0 && last ? offset / 2 : offset, - outer = poly.offset(calcoff, []), - inner = [], - j; - - // outer offset failed - if (outer.length === 0) { - if (last) last.append(poly); - return; - } - - // offset poly children to inner traces array - if (poly.inner) { - poly.inner.forEach(function(ic) { - ic.offset(-calcoff, inner); - }); - } - - let newouter = [], newinner = []; - subtract(outer, inner, newouter, newinner, poly.getZ()); - - if (newouter.length > 0) { - traces.appendAll(newouter); - if (depth === 0 && first) { - first.appendAll(newouter); - } - // recurse for multiple shells - if (count > 0) { - for (j=0; j 1) ? 90 : 0, - // calculate fill density - spacing = linewidth * (1 / density), - offsets = []; - // offset support poly for fill lines - POLY.trace2count(poly, offsets, linewidth/4, 1, 0); + let angle = (poly.bounds.width() / poly.bounds.height() > 1) ? 90 : 0; + // calculate fill density + let spacing = linewidth * (1 / density); + // inset support poly for fill lines 33% of nozzle width + let inset = POLY.offset([poly], -linewidth/3, {flat: true, z: slice.z}); // do the fill - if (offsets.length > 0) fillArea(offsets, angle, spacing, poly.fills = []); + if (inset.length > 0) { + fillArea(inset, angle, spacing, poly.fills = []); + } return true; }); diff --git a/src/mode/fdm/driver.js b/src/mode/fdm/driver.js index b01b9fd1..2af26b8b 100644 --- a/src/mode/fdm/driver.js +++ b/src/mode/fdm/driver.js @@ -669,7 +669,7 @@ // expand specified # of brims brims.forEach(function(brim) { - POLY.trace2count(brim, polys, -nozzle, process.outputBrimCount, 0); + POLY.offset([brim], nozzle, {outs: polys, flat: true, count: process.outputBrimCount}); }); // output brim points