From 87de4ed055c01f284fec1d0497ae358cf2eeaf97 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Fri, 20 Nov 2020 19:55:18 -0500 Subject: [PATCH] fix adaptive layering first layer --- notes.md | 5 +++-- src/kiri/slicer.js | 14 ++++++++++---- src/mode/fdm/slice.js | 10 +++++----- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/notes.md b/notes.md index 756e1d6a..9973fa1e 100644 --- a/notes.md +++ b/notes.md @@ -33,7 +33,7 @@ # FDM * `B` dwell / extrude engage reversed? -* `B` fix adaptive slicing. also with multi-extruder +* `B` fix adaptive slicing with multi-extruder * `B` fix supports with grouped parts * `B` sparse infill should follow polys it intersects * `B` multi-extruder rendering of raft fails to offset the rest of the print @@ -63,9 +63,11 @@ # CAM +* `B` climb vs conventional not fully consistent after refactor * `B` outside cutting direction in roughing mode inverted * `B` clear voids has double interior pass because wrong offset shadow used * `B` top clearing operations should use linear, not offset, passes +* `F` parameterize dropping close points in prep.js. ensure long segments remain straight * `F` flat and volumetric rendering of paths * `F` z bounded slices (extension of z bottom offset feature) * `F` z planar settings visualizations @@ -77,7 +79,6 @@ * `F` ease-in and ease-out especially on tab cut-out start/stop * `F` implement z line-only follows for ball/taper * `F` add option to spiral in vs out (optimal tool life) vs mixed (optimal path) -* `F` add endmill spiral direction to fully respect climb vs conventional * `F` add support for tapered ball mills * `F` warn when part > stock or cuts go outside bed * `P` crossing open space check point is outside camshell before returning max z diff --git a/src/kiri/slicer.js b/src/kiri/slicer.js index 9f8ef548..12ff1d71 100644 --- a/src/kiri/slicer.js +++ b/src/kiri/slicer.js @@ -286,7 +286,7 @@ } else if (zIncMin) { // console.log('adaptive slicing', zIncMin, ':', zInc, 'from', zMin, 'to', zMax); // FDM adaptive slicing - let zPos = zMin + zIncFirst, + let zPos = zIncFirst, zOI = 0, zDelta, zDivMin, @@ -298,12 +298,18 @@ // first slice is fixed zHeights.push(zIncFirst); zIndexes.push(zIncFirst / 2); - + // console.log({zIncFirst, zOrdered}) while (zPos < zMax && zOI < zOrdered.length) { nextZ = zOrdered[zOI++]; - if (zPos >= nextZ) continue; + if (zPos >= nextZ) { + // console.log('skip',{zPos},'>=',{nextZ}); + continue; + } zDelta = nextZ - zPos; - if (zDelta < zIncMin) continue; + if (zDelta < zIncMin) { + // console.log('skip',{zDelta},'<',{zIncMin}); + continue; + } zDivMin = Math.floor(zDelta / zIncMin); zDivMax = Math.floor(zDelta / zInc); diff --git a/src/mode/fdm/slice.js b/src/mode/fdm/slice.js index ce77ea00..05ede65b 100644 --- a/src/mode/fdm/slice.js +++ b/src/mode/fdm/slice.js @@ -106,10 +106,13 @@ spro.firstSliceHeight = sliceHeight; } + const sliceMinHeight = spro.sliceAdaptive && spro.sliceMinHeight > 0 ? + Math.min(spro.sliceMinHeight, sliceHeight) : 0; + if (spro.firstSliceHeight < sliceHeight) { DBUG.log("invalid first layer height < slice height"); - DBUG.log("reverting to slice height"); - spro.firstSliceHeight = sliceHeight; + DBUG.log("reverting to min valid slice height"); + spro.firstSliceHeight = sliceMinHeight || sliceHeight; } // const slicer = new KIRI.slicer2(widget.getPoints(), { }); @@ -134,9 +137,6 @@ // } }); // onSliceDone(slices); - const sliceMinHeight = spro.sliceAdaptive && spro.sliceMinHeight > 0 ? - Math.min(spro.sliceMinHeight, sliceHeight) : 0; - SLICER.sliceWidget(widget, { height: sliceHeight, minHeight: sliceMinHeight,