add laser stacking stl reconstruction option

This commit is contained in:
Stewart Allen 2025-12-15 21:06:19 -05:00
commit 84d6cdcf2c
7 changed files with 98 additions and 6 deletions

View file

@ -647,7 +647,11 @@ export const conf = {
ctSliceHeight: 1,
ctSliceHeightMin: 0,
ctSliceSingle: true,
ctOmitInner: false,
ctOutTileSpacing: 1,
ctOutClean: false,
ctOutFilter: 1,
ctOutSmooth: 0.1,
ctOutPower: 100,
ctOutSpeed: 1000,
ctOutGroup: true,
@ -690,6 +694,7 @@ export const conf = {
ctSliceHeight: 1,
ctSliceHeightMin: 0,
ctSliceSingle: true,
ctOmitInner: false,
ctOutTileSpacing: 1,
ctOutPower: 100,
ctOutSpeed: 1000,
@ -734,6 +739,7 @@ export const conf = {
ctSliceHeight: 1,
ctSliceHeightMin: 0,
ctSliceSingle: true,
ctOmitInner: false,
ctOutTileSpacing: 1,
ctOutPower: 100,
ctOutSpeed: 1000,

View file

@ -99,6 +99,12 @@ function exportLaserDialog(data, names) {
const filename = `${fileroot}-${(printSeq.toString().padStart(3,"0"))}`;
const settings = api.conf.get();
const driver = laser_driver;
const { process } = settings;
if (process.ctOutStack) {
$('print-stl').classList.remove('hide');
} else {
$('print-stl').classList.add('hide');
}
function download_svg() {
api.util.download(
@ -114,6 +120,13 @@ function exportLaserDialog(data, names) {
);
}
function download_stl() {
api.util.download(
driver.exportSTL(settings, data),
$('print-filename-laser').value + ".stl"
);
}
function download_gcode() {
api.util.download(
driver.exportGCode(settings, data),
@ -130,6 +143,7 @@ function exportLaserDialog(data, names) {
$('print-lines').value = util.comma(segments);
$('print-svg').onclick = download_svg;
$('print-dxf').onclick = download_dxf;
$('print-stl').onclick = download_stl;
$('print-lg').onclick = download_gcode;
}

View file

@ -872,8 +872,9 @@ class Widget {
return shadows[z] = POLY.setZ(shadow, z);
}
// create a stack of faces in 1mm increments
// the stacks are then used to produce shadowlines
#ensureShadowCache() {
// cache faces with normals up
if (this.cache.shadow) {
return;
}
@ -881,7 +882,6 @@ class Widget {
const length = geo.length;
const bounds = this.getBoundingBox();
const stack = {};
// const faces = [];
for (let i = Math.floor(bounds.min.z); i <= Math.ceil(bounds.max.z); i++) {
stack[i] = [];
}
@ -892,7 +892,6 @@ class Widget {
const n = THREE.computeFaceNormal(a, b, c);
if (n.z < 0.001) {
continue;
// faces.push(a, b, c);
}
const minZ = Math.floor(Math.min(a.z, b.z, c.z));
const maxZ = Math.ceil(Math.max(a.z, b.z, c.z));
@ -904,6 +903,7 @@ class Widget {
}
// union triangles > z (opt cap < ztop) into polygon(s)
// slice the triangle stack matchingg z then union the results
#computeShadowAt(z, ztop) {
this.#ensureShadowCache();
const found = [];