checkpoint outline refactor

This commit is contained in:
Stewart Allen 2020-11-03 22:56:55 -05:00
commit 521dfa058e
4 changed files with 92 additions and 90 deletions

View file

@ -209,8 +209,7 @@
finishingOver: "camContourOver", finishingOver: "camContourOver",
finishingSpeed: "camOutlineSpeed", finishingSpeed: "camOutlineSpeed",
finishingPlunge: "camOutlinePlunge", finishingPlunge: "camOutlinePlunge",
camOutlineOn: "camOutlineOut", finishingOn: "camOutlineOn",
finishingOn: "camOutlineOut",
finishingXOn: "camContourXOn", finishingXOn: "camContourXOn",
finishingYOn: "camContourYOn", finishingYOn: "camContourYOn",
drillTool: "camDrillTool", drillTool: "camDrillTool",
@ -413,7 +412,7 @@
camOutlinePlunge: 250, camOutlinePlunge: 250,
camOutlineWide: false, camOutlineWide: false,
camOutlineIn: false, camOutlineIn: false,
camOutlineOut: false, camOutlineOn: false,
camContourTool: 1000, camContourTool: 1000,
camContourSpindle: 1000, camContourSpindle: 1000,
camContourOver: 0.5, camContourOver: 0.5,

View file

@ -1412,10 +1412,10 @@
camOutlineDown: UC.newInput(LANG.cc_sdwn_s, {title:LANG.cc_sdwn_l, convert:UC.toFloat, modes:CAM}), camOutlineDown: UC.newInput(LANG.cc_sdwn_s, {title:LANG.cc_sdwn_l, convert:UC.toFloat, modes:CAM}),
camOutlineSpeed: UC.newInput(LANG.cc_feed_s, {title:LANG.cc_feed_l, convert:UC.toInt, modes:CAM}), camOutlineSpeed: UC.newInput(LANG.cc_feed_s, {title:LANG.cc_feed_l, convert:UC.toInt, modes:CAM}),
camOutlinePlunge: UC.newInput(LANG.cc_plng_s, {title:LANG.cc_plng_l, convert:UC.toInt, modes:CAM}), camOutlinePlunge: UC.newInput(LANG.cc_plng_s, {title:LANG.cc_plng_l, convert:UC.toInt, modes:CAM}),
camOutlineWide: UC.newBoolean(LANG.co_wide_s, onBooleanClick, {title:LANG.co_wide_l, modes:CAM, show:() => { return UI.camOutlineOut.checked }}), camOutlineWide: UC.newBoolean(LANG.co_wide_s, onBooleanClick, {title:LANG.co_wide_l, modes:CAM, show:() => { return !UI.camOutlineIn.checked }}),
camOutlineSep: UC.newBlank({class:"pop-sep"}),
camOutlineIn: UC.newBoolean(LANG.co_olin_s, onBooleanClick, {title:LANG.co_olin_l, modes:CAM}), camOutlineIn: UC.newBoolean(LANG.co_olin_s, onBooleanClick, {title:LANG.co_olin_l, modes:CAM}),
camOutlineOut: UC.newBoolean(LANG.co_olot_s, onBooleanClick, {title:LANG.co_olot_l, modes:CAM}), camOutlineSep: UC.newBlank({class:"pop-sep"}),
camOutlineOn: UC.newBoolean(LANG.co_olen_s, onBooleanClick, {title:LANG.co_olen_l, modes:CAM}),
camContour: UC.newGroup(LANG.cn_menu, null, {modes:CAM, marker:true}), camContour: UC.newGroup(LANG.cn_menu, null, {modes:CAM, marker:true}),
camContourTool: UC.newSelect(LANG.cc_tool, {modes:CAM}), camContourTool: UC.newSelect(LANG.cc_tool, {modes:CAM}),
camContourSpindle: UC.newInput(LANG.cc_spnd_s, {title:LANG.cc_spnd_l, convert:UC.toInt, modes:CAM, visible:spindleShow}), camContourSpindle: UC.newInput(LANG.cc_spnd_s, {title:LANG.cc_spnd_l, convert:UC.toInt, modes:CAM, visible:spindleShow}),
@ -1442,7 +1442,7 @@
camDrillingOn: UC.newBoolean(LANG.enable, onBooleanClick, {modes:CAM}), camDrillingOn: UC.newBoolean(LANG.enable, onBooleanClick, {modes:CAM}),
camDrillSep: UC.newBlank({class:"pop-sep"}), camDrillSep: UC.newBlank({class:"pop-sep"}),
camDrillReg: UC.newSelect(LANG.cd_regi_s, {modes:CAM, title:LANG.cd_regi_l}, "drillreg"), camDrillReg: UC.newSelect(LANG.cd_regi_s, {modes:CAM, title:LANG.cd_regi_l}, "drillreg"),
camTabs: UC.newGroup(LANG.ct_menu, null, {modes:CAM, marker:true, show:() => { return UI.camOutlineOut.checked }}), camTabs: UC.newGroup(LANG.ct_menu, null, {modes:CAM, marker:true, show:() => { return UI.camOutlineOn.checked }}),
camTabsAngle: UC.newInput(LANG.ct_angl_s, {title:LANG.ct_angl_l, convert:UC.toInt, bound:UC.bound(0,360), modes:CAM}), 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}), camTabsCount: UC.newInput(LANG.ct_numb_s, {title:LANG.ct_numb_l, convert:UC.toInt, bound:UC.bound(1,20), modes:CAM}),
camTabsWidth: UC.newInput(LANG.ct_wdth_s, {title:LANG.ct_wdth_l, convert:UC.toFloat, bound:UC.bound(0.1,100), modes:CAM}), camTabsWidth: UC.newInput(LANG.ct_wdth_s, {title:LANG.ct_wdth_l, convert:UC.toFloat, bound:UC.bound(0.1,100), modes:CAM}),
@ -1459,9 +1459,9 @@
camCommon: UC.newGroup(LANG.cc_menu, null, {modes:CAM}), camCommon: UC.newGroup(LANG.cc_menu, null, {modes:CAM}),
camZTopOffset: UC.newInput(LANG.ou_ztof_s, {title:LANG.ou_ztof_l, convert:UC.toFloat, modes:CAM}), camZTopOffset: UC.newInput(LANG.ou_ztof_s, {title:LANG.ou_ztof_l, convert:UC.toFloat, modes:CAM}),
camZBottom: UC.newInput(LANG.ou_zbot_s, {title:LANG.ou_zbot_l, convert:UC.toFloat, modes:CAM}), camZBottom: UC.newInput(LANG.ou_zbot_s, {title:LANG.ou_zbot_l, convert:UC.toFloat, modes:CAM, trigger: true}),
camZClearance: UC.newInput(LANG.ou_zclr_s, {title:LANG.ou_zclr_l, convert:UC.toFloat, bound:UC.bound(0.01,100), modes:CAM}), camZClearance: UC.newInput(LANG.ou_zclr_s, {title:LANG.ou_zclr_l, convert:UC.toFloat, bound:UC.bound(0.01,100), modes:CAM}),
camZThru: UC.newInput(LANG.ou_ztru_s, {title:LANG.ou_ztru_l, convert:UC.toFloat, bound:UC.bound(0.0,100), modes:CAM}), camZThru: UC.newInput(LANG.ou_ztru_s, {title:LANG.ou_ztru_l, convert:UC.toFloat, bound:UC.bound(0.0,100), modes:CAM, show:() => { return UI.camZBottom.value == 0 }}),
camFastFeedZ: UC.newInput(LANG.cc_rzpd_s, {title:LANG.cc_rzpd_l, convert:UC.toInt, modes:CAM}), camFastFeedZ: UC.newInput(LANG.cc_rzpd_s, {title:LANG.cc_rzpd_l, convert:UC.toInt, modes:CAM}),
camFastFeed: UC.newInput(LANG.cc_rapd_s, {title:LANG.cc_rapd_l, convert:UC.toInt, modes:CAM}), camFastFeed: UC.newInput(LANG.cc_rapd_s, {title:LANG.cc_rapd_l, convert:UC.toInt, modes:CAM}),
camTolerance: UC.newInput(LANG.ou_toll_s, {title:LANG.ou_toll_l, convert:UC.toFloat, bound:UC.bound(0.001,1.0), modes:CAM}), camTolerance: UC.newInput(LANG.ou_toll_s, {title:LANG.ou_toll_l, convert:UC.toFloat, bound:UC.bound(0.001,1.0), modes:CAM}),

View file

@ -60,8 +60,7 @@
api.ui.camRough.marker.style.display = proc.camRoughOn ? 'flex' : 'none'; api.ui.camRough.marker.style.display = proc.camRoughOn ? 'flex' : 'none';
api.ui.camDrill.marker.style.display = api.ui.camDrill.marker.style.display =
proc.camDrillingOn || proc.camDrillReg !== 'none' ? 'flex' : 'none'; proc.camDrillingOn || proc.camDrillReg !== 'none' ? 'flex' : 'none';
api.ui.camOutline.marker.style.display = api.ui.camOutline.marker.style.display = proc.camOutlineOn ? 'flex' : 'none';
proc.camOutlineIn || proc.camOutlineOut ? 'flex' : 'none';
api.ui.camContour.marker.style.display = api.ui.camContour.marker.style.display =
proc.camContourXOn || proc.camContourYOn ? 'flex' : 'none'; proc.camContourXOn || proc.camContourYOn ? 'flex' : 'none';
}); });
@ -776,15 +775,13 @@
* @param {boolean} outside emit polys outside part boundaries * @param {boolean} outside emit polys outside part boundaries
* @param {boolean} wide expand outside poly cuts * @param {boolean} wide expand outside poly cuts
*/ */
function createOutlinePaths(slice, shell, diameter, inside, outside, wide) { function createOutlinePaths(slice, shell, diameter, inside, wide) {
if (slice.tops.length === 0) return shell; let tops = slice.shadow.clone(true);
let tops = slice.gatherTopPolys([]).clone(inside);
let offset = POLY.expand(tops, diameter / 2, slice.z); let offset = POLY.expand(tops, diameter / 2, slice.z);
// when pocket only, drop first outer poly // when pocket only, drop first outer poly
// if it matches the shell and promote inner polys // if it matches the shell and promote inner polys
if (!outside) { if (inside) {
offset = POLY.filter(POLY.diff(shell, offset, slice.z), [], function(poly) { offset = POLY.filter(POLY.diff(shell, offset, slice.z), [], function(poly) {
if (poly.area() < 1) { if (poly.area() < 1) {
return null; return null;
@ -807,14 +804,6 @@
const output = POLY.flatten(offset, [], true); const output = POLY.flatten(offset, [], true);
slice.tops[0].traces = output; slice.tops[0].traces = output;
// append inner traces from findTracingPaths
let inner = slice.tops[0].inner;
if (inner) {
// console.log(slice.z,'inner',inner.length)
// output.append(...inner);
// slice.tops[0].inner = null;
}
}; };
/** /**
@ -836,9 +825,9 @@
procFacing = false && proc.camRoughOn && proc.camZTopOffset, procFacing = false && proc.camRoughOn && proc.camZTopOffset,
procRough = proc.camRoughOn && proc.camRoughDown && roughToolDiam, procRough = proc.camRoughOn && proc.camRoughDown && roughToolDiam,
procOutlineIn = proc.camOutlineIn, procOutlineIn = proc.camOutlineIn,
procOutlineOut = proc.camOutlineOut, procOutlineOn = proc.camOutlineOn,
procOutlineWide = proc.camOutlineWide, procOutlineWide = proc.camOutlineWide,
procOutline = (procOutlineIn || procOutlineOut) && proc.camOutlineDown && outlineToolDiam, procOutline = procOutlineOn && proc.camOutlineDown && outlineToolDiam,
procContourX = proc.camContourXOn && proc.camOutlinePlunge && contourToolDiam, procContourX = proc.camContourXOn && proc.camOutlinePlunge && contourToolDiam,
procContourY = proc.camContourYOn && proc.camOutlinePlunge && contourToolDiam, procContourY = proc.camContourYOn && proc.camOutlinePlunge && contourToolDiam,
procContour = procContourX || procContourY, procContour = procContourX || procContourY,
@ -848,14 +837,14 @@
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 * units), sliceDepth = Math.max(0.1, Math.min(roughDown, outlineDown) / 3 * units),
addTabsOutline = procOutlineOut && proc.camTabsOn, addTabsOutline = procOutlineOn && proc.camTabsOn,
tabWidth = proc.camTabsWidth * units, tabWidth = proc.camTabsWidth * units,
tabHeight = proc.camTabsHeight * units, tabHeight = proc.camTabsHeight * units,
bounds = widget.getBoundingBox(), bounds = widget.getBoundingBox(),
mesh = widget.mesh, mesh = widget.mesh,
zBottom = proc.camZBottom * units, zBottom = proc.camZBottom * units,
zMin = Math.max(bounds.min.z, zBottom), zMin = Math.max(bounds.min.z, zBottom),
zThru = (proc.camZThru || 0) * units, zThru = zBottom === 0 ? (proc.camZThru || 0) * units : 0,
ztoff = proc.camZTopOffset * units, ztoff = proc.camZTopOffset * units,
camRoughStock = proc.camRoughStock * units, camRoughStock = proc.camRoughStock * units,
camRoughDown = proc.camRoughDown * units, camRoughDown = proc.camRoughDown * units,
@ -961,28 +950,16 @@
slice.tops[0].traces = nutrace; slice.tops[0].traces = nutrace;
} }
// extend bottom cutout
const addZThru = function(selected) {
let last = selected[selected.length-1];
let add = last.clone(true);
add.camMode = last.camMode;
add.z -= zThru;
add.tops.forEach(top => {
top.poly.setZ(add.z);
});
selected.push(add);
};
// called when z-index slicing complete // called when z-index slicing complete
const camSlicesDone = function(slices) { const camSlicesDone = function(slices) {
// return outermost (bottom layer) "top" polys // return outermost (bottom layer) "top" polys
const camShell = pancake(slices, function(update) { // const camShell = pancake(slices, function(update) {
onupdate(0.25 + update * 0.15, "shelling"); // onupdate(0.25 + update * 0.15, "shelling");
}); // });
//
// set all default shells // // set all default shells
const camShellPolys = shellOutline = facePolys = camShell.gatherTopPolys([]); // const camShellPolys = shellOutline = facePolys = camShell.gatherTopPolys([]);
if (procDrillReg) { if (procDrillReg) {
sliceDrillReg(settings, widget, sliceAll, zThru); sliceDrillReg(settings, widget, sliceAll, zThru);
@ -992,45 +969,45 @@
sliceDrill(settings, widget, slices, sliceAll); sliceDrill(settings, widget, slices, sliceAll);
} }
if (procOutline) { // if (procOutline) {
if (!procOutlineOut) { // if (!procOutlineOn) {
// expand shell minimally triggering a clean // // expand shell minimally triggering a clean
shellOutline = POLY.expand(shellOutline, -outlineToolDiam / 2, 0); // shellOutline = POLY.expand(shellOutline, -outlineToolDiam / 2, 0);
} else { // } else {
// expand shell by half tool diameter (not needed because only one offset) // // expand shell by half tool diameter (not needed because only one offset)
// shellOutline = POLY.expand(shellOutline, outlineToolDiam / 2, 0); // // shellOutline = POLY.expand(shellOutline, outlineToolDiam / 2, 0);
} // }
} // }
// clear area from top of stock to top of part // clear area from top of stock to top of part
if (procFacing) { // if (procFacing) {
let ztop = bounds.max.z, // let ztop = bounds.max.z,
zpos = ztop + ztoff, // zpos = ztop + ztoff,
zstep = camRoughDown; // zstep = camRoughDown;
//
// while (zpos >= ztop) {
// zpos = zpos - Math.min(zstep, zpos - ztop);
//
// const slice = newSlice(zpos, mesh.newGroup ? mesh.newGroup() : null);
// slice.camMode = CPRO.LEVEL;
// sliceAll.append(slice);
//
// shellRough.clone().forEach(function(poly) {
// slice.addTop(poly);
// })
//
// if (Math.abs(zpos - ztop) < 0.001) break;
// }
// }
while (zpos >= ztop) { // if (procOutline) {
zpos = zpos - Math.min(zstep, zpos - ztop); // let selected = [];
// selectSlices(slices, proc.camOutlineDown * units, CPRO.OUTLINE, selected);
const slice = newSlice(zpos, mesh.newGroup ? mesh.newGroup() : null); // if (zThru) {
slice.camMode = CPRO.LEVEL; // addZThru(selected);
sliceAll.append(slice); // }
// sliceAll.appendAll(selected);
shellRough.clone().forEach(function(poly) { // }
slice.addTop(poly);
})
if (Math.abs(zpos - ztop) < 0.001) break;
}
}
if (procOutline) {
let selected = [];
selectSlices(slices, proc.camOutlineDown * units, CPRO.OUTLINE, selected);
if (zThru) {
addZThru(selected);
}
sliceAll.appendAll(selected);
}
} }
let slicer = new KIRI.slicer2(widget.getPoints(), { let slicer = new KIRI.slicer2(widget.getPoints(), {
@ -1045,14 +1022,14 @@
} }); } });
console.log({slicer, tzindex, tshadow, terrain}); console.log({slicer, tzindex, tshadow, terrain});
// do creating roughing slices // creating roughing slices
if (procRough) { if (procRough) {
// identify through holes // identify through holes
thruHoles = tshadow.map(p => p.inner || []).flat(); thruHoles = tshadow.map(p => p.inner || []).flat();
let shadow = []; let shadow = [];
let slices = []; let slices = [];
slicer.slice(slicer.interval(roughDown, { down: true }), { each: (data, index, total) => { slicer.slice(slicer.interval(roughDown, { down: true, min: zBottom }), { each: (data, index, total) => {
shadow = POLY.union(shadow.appendAll(data.tops), 0.01, true); shadow = POLY.union(shadow.appendAll(data.tops), 0.01, true);
data.shadow = shadow.clone(true); data.shadow = shadow.clone(true);
data.slice.camMode = CPRO.ROUGH; data.slice.camMode = CPRO.ROUGH;
@ -1081,8 +1058,34 @@
// expand shadow by half tool diameter + stock to leave // expand shadow by half tool diameter + stock to leave
shellRough = POLY.offset(shadow, (roughToolDiam / 4) + camRoughStock); shellRough = POLY.offset(shadow, (roughToolDiam / 4) + camRoughStock);
sliceAll.appendAll(slices);
}
// creating outline slices
if (procOutline) {
let shadow = [];
let slices = [];
slicer.slice(slicer.interval(outlineDown, { down: true, min: zBottom }), { each: (data, index, total) => {
shadow = POLY.union(shadow.appendAll(data.tops), 0.01, true);
data.shadow = shadow.clone(true);
data.slice.camMode = CPRO.OUTLINE;
data.slice.shadow = data.shadow;
slices.push(data.slice);
}, genso: true });
shellOutline = tshadow;
// extend cut thru (only when z bottom is 0)
if (zThru) { if (zThru) {
addZThru(slices); let last = slices[slices.length-1];
let add = last.clone(true);
add.camMode = last.camMode;
add.tops.forEach(top => {
top.poly.setZ(add.z);
});
add.shadow = last.shadow.clone(true);
add.z -= zThru;
slices.push(add);
} }
sliceAll.appendAll(slices); sliceAll.appendAll(slices);
@ -1129,7 +1132,7 @@
createRoughPaths(slice, shellRough, roughToolDiam, camRoughStock, proc.camRoughOver, thruHoles); createRoughPaths(slice, shellRough, roughToolDiam, camRoughStock, proc.camRoughOver, thruHoles);
break; break;
case CPRO.OUTLINE: case CPRO.OUTLINE:
createOutlinePaths(slice, shellOutline, outlineToolDiam, procOutlineIn, procOutlineOut, procOutlineWide); createOutlinePaths(slice, shellOutline, outlineToolDiam, procOutlineIn, procOutlineWide);
if (addTabsOutline) addCutoutTabs(slice, outlineToolDiam); if (addTabsOutline) addCutoutTabs(slice, outlineToolDiam);
if (traceToolProfile) findTracingPaths(widget, slice, traceTool, traceToolProfile); if (traceToolProfile) findTracingPaths(widget, slice, traceTool, traceToolProfile);
break; break;

View file

@ -269,10 +269,10 @@ kiri.lang['en-us'] = {
co_menu: "outline", co_menu: "outline",
co_wide_s: "wide cutout", co_wide_s: "wide cutout",
co_wide_l: "widen outside cutout paths\nfor deep cuts in hard material", co_wide_l: "widen outside cutout paths\nfor deep cuts in hard material",
co_olin_s: "inside", co_olin_s: "inside only",
co_olin_l: "enable outline cutting\ninside part boundaries", co_olin_l: "limit cutting to\ninside part boundaries",
co_olot_s: "outside", co_olen_s: "enable",
co_olot_l: "enabled outline cutting\noutside part boundaries", co_olen_l: "enabled outline cutting",
// CNC CONTOUR // CNC CONTOUR
cn_menu: "contour", cn_menu: "contour",