diff --git a/crates/kernel/src/modify_history_tests.rs b/crates/kernel/src/modify_history_tests.rs index 9a8247856..7d953e830 100644 --- a/crates/kernel/src/modify_history_tests.rs +++ b/crates/kernel/src/modify_history_tests.rs @@ -280,7 +280,10 @@ fn draft_tilts_faces() { let side = Vec3::new(40.0, 15.0, 10.0); let r = crate::draft(&b, &[side], &Plane::XY, Vec3::Z, 5f64.to_radians()).unwrap(); let h = verified(&r, &b, Reach { made: 0.0, moved: 2.0 }); - assert_eq!(changes(h), [0, 6, 0, 0, 0]); + // The side tilts about its bottom edge (on the neutral plane z = 0); the top and the two + // faces beside it lose a wedge along their moved edges. The bottom and the opposite side + // are untouched. + assert_eq!(changes(h), [2, 4, 0, 0, 0]); assert_eq!(with(h, &[face(face_at(&b, side))]).len(), 1); // Walls of a body that is not convex. let l = ell(); diff --git a/crates/kernel/tests/shell_barrel.rs b/crates/kernel/tests/shell_barrel.rs index fb933cbfb..fc7422ae9 100644 --- a/crates/kernel/tests/shell_barrel.rs +++ b/crates/kernel/tests/shell_barrel.rs @@ -43,13 +43,19 @@ fn check_volume(body: &Body, lo: f64, hi: f64) { #[test] fn shell_of_a_revolved_barrel() { let barrel = barrel(); - let side = (0..barrel.face_count()) - .find_map(|i| match face_surface(&barrel, i) { - Some(s @ FaceSurface::Torus { major, minor, .. }) if (major - CENTRE).abs() < 1e-6 && (minor - RADIUS).abs() < 1e-6 => Some(s), - _ => None, - }) - .expect("barrel side is the inner sheet of a spindle torus"); - assert!(side.nearest(Vec3::new(15.0, 0.0, HALF_HEIGHT)).unwrap().dist(Vec3::new(14.0, 0.0, HALF_HEIGHT)) < 1e-6); + // The side is the inner (lemon) zone of a spindle torus: SMLib's torus describes only its + // outer zone, so the side is the exact rational surface of revolution of the arc. Two flat + // caps and that side; the solid is the closed-form barrel, 14 mm round at mid height (`contains` asks the display mesh, so a margin round it). + assert_eq!(barrel.face_count(), 3); + let planes = (0..barrel.face_count()).filter(|i| matches!(face_surface(&barrel, *i), Some(FaceSurface::Plane { .. }))).count(); + assert_eq!(planes, 2, "two caps and the curved side"); + let full = integral(RADIUS, 2.0 * HALF_HEIGHT) - integral(RADIUS, 0.0); + let volume = measure(&barrel).unwrap().volume; + assert!((volume - full).abs() < full * 1e-3, "{volume} vs {full}"); + for turn in [0.0, 1.0, 2.5, 4.0] { + let (c, s) = (f64::cos(turn), f64::sin(turn)); + assert!(barrel.contains(Vec3::new(13.8 * c, 13.8 * s, HALF_HEIGHT)) && !barrel.contains(Vec3::new(14.2 * c, 14.2 * s, HALF_HEIGHT))); + } let result = shell(&barrel, &[Vec3::new(0.0, 0.0, 2.0 * HALF_HEIGHT)], 2.0).unwrap(); assert!(result.validity().is_empty(), "{:?}", result.validity()); assert_eq!(result.shell_count(), 1); @@ -62,7 +68,8 @@ fn shell_of_a_revolved_barrel() { check_volume(&result, 2.0, 2.0 * HALF_HEIGHT); let history = result.history().expect("exact shell face history"); assert_eq!(history.operands, 1); - assert_eq!(history.faces.iter().filter(|f| matches!(f.origins.as_slice(), [FaceOrigin::Offset { operand: 0, .. }])).count(), 4); + // The inner wall and the inner floor, offsets of the barrel's side and bottom (the top opened). + assert_eq!(history.faces.iter().filter(|f| matches!(f.origins.as_slice(), [FaceOrigin::Offset { operand: 0, .. }])).count(), 2); let step = step_export(&[&result], "barrel shell").unwrap(); let imported = step_import(&step).unwrap(); assert_eq!(imported.bodies.len(), 1); diff --git a/crates/smlib/SMLIB_PREBUILT b/crates/smlib/SMLIB_PREBUILT index de61afd1d..57562e10a 100644 --- a/crates/smlib/SMLIB_PREBUILT +++ b/crates/smlib/SMLIB_PREBUILT @@ -1,10 +1,10 @@ # Rust target, SHA-256 of smlib-.tar.gz in the release prebuilt- of # tangency-labs/smlib. Written by scripts/fetch-smlib.sh --pin; never edited by hand. -aarch64-apple-darwin 49c6cc428f3d1d4d9b20d9b2bf85377058c1ef016396082f1d7fa17d6f3c9e3b -aarch64-pc-windows-msvc e675f1f8eccdc8c902fbb300ba6eca0443a73ecf207ab10a5ecdffa411a0b5df -aarch64-unknown-linux-gnu 042f9c6af6053673e3ffd20c9791034a66748538a72b88f3bc08ba17eeca103a -i686-pc-windows-msvc 53fcb55669647484b70e707298e927b70b24301078f3181aa0544854dbcbfe86 -wasm32-unknown-unknown ef5a257974f2ff24c3420fdc4357d67a8da7a8b253508f5af7e549f5556c01ea -x86_64-apple-darwin b06dd703c07a0527623f77a70bfc421f580a278d5a18fd5828358b6803098dbe -x86_64-pc-windows-msvc 9a572adf26454401273f9c0d509956c684dd8f9eb8c389846ded36b9fabcdf0f -x86_64-unknown-linux-gnu 8eda2121cb7f3c50a6d6865c0daae8ed81a910e8cf3e5c5008bc3ffb60d2cf81 +aarch64-apple-darwin 0288998e1d7e0bc14149f7abc2cd7e44852a66af43b187a700981cffdfbc89dc +aarch64-pc-windows-msvc 51992eb16f529c0969a22d9c852c65c582dd48a8ca5febf28a5f28186dbec000 +aarch64-unknown-linux-gnu 9d0b96bbaf7ae255c0bcd8828fb3cbb0b3ffda053de47bca73edf8429efcffad +i686-pc-windows-msvc 26f130fc69f57bd0aa0552b653dde5120a6526525145f4f1cf91b8c0914de95f +wasm32-unknown-unknown a5a0b287078e4d1f216e8d78194cbb839fcd65a2ad9cb93b491ee5aa46902f7d +x86_64-apple-darwin 83768b97779df83aa11319668be3c78dad1d84f21e20ea6d923ff2a7bf352889 +x86_64-pc-windows-msvc 21f688d0d3d4c5d9e1e3cb33fb2991701a1172299d36bb6342238836a11cb85e +x86_64-unknown-linux-gnu 5c6145e288a3e7cd741d1f3f2b96a5a39016c9ceac950b1e05ae75a5f4cb5f53 diff --git a/crates/smlib/SMLIB_REV b/crates/smlib/SMLIB_REV index 380a58799..670339da7 100644 --- a/crates/smlib/SMLIB_REV +++ b/crates/smlib/SMLIB_REV @@ -1 +1 @@ -60b1c6a33da2af524206d20155096f361ae9484c +90aabff7937853f94ab1ddb9115382844f369793