From 230a1e5f664f034c99eff28cf2e965462bd72f95 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Thu, 5 Mar 2020 11:53:54 -0500 Subject: [PATCH] much better tab cutout control with count and angle now controllable --- js/kiri-driver-cam.js | 66 ++++++++++++++++++++++--------------------- js/kiri.js | 6 ++++ js/license.js | 2 +- 3 files changed, 41 insertions(+), 33 deletions(-) diff --git a/js/kiri-driver-cam.js b/js/kiri-driver-cam.js index 81f7c9ae..f5634920 100644 --- a/js/kiri-driver-cam.js +++ b/js/kiri-driver-cam.js @@ -747,39 +747,41 @@ var gs_kiri_cam = exports; // for tracing out intersections trace.setClockwise(); - const outside = 10000, - width = (tabWidth + toolDiam) / 2, - // horizontal top cut - htl = { x: -outside, y: width }, - htr = { x: -htl.x, y: htl.y }, - // horizontal bottom cut - hbl = { x: htl.x, y: -htl.y }, - hbr = { x: -htl.x, y: -htl.y }, - // vertical left cut - vtl = { x: -width, y: outside }, - vbl = { x: vtl.x, y: -vtl.y }, - // vertical right cut - vtr = { x: -vtl.x, y: vtl.y }, - vbr = { x: -vtl.x, y: -vtl.y }, - nutraces = []; - - var lrtop = trace.intersections(htl, htr), - lrbot = trace.intersections(hbl, hbr), - tblt = trace.intersections(vtl, vbl), - tbrt = trace.intersections(vtr, vbr); - - if (!(lrtop.length && lrbot.length && tblt.length && tbrt.length)) { - console.log("unable to compute cutouts"); - return; + let count = proc.camTabsCount; + let angle = proc.camTabsAngle; + let angle_inc = 360 / count; + let center = BASE.newPoint(0,0,slice.z); + let offset = (tabWidth + toolDiam) / 2; + let ints = []; + let segs = []; + while (count-- > 0) { + let slope = BASE.newSlopeFromAngle(angle); + let normal = BASE.newSlopeFromAngle(angle + 90); + let c1 = center.projectOnSlope(normal, offset); + let c2 = center.projectOnSlope(normal, -offset); + let o1 = c1.projectOnSlope(slope, 10000); + let o2 = c2.projectOnSlope(slope, 10000); + let int1 = trace.intersections(c1, o1).pop(); + let int2 = trace.intersections(c2, o2).pop(); + if (int1 && int2) { + ints.push(int1); + ints.push(int2); + } + // segs.push(BASE.newPolygon([c1, o1]).setOpen()); + // segs.push(BASE.newPolygon([c2, o2]).setOpen()); + angle -= angle_inc; + } + if (ints.length) { + let z = slice.z; + ints.push(ints.shift()); + for (let i=0; i - All Rights Reserved", LICENSE:"See the license.md file included with the source distribution", - VERSION:"1.6.7" + VERSION:"1.6.8" }; if (!module) var module = {}; module.exports = exports;