change curves only handling to use geometry input, not path output, as trigger
This commit is contained in:
parent
86273cd7e2
commit
058f5571e1
1 changed files with 24 additions and 8 deletions
|
|
@ -165,7 +165,7 @@ class Topo {
|
||||||
const newP = newPoint(x,y,z);
|
const newP = newPoint(x,y,z);
|
||||||
// todo: merge co-linear, not just co-planar
|
// todo: merge co-linear, not just co-planar
|
||||||
if (lastP && Math.abs(lastP.z - z) < flatness) {
|
if (lastP && Math.abs(lastP.z - z) < flatness) {
|
||||||
if (curvesOnly) {
|
if (false && curvesOnly) {
|
||||||
if ((newtrace.last() || lastP).distTo2D(newP) >= bridge) {
|
if ((newtrace.last() || lastP).distTo2D(newP) >= bridge) {
|
||||||
end_poly();
|
end_poly();
|
||||||
}
|
}
|
||||||
|
|
@ -177,7 +177,7 @@ class Topo {
|
||||||
newtrace.push(latent);
|
newtrace.push(latent);
|
||||||
latent = null;
|
latent = null;
|
||||||
}
|
}
|
||||||
if (curvesOnly && lastP) {
|
if (false && curvesOnly && lastP) {
|
||||||
// maxangle
|
// maxangle
|
||||||
const dz = Math.abs(lastP.z - z);
|
const dz = Math.abs(lastP.z - z);
|
||||||
const dv = contourX ? Math.abs(lastP.x - x) : Math.abs(lastP.y - y);
|
const dv = contourX ? Math.abs(lastP.x - x) : Math.abs(lastP.y - y);
|
||||||
|
|
@ -211,7 +211,7 @@ class Topo {
|
||||||
function raster(slices) {
|
function raster(slices) {
|
||||||
if (!topo.raster) {
|
if (!topo.raster) {
|
||||||
console.log(widget.id, 'topo raster cached');
|
console.log(widget.id, 'topo raster cached');
|
||||||
return;
|
return topo.box;
|
||||||
}
|
}
|
||||||
topo.raster = false;
|
topo.raster = false;
|
||||||
|
|
||||||
|
|
@ -219,7 +219,8 @@ class Topo {
|
||||||
gridy,
|
gridy,
|
||||||
gridi, // index
|
gridi, // index
|
||||||
gridv, // value
|
gridv, // value
|
||||||
i, il, j, jl, x, y, tv, ltv;
|
i, il, j, jl, x, y, tv, ltv,
|
||||||
|
box = topo.box = new THREE.Box2();
|
||||||
|
|
||||||
// filter lines pairs to only surface "up-facing", "uncovered" lines
|
// filter lines pairs to only surface "up-facing", "uncovered" lines
|
||||||
slices.map(slice => {
|
slices.map(slice => {
|
||||||
|
|
@ -231,7 +232,9 @@ class Topo {
|
||||||
outer: for (let i=0; i<len; i++) {
|
outer: for (let i=0; i<len; i++) {
|
||||||
let l1 = lines[i], p1 = l1.p1, p2 = l1.p2;
|
let l1 = lines[i], p1 = l1.p1, p2 = l1.p2;
|
||||||
// eliminate vertical
|
// eliminate vertical
|
||||||
if (p1.y === p2.y) continue;
|
if (Math.abs(p1.y - p2.y) < flatness) continue;
|
||||||
|
// eliminate horizontal when curves only selected
|
||||||
|
if (curvesOnly && Math.abs(p1.z - p2.z) < flatness) continue;
|
||||||
// eliminate if both points below cutoff
|
// eliminate if both points below cutoff
|
||||||
if (p1.z < zMin && p2.z < zMin) continue;
|
if (p1.z < zMin && p2.z < zMin) continue;
|
||||||
// sort p1,p2 by y for comparison
|
// sort p1,p2 by y for comparison
|
||||||
|
|
@ -250,6 +253,8 @@ class Topo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
points.push(p1, p2);
|
points.push(p1, p2);
|
||||||
|
box.expandByPoint(p1);
|
||||||
|
box.expandByPoint(p2);
|
||||||
}
|
}
|
||||||
slice.points = points;
|
slice.points = points;
|
||||||
if (debug_topo_lines) slice.output()
|
if (debug_topo_lines) slice.output()
|
||||||
|
|
@ -287,7 +292,7 @@ class Topo {
|
||||||
if (nz > gridv) {
|
if (nz > gridv) {
|
||||||
gridv = data[gridi] = Math.max(nz, zMin);
|
gridv = data[gridi] = Math.max(nz, zMin);
|
||||||
if (debug_topo) slice.output()
|
if (debug_topo) slice.output()
|
||||||
.setLayer("topo", {face: color, line: color})
|
.setLayer("heights", {face: color, line: color})
|
||||||
.addLine(
|
.addLine(
|
||||||
newPoint(p1.x, y, 0),
|
newPoint(p1.x, y, 0),
|
||||||
newPoint(p1.x, y, gridv)
|
newPoint(p1.x, y, gridv)
|
||||||
|
|
@ -300,6 +305,8 @@ class Topo {
|
||||||
gridx++;
|
gridx++;
|
||||||
onupdate(++stepsTaken, stepsTotal, "raster surface");
|
onupdate(++stepsTaken, stepsTotal, "raster surface");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return box;
|
||||||
}
|
}
|
||||||
|
|
||||||
function processSlices(slices) {
|
function processSlices(slices) {
|
||||||
|
|
@ -309,8 +316,7 @@ class Topo {
|
||||||
gridv, // value
|
gridv, // value
|
||||||
i, il, j, jl, x, y, tv, ltv;
|
i, il, j, jl, x, y, tv, ltv;
|
||||||
|
|
||||||
raster(slices);
|
const box = raster(slices);
|
||||||
|
|
||||||
const checkr = newPoint(0,0);
|
const checkr = newPoint(0,0);
|
||||||
const inClip = function(polys, checkZ) {
|
const inClip = function(polys, checkZ) {
|
||||||
checkr.x = x;
|
checkr.x = x;
|
||||||
|
|
@ -331,12 +337,17 @@ class Topo {
|
||||||
startTime = time();
|
startTime = time();
|
||||||
// emit slice per X
|
// emit slice per X
|
||||||
for (x = minX - partOff; x <= maxX + partOff; x += toolStep) {
|
for (x = minX - partOff; x <= maxX + partOff; x += toolStep) {
|
||||||
|
if (x < box.min.x || x > box.max.x) continue;
|
||||||
gridx = Math.round(((x - minX) / boundsX) * stepsx);
|
gridx = Math.round(((x - minX) / boundsX) * stepsx);
|
||||||
ly = gridy = -gridDelta;
|
ly = gridy = -gridDelta;
|
||||||
slice = newSlice(gridx);
|
slice = newSlice(gridx);
|
||||||
newtrace = newPolygon().setOpen();
|
newtrace = newPolygon().setOpen();
|
||||||
sliceout = [];
|
sliceout = [];
|
||||||
for (y = minY - partOff; y < maxY + partOff; y += resolution) {
|
for (y = minY - partOff; y < maxY + partOff; y += resolution) {
|
||||||
|
if (y < box.min.y || y > box.max.y) {
|
||||||
|
gridy++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// find tool z at grid point
|
// find tool z at grid point
|
||||||
tv = toolAtZ(gridx, gridy);
|
tv = toolAtZ(gridx, gridy);
|
||||||
// when tabs are on and this point is inside the
|
// when tabs are on and this point is inside the
|
||||||
|
|
@ -373,12 +384,17 @@ class Topo {
|
||||||
startTime = time();
|
startTime = time();
|
||||||
// emit slice per Y
|
// emit slice per Y
|
||||||
for (y = minY - partOff; y <= maxY + partOff; y += toolStep) {
|
for (y = minY - partOff; y <= maxY + partOff; y += toolStep) {
|
||||||
|
if (y < box.min.y || y > box.max.y) continue;
|
||||||
gridy = Math.round(((y - minY) / boundsY) * stepsy);
|
gridy = Math.round(((y - minY) / boundsY) * stepsy);
|
||||||
lx = gridx = -gridDelta;
|
lx = gridx = -gridDelta;
|
||||||
slice = newSlice(gridy);
|
slice = newSlice(gridy);
|
||||||
newtrace = newPolygon().setOpen();
|
newtrace = newPolygon().setOpen();
|
||||||
sliceout = [];
|
sliceout = [];
|
||||||
for (x = minX - partOff; x <= maxX + partOff; x += resolution) {
|
for (x = minX - partOff; x <= maxX + partOff; x += resolution) {
|
||||||
|
if (x < box.min.x || x > box.max.x) {
|
||||||
|
gridx++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
tv = toolAtZ(gridx, gridy);
|
tv = toolAtZ(gridx, gridy);
|
||||||
if (tabsOn && tv < tabHeight && inClip(clipTab, tv)) {
|
if (tabsOn && tv < tabHeight && inClip(clipTab, tv)) {
|
||||||
tv = tabZ;
|
tv = tabZ;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue