add trace re-contouring when poly z varies, offset present, no step down

This commit is contained in:
Stewart Allen 2025-06-27 01:02:12 -04:00
commit 82e2742b8d
4 changed files with 41 additions and 20 deletions

View file

@ -165,6 +165,7 @@ CAM.slice = async function(settings, widget, onupdate, ondone) {
tabs,
cutTabs,
cutPolys,
contourPolys,
healPolys,
shadowAt,
slicer,
@ -365,8 +366,6 @@ CAM.slice = async function(settings, widget, onupdate, ondone) {
ondone();
};
CAM.addDogbones = function(poly, dist, reverse) {
if (Array.isArray(poly)) {
return poly.forEach(p => CAM.addDogbones(p, dist));
@ -512,16 +511,16 @@ CAM.traces = async function(settings, widget, single) {
return true;
};
/**
* Generate a list of holes in the model based on the given diameter.
*
* @param {Object} settings - settings object
* @param {Object} widget - widget object
* @param {boolean} individual - if true, drill holes individually
* @param {Object} rec - DrillOp record
* @param {Function} onProgress - callback function to report progress
* @returns {Array} list of hole centers as objects with `x`, `y`, `z`, `depth`, and `selected` properties.
*/
/**
* Generate a list of holes in the model based on the given diameter.
*
* @param {Object} settings - settings object
* @param {Object} widget - widget object
* @param {boolean} individual - if true, drill holes individually
* @param {Object} rec - DrillOp record
* @param {Function} onProgress - callback function to report progress
* @returns {Array} list of hole centers as objects with `x`, `y`, `z`, `depth`, and `selected` properties.
*/
CAM.holes = async function(settings, widget, individual, rec,onProgress) {
let {tool,mark,precision} = rec //TODO: display some visual difference if mark is selected
@ -603,7 +602,6 @@ CAM.holes = async function(settings, widget, individual, rec,onProgress) {
// //if on the same xy point,
if (dist <= centerDiff ) {
// console.log("overlap",center,circle);
circle.overlapping.push(center);
// if overlapping, don't add and continue
@ -669,6 +667,19 @@ function cutPolys(polys, offset, z, inter) {
return healPolys(noff);
}
function contourPolys(widget, polys) {
const raycaster = new THREE.Raycaster();
raycaster.ray.direction.set(0, 0, -1); // ray pointing down Z
for (let poly of polys) {
for (let point of poly.points) {
raycaster.ray.origin.set(point.x, point.y, 10000);
const intersects = raycaster.intersectObject(widget.mesh, true);
const firstHit = intersects[0] || null;
point.z = firstHit.point.z;
}
}
}
function healPolys(noff) {
if (noff.length > 1) {
let heal = 0;