restore sla slice, preview, export
This commit is contained in:
parent
1c5c8e9cb4
commit
feca4902d1
11 changed files with 77 additions and 541 deletions
|
|
@ -19,98 +19,17 @@
|
|||
});
|
||||
};
|
||||
|
||||
SLA.sliceRender = function(widget) {
|
||||
// legacy debug
|
||||
return;
|
||||
|
||||
widget.slices.forEach(slice => {
|
||||
let layers = slice.layers,
|
||||
outline = layers.outline,
|
||||
support = layers.support;
|
||||
|
||||
if (slice.solids.unioned) {
|
||||
// console.log('solid', slice.index)
|
||||
slice.solids.unioned.forEach(poly => {
|
||||
poly = poly.clone(true);//.move(widget.track.pos);
|
||||
outline.poly(poly, 0x010101, true);
|
||||
outline.solid(poly, 0x0099cc);
|
||||
});
|
||||
} else if (slice.tops) {
|
||||
// console.log('top', slice.index)
|
||||
slice.tops.forEach(top => {
|
||||
let poly = top.poly;//.clone(true).move(widget.track.pos);
|
||||
outline.poly(poly, 0x010101, true, false);
|
||||
outline.solid(poly, 0xfcba03);
|
||||
});
|
||||
}
|
||||
|
||||
if (slice.supports) {
|
||||
// console.log('support', slice.index)
|
||||
slice.supports.forEach(poly => {
|
||||
//poly = poly.clone(true).move(widget.track.pos);
|
||||
support.poly(poly, 0x010101, true, false);
|
||||
support.solid(poly, 0xfcba03);
|
||||
});
|
||||
}
|
||||
|
||||
slice.renderDiff();
|
||||
slice.renderSolidOutlines();
|
||||
|
||||
outline.renderAll();
|
||||
support.renderAll();
|
||||
});
|
||||
}
|
||||
|
||||
SLA.printRender = function(print) {
|
||||
let widgets = print.widgets,
|
||||
settings = print.settings,
|
||||
device = settings.device,
|
||||
process = settings.process;
|
||||
|
||||
for (let index=0; ; index++) {
|
||||
let layer = KIRI.newLayer(print.group);
|
||||
let count = 0;
|
||||
|
||||
widgets.forEach(widget => {
|
||||
let slice = widget.slices[index];
|
||||
if (!slice) {
|
||||
return;
|
||||
}
|
||||
count++;
|
||||
let polys = slice.solids.unioned;
|
||||
if (!polys) polys = slice.tops.map(t => t.poly);
|
||||
if (slice.supports) polys.appendAll(slice.supports);
|
||||
polys.forEach(poly => {
|
||||
poly = poly.clone(true).move(widget.track.pos);
|
||||
layer.poly(poly, 0x777777, true);
|
||||
layer.solid(poly, 0x0099cc);
|
||||
});
|
||||
});
|
||||
|
||||
layer.renderSolid();
|
||||
layer.render();
|
||||
|
||||
if (count === 0) {
|
||||
// TODO fix with contract for exposing layer count
|
||||
// hack uses expected gcode output array in print object
|
||||
print.output = print.printView;
|
||||
return;
|
||||
}
|
||||
|
||||
print.printView.push(layer);
|
||||
}
|
||||
}
|
||||
|
||||
SLA.printDownload = function(print) {
|
||||
let { API, lines, done } = print.sla;
|
||||
let filename = `print-${new Date().getTime().toString(36)}`;
|
||||
SLA.printDownload = function(preview, output, API) {
|
||||
const lines = preview;
|
||||
const { file, width, height } = output;
|
||||
const filename = `print-${new Date().getTime().toString(36)}`;
|
||||
|
||||
API.ajax("/kiri/output-sla.html", html => {
|
||||
API.ui.print.innerHTML = html;
|
||||
|
||||
let printset = print.settings,
|
||||
process = printset.process,
|
||||
device = printset.device,
|
||||
let settings = API.conf.get(),
|
||||
process = settings.process,
|
||||
device = settings.device,
|
||||
print_sec = (process.slaBaseLayers * process.slaBaseOn) +
|
||||
(lines.length - process.slaBaseLayers) * process.slaLayerOn;
|
||||
|
||||
|
|
@ -148,17 +67,17 @@
|
|||
switch (device.deviceName) {
|
||||
case 'Anycubic.Photon':
|
||||
download.innerText += " .photon";
|
||||
download.onclick = () => { saveFile(API, done.file, ".photon") };
|
||||
download.onclick = () => { saveFile(API, file, ".photon") };
|
||||
break;
|
||||
case 'Anycubic.Photon.S':
|
||||
download.innerText += " .photons";
|
||||
download.onclick = () => { saveFile(API, done.file, ".photons") };
|
||||
download.onclick = () => { saveFile(API, file, ".photons") };
|
||||
break;
|
||||
}
|
||||
|
||||
let canvas = $('print-canvas');
|
||||
let ctx = canvas.getContext('2d');
|
||||
let img = ctx.createImageData(done.height, done.width);
|
||||
let img = ctx.createImageData(height, width);
|
||||
let imgDV = new DataView(img.data.buffer);
|
||||
let range = $('print-range');
|
||||
range.value = 0;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
SLA = KIRI.driver.SLA = {
|
||||
// init, // src/mode/sla/client.js
|
||||
// slice, // src/mode/sla/slice.js
|
||||
printSetup,
|
||||
prepare,
|
||||
// export, // src/mode/sla/export.js
|
||||
// printDownload, // src/mode/sla/client.js
|
||||
legacy: false
|
||||
|
|
@ -19,13 +19,10 @@
|
|||
|
||||
if (SLA.legacy) console.log("SLA Driver in Legacy Mode");
|
||||
|
||||
/**
|
||||
* DRIVER PRINT CONTRACT - runs in worker
|
||||
* @param {Object} print state object
|
||||
* @param {Function} update incremental callback
|
||||
*/
|
||||
function printSetup(print, update) {
|
||||
// runs in worker. would usually be in src/mode/sla/prepare.js
|
||||
function prepare(widgets, settings, update) {
|
||||
self.worker.print = KIRI.newPrint(settings, widgets);
|
||||
update(1);
|
||||
};
|
||||
}
|
||||
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* @param {Function} online streaming reply
|
||||
* @param {Function} ondone last reply
|
||||
*/
|
||||
SLA.printExport = function(print, online, ondone) {
|
||||
SLA.export = function(print, online, ondone) {
|
||||
let widgets = print.widgets,
|
||||
settings = print.settings,
|
||||
device = settings.device,
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
let KIRI = self.kiri,
|
||||
BASE = self.base,
|
||||
POLY = BASE.polygons,
|
||||
UTIL = BASE.util,
|
||||
SLA = KIRI.driver.SLA,
|
||||
FDM = KIRI.driver.FDM.share,
|
||||
|
|
@ -120,14 +121,12 @@
|
|||
slices[i-1].up = slices[i];
|
||||
slices[i].down = slices[i-1];
|
||||
}
|
||||
// reset for solids and support projections
|
||||
// slices.forEach(function(slice) {
|
||||
// slice.invalidateFill();
|
||||
// slice.invalidateSolids();
|
||||
// slice.invalidateSupports();
|
||||
// slice.isSolidFill = false;
|
||||
// });
|
||||
let solidLayers = Math.round(process.slaShell / process.slaSlice);
|
||||
// setup solid fill
|
||||
slices.forEach(function(slice) {
|
||||
slice.solids = [];
|
||||
});
|
||||
// compute total work for progress bar
|
||||
work_total = [
|
||||
5, // shell
|
||||
10, // diff
|
||||
|
|
@ -147,7 +146,7 @@
|
|||
}, "slice");
|
||||
forSlices(slices, 10, (slice) => {
|
||||
if (slice.synth) return;
|
||||
FDM.doDiff(slice, 0.000001, 0.005, true, !process.slaOpenBase);
|
||||
FDM.doDiff(slice, 0.000001, true, !process.slaOpenBase);
|
||||
}, "delta");
|
||||
if (solidLayers) {
|
||||
forSlices(slices, 10, (slice) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue