update single width extrusion claim system. does not require splitting medial axis segments

This commit is contained in:
Stewart Allen 2025-09-21 18:17:56 -04:00
commit 6a44654714
3 changed files with 29 additions and 39 deletions

View file

@ -114,11 +114,16 @@ class Point {
return this.key;
}
clone() {
clone(keys) {
let p = newPoint(this.x, this.y, this.z, this._key);
if (this.a !== undefined) {
p.a = this.a;
}
if (keys) {
for (let key of keys) {
p[key] = this[key];
}
}
return p;
}

View file

@ -2322,7 +2322,7 @@ export class Polygon {
// split long straight lines into segments no longer than max
// and return a new polygon
segment(max = 1) {
segment(max = 1, mark) {
const newp = [];
const points = this.points;
const length = points.length;
@ -2334,6 +2334,7 @@ export class Polygon {
const dy = p2.y - p1.y;
const dl = Math.sqrt(dx * dx + dy * dy);
newp.push(p1);
if (mark) p1.segment = p1;
if (dl < max) {
continue;
}
@ -2348,10 +2349,12 @@ export class Polygon {
newp.push(newPoint(ox, oy, (p1.z + p2.z) / 2));
ox += ix;
oy += iy;
// mark new point with first point of originating segment
if (mark) newp.peek().segment = p1;
}
}
if (newp.length > length) {
return newPolygon().addPoints(newp.map(p => p.clone())).setOpenValue(this.open);
return newPolygon().addPoints(newp.map(p => p.clone(['segment']))).setOpenValue(this.open);
}
return this;
}