From 0784e11c507b427c57912d2e3e21a84f60dcd667 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Wed, 6 Dec 2017 19:01:08 -0500 Subject: [PATCH] remove mostly unused top.outer array --- js/kiri-print.js | 2 +- js/kiri-slice.js | 30 +++++++++++++----------------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/js/kiri-print.js b/js/kiri-print.js index 4449bda7..1da9c9f0 100644 --- a/js/kiri-print.js +++ b/js/kiri-print.js @@ -519,7 +519,7 @@ var gs_kiri_print = exports; } } else { // top object - var bounds = POLY.flatten(next.outer); + var bounds = POLY.flatten(next.gatherOuter([])); outputTraces([].appendAll(next.traces).appendAll(next.innerTraces() || []), bounds); outputFills(next.fill_lines, bounds); outputSparse(next.fill_sparse, bounds); diff --git a/js/kiri-slice.js b/js/kiri-slice.js index e440f127..29741e4a 100644 --- a/js/kiri-slice.js +++ b/js/kiri-slice.js @@ -84,7 +84,6 @@ var gs_kiri_slice = exports; this.poly = polygon; // outline poly this.traces = null; // array of offset/inset trace polygons (ordered outer to inner) this.inner = null; // array of inner fillable areas (inset from last trace) - this.outer = null; // array of outer trace polygons (TODO remove) this.fill_lines = null; // solid fill lines (array of points) this.fill_sparse = null; // sparse fill area open polygons (poly lines) this.solids = null; // solid fill regions in otherwise sparse fill (from solids.trimmed) @@ -108,6 +107,19 @@ var gs_kiri_slice = exports; return top; }; + /** + * Appends all outermost trace polygons into a given array and returns it + * + * @param {Polygon[]} out array to populate + * @returns {Polygon[]} array of top polygons + */ + Top.prototype.gatherOuter = function(out) { + this.traces.forEach(function(trace) { + if (trace.depth === 0) out.append(trace); + }); + return out; + }; + /** ****************************************************************** * Slice Prototype Functions ******************************************************************* */ @@ -230,19 +242,6 @@ var gs_kiri_slice = exports; return out; }; - /** - * Appends all outermost trace polygons into a given array and returns it - * - * @param {Polygon[]} out array to populate - * @returns {Polygon[]} array of top polygons - */ - PRO.gatherOuter = function(out) { - this.tops.forEach(function(top) { - out.appendAll(top.outer); - }); - return out; - }; - /** * Appends all solid area polygons into a given array and returns it * @@ -366,7 +365,6 @@ var gs_kiri_slice = exports; if (vase) top.poly = top.poly.clone(false); top.traces = []; top.inner = []; - top.outer = []; var last = []; if (count) { @@ -376,8 +374,6 @@ var gs_kiri_slice = exports; top.traces = last; } else { POLY.expand([top.poly], -offset1, top.poly.getZ(), top.traces, count, -offsetN, function(polys, countNow) { - // first offset is the outer poly group (max count #) - if (count === countNow) top.outer = polys; last = polys; // mark each poly with depth (offset #) starting at 0 polys.forEach(function(p) { p.depth = count - countNow });