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

View file

@ -65,6 +65,8 @@
let grouped = process.outputLaserGroup;
let group = [];
group.thick = slice.thick;
function laserOut(poly, group) {
if (!poly) {
return;
@ -84,6 +86,7 @@
if (!grouped) {
groups.push(group);
group = [];
group.thick = slice.thick;
}
});
@ -210,7 +213,6 @@
*
*/
function exportElements(print, onpre, onpoly, onpost, onpoint) {
let process = print.settings.process,
output = print.output,
last,
@ -266,8 +268,10 @@
onpre(min, max, process.outputLaserPower, process.outputLaserSpeed);
output.forEach(function(layer) {
let thick = 0;
let color = 0;
layer.forEach(function(out) {
thick = out.thick;
point = out.point;
if (out.emit) {
color = out.emit;
@ -276,13 +280,13 @@
}
poly.push(onpoint(point));
} else if (poly.length > 0) {
onpoly(poly, color);
onpoly(poly, color, thick);
poly = [];
}
last = point;
});
if (poly.length > 0) {
onpoly(poly, color);
onpoly(poly, color, thick);
poly = [];
}
});
@ -375,9 +379,12 @@
lines.push('<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">');
lines.push(`<svg width="${width}mm" height="${height}mm" viewBox="0 0 ${width} ${height}" xmlns="http://www.w3.org/2000/svg" version="1.1">`);
},
function(poly, color) {
function(poly, color, thick) {
let cout = colors[((color-1) % colors.length)];
lines.push(`<polyline z="${z}" points="${poly.join(' ')}" fill="none" stroke="${cout}" stroke-width="0.1mm" />`);
let def = ["polyline"];
if (z != undefined) def.push(`z="${z}"`);
if (thick != undefined) def.push(`h="${thick}"`);
lines.push(`<${def.join(' ')} points="${poly.join(' ')}" fill="none" stroke="${cout}" stroke-width="0.1mm" />`);
},
function() {
lines.push("</svg>");