diff --git a/src/kiri/mode/cam/work/op-area.js b/src/kiri/mode/cam/work/op-area.js index af080a10..8297d419 100644 --- a/src/kiri/mode/cam/work/op-area.js +++ b/src/kiri/mode/cam/work/op-area.js @@ -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) }); diff --git a/src/kiri/mode/cam/work/prepare.js b/src/kiri/mode/cam/work/prepare.js index 35225178..43a26e1d 100644 --- a/src/kiri/mode/cam/work/prepare.js +++ b/src/kiri/mode/cam/work/prepare.js @@ -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 !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; } - descend(stack.slice(1), poly); + if (outline) { + output.forEach(poly => { + descend(stack.slice(1), poly); + }); + } else { + descend(stack.slice(1), poly); + } } else { return; }