Tests: volume checks held to what their measures can tell, not tighter

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 <noreply@anthropic.com>
This commit is contained in:
jyviko
2026-10-29 01:04:21 -04:00
committed by Irakli Kourtis
parent 6a780de5fd
commit 80b7ce28e0
2 changed files with 8 additions and 2 deletions
+5 -1
View File
@@ -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})");
}
}
}
+3 -1
View File
@@ -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.