fix nested top fill offsets

This commit is contained in:
Stewart Allen 2026-01-09 16:37:39 -05:00
commit 02b900a8f0
3 changed files with 17 additions and 4 deletions

View file

@ -61,6 +61,7 @@ const POLYS = {
offset,
outer,
points,
print,
rayIntersect,
reconnect,
renest,
@ -212,6 +213,15 @@ export function renest(polygons, deep) {
return nest(flatten(polygons, [], true), deep);
}
export function print(polys, pad = ' ', buf) {
buf = buf || [];
for (let poly of polys) {
buf.push(`${pad} - ${poly.points.length}`);
if (poly.inner) print(poly.inner, pad + pad, buf);
}
return buf;
}
/**
* todo use clipper polytree?
*

View file

@ -758,6 +758,9 @@ export function layerProcessTop(z, top, count, offset1, offsetN, fillOffset, opt
last = [top.poly];
}
// renest deep because last[] could be nested
last = POLY.renest(last, true);
// generate fill offset poly set from last offset to top.fill_off
if (fillOffset && last.length > 0) {
// if gaps present, remove that area from fill inset
@ -766,7 +769,7 @@ export function layerProcessTop(z, top, count, offset1, offsetN, fillOffset, opt
POLY.subtract(last, gaps, nulast, null, z);
last = nulast;
}
last.forEach(function(inner) {
last.forEach((inner) => {
POLY.offset([inner], -fillOffset, {outs: top.fill_off, flat: true, z});
});
}

View file

@ -983,9 +983,9 @@ function layerRender(slice, params, opt = {}) {
if (isThin && devel && top.fill_off?.length) {
slice.output()
.setLayer('fill inset', Color.inset)
.addPolys(top.fill_off);
// .setLayer('last', { face: 0, line: 0x008888, check: 0x008888 })
// .addPolys(top.last);
.addPolys(top.fill_off)
.setLayer('last', { face: 0, line: 0x008888, check: 0x008888 })
.addPolys(top.last);
}
}