From ecb7ab553e26d6c6f0bfbbae324b7ce5a2099f6c Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Thu, 27 Jan 2022 15:38:45 -0500 Subject: [PATCH] bucket max parameter, bucket array fix, notes --- notes.md | 3 ++- src/geo/slicer.js | 12 +++++++----- src/kiri/slicer.js | 3 +-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/notes.md b/notes.md index 7bc46af7..5084e255 100644 --- a/notes.md +++ b/notes.md @@ -57,7 +57,8 @@ * `B` auto bed resizing leaves the origin in the wrong place at first * `B` re-add progress calls for all work units -* `F` test and enable arcs in belt moe +* `F` promote forced layer retraction to a range parameter +* `F` test and enable arcs in belt more * `F` refactor brims to be generated at slice time * `F` anchors should be generated anywhere needed in the print, not just head * `F` slightly angle supports to lean into the Z of the part diff --git a/src/geo/slicer.js b/src/geo/slicer.js index bc1f3543..076b1d2e 100644 --- a/src/geo/slicer.js +++ b/src/geo/slicer.js @@ -38,7 +38,8 @@ zScale, // bucket span in z units zSum = 0.0, // sanity check that points enclose non-zere volume buckets = [], // banded/grouped faces to speed up slice/search - bucketMax = options.overlap || 0.75, + overlapMax = options.overlap || 0.75, + bucketMax = options.bucketmax || 100, onupdate = options.onupdate || function() {}, sliceFn = dval(options.slicer, sliceZ), { debug, flat, autoDim } = options, @@ -120,7 +121,7 @@ let zSpan = zMax - zMin; let zSpanAvg = zSum / points.length; let bucketCount = options.bucket !== false ? - Math.max(1, Math.floor(zSpan / zSpanAvg)) : 1; + Math.min(bucketMax, Math.max(1, Math.floor(zSpan / zSpanAvg))) : 1; zScale = 1 / (zSpan / bucketCount); @@ -138,12 +139,12 @@ } // create empty buckets - for (i = 0; i < bucketCount + 1; i++) { + for (i = 0; i < bucketCount; i++) { buckets.push({ points: [], slices: [] }); } if (bucketCount > 1) { - let failAt = (points.length * bucketMax) | 0, bucket; + let failAt = (points.length * overlapMax) | 0, bucket; // copy triples into all matching z-buckets outer: for (i = 0; i < points.length;) { p1 = points[i++]; @@ -177,7 +178,8 @@ // create buckets data structure for (let z of zIndexes) { - let index = bucketCount > 1 ? Math.floor((z - zMin) * zScale) : 0; + let index = bucketCount <= 1 ? 0 : + Math.min( Math.floor((z - zMin) * zScale), bucketCount - 1 ); buckets[index].slices.push(z); onupdate((i / zIndexes.length) * 0.1); } diff --git a/src/kiri/slicer.js b/src/kiri/slicer.js index 3b583441..ab68dcd8 100644 --- a/src/kiri/slicer.js +++ b/src/kiri/slicer.js @@ -176,10 +176,9 @@ if (concurrent > 1) { if (bucketCount < concurrent) { bucketCount = concurrent; - } else if (bucketCount > 100) { - bucketCount = 100; } } + bucketCount = Math.min(bucketCount, 100); zScale = 1 / (zMax / bucketCount);