testing getMaxZBetween z clearance routing
This commit is contained in:
parent
bf76458bc6
commit
7ad9559521
3 changed files with 73 additions and 30 deletions
|
|
@ -751,7 +751,7 @@
|
||||||
/**
|
/**
|
||||||
* returns intersections sorted by closest to lp1
|
* returns intersections sorted by closest to lp1
|
||||||
*/
|
*/
|
||||||
PRO.intersections = function(lp1, lp2) {
|
PRO.intersections = function(lp1, lp2, deep) {
|
||||||
let list = [];
|
let list = [];
|
||||||
this.forEachSegment(function(pp1, pp2, ip1, ip2) {
|
this.forEachSegment(function(pp1, pp2, ip1, ip2) {
|
||||||
let int = UTIL.intersect(lp1, lp2, pp1, pp2, BASE.key.SEGINT, false);
|
let int = UTIL.intersect(lp1, lp2, pp1, pp2, BASE.key.SEGINT, false);
|
||||||
|
|
@ -764,6 +764,12 @@
|
||||||
list.sort(function(p1, p2) {
|
list.sort(function(p1, p2) {
|
||||||
return UTIL.distSq(lp1, p1) - UTIL.distSq(lp1, p2);
|
return UTIL.distSq(lp1, p1) - UTIL.distSq(lp1, p2);
|
||||||
});
|
});
|
||||||
|
if (deep && this.inner) {
|
||||||
|
this.inner.forEach(p => {
|
||||||
|
let ints = p.intersections(lp1, lp2);
|
||||||
|
if (ints) list.appendAll(ints);
|
||||||
|
});
|
||||||
|
}
|
||||||
return list;
|
return list;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1064,8 +1064,8 @@
|
||||||
// - it has more than one sibling
|
// - it has more than one sibling
|
||||||
// - it has no parent (top/outer most)
|
// - it has no parent (top/outer most)
|
||||||
// - it is offset from its parent by more than diameter
|
// - it is offset from its parent by more than diameter
|
||||||
if (poly.isOpen() || !poly.parent || poly.parent.innerCount() > 1 || !polygonWithinOffset(poly, poly.parent, offset)) {
|
// if (poly.isOpen() || !poly.parent || poly.parent.innerCount() > 1 || !polygonWithinOffset(poly, poly.parent, offset)) {
|
||||||
// if (poly.depth === 0) {
|
if (poly.depth === 0) {
|
||||||
pools.push(poly);
|
pools.push(poly);
|
||||||
poly.pool = [];
|
poly.pool = [];
|
||||||
poly.poolsDown = [];
|
poly.poolsDown = [];
|
||||||
|
|
|
||||||
|
|
@ -158,26 +158,43 @@
|
||||||
return toolOffset;
|
return toolOffset;
|
||||||
};
|
};
|
||||||
|
|
||||||
function getMaxZBetween(terrain, x1, y1, x2, y2, z) {
|
function getMaxZBetween(terrain, x1, y1, x2, y2, z, zadd, off, over) {
|
||||||
let maxz = z;
|
let maxz = z;
|
||||||
let check = [];
|
let check = [];
|
||||||
for (let i=0; i<terrain.length; i++) {
|
for (let i=0; i<terrain.length; i++) {
|
||||||
let data = terrain[i];
|
let data = terrain[i];
|
||||||
check.push(data);
|
check.push(data);
|
||||||
if (data.z < z) {
|
if (data.z + zadd < z) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
check.reverse();
|
check.reverse();
|
||||||
for (let i=0; i<check.length; i++) {
|
for (let i=0; i<check.length; i++) {
|
||||||
let data = check[i];
|
let data = check[i];
|
||||||
let int = data.tops.map(p => p.intersections({x:x1, y:y1},{x:x2, y:y2})).flat();
|
let p1 = newPoint(x1, y1);
|
||||||
|
let p2 = newPoint(x2, y2);
|
||||||
|
let int = data.tops.map(p => p.intersections(p1, p2, true)).flat();
|
||||||
if (int.length) {
|
if (int.length) {
|
||||||
maxz = Math.max(maxz, data.z);
|
maxz = Math.max(maxz, data.z + zadd + over);
|
||||||
console.log({z, check, int, maxz, dataz: data.z});
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let s1 = p1.slopeTo(p2).toUnit().normal();
|
||||||
|
let s2 = p2.slopeTo(p1).toUnit().normal();
|
||||||
|
let pa = p1.projectOnSlope(s1, off);
|
||||||
|
let pb = p2.projectOnSlope(s1, off);
|
||||||
|
int = data.tops.map(p => p.intersections(pa, pb, true)).flat();
|
||||||
|
if (int.length) {
|
||||||
|
maxz = Math.max(maxz, data.z + zadd + over);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
pa = p1.projectOnSlope(s2, off);
|
||||||
|
pb = p2.projectOnSlope(s2, off);
|
||||||
|
int = data.tops.map(p => p.intersections(pa, pb, true)).flat();
|
||||||
|
if (int.length) {
|
||||||
|
maxz = Math.max(maxz, data.z + zadd + over);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return maxz;
|
return maxz;
|
||||||
}
|
}
|
||||||
|
|
@ -684,6 +701,7 @@
|
||||||
roughToolDiam = getToolDiameter(conf, proc.camRoughTool),
|
roughToolDiam = getToolDiameter(conf, proc.camRoughTool),
|
||||||
outlineToolDiam = getToolDiameter(conf, proc.camOutlineTool),
|
outlineToolDiam = getToolDiameter(conf, proc.camOutlineTool),
|
||||||
contourToolDiam = getToolDiameter(conf, proc.camContourTool),
|
contourToolDiam = getToolDiameter(conf, proc.camContourTool),
|
||||||
|
drillToolDiam = getToolDiameter(conf, proc.camDrillTool),
|
||||||
procFacing = proc.camRoughOn && proc.camZTopOffset,
|
procFacing = proc.camRoughOn && proc.camZTopOffset,
|
||||||
procRough = proc.camRoughOn && proc.camRoughDown && roughToolDiam,
|
procRough = proc.camRoughOn && proc.camRoughDown && roughToolDiam,
|
||||||
procOutlineIn = proc.camOutlineIn,
|
procOutlineIn = proc.camOutlineIn,
|
||||||
|
|
@ -711,6 +729,8 @@
|
||||||
ztOff = proc.camZTopOffset * units,
|
ztOff = proc.camZTopOffset * units,
|
||||||
camRoughStock = proc.camRoughStock * units,
|
camRoughStock = proc.camRoughStock * units,
|
||||||
camRoughDown = proc.camRoughDown * units,
|
camRoughDown = proc.camRoughDown * units,
|
||||||
|
minStepDown = Math.min(1, roughDown, outlineDown),
|
||||||
|
maxToolDiam = 0,
|
||||||
sliceIndex = 0,
|
sliceIndex = 0,
|
||||||
thruHoles;
|
thruHoles;
|
||||||
|
|
||||||
|
|
@ -748,7 +768,7 @@
|
||||||
});
|
});
|
||||||
let tslices = [];
|
let tslices = [];
|
||||||
let tshadow = [];
|
let tshadow = [];
|
||||||
let tzindex = slicer.interval(1, { fit: true, off: 0.01, down: true }); // bottom up 1mm steps
|
let tzindex = slicer.interval(minStepDown, { fit: true, off: 0.01, down: true });
|
||||||
let terrain = slicer.slice(tzindex, { each: (data, index, total) => {
|
let terrain = slicer.slice(tzindex, { each: (data, index, total) => {
|
||||||
console.log('terrain', index, total, data);
|
console.log('terrain', index, total, data);
|
||||||
tshadow = POLY.union(tshadow.appendAll(data.tops), 0.01, true);
|
tshadow = POLY.union(tshadow.appendAll(data.tops), 0.01, true);
|
||||||
|
|
@ -762,14 +782,15 @@
|
||||||
onupdate(0.0 + (index/total) * 0.1, "mapping");
|
onupdate(0.0 + (index/total) * 0.1, "mapping");
|
||||||
}, genso: true });
|
}, genso: true });
|
||||||
let shadowTop = terrain[terrain.length - 1];
|
let shadowTop = terrain[terrain.length - 1];
|
||||||
widget.terrain = terrain;
|
|
||||||
console.log({slicer, tzindex, tshadow, terrain});
|
console.log({slicer, tzindex, tshadow, terrain});
|
||||||
|
|
||||||
if (procDrillReg) {
|
if (procDrillReg) {
|
||||||
|
maxToolDiam = Math.max(maxToolDiam, drillToolDiam);
|
||||||
sliceDrillReg(settings, widget, sliceAll, zThru);
|
sliceDrillReg(settings, widget, sliceAll, zThru);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (procDrill) {
|
if (procDrill) {
|
||||||
|
maxToolDiam = Math.max(maxToolDiam, drillToolDiam);
|
||||||
sliceDrill(settings, widget, tslices, sliceAll);
|
sliceDrill(settings, widget, tslices, sliceAll);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -796,6 +817,7 @@
|
||||||
|
|
||||||
// create roughing slices
|
// create roughing slices
|
||||||
if (procRough) {
|
if (procRough) {
|
||||||
|
maxToolDiam = Math.max(maxToolDiam, roughToolDiam);
|
||||||
let shadow = [];
|
let shadow = [];
|
||||||
let slices = [];
|
let slices = [];
|
||||||
slicer.slice(slicer.interval(roughDown, { down: true, min: zBottom }), { each: (data, index, total) => {
|
slicer.slice(slicer.interval(roughDown, { down: true, min: zBottom }), { each: (data, index, total) => {
|
||||||
|
|
@ -864,6 +886,7 @@
|
||||||
|
|
||||||
// create outline slices
|
// create outline slices
|
||||||
if (procOutline) {
|
if (procOutline) {
|
||||||
|
maxToolDiam = Math.max(maxToolDiam, outlineToolDiam);
|
||||||
let shadow = [];
|
let shadow = [];
|
||||||
let slices = [];
|
let slices = [];
|
||||||
slicer.slice(slicer.interval(outlineDown, { down: true, min: zBottom }), { each: (data, index, total) => {
|
slicer.slice(slicer.interval(outlineDown, { down: true, min: zBottom }), { each: (data, index, total) => {
|
||||||
|
|
@ -949,6 +972,10 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// used in printSetup()
|
||||||
|
widget.terrain = terrain;
|
||||||
|
widget.maxToolDiam = maxToolDiam;
|
||||||
|
|
||||||
ondone();
|
ondone();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1169,7 +1196,14 @@
|
||||||
addOutput = print.addOutput,
|
addOutput = print.addOutput,
|
||||||
tip2tipEmit = print.tip2tipEmit,
|
tip2tipEmit = print.tip2tipEmit,
|
||||||
poly2polyEmit = print.poly2polyEmit,
|
poly2polyEmit = print.poly2polyEmit,
|
||||||
poly2polyDepthFirstEmit = print.poly2polyDepthFirstEmit;
|
poly2polyDepthFirstEmit = print.poly2polyDepthFirstEmit,
|
||||||
|
maxToolDiam = widget.maxToolDiam,
|
||||||
|
terrain = widget.terrain.map(data => {
|
||||||
|
return {
|
||||||
|
z: data.z,
|
||||||
|
tops: data.tops,//POLY.offset(data.tops, maxToolDiam, {z: data.z})
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
function newLayer() {
|
function newLayer() {
|
||||||
if (layerOut.length < 2) {
|
if (layerOut.length < 2) {
|
||||||
|
|
@ -1319,24 +1353,27 @@
|
||||||
} //else (TODO verify no else here b/c above could change isMove)
|
} //else (TODO verify no else here b/c above could change isMove)
|
||||||
// move over things
|
// move over things
|
||||||
if ((deltaXY > toolDiam || (deltaZ > toolDiam && deltaXY > tolerance)) && (isMove || absDeltaZ >= tolerance)) {
|
if ((deltaXY > toolDiam || (deltaZ > toolDiam && deltaXY > tolerance)) && (isMove || absDeltaZ >= tolerance)) {
|
||||||
// let maxz = getMaxZBetween(
|
let maxz = getMaxZBetween(
|
||||||
// widget.terrain,
|
terrain,
|
||||||
// lastPoint.x,// - wmx,
|
lastPoint.x,// - wmx,
|
||||||
// lastPoint.y,// - wmy,
|
lastPoint.y,// - wmy,
|
||||||
// point.x,// - wmx,
|
point.x,// - wmx,
|
||||||
// point.y,// - wmy,
|
point.y,// - wmy,
|
||||||
// Math.min(point.z, lastPoint.z)
|
Math.max(point.z, lastPoint.z),
|
||||||
// ) + ztOff,
|
zadd,
|
||||||
let maxz = (toolProfile ? Math.max(
|
maxToolDiam/2,
|
||||||
getTopoZPathMax(
|
zclear
|
||||||
widget,
|
) + ztOff,
|
||||||
toolProfile,
|
// let maxz = (toolProfile ? Math.max(
|
||||||
lastPoint.x - wmx,
|
// getTopoZPathMax(
|
||||||
lastPoint.y - wmy,
|
// widget,
|
||||||
point.x - wmx,
|
// toolProfile,
|
||||||
point.y - wmy),
|
// lastPoint.x - wmx,
|
||||||
point.z,
|
// lastPoint.y - wmy,
|
||||||
lastPoint.z) : zmax) + ztOff + zadd,
|
// point.x - wmx,
|
||||||
|
// point.y - wmy),
|
||||||
|
// point.z,
|
||||||
|
// lastPoint.z) : zmax) + ztOff + zadd,
|
||||||
mustGoUp = Math.max(maxz - point.z, maxz - lastPoint.z) >= tolerance,
|
mustGoUp = Math.max(maxz - point.z, maxz - lastPoint.z) >= tolerance,
|
||||||
clearz = maxz;
|
clearz = maxz;
|
||||||
// up if any point between higher than start/outline
|
// up if any point between higher than start/outline
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue