diff --git a/notes.md b/notes.md index b442cc0d..39ffe91a 100644 --- a/notes.md +++ b/notes.md @@ -103,10 +103,10 @@ * `F` maintain several part orientations + op chains in a single profile * `P` improve parser - do not require spaced tokens and support implied G0 / G1 -* `P` inner corner arc moves +* `P` outer corner arc moves * `P` log Z interpolation for contour XYZ moves * `P` option to start with the smallest poly by area on layer change -* `P` refactor slicing engine to use common core in geo +* `P` refactor slicing engine to add minion threading * `P` decrease cutting speed when entire tool is engaged (start of roughing, rest machining) * `P` port arc code from FDM export to CAM export * `P` redo all path route / planning in prepare to account for terrain before camOut diff --git a/release.md b/release.md index 6386efa4..381348cb 100644 --- a/release.md +++ b/release.md @@ -6,21 +6,22 @@ Full docs @ https://docs.grid.space/projects/kiri-moto # Release 3.8 * update server-side sample module code -* add new fdm parameters, range overrides * various fixes and improvements to CAM indexing * various fixes and improvements to gcode variables -* CAM move to save Z between ops, refresh spindle speed * improve gcode arc import decoding -* improve trace line selection with zoom adaptive thresholds -* CAM add origin offset optional parameters -* remove auto-decimation on object import +* removed auto-decimation on object import +* FDM slicing memory reduction from team lychee +* FDM add new parameters, range overrides * FDM fix raft line fill strategy -* slicing memory reduction from team lychee -* option to control first output point order +* CAM improve trace line selection with zoom adaptive thresholds +* CAM option to control first output point order +* CAM move to save Z between ops, refresh spindle speed +* CAM add origin offset optional parameters * CAM add control to omit initial tool change * CAM fix vertical face selection and step over defaults * CAM fix multi-part object import / grouping * CAM fix tracing nested polyline offset ordering +* CAM refactor of contouring yields 2x - 20x speedup - refactor object/group storage model in Mesh:Tool - add omit pocket to rough and outline diff --git a/src/kiri-mode/cam/client.js b/src/kiri-mode/cam/client.js index 3540fed4..259d4646 100644 --- a/src/kiri-mode/cam/client.js +++ b/src/kiri-mode/cam/client.js @@ -232,7 +232,7 @@ CAM.init = function(kiri, api) { ], () => { if (!isCamMode) return; for (let op of current.process.ops) { - if (op.type === 'trace') { + if (op.type === 'trace' && !flipping) { op.areas = {}; } } @@ -720,6 +720,8 @@ CAM.init = function(kiri, api) { if (axis === 'Y') { API.selection.rotate(0, Math.PI, 0); } + // clear traces cache + CAM.traces_clear(); flipping = false; process.ops = op2; process.op2 = ops; diff --git a/src/kiri-mode/cam/driver.js b/src/kiri-mode/cam/driver.js index f22d4cd2..e2de2b28 100644 --- a/src/kiri-mode/cam/driver.js +++ b/src/kiri-mode/cam/driver.js @@ -75,6 +75,12 @@ kiri.load(api => { ondone(ids); }); }; + + CAM.traces_clear = function(ondone) { + kiri.client.send("cam_traces_clear", {}, () => { + // console.log({clear_traces: true}); + }); + }; } if (kiri.worker) { @@ -114,15 +120,28 @@ kiri.load(api => { send.done(faces); } - kiri.worker.cam_traces = function(data, send) { + kiri.worker.cam_traces = async function(data, send) { const { settings, single } = data; const widgets = Object.values(kiri.worker.cache); - const fresh = widgets.filter(widget => CAM.traces(settings, widget, single)); + const fresh = []; + for (let widget of widgets) { + if (await CAM.traces(settings, widget, single)) { + fresh.push(widget); + } + } + // const fresh = widgets.filter(widget => CAM.traces(settings, widget, single)); send.done(kiri.codec.encode(fresh.map(widget => { return { id: widget.id, traces: widget.traces, } } ))); }; + + kiri.worker.cam_traces_clear = function(data, send) { + for (let widget of Object.values(kiri.worker.cache)) { + delete widget.traces; + } + send.done({}); + }; } }); diff --git a/src/kiri-mode/cam/ops.js b/src/kiri-mode/cam/ops.js index 4f4381b1..7e2fc7b1 100644 --- a/src/kiri-mode/cam/ops.js +++ b/src/kiri-mode/cam/ops.js @@ -974,7 +974,7 @@ class OpTrace extends CamOp { } else { poly = [ poly ]; } - for (let pi of poly) + for (let pi of POLY.flatten(poly, [], true)) if (down) { let zto = pi.getZ() - thru; if (zThru && similar(zto,0)) { diff --git a/src/kiri-mode/cam/slice.js b/src/kiri-mode/cam/slice.js index 35ddcc08..f273528f 100644 --- a/src/kiri-mode/cam/slice.js +++ b/src/kiri-mode/cam/slice.js @@ -331,7 +331,7 @@ CAM.addDogbones = function(poly, dist, reverse) { } }; -CAM.traces = function(settings, widget, single) { +CAM.traces = async function(settings, widget, single) { if (widget.traces && widget.trace_single === single) { // do no work if cached return false; @@ -365,12 +365,13 @@ CAM.traces = function(settings, widget, single) { let z = poly.getZ(); for (let i=0, il=traces.length; i 0.01) { + if (dz < 0.01) { continue; } // do not add duplicates - if (traces[i].isEquivalent(poly)) { + if (traces[i].isEquivalent(poly) && dz < 1) { return; } } @@ -378,9 +379,9 @@ CAM.traces = function(settings, widget, single) { }); }; let opts = { each: oneach, over: false, flatoff: 0, edges: true, openok: true }; - slicer.slice(indices, opts); + await slicer.slice(indices, opts); opts.over = true; - slicer.slice(indices, opts); + await slicer.slice(indices, opts); widget.traces = traces; widget.trace_single = single; return true; diff --git a/src/kiri-run/worker.js b/src/kiri-run/worker.js index 7cd381af..1feafd10 100644 --- a/src/kiri-run/worker.js +++ b/src/kiri-run/worker.js @@ -647,11 +647,15 @@ kiri.worker = { } }; +function is_async(fn) { + return fn.constructor.name === "AsyncFunction"; +} + dispatch.send = (msg, direct) => { self.postMessage(msg, direct); }; -dispatch.onmessage = self.onmessage = function(e) { +dispatch.onmessage = self.onmessage = async function(e) { let time_recv = time(), msg = e.data || {}, run = dispatch[msg.task], @@ -683,7 +687,7 @@ dispatch.onmessage = self.onmessage = function(e) { if (run) { try { let time_xfer = (time_recv - msg.time), - output = run(msg.data, send), + output = is_async(run) ? await run(msg.data, send) : run(msg.data, send), time_send = time(), time_proc = time_send - time_recv;