diff --git a/src/kiri-mode/sla/client.js b/src/kiri-mode/sla/client.js index 3bd2a84b..5a7b7e16 100644 --- a/src/kiri-mode/sla/client.js +++ b/src/kiri-mode/sla/client.js @@ -20,7 +20,7 @@ }; SLA.printDownload = function(output, API, names) { - const { file, width, height, layers } = output; + const { file, width, height, layers, volume } = output; const fileroot = names[0] || "print"; const filename = `${fileroot}-${new Date().getTime().toString(36)}`; @@ -61,6 +61,7 @@ print_hrs = print_hrs.toString().padStart(2,'0'); $('print-filename').value = filename; + $('print-volume').value = Math.round(volume); $('print-layers').value = layers; $('print-time').value = `${print_hrs}:${print_min}:${print_sec}`; diff --git a/src/kiri-mode/sla/export.js b/src/kiri-mode/sla/export.js index a692f74f..c2daf535 100644 --- a/src/kiri-mode/sla/export.js +++ b/src/kiri-mode/sla/export.js @@ -24,9 +24,11 @@ height = device.resolutionY, scaleX = width / device.bedWidth, scaleY = height / device.bedDepth, + layerZ = process.slaSlice, alias = process.slaAntiAlias || 1, mark = Date.now(), - layermax = 0; + layermax = 0, + volume = 0; // filter ignored widgets widgets = widgets.filter(w => !w.track.ignore && !w.meta.disabled); @@ -64,7 +66,8 @@ for (let index=0; index < layermax; index++) { let param = { index, width, height, widgets, scaleX, scaleY, masks }; - let {image, layers, end} = render(param); + let { image, layers, end, area } = render(param); + volume += (area * layerZ); images.push(image); slices.push(layers); online({ @@ -89,7 +92,7 @@ }, (progress, message) => { online({progress: progress * part2 + part1, message}); }); - ondone({ width, height, file, layers: images.length }, [file]); + ondone({ width, height, file, layers: images.length, volume }, [file]); } else { let part1 = 0.95; let part2 = 1 - part1; @@ -97,7 +100,8 @@ for (let index=0; index < layermax; index++) { let param = { index, width, height, widgets, scaleX, scaleY }; - let {lines} = CXDLP.render(param); + let { lines, area } = CXDLP.render(param); + volume += (area * layerZ); slices.push(lines); online({ progress: (index / layermax) * part1, @@ -151,7 +155,8 @@ width: width, height: height, file: file, - layers: slices.length + layers: slices.length, + volume }, [file]); } diff --git a/src/kiri-mode/sla/x_cxdlp.js b/src/kiri-mode/sla/x_cxdlp.js index 7c829930..f4c3e75e 100644 --- a/src/kiri-mode/sla/x_cxdlp.js +++ b/src/kiri-mode/sla/x_cxdlp.js @@ -335,6 +335,7 @@ let width2 = width / 2, height2 = height / 2; let array = []; let count = 0; + let area = 0; function scaleMovePoly(poly) { let points = poly.points; @@ -401,6 +402,7 @@ // scale and move all polys to fit in rendered platform coordinates for (let i=0, il=array.length; i { let slice = widget.slices[index]; if (slice) { @@ -489,6 +492,7 @@ if (!polys) polys = slice.tops.map(t => t.poly); if (slice.supports) polys.appendAll(slice.supports); polys.forEach(poly => { + area += poly.areaDeep(); poly.move(widget.track.pos); ctx.beginPath(); polyout(poly.setClockwise(), ctx, opt); @@ -510,7 +514,7 @@ for (let i=0; i