Wave 455/509: kernel: one smooth angle, and a round too small to change the part is refused (and 3 more)
4 commits, squashed; the originals stay reachable from tag archive/merge-main-develop. - 04955683f jyviko: Tests: a strip's tangent and curvature run-offs are the distance long across the surface - 4f64a035a jyviko: kernel: one smooth angle, and a round too small to change the part is refused - c23ef9d93 jyviko: Fillet rig: the knife-edge chamfers name SMLib's cause, a cusp's ball radius of 0 - 6f7172dc8 jyviko: kernel tests: a corner round wider than its faces overflows and takes the corner's other edges Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DtL5M41G8Nua7HvuFPZkmJ
This commit is contained in:
@@ -1294,8 +1294,9 @@ mod tests {
|
||||
/// Extend a cylinder strip: naturally 5 along its axis (10 · π/2 · 25, one face, still a
|
||||
/// cylinder), up to the plane z = 30 (10 · π/2 · 30), and by tangent and curvature run-offs
|
||||
/// along a straight edge, 20 long: each SMLib's G1 or G2 extension of the surface, so the
|
||||
/// strip stays one face (the tangent one a flat 5 × 20, the curvature one the parabola
|
||||
/// s ↦ s·R + ½κs²·n with the cylinder's κ = 1/10, its section ∫₀⁵ √(1 + κ²s²) ds long).
|
||||
/// strip stays one face. The distance is measured across the surface (the run-off's section
|
||||
/// is 5 long, whatever its curvature) and the strip is its section swept 20 along z, so each
|
||||
/// run-off adds 5 × 20: 10 · π/2 · 20 + 100.
|
||||
/// Undo, redo and reopening; the default saves nothing new.
|
||||
#[test]
|
||||
fn extend_a_cylinder_strip_every_way() {
|
||||
@@ -1322,11 +1323,9 @@ mod tests {
|
||||
run(&mut s, "edit.undo", json!({}));
|
||||
|
||||
let side = [0.0, 10.0, 10.0];
|
||||
let k: f64 = 0.1;
|
||||
let parabola = 2.5 * (1.0 + 25.0 * k * k).sqrt() + (5.0 * k).asinh() / (2.0 * k);
|
||||
for (mode, run_off) in [("tangent", 5.0), ("curvature", parabola)] {
|
||||
for mode in ["tangent", "curvature"] {
|
||||
run(&mut s, "surface.extend", json!({"body": "Strip", "edges": [side], "distance": 5, "mode": mode}));
|
||||
let want = 10.0 * pi / 2.0 * 20.0 + run_off * 20.0;
|
||||
let want = 10.0 * pi / 2.0 * 20.0 + 5.0 * 20.0;
|
||||
assert!((area(&s, "Strip") - want).abs() < want * 1e-3, "{mode}: {} vs {want}", area(&s, "Strip")); // (measured on meshes)
|
||||
let cold = Session::new(solidcraft_doc::Document::from_json(&s.doc.to_json()).unwrap());
|
||||
assert!((area(&cold, "Strip") - area(&s, "Strip")).abs() < 1e-9, "{mode}");
|
||||
|
||||
@@ -684,9 +684,11 @@ pub fn tangent_chain(body: &Body, picks: &[Vec3]) -> Result<Vec<Vec3>> {
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
/// Edges meeting at an angle below this continue one another; faces meeting at an angle below
|
||||
/// it meet tangentially.
|
||||
const TANGENT_DEGREES: f64 = 0.5;
|
||||
/// Edges meeting at an angle (radians) below this continue one another; faces meeting at an
|
||||
/// angle below it meet tangentially, a smooth edge with nothing to round. One value for smooth
|
||||
/// everywhere: the shaded view's ([`crate::smooth_edges::ANGLE`], half a degree), so an edge
|
||||
/// the view draws can be rounded and one it hides is smooth.
|
||||
const TANGENT: f64 = crate::smooth_edges::ANGLE;
|
||||
|
||||
/// The point halfway along edge `e`.
|
||||
fn edge_middle(rec: &Faces, e: usize) -> Option<Vec3> {
|
||||
@@ -699,7 +701,7 @@ fn normal_reach(rec: &Faces) -> f64 {
|
||||
rec.rec.tolerance.max(1e-7) * 10.0
|
||||
}
|
||||
|
||||
/// Whether edge `e`'s two uses meet tangentially (within [`TANGENT_DEGREES`]) all along it: a
|
||||
/// Whether edge `e`'s two uses meet tangentially (within [`TANGENT`]) all along it: a
|
||||
/// smooth edge, with no corner to blend (a seam a face meets itself across is one). An edge
|
||||
/// whose faces are tangent at one end only (a round running into a wall it is tangent to where
|
||||
/// the wall meets its face) is a crease everywhere else, which is not smooth; nor is a cusp, its
|
||||
@@ -707,7 +709,7 @@ fn normal_reach(rec: &Faces) -> f64 {
|
||||
/// edge. Decided exactly from the faces' surfaces and the uses' pcurves
|
||||
/// ([`crate::tangent_edge`]).
|
||||
fn smooth_join(rec: &Faces, e: usize) -> Result<bool> {
|
||||
crate::tangent_edge::tangent_all_along(&rec.rec, |f| rec.side(f), e, TANGENT_DEGREES.to_radians())
|
||||
crate::tangent_edge::tangent_all_along(&rec.rec, |f| rec.side(f), e, TANGENT)
|
||||
}
|
||||
|
||||
/// `seeds` (edges in the record's order, each once), then every other edge that continues one
|
||||
@@ -735,7 +737,7 @@ fn chain_of(rec: &Faces, seeds: &[usize], hidden: &[bool]) -> Result<Vec<usize>>
|
||||
}
|
||||
if a == v { rec.tangent(e, false) } else { rec.tangent(e, true).map(|t| t * -1.0) }
|
||||
};
|
||||
let cos = TANGENT_DEGREES.to_radians().cos();
|
||||
let cos = TANGENT.cos();
|
||||
let accept = normal_reach(rec);
|
||||
// Whether edge `e` is convex at its end `v` (its faces meet at less than 180° inside the
|
||||
// body): the direction into its second face, square to it, points against its first face's
|
||||
@@ -798,6 +800,33 @@ pub(crate) fn unfinished_chain(body: &Body, picks: &[Vec3], edges: &[usize], hid
|
||||
Ok(chain_of(&rec, &seeds, hidden)?.get(seeds.len()).and_then(|&next| edge_middle(&rec, next)))
|
||||
}
|
||||
|
||||
/// Before rounding exactly `edges` (the record's edges `picks` took, in order), edge i at radius
|
||||
/// `radii[i]`: refuses a round too small to change the part. Across a crease whose faces' normals
|
||||
/// turn by δ, a round of radius r lies r·(sec(δ/2) − 1) (≈ r·δ²/8) inside the sharp edge at its
|
||||
/// middle, the farthest it moves the part; below the edge's tolerance the round is the edge
|
||||
/// itself to the model's accuracy (SMLib refuses to build it). δ is the least turn along the edge
|
||||
/// ([`crate::tangent_edge::least_angle_along`]); the message names the smallest radius that
|
||||
/// rounds it, tolerance / (sec(δ/2) − 1), rounded up to the micrometre.
|
||||
pub(crate) fn rounds_too_small(body: &Body, picks: &[Vec3], edges: &[usize], radii: &[f64]) -> Result<()> {
|
||||
let rec = Faces::of(body)?;
|
||||
for (i, (&e, &r)) in edges.iter().zip(radii).enumerate() {
|
||||
let Some(edge) = rec.rec.edges.get(e) else { continue };
|
||||
let tolerance = edge.tolerance.max(rec.rec.tolerance);
|
||||
let Some(turn) = crate::tangent_edge::least_angle_along(&rec.rec, |f| rec.side(f), e)? else { continue };
|
||||
let reach = 1.0 / (0.5 * turn).cos() - 1.0;
|
||||
if !(turn > TANGENT && reach.is_finite() && reach > 0.0) || r * reach >= tolerance {
|
||||
continue;
|
||||
}
|
||||
let at = picks.get(i).map(|p| format!("({:.3}, {:.3}, {:.3})", p.x, p.y, p.z)).unwrap_or_default();
|
||||
let smallest = (tolerance / reach * 1e3).ceil() / 1e3;
|
||||
return Err(KernelError::Invalid(format!(
|
||||
"a round of radius {r} mm on the edge at {at} is too small: its faces turn only {:.2}° across the edge, so the round stays within the model's tolerance ({tolerance} mm) of it and changes nothing; the smallest radius that rounds this edge is {smallest:.3} mm",
|
||||
turn.to_degrees()
|
||||
)));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// A blend's failure where a picked edge continues tangentially into `next`, an edge left out
|
||||
/// ([`unfinished_chain`]): SMLib rounds a tangent chain as one sequence and could not end the
|
||||
/// blend there, so the reason and the way out are named.
|
||||
@@ -1216,6 +1245,66 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// A block 40 wide and 20 deep (z 0…20) whose top rises from y = 20 at its sides to a
|
||||
/// crease along z at x = 20, each half sloping `slope` degrees, so the faces turn by twice
|
||||
/// that across the crease; and a point on the crease.
|
||||
fn roof(slope: f64) -> (Body, Vec3) {
|
||||
let h = 20.0 * slope.to_radians().tan();
|
||||
let outline = [Vec2::new(0.0, 0.0), Vec2::new(40.0, 0.0), Vec2::new(40.0, 20.0), Vec2::new(20.0, 20.0 + h), Vec2::new(0.0, 20.0)];
|
||||
let region = Region2 { outer: Loop2::polygon(&outline), holes: vec![] };
|
||||
let body = crate::build::extrude(&Plane::XY, &[region], 0.0, 20.0).unwrap().remove(0);
|
||||
(body, Vec3::new(20.0, 20.0 + h, 10.0))
|
||||
}
|
||||
|
||||
/// A round lies r·(sec(δ/2) − 1) inside the crease it replaces (δ the faces' turn): below the
|
||||
/// edge's tolerance it changes nothing and is refused as too small, naming the smallest
|
||||
/// radius that rounds. The block's edges are held to 2e-5 mm (SMLib's intersection tolerance
|
||||
/// for a part this size, twice its zone tolerance of 1e-5). At 1° an R0.4 round would lie
|
||||
/// 0.4 · (sec 0.5° − 1) = 0.015 µm in, under it: the smallest is 2e-5 / (sec 0.5° − 1) =
|
||||
/// 0.52523 mm, named rounded up. At 3° the R2 round is 0.685 µm in and builds: one face more,
|
||||
/// the top that much lower, removing 20 · r²(tan(δ/2) − δ/2) = 4.786e-4 mm³.
|
||||
#[test]
|
||||
fn a_round_too_small_to_change_the_part_is_refused_naming_the_smallest_that_rounds() {
|
||||
let (gentle, crease) = roof(0.5);
|
||||
let rec = Faces::of(&gentle).unwrap().rec;
|
||||
assert!(rec.tolerance == 2e-5 && rec.edges.iter().all(|e| e.tolerance == 2e-5), "{}", rec.tolerance);
|
||||
let turn = 1f64.to_radians();
|
||||
let smallest = 2e-5 / (1.0 / (0.5 * turn).cos() - 1.0);
|
||||
assert!((smallest - 0.52523).abs() < 1e-5, "{smallest}");
|
||||
let e = fillet(&gentle, &[crease], 0.4).unwrap_err().to_string();
|
||||
assert!(
|
||||
e.contains("is too small") && e.contains("turn only 1.00°") && e.contains("the smallest radius that rounds this edge is 0.526 mm"),
|
||||
"{e}"
|
||||
);
|
||||
|
||||
let (steeper, crease) = roof(1.5);
|
||||
let (r, turn) = (2.0, 3f64.to_radians());
|
||||
let rounded = fillet(&steeper, &[crease], r).unwrap();
|
||||
assert!(rounded.validity().is_empty(), "{:?}", rounded.validity());
|
||||
assert_eq!(rounded.face_count(), steeper.face_count() + 1);
|
||||
let (before, after) = (crate::measure(&steeper).unwrap(), crate::measure(&rounded).unwrap());
|
||||
let sag = r * (1.0 / (0.5 * turn).cos() - 1.0);
|
||||
assert!(((before.bbox.max.y - after.bbox.max.y) - sag).abs() < 1e-9, "{} vs {sag}", before.bbox.max.y - after.bbox.max.y);
|
||||
let removed = 20.0 * r * r * ((0.5 * turn).tan() - 0.5 * turn);
|
||||
assert!(((before.volume - after.volume) - removed).abs() < 1e-6, "{} vs {removed}", before.volume - after.volume);
|
||||
}
|
||||
|
||||
/// At 1° the crease rounds from 0.526 mm: R2 lies 0.076 µm in and R20 0.76 µm, and each
|
||||
/// builds, removing 20 · r²(tan(δ/2) − δ/2).
|
||||
#[test]
|
||||
#[ignore = "fails until SMLib rounds creases from 0.5° (SmEdge::GetBlendEdgeuse calls an edge within 2° of tangent smooth: SM_ERR_INVALID_INPUT)"]
|
||||
fn a_one_degree_crease_rounds_from_the_smallest_radius_named() {
|
||||
let (gentle, crease) = roof(0.5);
|
||||
let turn = 1f64.to_radians();
|
||||
for r in [2.0, 20.0] {
|
||||
let rounded = fillet(&gentle, &[crease], r).unwrap();
|
||||
assert!(rounded.validity().is_empty(), "r={r}: {:?}", rounded.validity());
|
||||
let removed = 20.0 * r * r * ((0.5 * turn).tan() - 0.5 * turn);
|
||||
let (before, after) = (crate::measure(&gentle).unwrap().volume, crate::measure(&rounded).unwrap().volume);
|
||||
assert!(((before - after) - removed).abs() < 1e-6, "r={r}: {} vs {removed}", before - after);
|
||||
}
|
||||
}
|
||||
|
||||
/// A pin standing in a socket, 3.5 mm from two of its walls, in a large block. The cutters
|
||||
/// for its tip reach several times the chamfer's size past each edge (more on a larger part),
|
||||
/// into the walls, and their union took bites out of them: 7.2 mm³ instead of the tip's.
|
||||
|
||||
@@ -204,6 +204,9 @@ mod imp {
|
||||
sizes_ok(what, sizes)?;
|
||||
let picked = resolve(body, edges)?;
|
||||
let next = crate::blend::unfinished_chain(body, edges, &picked.edges, &picked.hidden)?;
|
||||
if matches!(kind, Kind::Round) {
|
||||
crate::blend::rounds_too_small(body, edges, &picked.edges, sizes)?;
|
||||
}
|
||||
let tol = pick_tolerance(body);
|
||||
let Kind::Round = kind else {
|
||||
let kind = blend_kind(kind);
|
||||
@@ -257,6 +260,7 @@ mod imp {
|
||||
}
|
||||
let picked = resolve(body, edges)?;
|
||||
let next = crate::blend::unfinished_chain(body, edges, &picked.edges, &picked.hidden)?;
|
||||
crate::blend::rounds_too_small(body, edges, &picked.edges, sizes)?;
|
||||
let corners = corner_vertices(body, setbacks.iter().map(|(p, _)| *p))?;
|
||||
let distances: Vec<f64> = setbacks.iter().map(|(_, d)| *d).collect();
|
||||
let tol = pick_tolerance(body);
|
||||
|
||||
@@ -33,7 +33,8 @@ const STATIONS: usize = 8;
|
||||
/// 1–2% step the eye tells apart on a smooth gradient. So a join this close to tangent shows no
|
||||
/// line in the shading. Exact tangency (fillets, analytic seams) reads 1e-12 or so, far inside
|
||||
/// it; real creases a model means are degrees. Tangency alone does not hide an edge ([`BEND`]).
|
||||
const ANGLE: f64 = 0.5 * std::f64::consts::PI / 180.0;
|
||||
/// It is SolidCraft's one angle for smooth: a blend finds nothing to round below it too.
|
||||
pub(crate) const ANGLE: f64 = 0.5 * std::f64::consts::PI / 180.0;
|
||||
/// Largest difference of the two faces' normal curvatures across an edge, relative to the
|
||||
/// larger one (or to 1 / the edge's length where both are flatter), that still counts as one
|
||||
/// smooth surface (G2): [`ANGLE`], the same visibility criterion as for the normals. Continued
|
||||
|
||||
@@ -265,12 +265,15 @@ fn bernstein_roots(c: &[f64], lo: f64, hi: f64, depth: u32, work: &mut usize, ou
|
||||
bernstein_roots(&r, mid, hi, depth - 1, work, out);
|
||||
}
|
||||
|
||||
/// Whether edge `e`'s two uses' faces meet with outward normals within `max_angle` (radians) of
|
||||
/// each other all along it, `sign(f)` turning face `f`'s natural normal outward. An edge with
|
||||
/// other than two uses has no such pair: false. See the module documentation.
|
||||
pub(crate) fn tangent_all_along(rec: &Brep, sign: impl Fn(usize) -> Option<f64>, e: usize, max_angle: f64) -> Result<bool> {
|
||||
/// Calls `visit` with the outward unit normals of edge `e`'s two uses' faces at one point of the
|
||||
/// edge after another, `sign(f)` turning face `f`'s natural normal outward: on each piece of the
|
||||
/// edge where both normals are polynomials, at the `D + 1` Chebyshev points the module
|
||||
/// documentation describes, skipping a point where either is undefined (a pole). `visit` returns
|
||||
/// whether to go on. `Ok(None)` for an edge with other than two uses; else whether some point had
|
||||
/// both normals.
|
||||
fn normal_pairs(rec: &Brep, sign: impl Fn(usize) -> Option<f64>, e: usize, mut visit: impl FnMut(Vec3, Vec3) -> bool) -> Result<Option<bool>> {
|
||||
let edge = rec.edges.get(e).ok_or_else(|| failed(format!("edge {e}")))?;
|
||||
let [ua, ub] = edge.uses.as_slice() else { return Ok(false) };
|
||||
let [ua, ub] = edge.uses.as_slice() else { return Ok(None) };
|
||||
let use_of = |u: &solidcraft_geom::brep::EdgeUseRef| -> Result<Use<'_>> {
|
||||
let face = rec.faces.get(u.face as usize).ok_or_else(|| failed(format!("face {}", u.face)))?;
|
||||
let oriented = match face.loops.get(u.r#loop as usize) {
|
||||
@@ -297,7 +300,6 @@ pub(crate) fn tangent_all_along(rec: &Brep, sign: impl Fn(usize) -> Option<f64>,
|
||||
if breaks.len().saturating_mul(nodes) > MAX_POINTS {
|
||||
return Err(failed(format!("deciding tangency along edge {e}: {} pieces of degree {degree}", breaks.len())));
|
||||
}
|
||||
let cos = max_angle.cos();
|
||||
let mut defined = false;
|
||||
for w in breaks.windows(2) {
|
||||
let &[t0, t1] = w else { continue };
|
||||
@@ -308,17 +310,47 @@ pub(crate) fn tangent_all_along(rec: &Brep, sign: impl Fn(usize) -> Option<f64>,
|
||||
for j in 0..nodes {
|
||||
let t = m + h * ((2 * j + 1) as f64 * std::f64::consts::PI / (2 * nodes) as f64).cos();
|
||||
if let (Some(na), Some(nb)) = (a.normal(t)?, b.normal(t)?) {
|
||||
if !(na.dot(nb) >= cos) {
|
||||
return Ok(false);
|
||||
}
|
||||
defined = true;
|
||||
if !visit(na, nb) {
|
||||
return Ok(Some(true));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(Some(defined))
|
||||
}
|
||||
|
||||
/// Whether edge `e`'s two uses' faces meet with outward normals within `max_angle` (radians) of
|
||||
/// each other all along it, `sign(f)` turning face `f`'s natural normal outward. An edge with
|
||||
/// other than two uses has no such pair: false. See the module documentation.
|
||||
pub(crate) fn tangent_all_along(rec: &Brep, sign: impl Fn(usize) -> Option<f64>, e: usize, max_angle: f64) -> Result<bool> {
|
||||
let cos = max_angle.cos();
|
||||
let mut tangent = true;
|
||||
let Some(defined) = normal_pairs(rec, sign, e, |na, nb| {
|
||||
tangent = na.dot(nb) >= cos;
|
||||
tangent
|
||||
})?
|
||||
else {
|
||||
return Ok(false);
|
||||
};
|
||||
if !defined {
|
||||
return Err(failed(format!("edge {e}: its faces' normals are undefined all along it")));
|
||||
}
|
||||
Ok(true)
|
||||
Ok(tangent)
|
||||
}
|
||||
|
||||
/// The least angle (radians, 0 to π) between the outward normals of edge `e`'s two uses' faces
|
||||
/// at the points [`normal_pairs`] visits: the edge's least angle where it is the same all along
|
||||
/// the edge (two planes, a plane and a cylinder along a generator), at most a little above it
|
||||
/// elsewhere. `None` for an edge with other than two uses, or whose normals are undefined
|
||||
/// everywhere.
|
||||
pub(crate) fn least_angle_along(rec: &Brep, sign: impl Fn(usize) -> Option<f64>, e: usize) -> Result<Option<f64>> {
|
||||
let mut least = f64::INFINITY;
|
||||
let defined = normal_pairs(rec, sign, e, |na, nb| {
|
||||
least = least.min(na.cross(nb).len().atan2(na.dot(nb)));
|
||||
true
|
||||
})?;
|
||||
Ok(defined.filter(|d| *d).map(|_| least))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -373,17 +373,43 @@ fn fillet_max_each_reduces_only_where_the_radius_does_not_fit() {
|
||||
assert_eq!(fillet_max_each(&post, &mids, 3.5).unwrap().map(|x| x.0), Some(vec![3.0; 4]));
|
||||
}
|
||||
|
||||
/// A corner's rounds with a radius per edge, one wider than its faces, are refused as too large,
|
||||
/// so a fit can reduce them. (The same corner at one radius as wide as the faces, and its fit,
|
||||
/// are the rig's fillets/477-fillet-cube-corner-rounds-as-wide-as-faces-* cases; no command
|
||||
/// takes a radius per edge.)
|
||||
/// R21 on an edge of a 20 mm cube overflows on its tangent sides, which a round may, taking all
|
||||
/// of both faces beside the edge: its circle about (y, z) = (21, 21) meets them only at 21, past
|
||||
/// the cube. What is left is the square [0, 20]² inside that circle, with u = 21 − y,
|
||||
/// ∫₁^√440 (√(441 − u²) − 1) du, along 20: 6107.529370.
|
||||
fn round_wider_than_its_faces() -> f64 {
|
||||
let f = |u: f64| 0.5 * (u * (441.0 - u * u).sqrt() + 441.0 * (u / 21.0).asin());
|
||||
let w = 440f64.sqrt();
|
||||
20.0 * (f(w) - f(1.0) - (w - 1.0))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn corner_rounds_larger_than_their_faces_are_too_large() {
|
||||
fn a_round_wider_than_its_faces_overflows_onto_its_tangent_sides() {
|
||||
let want = round_wider_than_its_faces();
|
||||
assert!((want - 6107.529370).abs() < 1e-6, "{want}");
|
||||
let b = box_solid(Vec3::ZERO, Vec3::new(20.0, 20.0, 20.0)).unwrap();
|
||||
let out = fillet(&b, &[Vec3::new(10.0, 0.0, 0.0)], 21.0).unwrap();
|
||||
assert!(out.validity().is_empty(), "{:?}", out.validity());
|
||||
assert!(rel(measure(&out).unwrap().volume, want) < 1e-9, "{} vs {want}", measure(&out).unwrap().volume);
|
||||
}
|
||||
|
||||
/// A corner's rounds with a radius per edge, one wider than its faces: R21 with R5 on the other
|
||||
/// two edges at the corner. The R21 takes both faces beside its edge, and with them the R5
|
||||
/// edges, which lie on them: the body is R21's alone
|
||||
/// ([`a_round_wider_than_its_faces_overflows_onto_its_tangent_sides`]). (The same corner at one
|
||||
/// radius as wide as the faces, and its fit, are the rig's
|
||||
/// fillets/477-fillet-cube-corner-rounds-as-wide-as-faces-* cases; no command takes a radius per
|
||||
/// edge.)
|
||||
#[test]
|
||||
#[ignore = "fails until SMLib blends the corner whole: status 1001, fillet error 4 (edge type 14), Unable to Trim Rail Curve"]
|
||||
fn a_corner_round_wider_than_its_faces_overflows_and_takes_the_corners_other_edges() {
|
||||
let b = box_solid(Vec3::ZERO, Vec3::new(20.0, 20.0, 20.0)).unwrap();
|
||||
let corner = [Vec3::new(10.0, 0.0, 0.0), Vec3::new(0.0, 10.0, 0.0), Vec3::new(0.0, 0.0, 10.0)];
|
||||
let sel: Vec<(Vec3, f64)> = corner.iter().copied().zip([21.0, 5.0, 5.0]).collect();
|
||||
let e = crate::blend_corner::fillet_radii(&b, &sel).unwrap_err();
|
||||
assert!(matches!(e, KernelError::TooLarge(_)), "{e}");
|
||||
let out = crate::blend_corner::fillet_radii(&b, &sel).unwrap();
|
||||
assert!(out.validity().is_empty(), "{:?}", out.validity());
|
||||
let want = round_wider_than_its_faces();
|
||||
assert!(rel(measure(&out).unwrap().volume, want) < 1e-9, "{} vs {want}", measure(&out).unwrap().volume);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -15,7 +15,7 @@ The long form is `docs/book/src/dev/testing.md`.
|
||||
- Crash fixes: a regression test from the report's `design.solidcraft` and `replay.json` (`skills/solidcraft-crash-safety/SKILL.md`).
|
||||
|
||||
## Unit test or rig case
|
||||
- Unit tests assert the code's logic: which edges a chain picks, name resolution, history labels, refusal wording, hostile input, parsing and saving (`corner_rounds_larger_than_their_faces_are_too_large`: per-edge radii, which no command takes, refused as `TooLarge`).
|
||||
- Unit tests assert the code's logic: which edges a chain picks, name resolution, history labels, refusal wording, hostile input, parsing and saving (`a_corner_round_wider_than_its_faces_overflows_and_takes_the_corners_other_edges`: per-edge radii, which no command takes, so no rig case can).
|
||||
- The rig (`tests/kernel-cases/`) asserts geometry: exact volumes, shapes, seam continuity, geometric refusals, through commands with a hand-derived answer, so it survives a kernel swap (`fillets/190-fillet-disc-rim-past-its-2mm-wall`). A test doing both keeps only its logic.
|
||||
|
||||
## A failing test needs its fix
|
||||
|
||||
@@ -28,11 +28,11 @@
|
||||
5835-chamfer-sloped-basin-1-mm-rim-2-two-edges SMLib status 1001: SmFilletNx2Corner, CalcFilletIntSideFace cannot intersect a chamfer with the side face at the rim's corner, where the front chamfer past the rim should build cut by the front face
|
||||
5835-chamfer-sloped-basin-4-mm-rim-2-2-edges SMLib status 1001 on the chamfers meeting at the rim's re-entrant corner
|
||||
5835-chamfer-sloped-basin-4-mm-rim-2-4-edges SMLib status 1001 on the chamfers meeting at the rim's re-entrant corners
|
||||
851-chamfer-knife-edge-tip-0-5 SMLib SM_ERR_INVALID_INPUT on the knife edge (opposite normals on its two faces)
|
||||
851-chamfer-knife-edge-tip-2 SMLib SM_ERR_INVALID_INPUT on the knife edge (opposite normals on its two faces)
|
||||
851-chamfer-knife-edge-tip-2-box-less-cylinder SMLib SM_ERR_INVALID_INPUT on the knife edge (opposite normals on its two faces)
|
||||
851-chamfer-knife-edge-tip-2-sketched SMLib SM_ERR_INVALID_INPUT on the knife edge (opposite normals on its two faces)
|
||||
851-chamfer-knife-edge-tip-5 SMLib SM_ERR_INVALID_INPUT on the knife edge (opposite normals on its two faces)
|
||||
851-chamfer-knife-edge-tip-0-5 SMLib SM_ERR_INVALID_INPUT: smlib_chamfer takes the ball radius d·√((1−c)/(1+c)), c the faces' binormals' dot (capi chamfer_radius), which is 0 at a cusp, where they agree; the case wants the ball of radius d
|
||||
851-chamfer-knife-edge-tip-2 SMLib SM_ERR_INVALID_INPUT: smlib_chamfer takes the ball radius d·√((1−c)/(1+c)), c the faces' binormals' dot (capi chamfer_radius), which is 0 at a cusp, where they agree; the case wants the ball of radius d
|
||||
851-chamfer-knife-edge-tip-2-box-less-cylinder SMLib SM_ERR_INVALID_INPUT: smlib_chamfer takes the ball radius d·√((1−c)/(1+c)), c the faces' binormals' dot (capi chamfer_radius), which is 0 at a cusp, where they agree; the case wants the ball of radius d
|
||||
851-chamfer-knife-edge-tip-2-sketched SMLib SM_ERR_INVALID_INPUT: smlib_chamfer takes the ball radius d·√((1−c)/(1+c)), c the faces' binormals' dot (capi chamfer_radius), which is 0 at a cusp, where they agree; the case wants the ball of radius d
|
||||
851-chamfer-knife-edge-tip-5 SMLib SM_ERR_INVALID_INPUT: smlib_chamfer takes the ball radius d·√((1−c)/(1+c)), c the faces' binormals' dot (capi chamfer_radius), which is 0 at a cusp, where they agree; the case wants the ball of radius d
|
||||
9-fillet-corner-curvature-with-reduce-fit not supported yet: solid.fillet builds corner g2 with the exact fit only
|
||||
9-fillet-corner-curvature-with-taper-fit not supported yet: solid.fillet builds corner g2 with the exact fit only
|
||||
926-chamfer-top-edge-ending-on-boss-wall-above-it not supported yet: the chamfer is refused as larger than its faces where it ends on the boss's wall
|
||||
|
||||
Reference in New Issue
Block a user