checkpoint zpress work

This commit is contained in:
Stewart Allen 2021-09-05 20:14:47 -04:00
commit 79fd318bea
2 changed files with 39 additions and 5 deletions

View file

@ -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) {

View file

@ -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,