From ce93e98c35bcc6028fe4fab9563ce0d464161757 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Wed, 1 Jul 2020 20:04:50 -0400 Subject: [PATCH] fix z clearance moves when z top offset. fix cutout tabs when muliple parts present --- src/mode/cam/driver.js | 93 ++++++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 45 deletions(-) diff --git a/src/mode/cam/driver.js b/src/mode/cam/driver.js index a9ff7d50..a79f08f9 100644 --- a/src/mode/cam/driver.js +++ b/src/mode/cam/driver.js @@ -903,56 +903,58 @@ // skip if no tops | traces if (slice.tops.length === 0) return; - let trace, index, maxArea = 0, tmpArea; + let notabs = 0; + let nutrace = []; // find trace with greatest area - slice.tops[0].traces.forEach(function(trc, idx) { - if ((tmpArea = trc.area()) > maxArea) { - maxArea = tmpArea; - index = idx; - trace = trc; + slice.tops[0].traces.forEach(function(trace, index) { + + // required to match computed order of cutouts + trace.setClockwise(); + + let count = proc.camTabsCount, + angle = proc.camTabsAngle, + angle_inc = 360 / count, + center = trace.circleCenter(),//BASE.newPoint(0,0,slice.z), + offset = (tabWidth + toolDiam) / 2, + ints = [], + segs = []; + + while (count-- > 0) { + let slope = BASE.newSlopeFromAngle(angle), + normal = BASE.newSlopeFromAngle(angle + 90), + c1 = center.projectOnSlope(normal, offset), + c2 = center.projectOnSlope(normal, -offset), + o1 = c1.projectOnSlope(slope, 10000), + o2 = c2.projectOnSlope(slope, 10000), + int1 = trace.intersections(c1, o1).pop(), + int2 = trace.intersections(c2, o2).pop(); + if (int1 && int2) { + ints.push(int1); + ints.push(int2); + } + angle -= angle_inc; } + + if (ints.length) { + ints.push(ints.shift()); + for (let i=0; i 0) { - let slope = BASE.newSlopeFromAngle(angle), - normal = BASE.newSlopeFromAngle(angle + 90), - c1 = center.projectOnSlope(normal, offset), - c2 = center.projectOnSlope(normal, -offset), - o1 = c1.projectOnSlope(slope, 10000), - o2 = c2.projectOnSlope(slope, 10000), - int1 = trace.intersections(c1, o1).pop(), - int2 = trace.intersections(c2, o2).pop(); - if (int1 && int2) { - ints.push(int1); - ints.push(int2); - } - angle -= angle_inc; - // segs.push(newPolygon([c1,o1])); - // segs.push(newPolygon([c2,o2])); + if (notabs) { + console.log(`unable to compute tabs for ${notabs} traces @ z=${slice.z}`, trace); } - if (ints.length) { - ints.push(ints.shift()); - for (let i=0; i toolDiam || (deltaZ > toolDiam && deltaXY > tolerance)) && (isMove || absDeltaZ >= tolerance)) { - let maxz = toolProfile ? Math.max( + let maxz = (toolProfile ? Math.max( getTopoZPathMax( widget, toolProfile, @@ -1416,7 +1419,7 @@ point.x - wmx, point.y - wmy) + zadd, point.z, - lastPoint.z) : zmax, + lastPoint.z) : zmax) + ztoff, mustGoUp = Math.max(maxz - point.z, maxz - lastPoint.z) >= tolerance, clearz = maxz; // up if any point between higher than start/outline