add slice thickness hints for laser output

This commit is contained in:
Stewart Allen 2020-10-14 15:29:51 -04:00
commit 9d471278eb
3 changed files with 35 additions and 14 deletions

View file

@ -316,13 +316,24 @@
// used for renderMoves client side. can drop non-essential
// data to speed up worker -> browser transfer. perhaps a
// more compact encoding (arrays, etc)
newlayer.push({
emit: out.emit,
speed: out.speed * 60,
retract: out.retract,
point: {x: out.point.x, y: out.point.y, z: out.point.z},
tool: out.tool
});
let push = { };
if (out.emit !== undefined) push.emit = out.emit;
if (out.speed !== undefined) push.speed = out.speed * 60;
if (out.retract !== undefined) push.retract = out.retract;
if (out.point !== undefined) push.point = {
x: out.point.x, y: out.point.y, z: out.point.z
};
if (out.tool !== undefined) push.tool = out.tool;
if (layerout.thick !== undefined) push.thick = layerout.thick;
newlayer.push(push);
// newlayer.push({
// emit: out.emit,
// speed: out.speed * 60,
// retract: out.retract,
// point: {x: out.point.x, y: out.point.y, z: out.point.z},
// tool: out.tool,
// thick: layerout.thick
// });
}
});
});

View file

@ -109,6 +109,7 @@
zHeights = [], // heights for zIndexes in adaptive mode
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
zFlat = {}, // map area of z index flat areas (cam)
zLines = {}, // map count of z index lines
@ -255,6 +256,7 @@
}
for (i = 0; i < zl.length - 1; i++) {
zIndexes.push((zl[i] + zl[i+1]) / 2);
zThick.push(zl[i+1] - zl[i]);
}
} else if (isCam) {
// re-divide slice height so that top and
@ -346,7 +348,7 @@
zIndexes[i] += isCam ? 0.001 : -0.001;
}
// slice next layer and add to slices[] array
let slice = sliceZ(zIndexes[i], zHeights[i], onFlat, onLine);
let slice = sliceZ(zIndexes[i], zHeights[i], onFlat, onLine, zThick[i]);
// override z in cam in case it was moved for a flat or line
if (isCam && slice) {
slice.z = zHeights[i];
@ -451,7 +453,7 @@
* @param {number} z
* @param {number} [height] optional real height (fdm)
*/
function sliceZ(z, height, onflat, online) {
function sliceZ(z, height, onflat, online, thick) {
let phash = {},
lines = [],
slice = newSlice(z, options.view ? options.view.newGroup() : null),
@ -507,6 +509,7 @@
slice.height = height;
slice.index = slices.length;
slice.lines = removeDuplicateLines(lines);
slice.thick = thick;
// for topo slices, we just need the raw lines
if (!topoMode && !simpleMode) {