Open large designs faster: meshes, face names and Measure on all cores (#916)
Display meshes after opening, the face names read when a feature finds a face by name, and inspect.measure over all bodies are now worked out per body on plain scoped threads (solidcraft_kernel::for_each_on_threads / map_on_threads), in body order and with the same results; the browser build stays serial.
This commit is contained in:
1 parent
c333889fc0
commit
6c61442bb2
7 files changed
+110
-6
No files matched your search
@@ -619,6 +619,17 @@ impl ModelState {
|
||||
pub fn body(&self, name: &str) -> Option<&ModelBody> {
|
||||
self.bodies.iter().find(|b| b.name == name)
|
||||
}
|
||||
|
||||
/// Make every body's display mesh now, on all cores (bodies are meshed independently and
|
||||
/// each keeps its own mesh, so the meshes are those `ModelBody::mesh` makes one by one).
|
||||
/// Stops starting bodies once `go_on` says no.
|
||||
pub fn warm_meshes(&self, go_on: impl Fn() -> bool + Sync) {
|
||||
kernel::for_each_on_threads(&self.bodies, 16, |b| {
|
||||
if go_on() {
|
||||
let _ = b.mesh();
|
||||
}
|
||||
});
|
||||
}
|
||||
pub fn sketch(&self, feature: u64) -> Option<&SolvedSketch> {
|
||||
self.sketches.iter().find(|s| s.feature == feature).map(|s| &**s)
|
||||
}
|
||||
|
||||
@@ -260,6 +260,14 @@ impl EdgeHit {
|
||||
/// answering to it (merged into it, or the named piece told apart by the faces around it); else
|
||||
/// the piece of it nearest `p` (`split`).
|
||||
pub fn locate_face(st: &ModelState, name: &str, p: Vec3) -> Option<FaceHit> {
|
||||
// Every body's names are read below: work out the ones not known yet on all cores first
|
||||
// (each body's names are its own, whichever thread works them out).
|
||||
if legacy_name(name).is_none() {
|
||||
let bodies: Vec<&ModelBody> = st.bodies.iter().filter(|b| !b.body.is_mesh()).collect();
|
||||
solidcraft_kernel::for_each_on_threads(&bodies, 16, |b| {
|
||||
let _ = naming::names(b);
|
||||
});
|
||||
}
|
||||
locate_in(st.bodies.iter().enumerate().filter(|(_, b)| !b.body.is_mesh()), name, p)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user