move overrides to top of common slice code. add support to roughing
This commit is contained in:
parent
33b6245297
commit
6b207cbf7d
4 changed files with 39 additions and 26 deletions
|
|
@ -350,7 +350,7 @@ module.exports = async (server) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// request system info
|
// request system info
|
||||||
false && mqtt.send({
|
mqtt.send({
|
||||||
info: {
|
info: {
|
||||||
command: "get_version"
|
command: "get_version"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1333,6 +1333,9 @@ CAM.init = function(kiri, api) {
|
||||||
voids: 'camRoughVoid',
|
voids: 'camRoughVoid',
|
||||||
flats: 'camRoughFlat',
|
flats: 'camRoughFlat',
|
||||||
inside: 'camRoughIn',
|
inside: 'camRoughIn',
|
||||||
|
ov_topz: 0,
|
||||||
|
ov_botz: 0,
|
||||||
|
ov_conv: '~camConventional',
|
||||||
}).inputs = {
|
}).inputs = {
|
||||||
tool: UC.newSelect(LANG.cc_tool, {}, "tools"),
|
tool: UC.newSelect(LANG.cc_tool, {}, "tools"),
|
||||||
sep: UC.newBlank({class:"pop-sep"}),
|
sep: UC.newBlank({class:"pop-sep"}),
|
||||||
|
|
@ -1348,7 +1351,13 @@ CAM.init = function(kiri, api) {
|
||||||
all: UC.newBoolean(LANG.cr_clst_s, undefined, {title:LANG.cr_clst_l, show:hasIndexing}),
|
all: UC.newBoolean(LANG.cr_clst_s, undefined, {title:LANG.cr_clst_l, show:hasIndexing}),
|
||||||
voids: UC.newBoolean(LANG.cr_clrp_s, undefined, {title:LANG.cr_clrp_l}),
|
voids: UC.newBoolean(LANG.cr_clrp_s, undefined, {title:LANG.cr_clrp_l}),
|
||||||
flats: UC.newBoolean(LANG.cr_clrf_s, undefined, {title:LANG.cr_clrf_l}),
|
flats: UC.newBoolean(LANG.cr_clrf_s, undefined, {title:LANG.cr_clrf_l}),
|
||||||
inside: UC.newBoolean(LANG.cr_olin_s, undefined, {title:LANG.cr_olin_l})
|
inside: UC.newBoolean(LANG.cr_olin_s, undefined, {title:LANG.cr_olin_l}),
|
||||||
|
sep: UC.newBlank({class:"pop-sep"}),
|
||||||
|
exp: UC.newExpand("overrides"),
|
||||||
|
ov_topz: UC.newInput(LANG.ou_ztop_s, {title:LANG.ou_ztop_l, convert:UC.toFloat, units:true}),
|
||||||
|
ov_botz: UC.newInput(LANG.ou_zbot_s, {title:LANG.ou_zbot_l, convert:UC.toFloat, units:true}),
|
||||||
|
ov_conv: UC.newBoolean(LANG.ou_conv_s, undefined, {title:LANG.ou_conv_l}),
|
||||||
|
exp_end: UC.endExpand(),
|
||||||
};
|
};
|
||||||
|
|
||||||
createPopOp('outline', {
|
createPopOp('outline', {
|
||||||
|
|
@ -1365,7 +1374,10 @@ CAM.init = function(kiri, api) {
|
||||||
outside: 'camOutlineOut',
|
outside: 'camOutlineOut',
|
||||||
inside: 'camOutlineIn',
|
inside: 'camOutlineIn',
|
||||||
wide: 'camOutlineWide',
|
wide: 'camOutlineWide',
|
||||||
top: 'camOutlineTop'
|
top: 'camOutlineTop',
|
||||||
|
ov_topz: 0,
|
||||||
|
ov_botz: 0,
|
||||||
|
ov_conv: '~camConventional',
|
||||||
}).inputs = {
|
}).inputs = {
|
||||||
tool: UC.newSelect(LANG.cc_tool, {}, "tools"),
|
tool: UC.newSelect(LANG.cc_tool, {}, "tools"),
|
||||||
sep: UC.newBlank({class:"pop-sep"}),
|
sep: UC.newBlank({class:"pop-sep"}),
|
||||||
|
|
@ -1384,6 +1396,12 @@ CAM.init = function(kiri, api) {
|
||||||
omitvoid: UC.newBoolean(LANG.co_omvd_s, undefined, {title:LANG.co_omvd_l, xshow:(op) => { return op.inputs.outside.checked }}),
|
omitvoid: UC.newBoolean(LANG.co_omvd_s, undefined, {title:LANG.co_omvd_l, xshow:(op) => { return op.inputs.outside.checked }}),
|
||||||
wide: UC.newBoolean(LANG.co_wide_s, undefined, {title:LANG.co_wide_l, show:(op) => { return !op.inputs.inside.checked }}),
|
wide: UC.newBoolean(LANG.co_wide_s, undefined, {title:LANG.co_wide_l, show:(op) => { return !op.inputs.inside.checked }}),
|
||||||
dogbones: UC.newBoolean(LANG.co_dogb_s, undefined, {title:LANG.co_dogb_l, show:(op) => { return !op.inputs.wide.checked }}),
|
dogbones: UC.newBoolean(LANG.co_dogb_s, undefined, {title:LANG.co_dogb_l, show:(op) => { return !op.inputs.wide.checked }}),
|
||||||
|
sep: UC.newBlank({class:"pop-sep"}),
|
||||||
|
exp: UC.newExpand("overrides"),
|
||||||
|
ov_topz: UC.newInput(LANG.ou_ztop_s, {title:LANG.ou_ztop_l, convert:UC.toFloat, units:true}),
|
||||||
|
ov_botz: UC.newInput(LANG.ou_zbot_s, {title:LANG.ou_zbot_l, convert:UC.toFloat, units:true}),
|
||||||
|
ov_conv: UC.newBoolean(LANG.ou_conv_s, undefined, {title:LANG.ou_conv_l}),
|
||||||
|
exp_end: UC.endExpand(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const contourFilter = gcodeEditor('Layer Filter', 'filter');
|
const contourFilter = gcodeEditor('Layer Filter', 'filter');
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,7 @@ class OpRough extends CamOp {
|
||||||
let { op, state } = this;
|
let { op, state } = this;
|
||||||
let { settings, slicer, addSlices, unsafe, color } = state;
|
let { settings, slicer, addSlices, unsafe, color } = state;
|
||||||
let { updateToolDiams, thruHoles, tabs, cutTabs, cutPolys } = state;
|
let { updateToolDiams, thruHoles, tabs, cutTabs, cutPolys } = state;
|
||||||
let { ztOff, zBottom, zMax, shadowAt, isIndexed} = state;
|
let { ztOff, zMax, shadowAt, isIndexed} = state;
|
||||||
let { workarea } = state;
|
let { workarea } = state;
|
||||||
let { process, stock } = settings;
|
let { process, stock } = settings;
|
||||||
|
|
||||||
|
|
@ -242,7 +242,7 @@ class OpRough extends CamOp {
|
||||||
.filter(row => row[1] > flatArea)
|
.filter(row => row[1] > flatArea)
|
||||||
.map(row => row[0])
|
.map(row => row[0])
|
||||||
.map(v => parseFloat(v).round(5))
|
.map(v => parseFloat(v).round(5))
|
||||||
.filter(v => v >= zBottom);
|
.filter(v => v >= workarea.bottom_z);
|
||||||
flats.forEach(v => {
|
flats.forEach(v => {
|
||||||
if (!indices.contains(v)) {
|
if (!indices.contains(v)) {
|
||||||
indices.push(v);
|
indices.push(v);
|
||||||
|
|
@ -270,7 +270,7 @@ class OpRough extends CamOp {
|
||||||
indices = indices.appendAll(flats).sort((a,b) => b-a);
|
indices = indices.appendAll(flats).sort((a,b) => b-a);
|
||||||
}
|
}
|
||||||
|
|
||||||
indices = indices.filter(v => v >= zBottom);
|
indices = indices.filter(v => v >= workarea.bottom_z);
|
||||||
// console.log('indices', ...indices, {zBottom});
|
// console.log('indices', ...indices, {zBottom});
|
||||||
|
|
||||||
let cnt = 0;
|
let cnt = 0;
|
||||||
|
|
@ -437,7 +437,7 @@ class OpRough extends CamOp {
|
||||||
let { process } = settings;
|
let { process } = settings;
|
||||||
|
|
||||||
let easeDown = process.camEaseDown;
|
let easeDown = process.camEaseDown;
|
||||||
let cutdir = process.camConventional;
|
let cutdir = op.ov_conv;
|
||||||
let depthFirst = process.camDepthFirst && !state.isIndexed;
|
let depthFirst = process.camDepthFirst && !state.isIndexed;
|
||||||
let depthData = [];
|
let depthData = [];
|
||||||
|
|
||||||
|
|
@ -684,7 +684,7 @@ class OpOutline extends CamOp {
|
||||||
|
|
||||||
let easeDown = process.camEaseDown;
|
let easeDown = process.camEaseDown;
|
||||||
let toolDiam = this.toolDiam;
|
let toolDiam = this.toolDiam;
|
||||||
let cutdir = process.camConventional;
|
let cutdir = op.ov_conv;//process.camConventional;
|
||||||
let depthFirst = process.camDepthFirst;
|
let depthFirst = process.camDepthFirst;
|
||||||
let depthData = [];
|
let depthData = [];
|
||||||
|
|
||||||
|
|
@ -962,11 +962,6 @@ class OpTrace extends CamOp {
|
||||||
if (state.isIndexed) {
|
if (state.isIndexed) {
|
||||||
throw 'trace op not supported with indexed stock';
|
throw 'trace op not supported with indexed stock';
|
||||||
}
|
}
|
||||||
// apply overrides
|
|
||||||
workarea.recalc({
|
|
||||||
top_z: ov_topz,
|
|
||||||
bottom_z: ov_botz
|
|
||||||
});
|
|
||||||
// generate tracing offsets from chosen features
|
// generate tracing offsets from chosen features
|
||||||
let zTop = workarea.top_z;
|
let zTop = workarea.top_z;
|
||||||
let zBottom = workarea.bottom_z;
|
let zBottom = workarea.bottom_z;
|
||||||
|
|
@ -1203,11 +1198,6 @@ class OpPocket extends CamOp {
|
||||||
let { settings, widget, addSlices, zBottom, zThru, tabs, color } = state;
|
let { settings, widget, addSlices, zBottom, zThru, tabs, color } = state;
|
||||||
let { updateToolDiams, cutTabs, healPolys, shadowAt, workarea } = state;
|
let { updateToolDiams, cutTabs, healPolys, shadowAt, workarea } = state;
|
||||||
let { process } = settings;
|
let { process } = settings;
|
||||||
// apply overrides
|
|
||||||
workarea.recalc({
|
|
||||||
top_z: ov_topz,
|
|
||||||
bottom_z: ov_botz
|
|
||||||
});
|
|
||||||
zBottom = ov_botz ? workarea.bottom_stock + ov_botz : zBottom;
|
zBottom = ov_botz ? workarea.bottom_stock + ov_botz : zBottom;
|
||||||
// generate tracing offsets from chosen features
|
// generate tracing offsets from chosen features
|
||||||
let sliceOut;
|
let sliceOut;
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ CAM.slice = async function(settings, widget, onupdate, ondone) {
|
||||||
bottom_stock = -bottom_gap,
|
bottom_stock = -bottom_gap,
|
||||||
bottom_thru = zThru,
|
bottom_thru = zThru,
|
||||||
bottom_z = Math.max(
|
bottom_z = Math.max(
|
||||||
(camZBottom ? bottom_stock + proc.camZBottom : bottom_part) - bottom_thru,
|
(camZBottom ? bottom_stock + camZBottom : bottom_part) - bottom_thru,
|
||||||
(camZBottom ? bottom_stock + camZBottom : bottom_stock - bottom_thru)
|
(camZBottom ? bottom_stock + camZBottom : bottom_stock - bottom_thru)
|
||||||
),
|
),
|
||||||
bottom_cut = Math.max(bottom_z, -zThru),
|
bottom_cut = Math.max(bottom_z, -zThru),
|
||||||
|
|
@ -84,12 +84,7 @@ CAM.slice = async function(settings, widget, onupdate, ondone) {
|
||||||
bottom_part,
|
bottom_part,
|
||||||
bottom_gap,
|
bottom_gap,
|
||||||
bottom_z,
|
bottom_z,
|
||||||
bottom_cut,
|
bottom_cut
|
||||||
recalc(val) {
|
|
||||||
if (val.top_z) workarea.top_z = bottom_stock + val.top_z;
|
|
||||||
if (val.bottom_z) workarea.bottom_z = bottom_stock + val.bottom_z;
|
|
||||||
if (val.bottom_z) workarea.bottom_cut = Math.max(workarea.bottom_z, -zThru)
|
|
||||||
}
|
|
||||||
}, 3);
|
}, 3);
|
||||||
|
|
||||||
// console.table({ workarea });
|
// console.table({ workarea });
|
||||||
|
|
@ -240,7 +235,7 @@ CAM.slice = async function(settings, widget, onupdate, ondone) {
|
||||||
unsafe,
|
unsafe,
|
||||||
color,
|
color,
|
||||||
dark,
|
dark,
|
||||||
workarea
|
// workarea
|
||||||
};
|
};
|
||||||
|
|
||||||
let opList = [
|
let opList = [
|
||||||
|
|
@ -273,9 +268,19 @@ CAM.slice = async function(settings, widget, onupdate, ondone) {
|
||||||
|
|
||||||
// call slice() function on all ops in order
|
// call slice() function on all ops in order
|
||||||
let tracker = setSliceTracker({ rotation: 0 });
|
let tracker = setSliceTracker({ rotation: 0 });
|
||||||
|
let workarea_orig = structuredClone(workarea);
|
||||||
setAxisIndex();
|
setAxisIndex();
|
||||||
for (let op of opList) {
|
for (let op of opList) {
|
||||||
let weight = op.weight();
|
let weight = op.weight();
|
||||||
|
// apply operation override vars
|
||||||
|
let workover = structuredClone(workarea_orig);
|
||||||
|
let valz = op.op;
|
||||||
|
if (valz.ov_topz) workover.top_z = bottom_stock + valz.ov_topz;
|
||||||
|
if (valz.ov_botz) {
|
||||||
|
workover.bottom_z = bottom_stock + valz.ov_botz;
|
||||||
|
workover.bottom_cut = Math.max(workover.bottom_z, -zThru);
|
||||||
|
}
|
||||||
|
state.workarea = workover;
|
||||||
await op.slice((progress, message) => {
|
await op.slice((progress, message) => {
|
||||||
onupdate((opSum + (progress * weight)) / opTot, message || op.type());
|
onupdate((opSum + (progress * weight)) / opTot, message || op.type());
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue