diff --git a/crates/kernel/src/tests.rs b/crates/kernel/src/tests.rs index 2056d1b2e..bf25aa8ab 100644 --- a/crates/kernel/src/tests.rs +++ b/crates/kernel/src/tests.rs @@ -1724,17 +1724,14 @@ fn tabbed_plate_area(da: f64, dt: f64) -> f64 { 0.5 * (big * big * (PI + 2.0 * at) + tab) + (4.0 - dt) * (cy - yc) } -#[test] -fn fillet_tabbed_plate_outer_loop_and_partial_selection_after_hole() { +/// The tabbed plate's outer outline, reconstructed from its seven public pick coordinates: an R25 +/// plate, x = ±4 tab sides, R2 corners centred at (±2, 280/9) and a 4 mm straight top. +fn tabbed_plate_outline() -> Loop2 { use solidcraft_geom::Seg2; - // Reconstruct the outer outline from its seven public pick coordinates: - // R25 plate, x=+/-4 tab sides, R2 corners and a 4 mm straight top. - // The hole's dimensions come from the public reproduction, not an original design file. let theta = (4.0_f64 / 25.0).acos(); let y = (625.0_f64 - 16.0).sqrt(); let corner_y = 280.0 / 9.0; - let hole_y = 262.0 / 9.0; - let outline = Loop2 { + Loop2 { segs: vec![ Seg2::Arc { center: Vec2::ZERO, radius: 25.0, start: PI - theta, sweep: PI + 2.0 * theta }, Seg2::Line { a: Vec2::new(4.0, y), b: Vec2::new(4.0, corner_y) }, @@ -1743,7 +1740,43 @@ fn fillet_tabbed_plate_outer_loop_and_partial_selection_after_hole() { Seg2::Arc { center: Vec2::new(-2.0, corner_y), radius: 2.0, start: PI / 2.0, sweep: PI / 2.0 }, Seg2::Line { a: Vec2::new(-4.0, corner_y), b: Vec2::new(-4.0, y) }, ], - }; + } +} + +/// solidcore#2223: the tabbed plate's R25 rim and one R2 tab corner arc, which share no vertex, +/// rounded together at r 0.5 on the plate 2 high (no hole). Each rounds alone; together they +/// failed 1001 in cliff_overflow. They take off the sum: the rim alone's 7.958674274526857 +/// (solidcore#2176's pinned value) and the corner arc's Pappus volume with flat ends, +/// 0.15913583972191622 (the spandrel (1 − π/4) r² about the corner's axis at 2 − its centroid +/// over a quarter turn), 8.117810114. +#[test] +fn fillet_tabbed_plate_rim_and_one_corner_arc_together() { + let body = extrude(&Plane::XY, &[Region2 { outer: tabbed_plate_outline(), holes: vec![] }], 0.0, 2.0).unwrap().pop().unwrap(); + let r = 0.5; + let (spandrel, centroid) = ((1.0 - PI / 4.0) * r * r, r * (10.0 - 3.0 * PI) / (3.0 * (4.0 - PI))); + let corner = spandrel * (PI / 2.0) * (2.0 - centroid); + assert!((corner - 0.159_135_839_721_916_22).abs() < 1e-12, "{corner}"); + let want = 7.958_674_274_526_857 + corner; + let picks = [ + Vec3::new(-24.91935125502191, -2.0064727829797544, 2.0), + Vec3::new(24.919351255429795, -2.006472777913911, 2.0), + Vec3::new(3.4142135598750105, 32.525324672801695, 2.0), + ]; + let blended = fillet(&body, &picks, r).unwrap_or_else(|e| panic!("rim and corner arc together: {e}")); + assert!(blended.validity().is_empty(), "{:?}", blended.validity()); + assert_eq!(blended.face_count(), 12); + let got = measure(&body).unwrap().volume - measure(&blended).unwrap().volume; + assert!((got - want).abs() < 1e-7, "removed {got}, expected {want}"); +} + +#[test] +fn fillet_tabbed_plate_outer_loop_and_partial_selection_after_hole() { + // The hole's dimensions come from the public reproduction, not an original design file. + let theta = (4.0_f64 / 25.0).acos(); + let y = (625.0_f64 - 16.0).sqrt(); + let corner_y = 280.0 / 9.0; + let hole_y = 262.0 / 9.0; + let outline = tabbed_plate_outline(); let body = extrude(&Plane::XY, &[Region2 { outer: outline, holes: vec![Loop2::circle(Vec2::new(0.0, hole_y), 1.5)] }], 0.0, 2.0).unwrap().pop().unwrap(); let r = 0.5; diff --git a/tests/KNOWN_FAILING_TESTS b/tests/KNOWN_FAILING_TESTS index f5af6ca23..d9da050a4 100644 --- a/tests/KNOWN_FAILING_TESTS +++ b/tests/KNOWN_FAILING_TESTS @@ -17,6 +17,6 @@ solidcraft-kernel::blend_corner::tests::three_rounds_at_a_corner the corner's va solidcraft-kernel::blend_variable::tests::variable_radius_with_a_corner_through_a_middle_point solidcore refuses a variable fillet whose law has a corner (solidcore#430) solidcraft-kernel::corner_g2::tests::a_long_setback_keeps_the_g2_patch_inside_the_box at set backs 11 to 15 the G2 corner patch bulges past the box, as on C++ solidcraft-kernel::corner_g2::tests::the_box_corner_g2_patch_is_a_closed_solid_curvature_continuous_to_its_neighbours the fitted G2 corner patch bulges 1.7e-5 past the box, as on C++ -solidcraft-kernel::tests::fillet_tabbed_plate_outer_loop_and_partial_selection_after_hole each tab corner arc rounds alone since solidcore#2176, but the R25 rim and a corner arc picked together fail 1001 in cliff_overflow (no room), though each builds alone; on C++ the rounds together miss by 3.8e-4 (solidcore#2223) +solidcraft-kernel::tests::fillet_tabbed_plate_outer_loop_and_partial_selection_after_hole the R25 rim and a corner arc round together since solidcore#2223, but the two R2 corner arcs picked together fail 1001 in trim_at_creases (cliff_overflow with the crease trims off), though each builds alone (solidcore#2314) solidcraft-smlib::core::offset_tests::mitred_rounds_follow_a_moved_top the C++ comparison: solidcore's offset edges keep their tolerances (offset_edges_keep_source_tolerance, solidcore#2111), C++ at 7ac037e's do not, so the moved tops' volumes are 2e-9 to 2.3e-7 apart; both are 1.2e-8 to 3.1e-7 off the closed form at accuracy 1e-8, solidcore with the fix 2.1e-7 at most solidcraft-smlib::ops::tests::a_variable_round_with_a_corner_in_its_law_is_its_balls_union solidcore refuses a variable fillet whose law has a corner (solidcore#430)