simplify: joining in modelcraft-mesh::join, shared label helper, run_script returns step outputs

Weld and face-to-face check move from the mesh.block command to
modelcraft_mesh::join (bounding-box-limited weld, grid-binned hanging-node
test), for node merging and imports to reuse. mesh.block and
mesh.tet.generate share fresh_labels. The block map evaluates each edge
curve once per lattice parameter; vector helpers come from vec3; tet10 and
hex20 mid-side nodes follow ElementKind::edges. Session::run_script returns
each step's output, which the oracle reads instead of its own loop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NmAttHhUZTokgPeEJia8sm
This commit is contained in:
jyvikoandClaude Opus 5.5 authored and Irakli Kourtis committed 2026-10-13 21:42:19 -04:00
1 parent cbff230734
commit 6dda34e837
11 files changed
+369 -359

No files matched your search

+13
View File
@@ -109,6 +109,19 @@ pub(crate) fn label(p: &Value, key: &str) -> Result<u32> {
.ok_or_else(|| EngineError::Params(format!("`{key}` must be a positive whole number")))
}
/// The first node and element labels after the model's largest, for `nodes` new nodes and
/// `elements` new elements, all within [`MAX_LABEL`].
pub(crate) fn fresh_labels(model: &modelcraft_model::Model, nodes: usize, elements: usize) -> Result<(u32, u32)> {
let first = |last: Option<&u32>, count: usize| {
let first = last.map_or(Some(1), |l| l.checked_add(1))?;
(u64::from(first) + count as u64 <= u64::from(MAX_LABEL) + 1).then_some(first)
};
match (first(model.nodes().keys().next_back(), nodes), first(model.elements().keys().next_back(), elements)) {
(Some(n), Some(e)) => Ok((n, e)),
_ => Err(EngineError::Params(format!("the mesh needs labels beyond {MAX_LABEL}"))),
}
}
/// A required `[x, y, z]` parameter.
pub(crate) fn xyz(p: &Value, key: &str) -> Result<[f64; 3]> {
p.get(key).and_then(xyz_value).ok_or_else(|| EngineError::Params(format!("`{key}` must be [x, y, z]")))