fix shadow/flat for step down that would miss them

This commit is contained in:
Stewart Allen 2020-11-17 20:01:29 -05:00
commit 7b0a85b9a2
3 changed files with 26 additions and 5 deletions

View file

@ -2,8 +2,7 @@
## 2.3 remaining
* cap path ends
* rulers need to follow workspace units
* rough/outline shadow needs to respect flats even when not used as slices
* fix ruler axis name label
* onshape mouse mapping option
## 2.4 tenative list

View file

@ -189,6 +189,7 @@
slice(z, options, index, total, mark) {
const opt = this.setOptions(options);
// if Z is supplied as an array, iterate and collect
if (Array.isArray(z)) {
const mark = UTIL.time();
const rarr = [];
@ -207,6 +208,7 @@
buckets = this.buckets,
bucket = buckets.length ? buckets[Math.floor(z * zScale)] : this.points;
// compensate by moving z by "flatoff" on flats
if (onflat) {
z += flatoff;
}

View file

@ -166,10 +166,11 @@
if (procRough) {
nextOp();
maxToolDiam = Math.max(maxToolDiam, roughToolDiam);
let flats = [];
let shadow = [];
let slices = [];
let indices = slicer.interval(roughDown, { down: true, min: zBottom, fit: true });
// add flats
if (proc.camRoughFlat) {
let flats = Object.keys(slicer.zFlat)
.map(v => parseFloat(v).round(4))
@ -193,10 +194,20 @@
indices[i] = next + ((prev - next) / 2);
}
}
} else {
// add flats to shadow
flats = Object.keys(slicer.zFlat)
.map(v => (parseFloat(v) - 0.01).round(5))
.filter(v => v > 0 && indices.indexOf(v) < 0);
indices = indices.appendAll(flats).sort((a,b) => b-a);
}
// console.log('indices', ...indices, {zBottom});
slicer.slice(indices, { each: (data, index, total) => {
shadow = POLY.union(shadow.appendAll(data.tops), 0.01, true);
if (flats.indexOf(data.z) >= 0) {
// exclude flats injected to complete shadow
return;
}
data.shadow = shadow.clone(true);
data.slice.camMode = PRO.ROUGH;
data.slice.shadow = data.shadow;
@ -295,10 +306,19 @@
let shadow = [];
let slices = [];
const indices = slicer.interval(outlineDown, { down: true, min: zBottom, fit: true });
let indices = slicer.interval(outlineDown, { down: true, min: zBottom, fit: true });
// add flats to shadow
const flats = Object.keys(slicer.zFlat)
.map(v => (parseFloat(v) - 0.01).round(5))
.filter(v => v > 0 && indices.indexOf(v) < 0);
indices = indices.appendAll(flats).sort((a,b) => b-a);
// console.log('indices', ...indices, {zBottom, slicer});
slicer.slice(indices, { each: (data, index, total) => {
shadow = POLY.union(shadow.appendAll(data.tops), 0.01, true);
if (flats.indexOf(data.z) >= 0) {
// exclude flats injected to complete shadow
return;
}
data.shadow = shadow.clone(true);
data.slice.camMode = PRO.OUTLINE;
data.slice.shadow = data.shadow;
@ -325,7 +345,7 @@
}
slices.forEach(slice => {
let tops = slice.shadow;//.clone(true);
let tops = slice.shadow;
let offset = POLY.expand(tops, outlineToolDiam / 2, slice.z);
if (!(offset && offset.length)) {
return;