Wave 418/509: Kernel tests: the collapsed taper's mesh is held to its B-rep, the taper to validity (and 3 more)
4 commits, squashed; the originals stay reachable from tag archive/merge-main-develop. -a0c24b87cjyviko: Kernel tests: the back edge then the arc is one more pair of the rounds-in-sequence test -c69dbc5d3jyviko: Kernel tests: the collapsed taper's mesh is held to its B-rep, the taper to validity -87e9123d3jyviko: Kernel tests: a crowned patch's hostile crowns are refused for their range -65718cd41jyviko: Kernel tests: the five- and six-sided fills are graded by what they make, not their face counts Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DtL5M41G8Nua7HvuFPZkmJ
This commit is contained in:
1 parent
f4dcd28de7
commit
fdd103fc2a
5 files changed
+17
-26
No files matched your search
@@ -730,8 +730,7 @@ mod tests {
|
||||
let f = fillet_variable_spline(&wedge, at, t.start, &t.spline).unwrap();
|
||||
let v = fine_volume(&f);
|
||||
assert!(rel(v, 6000.0 - removed(&law, 40.0)) < 1e-4, "{v} vs {}", 6000.0 - removed(&law, 40.0));
|
||||
assert_eq!(f.unmeshed_faces(), 0);
|
||||
assert!(faces_and_vertices(&f).0.contains(&3));
|
||||
assert!(f.validity().is_empty(), "{:?}", f.validity());
|
||||
}
|
||||
|
||||
/// A radius spline given directly: a cubic with its control radii pulling the radius up in
|
||||
|
||||
@@ -239,18 +239,13 @@ fn a_round_ending_in_an_earlier_round_matches_both_together() {
|
||||
(arc_top(), TIP),
|
||||
(BACK, TIP),
|
||||
(arc_top(), BACK),
|
||||
// The other order (the arc's round once left 0.05 mm³ more at the knife-edge tip).
|
||||
(BACK, arc_top()),
|
||||
] {
|
||||
one_then_the_other(first, then);
|
||||
}
|
||||
}
|
||||
|
||||
/// The back edge rounded first, then the arc's top edge: the same solid as both together, or the
|
||||
/// other order (the arc's round once left 0.05 mm³ more at the knife-edge tip).
|
||||
#[test]
|
||||
fn the_arc_rounded_after_the_back_edge_matches_both_together() {
|
||||
one_then_the_other(BACK, arc_top());
|
||||
}
|
||||
|
||||
/// The edge at `first` rounded (2), then the one at `then` as a fillet of its own, each with its
|
||||
/// tangent chain as the Fillet feature rounds by default (tangent propagation), against the same
|
||||
/// edges of the part rounded together: the picks' chains, and every edge of the part that the
|
||||
|
||||
@@ -1580,7 +1580,8 @@ mod tests {
|
||||
assert!(matches!(first_surface(&lid), b::Surface::Plane { .. }), "a planar loop is a plane");
|
||||
// Hostile crowns are refused before anything is built.
|
||||
for crown in [f64::NAN, f64::INFINITY, 3.01, -0.91, 1e300] {
|
||||
assert!(patch_edges_crowned(&open, &rim, crown).is_err(), "crown {crown}");
|
||||
let e = patch_edges_crowned(&open, &rim, crown).unwrap_err();
|
||||
assert!(e.to_string().contains("crown must be between -0.9 and 3"), "crown {crown}: {e}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -400,8 +400,6 @@ fn a_five_sided_window_fills_g1_and_through_a_point() {
|
||||
let (open, rim) = pentagon_window();
|
||||
let (fill, r) = patch_edges_report(&open, &rim, &spec(Continuity::G1)).unwrap();
|
||||
report("pentagon g1", &r);
|
||||
// Five patches about a centre: each rim edge in two halves, and five spokes.
|
||||
assert!(fill.face_count() == 5 && fill.edge_count() >= 15, "five patches on the rim's halves and five spokes");
|
||||
check_face("pentagon g1", &open, &fill);
|
||||
let (gap, angle, _) = along_the_loop(&fill, &radial, &|_| 0.0);
|
||||
eprintln!("pentagon g1: along the rim: within {gap:e}, normal within {angle:.5}° of the wall's");
|
||||
@@ -437,12 +435,11 @@ fn a_hexagonal_rim_fills_through_a_point_and_g1_to_walls_meeting_at_angles_holds
|
||||
let open = copy_faces(&solid, &keep).unwrap();
|
||||
let plain = patch_edges(&open, &rim).unwrap();
|
||||
let sealed = |f: &Body| measure(&stitch(&[&open, f], 0.0).unwrap()).unwrap().volume;
|
||||
// Six sides, G0, through a point 3 mm above the middle of the plain fill: six patches about
|
||||
// a centre.
|
||||
// Six sides, G0, through a point 3 mm above the middle of the plain fill: it passes through
|
||||
// the point and seals the cup into a closed solid holding more than the plain fill's.
|
||||
let point = Faces::of(&plain).nearest(Vec3::new(0.0, 0.0, 12.0)).2 + Vec3::Z * 3.0;
|
||||
let (lifted, r) = patch_edges_report(&open, &rim, &PatchSpec { points: vec![point], ..PatchSpec::default() }).unwrap();
|
||||
report("hexagon through a point", &r);
|
||||
assert_eq!((lifted.face_count(), lifted.edge_count()), (6, 18), "six patches on the rim's twelve halves and six spokes");
|
||||
check_face("hexagon through a point", &open, &lifted);
|
||||
let off = Faces::of(&lifted).nearest(point).2.dist(point);
|
||||
eprintln!("hexagon through a point: the point is {off:e} off the surface; sealed {:.2} against {:.2} plain", sealed(&lifted), sealed(&plain));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use super::*;
|
||||
|
||||
fn wedge() -> (Body, RadiusSpline) {
|
||||
fn wedge() -> Body {
|
||||
use solidcraft_geom::{Loop2, Plane, Region2, Vec2};
|
||||
let outer = Loop2::polygon(&[Vec2::new(0., 0.), Vec2::new(40., 0.), Vec2::new(0., 20.)]);
|
||||
let body = crate::extrude(&Plane::XY, &[Region2 { outer, holes: vec![] }], 0., 15.).unwrap().pop().unwrap();
|
||||
@@ -9,23 +9,22 @@ fn wedge() -> (Body, RadiusSpline) {
|
||||
// is built over the wedge's cliffs (the blend-overflow decision), so a tapered fillet no
|
||||
// longer tapers it.
|
||||
let t = taper(&body, at, 16.).unwrap();
|
||||
(fillet_variable_spline(&body, at, t.start, &t.spline).unwrap(), t.spline)
|
||||
}
|
||||
|
||||
fn expected(law: &RadiusSpline) -> f64 {
|
||||
let n = 20_000;
|
||||
let integral = (0..n).map(|i| law.eval((i as f64 + 0.5) / n as f64).powi(2)).sum::<f64>() / n as f64;
|
||||
6000. - (1. - std::f64::consts::FRAC_PI_4) * 40. * integral
|
||||
fillet_variable_spline(&body, at, t.start, &t.spline).unwrap()
|
||||
}
|
||||
|
||||
/// The display mesh of a fillet tapering to zero at a wedge's tip converges to the B-rep: each
|
||||
/// mesh lies within its chord tolerance of the faces, so its volume is within the body's area
|
||||
/// times that tolerance of the exact one (SMLib's, integrated on the surfaces, to 1e-8). Only
|
||||
/// the mesher is under test here; the taper's own law is `taper_follows_the_room_along_the_edge`'s.
|
||||
#[test]
|
||||
fn collapsed_taper_mesh_stays_accurate_as_tolerance_decreases() {
|
||||
let (body, law) = wedge();
|
||||
let wanted = expected(&law);
|
||||
let body = wedge();
|
||||
let exact = crate::measure(&body).unwrap();
|
||||
for tol in [0.002, 0.001, 0.0005, 0.0002] {
|
||||
let mesh = body.mesh(&crate::MeshTolerance::chord(tol)).unwrap();
|
||||
assert!(mesh.positions.iter().all(|p| p.x.is_finite() && p.y.is_finite() && p.z.is_finite()));
|
||||
let got = mesh.measure().volume;
|
||||
assert!((got - wanted).abs() / wanted < 1e-4, "tol={tol}: {got} vs {wanted}");
|
||||
let bound = exact.area * tol;
|
||||
assert!((got - exact.volume).abs() <= bound, "tol={tol}: mesh {got} vs exact {} (within {bound})", exact.volume);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user