fix indexed contouring, negative zBottom, indexed contour moves

This commit is contained in:
Stewart Allen 2023-02-16 11:11:00 -05:00
commit e1ec475473
4 changed files with 12 additions and 8 deletions

View file

@ -346,7 +346,7 @@ function prepEach(widget, settings, print, firstPoint, update) {
// new pos for plunge calc // new pos for plunge calc
deltaXY = 0; deltaXY = 0;
} }
} else if (isMove && currentOp.type === 'lathe') { } else if (isMove && ['lathe','contour'].contains(currentOp.type)) {
if (point.z > lastPoint.z) { if (point.z > lastPoint.z) {
layerPush(lastPoint.clone().setZ(point.z), 0, 0, tool.getNumber()); layerPush(lastPoint.clone().setZ(point.z), 0, 0, tool.getNumber());
} else if (point.z < lastPoint.z) { } else if (point.z < lastPoint.z) {

View file

@ -239,14 +239,14 @@ CAM.slice = async function(settings, widget, onupdate, ondone) {
}); });
tracker.rotation = isIndexed ? axisRotation : 0; tracker.rotation = isIndexed ? axisRotation : 0;
// setup new state when indexing the workspace // setup new state when indexing the workspace
if (true && op.op.type === "index") { if (op.op.type === "index") {
widget.topo = undefined;
// let points = base.verticesToPoints(); // let points = base.verticesToPoints();
state.slicer = new kiri.cam_slicer(widget); state.slicer = new kiri.cam_slicer(widget);
shadows = {}; shadows = {};
await new CAM.OPS.shadow(state, { type: "shadow", silent: true }).slice(progress => { await new CAM.OPS.shadow(state, { type: "shadow", silent: true }).slice(progress => {
// console.log('reshadow', progress.round(3)); // console.log('reshadow', progress.round(3));
}); });
widget.topo = undefined;
} }
camOps.push(op); camOps.push(op);
opSum += weight; opSum += weight;

View file

@ -87,7 +87,7 @@ class Topo {
clipTo = inside ? shadow : POLY.expand(shadow, toolDiameter/2 + resolution * 3), clipTo = inside ? shadow : POLY.expand(shadow, toolDiameter/2 + resolution * 3),
partOff = inside ? 0 : toolDiameter / 2 + resolution, partOff = inside ? 0 : toolDiameter / 2 + resolution,
gridDelta = Math.floor(partOff / resolution), gridDelta = Math.floor(partOff / resolution),
debug = true, debug = false,
debug_clips = debug && true, debug_clips = debug && true,
debug_topo = debug && true, debug_topo = debug && true,
debug_topo_lines = debug && true, debug_topo_lines = debug && true,
@ -205,7 +205,7 @@ class Topo {
const { box } = params; const { box } = params;
const { worker, minions } = kiri; const { worker, minions } = kiri;
const vertices = widget.getGeoVertices().toShared(); const vertices = widget.getGeoVertices({ unroll: true, translate: true }).toShared();
const range = { min: Infinity, max: -Infinity }; const range = { min: Infinity, max: -Infinity };
// swap XZ in shared array // swap XZ in shared array
@ -449,7 +449,7 @@ class Probe {
xl = sx - 1, xl = sx - 1,
yl = sy - 1; yl = sy - 1;
let gv, i = 0, mz = -1; let gv, i = 0, mz = -Infinity;
while (i < profile.length) { while (i < profile.length) {
// tool profile point x, y, and z offsets // tool profile point x, y, and z offsets
@ -467,7 +467,7 @@ class Probe {
mz = Math.max(tz + gv, mz); mz = Math.max(tz + gv, mz);
} }
return Math.max(mz, 0); return Math.max(mz, zMin);
} }
// export z probe function // export z probe function
@ -777,7 +777,7 @@ function raster_slice(inputs) {
// rasterize one x slice // rasterize one x slice
for (y = minY; y < maxY && gridy < stepsY; y += resolution) { for (y = minY; y < maxY && gridy < stepsY; y += resolution) {
gridi = gridx * stepsY + gridy; gridi = gridx * stepsY + gridy;
gridv = data[gridi] || 0; gridv = data[gridi] || zMin;
// strategy using raw lines (faster slice, but more lines) // strategy using raw lines (faster slice, but more lines)
for (i=0, il=points.length; i<il; i += 2) { for (i=0, il=points.length; i<il; i += 2) {
const p1 = points[i], p2 = points[i+1]; const p1 = points[i], p2 = points[i+1];

View file

@ -279,6 +279,10 @@ class Topo4 {
mz = Math.max(mz, lz); mz = Math.max(mz, lz);
} }
} }
if (mz === -Infinity && xo === 0 && yo === 0) {
// tool tip is off the model
break;
}
} }
if (mz === -Infinity) { if (mz === -Infinity) {
mz = Math.max(lz, 0); mz = Math.max(lz, 0);