add slice thickness hints for laser output
This commit is contained in:
parent
62682855a5
commit
9d471278eb
3 changed files with 35 additions and 14 deletions
|
|
@ -316,13 +316,24 @@
|
||||||
// used for renderMoves client side. can drop non-essential
|
// used for renderMoves client side. can drop non-essential
|
||||||
// data to speed up worker -> browser transfer. perhaps a
|
// data to speed up worker -> browser transfer. perhaps a
|
||||||
// more compact encoding (arrays, etc)
|
// more compact encoding (arrays, etc)
|
||||||
newlayer.push({
|
let push = { };
|
||||||
emit: out.emit,
|
if (out.emit !== undefined) push.emit = out.emit;
|
||||||
speed: out.speed * 60,
|
if (out.speed !== undefined) push.speed = out.speed * 60;
|
||||||
retract: out.retract,
|
if (out.retract !== undefined) push.retract = out.retract;
|
||||||
point: {x: out.point.x, y: out.point.y, z: out.point.z},
|
if (out.point !== undefined) push.point = {
|
||||||
tool: out.tool
|
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
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,7 @@
|
||||||
zHeights = [], // heights for zIndexes in adaptive mode
|
zHeights = [], // heights for zIndexes in adaptive mode
|
||||||
zIndexes = [], // auto-detected z slicing offsets (laser/cam)
|
zIndexes = [], // auto-detected z slicing offsets (laser/cam)
|
||||||
zOrdered = [], // ordered list of Z indexes
|
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)
|
zFlat = {}, // map area of z index flat areas (cam)
|
||||||
zLines = {}, // map count of z index lines
|
zLines = {}, // map count of z index lines
|
||||||
|
|
@ -255,6 +256,7 @@
|
||||||
}
|
}
|
||||||
for (i = 0; i < zl.length - 1; i++) {
|
for (i = 0; i < zl.length - 1; i++) {
|
||||||
zIndexes.push((zl[i] + zl[i+1]) / 2);
|
zIndexes.push((zl[i] + zl[i+1]) / 2);
|
||||||
|
zThick.push(zl[i+1] - zl[i]);
|
||||||
}
|
}
|
||||||
} else if (isCam) {
|
} else if (isCam) {
|
||||||
// re-divide slice height so that top and
|
// re-divide slice height so that top and
|
||||||
|
|
@ -346,7 +348,7 @@
|
||||||
zIndexes[i] += isCam ? 0.001 : -0.001;
|
zIndexes[i] += isCam ? 0.001 : -0.001;
|
||||||
}
|
}
|
||||||
// slice next layer and add to slices[] array
|
// 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
|
// override z in cam in case it was moved for a flat or line
|
||||||
if (isCam && slice) {
|
if (isCam && slice) {
|
||||||
slice.z = zHeights[i];
|
slice.z = zHeights[i];
|
||||||
|
|
@ -451,7 +453,7 @@
|
||||||
* @param {number} z
|
* @param {number} z
|
||||||
* @param {number} [height] optional real height (fdm)
|
* @param {number} [height] optional real height (fdm)
|
||||||
*/
|
*/
|
||||||
function sliceZ(z, height, onflat, online) {
|
function sliceZ(z, height, onflat, online, thick) {
|
||||||
let phash = {},
|
let phash = {},
|
||||||
lines = [],
|
lines = [],
|
||||||
slice = newSlice(z, options.view ? options.view.newGroup() : null),
|
slice = newSlice(z, options.view ? options.view.newGroup() : null),
|
||||||
|
|
@ -507,6 +509,7 @@
|
||||||
slice.height = height;
|
slice.height = height;
|
||||||
slice.index = slices.length;
|
slice.index = slices.length;
|
||||||
slice.lines = removeDuplicateLines(lines);
|
slice.lines = removeDuplicateLines(lines);
|
||||||
|
slice.thick = thick;
|
||||||
|
|
||||||
// for topo slices, we just need the raw lines
|
// for topo slices, we just need the raw lines
|
||||||
if (!topoMode && !simpleMode) {
|
if (!topoMode && !simpleMode) {
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,8 @@
|
||||||
let grouped = process.outputLaserGroup;
|
let grouped = process.outputLaserGroup;
|
||||||
let group = [];
|
let group = [];
|
||||||
|
|
||||||
|
group.thick = slice.thick;
|
||||||
|
|
||||||
function laserOut(poly, group) {
|
function laserOut(poly, group) {
|
||||||
if (!poly) {
|
if (!poly) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -84,6 +86,7 @@
|
||||||
if (!grouped) {
|
if (!grouped) {
|
||||||
groups.push(group);
|
groups.push(group);
|
||||||
group = [];
|
group = [];
|
||||||
|
group.thick = slice.thick;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -210,7 +213,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function exportElements(print, onpre, onpoly, onpost, onpoint) {
|
function exportElements(print, onpre, onpoly, onpost, onpoint) {
|
||||||
|
|
||||||
let process = print.settings.process,
|
let process = print.settings.process,
|
||||||
output = print.output,
|
output = print.output,
|
||||||
last,
|
last,
|
||||||
|
|
@ -266,8 +268,10 @@
|
||||||
onpre(min, max, process.outputLaserPower, process.outputLaserSpeed);
|
onpre(min, max, process.outputLaserPower, process.outputLaserSpeed);
|
||||||
|
|
||||||
output.forEach(function(layer) {
|
output.forEach(function(layer) {
|
||||||
|
let thick = 0;
|
||||||
let color = 0;
|
let color = 0;
|
||||||
layer.forEach(function(out) {
|
layer.forEach(function(out) {
|
||||||
|
thick = out.thick;
|
||||||
point = out.point;
|
point = out.point;
|
||||||
if (out.emit) {
|
if (out.emit) {
|
||||||
color = out.emit;
|
color = out.emit;
|
||||||
|
|
@ -276,13 +280,13 @@
|
||||||
}
|
}
|
||||||
poly.push(onpoint(point));
|
poly.push(onpoint(point));
|
||||||
} else if (poly.length > 0) {
|
} else if (poly.length > 0) {
|
||||||
onpoly(poly, color);
|
onpoly(poly, color, thick);
|
||||||
poly = [];
|
poly = [];
|
||||||
}
|
}
|
||||||
last = point;
|
last = point;
|
||||||
});
|
});
|
||||||
if (poly.length > 0) {
|
if (poly.length > 0) {
|
||||||
onpoly(poly, color);
|
onpoly(poly, color, thick);
|
||||||
poly = [];
|
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('<!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">`);
|
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)];
|
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() {
|
function() {
|
||||||
lines.push("</svg>");
|
lines.push("</svg>");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue