use alt strategy for depth first with outline
This commit is contained in:
parent
e8d2a111c0
commit
10c7bec3c8
2 changed files with 21 additions and 9 deletions
|
|
@ -136,7 +136,6 @@ class OpArea extends CamOp {
|
|||
|
||||
// filter out invalid polys
|
||||
polys = polys.filter(p => p && p.length > 2);
|
||||
console.log({ polys });
|
||||
|
||||
// process each area separately
|
||||
let proc = 0;
|
||||
|
|
@ -489,8 +488,9 @@ class OpArea extends CamOp {
|
|||
min.area.used = true;
|
||||
pocket({
|
||||
cutdir: op.ov_conv,
|
||||
depthFirst: process.camDepthFirst && !op.drape,
|
||||
depthFirst: process.camDepthFirst,
|
||||
easeDown: op.down && process.easeDown ? op.down : 0,
|
||||
outline: op.drape || op.mode === 'trace',
|
||||
progress: (n,m) => progress(n/m, "area"),
|
||||
slices: min.area.filter(slice => slice.camLines)
|
||||
});
|
||||
|
|
|
|||
|
|
@ -667,16 +667,21 @@ export async function prepare_one(widget, settings, print, firstPoint, update) {
|
|||
* @param {boolean} cutdir true=CW false=CCW
|
||||
* @param {boolean} depthFirst prioritize cut depth in pockets by nesting
|
||||
*/
|
||||
function pocket({ slices, cutdir, depthFirst, progress }) {
|
||||
function pocket({ slices, cutdir, depthFirst, outline, progress }) {
|
||||
let total = 0;
|
||||
let depthData = [];
|
||||
|
||||
for (let slice of slices) {
|
||||
let polys = [], t = [], c = [];
|
||||
// use shadow + tool radius offset when available (roughing)
|
||||
|
||||
// collect polys in to tops (parents) and children
|
||||
// so we can have the windings be opposite
|
||||
POLY.flatten(slice.camLines).forEach((poly) => {
|
||||
// poly is child if has parent
|
||||
let child = poly.parent;
|
||||
// for depth, collapse parent to 1 or 0 (has, missing)
|
||||
if (depthFirst) { poly = poly.clone(); poly.parent = child ? 1 : 0 }
|
||||
// place poly into top or child bucket
|
||||
if (child) c.push(poly); else t.push(poly);
|
||||
polys.push(poly);
|
||||
});
|
||||
|
|
@ -687,6 +692,7 @@ export async function prepare_one(widget, settings, print, firstPoint, update) {
|
|||
POLY.setWinding(c, !cutdir);
|
||||
|
||||
if (depthFirst) {
|
||||
// re-nest layer polys and add to depth stack
|
||||
polys = POLY.nest(polys,true,true);
|
||||
polys.tool_shadow = POLY.flatten(slice.tool_shadow.clone(true));
|
||||
depthData.push(polys);
|
||||
|
|
@ -706,18 +712,18 @@ export async function prepare_one(widget, settings, print, firstPoint, update) {
|
|||
|
||||
if (depthFirst) {
|
||||
for (let i=0; i<depthData.length; i++) {
|
||||
descend(depthData.slice(i));
|
||||
descend(depthData.slice(i), undefined, outline);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function descend(stack, inside) {
|
||||
function descend(stack, inside, outline) {
|
||||
if (stack.length === 0) return;
|
||||
let tops = stack[0];
|
||||
let flat = tops.filter(poly => !poly.marked);
|
||||
let flat = POLY.flatten(tops).filter(poly => !poly.marked);
|
||||
if (flat.length === 0) return;
|
||||
if (inside) {
|
||||
flat = flat.filter(p => p.isNested(inside));
|
||||
flat = flat.filter(p => p.isInside(inside));
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
|
|
@ -736,7 +742,13 @@ export async function prepare_one(widget, settings, print, firstPoint, update) {
|
|||
polyEmit(poly, CLOSEST_TO_PP, engage);
|
||||
engage = false;
|
||||
}
|
||||
if (outline) {
|
||||
output.forEach(poly => {
|
||||
descend(stack.slice(1), poly);
|
||||
});
|
||||
} else {
|
||||
descend(stack.slice(1), poly);
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue