complete first iteration of pocket + contour
This commit is contained in:
parent
5a05f77273
commit
943b4e0d7c
3 changed files with 60 additions and 35 deletions
|
|
@ -1134,31 +1134,33 @@ CAM.init = function(kiri, api) {
|
||||||
};
|
};
|
||||||
|
|
||||||
createPopOp('pocket', {
|
createPopOp('pocket', {
|
||||||
spindle: 'camPocketSpindle',
|
spindle: 'camPocketSpindle',
|
||||||
tool: 'camPocketTool',
|
tool: 'camPocketTool',
|
||||||
step: 'camPocketOver',
|
step: 'camPocketOver',
|
||||||
down: 'camPocketDown',
|
down: 'camPocketDown',
|
||||||
rate: 'camPocketSpeed',
|
rate: 'camPocketSpeed',
|
||||||
plunge: 'camPocketPlunge',
|
plunge: 'camPocketPlunge',
|
||||||
expand: 'camPocketExpand',
|
expand: 'camPocketExpand',
|
||||||
smooth: 'camPocketSmooth',
|
smooth: 'camPocketSmooth',
|
||||||
contour: 'camPocketContour',
|
contour: 'camPocketContour',
|
||||||
outline: 'cmaPocketOutline'
|
outline: 'cmaPocketOutline',
|
||||||
|
tolerance: 'camTolerance',
|
||||||
}).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"}),
|
||||||
spindle: UC.newInput(LANG.cc_spnd_s, {title:LANG.cc_spnd_l, convert:UC.toInt, show:hasSpindle}),
|
spindle: UC.newInput(LANG.cc_spnd_s, {title:LANG.cc_spnd_l, convert:UC.toInt, show:hasSpindle}),
|
||||||
step: UC.newInput(LANG.cc_sovr_s, {title:LANG.cc_sovr_l, convert:UC.toFloat, bound:UC.bound(0.01,1.0)}),
|
step: UC.newInput(LANG.cc_sovr_s, {title:LANG.cc_sovr_l, convert:UC.toFloat, bound:UC.bound(0.01,1.0)}),
|
||||||
down: UC.newInput(LANG.cc_sdwn_s, {title:LANG.cc_sdwn_l, convert:UC.toFloat, units:true}),
|
down: UC.newInput(LANG.cc_sdwn_s, {title:LANG.cc_sdwn_l, convert:UC.toFloat, units:true}),
|
||||||
rate: UC.newInput(LANG.cc_feed_s, {title:LANG.cc_feed_l, convert:UC.toInt, units:true}),
|
rate: UC.newInput(LANG.cc_feed_s, {title:LANG.cc_feed_l, convert:UC.toInt, units:true}),
|
||||||
plunge: UC.newInput(LANG.cc_plng_s, {title:LANG.cc_plng_l, convert:UC.toInt, units:true}),
|
plunge: UC.newInput(LANG.cc_plng_s, {title:LANG.cc_plng_l, convert:UC.toInt, units:true}),
|
||||||
sep: UC.newBlank({class:"pop-sep"}),
|
sep: UC.newBlank({class:"pop-sep"}),
|
||||||
expand: UC.newInput(LANG.cp_xpnd_s, {title:LANG.cp_xpnd_l, convert:UC.toFloat, units:true, show:() => !poppedRec.contour}),
|
expand: UC.newInput(LANG.cp_xpnd_s, {title:LANG.cp_xpnd_l, convert:UC.toFloat, units:true, show:() => !poppedRec.contour}),
|
||||||
smooth: UC.newInput(LANG.cp_smoo_s, {title:LANG.cp_smoo_l, convert:UC.toFloat, units:true}),
|
smooth: UC.newInput(LANG.cp_smoo_s, {title:LANG.cp_smoo_l, convert:UC.toFloat, units:true}),
|
||||||
sep: UC.newBlank({class:"pop-sep"}),
|
tolerance: UC.newInput(LANG.ou_toll_s, {title:LANG.ou_toll_l, convert:UC.toFloat, bound:UC.bound(0,10.0), units:true, round:4, show:() => poppedRec.contour}),
|
||||||
contour: UC.newBoolean(LANG.cp_cont_s, undefined, {title:LANG.cp_cont_s}),
|
sep: UC.newBlank({class:"pop-sep"}),
|
||||||
outline: UC.newBoolean(LANG.cp_outl_s, undefined, {title:LANG.cp_outl_l, show:() => !poppedRec.contour}),
|
contour: UC.newBoolean(LANG.cp_cont_s, undefined, {title:LANG.cp_cont_s}),
|
||||||
sep: UC.newBlank({class:"pop-sep"}),
|
outline: UC.newBoolean(LANG.cp_outl_s, undefined, {title:LANG.cp_outl_l, show:() => !poppedRec.contour}),
|
||||||
|
sep: UC.newBlank({class:"pop-sep"}),
|
||||||
menu: UC.newRow([
|
menu: UC.newRow([
|
||||||
UC.newButton(undefined, func.surfaceAdd, {icon:'<i class="fas fa-plus"></i>'}),
|
UC.newButton(undefined, func.surfaceAdd, {icon:'<i class="fas fa-plus"></i>'}),
|
||||||
UC.newButton(undefined, func.surfaceDone, {icon:'<i class="fas fa-check"></i>'}),
|
UC.newButton(undefined, func.surfaceDone, {icon:'<i class="fas fa-check"></i>'}),
|
||||||
|
|
|
||||||
|
|
@ -957,32 +957,31 @@ class OpPocket extends CamOp {
|
||||||
}
|
}
|
||||||
|
|
||||||
slice(progress) {
|
slice(progress) {
|
||||||
const debug = false;
|
const pocket = this;
|
||||||
|
const debug = true;
|
||||||
let { op, state } = this;
|
let { op, state } = this;
|
||||||
let { tool, rate, down, plunge, expand, contour, smooth } = op;
|
let { tool, rate, down, plunge, expand, contour, smooth, tolerance } = op;
|
||||||
let { settings, widget, sliceAll, zMax, zTop, zThru, tabs, color } = state;
|
let { settings, widget, sliceAll, zMax, zTop, zThru, tabs, color } = state;
|
||||||
let { updateToolDiams, cutTabs, cutPolys, healPolys, shadowAt } = state;
|
let { updateToolDiams, cutTabs, cutPolys, healPolys, shadowAt } = state;
|
||||||
let { process, stock } = settings;
|
let { process, stock } = settings;
|
||||||
// generate tracing offsets from chosen features
|
// generate tracing offsets from chosen features
|
||||||
let sliceOut = this.sliceOut = [];
|
let sliceOut = this.sliceOut = [];
|
||||||
let toolDiam = new CAM.Tool(settings, tool).fluteDiameter();
|
let camTool = new CAM.Tool(settings, tool);
|
||||||
|
let toolDiam = camTool.fluteDiameter();
|
||||||
let toolOver = toolDiam * op.step;
|
let toolOver = toolDiam * op.step;
|
||||||
let cutdir = process.camConventional;
|
let cutdir = process.camConventional;
|
||||||
if (contour) {
|
if (contour) {
|
||||||
down = 0;
|
down = 0;
|
||||||
let topo = new CAM.Topo({
|
this.topo = new CAM.Topo({
|
||||||
// onupdate: (update, msg) => {
|
// onupdate: (update, msg) => {
|
||||||
onupdate: (index, total, msg) => {
|
onupdate: (index, total, msg) => {
|
||||||
progress(index / total, msg);
|
progress(index / total, msg);
|
||||||
},
|
},
|
||||||
ondone: (slices) => {
|
ondone: (slices) => { },
|
||||||
this.sliceOut = slices;
|
|
||||||
sliceAll.appendAll(slices);
|
|
||||||
},
|
|
||||||
contour: {
|
contour: {
|
||||||
tolerance: 0,
|
tool,
|
||||||
|
tolerance,
|
||||||
inside: true,
|
inside: true,
|
||||||
tool: tool,
|
|
||||||
axis: "-"
|
axis: "-"
|
||||||
},
|
},
|
||||||
state: state
|
state: state
|
||||||
|
|
@ -1027,7 +1026,7 @@ class OpPocket extends CamOp {
|
||||||
} else {
|
} else {
|
||||||
shadow = shadowAt(z);
|
shadow = shadowAt(z);
|
||||||
if (smooth) {
|
if (smooth) {
|
||||||
shadow = POLY.offset(POLY.offset(shadow, smooth), -smooth);
|
shadow = POLY.setZ(POLY.offset(POLY.offset(shadow, smooth), -smooth), z);
|
||||||
}
|
}
|
||||||
POLY.subtract([ poly ], shadow, clip);
|
POLY.subtract([ poly ], shadow, clip);
|
||||||
}
|
}
|
||||||
|
|
@ -1045,6 +1044,9 @@ class OpPocket extends CamOp {
|
||||||
slice.camLines = POLY.flatten(slice.camLines, null, true);
|
slice.camLines = POLY.flatten(slice.camLines, null, true);
|
||||||
}
|
}
|
||||||
POLY.setWinding(slice.camLines, cutdir, false);
|
POLY.setWinding(slice.camLines, cutdir, false);
|
||||||
|
if (contour) {
|
||||||
|
pocket.conform(slice.camLines);
|
||||||
|
}
|
||||||
slice.output()
|
slice.output()
|
||||||
.setLayer("pocket", {line: color}, false)
|
.setLayer("pocket", {line: color}, false)
|
||||||
.addPolys(slice.camLines)
|
.addPolys(slice.camLines)
|
||||||
|
|
@ -1090,12 +1092,24 @@ class OpPocket extends CamOp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// mold cam output lines to the surface of the topo offset by tool geometry
|
||||||
|
conform(camLines) {
|
||||||
|
const topo = this.topo;
|
||||||
|
let repo = 10;
|
||||||
|
for (let poly of camLines) {
|
||||||
|
for (let point of poly.points) {
|
||||||
|
point.z = topo.toolAtXY(point.x, point.y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
prepare(ops, progress) {
|
prepare(ops, progress) {
|
||||||
let { op, state, sliceOut } = this;
|
let { op, state, sliceOut } = this;
|
||||||
let { setTool, setSpindle } = ops;
|
let { setTool, setSpindle } = ops;
|
||||||
|
|
||||||
setTool(op.tool, op.rate);
|
setTool(op.tool, op.rate);
|
||||||
setSpindle(op.spindle);
|
setSpindle(op.spindle);
|
||||||
|
|
||||||
let i=0, l=sliceOut.length;
|
let i=0, l=sliceOut.length;
|
||||||
for (let slice of sliceOut.filter(s => s.camLines)) {
|
for (let slice of sliceOut.filter(s => s.camLines)) {
|
||||||
ops.emitTrace(slice);
|
ops.emitTrace(slice);
|
||||||
|
|
|
||||||
|
|
@ -146,6 +146,15 @@ class Topo {
|
||||||
return Math.max(mz, 0);
|
return Math.max(mz, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// export z probe function
|
||||||
|
const rx = stepsx / boundsX;
|
||||||
|
const ry = stepsx / boundsX;
|
||||||
|
this.toolAtXY = function(px, py) {
|
||||||
|
px = Math.round(rx * (px - minX));
|
||||||
|
py = Math.round(ry * (py - minY));
|
||||||
|
return toolAtZ(px, py);
|
||||||
|
};
|
||||||
|
|
||||||
function push_point(x,y,z) {
|
function push_point(x,y,z) {
|
||||||
const newP = newPoint(x,y,z);
|
const newP = newPoint(x,y,z);
|
||||||
// todo: merge co-linear, not just co-planar
|
// todo: merge co-linear, not just co-planar
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue