remove dead tab code. clear tabs and supports on scale events
This commit is contained in:
parent
25e198ec5f
commit
d020a94b53
8 changed files with 14 additions and 126 deletions
1
notes.md
1
notes.md
|
|
@ -4,7 +4,6 @@
|
||||||
* cnc
|
* cnc
|
||||||
* tracing (chamfer, engrave)
|
* tracing (chamfer, engrave)
|
||||||
* auto feature detection (slicing)
|
* auto feature detection (slicing)
|
||||||
* add tabs to shadow and slice model (for topo)
|
|
||||||
* fdm
|
* fdm
|
||||||
* continuous printing (z belt systems)
|
* continuous printing (z belt systems)
|
||||||
* laser
|
* laser
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@
|
||||||
tnode.m_Childs.forEach(function(child) {
|
tnode.m_Childs.forEach(function(child) {
|
||||||
poly = fromClipperNode(child, z);
|
poly = fromClipperNode(child, z);
|
||||||
// throw out all tiny polygons
|
// throw out all tiny polygons
|
||||||
if (poly.area() < min) {
|
if (!poly.open && poly.area() < min) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (parent) {
|
if (parent) {
|
||||||
|
|
@ -99,7 +99,7 @@
|
||||||
|
|
||||||
tnode.m_Childs.forEach(function(child) {
|
tnode.m_Childs.forEach(function(child) {
|
||||||
poly = fromClipperNode(child, z);
|
poly = fromClipperNode(child, z);
|
||||||
if (minarea && poly.area() < minarea) {
|
if (!poly.open && minarea && poly.area() < minarea) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (parent) {
|
if (parent) {
|
||||||
|
|
|
||||||
|
|
@ -438,8 +438,6 @@
|
||||||
camDrillLift: 2,
|
camDrillLift: 2,
|
||||||
camDrillingOn: false,
|
camDrillingOn: false,
|
||||||
camDrillReg: "none",
|
camDrillReg: "none",
|
||||||
camTabsAngle: 0,
|
|
||||||
camTabsCount: 4,
|
|
||||||
camTabsWidth: 5,
|
camTabsWidth: 5,
|
||||||
camTabsHeight: 5,
|
camTabsHeight: 5,
|
||||||
camTabsOn: false,
|
camTabsOn: false,
|
||||||
|
|
|
||||||
|
|
@ -1547,10 +1547,6 @@
|
||||||
camTabs: UC.newGroup(LANG.ct_menu, null, {modes:CAM, marker:false}),
|
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}),
|
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}),
|
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"}),
|
camTabSep: UC.newBlank({class:"pop-sep"}),
|
||||||
camTabsManual: UC.newRow([
|
camTabsManual: UC.newRow([
|
||||||
(UI.tabAdd = UC.newButton(undefined, onButtonClick, {icon:'<i class="fas fa-plus"></i>'})),
|
(UI.tabAdd = UC.newButton(undefined, onButtonClick, {icon:'<i class="fas fa-plus"></i>'})),
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,12 @@
|
||||||
});
|
});
|
||||||
api.event.on("key.esc", () => {
|
api.event.on("key.esc", () => {
|
||||||
if (isCamMode) {
|
if (isCamMode) {
|
||||||
func.tdone()
|
func.tdone();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
api.event.on("selection.scale", () => {
|
||||||
|
if (isCamMode) {
|
||||||
|
func.tclear();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
api.event.on("widget.rotate", rot => {
|
api.event.on("widget.rotate", rot => {
|
||||||
|
|
|
||||||
|
|
@ -48,9 +48,6 @@
|
||||||
roughDown = procRough ? proc.camRoughDown : Infinity,
|
roughDown = procRough ? proc.camRoughDown : Infinity,
|
||||||
outlineDown = procOutline ? proc.camOutlineDown : Infinity,
|
outlineDown = procOutline ? proc.camOutlineDown : Infinity,
|
||||||
sliceDepth = Math.max(0.1, Math.min(roughDown, outlineDown) / 3),
|
sliceDepth = Math.max(0.1, Math.min(roughDown, outlineDown) / 3),
|
||||||
addTabsOutline = (procOutlineOn || procRough) && proc.camTabsOn,
|
|
||||||
tabWidth = proc.camTabsWidth,
|
|
||||||
tabHeight = proc.camTabsHeight,
|
|
||||||
bounds = widget.getBoundingBox(),
|
bounds = widget.getBoundingBox(),
|
||||||
mesh = widget.mesh,
|
mesh = widget.mesh,
|
||||||
zBottom = proc.camZBottom,
|
zBottom = proc.camZBottom,
|
||||||
|
|
@ -65,9 +62,6 @@
|
||||||
thruHoles,
|
thruHoles,
|
||||||
tabs = settings.widget[widget.id].tab;
|
tabs = settings.widget[widget.id].tab;
|
||||||
|
|
||||||
// force off for testing
|
|
||||||
proc.camTabsOn = false;
|
|
||||||
|
|
||||||
if (tabs) {
|
if (tabs) {
|
||||||
// make tab polygons
|
// make tab polygons
|
||||||
tabs.forEach(tab => {
|
tabs.forEach(tab => {
|
||||||
|
|
@ -301,9 +295,6 @@
|
||||||
const outside = POLY.offset(shadow.clone(), roughToolDiam * proc.camRoughOver, {z: slice.z});
|
const outside = POLY.offset(shadow.clone(), roughToolDiam * proc.camRoughOver, {z: slice.z});
|
||||||
if (outside) {
|
if (outside) {
|
||||||
offset.appendAll(outside);
|
offset.appendAll(outside);
|
||||||
// if (addTabsOutline && slice.z <= zMin + tabHeight) {
|
|
||||||
// offset = addCutoutTabs(offset, slice.z, center, roughToolDiam, tabWidth, proc.camTabsCount, proc.camTabsAngle);
|
|
||||||
// }
|
|
||||||
if (tabs) {
|
if (tabs) {
|
||||||
tabs.forEach(tab => {
|
tabs.forEach(tab => {
|
||||||
tab.off = POLY.expand([tab.poly], roughToolDiam / 2).flat();
|
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) {
|
if (tabs) {
|
||||||
tabs.forEach(tab => {
|
tabs.forEach(tab => {
|
||||||
tab.off = POLY.expand([tab.poly], outlineToolDiam / 2).flat();
|
tab.off = POLY.expand([tab.poly], outlineToolDiam / 2).flat();
|
||||||
|
|
@ -583,91 +571,4 @@
|
||||||
return noff;
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@
|
||||||
newslices = [],
|
newslices = [],
|
||||||
tabs = opt.tabs,
|
tabs = opt.tabs,
|
||||||
tabsMax = tabs ? Math.max(...tabs.map(tab => tab.dim.z)) : 0,
|
tabsMax = tabs ? Math.max(...tabs.map(tab => tab.dim.z)) : 0,
|
||||||
tabsOn = proc.camTabsOn || tabs,
|
tabsOn = tabs,
|
||||||
tabHeight = Math.max(proc.camTabsHeight + zBottom, tabsMax),
|
tabHeight = Math.max(proc.camTabsHeight + zBottom, tabsMax),
|
||||||
clipTab = tabsOn ? [] : null,
|
clipTab = tabsOn ? [] : null,
|
||||||
clipTo = inside ? shadow : POLY.expand(shadow, toolDiameter/2 + resolution * 3),
|
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());
|
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
|
// debug clipTab and clipTo
|
||||||
if (debug_clips) {
|
if (debug_clips) {
|
||||||
const debug = newSlice(-1);
|
const debug = newSlice(-1);
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,11 @@
|
||||||
}
|
}
|
||||||
func.sdone()
|
func.sdone()
|
||||||
});
|
});
|
||||||
|
api.event.on("selection.scale", () => {
|
||||||
|
if (isFdmMode) {
|
||||||
|
func.sclear();
|
||||||
|
}
|
||||||
|
});
|
||||||
api.event.on("widget.rotate", rot => {
|
api.event.on("widget.rotate", rot => {
|
||||||
if (!isFdmMode) {
|
if (!isFdmMode) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue