From 051c5d6f7a687026e7f2f2ce237f831e8187f249 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Mon, 4 May 2020 23:00:39 -0400 Subject: [PATCH] improve performance of pocketed roughing by simplifying pancaked shell --- js/geo-polygon.js | 11 ++++++++--- js/geo-polygons.js | 1 + js/kiri-driver-cam.js | 9 ++++++++- js/kiri-slicer.js | 2 +- js/web-server.js | 2 +- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/js/geo-polygon.js b/js/geo-polygon.js index f23233fc..1eefd7b7 100644 --- a/js/geo-polygon.js +++ b/js/geo-polygon.js @@ -1028,12 +1028,17 @@ var gs_base_polygon = exports; * simplify and merge collinear. only works for single * non-nested polygons. used primarily in slicer/connectLines. */ - PRO.clean = function() { - var clib = self.ClipperLib, + PRO.clean = function(deep, parent) { + let clib = self.ClipperLib, clip = clib.Clipper, clean = clip.CleanPolygon(this.toClipper()[0], CONF.clipperClean), poly = fromClipperPath(clean, this.getZ()); - return poly; + if (deep && this.inner) { + poly.inner = this.inner.map(inr => inr.clean(false, poly)); + } + poly.parent = parent || this.parent; + poly.area2 = this.area2; + return poly || this; }; PRO.toClipper = function(inout,debug) { diff --git a/js/geo-polygons.js b/js/geo-polygons.js index 0a7bc223..80fdd7a9 100644 --- a/js/geo-polygons.js +++ b/js/geo-polygons.js @@ -490,6 +490,7 @@ var gs_base_polygons = exports; var simple = clip.SimplifyPolygons(clean, cpft.pftNonZero); coff.AddPaths(simple, cjnt.jtMiter, cety.etClosedPolygon); }); + coff.Execute(ctre, (dist1 + over) * fact); polys = fromClipperTree(ctre, z); diff --git a/js/kiri-driver-cam.js b/js/kiri-driver-cam.js index ed1ed914..ff57ad6f 100644 --- a/js/kiri-driver-cam.js +++ b/js/kiri-driver-cam.js @@ -903,6 +903,9 @@ var gs_kiri_cam = exports; if (procRough && !pocketOnlyRough) { // expand shell by half tool diameter + stock to leave shellRough = facePolys = POLY.expand(shellRough, (roughToolDiam / 2) + proc.roughingStock, 0); + } else { + // expand shell minimally triggering a clean + shellRough = facePolys = POLY.expand(shellRough, 0.01, 0); } if (anyFinish && pocketOnlyRough && !pocketOnlyFinish) { @@ -1023,21 +1026,25 @@ var gs_kiri_cam = exports; sliceAll.forEach(function(slice, index) { // re-index slice.index = index; + let modekey = "?mode?"; switch (slice.camMode) { case CPRO.FACING: + modekey = "facing"; createFacingSlices(slice, facePolys, roughToolDiam, proc.roughingOver, pocketOnlyRough); break; case CPRO.ROUGH: + modekey = "roughing"; createRoughingSlices(slice, shellRough, roughToolDiam, proc.roughingStock * units, proc.roughingOver, pocketOnlyRough); if (addTabsRough) addCutoutTabs(slice, roughToolDiam); break; case CPRO.FINISH: + modekey = "finishing"; if (profile) findTracingPaths(widget, slice, tool, profile); createFinishingSlices(slice, shellFinish, finishToolDiam, pocketOnlyFinish); if (addTabsFinish) addCutoutTabs(slice, finishToolDiam); break; } - onupdate(0.90 + (index / sliceAll.length) * 0.10, "finishing") + onupdate(0.90 + (index / sliceAll.length) * 0.10, modekey); }, "cam post"); ondone(); diff --git a/js/kiri-slicer.js b/js/kiri-slicer.js index 228899f0..a0636b9b 100644 --- a/js/kiri-slicer.js +++ b/js/kiri-slicer.js @@ -656,7 +656,7 @@ let gs_kiri_slicer = exports; // emit a polygon if it can be cleaned and still have 2 or more points function emit(poly) { poly = poly.clean(); - if (poly.length > 2) output.push(poly.clean()); + if (poly.length > 2) output.push(poly); } // given an array of paths, emit longest to shortest diff --git a/js/web-server.js b/js/web-server.js index 13673608..f4acfadb 100644 --- a/js/web-server.js +++ b/js/web-server.js @@ -914,7 +914,7 @@ let ver = require('../js/license.js'), "add-three", "add-class", "geo", - "geo-wasm", + // "geo-wasm", "geo-debug", "geo-point", "geo-slope",