mod common;
use common::{assert_close, slotted_cube};
#[test]
fn compare_with_design_reports_excess_and_gouge() {
let design = slotted_cube(4.0, 6.0).combined_mesh();
let a = slotted_cube(4.0, 8.0);
let ca = a.compare_with_design(&design, 0.0).unwrap();
assert_close(ca.excess_volume, 80.0, 2e-2, "excess of shallow cut");
assert!(ca.gouge_volume < 0.5, "gouge {}", ca.gouge_volume);
assert!(ca.excess_bounds.is_some() && ca.excess.triangle_count() > 0);
let b = slotted_cube(6.0, 6.0);
let cb = b.compare_with_design(&design, 0.0).unwrap();
assert_close(cb.gouge_volume, 80.0, 2e-2, "gouge of wide cut");
assert!(cb.excess_volume < 0.5, "excess {}", cb.excess_volume);
let ca_tol = a.compare_with_design(&design, 0.5).unwrap();
assert!(
ca_tol.excess_volume < ca.excess_volume,
"{} vs {}",
ca_tol.excess_volume,
ca.excess_volume
);
assert_close(ca_tol.excess_volume, 45.0, 5e-2, "excess beyond tolerance");
let same = slotted_cube(4.0, 6.0).compare_with_design(&design, 0.0).unwrap();
assert!(
same.is_within_tolerance(),
"{:?}",
(same.excess_volume, same.gouge_volume)
);
}