add laser z banding and flatten options

This commit is contained in:
Stewart Allen 2022-10-19 10:17:19 -04:00
commit 5f07f82eb3
6 changed files with 95 additions and 13 deletions

View file

@ -533,7 +533,14 @@ const conf = exports({
camLaserOff: ["M5"],
camLaserSpeed: 100,
camLaserPower: 1,
// camDrillReg: "none",
camLaserAdaptive: false,
camLaserAdaptMod: false,
camLaserFlatten: false,
camLaserFlatZ: 0,
camLaserPowerMin: 0,
camLaserPowerMax: 1,
camLaserZMin: 0,
camLaserZMax: 0,
camTabsWidth: 5,
camTabsHeight: 5,
camTabsDepth: 5,

View file

@ -106,6 +106,7 @@ async function path(levels, update, opts = {}) {
let lastEnd = null;
let lastOut = null;
let current = null;
let currentLaser = null;
let retracted = false;
let retractz = 0;
@ -124,6 +125,7 @@ async function path(levels, update, opts = {}) {
const changes = [];
const retracts = [];
const engages = [];
const lasers = [];
const output = new kiri.Layers();
layers.push(output);
@ -189,6 +191,19 @@ async function path(levels, update, opts = {}) {
}
current.push(out.point);
}
if (out.type === 'laser') {
current.isLaser = true;
if (out.emit) {
if (!lastOut.emit || out.emit !== lastOut.emit) {
// off to on or different power
currentLaser = newPolygon().setOpen();
currentLaser.push(lastOut.point);
currentLaser.color = rate_to_color(out.emit, 1);
lasers.push(currentLaser);
}
currentLaser.push(out.point);
}
}
lastEnd = null;
} else {
current = newPolygon().setOpen();
@ -215,6 +230,13 @@ async function path(levels, update, opts = {}) {
pushPrint(lastOut.tool, current)
}
if (lasers.length) {
for (let poly of lasers)
output
.setLayer('power', { line: 0x000055, face: 0x0000ff, opacity: 0.5 }, true)
.addPolys([ poly ], { thin: true, z: opts.z, color: poly.color });
}
if (changes.length) {
output
.setLayer('tool', { line: 0x000055, face: 0x0000ff, opacity: 0.5 }, true)
@ -267,8 +289,9 @@ async function path(levels, update, opts = {}) {
poly.setClosed();
poly.points.pop();
}
let action = poly.isLaser ? 'speed' : opts.action || 'print';
output
.setLayer(opts.action || 'print', printOpt)
.setLayer(action, printOpt)
.addPolys([ poly ],
thin ? { thin, z: opts.z, color: poly.color } :
flat ? {