remove dead tab code. clear tabs and supports on scale events

This commit is contained in:
Stewart Allen 2020-11-26 00:14:45 -05:00
commit d020a94b53
8 changed files with 14 additions and 126 deletions

View file

@ -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

View file

@ -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) {

View file

@ -438,8 +438,6 @@
camDrillLift: 2,
camDrillingOn: false,
camDrillReg: "none",
camTabsAngle: 0,
camTabsCount: 4,
camTabsWidth: 5,
camTabsHeight: 5,
camTabsOn: false,

View file

@ -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:'<i class="fas fa-plus"></i>'})),

View file

@ -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 => {

View file

@ -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<ints.length; i+=2) {
const seg = trace.emitSegment(ints[i], ints[i+1]);
// const col = [0x0000ff,0x009900,0x999900];
// seg.setZ(seg.getZ()+i);
// seg.points.forEach((p,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<il; j++) {
let sj = segs[j];
if (sj.overlaps(si)) {
if (sj.perimeter() > 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;
}
})();

View file

@ -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);

View file

@ -79,6 +79,11 @@
}
func.sdone()
});
api.event.on("selection.scale", () => {
if (isFdmMode) {
func.sclear();
}
});
api.event.on("widget.rotate", rot => {
if (!isFdmMode) {
return;