remove unused return data. move rastering into slicing pipeline
This commit is contained in:
parent
d8e731ed85
commit
94cf3c452d
1 changed files with 41 additions and 76 deletions
|
|
@ -212,38 +212,7 @@ class Topo {
|
||||||
lastP = undefined;
|
lastP = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
function rastering(slices) {
|
function contouring() {
|
||||||
if (!topo.raster) {
|
|
||||||
console.log(widget.id, 'topo raster cached');
|
|
||||||
return topo.box;
|
|
||||||
}
|
|
||||||
|
|
||||||
topo.raster = false;
|
|
||||||
topo.box = new THREE.Box2();
|
|
||||||
|
|
||||||
let gridx = 0;
|
|
||||||
for (let slice of slices) {
|
|
||||||
newslices.push(slice);
|
|
||||||
slice.points = raster_slice({
|
|
||||||
lines: slice.lines,
|
|
||||||
box: topo.box,
|
|
||||||
data,
|
|
||||||
resolution,
|
|
||||||
curvesOnly,
|
|
||||||
flatness,
|
|
||||||
zMin,
|
|
||||||
minY,
|
|
||||||
maxY,
|
|
||||||
stepsY,
|
|
||||||
slice,
|
|
||||||
gridx: gridx++
|
|
||||||
});
|
|
||||||
onupdate(++stepsTaken, stepsTotal, "raster surface");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function contouring(slices) {
|
|
||||||
let gridx = 0,
|
let gridx = 0,
|
||||||
gridy,
|
gridy,
|
||||||
gridi, // index
|
gridi, // index
|
||||||
|
|
@ -360,6 +329,8 @@ class Topo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const box = topo.box = new THREE.Box2();
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
resolution,
|
resolution,
|
||||||
curvesOnly,
|
curvesOnly,
|
||||||
|
|
@ -368,13 +339,13 @@ class Topo {
|
||||||
minY,
|
minY,
|
||||||
maxY,
|
maxY,
|
||||||
zMin,
|
zMin,
|
||||||
data
|
data,
|
||||||
|
box
|
||||||
};
|
};
|
||||||
|
|
||||||
const slices2 = await this.topo_slice(widget, params);
|
await this.topo_slice(widget, params);
|
||||||
|
|
||||||
rastering(slices2);
|
contouring();
|
||||||
contouring(slices2);
|
|
||||||
ondone(newslices);
|
ondone(newslices);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|
@ -389,6 +360,7 @@ class Topo {
|
||||||
const minions = kiri.minions;
|
const minions = kiri.minions;
|
||||||
const vertices = widget.getGeoVertices().toShared();
|
const vertices = widget.getGeoVertices().toShared();
|
||||||
const range = { min: Infinity, max: -Infinity };
|
const range = { min: Infinity, max: -Infinity };
|
||||||
|
const { box } = params;
|
||||||
|
|
||||||
// swap XZ in shared array
|
// swap XZ in shared array
|
||||||
for (let i=0,l=vertices.length; i<l; i += 3) {
|
for (let i=0,l=vertices.length; i<l; i += 3) {
|
||||||
|
|
@ -424,7 +396,7 @@ class Topo {
|
||||||
// console.log({ put_cache_done: data });
|
// console.log({ put_cache_done: data });
|
||||||
}});
|
}});
|
||||||
|
|
||||||
let ps = slices.map((slice, index) => {
|
let promises = slices.map((slice, index) => {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
minions.queue({
|
minions.queue({
|
||||||
cmd: "topo_slice",
|
cmd: "topo_slice",
|
||||||
|
|
@ -437,41 +409,34 @@ class Topo {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
slices = (await Promise.all(ps))
|
// merge boxes for all rasters for contouring clipping
|
||||||
.map(rec => rec.res)
|
(await Promise.all(promises))
|
||||||
.flat()
|
.map(rec => rec.box)
|
||||||
.sort((a,b) => a[0] - b[0])
|
.map(box => new THREE.Box2(
|
||||||
.map(rec => {
|
new THREE.Vector2(box.min.x, box.min.y),
|
||||||
let slice = kiri.newSlice(rec[0]);
|
new THREE.Vector2(box.max.x, box.max.y)
|
||||||
slice.index = rec[1];
|
))
|
||||||
let lines = slice.lines = [];
|
.map(box2 => {
|
||||||
for (let i=2, l=rec.length; i<l; ) {
|
box.union(box2);
|
||||||
lines.push(
|
return box2;
|
||||||
base.newLine(
|
|
||||||
base.newPoint(rec[i++], rec[i++], rec[i++]),
|
|
||||||
base.newPoint(rec[i++], rec[i++], rec[i++])
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return slice;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
dispatch.clearCache({}, { done: data => {
|
dispatch.clearCache({}, { done: data => {
|
||||||
// console.log({ clear_cache_done: data });
|
// console.log({ clear_cache_done: data });
|
||||||
}});
|
}});
|
||||||
console.timeEnd('new topo slice minion');
|
console.timeEnd('new topo slice minion');
|
||||||
return slices;
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
console.time('new topo slice');
|
console.time('new topo slice');
|
||||||
// iterate over shards, merge output
|
// iterate over shards, merge output
|
||||||
const output = [];
|
// const output = [];
|
||||||
for (let slice of slices) {
|
for (let slice of slices) {
|
||||||
const res = new kiri.topo_slicer(slice.index)
|
new kiri.topo_slicer(slice.index)
|
||||||
.setFromArray(vertices, slice)
|
.setFromArray(vertices, slice)
|
||||||
.slice(resolution)
|
.slice(resolution)
|
||||||
.map(rec => {
|
.map(rec => {
|
||||||
|
|
||||||
const slice = kiri.newSlice(rec.z);
|
const slice = kiri.newSlice(rec.z);
|
||||||
slice.index = rec.index;
|
slice.index = rec.index;
|
||||||
slice.lines = rec.lines;
|
slice.lines = rec.lines;
|
||||||
|
|
@ -480,13 +445,18 @@ class Topo {
|
||||||
if (!p1.swapped) { p1.swapXZ(); p1.swapped = true }
|
if (!p1.swapped) { p1.swapXZ(); p1.swapped = true }
|
||||||
if (!p2.swapped) { p2.swapXZ(); p2.swapped = true }
|
if (!p2.swapped) { p2.swapXZ(); p2.swapped = true }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
raster_slice({
|
||||||
|
...params,
|
||||||
|
box,
|
||||||
|
lines: rec.lines,
|
||||||
|
gridx: rec.index
|
||||||
|
});
|
||||||
|
|
||||||
return slice;
|
return slice;
|
||||||
});
|
});
|
||||||
output.appendAll(res);
|
|
||||||
}
|
}
|
||||||
output.sort((a,b) => a.z - b.z);
|
|
||||||
console.timeEnd('new topo slice');
|
console.timeEnd('new topo slice');
|
||||||
return output;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -595,33 +565,28 @@ moto.broker.subscribe("minion.started", msg => {
|
||||||
const { id, slice, params } = data;
|
const { id, slice, params } = data;
|
||||||
const { resolution } = params;
|
const { resolution } = params;
|
||||||
const vertices = cache[id];
|
const vertices = cache[id];
|
||||||
const res = new kiri.topo_slicer(slice.index)
|
const box = new THREE.Box2();
|
||||||
|
new kiri.topo_slicer(slice.index)
|
||||||
.setFromArray(vertices, slice)
|
.setFromArray(vertices, slice)
|
||||||
.slice(resolution)
|
.slice(resolution)
|
||||||
.map(rec => {
|
.forEach(rec => {
|
||||||
const { z, index, lines } = rec;
|
const { z, index, lines } = rec;
|
||||||
|
|
||||||
const ret = [ z, index ];
|
|
||||||
for (let line of lines) {
|
for (let line of lines) {
|
||||||
const { p1, p2 } = line;
|
const { p1, p2 } = line;
|
||||||
if (!p1.swapped) { p1.swapXZ(); p1.swapped = true }
|
if (!p1.swapped) { p1.swapXZ(); p1.swapped = true }
|
||||||
if (!p2.swapped) { p2.swapXZ(); p2.swapped = true }
|
if (!p2.swapped) { p2.swapXZ(); p2.swapped = true }
|
||||||
ret.push(p1.x, p1.y, p1.z);
|
|
||||||
ret.push(p2.x, p2.y, p2.z);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// const box = new THREE.Box2();
|
raster_slice({
|
||||||
// const points = raster_slice({
|
...params,
|
||||||
// ...params,
|
box,
|
||||||
// box,
|
lines,
|
||||||
// lines,
|
gridx: index
|
||||||
// gridx: index
|
|
||||||
// });
|
|
||||||
// console.log({ box, points });
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
});
|
});
|
||||||
reply({ seq, res });
|
});
|
||||||
|
// only pass back bounds of rasters to be merged
|
||||||
|
reply({ seq, box });
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue