first order clear for area op
This commit is contained in:
parent
1ae3750b34
commit
f8c53dfee9
5 changed files with 44 additions and 20 deletions
|
|
@ -70,7 +70,7 @@ export class Polygon {
|
||||||
return bounds;
|
return bounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
getBound3D() {
|
getBounds3D() {
|
||||||
let bounds = new THREE.Box3();
|
let bounds = new THREE.Box3();
|
||||||
for (let point of this.points) {
|
for (let point of this.points) {
|
||||||
bounds.expandByPoint(point);
|
bounds.expandByPoint(point);
|
||||||
|
|
|
||||||
|
|
@ -425,7 +425,7 @@ export const conf = {
|
||||||
camArcTolerance: 0.15,
|
camArcTolerance: 0.15,
|
||||||
camAreaSpindle: 1000,
|
camAreaSpindle: 1000,
|
||||||
camAreaTool: 1000,
|
camAreaTool: 1000,
|
||||||
camAreaType: "clear",
|
camAreaMode: "clear",
|
||||||
camAreaOver: 0.4,
|
camAreaOver: 0.4,
|
||||||
camAreaDown: 1,
|
camAreaDown: 1,
|
||||||
camAreaSpeed: 1000,
|
camAreaSpeed: 1000,
|
||||||
|
|
|
||||||
|
|
@ -678,7 +678,7 @@ export function createPopOps() {
|
||||||
plunge: UC.newInput(LANG.cc_plng_s, { title: LANG.cc_plng_l, convert: toInt, units }),
|
plunge: UC.newInput(LANG.cc_plng_s, { title: LANG.cc_plng_l, convert: toInt, units }),
|
||||||
sep: UC.newBlank({ class: "pop-sep" }),
|
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 }),
|
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" }),
|
sep: UC.newBlank({ class: "pop-sep" }),
|
||||||
expand: UC.newInput(LANG.cp_xpnd_s, { title: LANG.cp_xpnd_l, convert: toFloat, units }),
|
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 }),
|
refine: UC.newInput(LANG.cp_refi_s, { title: LANG.cp_refi_l, convert: toInt }),
|
||||||
|
|
|
||||||
|
|
@ -22,13 +22,16 @@ class OpArea extends CamOp {
|
||||||
let { op, state } = this;
|
let { op, state } = this;
|
||||||
let { tool, mode, down, over, follow, expand, plunge, smooth, tolerance } = op;
|
let { tool, mode, down, over, follow, expand, plunge, smooth, tolerance } = op;
|
||||||
let { ov_topz, ov_botz, ov_conv } = 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 { addSlices, setToolDiam, cutTabs, healPolys, shadowAt, workarea } = state;
|
||||||
|
|
||||||
let areaTool = new Tool(settings, tool);
|
let areaTool = new Tool(settings, tool);
|
||||||
let toolDiam = areaTool.fluteDiameter();
|
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);
|
setToolDiam(toolDiam);
|
||||||
|
|
||||||
|
|
@ -83,12 +86,42 @@ class OpArea extends CamOp {
|
||||||
|
|
||||||
// process each area separately
|
// process each area separately
|
||||||
for (let area of polys) {
|
for (let area of polys) {
|
||||||
let bounds = area.getBound3D();
|
let bounds = area.getBounds3D();
|
||||||
console.log({ area, bounds });
|
|
||||||
|
|
||||||
if (devel) newGroup().output()
|
if (devel) newGroup().output()
|
||||||
.setLayer("areas", { line: 0xff8800 }, false)
|
.setLayer("area", { line: 0xff8800 }, false)
|
||||||
.addPolys(polys);
|
.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);
|
addSlices(groups);
|
||||||
|
|
|
||||||
|
|
@ -229,19 +229,10 @@ export async function cam_slice(settings, widget, onupdate, ondone) {
|
||||||
return cached;
|
return cached;
|
||||||
}
|
}
|
||||||
// find closest shadow above and use to speed up delta shadow gen
|
// 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);
|
let zover = Object.keys(shadows).map(v => parseFloat(v)).filter(v => v > z);
|
||||||
for (let zkey of zover) {
|
let minZabove = Math.min(Infinity, ...zover);
|
||||||
if (minZabove && zkey < minZabove) {
|
|
||||||
minZabove = zkey;
|
|
||||||
} else {
|
|
||||||
minZabove = zkey;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let shadow = computeShadowAt(widget, z, minZabove);
|
let shadow = computeShadowAt(widget, z, minZabove);
|
||||||
if (minZabove) {
|
if (minZabove < Infinity) {
|
||||||
// const merge = shadow.length;
|
|
||||||
// const plus = shadows[minZabove].length;
|
|
||||||
shadow = POLY.union([...shadow, ...shadows[minZabove]], 0.001, true);
|
shadow = POLY.union([...shadow, ...shadows[minZabove]], 0.001, true);
|
||||||
}
|
}
|
||||||
return shadows[z] = POLY.setZ(shadow, z);
|
return shadows[z] = POLY.setZ(shadow, z);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue