add new uber-op: area

This commit is contained in:
Stewart Allen 2025-11-28 20:03:46 -05:00
commit cc85832236
7 changed files with 80 additions and 2 deletions

View file

@ -73,6 +73,9 @@ let UC = UI.prefix('kiri').inputAction(settings.conf.update),
redo: noop // do.js
},
devel = {
get enabled() {
return settings.ctrl().devel;
},
xray(layers, raw) {
let proc = api.conf.get().process,
size = proc.sliceHeight || proc.slaSlice || 1,

View file

@ -423,6 +423,16 @@ export const conf = {
camArcEnabled: false,
camArcResolution: 5,
camArcTolerance: 0.15,
camAreaSpindle: 1000,
camAreaTool: 1000,
camAreaType: "clear",
camAreaOver: 0.4,
camAreaDown: 1,
camAreaSpeed: 1000,
camAreaPlunge: 100,
camAreaExpand: 0,
camAreaSmooth: 1,
camAreaRefine: 0,
camContourAngle: 85,
camContourBottom: false,
camContourBridge: 0,

View file

@ -121,6 +121,11 @@ const LISTS = {
{ name: "adaptive" },
{ name: "legacy 1" },
{ name: "legacy 2" }
],
opmode: [
{ name: "clear" },
{ name: "trace" },
{ name: "surface" }
]
};

View file

@ -651,4 +651,48 @@ export function createPopOps() {
};
createPopOp('|', {}).inputs = {};
createPopOp('area', {
spindle: 'camAreaSpindle',
tool: 'camAreaTool',
mode: 'camAreaMode',
over: 'camAreaOver',
down: 'camAreaDown',
rate: 'camAreaSpeed',
plunge: 'camAreaPlunge',
expand: 'camAreaExpand',
smooth: 'camAreaSmooth',
refine: 'camAreaRefine',
ov_topz: 0,
ov_botz: 0,
ov_conv: '~camConventional',
tolerance: 'camTolerance',
}).inputs = {
tool: UC.newSelect(LANG.cc_tool, {}, "tools"),
mode: UC.newSelect(LANG.mo_menu, {}, "opmode"),
sep: UC.newBlank({ class: "pop-sep" }),
spindle: UC.newInput(LANG.cc_spnd_s, { title: LANG.cc_spnd_l, convert: UC.toInt, show: hasSpindle }),
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 }),
sep: UC.newBlank({ class: "pop-sep" }),
over: 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 }),
sep: UC.newBlank({ class: "pop-sep" }),
expand: UC.newInput(LANG.cp_xpnd_s, { title: LANG.cp_xpnd_l, convert: UC.toFloat, units: true }),
refine: UC.newInput(LANG.cp_refi_s, { title: LANG.cp_refi_l, convert: UC.toInt }),
smooth: UC.newInput(LANG.cp_smoo_s, { title: LANG.cp_smoo_l, convert: UC.toInt }),
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 }),
exp: UC.newExpand("overrides"),
sep: UC.newBlank({ class: "pop-sep" }),
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(),
sep: UC.newBlank({ class: "pop-sep" }),
menu: UC.newRow([
UC.newButton("edge", traceAdd),
UC.newButton("surface", surfaceAdd),
], { class: "ext-buttons f-row" }),
};
}

View file

@ -16,9 +16,10 @@ export function surfaceAdd(ev) {
return surfaceDone();
}
clearPops();
let { surfaces, follow } = env.poppedRec;
let { edgeangle } = api.conf.get().controller;
alert = api.show.alert("analyzing surfaces...", 1000);
let surfaces = env.poppedRec.surfaces;
let radians = env.poppedRec.follow * DEG2RAD;
let radians = (follow ?? edgeangle) * DEG2RAD;
CAM.surface_prep(env.currentIndex * RAD2DEG, () => {
api.hide.alert(alert);
alert = api.show.alert("[esc] cancels surface selection");

View file

@ -189,6 +189,15 @@ const opAddHelical = () => {
opAdd(rec);
};
const opAddArea = () => {
traceDone();
surfaceDone();
let rec = env.popOp.area.new();
rec.areas = { /* widget.id: [ polygons... ] */ };
rec.surfaces = { /* widget.id: [ faces... ] */ };
opAdd(rec);
};
const opAddContour = (axis) => {
let rec = env.popOp.contour.new();
rec.axis = axis.toUpperCase();
@ -517,6 +526,10 @@ export function opRender() {
export function init() {
if (api.devel.enabled) {
$('op:area').classList.remove('hide');
}
api.event.on('tool.mesh.face-normal', normal => {
// console.log({ env.poppedRec });
env.poppedRec.degrees = (Math.atan2(normal.y, normal.z) * RAD2DEG).round(2);
@ -764,6 +777,7 @@ export function init() {
case "trace": return opAddTrace();
case "pocket": return opAddPocket();
case "helical": return opAddHelical();
case "area": return opAddArea();
case "flip":
// only one flip op permitted
for (let op of env.current.process.ops) {

View file

@ -461,6 +461,7 @@
<div title="2.5D tracing along X or Y axis&#13;used for complex part features">contour</div>
<div title="clear areas above&#13;selected surfaces">pocket</div>
<div title="follow a helix&#13;around circular paths">helical</div>
<div title="perform configurable operations on selected areas" id="op:area" class="hide">area</div>
</div>
</div>
</div>