From d020a94b53b926ce36108b945fa95cb2ca94c76a Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Thu, 26 Nov 2020 00:14:45 -0500 Subject: [PATCH] remove dead tab code. clear tabs and supports on scale events --- notes.md | 1 - src/geo/polygons.js | 4 +- src/kiri/conf.js | 2 - src/kiri/init.js | 4 -- src/mode/cam/client.js | 7 ++- src/mode/cam/slice.js | 99 ------------------------------------------ src/mode/cam/topo.js | 18 +------- src/mode/fdm/client.js | 5 +++ 8 files changed, 14 insertions(+), 126 deletions(-) diff --git a/notes.md b/notes.md index 36a38032..a1f640fc 100644 --- a/notes.md +++ b/notes.md @@ -4,7 +4,6 @@ * cnc * tracing (chamfer, engrave) * auto feature detection (slicing) -* add tabs to shadow and slice model (for topo) * fdm * continuous printing (z belt systems) * laser diff --git a/src/geo/polygons.js b/src/geo/polygons.js index b6d534d3..78fdbc18 100644 --- a/src/geo/polygons.js +++ b/src/geo/polygons.js @@ -78,7 +78,7 @@ tnode.m_Childs.forEach(function(child) { poly = fromClipperNode(child, z); // throw out all tiny polygons - if (poly.area() < min) { + if (!poly.open && poly.area() < min) { return; } if (parent) { @@ -99,7 +99,7 @@ tnode.m_Childs.forEach(function(child) { poly = fromClipperNode(child, z); - if (minarea && poly.area() < minarea) { + if (!poly.open && minarea && poly.area() < minarea) { return; } if (parent) { diff --git a/src/kiri/conf.js b/src/kiri/conf.js index b3c4798a..70767ed7 100644 --- a/src/kiri/conf.js +++ b/src/kiri/conf.js @@ -438,8 +438,6 @@ camDrillLift: 2, camDrillingOn: false, camDrillReg: "none", - camTabsAngle: 0, - camTabsCount: 4, camTabsWidth: 5, camTabsHeight: 5, camTabsOn: false, diff --git a/src/kiri/init.js b/src/kiri/init.js index 641ee053..f5cfdf1b 100644 --- a/src/kiri/init.js +++ b/src/kiri/init.js @@ -1547,10 +1547,6 @@ camTabs: UC.newGroup(LANG.ct_menu, null, {modes:CAM, marker:false}), camTabsWidth: UC.newInput(LANG.ct_wdth_s, {title:LANG.ct_wdth_l, convert:UC.toFloat, bound:UC.bound(0.005,100), modes:CAM, units:true}), camTabsHeight: UC.newInput(LANG.ct_hght_s, {title:LANG.ct_hght_l, convert:UC.toFloat, bound:UC.bound(0.005,100), modes:CAM, units:true}), - // camTabSep: UC.newBlank({class:"pop-sep"}), - // camTabsAngle: UC.newInput(LANG.ct_angl_s, {title:LANG.ct_angl_l, convert:UC.toInt, bound:UC.bound(0,360), modes:CAM}), - // camTabsCount: UC.newInput(LANG.ct_numb_s, {title:LANG.ct_numb_l, convert:UC.toInt, bound:UC.bound(1,20), modes:CAM}), - // camTabsOn: UC.newBoolean(LANG.ct_nabl_s, onBooleanClick, {title:LANG.ct_nabl_l, modes:CAM}), camTabSep: UC.newBlank({class:"pop-sep"}), camTabsManual: UC.newRow([ (UI.tabAdd = UC.newButton(undefined, onButtonClick, {icon:''})), diff --git a/src/mode/cam/client.js b/src/mode/cam/client.js index 8e9779c4..0b8635a5 100644 --- a/src/mode/cam/client.js +++ b/src/mode/cam/client.js @@ -132,7 +132,12 @@ }); api.event.on("key.esc", () => { if (isCamMode) { - func.tdone() + func.tdone(); + } + }); + api.event.on("selection.scale", () => { + if (isCamMode) { + func.tclear(); } }); api.event.on("widget.rotate", rot => { diff --git a/src/mode/cam/slice.js b/src/mode/cam/slice.js index 89324824..7f4f5502 100644 --- a/src/mode/cam/slice.js +++ b/src/mode/cam/slice.js @@ -48,9 +48,6 @@ roughDown = procRough ? proc.camRoughDown : Infinity, outlineDown = procOutline ? proc.camOutlineDown : Infinity, sliceDepth = Math.max(0.1, Math.min(roughDown, outlineDown) / 3), - addTabsOutline = (procOutlineOn || procRough) && proc.camTabsOn, - tabWidth = proc.camTabsWidth, - tabHeight = proc.camTabsHeight, bounds = widget.getBoundingBox(), mesh = widget.mesh, zBottom = proc.camZBottom, @@ -65,9 +62,6 @@ thruHoles, tabs = settings.widget[widget.id].tab; - // force off for testing - proc.camTabsOn = false; - if (tabs) { // make tab polygons tabs.forEach(tab => { @@ -301,9 +295,6 @@ const outside = POLY.offset(shadow.clone(), roughToolDiam * proc.camRoughOver, {z: slice.z}); if (outside) { offset.appendAll(outside); - // if (addTabsOutline && slice.z <= zMin + tabHeight) { - // offset = addCutoutTabs(offset, slice.z, center, roughToolDiam, tabWidth, proc.camTabsCount, proc.camTabsAngle); - // } if (tabs) { tabs.forEach(tab => { tab.off = POLY.expand([tab.poly], roughToolDiam / 2).flat(); @@ -417,9 +408,6 @@ } } - // if (addTabsOutline && slice.z <= zMin + tabHeight) { - // offset = addCutoutTabs(offset, slice.z, center, outlineToolDiam, tabWidth, proc.camTabsCount, proc.camTabsAngle); - // } if (tabs) { tabs.forEach(tab => { tab.off = POLY.expand([tab.poly], outlineToolDiam / 2).flat(); @@ -583,91 +571,4 @@ return noff; } - // cut outside traces at the right points - function addCutoutTabs(polys, z, center, toolDiam, tabWidth, tabCount, tabAngle, slice) { - // skip if no tops | traces - if (polys.length === 0) return polys; - - let notabs = 0; - let nutrace = []; - - polys.forEach(function(trace, index) { - // required to match computed order of cutouts - trace.setClockwise(); - - let ints = []; - CAM.createTabLines(center, toolDiam, tabWidth, tabCount, tabAngle).forEach(tab => { - const {c1, c2, o1, o2} = tab, - int1 = trace.intersections(c1, o1).pop(), - int2 = trace.intersections(c2, o2).pop(); - if (int1 && int2) { - ints.push(int1); - ints.push(int2); - // slice.output().setLayer('int',0xff0000).addLine(int1, int2); - } - }); - - let segs = []; - if (ints.length) { - ints.push(ints.shift()); - // let cv = 0; - for (let i=0; i p.z += (i*0.01)); - // slice.output().setLayer(`seg${i}`,col[cv++]).addPoly(seg); - // slice.output().setLayer(`seg${i}`).addPoly(newPolygon().centerCircle(seg.first(),1,5)); - // slice.output().setLayer(`seg${i}`).addPoly(newPolygon().centerCircle(seg.last(),1,4)); - // slice.output().setLayer(`seg${i}`).addPoly(newPolygon().centerCircle(trace.first(),2,5)); - // slice.output().setLayer(`seg${i}`).addPoly(newPolygon().centerCircle(trace.last(),2,4)); - segs.push(seg); - } - // check for and eliminate overlaps - if (false) - for (let i=0, il=segs.length; i < il; i++) { - let si = segs[i]; - for (let j=i+1; j si.perimeter()) { - sj._overlap = true; - } - } - } - } - // replace intersected trace with non-overlapping segments - nutrace.appendAll(segs.filter(seg => !seg._overlap)); - } else { - nutrace.push(trace); - notabs++; - } - }); - - if (notabs) { - console.log(`unable to compute tabs for ${notabs} traces @ z=${z}`); - } - - return nutrace; - } - - CAM.createTabLines = function(center, toolDiam, tabWidth, tabCount, tabAngle) { - let angle_inc = 360 / tabCount, - offset = (tabWidth + toolDiam) / 2, - lines = []; - - while (tabCount-- > 0) { - let slope = BASE.newSlopeFromAngle(tabAngle), - normal = BASE.newSlopeFromAngle(tabAngle + 90), - c1 = center.projectOnSlope(normal, offset), - c2 = center.projectOnSlope(normal, -offset), - o1 = c1.projectOnSlope(slope, 10000), - o2 = c2.projectOnSlope(slope, 10000); - tabAngle -= angle_inc; - lines.push({c1, o1, c2, o2}); - } - - return lines; - } - })(); diff --git a/src/mode/cam/topo.js b/src/mode/cam/topo.js index 75e374d5..4a36fd9d 100644 --- a/src/mode/cam/topo.js +++ b/src/mode/cam/topo.js @@ -60,7 +60,7 @@ newslices = [], tabs = opt.tabs, tabsMax = tabs ? Math.max(...tabs.map(tab => tab.dim.z)) : 0, - tabsOn = proc.camTabsOn || tabs, + tabsOn = tabs, tabHeight = Math.max(proc.camTabsHeight + zBottom, tabsMax), clipTab = tabsOn ? [] : null, clipTo = inside ? shadow : POLY.expand(shadow, toolDiameter/2 + resolution * 3), @@ -77,22 +77,6 @@ clipTab.appendAll(tabs.map(tab => POLY.expand([tab.poly], toolDiameter/2)).flat()); } - if (proc.camTabsOn) { - CAM.createTabLines( - center, - toolDiameter, - proc.camTabsWidth, - proc.camTabsCount, - proc.camTabsAngle - ).forEach(tab => { - const { o1, o2, c1, c2 } = tab; - const poly = newPolygon().addPoints([ - o1, c1, c2, o2 - ]); - clipTab.push(poly); - }); - } - // debug clipTab and clipTo if (debug_clips) { const debug = newSlice(-1); diff --git a/src/mode/fdm/client.js b/src/mode/fdm/client.js index 23840671..eec69ccb 100644 --- a/src/mode/fdm/client.js +++ b/src/mode/fdm/client.js @@ -79,6 +79,11 @@ } func.sdone() }); + api.event.on("selection.scale", () => { + if (isFdmMode) { + func.sclear(); + } + }); api.event.on("widget.rotate", rot => { if (!isFdmMode) { return;