update single width extrusion claim system. does not require splitting medial axis segments
This commit is contained in:
parent
099c0ea0f9
commit
6a44654714
3 changed files with 29 additions and 39 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue