SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Wave 394/509: Exploded views are shown only: the design's placements and Capture Position leave them out (and 2 more)
jyviko86390de541f8
diff --git a/crates/doc/src/eval.rs b/crates/doc/src/eval.rsindex 289dab12ab..efcd233ab7 100644--- a/crates/doc/src/eval.rs+++ b/crates/doc/src/eval.rs@@ -347,9 +347,9 @@ impl ModelBody {self.mesh.get().cloned()}- /// The isoparametric curves of face `face` for Isocurve Analysis: spaced by `count` on the- /// face's surface (so faces on one surface share them), exact and cut to its trims- /// ([`kernel::iso_grid`]), their points at the chord+ /// The isoparametric curves of face `face` for Isocurve Analysis: `count` each way, evenly+ /// spaced across the face (faces on one surface spaced together, so they share them), exact+ /// and cut to its trims ([`kernel::iso_grid`]), their points at the chord/// tolerance of the viewport's display quality. Worked out once per face, count and display/// quality, and shared by every clone of this body (timeline snapshots, world states). A mesh/// body has no surfaces, so none.diff --git a/crates/engine/src/cmd/component.rs b/crates/engine/src/cmd/component.rsindex a99d000a57..5bb82ddf41 100644--- a/crates/engine/src/cmd/component.rs+++ b/crates/engine/src/cmd/component.rs@@ -430,8 +430,8 @@ pub(super) fn copy_occurrence(s: &mut Session, p: &Value) -> Result<Value> {let m = if bool_(p, "in_place") == Some(true) {placing::in_place(s, &occurrence_path(s, p, src.id, cmd)?, parent, placing::parent_path(p, cmd)?.as_deref(), t, cmd)?} else {- let base = s.pending_moves.get(&src.id).unwrap_or(&src.transform);- solidcraft_doc::mat_mul(&translation(t), base)+ let base = s.uncaptured_moves().get(&src.id).copied().unwrap_or(src.transform);+ solidcraft_doc::mat_mul(&translation(t), &base)};if !valid_position(&m) {return Err(bad(cmd, "copy transform exceeds supported numeric range"));@@ -469,7 +469,7 @@ fn paste_new(s: &mut Session, p: &Value) -> Result<Value> {let transform = match occ.as_ref().filter(|_| bool_(p, "in_place") == Some(true)) {Some(o) => placing::in_place(s, &occurrence_path(s, p, o.id, cmd)?, parent, placing::parent_path(p, cmd)?.as_deref(), t, cmd)?,None => {- let base = occ.as_ref().map(|o| s.pending_moves.get(&o.id).copied().unwrap_or(o.transform)).unwrap_or(solidcraft_doc::IDENTITY);+ let base = occ.as_ref().map(|o| s.uncaptured_moves().get(&o.id).copied().unwrap_or(o.transform)).unwrap_or(solidcraft_doc::IDENTITY);solidcraft_doc::mat_mul(&translation(t), &base)}};@@ -560,7 +560,7 @@ fn move_occurrence(s: &mut Session, p: &Value) -> Result<Value> {}let path = if p.get("path").is_some() || space == "world" { Some(occurrence_path(s, p, id, cmd)?) } else { None };let delta = if space == "world" {- let placement = s.occurrence_placement(path.as_deref().unwrap_or(&[]))?;+ let placement = s.occurrence_placement_with(path.as_deref().unwrap_or(&[]), &s.uncaptured_moves())?;let inverse = solidcraft_doc::mat_inverse(&placement.parent_world).ok_or_else(|| bad(cmd, "parent frame is singular"))?;solidcraft_doc::mat_mul(&solidcraft_doc::mat_mul(&inverse, &delta), &placement.parent_world)} else {@@ -579,7 +579,7 @@ fn move_occurrence(s: &mut Session, p: &Value) -> Result<Value> {}base} else {- s.pending_moves.get(&id).copied().unwrap_or(o.transform)+ s.uncaptured_moves().get(&id).copied().unwrap_or(o.transform)};let next = solidcraft_doc::mat_mul(&delta, &cur);if !valid_position(&next) {@@ -611,7 +611,9 @@ fn ground(s: &mut Session, p: &Value) -> Result<Value> {}fn capture(s: &mut Session, _p: &Value) -> Result<Value> {- let moves = std::mem::take(&mut s.pending_moves);+ // The exploded view is shown, never captured: it stays shown, the design keeps its placements.+ let moves = s.uncaptured_moves().into_owned();+ s.pending_moves.retain(|id, _| !moves.contains_key(id));let n = moves.len();for (id, m) in moves {if let Some(o) = s.doc_mut().occurrences.iter_mut().find(|o| o.id == id) {diff --git a/crates/engine/src/cmd/component_clone.rs b/crates/engine/src/cmd/component_clone.rsindex 1d2e1e839a..5e0b9e5dcb 100644--- a/crates/engine/src/cmd/component_clone.rs+++ b/crates/engine/src/cmd/component_clone.rs@@ -277,7 +277,7 @@ pub(super) fn paste(for old in source.occurrences.iter().filter(|o| selected.contains(&o.parent)) {let child = *components.get(&old.component).ok_or_else(|| bad(CMD, "missing child definition"))?;let owner = *components.get(&old.parent).ok_or_else(|| bad(CMD, "missing parent definition"))?;- let pose = s.pending_moves.get(&old.id).copied().unwrap_or(old.transform);+ let pose = s.uncaptured_moves().get(&old.id).copied().unwrap_or(old.transform);if !super::component::valid_position(&pose) {return Err(bad(CMD, "invalid internal pending occurrence transform"));}diff --git a/crates/engine/src/cmd/component_extract.rs b/crates/engine/src/cmd/component_extract.rsindex fab3b78bdd..ea72a2bd3e 100644--- a/crates/engine/src/cmd/component_extract.rs+++ b/crates/engine/src/cmd/component_extract.rs@@ -228,7 +228,7 @@ fn scope(s: &Session, comp: u64, cmd: &str) -> Result<Scope> {if source.marker.is_some_and(|m| m < source.features.len()) {return Err(bad(cmd, "move the timeline marker to the end first"));}- if !s.pending_moves.is_empty() {+ if !s.uncaptured_moves().is_empty() {return Err(bad(cmd, "capture or revert the moved components first"));}let subtree: BTreeSet<u64> = source.components.iter().filter(|c| source.component_within(c.id, comp)).map(|c| c.id).collect();diff --git a/crates/engine/src/cmd/component_placing.rs b/crates/engine/src/cmd/component_placing.rsindex 60b0628ecd..01aeb03a2d 100644--- a/crates/engine/src/cmd/component_placing.rs+++ b/crates/engine/src/cmd/component_placing.rs@@ -21,7 +21,7 @@ pub(super) fn parent_path(p: &Value, cmd: &str) -> Result<Option<Vec<u64>>> {/// is in the world, then moved by `translate` (in the world). The parent is placed by/// [`placement_of`]: in its other instances the copy sits in the same place within them.pub(super) fn in_place(s: &Session, path: &[u64], parent: u64, parent_path: Option<&[u64]>, translate: Vec3, cmd: &str) -> Result<Mat> {- let doc = s.placed_document();+ let doc = s.design_document();let component =path.last().and_then(|id| doc.occurrences.iter().find(|o| o.id == *id)).map(|o| o.component).ok_or_else(|| bad(cmd, "no placement"))?;let world = doc.path_transform(component, path).ok_or_else(|| bad(cmd, "that placement is gone"))?;diff --git a/crates/engine/src/cmd/component_properties.rs b/crates/engine/src/cmd/component_properties.rsindex dd8033474d..c1a654951b 100644--- a/crates/engine/src/cmd/component_properties.rs+++ b/crates/engine/src/cmd/component_properties.rs@@ -15,13 +15,7 @@ fn descendants(p: &Value, cmd: &str) -> Result<bool> {}fn placed_doc(s: &Session) -> Document {- let mut doc = (*s.doc).clone();- for occurrence in &mut doc.occurrences {- if let Some(transform) = s.pending_moves.get(&occurrence.id) {- occurrence.transform = *transform;- }- }- doc+ s.design_document().into_owned()}/// A property total must cover the entire assembly. The display traversal intentionally@@ -97,7 +91,7 @@ fn properties(s: &Session, doc: &Document, selected: &[u64], descendants: bool,let selected_placements = if selected.is_empty() {if descendants { placements(doc, cmd)? } else { vec![(0, Vec::new(), solidcraft_doc::IDENTITY)] }} else {- let placement = s.occurrence_placement(selected).map_err(|e| bad(cmd, e.to_string()))?;+ let placement = s.occurrence_placement_with(selected, &s.uncaptured_moves()).map_err(|e| bad(cmd, e.to_string()))?;let mut out = vec![(placement.component, selected.to_vec(), placement.world)];let mut stack = if descendants { out.clone() } else { Vec::new() };while let Some((component, path, transform)) = stack.pop() {diff --git a/crates/engine/src/cmd/component_reparent.rs b/crates/engine/src/cmd/component_reparent.rsindex 3e1e23525d..c5000ab3b9 100644--- a/crates/engine/src/cmd/component_reparent.rs+++ b/crates/engine/src/cmd/component_reparent.rs@@ -35,7 +35,7 @@ pub(super) fn reparent(s: &mut Session, p: &Value) -> Result<Value> {// From the placement named (`path`), into the parent's placement named (`parent_path`).let moved = occurrence_path(s, p, id, cmd)?;let to_given = parent_path(p, cmd)?;- let doc = s.placed_document();+ let doc = s.design_document();let (from_path, from_frame) = placement_of(s, &doc, o.parent, moved.split_last().map(|(_, up)| up), "path", cmd)?;let (to_path, to_frame) = placement_of(s, &doc, to, to_given.as_deref(), "parent_path", cmd)?;let local = doc.occurrences.iter().find(|x| x.id == id).map(|x| x.transform).unwrap_or(o.transform);@@ -52,10 +52,12 @@ pub(super) fn reparent(s: &mut Session, p: &Value) -> Result<Value> {let mut scratch = s.scratch();// Pending moves along both parents and of the placement itself are kept: its new transform// was worked out from them.+ // The exploded view is shown only: an ancestor it moves keeps its placement, and stays shown.+ let uncaptured = s.uncaptured_moves().into_owned();for ancestor in from_path.iter().chain(&to_path) {- if let Some(pending) = scratch.pending_moves.remove(ancestor)- && let Some(x) = scratch.doc_mut().occurrences.iter_mut().find(|x| x.id == *ancestor)- {+ let Some(pending) = uncaptured.get(ancestor).copied() else { continue };+ scratch.pending_moves.remove(ancestor);+ if let Some(x) = scratch.doc_mut().occurrences.iter_mut().find(|x| x.id == *ancestor) {x.transform = pending;}}diff --git a/crates/engine/src/cmd/component_transfer.rs b/crates/engine/src/cmd/component_transfer.rsindex ffb66c9fb9..6e893d8750 100644--- a/crates/engine/src/cmd/component_transfer.rs+++ b/crates/engine/src/cmd/component_transfer.rs@@ -6,7 +6,7 @@ use std::collections::{BTreeMap, BTreeSet};type UniqueFrames = BTreeMap<u64, Option<(Vec<u64>, Mat)>>;fn unique_frames(s: &Session, cmd: &str) -> Result<UniqueFrames> {- let doc = s.placed_document();+ let doc = s.design_document();let mut children = BTreeMap::<u64, Vec<&Occurrence>>::new();for occurrence in &doc.occurrences {children.entry(occurrence.parent).or_default().push(occurrence);@@ -54,7 +54,7 @@ fn transfer(s: &mut Session, name: &str, to: u64, frames: &UniqueFrames, cmd: &slet state = s.model.state();let body = state.body(name).ok_or_else(|| bad(cmd, "body is missing"))?;let from = s.doc.model_body_component(body);- let doc = s.placed_document();+ let doc = s.design_document();let unique = |component| {frames.get(&component).and_then(Option::as_ref).ok_or_else(|| {bad(cmd, "body transfer requires one source and destination placement; shared instances cannot preserve a unique world pose")@@ -78,7 +78,9 @@ fn transfer(s: &mut Session, name: &str, to: u64, frames: &UniqueFrames, cmd: &s}let inherited = (!s.doc.appearances.bodies.contains_key(name)).then(|| s.doc.appearances.components.get(&from).cloned()).flatten();let paths: BTreeSet<u64> = source.0.iter().chain(&destination.0).copied().collect();- let captures: Vec<_> = paths.into_iter().filter_map(|id| s.pending_moves.get(&id).map(|transform| (id, *transform))).collect();+ let uncaptured = s.uncaptured_moves();+ let captures: Vec<_> = paths.into_iter().filter_map(|id| uncaptured.get(&id).map(|transform| (id, *transform))).collect();+ drop(uncaptured);if captures.iter().any(|(_, transform)| !solidcraft_doc::valid_transfer_matrix(transform)) {return Err(bad(cmd, "pending transfer position is not a supported rigid transform"));}@@ -164,13 +166,13 @@ fn move_at_boundary(s: &mut Session, p: &Value, allow_boundary: bool) -> Result<// component placed more than once gets the bodies in every instance, placed by that one.let given = path_param(p, "component_path", cmd)?;if given.is_some() || frames.get(&to).is_some_and(Option::is_none) {- let placed = super::placing::placement_of(&scratch, &scratch.placed_document(), to, given.as_deref(), "component_path", cmd)?;+ let placed = super::placing::placement_of(&scratch, &scratch.design_document(), to, given.as_deref(), "component_path", cmd)?;frames.insert(to, Some(placed));}// The bodies move from the placement named (`from_path`: one of several where their component// is placed), as that placement shows them.if let Some(path) = path_param(p, "from_path", cmd)? {- let placed = scratch.placed_document();+ let placed = scratch.design_document();let component = path.last().and_then(|id| placed.occurrences.iter().find(|o| o.id == *id))diff --git a/crates/engine/src/cmd/features.rs b/crates/engine/src/cmd/features.rsindex 398cc0455a..79008ecc58 100644--- a/crates/engine/src/cmd/features.rs+++ b/crates/engine/src/cmd/features.rs@@ -2091,9 +2091,13 @@ fn placed_bodies(s: &Session, names: Vec<String>, cmd: &str) -> Result<(Vec<Striif !crate::frames::placed(s) && picked.iter().all(|(_, component, _)| *component == s.active_component) {return Ok((names, Vec::new()));}- if let Some((name, ..)) = picked.iter().find(|(_, _, path)| path.iter().any(|id| s.pending_moves.contains_key(id))) {+ let uncaptured = s.uncaptured_moves();+ if let Some((name, ..)) = picked.iter().find(|(_, _, path)| path.iter().any(|id| uncaptured.contains_key(id))) {return Err(bad(cmd, format!("`{name}` has a position that is not captured yet: Capture Position (component.capture_position) first")));}+ if let Some((name, ..)) = picked.iter().find(|(_, _, path)| path.iter().any(|id| s.pending_moves.contains_key(id))) {+ return Err(bad(cmd, format!("`{name}` is shown in an exploded view: show it assembled (explode.show with no view) first")));+ }Ok(picked.into_iter().map(|(own, _, path)| (own, path)).unzip())}diff --git a/crates/engine/src/cmd/file.rs b/crates/engine/src/cmd/file.rsindex 6bdaf6e5bb..69d6149a0d 100644--- a/crates/engine/src/cmd/file.rs+++ b/crates/engine/src/cmd/file.rs@@ -660,13 +660,15 @@ fn export_urdf(s: &Session, path: &str, p: &Value) -> Result<Value> {// their links.let st = s.model.state();let mut held = Vec::new();- let doc = if s.pending_moves.is_empty() {+ // The exploded view is shown only: the links are where the design places them.+ let moves = s.uncaptured_moves();+ let doc = if moves.is_empty() {std::borrow::Cow::Borrowed(&*s.doc)} else {let placed = solidcraft_doc::joints::solve(&s.doc, &st).world;let mut doc = (*s.doc).clone();for o in &mut doc.occurrences {- match s.pending_moves.get(&o.id) {+ match moves.get(&o.id) {Some(_) if placed.contains_key(&o.id) => held.push(o.name.clone()),Some(t) => o.transform = *t,None => {}diff --git a/crates/engine/src/cmd/motion.rs b/crates/engine/src/cmd/motion.rsindex 0800dd11db..69955852ca 100644--- a/crates/engine/src/cmd/motion.rs+++ b/crates/engine/src/cmd/motion.rs@@ -1061,6 +1061,7 @@ fn explode_show(s: &mut Session, p: &Value) -> Result<Value> {let cmd = "explode.show";if p.get("view").is_none_or(|v| v.is_null() || v.as_str().is_some_and(|x| x.eq_ignore_ascii_case("none"))) {s.pending_moves.clear();+ s.exploded.clear();s.revision += 1;return Ok(json!({"view": null}));}@@ -1070,6 +1071,8 @@ fn explode_show(s: &mut Session, p: &Value) -> Result<Value> {if !moves.values().all(solidcraft_doc::is_placement) {return Err(bad(cmd, format!("exploded view `{}` moves an occurrence out of range", v.name)));}+ // Shown only: `exploded` marks these as the view's, so the design's placements leave them out.+ s.exploded.clone_from(&moves);s.pending_moves = moves;s.revision += 1;Ok(json!({"view": v.id, "name": v.name}))diff --git a/crates/engine/src/cmd/motion_tests.rs b/crates/engine/src/cmd/motion_tests.rsindex 371ff6d4bc..63543f62dc 100644--- a/crates/engine/src/cmd/motion_tests.rs+++ b/crates/engine/src/cmd/motion_tests.rs@@ -652,6 +652,18 @@ fn exploded_views_show_without_changing_the_design() {assert!((bb(&mut s, &names[0]) + 10.0).abs() < 1e-6, "{names:?}");assert!((bb(&mut s, &names[1]) - 30.0).abs() < 1e-6);assert_eq!(s.doc.occurrences, before, "shown only");+ // The design's placements are not the view's: the properties report where the design+ // places B, and Capture Position has nothing of the view's to keep (it stays shown).+ let b_id = occ(&s, "B");+ let centre =+ |s: &mut Session| run(s, "occurrence.properties", json!({"occurrence": b_id}))["total"]["center_of_mass"][0].as_f64().unwrap_or(f64::NAN);+ run(&mut s, "explode.show", json!({"view": null}));+ let placed = centre(&mut s);+ run(&mut s, "explode.show", json!({"view": "Apart"}));+ assert!((centre(&mut s) - placed).abs() < 1e-9, "{} shown, {placed} placed", centre(&mut s));+ assert_eq!(run(&mut s, "component.capture_position", json!({}))["captured"], 0);+ assert_eq!(s.doc.occurrences, before, "the exploded view is never captured");+ assert!((bb(&mut s, &names[1]) - 30.0).abs() < 1e-6, "still shown");run(&mut s, "explode.show", json!({"view": null}));assert!(bb(&mut s, &names[0]).abs() < 1e-6);run(&mut s, "explode.create", json!({"name": "Hand", "moves": [{"occurrence": "B", "translate": [0, 0, 50]}]}));diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rsindex 7b93a74265..1460203f6d 100644--- a/crates/engine/src/lib.rs+++ b/crates/engine/src/lib.rs@@ -400,6 +400,11 @@ pub struct Session {pub active_occurrence_path: Option<Vec<u64>>,/// Occurrence moves not captured yet (Capture Position keeps them, a recompute drops them).pub pending_moves: std::collections::BTreeMap<u64, solidcraft_doc::Mat>,+ /// The placements the exploded view (`explode.show`) put in `pending_moves` to be shown:+ /// display only. An entry of `pending_moves` still equal to its one here is the exploded view's,+ /// not a move of the design's, so the placements the design reports and Capture Position+ /// keeps leave it out ([`Session::uncaptured_moves`]).+ pub exploded: std::collections::BTreeMap<u64, solidcraft_doc::Mat>,world_cache: std::sync::Mutex<Option<WorldCache>>,/// The design the joints were last solved for, as the solve left it, and the model it read/// (see [`Session::solve_joints`]).@@ -611,6 +616,7 @@ impl Session {active_component: 0,active_occurrence_path: None,pending_moves: Default::default(),+ exploded: Default::default(),world_cache: Default::default(),joints_settled: None,occurrence_visibility_cache: Default::default(),@@ -1420,6 +1426,7 @@ impl Session {active_component: self.active_component,active_occurrence_path: self.active_occurrence_path.clone(),pending_moves: self.pending_moves.clone(),+ exploded: self.exploded.clone(),world_cache: std::sync::Mutex::new(self.world_cache.lock().ok().and_then(|cache| cache.clone())),joints_settled: self.joints_settled.clone(),occurrence_visibility_cache: Default::default(),@@ -1609,6 +1616,7 @@ impl Session {self.active_component = computed.active_component;self.active_occurrence_path = computed.active_occurrence_path;self.pending_moves = computed.pending_moves;+ self.exploded = computed.exploded;// Joints the computation hid (an import's rigid group) stay hidden.for j in computed.visibility.hidden_joints {if !self.visibility.hidden_joints.contains(&j) {diff --git a/crates/engine/src/occurrences.rs b/crates/engine/src/occurrences.rsindex a07b4a3052..9094b75c88 100644--- a/crates/engine/src/occurrences.rs+++ b/crates/engine/src/occurrences.rs@@ -139,8 +139,44 @@ impl Session {}std::borrow::Cow::Owned(doc)}- /// Resolve only the supplied path, never an exponentially expanded assembly.+ /// The occurrence moves of the design not captured yet: `pending_moves` without the+ /// placements the exploded view shows ([`Session::exploded`]), which are display only. An+ /// entry the exploded view put there and nothing has moved since is left out; one moved since+ /// (dragged, played) is a move like any other.+ pub fn uncaptured_moves(&self) -> std::borrow::Cow<'_, std::collections::BTreeMap<u64, Mat>> {+ if !self.pending_moves.iter().any(|(id, m)| self.exploded.get(id) == Some(m)) {+ return std::borrow::Cow::Borrowed(&self.pending_moves);+ }+ std::borrow::Cow::Owned(self.pending_moves.iter().filter(|(id, m)| self.exploded.get(id) != Some(*m)).map(|(id, m)| (*id, *m)).collect())+ }++ /// The document with the design's own uncaptured moves applied ([`Session::uncaptured_moves`]):+ /// [`Session::placed_document`] without the exploded view, for what reports the design's+ /// placements or works a new placement out from them.+ pub fn design_document(&self) -> std::borrow::Cow<'_, solidcraft_doc::Document> {+ let moves = self.uncaptured_moves();+ if moves.is_empty() {+ return std::borrow::Cow::Borrowed(&self.doc);+ }+ let mut doc = (*self.doc).clone();+ for o in &mut doc.occurrences {+ if let Some(transform) = moves.get(&o.id) {+ o.transform = *transform;+ }+ }+ std::borrow::Cow::Owned(doc)+ }++ /// Resolve only the supplied path, never an exponentially expanded assembly: placed where+ /// it is shown (uncaptured moves and the exploded view included).pub fn occurrence_placement(&self, path: &[u64]) -> Result<OccurrencePlacement> {+ self.occurrence_placement_with(path, &self.pending_moves)+ }++ /// [`Session::occurrence_placement`] with the occurrences moved by `moves` instead of+ /// `pending_moves` (the design's own, [`Session::uncaptured_moves`], for what reports the+ /// design's placements).+ pub fn occurrence_placement_with(&self, path: &[u64], moves: &std::collections::BTreeMap<u64, Mat>) -> Result<OccurrencePlacement> {if path.is_empty() || path.len() > 64 {return Err(invalid("occurrence path must contain 1..64 ids"));}@@ -162,7 +198,7 @@ impl Session {return Err(invalid("occurrence path has a missing component"));}parent_world = world;- world = mat_mul(&world, self.pending_moves.get(id).unwrap_or(&o.transform));+ world = mat_mul(&world, moves.get(id).unwrap_or(&o.transform));if world.iter().flatten().any(|x| !x.is_finite()) {return Err(invalid("occurrence path has a non-finite transform"));}@@ -183,7 +219,7 @@ impl Session {path: path.to_vec(),name: leaf.name.clone(),world,- local: self.pending_moves.get(&leaf.id).copied().unwrap_or(leaf.transform),+ local: moves.get(&leaf.id).copied().unwrap_or(leaf.transform),parent_world,grounded: leaf.grounded,bodies,@@ -497,6 +533,7 @@ impl Session {pub(crate) fn prune_occurrence_state(&mut self) {self.pending_moves.retain(|id, _| self.doc.occurrences.iter().any(|o| o.id == *id));+ self.exploded.retain(|id, _| self.doc.occurrences.iter().any(|o| o.id == *id));if self.active_component != 0 && !self.doc.components.iter().any(|c| c.id == self.active_component) {self.active_component = 0;self.active_occurrence_path = None;diff --git a/crates/kernel/src/iso.rs b/crates/kernel/src/iso.rsindex 391ed144bf..1e6e7cbd08 100644--- a/crates/kernel/src/iso.rs+++ b/crates/kernel/src/iso.rs@@ -191,14 +191,14 @@ pub fn iso_curves(body: &Body, face: usize, at: Vec3, along_u: bool) -> Result<VOk(out)}-/// The isoparametric curves of face `face` of `body` for Isocurve Analysis, the held parameter-/// on a ladder of the face's surface ([`iso_ladder`]) rather than on the face's own extent, so-/// faces on one surface (a face split by a boss, the pieces of a split cylinder) show the same-/// lines, straight across where they meet. `count` (1…[`MAX_ISO_COUNT`]) sets the density: a-/// bounded parameter's range in `count + 1` steps, a linear one in steps of the body's size over-/// `count + 1`, rounded to 1, 2 or 5 times a power of ten. The rungs strictly inside the face's-/// extent are cut to the face ([`FaceTrims::clip`]), their points at chord tolerance `chord`.-/// Along u first, then v.+/// The isoparametric curves of face `face` of `body` for Isocurve Analysis: `count`+/// (1…[`MAX_ISO_COUNT`]) curves each way, evenly spaced across the face, the held parameter at+/// `lo + k · (hi − lo) / (count + 1)` for `k = 1…count` over the face's extent in (u, v), so+/// neither side of the extent (the face's boundary) is drawn as a curve. Faces of the body on the+/// very same surface (a face a boss splits in two) are spaced together, across the extent of all+/// of them, so their curves are the same lines, straight across where they meet. Each curve is+/// cut to the face ([`FaceTrims::clip`]), its points at chord tolerance `chord`. Along u first,+/// then v.pub fn iso_grid(body: &Body, face: usize, count: usize, chord: f64) -> Result<Vec<IsoLine>> {if !(1..=MAX_ISO_COUNT).contains(&count) {return Err(KernelError::Invalid(format!("iso curves: 1…{MAX_ISO_COUNT} each way")));@@ -207,28 +207,15 @@ pub fn iso_grid(body: &Body, face: usize, count: usize, chord: f64) -> Result<Vereturn Err(KernelError::Invalid("iso curves: the chord tolerance must be positive".into()));}let trims = FaceTrims::new(body, face)?;- let spacing = round_spacing(body.size() / (count + 1) as f64)- .ok_or_else(|| KernelError::Invalid("iso curves: the body has no size to space them by".into()))?;- let [[u0, u1], [v0, v1]] = trims.extent();+ let [[u0, u1], [v0, v1]] = shared_extent(body, face, &trims)?;let mut out = Vec::new();for along_u in [true, false] {let (lo, hi) = if along_u { (v0, v1) } else { (u0, u1) };if !(hi > lo) {continue;}- let Some((start, step)) = iso_ladder(trims.surface, &trims.eval, !along_u, count, spacing) else { continue };- // Rungs on the extent's sides are its boundary, not curves across it.- let eps = step * 1e-6;- let first = ((lo + eps - start) / step).ceil();- let last = ((hi - eps - start) / step).floor();- if !(first.is_finite() && last.is_finite()) {- continue;- }- // The ladder is spaced so that a face holds at most about `count + 1` rungs; the cap- // only guards a surface whose parameters run far faster than the body's size.- let rungs = (last - first + 1.0).clamp(0.0, (4 * MAX_ISO_COUNT) as f64) as usize;- for k in 0..rungs {- let fixed = start + (first + k as f64) * step;+ for k in 1..=count {+ let fixed = lo + (hi - lo) * k as f64 / (count + 1) as f64;for (curve, interval) in trims.clip(along_u, fixed)? {let segs = curve_path(&curve, interval)?;let mut points: Vec<Vec3> = segs.first().map(crate::PathSeg::start).into_iter().collect();@@ -242,72 +229,19 @@ pub fn iso_grid(body: &Body, face: usize, count: usize, chord: f64) -> Result<VeOk(out)}-/// Where the iso lines of a surface fall in one of its parameters (`held_u`: u, else v):-/// `start + k * step` for whole k, fixed by the surface alone. A bounded parameter (an angle, a-/// B-spline's knot range) is its range in `count + 1` steps from its start. A linear one (a-/// plane's, a cylinder's or cone's along its axis) has rungs `spacing` apart in the world,-/// counted from the world origin along the parameter's gradient, so another record of the same-/// plane or axis (its own origin, its own face) gets the same lines. None for a parameter that is-/// neither.-fn iso_ladder(surface: &brep::Surface, eval: &SurfaceEval, held_u: bool, count: usize, spacing: f64) -> Option<(f64, f64)> {- use solidcraft_geom::brep::Surface;- let d = if held_u { 0 } else { 1 };- if let Some((a, b)) = eval.domain().range.get(d).copied().flatten().filter(|(a, b)| b > a) {- return Some((a, (b - a) / (count + 1) as f64));- }- let v = |q: [f64; 3]| Vec3::new(q[0], q[1], q[2]);- // The parameter as (P - origin) · g, P a point of the surface.- let (origin, g) = match surface {- Surface::Plane { origin, u_axis, v_axis } => (v(*origin), plane_gradient(v(*u_axis), v(*v_axis), held_u)?),- Surface::PlaneThrough { origin, u_point, v_point } => {- let o = v(*origin);- (o, plane_gradient(v(*u_point) - o, v(*v_point) - o, held_u)?)- }- // Along the axis: P = origin + z * v + (radial part, at right angles to z).- Surface::Cylinder { frame, .. } | Surface::Cone { frame, .. } if !held_u => {- let z = v(frame.x_axis).cross(v(frame.y_axis));- let zz = z.dot(z);- if !(zz > 1e-300) {- return None;- }- (v(frame.origin), z * (1.0 / zz))+/// The extent in (u, v) of face `face` together with every other face of `body` on the same+/// surface record (the same surface and parameters, so one (u, v) for all of them): the box round+/// all their extents ([`FaceTrims::extent`]).+fn shared_extent(body: &Body, face: usize, trims: &FaceTrims) -> Result<[[f64; 2]; 2]> {+ let mut b = trims.extent();+ for (i, other) in body.record().faces.iter().enumerate() {+ if i == face || other.parameters() != trims.surface {+ continue;}- _ => return None,- };- let len = g.len();- if !(len.is_finite() && len > 0.0) {- return None;- }- // The parameter of the world plane P · g/|g| = k * spacing is k * spacing * |g| - origin · g.- Some((-origin.dot(g), spacing * len))-}--/// The gradient of a plane's u (`held_u`) or v in the world: the dual of its axes in their plane.-fn plane_gradient(du: Vec3, dv: Vec3, held_u: bool) -> Option<Vec3> {- let n = du.cross(dv);- let nn = n.dot(n);- if !(nn > 1e-300) {- return None;- }- Some(if held_u { dv.cross(n) } else { n.cross(du) } * (1.0 / nn))-}--/// `x` rounded down to 1, 2 or 5 times a power of ten (None unless it is positive and finite).-fn round_spacing(x: f64) -> Option<f64> {- if !(x.is_finite() && x > 0.0) {- return None;+ let [[a0, a1], [c0, c1]] = FaceTrims::new(body, i)?.extent();+ b = [[b[0][0].min(a0), b[0][1].max(a1)], [b[1][0].min(c0), b[1][1].max(c1)]];}- let p = 10f64.powf(x.log10().floor());- let m = x / p;- Some(- p * if m >= 5.0 {- 5.0- } else if m >= 2.0 {- 2.0- } else {- 1.0- },- )+ Ok(b)}/// A pcurve's parameters and points at [`ISO_SAMPLES`] per knot span, in its direction.diff --git a/crates/smlib/src/export.rs b/crates/smlib/src/export.rsindex 70df616f9b..7a1b3fee34 100644--- a/crates/smlib/src/export.rs+++ b/crates/smlib/src/export.rs@@ -1259,6 +1259,10 @@ fn canonical(parts: Parts, n_vertices: usize, flat: View, tolerances: &Toleranceuses,});}+ let record_geometry = |e: u32| {+ let edge = edge_records.get(e as usize)?;+ Some(EdgeGeometry { curve: edge.nurbs.as_ref().unwrap_or(&edge.curve), interval: edge.interval, tolerance: edge.tolerance })+ };let mut face_records = Vec::with_capacity(face_order.len());for (fi, &f) in face_order.iter().enumerate() {let face = faces.get(f as usize).ok_or_else(|| invalid("face"))?;@@ -1271,7 +1275,7 @@ fn canonical(parts: Parts, n_vertices: usize, flat: View, tolerances: &Tolerance}).collect::<Res<_>>()?;let mut curves =- pcurves(face.nurbs.as_ref().unwrap_or(&face.surface), face.domain, &renumbered, &face.given, &edge_records, tolerance)?.into_iter();+ pcurves(face.nurbs.as_ref().unwrap_or(&face.surface), face.domain, &renumbered, &face.given, record_geometry, tolerance)?.into_iter();let mut loops = Vec::with_capacity(renumbered.len());for (li, l) in renumbered.iter().enumerate() {loops.push(match l {@@ -1532,15 +1536,23 @@ fn split_touching(faces: &mut [Face], edges: &mut Vec<Edge>, edge_source: &mut VOk(())}+/// What the pcurve routine needs of one edge: the curve its parameter is on, its interval and its+/// tolerance.+struct EdgeGeometry<'a> {+ curve: &'a b::Curve,+ interval: [f64; 2],+ tolerance: f64,+}+/// A face's pcurves, edge loop by edge loop: SMLib's own UV trims where `given` (loop by loop as/// `loops`) has them, the plain-record routine on the face's records for the rest; each loop moved-/// by whole periods into the face's domain.-fn pcurves(+/// by whole periods into the face's domain. `edge` looks up an edge of `loops` by its index.+fn pcurves<'a>(surface: &b::Surface,domain: [[f64; 2]; 2],loops: &[Loop],- given: &[Vec<Option<b::Curve2>>],- edges: &[b::Edge],+ given: &'a [Vec<Option<b::Curve2>>],+ edge: impl Fn(u32) -> Option<EdgeGeometry<'a>>,tolerance: f64,) -> Res<Vec<Vec<b::Curve2>>> {if given.len() != loops.len() {@@ -1554,13 +1566,13 @@ fn pcurves(}let mut loop_uses = Vec::with_capacity(l.len());for (&(e, forward), given) in l.iter().zip(g) {- let edge = edges.get(e as usize).ok_or_else(|| invalid("edge"))?;+ let geometry = edge(e).ok_or_else(|| invalid("edge"))?;loop_uses.push(b::pcurve::EdgeUse {edge: e,- curve: edge.nurbs.as_ref().unwrap_or(&edge.curve),- interval: edge.interval,+ curve: geometry.curve,+ interval: geometry.interval,forward,- tolerance: edge.tolerance,+ tolerance: geometry.tolerance,given: given.as_ref(),});}@@ -1575,12 +1587,12 @@ fn pcurves(/// (positive: counter-clockwise, the record's convention); 0 where it has no edge loop.fn outer_area(face: &Face, edges: &[Edge], tolerance: f64) -> Res<f64> {let Some(Loop::Edges(outer)) = face.loops.first() else { return Ok(0.0) };- let records: Vec<b::Edge> = edges- .iter()- .map(|e| b::Edge { nurbs: e.nurbs.clone(), curve: e.curve.clone(), interval: e.interval, vertices: e.vertices, tolerance, uses: Vec::new() })- .collect();+ let geometry = |e: u32| {+ let edge = edges.get(e as usize)?;+ Some(EdgeGeometry { curve: edge.nurbs.as_ref().unwrap_or(&edge.curve), interval: edge.interval, tolerance })+ };let given = face.given.first().map(std::slice::from_ref).unwrap_or(&[]);- let curves = pcurves(face.nurbs.as_ref().unwrap_or(&face.surface), face.domain, &[Loop::Edges(outer.clone())], given, &records, tolerance)?;+ let curves = pcurves(face.nurbs.as_ref().unwrap_or(&face.surface), face.domain, &[Loop::Edges(outer.clone())], given, geometry, tolerance)?;let mut pts: Vec<[f64; 2]> = Vec::new();for (pc, &(e, forward)) in curves.first().map(Vec::as_slice).unwrap_or(&[]).iter().zip(outer) {let edge = edges.get(e as usize).ok_or_else(|| invalid("edge"))?;diff --git a/crates/smlib/src/export/tests.rs b/crates/smlib/src/export/tests.rsindex daff933d4e..da02114bac 100644--- a/crates/smlib/src/export/tests.rs+++ b/crates/smlib/src/export/tests.rs@@ -281,6 +281,95 @@ mod native_tests {assert!(native(&shifted(1e-3)).map(|(r, _)| r.validate()).map_or(true, |v| v.is_err()), "a real overshoot is not moved");}+ /// [`outer_area`] as it was: every edge of the body copied into a record for each face.+ #[allow(clippy::unwrap_used)] // test reference+ fn outer_area_copying_every_edge(face: &Face, edges: &[Edge], tolerance: f64) -> Res<f64> {+ let Some(Loop::Edges(outer)) = face.loops.first() else { return Ok(0.0) };+ let records: Vec<b::Edge> = edges+ .iter()+ .map(|e| b::Edge {+ nurbs: e.nurbs.clone(),+ curve: e.curve.clone(),+ interval: e.interval,+ vertices: e.vertices,+ tolerance,+ uses: Vec::new(),+ })+ .collect();+ let lookup = |e: u32| {+ let edge = records.get(e as usize)?;+ Some(EdgeGeometry { curve: edge.nurbs.as_ref().unwrap_or(&edge.curve), interval: edge.interval, tolerance: edge.tolerance })+ };+ let given = face.given.first().map(std::slice::from_ref).unwrap_or(&[]);+ let curves = pcurves(face.nurbs.as_ref().unwrap_or(&face.surface), face.domain, &[Loop::Edges(outer.clone())], given, lookup, tolerance)?;+ let mut pts: Vec<[f64; 2]> = Vec::new();+ for (pc, &(e, forward)) in curves.first().map(Vec::as_slice).unwrap_or(&[]).iter().zip(outer) {+ let [a, z] = edges.get(e as usize).unwrap().interval;+ let mut run: Vec<[f64; 2]> = (0..=32).filter_map(|i| point2(pc, a + (z - a) * f64::from(i) / 32.0)).collect();+ if !forward {+ run.reverse();+ }+ pts.extend(run);+ }+ let n = pts.len();+ Ok(0.5 * (0..n).map(|k| (pts[k], pts[(k + 1) % n])).map(|(p, q)| p[0] * q[1] - q[0] * p[1]).sum::<f64>())+ }++ /// A face's outer area reads only its own loop's edges, and is bit for bit what copying every+ /// edge of the body gave: the export's face turns, and so its records and numbering, are+ /// unchanged. Each body's record faces are counter-clockwise by convention, so positive.+ #[test]+ fn a_faces_outer_area_reads_only_its_own_loop_and_is_unchanged() {+ let block = Brep::make_box([0.0; 3], [31.0, 29.0, 10.0]).unwrap();+ let hole = Brep::make_cylinder([12.0, 14.5, -1.0], 5.0, 12.0).unwrap();+ let rounded = Brep::make_box([0.0; 3], [60.0, 40.0, 20.0]).unwrap().fillet(&[[60.0, 40.0, 10.0]], 0.1, 5.0).unwrap();+ let mut bodies: Vec<(&str, Brep)> = primitives().into_iter().map(|(name, b, _)| (name, b)).collect();+ bodies.push(("box minus cylinder", block.boolean(&hole, crate::BooleanOp::Subtract).unwrap().unwrap()));+ bodies.push(("rounded box", rounded));+ for (name, body) in bodies {+ let record = body.to_native().unwrap_or_else(|e| panic!("{name}: {e}"));+ let edges: Vec<Edge> = record+ .edges+ .iter()+ .map(|e| Edge {+ curve: e.curve.clone(),+ nurbs: e.nurbs.clone(),+ interval: e.interval,+ vertices: e.vertices,+ reversed: false,+ trim_map: None,+ })+ .collect();+ for (f, rf) in record.faces.iter().enumerate() {+ // Without SMLib's trims (the pcurve routine) and with the record's pcurves as them.+ for with_given in [false, true] {+ let loops: Vec<Loop> = rf+ .loops+ .iter()+ .map(|l| match l {+ b::Loop::Edges { edges } => Loop::Edges(edges.iter().map(|u| (u.edge, u.forward)).collect()),+ b::Loop::Vertex { vertex } => Loop::Vertex(*vertex),+ })+ .collect();+ let given = rf+ .loops+ .iter()+ .map(|l| match l {+ b::Loop::Edges { edges } => edges.iter().map(|u| with_given.then(|| u.pcurve.clone())).collect(),+ b::Loop::Vertex { .. } => Vec::new(),+ })+ .collect();+ let records = loops.iter().map(|_| Vec::new()).collect();+ let face = Face { nurbs: rf.nurbs.clone(), surface: rf.surface.clone(), domain: rf.domain, agrees: true, loops, records, given };+ let now = outer_area(&face, &edges, record.tolerance).unwrap_or_else(|e| panic!("{name}: face {f}: {e}"));+ let before = outer_area_copying_every_edge(&face, &edges, record.tolerance).unwrap();+ assert_eq!(now.to_bits(), before.to_bits(), "{name}: face {f}, trims given {with_given}: {now} != {before}");+ assert!(now > 0.0, "{name}: face {f}, trims given {with_given}: area {now}");+ }+ }+ }+ }+#[test]fn hostile_arrays_are_errors_never_panics() {let good = Brep::make_box([0.0; 3], [1.0, 2.0, 3.0]).unwrap().arrays().unwrap();diff --git a/tests/kernel-cases/assemblies/PATHS b/tests/kernel-cases/assemblies/PATHSindex c4d4c73b59..45bba6bf71 100644--- a/tests/kernel-cases/assemblies/PATHS+++ b/tests/kernel-cases/assemblies/PATHS@@ -18,9 +18,12 @@ crates/engine/src/cmd/component_clone_assembly.rscrates/engine/src/cmd/component_drag.rscrates/engine/src/cmd/component_extract.rscrates/engine/src/cmd/component_link.rs+crates/engine/src/cmd/component_placing.rscrates/engine/src/cmd/component_properties.rscrates/engine/src/cmd/component_reparent.rscrates/engine/src/cmd/component_transfer.rs+# Where occurrences are placed, shown and reported (the exploded view is shown only).+crates/engine/src/occurrences.rs# Interference and clearance between placed bodies.crates/engine/src/cmd/clearance.rscrates/engine/src/cmd/interference.rsdiff --git a/tests/kernel-cases/assemblies/cov-explode-create-automatic-scale-2/expected.json b/tests/kernel-cases/assemblies/cov-explode-create-automatic-scale-2/expected.jsonindex 21464fb601..9779216e30 100644--- a/tests/kernel-cases/assemblies/cov-explode-create-automatic-scale-2/expected.json+++ b/tests/kernel-cases/assemblies/cov-explode-create-automatic-scale-2/expected.json@@ -2,7 +2,7 @@"sources": [],"what": "an automatic exploded view of scale 2","source": "analytic",- "method": "Base: box 20x20x10 from (-10,-10,-10), grounded; Arm: box 40x10x10 from (0,-5,0), centre (20,0,5); each occurrence moves scale \u00d7 (its centre - the mean of the centres): centres (0,0,-5) and (20,0,5), mean (10,0,0): Base by (-20,0,-10), Arm by (20,0,10); shown, Arm at (40,0,15)",+ "method": "Base: box 20x20x10 from (-10,-10,-10), grounded; Arm: box 40x10x10 from (0,-5,0), centre (20,0,5); each occurrence moves scale \u00d7 (its centre - the mean of the centres): centres (0,0,-5) and (20,0,5), mean (10,0,0): Base by (-20,0,-10), Arm by (20,0,10); shown only (the design keeps its placements), so occurrence.properties reports Arm where the design places it: centre (20,0,5)","body_count": 2,"volume_mm3": 8000.0,"results": [@@ -32,12 +32,12 @@"json": {"total": {"center_of_mass": [- 40.0,+ 20.0,0.0,- 15.0+ 5.0]}}}]-}+}\ No newline at end of filediff --git a/tests/kernel-cases/assemblies/cov-explode-create-explicit-move/expected.json b/tests/kernel-cases/assemblies/cov-explode-create-explicit-move/expected.jsonindex 63cb1244da..9192aa3e40 100644--- a/tests/kernel-cases/assemblies/cov-explode-create-explicit-move/expected.json+++ b/tests/kernel-cases/assemblies/cov-explode-create-explicit-move/expected.json@@ -2,7 +2,7 @@"sources": [],"what": "an exploded view moving the arm 30 mm up, shown","source": "analytic",- "method": "Base: box 20x20x10 from (-10,-10,-10), grounded; Arm: box 40x10x10 from (0,-5,0), centre (20,0,5); explode.show places Arm by (0,0,30): centre (20,0,35)",+ "method": "Base: box 20x20x10 from (-10,-10,-10), grounded; Arm: box 40x10x10 from (0,-5,0), centre (20,0,5); the view moves Arm by (0,0,30). explode.show is shown only (the design keeps its placements), so occurrence.properties reports Arm where the design places it: centre (20,0,5)","body_count": 2,"volume_mm3": 8000.0,"results": [@@ -27,10 +27,10 @@"center_of_mass": [20.0,0.0,- 35.0+ 5.0]}}}]-}+}\ No newline at end of filediff --git a/tests/kernel-cases/assemblies/cov-explode-show-keeps-the-placements/expected.json b/tests/kernel-cases/assemblies/cov-explode-show-keeps-the-placements/expected.jsonnew file mode 100644index 0000000000..e57cdf8a46--- /dev/null+++ b/tests/kernel-cases/assemblies/cov-explode-show-keeps-the-placements/expected.json@@ -0,0 +1,91 @@+{+ "sources": [],+ "what": "an exploded view shown, then the arm's properties and Capture Position: the design keeps its placements",+ "source": "analytic",+ "method": "Arm: box 40x10x10 from (0,-5,0), centre (20,0,5), volume 4000. explode.show is shown only (the design keeps its placements), so occurrence.properties reports the arm where the design places it before the view is shown (step 8), while it is shown (step 11) and after Capture Position (step 12, which has no move of the design's to keep: 0 captured) and the assembled view (step 14): centre (20,0,5), box (0,-5,0)..(40,5,10)",+ "body_count": 2,+ "volume_mm3": 8000.0,+ "results": [+ {+ "step": 8,+ "json": {+ "total": {+ "center_of_mass": [+ 20.0,+ 0.0,+ 5.0+ ],+ "bbox": {+ "min": [+ 0.0,+ -5.0,+ 0.0+ ],+ "max": [+ 40.0,+ 5.0,+ 10.0+ ]+ },+ "volume_mm3": 4000.0+ }+ }+ },+ {+ "step": 11,+ "json": {+ "total": {+ "center_of_mass": [+ 20.0,+ 0.0,+ 5.0+ ],+ "bbox": {+ "min": [+ 0.0,+ -5.0,+ 0.0+ ],+ "max": [+ 40.0,+ 5.0,+ 10.0+ ]+ },+ "volume_mm3": 4000.0+ }+ }+ },+ {+ "step": 12,+ "json": {+ "captured": 0+ }+ },+ {+ "step": 14,+ "json": {+ "total": {+ "center_of_mass": [+ 20.0,+ 0.0,+ 5.0+ ],+ "bbox": {+ "min": [+ 0.0,+ -5.0,+ 0.0+ ],+ "max": [+ 40.0,+ 5.0,+ 10.0+ ]+ },+ "volume_mm3": 4000.0+ }+ }+ }+ ]+}\ No newline at end of filediff --git a/tests/kernel-cases/assemblies/cov-explode-show-keeps-the-placements/recipe.json b/tests/kernel-cases/assemblies/cov-explode-show-keeps-the-placements/recipe.jsonnew file mode 100644index 0000000000..1288e18959--- /dev/null+++ b/tests/kernel-cases/assemblies/cov-explode-show-keeps-the-placements/recipe.json@@ -0,0 +1,123 @@+{+ "commands": [+ {+ "command": "solid.box",+ "params": {+ "length": 20,+ "width": 20,+ "height": 10,+ "corner": [+ -10,+ -10,+ -10+ ],+ "operation": "new",+ "body_name": "BaseBox"+ }+ },+ {+ "command": "solid.box",+ "params": {+ "length": 40,+ "width": 10,+ "height": 10,+ "corner": [+ 0,+ -5,+ 0+ ],+ "operation": "new",+ "body_name": "ArmBox"+ }+ },+ {+ "command": "component.create",+ "params": {+ "name": "Base",+ "parent": "root",+ "activate": false+ }+ },+ {+ "command": "component.move_bodies",+ "params": {+ "bodies": [+ "BaseBox"+ ],+ "component": "Base"+ }+ },+ {+ "command": "component.create",+ "params": {+ "name": "Arm",+ "parent": "root",+ "activate": false+ }+ },+ {+ "command": "component.move_bodies",+ "params": {+ "bodies": [+ "ArmBox"+ ],+ "component": "Arm"+ }+ },+ {+ "command": "occurrence.ground",+ "params": {+ "occurrence": "Base:1",+ "grounded": true+ }+ },+ {+ "command": "occurrence.properties",+ "params": {+ "occurrence": "Arm:1"+ }+ },+ {+ "command": "explode.create",+ "params": {+ "name": "Up",+ "moves": [+ {+ "occurrence": "Arm:1",+ "translate": [+ 0,+ 0,+ 30+ ]+ }+ ]+ }+ },+ {+ "command": "explode.show",+ "params": {+ "view": "Up"+ }+ },+ {+ "command": "occurrence.properties",+ "params": {+ "occurrence": "Arm:1"+ }+ },+ {+ "command": "component.capture_position",+ "params": {}+ },+ {+ "command": "explode.show",+ "params": {}+ },+ {+ "command": "occurrence.properties",+ "params": {+ "occurrence": "Arm:1"+ }+ }+ ]+}\ No newline at end of filediff --git a/tests/kernel-cases/inspect/cov-isocurve-40-by-30-face-count-3/expected.json b/tests/kernel-cases/inspect/cov-isocurve-40-by-30-face-count-3/expected.jsonnew file mode 100644index 0000000000..61b4efb794--- /dev/null+++ b/tests/kernel-cases/inspect/cov-isocurve-40-by-30-face-count-3/expected.json@@ -0,0 +1,102 @@+{+ "sources": [],+ "what": "three isocurves each way across a 40 x 30 face",+ "source": "analytic",+ "method": "box 40 x 30 x 10 with a corner at the origin: its top is the plane z = 10, x 0..40 and y 0..30. count 3 curves each way, evenly spaced across it (the command's contract), divide each side into 4: x = 10, 20, 30 (each from y 0 to 30) and y = 7.5, 15, 22.5 (each from x 0 to 40), every curve the straight line across the face. In the order the reply lists them (along the surface's first parameter first, as its parameters run), to 1e-9 mm",+ "results": [+ {+ "step": 2,+ "pointer": "/faces/0/count",+ "json": 3+ },+ {+ "step": 2,+ "pointer": "/faces/0/u_curves",+ "json": 3+ },+ {+ "step": 2,+ "pointer": "/faces/0/v_curves",+ "json": 3+ },+ {+ "step": 2,+ "pointer": "/curves",+ "json": [+ [+ [+ 30.0,+ 0.0,+ 10.0+ ],+ [+ 30.0,+ 30.0,+ 10.0+ ]+ ],+ [+ [+ 20.0,+ 0.0,+ 10.0+ ],+ [+ 20.0,+ 30.0,+ 10.0+ ]+ ],+ [+ [+ 10.0,+ 0.0,+ 10.0+ ],+ [+ 10.0,+ 30.0,+ 10.0+ ]+ ],+ [+ [+ 40.0,+ 7.5,+ 10.0+ ],+ [+ 0.0,+ 7.5,+ 10.0+ ]+ ],+ [+ [+ 40.0,+ 15.0,+ 10.0+ ],+ [+ 0.0,+ 15.0,+ 10.0+ ]+ ],+ [+ [+ 40.0,+ 22.5,+ 10.0+ ],+ [+ 0.0,+ 22.5,+ 10.0+ ]+ ]+ ],+ "abs_mm": 1e-09+ }+ ]+}\ No newline at end of filediff --git a/tests/kernel-cases/inspect/cov-isocurve-40-by-30-face-count-3/recipe.json b/tests/kernel-cases/inspect/cov-isocurve-40-by-30-face-count-3/recipe.jsonnew file mode 100644index 0000000000..4aa2e11332--- /dev/null+++ b/tests/kernel-cases/inspect/cov-isocurve-40-by-30-face-count-3/recipe.json@@ -0,0 +1,27 @@+{+ "commands": [+ {+ "command": "solid.box",+ "params": {+ "length": 40,+ "width": 30,+ "height": 10,+ "body_name": "Slab",+ "operation": "new"+ }+ },+ {+ "command": "inspect.isocurve",+ "params": {+ "faces": [+ [+ 20,+ 15,+ 10+ ]+ ],+ "count": 3+ }+ }+ ]+}\ No newline at end of file