From 8075b8f70f6b7c2eeea7700989371787fc7189ee Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Wed, 28 Oct 2026 22:22:59 -0400 Subject: [PATCH] Tests: a swept point path is its lines, and rails must turn with a cornered path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A sweep along points follows the lines between them (no wall is fitted through the points, sweep_sheet_points' contract, as sweeps_along_3d_paths already says): along a quarter circle of 41 points the sheet is a wall per line, 40, its area 10 × the polyline's length (within 10⁻⁴ of 10 × 15π); the bent chain is 2 × 40 walls sharing every seam, 2·41 + 3·40 edges. SMLib's sweep takes guide rails along a cornered path when each rail turns with the path at its corners; a straight rail along a bent path is refused for that reason, not as "guide rails along a path with sharp corners". Co-Authored-By: Claude Opus 5.5 --- crates/kernel/src/surfaces.rs | 15 +++++++++------ crates/kernel/src/sweep_rails_tests.rs | 5 +++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/crates/kernel/src/surfaces.rs b/crates/kernel/src/surfaces.rs index 4cb90ea24..9c7a98667 100644 --- a/crates/kernel/src/surfaces.rs +++ b/crates/kernel/src/surfaces.rs @@ -1718,8 +1718,9 @@ mod tests { assert!(walls.is_surface() && walls.face_count() == 4 && rel(area(&walls), 80.0) < 1e-9); let pts: Vec = (0..=10).map(|i| Vec3::new(0.0, 0.0, i as f64)).collect(); assert!(rel(area(&sweep_sheet_points(&Plane::XY, std::slice::from_ref(&line), &pts).unwrap()), 100.0) < 1e-6); - // A smooth point path: a quarter circle of radius 30 in the YZ plane. One smooth wall (not - // forty ruled strips), a piece of cylinder: 10 × 15π. + // A point path through a quarter circle of radius 30 in the YZ plane: the path is its + // lines (no wall is fitted through the points), a wall along each of the 40, together + // 10 × the polyline's length, within 10⁻⁴ of the cylinder's 10 × 15π. let arc: Vec = (0..=40) .map(|i| { let t = i as f64 / 40.0 * FRAC_PI_2; @@ -1727,14 +1728,16 @@ mod tests { }) .collect(); let curved = sweep_sheet_points(&Plane::XY, std::slice::from_ref(&line), &arc).unwrap(); - assert_eq!(curved.face_count(), 1, "smooth wall"); + assert_eq!(curved.face_count(), 40, "a wall along each line"); let want = 10.0 * 30.0 * FRAC_PI_2; assert!(rel(area(&curved), want) < 2e-3, "{} vs {want}", area(&curved)); // (measured on meshes) - // A bent chain along the same path: two smooth walls joined by one shared seam edge. + // A bent chain along the same path: two walls along each line, sharing every seam: the + // profile's two segments at each of the 41 points and its three vertices along each of + // the 40 lines. let bent = vec![line[0], Seg2::Line { a: Vec2::new(10.0, 0.0), b: Vec2::new(10.0, 5.0) }]; let two = sweep_sheet_points(&Plane::XY, &[bent], &arc).unwrap(); - assert_eq!(two.face_count(), 2); - assert_eq!(two.edge_count(), 7, "the walls share their seam"); + assert_eq!(two.face_count(), 2 * 40); + assert_eq!(two.edge_count(), 2 * 41 + 3 * 40, "the walls share their seams"); } #[test] diff --git a/crates/kernel/src/sweep_rails_tests.rs b/crates/kernel/src/sweep_rails_tests.rs index 4bc438e33..76d2f9fee 100644 --- a/crates/kernel/src/sweep_rails_tests.rs +++ b/crates/kernel/src/sweep_rails_tests.rs @@ -146,7 +146,8 @@ fn two_rails_carry_a_line_between_arcs() { /// Rails the sweep cannot follow are refused with a reason, never a panic: three rails, a rail /// with a bad point, a rail with a twist or scale besides, a rail starting on the path, a rail -/// that stops short, rails along a path with a corner. +/// that stops short, a straight rail along a path with a corner (a rail must turn with the path +/// at its corners). #[test] fn rails_the_sweep_cannot_follow_are_refused() { let rail = vec![Vec3::new(10.0, 0.0, 0.0), Vec3::new(5.0, 0.0, 40.0)]; @@ -162,5 +163,5 @@ fn rails_the_sweep_cannot_follow_are_refused() { refuse(railed(vec![vec![Vec3::new(10.0, 0.0, 0.0), Vec3::new(8.0, 0.0, 20.0)]], RailFit::Scale), &up(), "whole length"); refuse(railed(vec![rail.clone(), rail.clone()], RailFit::Scale), &up(), "start at the same point"); let bent = vec![Vec3::ZERO, Vec3::new(0.0, 0.0, 20.0), Vec3::new(20.0, 0.0, 20.0)]; - refuse(railed(vec![vec![Vec3::new(10.0, 0.0, 0.0), Vec3::new(10.0, 0.0, 30.0)]], RailFit::Scale), &bent, "sharp corners"); + refuse(railed(vec![vec![Vec3::new(10.0, 0.0, 0.0), Vec3::new(10.0, 0.0, 30.0)]], RailFit::Scale), &bent, "the guide rails have to turn with it"); }