diff --git a/src/kiri/print.js b/src/kiri/print.js index 613dbdcc..abeb85db 100644 --- a/src/kiri/print.js +++ b/src/kiri/print.js @@ -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 + // }); } }); }); diff --git a/src/kiri/slicer.js b/src/kiri/slicer.js index de012f8c..f7f6a0b8 100644 --- a/src/kiri/slicer.js +++ b/src/kiri/slicer.js @@ -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) { diff --git a/src/mode/laser/driver.js b/src/mode/laser/driver.js index 39eda463..7dcbea22 100644 --- a/src/mode/laser/driver.js +++ b/src/mode/laser/driver.js @@ -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(''); lines.push(``); }, - function(poly, color) { + function(poly, color, thick) { let cout = colors[((color-1) % colors.length)]; - lines.push(``); + 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("");