checkpoint
This commit is contained in:
parent
849a55439b
commit
ed90dea0a5
2 changed files with 51 additions and 38 deletions
|
|
@ -41,15 +41,18 @@ class Slicer {
|
||||||
const x2 = position[i++];
|
const x2 = position[i++];
|
||||||
const y2 = position[i++];
|
const y2 = position[i++];
|
||||||
const z2 = position[i++];
|
const z2 = position[i++];
|
||||||
if (Math.min(z0, z1, z2) >= min && Math.max(z0, z1, z2) <= max) {
|
const minz = Math.min(z0, z1, z2);
|
||||||
pts.push(
|
const maxz = Math.max(z0, z1, z2);
|
||||||
newPoint(x0, y0, z0),
|
if (maxz < min || minz > max) {
|
||||||
newPoint(x1, y1, z1),
|
continue;
|
||||||
newPoint(x2, y2, z2)
|
|
||||||
);
|
|
||||||
this.min = Math.min(this.min, z0, z1, z2);
|
|
||||||
this.max = Math.max(this.max, z0, z1, z2);
|
|
||||||
}
|
}
|
||||||
|
pts.push(
|
||||||
|
newPoint(x0, y0, z0),
|
||||||
|
newPoint(x1, y1, z1),
|
||||||
|
newPoint(x2, y2, z2)
|
||||||
|
);
|
||||||
|
this.min = options.min || Math.min(this.min, minz);
|
||||||
|
this.max = options.max || Math.max(this.max, maxz);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
@ -63,11 +66,14 @@ class Slicer {
|
||||||
const p0 = points[i++];
|
const p0 = points[i++];
|
||||||
const p1 = points[i++];
|
const p1 = points[i++];
|
||||||
const p2 = points[i++];
|
const p2 = points[i++];
|
||||||
if (Math.min(p0.z, p1.z, p2.z) >= min && Math.max(p0.z, p1.z, p2.z) <= max) {
|
const minz = Math.min(p0.z, p1.z, p2.z);
|
||||||
pts.push(p0, p1, p2);
|
const maxz = Math.max(p0.z, p1.z, p2.z);
|
||||||
this.min = Math.min(this.min, p0.z, p1.z, p2.z);
|
if (maxz < min || minz > max) {
|
||||||
this.max = Math.max(this.max, p0.z, p1.z, p2.z);
|
continue;
|
||||||
}
|
}
|
||||||
|
pts.push(p0, p1, p2);
|
||||||
|
this.min = options.min || Math.min(this.min, minz);
|
||||||
|
this.max = options.max || Math.max(this.max, maxz);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
@ -332,6 +338,18 @@ moto.broker.subscribe("worker.started", msg => {
|
||||||
range.min = Math.min(range.min, x);
|
range.min = Math.min(range.min, x);
|
||||||
range.max = Math.max(range.max, x);
|
range.max = Math.max(range.max, x);
|
||||||
}
|
}
|
||||||
|
const shards = Math.ceil(Math.min(25, vertices.length / 27000));
|
||||||
|
const step = (range.max - range.min) / shards;
|
||||||
|
const slices = [];
|
||||||
|
let slice = { min: range.min, max: range.min + step };
|
||||||
|
for (let z = range.min; z < range.max; z += resolution) {
|
||||||
|
if (z > slice.max) {
|
||||||
|
slices.push(slice);
|
||||||
|
slice = { min: z, max: z + step };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
slices.push(slice);
|
||||||
|
console.log({ shards, range, step, slices });
|
||||||
// define sharded ranges
|
// define sharded ranges
|
||||||
if (false && minions.concurrent) {
|
if (false && minions.concurrent) {
|
||||||
dispatch.putCache({ key: widget.id, data: vertices }, { done: data => {
|
dispatch.putCache({ key: widget.id, data: vertices }, { done: data => {
|
||||||
|
|
@ -345,19 +363,25 @@ moto.broker.subscribe("worker.started", msg => {
|
||||||
} else {
|
} else {
|
||||||
console.time('nuslice');
|
console.time('nuslice');
|
||||||
// iterate over shards, merge output
|
// iterate over shards, merge output
|
||||||
const output = new Slicer()
|
const output = [];
|
||||||
.setFromArray(vertices)
|
for (let slice of slices) {
|
||||||
.slice(resolution)
|
console.log({ slice });
|
||||||
.map(rec => {
|
const res = new Slicer()
|
||||||
const slice = kiri.newSlice(rec.z);
|
.setFromArray(vertices, slice)
|
||||||
slice.lines = rec.lines;
|
.slice(resolution)
|
||||||
for (let line of rec.lines) {
|
.map(rec => {
|
||||||
const { p1, p2 } = line;
|
const slice = kiri.newSlice(rec.z);
|
||||||
if (!p1.swapped) { p1.swapXZ(); p1.swapped = true }
|
slice.lines = rec.lines;
|
||||||
if (!p2.swapped) { p2.swapXZ(); p2.swapped = true }
|
for (let line of rec.lines) {
|
||||||
}
|
const { p1, p2 } = line;
|
||||||
return slice;
|
if (!p1.swapped) { p1.swapXZ(); p1.swapped = true }
|
||||||
});
|
if (!p2.swapped) { p2.swapXZ(); p2.swapped = true }
|
||||||
|
}
|
||||||
|
return slice;
|
||||||
|
});
|
||||||
|
output.appendAll(res);
|
||||||
|
}
|
||||||
|
output.sort((a,b) => a.z - b.z);
|
||||||
console.log({ output });
|
console.log({ output });
|
||||||
console.timeEnd('nuslice');
|
console.timeEnd('nuslice');
|
||||||
return output;
|
return output;
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ class Topo {
|
||||||
widtopo = widget.topo,
|
widtopo = widget.topo,
|
||||||
topoCache = widtopo && widtopo.resolution === resolution ? widtopo : undefined,
|
topoCache = widtopo && widtopo.resolution === resolution ? widtopo : undefined,
|
||||||
topo = widget.topo = topoCache || {
|
topo = widget.topo = topoCache || {
|
||||||
data: new Float32Array(stepsx * stepsy),
|
data: new Float32Array(new SharedArrayBuffer(stepsx * stepsy * 4)),
|
||||||
stepsx: stepsx,
|
stepsx: stepsx,
|
||||||
stepsy: stepsy,
|
stepsy: stepsy,
|
||||||
bounds: bounds,
|
bounds: bounds,
|
||||||
|
|
@ -439,16 +439,13 @@ class Topo {
|
||||||
ondone(newslices);
|
ondone(newslices);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('get vertices and points');
|
|
||||||
let points = base.verticesToPoints(widget.getGeoVertices({ unroll: true, translate: true }));
|
|
||||||
|
|
||||||
console.log('topo slice 2');
|
console.log('topo slice 2');
|
||||||
const slices2 = await kiri.topo_slice(widget, resolution);
|
const slices2 = await kiri.topo_slice(widget, resolution);
|
||||||
console.log({ topo_slice_done: slices2 });
|
console.log({ topo_slice_done: slices2 });
|
||||||
processSlices(slices2);
|
processSlices(slices2);
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
console.log('old slice setup')
|
let points = base.verticesToPoints(widget.getGeoVertices({ unroll: true, translate: true }));
|
||||||
let slicer = new kiri.cam_slicer(points, {
|
let slicer = new kiri.cam_slicer(points, {
|
||||||
swapX: true, emptyok: true, notopok: true
|
swapX: true, emptyok: true, notopok: true
|
||||||
});
|
});
|
||||||
|
|
@ -457,20 +454,12 @@ class Topo {
|
||||||
if (contourX) stepsTotal += Math.round((maxY-minY) / toolStep);
|
if (contourX) stepsTotal += Math.round((maxY-minY) / toolStep);
|
||||||
if (contourY) stepsTotal += Math.round((maxX-minX) / toolStep);
|
if (contourY) stepsTotal += Math.round((maxX-minX) / toolStep);
|
||||||
|
|
||||||
console.log('old slice run', stepsTotal)
|
|
||||||
let slices = topo.slices = topo.slices || slicer.slice(sindex, { each: (data, index, total) => {
|
let slices = topo.slices = topo.slices || slicer.slice(sindex, { each: (data, index, total) => {
|
||||||
onupdate(++stepsTaken, stepsTotal, "topo slice");
|
onupdate(++stepsTaken, stepsTotal, "topo slice");
|
||||||
}, genso: true });
|
}, genso: true });
|
||||||
|
|
||||||
console.log('process slices', stepsTaken)
|
|
||||||
processSlices(slices.filter(s => s.lines).map(data => data.slice));
|
processSlices(slices.filter(s => s.lines).map(data => data.slice));
|
||||||
|
|
||||||
console.log('process done', stepsTaken)
|
|
||||||
// const t0 = Date.now();
|
|
||||||
// for (let point of points) point.swapXZ();
|
|
||||||
// let lines = new kiri.cam_slicer2().setFromPoints(points).slice(resolution);
|
|
||||||
// console.log({ sindex, lines, time: Date.now() - t0 });
|
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue