refactor print as proper class

This commit is contained in:
Stewart Allen 2022-02-19 16:16:49 -05:00
commit 930b56b428
4 changed files with 599 additions and 653 deletions

View file

@ -38,6 +38,7 @@
* `F` apply finish speed to exposed top and underside flat areas
* `F` expand internal supporting flats / solids before projection
* `P` expand projected flats (parameterize?)
* `P` enable purge blocks when quick layers are detected
* `P` refactor skirt, brim, raft as synth widget instead of in path routing
* `P` extruder + filament max flow rate cap in planner

View file

@ -5,9 +5,7 @@
// path & routing output utilities
(function() {
const base = self.base;
if (base.paths) return;
const { base } = self;
const { util, config, newPoint } = base;
const { sqr, numOrDefault } = util;

View file

@ -1135,7 +1135,7 @@ class Polygon {
let mid, exit = false;
this.forEachSegment(function(prev, next) {
this.forEachSegment((prev, next) => {
// check midpoint on long lines
if (prev.distTo2D(next) > config.precision_midpoint_check_dist) {
mid = prev.midPointTo(next);
@ -1165,7 +1165,7 @@ class Polygon {
return mem[poly.id];
}
this.forEachSegment(function(prev, next) {
this.forEachSegment((prev, next) => {
// check midpoint on long lines
if (prev.distToSq2D(next) > midcheck) {
if (prev.midPointTo(next).nearPolygon(poly, dist)) {
@ -1202,7 +1202,7 @@ class Polygon {
midcheck = config.precision_midpoint_check_dist,
exit = true;
this.forEachSegment(function(prev, next) {
this.forEachSegment((prev, next) => {
// check midpoint on long lines (TODO: should be distToSq2D()?)
if (prev.distTo2D(next) > midcheck) {
mid = prev.midPointTo(next);
@ -1271,7 +1271,7 @@ class Polygon {
newUndeleted() {
let poly = newPolygon();
this.forEachPoint(function(p) {
this.forEachPoint(p => {
if (!p.del) poly.push(p);
});
return poly;
@ -1299,7 +1299,7 @@ class Polygon {
let len = 0.0;
this.forEachSegment(function(prev, next) {
this.forEachSegment((prev, next) => {
len += Math.sqrt(prev.distToSq2D(next));
}, this.open);
@ -1308,7 +1308,7 @@ class Polygon {
perimeterDeep() {
let len = this.perimeter();
if (this.inner) this.inner.forEach(function(p) {
if (this.inner) this.inner.forEach(p => {
len += p.perimeter()
});
return len;
@ -1432,7 +1432,7 @@ class Polygon {
out = inout || [];
out.push(poly.points.map(p => p.toClipper()));
if (poly.inner) {
poly.inner.forEach(function(p) {
poly.inner.forEach(p => {
p.toClipper(out);
});
}
@ -1494,9 +1494,9 @@ class Polygon {
dist,
min;
this.forEachPoint(function(i2p) {
this.forEachPoint(i2p => {
pointok = false;
poly.forEachSegment(function(i1p1, i1p2) {
poly.forEachSegment((i1p1, i1p2) => {
// if point is close to poly, terminate search, go to next point
if ((dist = i2p.distToLine(i1p1, i1p2)) < config.precision_poly_merge) {
return pointok = true;
@ -1532,7 +1532,7 @@ class Polygon {
closest,
mindist = Infinity;
this.forEachPoint(function(point, pos) {
this.forEachPoint((point, pos) => {
dist = Math.sqrt(point.distToSq2D(target));
if (dist < mindist) {
index = pos;
@ -1560,7 +1560,7 @@ class Polygon {
shortestSegmentLength() {
let len = Infinity;
this.forEachSegment(function(p1, p2) {
this.forEachSegment((p1, p2) => {
len = Math.min(len, p1.distTo2D(p2));
});
return len;
@ -1582,7 +1582,7 @@ class Polygon {
if (clip.Execute(ctyp.ctDifference, ctre, cfil.pftEvenOdd, cfil.pftEvenOdd)) {
poly = POLY.fromClipperTree(ctre, poly.getZ());
poly.forEach(function(p) {
poly.forEach(p => {
p.fillang = fillang;
})
return poly;
@ -1607,7 +1607,7 @@ class Polygon {
if (clip.Execute(ctyp.ctIntersection, ctre, cfil.pftEvenOdd, cfil.pftEvenOdd)) {
poly = POLY.fromClipperTree(ctre, poly.getZ());
poly.forEach(function(p) {
poly.forEach(p => {
p.fillang = fillang;
})
if (nullOnEquiv && poly.length === 1 && poly[0].isEquivalent(this)) {

File diff suppressed because it is too large Load diff