fix swapped y bounds that could affect belt offset. bump rev 2.9.D6

This commit is contained in:
Stewart Allen 2021-05-01 00:43:01 -04:00
commit 6fb292705a
6 changed files with 25 additions and 47 deletions

View file

@ -1,6 +1,6 @@
{
"name": "grid-apps",
"version": "2.9.5D",
"version": "2.9.6D",
"description": "grid.space 3d slice & modeling tools",
"author": "Stewart Allen <sa@grid.space>",
"license": "MIT",

View file

@ -6,7 +6,7 @@
if (!self.kiri) {
self.kiri = {
beta: 2905,
beta: 2906,
driver: {}, // driver modules
loader: [] // module loading: array of functions
};

View file

@ -3,7 +3,7 @@
let terms = {
COPYRIGHT: "Copyright (C) Stewart Allen <sa@grid.space> - All Rights Reserved",
LICENSE: "See the license.md file included with the source distribution",
VERSION: "2.9.D5"
VERSION: "2.9.D6"
};
if (typeof(module) === 'object') {

View file

@ -7,7 +7,8 @@
let KIRI = self.kiri,
BASE = self.base,
UTIL = BASE.util,
FDM = KIRI.driver.FDM;
FDM = KIRI.driver.FDM,
debug = false;
/**
* @returns {Array} gcode lines
@ -97,7 +98,8 @@
bcos = Math.cos(Math.PI/4),
icos = 1 / bcos,
inLoop,
arcQ = [];
arcQ = [],
minz = { x: Infinity, y: Infinity, z: Infinity };
// smallish band-aid. refactor above to remove redundancy
function updateParams(layer) {
@ -295,6 +297,11 @@
if (emit.x) o.append(" X").append(epos.x.toFixed(decimals));
if (emit.y) o.append(" Y").append(epos.y.toFixed(decimals));
if (emit.z) o.append(" Z").append(epos.z.toFixed(decimals));
if (debug) {
if (emit.x) minz.x = Math.min(minz.x, epos.x);
if (emit.y) minz.y = Math.min(minz.y, epos.y);
if (emit.z) minz.z = Math.min(minz.z, epos.z);
}
if (typeof newpos.e === 'number') {
outputLength += newpos.e;
if (extrudeAbs) {
@ -650,6 +657,10 @@
print.lines = lines;
print.bytes = bytes + lines - 1;
print.time = time;
if (debug) {
console.log('minz', minz);
}
};
})();

View file

@ -11,7 +11,8 @@
FDM = KIRI.driver.FDM,
newPoint = BASE.newPoint,
newPolygon = BASE.newPolygon,
getRangeParameters = FDM.getRangeParameters;
getRangeParameters = FDM.getRangeParameters,
debug = false;
/**
* DRIVER PRINT CONTRACT
@ -47,8 +48,7 @@
print = self.worker.print = KIRI.newPrint(settings, widgets),
beltYoff = device.bedDepth / 2,
beltfact = Math.cos(Math.PI/4),
invbfact = 1 / beltfact,
bfactor = invbfact * beltfact;
invbfact = 1 / beltfact;
// compute bounds if missing
if (!bounds) {
@ -308,20 +308,6 @@
y: o,
z: o
};
// offset = { x:0, y:0, z:0 };
// locate the lowest point in slices and widget overall
let minby = Infinity;
for (let slice of widget.slices) {
slice.minby = Infinity;
for (let top of slice.tops) {
let poly = top.poly;
for (let point of poly.points) {
let ypos = -point.y + point.z * bfactor;
slice.minby = Math.min(slice.minby, ypos);
minby = Math.min(minby, ypos);
}
}
}
} else {
// when rafts used this is non-zero
offset.z = zoff;
@ -472,26 +458,8 @@
// post-process for base extrusions (touching the bed)
if (isBelt) {
// find belt min y
let minby = Infinity;
let normout = output.filter(l => !l.anchor);
for (let layer of normout) {
for (let rec of layer) {
let point = rec.point;
if (rec.emit) {
minby = Math.min(minby, -point.y + point.z * bfactor);
}
}
}
// correct y offset to desired layer offset
// // correct y offset to desired layer offset
let miny = process.firstLayerYOffset || 0;
let poff = minby - miny;
for (let layer of output) {
for (let rec of layer) {
rec.point.y += poff;
}
}
let thresh = firstLayerHeight * 0.25;
let seqn = 0;
// iterate over layers, find extrusion on belt and
@ -511,7 +479,7 @@
for (let rec of layer) {
let point = rec.point;
let belty = rec.belty = -point.y + point.z * bfactor;
let belty = rec.belty = -point.y + point.z;
miny = Math.min(miny, belty);
if (rec.emit && belty <= thresh && lastout && Math.abs(lastout.belty - belty) < 0.005) {
// apply base speed to segments touching belt

View file

@ -27,7 +27,7 @@
PROTO = Object.clone(COLOR),
bwcomp = (1 / Math.cos(Math.PI/4)),
getRangeParameters = FDM.getRangeParameters,
debug = true;
debug = false;
let isThin = false; // force line rendering
let isFlat = false; // force flat rendering
@ -38,7 +38,7 @@
if (isFlat) {
opt.flat = true;
opt.outline = true;
return opt
return opt;
}
if (isThin) return null;
}
@ -320,9 +320,9 @@
for (let slice of slices) {
let miny = Infinity;
for (let poly of slice.topPolys()) {
let y = poly.bounds.maxy;
let y = poly.bounds.miny;
let z = slice.z;
let by = -y + z;
let by = y + z;
if (by < miny) miny = by;
if (by < smin) smin = by;
}
@ -345,7 +345,6 @@
if (!start) start = slice;
}
}
// console.log({smin: smin.round(4)});
let offset = spro.firstLayerBeltLead * beltfact;
// ensure we start against a layer with shells
while (start.up && start.topShells().length === 0) {