fix multiple tab heights in contouring

This commit is contained in:
Stewart Allen 2020-11-28 10:35:46 -05:00
commit 0842d235a3
4 changed files with 17 additions and 10 deletions

View file

@ -148,7 +148,7 @@
let terrain = slicer.slice(tzindex, { each: (data, index, total) => {
tshadow = POLY.union(tshadow.appendAll(data.tops), 0.01, true);
tslices.push(data.slice);
if (true) {
if (false) {
const slice = data.slice;
sliceAll.push(slice);
slice.output()

View file

@ -74,7 +74,11 @@
debug_topo_shells = debug && true;
if (tabs) {
clipTab.appendAll(tabs.map(tab => POLY.expand([tab.poly], toolDiameter/2)).flat());
clipTab.appendAll(tabs.map(tab => {
let ctab = POLY.expand([tab.poly], toolDiameter/2);
ctab.forEach(ct => ct.z = tab.dim.z);
return ctab;
}).flat());
}
// debug clipTab and clipTo
@ -257,16 +261,20 @@
}
const checkr = newPoint(0,0);
const inClip = function(polys) {
const inClip = function(polys, checkZ) {
checkr.x = x;
checkr.y = y;
for (let i=0; i<polys.length; i++) {
if (checkr.isInPolygon(polys[i])) {
let poly = polys[i];
let zok = checkZ ? checkZ <= poly.z : true;
tabZ = poly.z;
if (zok && checkr.isInPolygon(poly)) {
return true;
}
}
return false;
};
let tabZ;
// x contouring
if (proc.camContourXOn) {
@ -284,8 +292,8 @@
tv = toolAtZ(gridx, gridy);
// when tabs are on and this point is inside the
// tab polygon, ensure z is at least tabHeight
if (tabsOn && tv < tabHeight && inClip(clipTab)) {
tv = tabHeight;
if (tabsOn && tv < tabHeight && inClip(clipTab, tv)) {
tv = tabZ;//tabHeight;
}
// if the value is on the floor and inside the clip
// poly (usually shadow), end the segment
@ -325,8 +333,8 @@
sliceout = [];
for (x = minX - partOff; x <= maxX + partOff; x += resolution) {
tv = toolAtZ(gridx, gridy);
if (tabsOn && tv < tabHeight && inClip(clipTab)) {
tv = tabHeight;
if (tabsOn && tv < tabHeight && inClip(clipTab, tv)) {
tv = tabZ;
}
if (clipTo && !inClip(clipTo)) {
end_poly();