first order clear for area op

This commit is contained in:
Stewart Allen 2025-11-29 12:38:57 -05:00
commit f8c53dfee9
5 changed files with 44 additions and 20 deletions

View file

@ -70,7 +70,7 @@ export class Polygon {
return bounds;
}
getBound3D() {
getBounds3D() {
let bounds = new THREE.Box3();
for (let point of this.points) {
bounds.expandByPoint(point);

View file

@ -425,7 +425,7 @@ export const conf = {
camArcTolerance: 0.15,
camAreaSpindle: 1000,
camAreaTool: 1000,
camAreaType: "clear",
camAreaMode: "clear",
camAreaOver: 0.4,
camAreaDown: 1,
camAreaSpeed: 1000,

View file

@ -678,7 +678,7 @@ export function createPopOps() {
plunge: UC.newInput(LANG.cc_plng_s, { title: LANG.cc_plng_l, convert: toInt, units }),
sep: UC.newBlank({ class: "pop-sep" }),
over: UC.newInput(LANG.cc_sovr_s, { title: LANG.cc_sovr_l, convert: toFloat, bound: UC.bound(0.001, 100.0), units }),
down: UC.newInput(LANG.cc_sdwn_s, { title: LANG.cc_sdwn_l, convert: toFloat, bound: UC.bound(0, 100), units }),
down: UC.newInput(LANG.cc_sdwn_s, { title: LANG.cc_sdwn_l, convert: toFloat, bound: UC.bound(0.001, 100.0), units }),
sep: UC.newBlank({ class: "pop-sep" }),
expand: UC.newInput(LANG.cp_xpnd_s, { title: LANG.cp_xpnd_l, convert: toFloat, units }),
refine: UC.newInput(LANG.cp_refi_s, { title: LANG.cp_refi_l, convert: toInt }),

View file

@ -22,13 +22,16 @@ class OpArea extends CamOp {
let { op, state } = this;
let { tool, mode, down, over, follow, expand, plunge, smooth, tolerance } = op;
let { ov_topz, ov_botz, ov_conv } = op;
let { settings, widget, zBottom, tabs, color } = state;
let { settings, widget, tabs, color } = state;
let { addSlices, setToolDiam, cutTabs, healPolys, shadowAt, workarea } = state;
let areaTool = new Tool(settings, tool);
let toolDiam = areaTool.fluteDiameter();
let toolOver = toolDiam * over;
let zTop = ov_topz ? workarea.bottom_stock + ov_topz : workarea.top_stock;
let zBottom = ov_botz ? workarea.bottom_stock + ov_botz : workarea.bottom_stock;
zBottom = ov_botz ? workarea.bottom_stock + ov_botz : zBottom;
console.log({ workarea, zTop, zBottom });
setToolDiam(toolDiam);
@ -83,12 +86,42 @@ class OpArea extends CamOp {
// process each area separately
for (let area of polys) {
let bounds = area.getBound3D();
console.log({ area, bounds });
let bounds = area.getBounds3D();
if (devel) newGroup().output()
.setLayer("areas", { line: 0xff8800 }, false)
.addPolys(polys);
.setLayer("area", { line: 0xff8800 }, false)
.addPolys([ area ]);
if (mode === 'clear') {
let zs = base_util.lerp(zTop, zBottom, down);
console.log({ area, bounds, zs });
for (let z of zs) {
let layers = newGroup().output();
let outs = [];
let clip = [];
let shadow = shadowAt(z);
POLY.subtract([ area ], shadow, clip, undefined, undefined, 0);
POLY.offset(clip, [ -toolDiam / 2, -toolOver ], {
count: 1, outs, flat: true, z, minArea: 0
});
if (outs.length === 0) {
break;
}
layers
.setLayer("shadow", { line: 0x0088ff }, false)
.addPolys(shadow);
layers
.setLayer("clear", { line: 0x88ff00 }, false)
.addPolys(outs);
}
} else
if (mode === 'trace') {
} else
if (mode === 'surface') {
}
}
addSlices(groups);

View file

@ -229,19 +229,10 @@ export async function cam_slice(settings, widget, onupdate, ondone) {
return cached;
}
// find closest shadow above and use to speed up delta shadow gen
let minZabove;
let zover = Object.keys(shadows).map(v => parseFloat(v)).filter(v => v > z);
for (let zkey of zover) {
if (minZabove && zkey < minZabove) {
minZabove = zkey;
} else {
minZabove = zkey;
}
}
let minZabove = Math.min(Infinity, ...zover);
let shadow = computeShadowAt(widget, z, minZabove);
if (minZabove) {
// const merge = shadow.length;
// const plus = shadows[minZabove].length;
if (minZabove < Infinity) {
shadow = POLY.union([...shadow, ...shadows[minZabove]], 0.001, true);
}
return shadows[z] = POLY.setZ(shadow, z);