From 71a17494f191e8f34ef8d0a0d270f396dc720380 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Mon, 17 May 2021 20:51:51 -0400 Subject: [PATCH] another patch for experimental path routing around voids --- src/kiri/print.js | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/kiri/print.js b/src/kiri/print.js index 0f36956d..29c73a9f 100644 --- a/src/kiri/print.js +++ b/src/kiri/print.js @@ -591,8 +591,7 @@ return int; } - // returns true if no path around and retract required - // returns false if routed around or no retract + // returns true if routed around or no retract requried function routeAround(p1, p2) { const dbug = false; if (dbug === slice.index) console.log(slice.index, {p1, p2, d: p1.distTo2D(p2)}); @@ -617,7 +616,7 @@ // odd # of intersections ?!? do retraction if (ints.length && ints.length % 2 !== 0) { if (dbug === slice.index) console.log(slice.index, {odd_intersects: ints}); - return true; + return false; } // sort by distance @@ -625,8 +624,6 @@ return a.ip.dist - b.ip.dist; }); - let valid = ints.length; - if (dbug === slice.index) console.log(slice.index, {ints}); // check pairs. eliminate too close points. @@ -637,7 +634,7 @@ // different poly. force retract if (i1.poly !== i2.poly) { if (dbug === slice.index) console.log(slice.index, {int_diff_poly: ints, i}); - return true; + return false; } // mark invalid intersect pairs (low or zero dist, etc) // TODO: only if this is the outer pair and there are closer inner pairs @@ -645,18 +642,17 @@ if (dbug === slice.index) console.log(slice.index, {int_dist_too_small: i1.ip.distTo2D(i2.ip), retractDist}); ints[i] = undefined; ints[i+1] = undefined; - valid -= 2; } } // filter out invalid intersection pairs ints = ints.filter(i => i); - if (valid > 2) { - if (dbug === slice.index) console.log(slice.index, {complex_route: valid}); - return true; + if (ints.length > 2) { + if (dbug === slice.index) console.log(slice.index, {complex_route: ints.length}); + return false; } - if (valid) { + if (ints.length === 2) { // can route around intersected top polys for (let i=0; i 2 && p1.distTo2D(p2) >= retractDist; } function outputTraces(poly, opt = {}) {