move file export to workers
This commit is contained in:
parent
538b6401c6
commit
8da355efbc
2 changed files with 59 additions and 39 deletions
|
|
@ -187,18 +187,37 @@ let gs_kiri_sla = exports;
|
||||||
process = settings.process,
|
process = settings.process,
|
||||||
output = print.output;
|
output = print.output;
|
||||||
|
|
||||||
print.images.forEach(image => {
|
print.images.forEach((image,index) => {
|
||||||
online(image.data, [image.data.buffer]);
|
// online(image.data, [image.data.buffer]);
|
||||||
|
online({progress: (index/print.images.length)/2, data: image.data});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let exp_func;
|
||||||
|
|
||||||
|
switch (device.deviceName) {
|
||||||
|
case 'Anycubic.Photon':
|
||||||
|
exp_func = generatePhoton;
|
||||||
|
break;
|
||||||
|
case 'Anycubic.Photon.S':
|
||||||
|
exp_func = generatePhotons;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
let file = exp_func(print, {
|
||||||
|
width: 2560,
|
||||||
|
height: 1440,
|
||||||
|
lines: print.images.map(i => i.data),
|
||||||
|
small: previewSmall.data,
|
||||||
|
large: previewLarge.data
|
||||||
|
}, progress => {
|
||||||
|
online({progress: progress/2 + 0.5});
|
||||||
|
});
|
||||||
|
|
||||||
ondone({
|
ondone({
|
||||||
width:2560,
|
width:2560,
|
||||||
height:1440,
|
height:1440,
|
||||||
small:previewSmall.data,
|
file:file
|
||||||
large:previewLarge.data
|
},[file]);
|
||||||
},[
|
|
||||||
previewSmall.data.buffer,
|
|
||||||
previewLarge.data.buffer
|
|
||||||
]);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// runs in browser main
|
// runs in browser main
|
||||||
|
|
@ -218,7 +237,6 @@ let gs_kiri_sla = exports;
|
||||||
if (!slice) {
|
if (!slice) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// let polys = slice.gatherTraces([]);
|
|
||||||
let polys = slice.solids.unioned;
|
let polys = slice.solids.unioned;
|
||||||
polys.forEach(poly => {
|
polys.forEach(poly => {
|
||||||
layer.poly(poly, 0x888888, true, false);
|
layer.poly(poly, 0x888888, true, false);
|
||||||
|
|
@ -267,11 +285,11 @@ let gs_kiri_sla = exports;
|
||||||
switch (device.deviceName) {
|
switch (device.deviceName) {
|
||||||
case 'Anycubic.Photon':
|
case 'Anycubic.Photon':
|
||||||
download.innerText += " .photon";
|
download.innerText += " .photon";
|
||||||
download.onclick = () => { download_photon(print) };
|
download.onclick = () => { saveFile(API, done.file, ".photon") };
|
||||||
break;
|
break;
|
||||||
case 'Anycubic.Photon.S':
|
case 'Anycubic.Photon.S':
|
||||||
download.innerText += " .photons";
|
download.innerText += " .photons";
|
||||||
download.onclick = () => { download_photons(print) };
|
download.onclick = () => { saveFile(API, done.file, ".photons") };
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -298,18 +316,25 @@ let gs_kiri_sla = exports;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function download_photon(print) {
|
function saveFile(API, file, ext) {
|
||||||
|
saveAs(
|
||||||
|
new Blob([file], { type: "application/octet-stream" }),
|
||||||
|
$('print-filename').value + ext);
|
||||||
|
API.modal.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
function generatePhoton(print, conf, progress) {
|
||||||
let printset = print.settings,
|
let printset = print.settings,
|
||||||
process = printset.process,
|
process = printset.process,
|
||||||
device = printset.device,
|
device = printset.device,
|
||||||
width = print.sla.done.width,
|
width = conf.width,
|
||||||
height = print.sla.done.height,
|
height = conf.height,
|
||||||
layerCount = print.sla.lines.length,
|
layerCount = conf.lines.length,
|
||||||
layerBytes = width * height,
|
layerBytes = width * height,
|
||||||
small = print.sla.done.small,
|
small = conf.small,
|
||||||
large = print.sla.done.large;
|
large = conf.large;
|
||||||
|
|
||||||
let converted = print.sla.lines.map((line, index) => {
|
let converted = conf.lines.map((line, index) => {
|
||||||
let count = line.length / 4;
|
let count = line.length / 4;
|
||||||
let bits = new Uint8Array(line.length / 4);
|
let bits = new Uint8Array(line.length / 4);
|
||||||
let bitsDV = new DataView(bits.buffer);
|
let bitsDV = new DataView(bits.buffer);
|
||||||
|
|
@ -319,6 +344,7 @@ let gs_kiri_sla = exports;
|
||||||
// defeat anti-aliasing for the moment
|
// defeat anti-aliasing for the moment
|
||||||
bitsDV.setUint8(i, lineDV.getUint8(i * 4) > 0 ? 1 : 0);
|
bitsDV.setUint8(i, lineDV.getUint8(i * 4) > 0 ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
progress(index / conf.lines.length);
|
||||||
return {
|
return {
|
||||||
subs: [{
|
subs: [{
|
||||||
exposureTime: process.slaLayerOn,
|
exposureTime: process.slaLayerOn,
|
||||||
|
|
@ -400,39 +426,36 @@ let gs_kiri_sla = exports;
|
||||||
for (let j=0; j<layer.length; j++) {
|
for (let j=0; j<layer.length; j++) {
|
||||||
filedat.writeU8(layer[j], false);
|
filedat.writeU8(layer[j], false);
|
||||||
}
|
}
|
||||||
|
progress((l / layers.length) / 2 + 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
filedat.view.setUint32(hirez, filedat.pos, true);
|
filedat.view.setUint32(hirez, filedat.pos, true);
|
||||||
writePhotonImage({
|
writePhotonImage({
|
||||||
width: 400,
|
width: 400,
|
||||||
height: 300,
|
height: 300,
|
||||||
data: print.sla.done.large
|
data: conf.large
|
||||||
}, filedat);
|
}, filedat);
|
||||||
|
|
||||||
filedat.view.setUint32(lorez, filedat.pos, true);
|
filedat.view.setUint32(lorez, filedat.pos, true);
|
||||||
writePhotonImage({
|
writePhotonImage({
|
||||||
width: 200,
|
width: 200,
|
||||||
height: 125,
|
height: 125,
|
||||||
data: print.sla.done.small
|
data: conf.small
|
||||||
}, filedat);
|
}, filedat);
|
||||||
|
|
||||||
saveAs(
|
return filebuf;
|
||||||
new Blob([filebuf], { type: "application/octet-stream" }),
|
|
||||||
$('print-filename').value + ".photon");
|
|
||||||
|
|
||||||
print.sla.API.modal.hide();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function download_photons(print) {
|
function generatePhotons(print, conf, progress) {
|
||||||
let printset = print.settings,
|
let printset = print.settings,
|
||||||
process = printset.process,
|
process = printset.process,
|
||||||
device = printset.device,
|
device = printset.device,
|
||||||
width = print.sla.done.width,
|
width = conf.width,
|
||||||
height = print.sla.done.height,
|
height = conf.height,
|
||||||
layerCount = print.sla.lines.length,
|
layerCount = conf.lines.length,
|
||||||
layerBytes = width * height;
|
layerBytes = width * height;
|
||||||
|
|
||||||
let converted = print.sla.lines.map((line, index) => {
|
let converted = conf.lines.map((line, index) => {
|
||||||
let count = line.length / 4;
|
let count = line.length / 4;
|
||||||
let bits = new Uint8Array(line.length / 4);
|
let bits = new Uint8Array(line.length / 4);
|
||||||
let bitsDV = new DataView(bits.buffer);
|
let bitsDV = new DataView(bits.buffer);
|
||||||
|
|
@ -442,6 +465,7 @@ let gs_kiri_sla = exports;
|
||||||
// defeat anti-aliasing for the moment
|
// defeat anti-aliasing for the moment
|
||||||
bitsDV.setUint8(i, lineDV.getUint8(i * 4) > 0 ? 1 : 0);
|
bitsDV.setUint8(i, lineDV.getUint8(i * 4) > 0 ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
progress(index / conf.lines.length);
|
||||||
return {
|
return {
|
||||||
subs: [{
|
subs: [{
|
||||||
exposureTime: process.slaLayerOn,
|
exposureTime: process.slaLayerOn,
|
||||||
|
|
@ -491,16 +515,10 @@ let gs_kiri_sla = exports;
|
||||||
filedat.setUint8(filePos + j, sublayer[j], false);
|
filedat.setUint8(filePos + j, sublayer[j], false);
|
||||||
}
|
}
|
||||||
filePos += numbytes;
|
filePos += numbytes;
|
||||||
|
progress((i / layerCount) / 2 + 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
saveAs(
|
return filebuf;
|
||||||
new Blob([filebuf], { type: "application/octet-stream" }),
|
|
||||||
$('print-filename').value + ".photons");
|
|
||||||
|
|
||||||
print.sla.API.modal.hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
function download_pws() {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function encodeLayers(input, type) {
|
function encodeLayers(input, type) {
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,10 @@ let gs_kiri_export = exports;
|
||||||
if (currentPrint) {
|
if (currentPrint) {
|
||||||
let lines = [];
|
let lines = [];
|
||||||
currentPrint.export(true, function(line) {
|
currentPrint.export(true, function(line) {
|
||||||
lines.push(line);
|
if (line.progress) API.show.progress(line.progress, "exporting");
|
||||||
|
if (line.data) lines.push(line.data);
|
||||||
}, function(done) {
|
}, function(done) {
|
||||||
|
API.show.progress(0);
|
||||||
currentPrint.sla = { lines, done, API };
|
currentPrint.sla = { lines, done, API };
|
||||||
KIRI.driver.SLA.printDownload(currentPrint);
|
KIRI.driver.SLA.printDownload(currentPrint);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue