change the way contouring uses tool diameter and offset

This commit is contained in:
Stewart Allen 2022-10-10 19:24:16 -04:00
commit 3252a42079
4 changed files with 19 additions and 11 deletions

View file

@ -1151,7 +1151,7 @@ CAM.init = function(kiri, api) {
tool: UC.newSelect(LANG.cc_tool, {}, "tools"),
sep: UC.newBlank({class:"pop-sep"}),
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), show:() => !(poppedRec.engrave && poppedRec.contour)}),
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, show:() => !(poppedRec.engrave && poppedRec.contour)}),
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}),

View file

@ -1008,8 +1008,11 @@ class OpPocket extends CamOp {
down = diff / Math.ceil(diff / down);
}
let zs = down ? base.util.lerp(zTop, z, down) : [ z ];
if (engrave) {
toolDiam = toolOver;
}
if (contour) {
expand = toolOver;
expand = engrave ? 0 : toolOver;
}
if (expand) {
polys = POLY.offset(polys, expand);
@ -1037,9 +1040,14 @@ class OpPocket extends CamOp {
let slice = newSliceOut(z);
let count = engrave ? 1 : 999;
slice.camTrace = { tool, rate, plunge };
POLY.offset(clip, [ -toolDiam / 2, -toolOver ], {
count, outs: slice.camLines = [], flat:true, z
});
if (toolDiam) {
POLY.offset(clip, [ -toolDiam / 2, -toolOver ], {
count, outs: slice.camLines = [], flat:true, z
});
} else {
// when engraving with a 0 width tip
slice.camLines = clip;
}
if (tabs) {
slice.camLines = cutTabs(tabs, POLY.flatten(slice.camLines, null, true), z);
} else {

View file

@ -70,11 +70,11 @@ class Tool {
}
isBallMill() {
return this.type === "ballmill";
return this.tool.type === "ballmill";
}
isTaperMill() {
return this.type === "tapermill";
return this.tool.type === "tapermill";
}
generateProfile(resolution) {

View file

@ -155,10 +155,10 @@ class Topo {
return toolAtZ(px, py);
};
this.zAtXY = function(px, py) {
px = Math.round(rx * (px - minX));
py = Math.round(ry * (py - minY));
return topo.data[px * stepsy + py] || zMin;
const zAtXY = this.zAtXY = function(px, py) {
let ix = Math.round(rx * (px - minX));
let iy = Math.round(ry * (py - minY));
return topo.data[ix * stepsy + iy] || zMin;
};
function push_point(x,y,z) {