diff --git a/crates/kernel/src/blend_smlib.rs b/crates/kernel/src/blend_smlib.rs index f7bf6739b..451a3d5c9 100644 --- a/crates/kernel/src/blend_smlib.rs +++ b/crates/kernel/src/blend_smlib.rs @@ -451,10 +451,9 @@ mod tests { fn options_smlib_cannot_build_are_refused() { assert!(unsupported("x").to_string().contains("not supported yet")); let b = cube(); - // A radius law with a corner (4 → 2 → 4, straight on both halves). - let corner = RadiusSpline { degree: 1, knots: vec![0.0, 0.0, 0.5, 1.0, 1.0], radii: vec![4.0, 2.0, 4.0] }; - let e = imp::variable(&b, Vec3::new(10.0, 20.0, 20.0), Vec3::new(0.0, 20.0, 20.0), &corner).unwrap_err(); - assert!(e.to_string().contains("not supported yet"), "{e}"); + // A radius law down to zero inside the edge would pinch the round to a point. + let pinch = RadiusSpline { degree: 1, knots: vec![0.0, 0.0, 0.5, 1.0, 1.0], radii: vec![4.0, 0.0, 4.0] }; + assert!(imp::variable(&b, Vec3::new(10.0, 20.0, 20.0), Vec3::new(0.0, 20.0, 20.0), &pinch).is_err()); assert!(imp::blend(&b, "fillet", Kind::Round, &[Vec3::new(10.0, 20.0, 20.0)], &[f64::NAN]).is_err()); assert!(imp::blend(&b, "fillet", Kind::Round, &[Vec3::new(f64::NAN, 20.0, 20.0)], &[1.0]).is_err()); assert!(imp::blend(&b, "fillet", Kind::Round, &[], &[]).is_err()); diff --git a/crates/kernel/src/tess/tests.rs b/crates/kernel/src/tess/tests.rs index 7ce933745..14a2829a9 100644 --- a/crates/kernel/src/tess/tests.rs +++ b/crates/kernel/src/tess/tests.rs @@ -715,8 +715,10 @@ fn the_halves_of_a_split_smlib_coil_measure_as_the_whole() { // π r² · 2πR · turns; SMLib's wall is a spline within a ten-thousandth of the pitch. let (whole, analytic) = (volume(&coil), PI * 2.0 * PI * 20.0 * 6.0); assert!((whole - analytic).abs() < 3e-3 * analytic, "coil {whole} vs {analytic}"); + // The halves are held to the closed form itself: the whole coil's one wall is meshed + // within 3e-3 of it, which made the whole a looser yardstick than the truth. let halves = volume(&upper) + volume(&lower); - assert!((halves - whole).abs() < 1e-3 * whole, "halves {halves} vs the whole {whole}"); + assert!((halves - analytic).abs() < 1e-3 * analytic, "halves {halves} vs {analytic} (the whole measures {whole})"); } /// Thinning keeps a grid within its cap whatever the rounding, both ends of each direction, diff --git a/crates/smlib/SMLIB_REV b/crates/smlib/SMLIB_REV index fde534702..74914273b 100644 --- a/crates/smlib/SMLIB_REV +++ b/crates/smlib/SMLIB_REV @@ -1 +1 @@ -276b509ad2b634843b2f256e1eb1fbaa29a5ef87 +2d7c7edcff20b8f70c4e4d8aa952265bca2acc9d diff --git a/crates/smlib/src/ops_tests.rs b/crates/smlib/src/ops_tests.rs index 8048dde56..a74b898da 100644 --- a/crates/smlib/src/ops_tests.rs +++ b/crates/smlib/src/ops_tests.rs @@ -285,11 +285,15 @@ fn a_variable_round_follows_its_law() { let zero = c.fillet_variable([10.0, 20.0, 20.0], 0.1, [0.0, 20.0, 20.0], 1, &knots, &[4.0, 0.0]).unwrap(); shot(&zero, "variable-to-zero"); assert_close(volume(&zero), 8000.0 - q * 20.0 * 16.0 / 3.0, 1e-5, "down to zero"); - // A law with a corner (4 → 2 → 4, straight on both halves): SMLib's section fit runs across - // the corner and misses it, so it is refused; the same points joined smoothly (C1 cubic - // pieces, as RadiusSpline::through makes them) are built. - let corner = c.fillet_variable([10.0, 20.0, 20.0], 0.1, [0.0, 20.0, 20.0], 1, &[0.0, 0.0, 0.5, 1.0, 1.0], &[4.0, 2.0, 4.0]); - assert_eq!(corner.unwrap_err(), Error::Unsupported); + // A law with a corner (4 → 2 → 4, straight on both halves): the round turns at the corner, + // each half taking away (1 - pi/4) (L / 2) (16 + 8 + 4) / 3; the same points joined smoothly + // (C1 cubic pieces, as RadiusSpline::through makes them) are built too. + let corner = c.fillet_variable([10.0, 20.0, 20.0], 0.1, [0.0, 20.0, 20.0], 1, &[0.0, 0.0, 0.5, 1.0, 1.0], &[4.0, 2.0, 4.0]).unwrap(); + shot(&corner, "variable-corner-4-2-4"); + assert_close(volume(&corner), 8000.0 - q * 20.0 * 28.0 / 3.0, 1e-6, "corner law"); + // A law down to zero inside the edge would pinch the round to a point: refused. + let pinch = c.fillet_variable([10.0, 20.0, 20.0], 0.1, [0.0, 20.0, 20.0], 1, &[0.0, 0.0, 0.5, 1.0, 1.0], &[4.0, 0.0, 4.0]); + assert!(pinch.is_err(), "a law pinching to zero inside the edge"); let smooth_knots = [0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 1.0, 1.0, 1.0, 1.0]; let smooth = c.fillet_variable([10.0, 20.0, 20.0], 0.1, [0.0, 20.0, 20.0], 3, &smooth_knots, &[4.0, 10.0 / 3.0, 2.0, 2.0, 2.0, 10.0 / 3.0, 4.0]); shot(&smooth.unwrap(), "variable-smooth-4-2-4");