checkpoint send trace state to minions
This commit is contained in:
parent
f751f75c74
commit
bb291d659a
2 changed files with 82 additions and 38 deletions
|
|
@ -128,8 +128,7 @@ class Topo {
|
||||||
this.toolAtXY = toolAtXY;
|
this.toolAtXY = toolAtXY;
|
||||||
this.zAtXY = zAtXY;
|
this.zAtXY = zAtXY;
|
||||||
|
|
||||||
const trace = this.trace = new Trace({
|
const trace = this.trace = new Trace(probe, {
|
||||||
probe,
|
|
||||||
curvesOnly,
|
curvesOnly,
|
||||||
maxangle,
|
maxangle,
|
||||||
flatness
|
flatness
|
||||||
|
|
@ -190,8 +189,6 @@ class Topo {
|
||||||
|
|
||||||
console.log({ topo_raster: widget, resolution });
|
console.log({ topo_raster: widget, resolution });
|
||||||
|
|
||||||
// const worker = kiri.worker;
|
|
||||||
// const minions = kiri.minions;
|
|
||||||
const { worker, minions } = kiri;
|
const { worker, minions } = kiri;
|
||||||
const vertices = widget.getGeoVertices().toShared();
|
const vertices = widget.getGeoVertices().toShared();
|
||||||
const range = { min: Infinity, max: -Infinity };
|
const range = { min: Infinity, max: -Infinity };
|
||||||
|
|
@ -297,6 +294,7 @@ class Topo {
|
||||||
|
|
||||||
async contour(params) {
|
async contour(params) {
|
||||||
const trace = this.trace;
|
const trace = this.trace;
|
||||||
|
const concurrent = kiri.minions.running;
|
||||||
|
|
||||||
const { minX, maxX, minY, maxY, boundsX, boundsY, stepsX, stepsY } = params;
|
const { minX, maxX, minY, maxY, boundsX, boundsY, stepsX, stepsY } = params;
|
||||||
const { gridDelta, resolution, partOff, toolStep, contourX, contourY } = params;
|
const { gridDelta, resolution, partOff, toolStep, contourX, contourY } = params;
|
||||||
|
|
@ -322,6 +320,15 @@ class Topo {
|
||||||
partOff, partOff, 0
|
partOff, partOff, 0
|
||||||
));
|
));
|
||||||
|
|
||||||
|
trace.init({
|
||||||
|
box,
|
||||||
|
clipTo,
|
||||||
|
clipTab,
|
||||||
|
tabHeight,
|
||||||
|
resolution,
|
||||||
|
concurrent
|
||||||
|
});
|
||||||
|
|
||||||
if (contourY) {
|
if (contourY) {
|
||||||
// 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) {
|
||||||
|
|
@ -329,28 +336,23 @@ class Topo {
|
||||||
gridx = Math.round(((x - minX) / boundsX) * stepsX);
|
gridx = Math.round(((x - minX) / boundsX) * stepsX);
|
||||||
gridy = -gridDelta;
|
gridy = -gridDelta;
|
||||||
|
|
||||||
const segments = trace.crossY({
|
trace.crossY({
|
||||||
from: minY - partOff,
|
from: minY - partOff,
|
||||||
to: maxY + partOff,
|
to: maxY + partOff,
|
||||||
step: resolution,
|
|
||||||
box,
|
|
||||||
x,
|
x,
|
||||||
gridx,
|
gridx,
|
||||||
gridy,
|
gridy
|
||||||
clipTo,
|
}, segments => {
|
||||||
clipTab,
|
if (segments.length > 0) {
|
||||||
tabHeight
|
let slice = newSlice(gridx);
|
||||||
|
slice.camLines = segments;
|
||||||
|
slice.output()
|
||||||
|
.setLayer("contour y", {face: color, line: color})
|
||||||
|
.addPolys(segments);
|
||||||
|
newslices.push(slice);
|
||||||
|
}
|
||||||
|
onupdate(++stepsTaken, stepsTotal, "contour y");
|
||||||
});
|
});
|
||||||
|
|
||||||
if (segments.length > 0) {
|
|
||||||
let slice = newSlice(gridx);
|
|
||||||
slice.camLines = segments;
|
|
||||||
slice.output()
|
|
||||||
.setLayer("contour y", {face: color, line: color})
|
|
||||||
.addPolys(segments);
|
|
||||||
newslices.push(slice);
|
|
||||||
}
|
|
||||||
onupdate(++stepsTaken, stepsTotal, "contour y");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -364,14 +366,9 @@ class Topo {
|
||||||
const segments = trace.crossX({
|
const segments = trace.crossX({
|
||||||
from: minX - partOff,
|
from: minX - partOff,
|
||||||
to: maxX + partOff,
|
to: maxX + partOff,
|
||||||
step: resolution,
|
|
||||||
box,
|
|
||||||
y,
|
y,
|
||||||
gridx,
|
gridx,
|
||||||
gridy,
|
gridy
|
||||||
clipTo,
|
|
||||||
clipTab,
|
|
||||||
tabHeight
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (segments.length > 0) {
|
if (segments.length > 0) {
|
||||||
|
|
@ -385,6 +382,8 @@ class Topo {
|
||||||
onupdate(++stepsTaken, stepsTotal, "contour x");
|
onupdate(++stepsTaken, stepsTotal, "contour x");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trace.cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -396,6 +395,8 @@ class Probe {
|
||||||
const { data, profile } = params;
|
const { data, profile } = params;
|
||||||
const { stepsX, stepsY, boundsX, boundsY, zMin } = params;
|
const { stepsX, stepsY, boundsX, boundsY, zMin } = params;
|
||||||
|
|
||||||
|
this.params = params;
|
||||||
|
|
||||||
// return the touching z given topo x,y and a tool profile
|
// return the touching z given topo x,y and a tool profile
|
||||||
const toolAtZ = this.toolAtZ = function(x,y) {
|
const toolAtZ = this.toolAtZ = function(x,y) {
|
||||||
let sx = stepsX,
|
let sx = stepsX,
|
||||||
|
|
@ -445,10 +446,11 @@ class Probe {
|
||||||
|
|
||||||
class Trace {
|
class Trace {
|
||||||
|
|
||||||
constructor(params) {
|
constructor(probe, params) {
|
||||||
|
|
||||||
const { probe, curvesOnly, maxangle, flatness } = params;
|
const { curvesOnly, maxangle, flatness } = params;
|
||||||
|
|
||||||
|
this.params = params;
|
||||||
this.probe = probe;
|
this.probe = probe;
|
||||||
|
|
||||||
let trace,
|
let trace,
|
||||||
|
|
@ -527,15 +529,37 @@ class Trace {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
crossY(params) {
|
init(params) {
|
||||||
|
this.cross = params;
|
||||||
|
if (this.cross.concurrent) {
|
||||||
|
const { worker, minions } = kiri;
|
||||||
|
const { codec } = kiri;
|
||||||
|
|
||||||
|
minions.broadcast("trace_init", codec.encode({
|
||||||
|
probe: this.probe.params,
|
||||||
|
trace: this.params,
|
||||||
|
cross: params,
|
||||||
|
// clipTo: codec.encode(params.clipTo)
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
if (this.cross.concurrent) {
|
||||||
|
const { worker, minions } = kiri;
|
||||||
|
minions.broadcast("trace_cleanup");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
crossY(params, then) {
|
||||||
const { push_point, end_poly, newtrace, newslice, inClip } = this.object;
|
const { push_point, end_poly, newtrace, newslice, inClip } = this.object;
|
||||||
|
const { clipTab, tabHeight, clipTo, box, resolution } = this.cross;
|
||||||
const { toolAtZ, toolAtXY, zAtXY } = this.probe;
|
const { toolAtZ, toolAtXY, zAtXY } = this.probe;
|
||||||
let { from, to, step, box, x, gridx, gridy } = params;
|
let { from, to, x, gridx, gridy } = params;
|
||||||
let { clipTab, tabHeight, clipTo } = params;
|
|
||||||
const checkr = newPoint(0,0);
|
const checkr = newPoint(0,0);
|
||||||
newslice();
|
newslice();
|
||||||
newtrace();
|
newtrace();
|
||||||
for (let y = from; y < to; y += step) {
|
for (let y = from; y < to; y += resolution) {
|
||||||
if (y < box.min.y || y > box.max.y) {
|
if (y < box.min.y || y > box.max.y) {
|
||||||
gridy++;
|
gridy++;
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -560,18 +584,18 @@ class Trace {
|
||||||
gridy++;
|
gridy++;
|
||||||
}
|
}
|
||||||
end_poly();
|
end_poly();
|
||||||
return this.slice;
|
then(this.slice);
|
||||||
}
|
}
|
||||||
|
|
||||||
crossX(params) {
|
crossX(params) {
|
||||||
const { push_point, end_poly, newtrace, newslice, inClip } = this.object;
|
const { push_point, end_poly, newtrace, newslice, inClip } = this.object;
|
||||||
|
const { clipTab, tabHeight, clipTo, box, resolution } = this.cross;
|
||||||
const { toolAtZ, toolAtXY, zAtXY } = this.probe;
|
const { toolAtZ, toolAtXY, zAtXY } = this.probe;
|
||||||
let { from, to, step, box, y, gridx, gridy } = params;
|
let { from, to, y, gridx, gridy } = params;
|
||||||
let { clipTab, tabHeight, clipTo } = params;
|
|
||||||
const checkr = newPoint(0,0);
|
const checkr = newPoint(0,0);
|
||||||
newslice();
|
newslice();
|
||||||
newtrace();
|
newtrace();
|
||||||
for (let x = from; x < to; x += step) {
|
for (let x = from; x < to; x += resolution) {
|
||||||
if (x < box.min.x || y > box.max.x) {
|
if (x < box.min.x || y > box.max.x) {
|
||||||
gridx++;
|
gridx++;
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -726,6 +750,26 @@ moto.broker.subscribe("minion.started", msg => {
|
||||||
// only pass back bounds of rasters to be merged
|
// only pass back bounds of rasters to be merged
|
||||||
reply({ seq, box });
|
reply({ seq, box });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
funcs.trace_init = data => {
|
||||||
|
const { cache } = self;
|
||||||
|
const { codec } = kiri;
|
||||||
|
data.cross.clipTo = codec.decode(data.cross.clipTo);
|
||||||
|
data.cross.clipTab = codec.decode(data.cross.clipTab);
|
||||||
|
const probe = new Probe(data.probe);
|
||||||
|
const trace = new Trace(probe, data.trace);
|
||||||
|
cache.trace = {
|
||||||
|
probe,
|
||||||
|
trace,
|
||||||
|
cross: data.cross
|
||||||
|
};
|
||||||
|
log('trace_init', { data, trace: cache.trace });
|
||||||
|
};
|
||||||
|
|
||||||
|
funcs.trace_cleanup = () => {
|
||||||
|
// log('trace_cleanup');
|
||||||
|
delete cache.trace;
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,7 @@ const funcs = self.minion = {
|
||||||
},
|
},
|
||||||
|
|
||||||
clearCache: msg => {
|
clearCache: msg => {
|
||||||
cache = self.cache = [];
|
cache = self.cache = {};
|
||||||
},
|
},
|
||||||
|
|
||||||
wasm: data => {
|
wasm: data => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue