refactor print as proper class
This commit is contained in:
parent
b45fb78c1b
commit
930b56b428
4 changed files with 599 additions and 653 deletions
1
notes.md
1
notes.md
|
|
@ -38,6 +38,7 @@
|
||||||
* `F` apply finish speed to exposed top and underside flat areas
|
* `F` apply finish speed to exposed top and underside flat areas
|
||||||
* `F` expand internal supporting flats / solids before projection
|
* `F` expand internal supporting flats / solids before projection
|
||||||
|
|
||||||
|
* `P` expand projected flats (parameterize?)
|
||||||
* `P` enable purge blocks when quick layers are detected
|
* `P` enable purge blocks when quick layers are detected
|
||||||
* `P` refactor skirt, brim, raft as synth widget instead of in path routing
|
* `P` refactor skirt, brim, raft as synth widget instead of in path routing
|
||||||
* `P` extruder + filament max flow rate cap in planner
|
* `P` extruder + filament max flow rate cap in planner
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,7 @@
|
||||||
// path & routing output utilities
|
// path & routing output utilities
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
const base = self.base;
|
const { base } = self;
|
||||||
if (base.paths) return;
|
|
||||||
|
|
||||||
const { util, config, newPoint } = base;
|
const { util, config, newPoint } = base;
|
||||||
const { sqr, numOrDefault } = util;
|
const { sqr, numOrDefault } = util;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1135,7 +1135,7 @@ class Polygon {
|
||||||
|
|
||||||
let mid, exit = false;
|
let mid, exit = false;
|
||||||
|
|
||||||
this.forEachSegment(function(prev, next) {
|
this.forEachSegment((prev, next) => {
|
||||||
// check midpoint on long lines
|
// check midpoint on long lines
|
||||||
if (prev.distTo2D(next) > config.precision_midpoint_check_dist) {
|
if (prev.distTo2D(next) > config.precision_midpoint_check_dist) {
|
||||||
mid = prev.midPointTo(next);
|
mid = prev.midPointTo(next);
|
||||||
|
|
@ -1165,7 +1165,7 @@ class Polygon {
|
||||||
return mem[poly.id];
|
return mem[poly.id];
|
||||||
}
|
}
|
||||||
|
|
||||||
this.forEachSegment(function(prev, next) {
|
this.forEachSegment((prev, next) => {
|
||||||
// check midpoint on long lines
|
// check midpoint on long lines
|
||||||
if (prev.distToSq2D(next) > midcheck) {
|
if (prev.distToSq2D(next) > midcheck) {
|
||||||
if (prev.midPointTo(next).nearPolygon(poly, dist)) {
|
if (prev.midPointTo(next).nearPolygon(poly, dist)) {
|
||||||
|
|
@ -1202,7 +1202,7 @@ class Polygon {
|
||||||
midcheck = config.precision_midpoint_check_dist,
|
midcheck = config.precision_midpoint_check_dist,
|
||||||
exit = true;
|
exit = true;
|
||||||
|
|
||||||
this.forEachSegment(function(prev, next) {
|
this.forEachSegment((prev, next) => {
|
||||||
// check midpoint on long lines (TODO: should be distToSq2D()?)
|
// check midpoint on long lines (TODO: should be distToSq2D()?)
|
||||||
if (prev.distTo2D(next) > midcheck) {
|
if (prev.distTo2D(next) > midcheck) {
|
||||||
mid = prev.midPointTo(next);
|
mid = prev.midPointTo(next);
|
||||||
|
|
@ -1271,7 +1271,7 @@ class Polygon {
|
||||||
|
|
||||||
newUndeleted() {
|
newUndeleted() {
|
||||||
let poly = newPolygon();
|
let poly = newPolygon();
|
||||||
this.forEachPoint(function(p) {
|
this.forEachPoint(p => {
|
||||||
if (!p.del) poly.push(p);
|
if (!p.del) poly.push(p);
|
||||||
});
|
});
|
||||||
return poly;
|
return poly;
|
||||||
|
|
@ -1299,7 +1299,7 @@ class Polygon {
|
||||||
|
|
||||||
let len = 0.0;
|
let len = 0.0;
|
||||||
|
|
||||||
this.forEachSegment(function(prev, next) {
|
this.forEachSegment((prev, next) => {
|
||||||
len += Math.sqrt(prev.distToSq2D(next));
|
len += Math.sqrt(prev.distToSq2D(next));
|
||||||
}, this.open);
|
}, this.open);
|
||||||
|
|
||||||
|
|
@ -1308,7 +1308,7 @@ class Polygon {
|
||||||
|
|
||||||
perimeterDeep() {
|
perimeterDeep() {
|
||||||
let len = this.perimeter();
|
let len = this.perimeter();
|
||||||
if (this.inner) this.inner.forEach(function(p) {
|
if (this.inner) this.inner.forEach(p => {
|
||||||
len += p.perimeter()
|
len += p.perimeter()
|
||||||
});
|
});
|
||||||
return len;
|
return len;
|
||||||
|
|
@ -1432,7 +1432,7 @@ class Polygon {
|
||||||
out = inout || [];
|
out = inout || [];
|
||||||
out.push(poly.points.map(p => p.toClipper()));
|
out.push(poly.points.map(p => p.toClipper()));
|
||||||
if (poly.inner) {
|
if (poly.inner) {
|
||||||
poly.inner.forEach(function(p) {
|
poly.inner.forEach(p => {
|
||||||
p.toClipper(out);
|
p.toClipper(out);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -1494,9 +1494,9 @@ class Polygon {
|
||||||
dist,
|
dist,
|
||||||
min;
|
min;
|
||||||
|
|
||||||
this.forEachPoint(function(i2p) {
|
this.forEachPoint(i2p => {
|
||||||
pointok = false;
|
pointok = false;
|
||||||
poly.forEachSegment(function(i1p1, i1p2) {
|
poly.forEachSegment((i1p1, i1p2) => {
|
||||||
// if point is close to poly, terminate search, go to next point
|
// if point is close to poly, terminate search, go to next point
|
||||||
if ((dist = i2p.distToLine(i1p1, i1p2)) < config.precision_poly_merge) {
|
if ((dist = i2p.distToLine(i1p1, i1p2)) < config.precision_poly_merge) {
|
||||||
return pointok = true;
|
return pointok = true;
|
||||||
|
|
@ -1532,7 +1532,7 @@ class Polygon {
|
||||||
closest,
|
closest,
|
||||||
mindist = Infinity;
|
mindist = Infinity;
|
||||||
|
|
||||||
this.forEachPoint(function(point, pos) {
|
this.forEachPoint((point, pos) => {
|
||||||
dist = Math.sqrt(point.distToSq2D(target));
|
dist = Math.sqrt(point.distToSq2D(target));
|
||||||
if (dist < mindist) {
|
if (dist < mindist) {
|
||||||
index = pos;
|
index = pos;
|
||||||
|
|
@ -1560,7 +1560,7 @@ class Polygon {
|
||||||
|
|
||||||
shortestSegmentLength() {
|
shortestSegmentLength() {
|
||||||
let len = Infinity;
|
let len = Infinity;
|
||||||
this.forEachSegment(function(p1, p2) {
|
this.forEachSegment((p1, p2) => {
|
||||||
len = Math.min(len, p1.distTo2D(p2));
|
len = Math.min(len, p1.distTo2D(p2));
|
||||||
});
|
});
|
||||||
return len;
|
return len;
|
||||||
|
|
@ -1582,7 +1582,7 @@ class Polygon {
|
||||||
|
|
||||||
if (clip.Execute(ctyp.ctDifference, ctre, cfil.pftEvenOdd, cfil.pftEvenOdd)) {
|
if (clip.Execute(ctyp.ctDifference, ctre, cfil.pftEvenOdd, cfil.pftEvenOdd)) {
|
||||||
poly = POLY.fromClipperTree(ctre, poly.getZ());
|
poly = POLY.fromClipperTree(ctre, poly.getZ());
|
||||||
poly.forEach(function(p) {
|
poly.forEach(p => {
|
||||||
p.fillang = fillang;
|
p.fillang = fillang;
|
||||||
})
|
})
|
||||||
return poly;
|
return poly;
|
||||||
|
|
@ -1607,7 +1607,7 @@ class Polygon {
|
||||||
|
|
||||||
if (clip.Execute(ctyp.ctIntersection, ctre, cfil.pftEvenOdd, cfil.pftEvenOdd)) {
|
if (clip.Execute(ctyp.ctIntersection, ctre, cfil.pftEvenOdd, cfil.pftEvenOdd)) {
|
||||||
poly = POLY.fromClipperTree(ctre, poly.getZ());
|
poly = POLY.fromClipperTree(ctre, poly.getZ());
|
||||||
poly.forEach(function(p) {
|
poly.forEach(p => {
|
||||||
p.fillang = fillang;
|
p.fillang = fillang;
|
||||||
})
|
})
|
||||||
if (nullOnEquiv && poly.length === 1 && poly[0].isEquivalent(this)) {
|
if (nullOnEquiv && poly.length === 1 && poly[0].isEquivalent(this)) {
|
||||||
|
|
|
||||||
1099
src/kiri/print.js
1099
src/kiri/print.js
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue