fix detected rapid plunge
This commit is contained in:
parent
f272ce86f0
commit
d5b50f5d25
4 changed files with 22 additions and 13 deletions
|
|
@ -88,7 +88,7 @@ class Print {
|
||||||
}
|
}
|
||||||
output.appendAll(input);
|
output.appendAll(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints a polygon to a given output array, possibly with a given extrude factor,
|
* Prints a polygon to a given output array, possibly with a given extrude factor,
|
||||||
* and starting from a given point. The last point is returned.
|
* and starting from a given point. The last point is returned.
|
||||||
|
|
|
||||||
|
|
@ -234,7 +234,7 @@ export function cam_export(print, online) {
|
||||||
// speed: Infinity,
|
// speed: Infinity,
|
||||||
tool: out.tool,
|
tool: out.tool,
|
||||||
point: { x: newpos.x, y: newpos.y, z: newpos.z, a: pos.a },
|
point: { x: newpos.x, y: newpos.y, z: newpos.z, a: pos.a },
|
||||||
emit: 1,
|
emit: out.emit,
|
||||||
}, {
|
}, {
|
||||||
dx: 1, dy: 1, dz: 0, time: 0
|
dx: 1, dy: 1, dz: 0, time: 0
|
||||||
});
|
});
|
||||||
|
|
@ -251,7 +251,7 @@ export function cam_export(print, online) {
|
||||||
// speed: Infinity,
|
// speed: Infinity,
|
||||||
tool: out.tool,
|
tool: out.tool,
|
||||||
point: { x: newpos.x, y: newpos.y, z: newpos.z, a: newpos.a },
|
point: { x: newpos.x, y: newpos.y, z: newpos.z, a: newpos.a },
|
||||||
emit: 1
|
emit: out.emit
|
||||||
}, {
|
}, {
|
||||||
dx: 0, dy: 0, dz: 1, time: 0
|
dx: 0, dy: 0, dz: 1, time: 0
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -393,8 +393,19 @@ export function prepEach(widget, settings, print, firstPoint, update) {
|
||||||
let deltaXY = lastPoint.distTo2D(point),
|
let deltaXY = lastPoint.distTo2D(point),
|
||||||
deltaZ = point.z - lastPoint.z,
|
deltaZ = point.z - lastPoint.z,
|
||||||
absDeltaZ = Math.abs(deltaZ),
|
absDeltaZ = Math.abs(deltaZ),
|
||||||
|
hasDelta = deltaXY >= 0.001 && absDeltaZ >= 0,
|
||||||
isMove = emit == 0;
|
isMove = emit == 0;
|
||||||
|
|
||||||
|
// when rapid pluge could cut thru stock, rapid to just above stock
|
||||||
|
// then continue plunge as a plunge cut
|
||||||
|
if (deltaZ < 0 && lastPoint.z > stockz && point.z < stockz && emit === 0) {
|
||||||
|
// console.log('detected plunge cut as rapid move', lastPoint.z, point.z);
|
||||||
|
let above = point.clone().setZ(stockz + 0.1);
|
||||||
|
layerPush(above, 0, 0, tool);
|
||||||
|
// change to cutting move for remainder of plunge
|
||||||
|
emit = 1;
|
||||||
|
}
|
||||||
|
|
||||||
// drop points too close together
|
// drop points too close together
|
||||||
if (!isLathe && !isArc && deltaXY < 0.001 && point.z === lastPoint.z) {
|
if (!isLathe && !isArc && deltaXY < 0.001 && point.z === lastPoint.z) {
|
||||||
// console.trace(["drop dup",lastPoint,point]);
|
// console.trace(["drop dup",lastPoint,point]);
|
||||||
|
|
@ -402,7 +413,7 @@ export function prepEach(widget, settings, print, firstPoint, update) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert short planar moves to cuts in some cases
|
// convert short planar moves to cuts in some cases
|
||||||
if (!isRough && !isArc && isMove && deltaXY <= moveLen && deltaZ <= 0 && !lasering) {
|
if (hasDelta && !isRough && !isArc && isMove && deltaXY <= moveLen && deltaZ <= 0 && !lasering) {
|
||||||
let iscontour = tolerance > 0;
|
let iscontour = tolerance > 0;
|
||||||
let isflat = absDeltaZ < 0.001;
|
let isflat = absDeltaZ < 0.001;
|
||||||
// restrict this to contouring
|
// restrict this to contouring
|
||||||
|
|
@ -718,8 +729,6 @@ export function prepEach(widget, settings, print, firstPoint, update) {
|
||||||
function emitTrace(slice) {
|
function emitTrace(slice) {
|
||||||
let { tool, rate, plunge } = slice.camTrace;
|
let { tool, rate, plunge } = slice.camTrace;
|
||||||
setTool(tool, rate, plunge);
|
setTool(tool, rate, plunge);
|
||||||
let traceTool = new Tool(settings, tool);
|
|
||||||
let traceToolDiam = traceTool.fluteDiameter();
|
|
||||||
printPoint = poly2polyEmit(slice.camLines, printPoint, polyEmit, {
|
printPoint = poly2polyEmit(slice.camLines, printPoint, polyEmit, {
|
||||||
swapdir: false,
|
swapdir: false,
|
||||||
weight: innerFirst
|
weight: innerFirst
|
||||||
|
|
@ -743,7 +752,7 @@ export function prepEach(widget, settings, print, firstPoint, update) {
|
||||||
* @param {boolean} ops.cutFromLast - whether to emit a 1 when moving from last point. Defaults to false
|
* @param {boolean} ops.cutFromLast - whether to emit a 1 when moving from last point. Defaults to false
|
||||||
* @returns {Point} - the last point of the polygon
|
* @returns {Point} - the last point of the polygon
|
||||||
*/
|
*/
|
||||||
function polyEmit(poly, index, count, fromPoint,ops) {
|
function polyEmit(poly, index, count, fromPoint, ops) {
|
||||||
let {
|
let {
|
||||||
cutFromLast,
|
cutFromLast,
|
||||||
} = ops ?? {
|
} = ops ?? {
|
||||||
|
|
@ -855,7 +864,6 @@ export function prepEach(widget, settings, print, firstPoint, update) {
|
||||||
radFault = Math.abs(angle) > arcRes
|
radFault = Math.abs(angle) > arcRes
|
||||||
if (radFault) {
|
if (radFault) {
|
||||||
// if so, remove first point
|
// if so, remove first point
|
||||||
|
|
||||||
console.log("secondary radfault,",structuredClone(arcQ),{angle,arcRes,a,b})
|
console.log("secondary radfault,",structuredClone(arcQ),{angle,arcRes,a,b})
|
||||||
camOut(arcQ.shift(), 1)
|
camOut(arcQ.shift(), 1)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1392,14 +1392,15 @@ const prefs = {
|
||||||
scale_group_Z: true
|
scale_group_Z: true
|
||||||
},
|
},
|
||||||
space: {
|
space: {
|
||||||
|
bounds: false,
|
||||||
|
center: false,
|
||||||
|
dark: false,
|
||||||
|
floor: false,
|
||||||
|
grid: true,
|
||||||
|
select: [],
|
||||||
snap: 1,
|
snap: 1,
|
||||||
snapon: false,
|
snapon: false,
|
||||||
center: false,
|
wire: false
|
||||||
floor: false,
|
|
||||||
wire: false,
|
|
||||||
grid: true,
|
|
||||||
dark: false,
|
|
||||||
select: []
|
|
||||||
},
|
},
|
||||||
sketch: {
|
sketch: {
|
||||||
open_close: false,
|
open_close: false,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue