From 8d05cb7a2b4b2669e225093d04e54719d52bd831 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Sat, 21 Nov 2020 20:52:52 -0500 Subject: [PATCH] align tabs to a common center. fix tab height when z bottom in topo --- src/mode/cam/slice.js | 11 ++++++----- src/mode/cam/topo.js | 5 +++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/mode/cam/slice.js b/src/mode/cam/slice.js index 67af4914..ec941bd8 100644 --- a/src/mode/cam/slice.js +++ b/src/mode/cam/slice.js @@ -135,6 +135,7 @@ updateOp(index, total); }, genso: true }); let shadowTop = terrain[terrain.length - 1]; + let center = tshadow[0].bounds.center(); if (procDrillReg) { maxToolDiam = Math.max(maxToolDiam, drillToolDiam); @@ -275,7 +276,7 @@ if (outside) { offset.appendAll(outside); if (addTabsOutline && slice.z <= zMin + tabHeight) { - offset = addCutoutTabs(offset, slice.z, roughToolDiam, tabWidth, proc.camTabsCount, proc.camTabsAngle, slice); + offset = addCutoutTabs(offset, slice.z, center, roughToolDiam, tabWidth, proc.camTabsCount, proc.camTabsAngle); } } } @@ -383,7 +384,7 @@ } if (addTabsOutline && slice.z <= zMin + tabHeight) { - offset = addCutoutTabs(offset, slice.z, outlineToolDiam, tabWidth, proc.camTabsCount, proc.camTabsAngle); + offset = addCutoutTabs(offset, slice.z, center, outlineToolDiam, tabWidth, proc.camTabsCount, proc.camTabsAngle); } // offset.xout(`slice ${slice.z}`); @@ -413,7 +414,8 @@ ondone: (slices) => { sliceAll.appendAll(slices); }, - shadow: tshadow + shadow: tshadow, + center: center }); } @@ -534,7 +536,7 @@ } // cut outside traces at the right points - function addCutoutTabs(polys, z, toolDiam, tabWidth, tabCount, tabAngle, slice) { + function addCutoutTabs(polys, z, center, toolDiam, tabWidth, tabCount, tabAngle, slice) { // skip if no tops | traces if (polys.length === 0) return polys; @@ -546,7 +548,6 @@ trace.setClockwise(); let ints = []; - let center = trace.bounds.center(z); CAM.createTabLines(center, toolDiam, tabWidth, tabCount, tabAngle).forEach(tab => { const {c1, c2, o1, o2} = tab, int1 = trace.intersections(c1, o1).pop(), diff --git a/src/mode/cam/topo.js b/src/mode/cam/topo.js index be4907f8..6734053f 100644 --- a/src/mode/cam/topo.js +++ b/src/mode/cam/topo.js @@ -59,11 +59,12 @@ }, newslices = [], tabsOn = proc.camTabsOn, - tabHeight = proc.camTabsHeight, + tabHeight = proc.camTabsHeight + zBottom, clipTab = tabsOn ? [] : null, clipTo = inside ? shadow : POLY.expand(shadow, toolDiameter/2 + resolution * 3), partOff = inside ? 0 : toolDiameter / 2 + resolution, gridDelta = Math.floor(partOff / resolution), + center = opt.center, debug = false, debug_clips = debug && true, debug_topo = debug && false, @@ -72,7 +73,7 @@ if (proc.camTabsOn) { CAM.createTabLines( - clipTo[0].bounds.center(), + center, toolDiameter, proc.camTabsWidth, proc.camTabsCount,