From 79fd318bea020f88929a88d4718cc18b92815cbe Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Sun, 5 Sep 2021 20:14:47 -0400 Subject: [PATCH] checkpoint zpress work --- src/kiri/slicer.js | 42 +++++++++++++++++++++++++++++++++++++----- src/mode/fdm/slice.js | 2 ++ 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/src/kiri/slicer.js b/src/kiri/slicer.js index e147799e..85c469fc 100644 --- a/src/kiri/slicer.js +++ b/src/kiri/slicer.js @@ -25,7 +25,9 @@ time = UTIL.time, tracker = UTIL.pwait, newSlice = KIRI.newSlice, - newOrderedLine = BASE.newOrderedLine; + newOrderedLine = BASE.newOrderedLine, + beltfact = Math.cos(Math.PI/4), + ibeltfact = 1/beltfact; /** * Convenience method. Gets a Widget's points and calls slice() @@ -53,19 +55,48 @@ */ function slice(points, bounds, options, ondone, onupdate) { let useFlats = options.flats, - zCut = options.zCut || 0, + isBelt = options.isBelt || false, + zPress = options.zPress || 0, // compress z values less than zPress (flaten bottom) + zCut = options.zCut || 0, // cut bottom off model below bed/belt xray = options.xray, + zList = {}, // map count of z index points for adaptive slicing ox = 0, oy = 0; - if (zCut) { + // support moving parts below bed to "cut" them + // and/or flatten part bottoms + let zpress = 0; + let zneg = 0; + if (zCut || zPress) { for (let p of points) { if (!p._z) { p._z = p.z; - p.z -= zCut; + if (zPress) { + if (isBelt) { + let z = (p.z - p.y); + let zo = z * ibeltfact; + let zb = z * beltfact; + if (z < 0) zneg++; + if (zo > 0 && zo < zPress) { + p.y += z; + p.z -= z; + zpress++; + } + countZ(zo); + } else { + if (p.z < zPress) p.z = 0; + } + } + if (zCut) { + p.z -= zCut; + } } } } + console.log({zpress, zneg}); + console.log({ + zList: Object.entries(zList).sort((a,b) => { return parseFloat(a[0]) - parseFloat(b[0]) }) + }); let zMin = options.zmin || options.firstHeight || Math.floor(bounds.min.z), zMax = options.zmax || Math.ceil(bounds.max.z), @@ -77,7 +108,7 @@ zIndexes = [], // auto-detected z slicing offsets (laser/cam) zOrdered = [], // ordered list of Z indexes zThick = [], // ordered list of Z slice thickness (laser) - zList = {}, // map count of z index points for adaptive slicing + // zList = {}, // map count of z index points for adaptive slicing zFlat = {}, // map area of z index flat areas (cam) zLines = {}, // map count of z index lines zScale, // bucket span in z units @@ -105,6 +136,7 @@ p1 = points[i++]; p2 = points[i++]; p3 = points[i++]; + // used to calculate buckets zSum += (Math.abs(p1.z - p2.z) + Math.abs(p2.z - p3.z) + Math.abs(p3.z - p1.z)); // laser auto-detect z slice points if (zInc === 0 || zIncMin) { diff --git a/src/mode/fdm/slice.js b/src/mode/fdm/slice.js index 7402790c..09571a1c 100644 --- a/src/mode/fdm/slice.js +++ b/src/mode/fdm/slice.js @@ -179,6 +179,8 @@ SLICER.sliceWidget(widget, { mode: 'FDM', zCut: widget.track.zcut || 0, + zPress: 1,//0.05, + isBelt, height: sliceHeight, minHeight: sliceMinHeight, firstHeight: sliceHeightBase,