From 80b7ce28e08b43146dae467236adda471955aae1 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Thu, 29 Oct 2026 01:04:21 -0400 Subject: [PATCH] Tests: volume checks held to what their measures can tell, not tighter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit a_lip_swept_on_a_round_rim_joins_it compared the union's mesh volume with the two operands' at a 1e-5 chord to 1e-3 mm³. Each mesh lies within its chord of its own faces, and the union is tessellated by its own faces (the lip's foot merged into the top): two meshes of one solid differ by up to their area times twice the chord, 0.02 here; they differed by 1.6e-3. The bound is now that. overlapping_holes_and_mirror_joins held the mirrored union to 2v within 1e-9, below the relative accuracy SMLib integrates volumes at (1e-4, measure::ACCURACY): the two integrals differed by 2.3e-8. (That test now stops earlier, at the mirrored operand SMLib's check refuses, the mirror-regressions agent's cause.) Co-Authored-By: Claude Opus 5.5 --- crates/kernel/src/outline_tests.rs | 6 +++++- crates/kernel/src/tests.rs | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/kernel/src/outline_tests.rs b/crates/kernel/src/outline_tests.rs index 017dd54eb..c1579db16 100644 --- a/crates/kernel/src/outline_tests.rs +++ b/crates/kernel/src/outline_tests.rs @@ -30,8 +30,12 @@ fn a_lip_swept_on_a_round_rim_joins_it() { let r = boolean(a, b, BoolOp::Union).unwrap().unwrap(); assert_eq!(r.shell_count(), 1, "inset {inset}: one solid"); assert!(r.validity().is_empty(), "inset {inset}: {:?}", r.validity()); + // Each mesh lies within its chord (1e-5) of its faces: two meshes of the same solid, + // tessellated face by face as each body has its faces, differ by at most their area + // times twice that. let v = mesh_volume(&r); - assert!((v - want).abs() < 1e-3, "inset {inset}: volume {v} vs {want}"); + let bound = crate::measure(&r).unwrap().area * 2e-5; + assert!((v - want).abs() < bound, "inset {inset}: volume {v} vs {want} (within {bound})"); } } } diff --git a/crates/kernel/src/tests.rs b/crates/kernel/src/tests.rs index ff4b877e4..850bd87c5 100644 --- a/crates/kernel/src/tests.rs +++ b/crates/kernel/src/tests.rs @@ -1603,7 +1603,9 @@ fn overlapping_holes_and_mirror_joins() { let both = boolean(&half, &other, BoolOp::Union).unwrap().unwrap(); let v = measure(&half).unwrap().volume; let mb = measure(&both).unwrap(); - assert!(rel(mb.volume, 2.0 * v) < 1e-9, "{} vs {}", mb.volume, 2.0 * v); + // Both volumes are SMLib's integrals, each good to its relative accuracy (1e-4, + // measure::ACCURACY); a lost round or wall would be off by percent. + assert!(rel(mb.volume, 2.0 * v) < 1e-4, "{} vs {}", mb.volume, 2.0 * v); // One body: the shared face is gone and the faces either side of it merged. assert_eq!(mb.merged.faces, 10, "{:?}", mb.merged); // Two equal cylinders on one axis, overlapping: one longer cylinder.