add resin volume to SLA export dialog
This commit is contained in:
parent
6993a339e7
commit
0b19a6c98f
5 changed files with 23 additions and 11 deletions
|
|
@ -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}`;
|
||||
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<il; i++) {
|
||||
let poly = array[i];
|
||||
area += poly.areaDeep();
|
||||
scaleMovePoly(poly);
|
||||
writePoly(writer, poly);
|
||||
}
|
||||
|
|
@ -425,8 +427,7 @@
|
|||
lastv = v;
|
||||
}
|
||||
}
|
||||
return { lines };
|
||||
// return { image, lines };
|
||||
return { lines, area };
|
||||
}
|
||||
|
||||
if (!self.navigator && self.process && self.process.env) {
|
||||
|
|
|
|||
|
|
@ -391,6 +391,7 @@
|
|||
let width2 = width / 2, height2 = height / 2;
|
||||
let array = [];
|
||||
let count = 0;
|
||||
let area = 0;
|
||||
|
||||
function scaleMovePoly(poly) {
|
||||
let points = poly.points;
|
||||
|
|
@ -457,6 +458,7 @@
|
|||
// scale and move all polys to fit in rendered platform coordinates
|
||||
for (let i=0, il=array.length; i<il; i++) {
|
||||
let poly = array[i];
|
||||
area += poly.areaDeep();
|
||||
scaleMovePoly(poly);
|
||||
writePoly(writer, poly);
|
||||
}
|
||||
|
|
@ -469,7 +471,7 @@
|
|||
layers.push(wasm.heap.slice(imagelen, imagelen + rlelen));
|
||||
}
|
||||
|
||||
return { image, layers, end: count === 0 };
|
||||
return { image, layers, end: count === 0, area };
|
||||
}
|
||||
|
||||
// legacy JS-only rasterizer uses OffscreenCanvas
|
||||
|
|
@ -480,6 +482,7 @@
|
|||
let ctx = layer.getContext('2d');
|
||||
ctx.fillStyle = 'rgb(200, 0, 0)';
|
||||
let count = 0;
|
||||
let area = 0;
|
||||
widgets.forEach(widget => {
|
||||
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<red.length; i++) {
|
||||
red[i] = data[i*4];
|
||||
}
|
||||
return { image: red, end: count === 0 };
|
||||
return { image: red, end: count === 0, area };
|
||||
}
|
||||
|
||||
function polyout(poly, ctx, opt) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue