fix pocket outline only with thru holes

This commit is contained in:
Stewart Allen 2025-02-28 23:25:52 -05:00
commit 6ead32637e
2 changed files with 11 additions and 4 deletions

View file

@ -41,6 +41,7 @@ const ClipperLib = self.ClipperLib,
; ;
const POLYS = base.polygons = { const POLYS = base.polygons = {
clearInner,
rayIntersect, rayIntersect,
alignWindings, alignWindings,
setWinding, setWinding,
@ -104,6 +105,12 @@ function setZ(polys, z) {
return polys; return polys;
} }
function clearInner(polys) {
for (let p of polys) {
p.clearInner();
}
}
function toClipper(polys = []) { function toClipper(polys = []) {
let out = []; let out = [];
for (let poly of polys) { for (let poly of polys) {

View file

@ -1242,7 +1242,6 @@ class OpPocket extends CamOp {
return slice; return slice;
} }
function clearZ(polys, z, down) { function clearZ(polys, z, down) {
// console.log({ clearZ: polys });
if (down) { if (down) {
// adjust step down to a value <= down that // adjust step down to a value <= down that
// ends on the lowest z specified // ends on the lowest z specified
@ -1275,6 +1274,9 @@ class OpPocket extends CamOp {
shadow = POLY.setZ(POLY.offset(POLY.offset(shadow, smooth), -smooth), z); shadow = POLY.setZ(POLY.offset(POLY.offset(shadow, smooth), -smooth), z);
} }
POLY.subtract([ poly ], shadow, clip, undefined, undefined, 0); POLY.subtract([ poly ], shadow, clip, undefined, undefined, 0);
if (op.outline) {
POLY.clearInner(clip);
}
} }
if (clip.length === 0) { if (clip.length === 0) {
continue; continue;
@ -1343,9 +1345,7 @@ class OpPocket extends CamOp {
if (outline.length) { if (outline.length) {
// option to skip interior features (holes, pillars) // option to skip interior features (holes, pillars)
if (op.outline) { if (op.outline) {
for (let p of outline) { POLY.clearInner(outline);
p.inner = undefined;
}
} }
if (debug) newSliceOut(zmin).output() if (debug) newSliceOut(zmin).output()
.setLayer("pocket area", {line: 0x1188ff}, false) .setLayer("pocket area", {line: 0x1188ff}, false)