From 26bf2baf5e6db017d3664aefc0c39e6e22ba3b13 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Thu, 8 Mar 2018 09:28:03 -0500 Subject: [PATCH] make first part of slicing cancellable --- js/kiri-driver-fdm.js | 2 +- js/kiri-slicer.js | 36 +++++++++++++++++++++++++++++++++++- js/kiri-widget.js | 7 ++++++- js/kiri-work.js | 12 +++++++----- js/license.js | 2 +- notes.md | 20 +++++--------------- 6 files changed, 55 insertions(+), 24 deletions(-) diff --git a/js/kiri-driver-fdm.js b/js/kiri-driver-fdm.js index 84b6025d..4977e98f 100644 --- a/js/kiri-driver-fdm.js +++ b/js/kiri-driver-fdm.js @@ -71,7 +71,7 @@ var gs_kiri_fdm = exports; }, onSliceDone, onSliceUpdate); function onSliceUpdate(update) { - onupdate(0.0 + update * 0.5); + return onupdate(0.0 + update * 0.5); } function onSliceDone(slices) { diff --git a/js/kiri-slicer.js b/js/kiri-slicer.js index f0a4d6bd..3d9f832d 100644 --- a/js/kiri-slicer.js +++ b/js/kiri-slicer.js @@ -257,9 +257,10 @@ var gs_kiri_slicer = exports; } } +/* -- synchronous slice -- can't be cancelled -- // create a Slice for each z offset in the zIndexes array for (var i = 0; i < zIndexes.length; i++) { - // mark the slice height + // slice next layer and add to slices[] array sliceZ(zIndexes[i], zHeights[i]); // kill slicing if onupdate() returns 42 if (onupdate(i / zIndexes.length) === 42) { @@ -283,6 +284,39 @@ var gs_kiri_slicer = exports; // pass Slices array back to ondone function ondone(slices); +*/ + + var sliceIndex = 0; + + function kickSlice() { + sliceZ(zIndexes[sliceIndex], zHeights[sliceIndex]); + // kill slicing if onupdate() returns 42 + if (onupdate(sliceIndex / zIndexes.length) === 42) { + return ondone(null); + } + if (++sliceIndex < zIndexes.length) { + setTimeout(kickSlice, 0); + } else { + // for cam, mark top and bottom as mandatory (hasFlats) + if (options.cam && slices.length > 0) { + slices[0].hasFlats = true; + slices[slices.length-1].hasFlats = true; + } + + // connect slices into linked list for island/bridge projections + for (i=1; i - All Rights Reserved", LICENSE:"Unauthorized copying, modification and re-distribution are strictly prohibited without prior written consent.", - VERSION:"1.1.8c" + VERSION:"1.1.9" }; if (!module) var module = {}; module.exports = exports; diff --git a/notes.md b/notes.md index 669873af..42184351 100644 --- a/notes.md +++ b/notes.md @@ -1,6 +1,5 @@ # Kiri:Moto todo -* fix slicing cancellation * widget general add-ons (fdm supports, cam tabs) * extend mesh object to store raw + annotations (rot,scale,pos), share raw data w/ dups, encode/decode * bail on decimation if it's proving ineffective @@ -30,11 +29,6 @@ * option to support interior bridges when 0% infill * fix multiple part layout export offset (resend position @ print time) -# Laser todo - -* overcuts, radii for drag knives -* sla :: svg modified from http://garyhodgson.github.io/slic3rsvgviewer/?file=examples/belt_pulley3.svg - # CAM todo * add imperial / metric units switch in (future) global config options @@ -66,20 +60,16 @@ * linear x/y not obeying inset from pocket only * check normals for downward facing facets. mark top for slice skirt/pancake -# References +# Laser todo -* shader examples to enable object-clipping - ----- -* http://jsfiddle.net/LK84y/9/ -* http://www.html5rocks.com/en/tutorials/webgl/shaders/ +* overcuts, radii for drag knives +* sla :: svg modified from http://garyhodgson.github.io/slic3rsvgviewer/?file=examples/belt_pulley3.svg + +# References * other ----- * http://lcamtuf.coredump.cx/gcnc/full/ -* http://www.tcs.fudan.edu.cn/rudolf/Courses/Algorithms/Alg_cs_07w/Webprojects/Zhaobo_hull/ -* https://en.wikipedia.org/wiki/Graham_scan -* http://www.cambam.info/doc/0.9.7/cam/Pocket.aspx -* http://hackaday.com/2016/01/22/pack-your-plywood-cuts-with-genetic-algortihms/ * http://wiki.imal.org/howto/cnc-milling-introduction-cutting-tools * http://www.twak.co.uk/2011/01/degeneracy-in-weighted-straight.html