add experimental lathe linear passes

This commit is contained in:
Stewart Allen 2025-01-03 21:55:19 -05:00
commit daedae0d41
5 changed files with 38 additions and 11 deletions

View file

@ -1422,7 +1422,7 @@ CAM.init = function(kiri, api) {
tolerance: 'camTolerance', tolerance: 'camTolerance',
filter: 'camContourFilter', filter: 'camContourFilter',
leave: 'camContourLeave', leave: 'camContourLeave',
axis: 'X' linear: 'camLatheLinear'
}).inputs = { }).inputs = {
tool: UC.newSelect(LANG.cc_tool, {}, "tools"), tool: UC.newSelect(LANG.cc_tool, {}, "tools"),
// axis: UC.newSelect(LANG.cd_axis, {}, "xyaxis"), // axis: UC.newSelect(LANG.cd_axis, {}, "xyaxis"),
@ -1435,6 +1435,8 @@ CAM.init = function(kiri, api) {
sep: UC.newBlank({class:"pop-sep"}), 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}), 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}),
leave: UC.newInput(LANG.cf_leav_s, {title:LANG.cf_leav_l, convert:UC.toFloat, bound:UC.bound(0,100)}), leave: UC.newInput(LANG.cf_leav_s, {title:LANG.cf_leav_l, convert:UC.toFloat, bound:UC.bound(0,100)}),
sep: UC.newBlank({class:"pop-sep"}),
linear: UC.newBoolean(LANG.ci_line_s, undefined, {title:LANG.ci_line_l}),
// filter: UC.newRow([ UC.newButton(LANG.filter, contourFilter) ], {class:"ext-buttons f-row"}) // filter: UC.newRow([ UC.newButton(LANG.filter, contourFilter) ], {class:"ext-buttons f-row"})
}; };

View file

@ -62,6 +62,10 @@ class Tool {
return this.unitScale() * this.tool.taper_tip; return this.unitScale() * this.tool.taper_tip;
} }
maxDiameter() {
return Math.max(this.fluteDiameter(), this.tipDiameter(), this.shaftDiameter());
}
traceOffset() { traceOffset() {
return (this.isTaperMill() ? this.tipDiameter() : this.fluteDiameter()) / 2; return (this.isTaperMill() ? this.tipDiameter() : this.fluteDiameter()) / 2;
} }

View file

@ -73,6 +73,7 @@ class Topo4 {
this.diam = tool.fluteDiameter(); this.diam = tool.fluteDiameter();
this.zoff = widget.track.top || 0; this.zoff = widget.track.top || 0;
this.leave = op.leave || 0; this.leave = op.leave || 0;
this.linear = op.linear || false;
this.lineColor = state.settings.controller.dark ? 0xffff00 : 0x555500; this.lineColor = state.settings.controller.dark ? 0xffff00 : 0x555500;
onupdate(0, "lathe"); onupdate(0, "lathe");
@ -363,7 +364,7 @@ class Topo4 {
} }
async latheMinions(onupdate) { async latheMinions(onupdate) {
const { sliced, tool, zoff, leave, maxo, zBottom, step, resolution } = this; const { sliced, tool, zoff, leave, maxo, zBottom, step, resolution, linear } = this;
const { putCache, clearCache, queue } = this; const { putCache, clearCache, queue } = this;
const rota = this.angle * DEG2RAD; const rota = this.angle * DEG2RAD;
@ -404,19 +405,34 @@ class Topo4 {
await Promise.all(promises); await Promise.all(promises);
recs.sort((a, b) => { return b.angle - a.angle }); recs.sort((a, b) => { return b.angle - a.angle });
count = recs[0].heights.length / 3; // let linear = true;
count = linear ? recs.length : recs[0].heights.length / 3;
while (count-- > 0) { while (count-- > 0) {
let slice = newSlice(count); let slice = newSlice(count);
slice.camLines = [ newPolygon().setOpen() ]; slice.camLines = [ newPolygon().setOpen() ];
paths.push(slice); paths.push(slice);
} }
for (let rec of recs) { if (linear) {
const { degrees, heights } = rec; recs.forEach((rec,i) => {
[...heights].group(3).forEach((a,i) => { const { degrees, heights } = rec;
// progress each path 360 degrees to prevent A rolling backwards [...heights].group(3).forEach((a) => {
paths[i].camLines[0].push( newPoint(a[0], a[1], a[2] + leave).setA(degrees + i * -360) ); // progress each path 360 degrees to prevent A rolling backwards
paths[i].camLines[0].push( newPoint(a[0], a[1], a[2] + leave).setA(degrees + i * -360) );
});
if (i % 2 === 1) {
paths[i].camLines[0].reverse();
}
}); });
} else {
for (let rec of recs) {
const { degrees, heights } = rec;
[...heights].group(3).forEach((a,i) => {
// progress each path 360 degrees to prevent A rolling backwards
paths[i].camLines[0].push( newPoint(a[0], a[1], a[2] + leave).setA(degrees + i * -360) );
});
}
} }
for (let slice of paths) { for (let slice of paths) {
@ -425,9 +441,11 @@ class Topo4 {
console.log('empty', slice); console.log('empty', slice);
continue; continue;
} }
// repeat first point 360 degrees progressed if (!linear) {
const repeat = poly.points[0]; // repeat first point 360 degrees progressed
slice.camLines[0].push(repeat.clone().setA(repeat.a - 360)); const repeat = poly.points[0];
slice.camLines[0].push(repeat.clone().setA(repeat.a - 360));
}
slice.output() slice.output()
.setLayer("lathe", { line: this.lineColor }) .setLayer("lathe", { line: this.lineColor })
.addPoly(poly.clone().applyRotations().move({ z: -zoff, x:0, y:0 })); .addPoly(poly.clone().applyRotations().move({ z: -zoff, x:0, y:0 }));

View file

@ -725,6 +725,7 @@ button:hover {
right: 0; right: 0;
bottom: 0; bottom: 0;
position: fixed; position: fixed;
color: black;
background-color: #fff; background-color: #fff;
font-family: 'Russo One', sans-serif; font-family: 'Russo One', sans-serif;
z-index: 1000; z-index: 1000;

View file

@ -607,6 +607,8 @@ self.kiri.lang['en-us'] = {
ci_abso_l: "degree rotation is absolute", ci_abso_l: "degree rotation is absolute",
ci_face_s: "face", ci_face_s: "face",
ci_face_l: "select face to rotate facing up", ci_face_l: "select face to rotate facing up",
ci_line_s: "linear",
ci_line_l: "make linear passes along X then rotate Y",
// CNC LASER On/Off Operations (Carvera) // CNC LASER On/Off Operations (Carvera)
cl_powr_s: "power", cl_powr_s: "power",