mock up basic thinwall w/out medial axis

This commit is contained in:
Stewart Allen 2025-09-24 01:18:19 -04:00
commit f8180fe79a
2 changed files with 37 additions and 4 deletions

View file

@ -138,16 +138,17 @@ class Print {
} }
poly.forEachPoint((point, pos, points, count) => { poly.forEachPoint((point, pos, points, count) => {
if (first) { if (first || point.skip) {
if (options.onfirst) { // if (point.skip) console.log({ skip: point });
if (first && options.onfirst) {
options.onfirst(point); options.onfirst(point);
} }
// move to first output point on poly // move to first output point on poly
let out = scope.addOutput(output, point, 0, moveSpeed, tool); let out = scope.addOutput(output, point, 0, moveSpeed, tool);
if (options.onfirstout) { if (first && options.onfirstout) {
options.onfirstout(out); options.onfirstout(out);
} }
first = false; if (first) first = false;
} else { } else {
let seglen = last.distTo2D(point); let seglen = last.distTo2D(point);
if (coastDist && shellMult && perimeter - seglen <= coastDist) { if (coastDist && shellMult && perimeter - seglen <= coastDist) {
@ -158,6 +159,7 @@ class Print {
shellMult = 0; shellMult = 0;
} }
perimeter -= seglen; perimeter -= seglen;
// to increase shellMult when point.inc set for collapsed points
scope.addOutput(output, point, shellMult, printSpeed, tool); scope.addOutput(output, point, shellMult, printSpeed, tool);
} }
last = point; last = point;

View file

@ -99,6 +99,37 @@ function offset_default(params) {
} }
} }
); );
// look for close points on segmented polys
if (false)
for (let poly of POLY.flatten(last)) {
let ps = poly.segment(offset1, true);
let pp = ps.points;
let moved = false;
pp.push(pp[0]);
for (let i=0; i<pp.length; i++) {
let p0 = pp[i];
if (p0.moved) continue;
for (let j=i+1; j<pp.length; j++) {
let p1 = pp[j];
if (p1.moved) continue;
if (p0.segment === p1.segment) {
continue;
}
if (p0.distTo2D(p1) < offset1) {
// merge points marking point offset and skip
let mid = p0.midPointTo(p1);
let inc = p0.distTo2D(mid);
moved = p0.moved = p1.moved = inc;
p1.skip = true;
p0.x = p1.x = mid.x;
p0.y = p1.y = mid.y;
}
}
}
if (moved) {
poly.points = pp;
}
}
return { last, gaps }; return { last, gaps };
} }