fix clone error. only perform route around if intersection detected

This commit is contained in:
Stewart Allen 2021-04-30 09:49:13 -04:00
commit f6dd5312b9
3 changed files with 10 additions and 7 deletions

View file

@ -568,9 +568,6 @@
if (slice.index < 0) {
return false;
}
if (opt.danger) {
return retractRequired(p1, p2);
}
let int = false;
slice.topPolysFlat().forEach(function(poly) {
if (!int) poly.forEachSegment(function(s1, s2) {
@ -579,12 +576,16 @@
}
});
});
// if intersecting, look for a route around
if (int && opt.danger) {
return !routeAround(p1, p2);
}
return int;
}
// returns true if no path around and retract required
// returns false if routed around or no retract
function retractRequired(p1, p2) {
function routeAround(p1, p2) {
const dbug = false;
if (dbug === slice.index) console.log(slice.index, {p1, p2, d: p1.distTo2D(p2)});
@ -632,6 +633,7 @@
return true;
}
// mark invalid intersect pairs (low or zero dist, etc)
// TODO: only if this is the outer pair and there are closer inner pairs
if (i1.ip.distTo2D(i2.ip) < retractDist) {
if (dbug === slice.index) console.log(slice.index, {int_dist_too_small: i1.ip.distTo2D(i2.ip), retractDist});
ints[i] = undefined;

View file

@ -111,7 +111,7 @@
if (this.topFlatPolys) {
return this.topFlatPolys;
}
return this.topFlatPolys = POLY.flatten(this.topPolys()).clone(true);
return this.topFlatPolys = POLY.flatten(this.topPolys().clone(true), [], true);
};
// FDM retract path routing using first shell
@ -119,7 +119,8 @@
if (this.topFlatRoutes) {
return this.topFlatRoutes;
}
return this.topFlatRoutes = POLY.flatten(this.tops.map(top => top.shells[0]).clone(true), [], true);
let topShells0 = this.tops.map(top => top.shells[0]).filter(p => p);
return this.topFlatRoutes = POLY.flatten(topShells0.clone(true), [], true);
}
// CAM only

View file

@ -534,7 +534,7 @@
.setLayer("gaps", COLOR.gaps)
.addPolys(top.gaps, vopt({ offset, height, thin: true }));
if (isThin && devel) {
if (isThin && devel && top.fill_off && top.fill_off.length) {
slice.output()
.setLayer('fill inset', { face: 0, line: 0xaaaaaa, check: 0xaaaaaa })
.addPolys(top.fill_off);