diff --git a/crates/doc/src/document.rs b/crates/doc/src/document.rs index 144c295b3..0bb9d6b73 100644 --- a/crates/doc/src/document.rs +++ b/crates/doc/src/document.rs @@ -1487,7 +1487,7 @@ pub enum FeatureKind { }, /// Plastic lip (raised band) or groove (recess) along the rim face picked at `face`. Lip { - face: Position, + face: FacePick, #[walk(length = "Width")] width: Expr, #[walk(length = "Height")] diff --git a/crates/doc/src/feature_geometry.rs b/crates/doc/src/feature_geometry.rs index 1ee5565b2..c0501bb28 100644 --- a/crates/doc/src/feature_geometry.rs +++ b/crates/doc/src/feature_geometry.rs @@ -67,6 +67,7 @@ impl FeatureKind { | FeatureKind::ReplaceFace { body, .. } | FeatureKind::SurfaceOffset { body, .. } | FeatureKind::Boss { body, .. } + | FeatureKind::Lip { body, .. } | FeatureKind::SnapFit { body, .. } | FeatureKind::Rest { body, .. } => body.as_deref(), FeatureKind::SheetConvert { body, .. } | FeatureKind::SurfaceRuled { body, .. } => Some(body.as_ref()), diff --git a/crates/doc/src/feature_walk_tests/golden_geometry.txt b/crates/doc/src/feature_walk_tests/golden_geometry.txt index 550be0249..b49d86e1d 100644 --- a/crates/doc/src/feature_walk_tests/golden_geometry.txt +++ b/crates/doc/src/feature_walk_tests/golden_geometry.txt @@ -150,6 +150,7 @@ boss face points: [0, 0, 0] lip moves: face[0], face[1], face[2] + face points: [0, 0, 0] snap_fit moves: direction[0], direction[2], hook[0], hook[1], position[0], position[1], position[2] face points: [0, 0, 0] diff --git a/crates/engine/src/cmd/plastic.rs b/crates/engine/src/cmd/plastic.rs index d5afad126..58085095e 100644 --- a/crates/engine/src/cmd/plastic.rs +++ b/crates/engine/src/cmd/plastic.rs @@ -6,7 +6,7 @@ use solidcraft_doc::BodyName; use solidcraft_doc::FeatureKind; use solidcraft_doc::expr::Kind; use solidcraft_doc::plastic::PlasticRule; -use solidcraft_doc::{Dir, FacePick, Position}; +use solidcraft_doc::{Dir, FacePick}; use solidcraft_geom::prelude::*; use super::CommandSpec; @@ -237,7 +237,7 @@ fn lip(s: &mut Session, p: &Value) -> Result { Some(o) => return Err(bad(cmd, format!("unknown side `{o}` (inside or outside)"))), }; let kind = FeatureKind::Lip { - face: Position(face), + face: FacePick(face), width: required(s, p, "width", Kind::Length, cmd)?, height: required(s, p, "height", Kind::Length, cmd)?, groove, @@ -343,6 +343,27 @@ mod tests { assert!(g.execute("plastic.lip", &json!({"face": [40, 25, 0], "width": 1, "height": 2})).is_err(), "a face without an inner edge"); } + /// A lip follows its rim face when a parameter moves it (#11209): it was kept by a point + /// only, so a taller box left the point below the rim and the lip failed. + #[test] + fn a_lip_and_a_groove_follow_their_rim_when_a_parameter_moves_it() { + for groove in [false, true] { + let mut s = Session::default(); + run(&mut s, "parameters.add", json!({"name": "h", "expression": "30 mm"})); + run(&mut s, "solid.box", json!({"length": 80, "width": 50, "height": "h"})); + run(&mut s, "solid.shell", json!({"faces": [[40, 25, 30]], "thickness": 2})); + let kind = if groove { "groove" } else { "lip" }; + run(&mut s, "plastic.lip", json!({"face": [1, 25, 30], "width": 1, "height": 2, "type": kind})); + let before = volume(&mut s); + run(&mut s, "parameters.change", json!({"name": "h", "expression": "40 mm"})); + let failing: Vec = s.model.results.iter().filter_map(|r| r.error.clone()).collect(); + assert!(failing.is_empty(), "{kind}: {failing:?}"); + // 10 mm more of the shell's walls: (80·50 − 76·46) · 10, and the same band on top. + let walls = (80.0 * 50.0 - 76.0 * 46.0) * 10.0; + assert!(rel(volume(&mut s) - before, walls) < 1e-6, "{kind}: {} {walls}", volume(&mut s) - before); + } + } + #[test] fn round_rim_lips_and_grooves_keep_curved_walls() { for (obround, tilted) in [(false, false), (true, false), (true, true)] {