From b16e8a5423776f83585679d263aa2d08b3139dc2 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Fri, 30 Oct 2026 23:06:33 -0400 Subject: [PATCH 01/81] Sketch: a control spline can carry its own knots and weights A sketch spline over control points was always the clamped uniform B-spline over them, so a free-form edge whose knots are not evenly spaced (or whose weights are not 1) could only come into a sketch as one curve per Bezier span. A control spline now may save `nurbs`: its clamped knots and its weights. Its points, polyline, exact pieces (one a knot span; conics for a rational quadratic), the solver's distance and curvature, links, parallel re-projection and inspect.sketch all read them; a loaded design's are checked. One pending format file (spline-knots). Co-Authored-By: Claude Opus 5.5 --- crates/doc/src/format.rs | 3 +- crates/doc/src/format/pending/spline-knots.rs | 6 + crates/doc/src/project.rs | 11 +- crates/doc/src/project3d.rs | 4 +- crates/doc/src/project_order.rs | 8 +- crates/engine/src/cmd/inspect.rs | 12 +- crates/engine/src/cmd/sketch_create.rs | 10 +- crates/engine/src/cmd/sketch_freeform.rs | 4 +- crates/engine/src/cmd/sketch_import.rs | 2 +- crates/engine/src/cmd/sketch_modify.rs | 2 +- crates/sketch/src/curves.rs | 14 +- crates/sketch/src/freeform_offset.rs | 11 +- crates/sketch/src/freeform_offset/trim.rs | 9 +- crates/sketch/src/lib.rs | 2 + crates/sketch/src/link.rs | 74 +++++-- crates/sketch/src/model.rs | 27 ++- crates/sketch/src/nurbs.rs | 200 ++++++++++++++++++ crates/sketch/src/periodic.rs | 14 +- crates/sketch/src/solver.rs | 16 +- crates/sketch/src/tests.rs | 74 ++++++- crates/sketch/src/text.rs | 2 +- crates/sketch/src/thin.rs | 2 +- crates/sketch/src/virtual_corner_tests.rs | 4 +- crates/ui-egui/src/tools.rs | 1 + 24 files changed, 434 insertions(+), 78 deletions(-) create mode 100644 crates/doc/src/format/pending/spline-knots.rs create mode 100644 crates/sketch/src/nurbs.rs diff --git a/crates/doc/src/format.rs b/crates/doc/src/format.rs index 043a5cba7..53fe967ad 100644 --- a/crates/doc/src/format.rs +++ b/crates/doc/src/format.rs @@ -676,6 +676,7 @@ pub fn read(s: &str) -> Result { sketch.validate_wires().map_err(|e| DocError::Invalid(format!("damaged design: {e}")))?; sketch.validate_patterns().map_err(|e| DocError::Invalid(format!("damaged design: {e}")))?; sketch.validate_periodic_splines().map_err(|e| DocError::Invalid(format!("damaged design: {e}")))?; + sketch.validate_spline_knots().map_err(|e| DocError::Invalid(format!("damaged design: {e}")))?; } if let crate::FeatureKind::BodyTransfer { from, to, .. } = &feature.kind && [from, to].into_iter().any(|id| !component_ids.contains(id)) @@ -1811,7 +1812,7 @@ mod tests { let first = pts[0]; let neighbor = pts[1]; let closing = pts[3]; - sketch.add_curve(CurveKind::Spline { pts, control: false, degree: 3, periodic: true }, None).unwrap(); + sketch.add_curve(CurveKind::Spline { pts, control: false, degree: 3, periodic: true, nurbs: None }, None).unwrap(); let mut document = Document::new("periodic file validation"); document.add_feature(crate::FeatureKind::Sketch { plane: crate::PlaneRef::Origin { name: "XY".into() }, sketch }, None).unwrap(); assert_eq!(read(&document.to_json()).unwrap(), document); diff --git a/crates/doc/src/format/pending/spline-knots.rs b/crates/doc/src/format/pending/spline-knots.rs new file mode 100644 index 000000000..8fd839e95 --- /dev/null +++ b/crates/doc/src/format/pending/spline-knots.rs @@ -0,0 +1,6 @@ +//! A sketch's control spline may save `nurbs`: its own `knots` (clamped, the point count plus +//! the degree plus one) and `weights` (one per point; none: all 1). A projected free-form edge +//! comes in as that one exact curve, where it came in as one spline per Bézier span. An older +//! design has none: its splines are the clamped uniform B-splines they were, and its projected +//! edges are read again as they rebuild. The last release refuses a design with this change +//! (the newer format number). diff --git a/crates/doc/src/project.rs b/crates/doc/src/project.rs index e629aa024..6b22d6c82 100644 --- a/crates/doc/src/project.rs +++ b/crates/doc/src/project.rs @@ -587,8 +587,8 @@ fn link_geom(s: &Seg2) -> Option { LinkGeom::Arc { c: center, a, b } } Seg2::Conic { a, apex, b, w } => LinkGeom::Conic { a, apex, b, rho: w / (1. + w) }, - Seg2::Cubic { p0, p1, p2, p3 } => LinkGeom::Spline { pts: vec![p0, p1, p2, p3], control: true, degree: 3, periodic: false }, - Seg2::Bezier { n, p } => LinkGeom::Spline { pts: p.get(..=usize::from(n))?.to_vec(), control: true, degree: n, periodic: false }, + Seg2::Cubic { p0, p1, p2, p3 } => LinkGeom::Spline { pts: vec![p0, p1, p2, p3], control: true, degree: 3, periodic: false, nurbs: None }, + Seg2::Bezier { n, p } => LinkGeom::Spline { pts: p.get(..=usize::from(n))?.to_vec(), control: true, degree: n, periodic: false, nurbs: None }, }) } @@ -1088,9 +1088,10 @@ fn project_sketch_curve(sk: &Sketch, from: &Plane, ci: usize, to: &Plane) -> Vec (Some(c), Some(m)) => vec![LinkGeom::Ellipse { c: map(c), major: map(m), minor: *r }], _ => Vec::new(), }, - Some(CurveKind::Spline { pts, control, degree, periodic }) if parallel => { + Some(CurveKind::Spline { pts, control, degree, periodic, nurbs }) if parallel => { let p: Option> = pts.iter().map(|q| sk.point(*q).map(map)).collect(); - p.map(|pts| vec![LinkGeom::Spline { pts, control: *control, degree: *degree, periodic: *periodic }]).unwrap_or_default() + p.map(|pts| vec![LinkGeom::Spline { pts, control: *control, degree: *degree, periodic: *periodic, nurbs: nurbs.clone() }]) + .unwrap_or_default() } Some(CurveKind::Conic { a, b, apex, rho }) if parallel => match (sk.point(*a), sk.point(*apex), sk.point(*b)) { (Some(a), Some(x), Some(b)) => vec![LinkGeom::Conic { a: map(a), apex: map(x), b: map(b), rho: *rho }], @@ -1206,7 +1207,7 @@ fn as_spline(pts: &[Vec2], tol: f64) -> Option { <= tol }); if ok { - return Some(LinkGeom::Spline { pts: fit, control: false, degree: 3, periodic: false }); + return Some(LinkGeom::Spline { pts: fit, control: false, degree: 3, periodic: false, nurbs: None }); } } None diff --git a/crates/doc/src/project3d.rs b/crates/doc/src/project3d.rs index a12510aaf..6542c12fa 100644 --- a/crates/doc/src/project3d.rs +++ b/crates/doc/src/project3d.rs @@ -247,7 +247,9 @@ fn link_polyline(g: &solidcraft_sketch::LinkGeom) -> Vec { LinkGeom::Ellipse { c, major, minor } => { (0..=96).map(|i| solidcraft_sketch::ellipse_point(c, major, minor, i as f64 / 96.0 * std::f64::consts::TAU)).collect() } - LinkGeom::Spline { ref pts, control, degree, periodic } => solidcraft_sketch::spline_polyline_mode(pts, control, degree, periodic), + LinkGeom::Spline { ref pts, control, degree, periodic, ref nurbs } => { + solidcraft_sketch::spline_polyline_mode(pts, control, degree, periodic, nurbs.as_ref()) + } LinkGeom::Point(_) => Vec::new(), } } diff --git a/crates/doc/src/project_order.rs b/crates/doc/src/project_order.rs index 2964468c1..70b8a736d 100644 --- a/crates/doc/src/project_order.rs +++ b/crates/doc/src/project_order.rs @@ -251,7 +251,13 @@ mod tests { vec![ line(0., 1.), line(1., 2.), - LinkGeom::Spline { pts: vec![Vec2::new(1., 0.), Vec2::new(2., 1.), Vec2::new(3., 1.)], control: false, degree: 2, periodic: false }, + LinkGeom::Spline { + pts: vec![Vec2::new(1., 0.), Vec2::new(2., 1.), Vec2::new(3., 1.)], + control: false, + degree: 2, + periodic: false, + nurbs: None, + }, ], vec![line(0., 1.), LinkGeom::Arc { c: Vec2::new(1., 1.), a: Vec2::new(1., 0.), b: Vec2::new(2., 1.) }], vec![line(0., 1.), line(1.00001, 2.)], diff --git a/crates/engine/src/cmd/inspect.rs b/crates/engine/src/cmd/inspect.rs index 189e7e681..3bb5c09d9 100644 --- a/crates/engine/src/cmd/inspect.rs +++ b/crates/engine/src/cmd/inspect.rs @@ -186,7 +186,17 @@ fn sketch_json(s: &Session, world: &solidcraft_doc::ModelState, id: u64) -> Opti CurveKind::Circle { c: cc, r } => json!({"id": c.id, "type": "circle", "center": pid(cc), "center_at": sk.point(cc), "radius": r, "construction": c.construction, "fixed": sk.curve_locked(i), "fully_constrained": det}), CurveKind::Arc { c: cc, a, b } => json!({"id": c.id, "type": "arc", "center": pid(cc), "start": pid(a), "end": pid(b), "center_at": sk.point(cc), "start_at": sk.point(a), "end_at": sk.point(b), "radius": sk.radius(i), "construction": c.construction, "fixed": sk.curve_locked(i), "fully_constrained": det}), CurveKind::Ellipse { c: cc, m, r } => json!({"id": c.id, "type": "ellipse", "center": pid(cc), "major": pid(m), "center_at": sk.point(cc), "major_at": sk.point(m), "minor_radius": r, "construction": c.construction, "fixed": sk.curve_locked(i), "fully_constrained": det}), - CurveKind::Spline { ref pts, control, degree, periodic } => json!({"id": c.id, "type": "spline", "points": pts.iter().map(|q| pid(*q)).collect::>(), "points_at": pts.iter().map(|q| sk.point(*q)).collect::>(), "control": control, "degree": degree, "periodic": periodic, "construction": c.construction, "fixed": sk.curve_locked(i), "fully_constrained": det}), + CurveKind::Spline { ref pts, control, degree, periodic, ref nurbs } => { + let mut v = json!({"id": c.id, "type": "spline", "points": pts.iter().map(|q| pid(*q)).collect::>(), "points_at": pts.iter().map(|q| sk.point(*q)).collect::>(), "control": control, "degree": degree, "periodic": periodic, "construction": c.construction, "fixed": sk.curve_locked(i), "fully_constrained": det}); + // A control spline with its own knots (a projected free-form edge) says them. + if let (Some(n), Some(o)) = (nurbs, v.as_object_mut()) { + o.insert("knots".into(), json!(n.knots)); + if !n.weights.is_empty() { + o.insert("weights".into(), json!(n.weights)); + } + } + v + } CurveKind::Conic { a, b, apex, rho } => json!({"id": c.id, "type": "conic", "start": pid(a), "end": pid(b), "apex": pid(apex), "start_at": sk.point(a), "end_at": sk.point(b), "apex_at": sk.point(apex), "rho": rho, "construction": c.construction, "fixed": sk.curve_locked(i), "fully_constrained": det}), }; if let (Some(l), Some(o)) = (&c.link, v.as_object_mut()) { diff --git a/crates/engine/src/cmd/sketch_create.rs b/crates/engine/src/cmd/sketch_create.rs index 608848702..eac876942 100644 --- a/crates/engine/src/cmd/sketch_create.rs +++ b/crates/engine/src/cmd/sketch_create.rs @@ -505,7 +505,7 @@ fn blend(s: &mut Session, p: &Value) -> Result { let (sp, cons) = if order <= 1 { let c1 = sk.add_point(qa + ta * (l / 3.0), None)?; let c2 = sk.add_point(qb + tb * (l / 3.0), None)?; - let sp = sk.add_curve(CurveKind::Spline { pts: vec![pa, c1, c2, pb], control: true, degree: 3, periodic: false }, None)?; + let sp = sk.add_curve(CurveKind::Spline { pts: vec![pa, c1, c2, pb], control: true, degree: 3, periodic: false, nurbs: None }, None)?; let cons = vec![add_c(sk, ConstraintKind::Tangent { a: ca, b: sp })?, add_c(sk, ConstraintKind::Tangent { a: cb, b: sp })?]; (sp, cons) } else { @@ -527,7 +527,7 @@ fn blend(s: &mut Session, p: &Value) -> Result { }); } let degree = u8::try_from(cps.len().saturating_sub(1)).map_err(|_| bad(cmd, "the blend curve needs too many control points"))?; - let sp = sk.add_curve(CurveKind::Spline { pts, control: true, degree, periodic: false }, None)?; + let sp = sk.add_curve(CurveKind::Spline { pts, control: true, degree, periodic: false, nurbs: None }, None)?; (sp, Vec::new()) }; solve_new_only(sk, first_new); @@ -655,7 +655,7 @@ fn spline(s: &mut Session, p: &Value, cmd: &str, control: bool, degree: u8) -> R { pts.push(*pts.first().ok_or_else(|| bad(cmd, "missing first point"))?); } - let c = sk.add_curve(CurveKind::Spline { pts, control, degree, periodic }, None)?; + let c = sk.add_curve(CurveKind::Spline { pts, control, degree, periodic, nurbs: None }, None)?; mark_construction(sk, &[c], p); Ok((ids_of(sk, &[c]), Vec::new())) })?; @@ -1344,13 +1344,13 @@ mod blend_tests { let mut broken = solidcraft_sketch::Sketch::new(); let p0 = broken.add_point(Vec2::new(1.0, 1.0), None).unwrap(); let p1 = broken.add_point(Vec2::ZERO, None).unwrap(); - let l = broken.add_curve(CurveKind::Spline { pts: vec![p1, p0], control: true, degree: 1, periodic: false }, None).unwrap(); + let l = broken.add_curve(CurveKind::Spline { pts: vec![p1, p0], control: true, degree: 1, periodic: false, nurbs: None }, None).unwrap(); broken.points[p0].pos = Vec2::new(f64::NAN, 4.0); assert!(super::joint_derivatives(&broken, l, p1, 2, true, "a", "sketch.blend_curve").is_err(), "non-finite geometry"); let mut flat = solidcraft_sketch::Sketch::new(); let q0 = flat.add_point(Vec2::new(3.0, 3.0), None).unwrap(); let q1 = flat.add_point(Vec2::new(3.0, 3.0), None).unwrap(); - let d = flat.add_curve(CurveKind::Spline { pts: vec![q0, q1], control: true, degree: 1, periodic: false }, None).unwrap(); + let d = flat.add_curve(CurveKind::Spline { pts: vec![q0, q1], control: true, degree: 1, periodic: false, nurbs: None }, None).unwrap(); let e = super::joint_derivatives(&flat, d, q0, 2, true, "a", "sketch.blend_curve").unwrap_err().to_string(); assert!(e.contains("no tangent"), "{e}"); assert!(solidcraft_geom::hermite_bezier(Vec2::ZERO, Vec2::X, &[Vec2::Y; 5], &[Vec2::Y; 5]).is_none(), "no order above g4"); diff --git a/crates/engine/src/cmd/sketch_freeform.rs b/crates/engine/src/cmd/sketch_freeform.rs index 6d8763a33..ceda14e56 100644 --- a/crates/engine/src/cmd/sketch_freeform.rs +++ b/crates/engine/src/cmd/sketch_freeform.rs @@ -156,7 +156,7 @@ fn add_pieces(sk: &mut Sketch, segs: &[Seg2], start: Option, end: Option< Seg2::Line { .. } => CurveKind::Line { a: prev, b: to }, Seg2::Cubic { p1, p2, .. } => { let (c1, c2) = (sk.add_point(p1, None)?, sk.add_point(p2, None)?); - CurveKind::Spline { pts: vec![prev, c1, c2, to], control: true, degree: 3, periodic: false } + CurveKind::Spline { pts: vec![prev, c1, c2, to], control: true, degree: 3, periodic: false, nurbs: None } } Seg2::Conic { apex, w, .. } => { let x = sk.add_point(apex, None)?; @@ -169,7 +169,7 @@ fn add_pieces(sk: &mut Sketch, segs: &[Seg2], start: Option, end: Option< pts.push(sk.add_point(*q, None)?); } pts.push(to); - CurveKind::Spline { pts, control: true, degree: n, periodic: false } + CurveKind::Spline { pts, control: true, degree: n, periodic: false, nurbs: None } } Seg2::Arc { .. } => return Err(bad("trim", "unexpected arc piece")), }; diff --git a/crates/engine/src/cmd/sketch_import.rs b/crates/engine/src/cmd/sketch_import.rs index c7efde07a..d9d3e9c50 100644 --- a/crates/engine/src/cmd/sketch_import.rs +++ b/crates/engine/src/cmd/sketch_import.rs @@ -101,7 +101,7 @@ pub(super) fn add_geometry(sk: &mut Sketch, geom: &[Geom2], f: &dyn Fn(Vec2) -> idx.push(i); } } - (idx.len() >= 2).then_some(CurveKind::Spline { pts: idx, control: *control, degree: *degree, periodic: false }) + (idx.len() >= 2).then_some(CurveKind::Spline { pts: idx, control: *control, degree: *degree, periodic: false, nurbs: None }) } Geom2::Conic { a, apex, b, rho } => { let (a, x, b) = (pt(sk, *a)?, pt(sk, *apex)?, pt(sk, *b)?); diff --git a/crates/engine/src/cmd/sketch_modify.rs b/crates/engine/src/cmd/sketch_modify.rs index 482b1cce9..f42a9959c 100644 --- a/crates/engine/src/cmd/sketch_modify.rs +++ b/crates/engine/src/cmd/sketch_modify.rs @@ -1764,7 +1764,7 @@ fn offset_side(sk: &mut Sketch, cmd: &str, order: &[(usize, bool)], sources: &[( idx.push(pb); idx.dedup(); if idx.len() >= 2 { - made.push(sk.add_curve(CurveKind::Spline { pts: idx, control: false, degree: 3, periodic: false }, None)?); + made.push(sk.add_curve(CurveKind::Spline { pts: idx, control: false, degree: 3, periodic: false, nurbs: None }, None)?); } } Piece::Line(..) => { diff --git a/crates/sketch/src/curves.rs b/crates/sketch/src/curves.rs index 66a7fb272..e35bc0711 100644 --- a/crates/sketch/src/curves.rs +++ b/crates/sketch/src/curves.rs @@ -190,7 +190,12 @@ pub fn fit_beziers(p: &[Vec2]) -> Vec<[Vec2; 4]> { pub fn fit_beziers_mode(p: &[Vec2], periodic: bool) -> crate::model::Result> { if periodic { crate::periodic_beziers(p) } else { Ok(fit_beziers(p)) } } -pub fn spline_point_mode(p: &[Vec2], control: bool, degree: u8, periodic: bool, t: f64) -> Vec2 { +/// Point of a spline at `t` in [0, 1]: through its points, over them as a clamped uniform +/// B-spline, or with its own knots and weights (`nurbs`). +pub fn spline_point_mode(p: &[Vec2], control: bool, degree: u8, periodic: bool, nurbs: Option<&crate::Nurbs>, t: f64) -> Vec2 { + if let Some(nurbs) = nurbs { + return nurbs.point(p, degree, t).unwrap_or_else(|| p.first().copied().unwrap_or_default()); + } if !periodic { return spline_point(p, control, degree, t); } @@ -211,7 +216,11 @@ pub fn spline_point_mode(p: &[Vec2], control: bool, degree: u8, periodic: bool, let t = (remaining / lengths[i]).clamp(0.0, 1.0); a * (1.0 - t).powi(3) + b * (3.0 * t * (1.0 - t).powi(2)) + c * (3.0 * t * t * (1.0 - t)) + d * t.powi(3) } -pub fn spline_polyline_mode(p: &[Vec2], control: bool, degree: u8, periodic: bool) -> Vec { +/// Polyline of a spline, as [`spline_point_mode`] reads it. +pub fn spline_polyline_mode(p: &[Vec2], control: bool, degree: u8, periodic: bool, nurbs: Option<&crate::Nurbs>) -> Vec { + if let Some(nurbs) = nurbs { + return nurbs.polyline(p, degree); + } if !periodic { return spline_polyline(p, control, degree); } @@ -307,6 +316,7 @@ pub fn spline_polyline(p: &[Vec2], control: bool, degree: u8) -> Vec { } /// Unit tangent of a spline at its start (`at_end == false`) or end, pointing along the curve. +/// A control spline's runs along its end leg whatever its knots and (positive) weights. pub fn spline_end_tangent(p: &[Vec2], control: bool, at_end: bool) -> Option { let n = p.len(); if n < 2 { diff --git a/crates/sketch/src/freeform_offset.rs b/crates/sketch/src/freeform_offset.rs index fde3254ae..68bf0d8e6 100644 --- a/crates/sketch/src/freeform_offset.rs +++ b/crates/sketch/src/freeform_offset.rs @@ -439,7 +439,7 @@ impl Sketch { } let output = self.curve_index(&record.output).ok_or_else(|| bad("offset output vanished"))?; match &self.curves[output].kind { - CurveKind::Spline { pts, control: false, degree: 3, periodic } + CurveKind::Spline { pts, control: false, degree: 3, periodic, .. } if *periodic == (record.certificate == 2) && (record.certificate != 2 || record.closed) && pts.len() == record.pieces * record.divisions + 1 @@ -484,7 +484,7 @@ impl Sketch { p.fixed = true; } } - let output = candidate.add_curve(CurveKind::Spline { pts: indices, control: false, degree: 3, periodic: closed }, None)?; + let output = candidate.add_curve(CurveKind::Spline { pts: indices, control: false, degree: 3, periodic: closed, nurbs: None }, None)?; candidate.freeform_offsets.push(FreeformOffset { source: source_id, output: candidate.curves[output].id.clone(), @@ -551,7 +551,7 @@ impl Sketch { return Err(bad("offset source topology changed")); } let old_indices = match &candidate.curves[output].kind { - CurveKind::Spline { pts, control: false, degree: 3, periodic } + CurveKind::Spline { pts, control: false, degree: 3, periodic, .. } if *periodic == (record.certificate == 2) && (record.certificate != 2 || record.closed) && pts.len() == record.pieces * record.divisions + 1 => @@ -583,7 +583,8 @@ impl Sketch { p.pos = pos; p.fixed = true; } - candidate.curves[output].kind = CurveKind::Spline { pts: indices, control: false, degree: 3, periodic: record.certificate == 2 }; + candidate.curves[output].kind = + CurveKind::Spline { pts: indices, control: false, degree: 3, periodic: record.certificate == 2, nurbs: None }; candidate.freeform_offsets[record_index].divisions = divisions; candidate.freeform_offsets[record_index].pieces = pieces; } @@ -632,7 +633,7 @@ mod tests { .into_iter() .map(|(x, y)| sk.add_point(Vec2::new(x, y), None).unwrap()) .collect(); - let source = sk.add_curve(CurveKind::Spline { pts, control: false, degree: 3, periodic: true }, None).unwrap(); + let source = sk.add_curve(CurveKind::Spline { pts, control: false, degree: 3, periodic: true, nurbs: None }, None).unwrap(); let original = sk.clone(); for (forward, distance) in [(true, 2.0), (false, -2.0)] { let mut sk = original.clone(); diff --git a/crates/sketch/src/freeform_offset/trim.rs b/crates/sketch/src/freeform_offset/trim.rs index 380f7ec71..070e3b60d 100644 --- a/crates/sketch/src/freeform_offset/trim.rs +++ b/crates/sketch/src/freeform_offset/trim.rs @@ -1080,7 +1080,7 @@ impl Sketch { pts.push(candidate.add_point(*p, None)?); } pts.push(end); - CurveKind::Spline { pts, control: false, degree: 3, periodic: false } + CurveKind::Spline { pts, control: false, degree: 3, periodic: false, nurbs: None } } Out::Arc { center, sweep, .. } => { let c = candidate.add_point(*center, None)?; @@ -1111,7 +1111,7 @@ mod tests { fn spline(coords: &[(f64, f64)], periodic: bool) -> (Sketch, usize) { let mut sk = Sketch::new(); let pts = coords.iter().map(|(x, y)| sk.add_point(Vec2::new(*x, *y), None).unwrap()).collect(); - let source = sk.add_curve(CurveKind::Spline { pts, control: false, degree: 3, periodic }, None).unwrap(); + let source = sk.add_curve(CurveKind::Spline { pts, control: false, degree: 3, periodic, nurbs: None }, None).unwrap(); (sk, source) } @@ -1210,8 +1210,9 @@ mod tests { for (k, b) in beziers.iter().enumerate() { let mid = [1, 2].map(|i| sk.add_point(Vec2::new(b[i].0, b[i].1), None).unwrap()); let end = if k + 1 == beziers.len() { first } else { sk.add_point(Vec2::new(b[3].0, b[3].1), None).unwrap() }; - let c = - sk.add_curve(CurveKind::Spline { pts: vec![start, mid[0], mid[1], end], control: true, degree: 3, periodic: false }, None).unwrap(); + let c = sk + .add_curve(CurveKind::Spline { pts: vec![start, mid[0], mid[1], end], control: true, degree: 3, periodic: false, nurbs: None }, None) + .unwrap(); order.push((c, true)); start = end; } diff --git a/crates/sketch/src/lib.rs b/crates/sketch/src/lib.rs index 91d2ec79c..ca01480a8 100644 --- a/crates/sketch/src/lib.rs +++ b/crates/sketch/src/lib.rs @@ -27,6 +27,7 @@ pub mod linalg; mod link; mod loci; mod model; +mod nurbs; mod offset; mod offset_topology; mod pattern; @@ -55,6 +56,7 @@ pub use model::{ Constraint, ConstraintKind, Curve, CurveKind, MAX_CONSTRAINTS, MAX_COORD, MAX_CURVES, MAX_POINTS, PointExprs, SPoint, Sketch, SketchError, SketchView, TwoCircles, }; +pub use nurbs::Nurbs; pub use offset::OffsetChain; pub use offset_topology::{OffsetCreated, OffsetRole, OffsetRoleFlags, OffsetRoleKind, OffsetTopology}; pub use pattern::{PatternAlignment, PatternInstance, SketchPattern, SketchPatternKind}; diff --git a/crates/sketch/src/link.rs b/crates/sketch/src/link.rs index ca5a57626..d8b49172a 100644 --- a/crates/sketch/src/link.rs +++ b/crates/sketch/src/link.rs @@ -238,12 +238,14 @@ pub enum LinkGeom { major: Vec2, minor: f64, }, - /// Spline through (`control == false`) or over (`control`) the points. + /// Spline through (`control == false`) or over (`control`) the points; a control spline + /// with its own knots and weights where it has them ([`crate::Nurbs`]). Spline { pts: Vec, control: bool, degree: u8, periodic: bool, + nurbs: Option, }, } @@ -257,8 +259,9 @@ impl LinkGeom { LinkGeom::Arc { c, a, b } => ok(c) && ok(a) && ok(b) && c.dist(*a) > 1e-9 && a.dist(*b) > MERGE_TOL, LinkGeom::Conic { a, apex, b, rho } => ok(a) && ok(apex) && ok(b) && a.dist(*b) > MERGE_TOL && *rho > 1e-6 && *rho < 1.0 - 1e-6, LinkGeom::Ellipse { c, major, minor } => ok(c) && ok(major) && c.dist(*major) > 1e-9 && radius_in_range(*minor), - LinkGeom::Spline { pts, control, degree, periodic } => { + LinkGeom::Spline { pts, control, degree, periodic, nurbs } => { (!*periodic || (!*control && *degree == 3 && crate::periodic_beziers(pts).is_ok())) + && nurbs.as_ref().is_none_or(|k| *control && !*periodic && k.check(pts.len(), *degree).is_ok()) && (2..=crate::curves::MAX_SPLINE_POINTS).contains(&pts.len()) && pts.iter().all(ok) && (1..=solidcraft_geom::MAX_BEZIER_DEGREE as u8).contains(degree) @@ -275,7 +278,7 @@ struct Layout { curves: Vec, } -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq)] enum LCurve { Line(usize, usize), Circle(usize, f64), @@ -283,8 +286,8 @@ enum LCurve { Conic(usize, usize, usize, f64), Ellipse(usize, usize, f64), /// Start, end, first interior point and interior count (interior points are consecutive - /// and never shared), control flag, degree. - Spline(usize, usize, usize, usize, bool, u8, bool), + /// and never shared), control flag, degree, periodic, own knots and weights. + Spline(usize, usize, usize, usize, bool, u8, bool, Option), } fn layout(geom: &[LinkGeom]) -> Result { @@ -339,14 +342,14 @@ fn layout(geom: &[LinkGeom]) -> Result { l.curves.push(LCurve::Ellipse(c, m, minor)); } } - LinkGeom::Spline { pts, control, degree, periodic } => { + LinkGeom::Spline { pts, control, degree, periodic, nurbs } => { let (Some(first), Some(last)) = (pts.first(), pts.last()) else { continue }; let s0 = pt(&mut l.pts, *first); let first_in = l.pts.len(); let inner = pts.get(1..pts.len() - 1).unwrap_or_default(); l.pts.extend(inner.iter().copied()); let s1 = pt(&mut l.pts, *last); - l.curves.push(LCurve::Spline(s0, s1, first_in, inner.len(), control, degree, periodic)); + l.curves.push(LCurve::Spline(s0, s1, first_in, inner.len(), control, degree, periodic, nurbs)); } } } @@ -402,6 +405,16 @@ fn same_shape(a: &LCurve, b: &LCurve) -> bool { ) } +/// Whether two splines' own knots and weights ([`crate::Nurbs`]) are the same within `close`. +fn same_nurbs(a: Option<&crate::Nurbs>, b: Option<&crate::Nurbs>, close: impl Fn(f64, f64) -> bool) -> bool { + let all = |x: &[f64], y: &[f64]| x.len() == y.len() && x.iter().zip(y).all(|(p, q)| close(*p, *q)); + match (a, b) { + (None, None) => true, + (Some(a), Some(b)) => all(&a.knots, &b.knots) && all(&a.weights, &b.weights), + _ => false, + } +} + /// Do two curve sets describe the same geometry, regardless of the order the curves come in or /// the direction a loop was walked? Lines match with either end first; circles by centre and /// radius; arcs by centre and their (start, end) pair; conics by all their points and rho. @@ -422,7 +435,9 @@ fn same_geometry(a: &[(LCurve, Vec)], b: &[(LCurve, Vec)]) -> bool { (LCurve::Arc(..), LCurve::Arc(..)) => all(), (LCurve::Conic(.., ra), LCurve::Conic(.., rb)) => all() && close(*ra, *rb), (LCurve::Ellipse(.., ra), LCurve::Ellipse(.., rb)) => all() && close(*ra, *rb), - (LCurve::Spline(.., ca, da, pa), LCurve::Spline(.., cb, db, pb)) => ca == cb && da == db && pa == pb && all(), + (LCurve::Spline(.., ca, da, pa, ka), LCurve::Spline(.., cb, db, pb, kb)) => { + ca == cb && da == db && pa == pb && same_nurbs(ka.as_ref(), kb.as_ref(), close) && all() + } _ => false, } }; @@ -666,10 +681,10 @@ impl Sketch { let at = |i: usize| self.points.get(i).map(|p| p.pos); let near = |i: usize, q: Option| lay.pts.get(i).zip(q).is_some_and(|(p, q)| p.dist(q) <= MERGE_TOL); let curve_present = |c: &LCurve| { - self.curves.iter().filter(|k| k.link.is_some()).any(|k| match (*c, &k.kind) { - (LCurve::Line(a, b), CurveKind::Line { a: p, b: q }) => (near(a, at(*p)) && near(b, at(*q))) || (near(a, at(*q)) && near(b, at(*p))), - (LCurve::Circle(c, r), CurveKind::Circle { c: p, r: s }) => near(c, at(*p)) && (r - s).abs() <= MERGE_TOL, - (LCurve::Arc(c, a, b), CurveKind::Arc { c: p, a: q, b: e }) => near(c, at(*p)) && near(a, at(*q)) && near(b, at(*e)), + self.curves.iter().filter(|k| k.link.is_some()).any(|k| match (c, &k.kind) { + (&LCurve::Line(a, b), CurveKind::Line { a: p, b: q }) => (near(a, at(*p)) && near(b, at(*q))) || (near(a, at(*q)) && near(b, at(*p))), + (&LCurve::Circle(c, r), CurveKind::Circle { c: p, r: s }) => near(c, at(*p)) && (r - s).abs() <= MERGE_TOL, + (&LCurve::Arc(c, a, b), CurveKind::Arc { c: p, a: q, b: e }) => near(c, at(*p)) && near(a, at(*q)) && near(b, at(*e)), _ => false, }) }; @@ -716,13 +731,13 @@ impl Sketch { LCurve::Arc(c, a, b) => (CurveKind::Arc { c: point(self, c)?, a: point(self, a)?, b: point(self, b)? }, "a"), LCurve::Conic(a, b, x, rho) => (CurveKind::Conic { a: point(self, a)?, b: point(self, b)?, apex: point(self, x)?, rho }, "k"), LCurve::Ellipse(c, m, r) => (CurveKind::Ellipse { c: point(self, c)?, m: point(self, m)?, r }, "e"), - LCurve::Spline(a, b, f, n, control, degree, periodic) => { + LCurve::Spline(a, b, f, n, control, degree, periodic, ref nurbs) => { let mut pts = vec![point(self, a)?]; for i in f..f + n { pts.push(point(self, i)?); } pts.push(point(self, b)?); - (CurveKind::Spline { pts, control, degree, periodic }, "s") + (CurveKind::Spline { pts, control, degree, periodic, nurbs: nurbs.clone() }, "s") } }; let cid = self.fresh(prefix)?; @@ -775,7 +790,7 @@ impl Sketch { Some(CurveKind::Arc { c, a, b }) => Some(LCurve::Arc(local(*c)?, local(*a)?, local(*b)?)), Some(CurveKind::Conic { a, b, apex, rho }) => Some(LCurve::Conic(local(*a)?, local(*b)?, local(*apex)?, *rho)), Some(CurveKind::Ellipse { c, m, r }) => Some(LCurve::Ellipse(local(*c)?, local(*m)?, *r)), - Some(CurveKind::Spline { pts, control, degree, periodic }) => { + Some(CurveKind::Spline { pts, control, degree, periodic, nurbs }) => { let (a, b) = (local(*pts.first()?)?, local(*pts.last()?)?); let inner: Vec = pts.get(1..pts.len().saturating_sub(1)).unwrap_or_default().iter().map(|q| local(*q)).collect::>()?; @@ -784,7 +799,7 @@ impl Sketch { if inner.iter().enumerate().any(|(k, x)| *x != f + k) { return None; } - Some(LCurve::Spline(a, b, f, inner.len(), *control, *degree, *periodic)) + Some(LCurve::Spline(a, b, f, inner.len(), *control, *degree, *periodic, nurbs.clone())) } _ => None, }) @@ -840,7 +855,7 @@ impl Sketch { LCurve::Arc(c, a, b) => LCurve::Arc(renum(c), renum(a), renum(b)), LCurve::Conic(a, b, x, r) => LCurve::Conic(renum(a), renum(b), renum(x), r), LCurve::Ellipse(c, m, r) => LCurve::Ellipse(renum(c), renum(m), r), - LCurve::Spline(a, b, f, n, ct, d, periodic) => LCurve::Spline(renum(a), renum(b), renum(f), n, ct, d, periodic), + LCurve::Spline(a, b, f, n, ct, d, periodic, ref k) => LCurve::Spline(renum(a), renum(b), renum(f), n, ct, d, periodic, k.clone()), }) .collect(); let same = match &cur { @@ -855,8 +870,15 @@ impl Sketch { (LCurve::Arc(a0, a1, a2), LCurve::Arc(b0, b1, b2)) => a0 == b0 && a1 == b1 && a2 == b2, (LCurve::Conic(a0, a1, a2, _), LCurve::Conic(b0, b1, b2, _)) => a0 == b0 && a1 == b1 && a2 == b2, (LCurve::Ellipse(a0, a1, _), LCurve::Ellipse(b0, b1, _)) => a0 == b0 && a1 == b1, - (LCurve::Spline(a0, a1, a2, a3, a4, a5, a6), LCurve::Spline(b0, b1, b2, b3, b4, b5, b6)) => { - a0 == b0 && a1 == b1 && (a2 == b2 || *a3 == 0) && a3 == b3 && a4 == b4 && a5 == b5 && a6 == b6 + (LCurve::Spline(a0, a1, a2, a3, a4, a5, a6, a7), LCurve::Spline(b0, b1, b2, b3, b4, b5, b6, b7)) => { + a0 == b0 + && a1 == b1 + && (a2 == b2 || *a3 == 0) + && a3 == b3 + && a4 == b4 + && a5 == b5 + && a6 == b6 + && a7.is_some() == b7.is_some() } _ => false, } @@ -873,12 +895,14 @@ impl Sketch { let pos = |pi: usize| self.points.get(pi).map(|p| p.pos); let old: Option)>> = cur .iter() - .map(|c| curve_points(c).into_iter().map(|li| points.get(li).and_then(|pi| pos(*pi))).collect::>>().map(|ps| (*c, ps))) + .map(|c| { + curve_points(c).into_iter().map(|li| points.get(li).and_then(|pi| pos(*pi))).collect::>>().map(|ps| (c.clone(), ps)) + }) .collect(); let fresh: Option)>> = lay .curves .iter() - .map(|c| curve_points(c).into_iter().map(|li| lay.pts.get(li).copied()).collect::>>().map(|ps| (*c, ps))) + .map(|c| curve_points(c).into_iter().map(|li| lay.pts.get(li).copied()).collect::>>().map(|ps| (c.clone(), ps))) .collect(); let lone_old: Vec = points.iter().filter_map(|pi| pos(*pi)).collect(); if let (Some(old), Some(fresh)) = (old, fresh) @@ -1028,6 +1052,11 @@ impl Sketch { { *r = *value; } + if let (Some(Curve { kind: CurveKind::Spline { nurbs, .. }, .. }), Some(LCurve::Spline(.., value))) = + (self.curves.get_mut(*ci), lay.curves.get(li)) + { + nurbs.clone_from(value); + } } return Ok(false); } @@ -1056,6 +1085,9 @@ impl Sketch { if let (LCurve::Ellipse(.., r), Some(Curve { kind: CurveKind::Ellipse { r: slot, .. }, .. })) = (c, self.curves.get_mut(*ci)) { *slot = *r; } + if let (LCurve::Spline(.., k), Some(Curve { kind: CurveKind::Spline { nurbs, .. }, .. })) = (c, self.curves.get_mut(*ci)) { + nurbs.clone_from(k); + } } return Ok(false); } diff --git a/crates/sketch/src/model.rs b/crates/sketch/src/model.rs index 29190e515..15a9c402b 100644 --- a/crates/sketch/src/model.rs +++ b/crates/sketch/src/model.rs @@ -104,6 +104,10 @@ pub enum CurveKind { /// Explicit cyclic C2 fit interpolation; absent retains natural endpoints. #[serde(default, skip_serializing_if = "std::ops::Not::not")] periodic: bool, + /// A control spline's own knots and weights (a projected free-form edge as the exact + /// curve it is); none: the clamped uniform B-spline over its points, all weights 1. + #[serde(default, skip_serializing_if = "Option::is_none")] + nurbs: Option, }, /// Conic from `a` to `b` shaped by the `apex` point and `rho` in (0, 1) (0.5 parabola, /// less elliptical, more hyperbolic). @@ -1463,8 +1467,9 @@ impl Sketch { } /// Exact boundary segments of a free-form curve: ellipses as four conics, conics, fit - /// splines and control splines up to `MAX_BEZIER_DEGREE` as Béziers. None for other curves - /// (and for higher-degree splines, which stay polylines). + /// splines and control splines up to `MAX_BEZIER_DEGREE` as Béziers (one a knot span for a + /// spline with its own knots, conics for a rational quadratic one). None for other curves + /// (and for higher-degree or other rational splines, which stay polylines). pub fn exact_segs(&self, ci: usize) -> Option> { let cu = self.curves.get(ci)?; let pt = |i: &usize| self.point(*i); @@ -1491,7 +1496,11 @@ impl Sketch { crate::curves::fit_beziers_mode(&p, *periodic).ok()?.into_iter().map(|[p0, p1, p2, p3]| Seg2::Cubic { p0, p1, p2, p3 }).collect(), ) } - CurveKind::Spline { pts, control: true, degree, .. } if (*degree as usize) <= solidcraft_geom::MAX_BEZIER_DEGREE => { + CurveKind::Spline { pts, control: true, degree, nurbs: Some(nurbs), .. } => { + let p: Vec = pts.iter().map(pt).collect::>()?; + nurbs.segs(&p, *degree) + } + CurveKind::Spline { pts, control: true, degree, nurbs: None, .. } if (*degree as usize) <= solidcraft_geom::MAX_BEZIER_DEGREE => { let p: Vec = pts.iter().map(pt).collect::>()?; let k = (*degree as usize).min(p.len().saturating_sub(1)).max(1); Some(crate::curves::bspline_beziers(&p, k).iter().filter_map(|c| solidcraft_geom::bezier(c)).collect()) @@ -1521,9 +1530,9 @@ impl Sketch { (Some(c), Some(m)) => crate::curves::ellipse_polyline(c, m, *r), _ => Vec::new(), }, - CurveKind::Spline { pts, control, degree, periodic } => { + CurveKind::Spline { pts, control, degree, periodic, nurbs } => { let p: Option> = pts.iter().map(pt).collect(); - p.map(|p| crate::curves::spline_polyline_mode(&p, *control, *degree, *periodic)).unwrap_or_default() + p.map(|p| crate::curves::spline_polyline_mode(&p, *control, *degree, *periodic, nurbs.as_ref())).unwrap_or_default() } CurveKind::Conic { a, b, apex, rho } => match (pt(a), pt(apex), pt(b)) { (Some(a), Some(x), Some(b)) => crate::curves::conic_polyline(a, x, b, *rho), @@ -1559,7 +1568,13 @@ impl Sketch { } "e" } - CurveKind::Spline { pts, control, degree, periodic } => { + CurveKind::Spline { pts, control, degree, periodic, nurbs } => { + if let Some(nurbs) = nurbs { + if !*control || *periodic { + return Err(SketchError::Invalid("only an open control spline has its own knots".into())); + } + nurbs.check(pts.len(), *degree)?; + } if pts.len() < 2 || pts.len() > crate::curves::MAX_SPLINE_POINTS || !(1..=solidcraft_geom::MAX_BEZIER_DEGREE as u8).contains(degree) { return Err(SketchError::Invalid(format!( "a spline needs 2 to 500 points and degree 1 to {}", diff --git a/crates/sketch/src/nurbs.rs b/crates/sketch/src/nurbs.rs new file mode 100644 index 000000000..a3eae6511 --- /dev/null +++ b/crates/sketch/src/nurbs.rs @@ -0,0 +1,200 @@ +//! A control spline's own knots and weights ([`Nurbs`]): the exact form of a free-form edge a +//! sketch projects, whose knots need not be evenly spaced and whose weights need not be 1. A +//! control spline without them is the clamped uniform B-spline over its points. + +use serde::{Deserialize, Serialize}; +use solidcraft_geom::bspline::{self, HPoint}; +use solidcraft_geom::{Seg2, Vec2, Vec3}; + +use crate::model::{Result, SketchError}; + +/// Most knots a spline may have (its points are capped at [`crate::MAX_SPLINE_POINTS`]). +const MAX_KNOTS: usize = crate::curves::MAX_SPLINE_POINTS + solidcraft_geom::MAX_BEZIER_DEGREE + 1; +/// Most a weight may exceed another by: past it the curve is all but its heaviest points. +const MAX_WEIGHT_RATIO: f64 = 1e12; +/// Polyline samples per knot span. +const SPAN_SAMPLES: usize = 24; + +/// The knot vector and weights of a control spline of `degree` over `n` points: clamped (each +/// end knot `degree + 1` times, no interior knot more than `degree` times), `n + degree + 1` +/// non-decreasing knots, and one positive weight per point (none: all 1). +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct Nurbs { + pub knots: Vec, + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub weights: Vec, +} + +fn bad(why: &str) -> Result { + Err(SketchError::Invalid(format!("spline knots: {why}"))) +} + +impl Nurbs { + /// Whether these knots and weights fit a control spline of `degree` over `n` points. + pub fn check(&self, n: usize, degree: u8) -> Result<()> { + let d = usize::from(degree); + if !(1..=solidcraft_geom::MAX_BEZIER_DEGREE).contains(&d) || n <= d || n > crate::curves::MAX_SPLINE_POINTS { + return bad("a knotted spline needs more points than its degree, 1 to 9"); + } + let k = &self.knots; + if k.len() != n + d + 1 || k.len() > MAX_KNOTS { + return bad("a spline needs its point count plus its degree plus one knots"); + } + if k.iter().any(|x| !x.is_finite()) || k.windows(2).any(|w| w[1] < w[0]) { + return bad("knots must be finite and never decrease"); + } + let (lo, hi) = (k[d], k[n]); + let span = hi - lo; + if !(span > 0.0 && span.is_finite()) || k[..=d].iter().any(|x| *x != lo) || k[n..].iter().any(|x| *x != hi) { + return bad("the knots must be clamped at both ends"); + } + let mut run = 0usize; + for (i, x) in k.iter().enumerate().take(n).skip(d + 1) { + run = if k.get(i - 1) == Some(x) { run + 1 } else { 1 }; + if *x == lo || *x == hi || run > d { + return bad("no knot inside the spline may repeat more than its degree"); + } + } + if !self.weights.is_empty() { + if self.weights.len() != n || self.weights.iter().any(|w| !(w.is_finite() && *w > 0.0)) { + return bad("a rational spline needs one positive weight per point"); + } + let (min, max) = self.weights.iter().fold((f64::INFINITY, 0.0f64), |(a, b), w| (a.min(*w), b.max(*w))); + if max / min > MAX_WEIGHT_RATIO { + return bad("the weights differ too much"); + } + } + Ok(()) + } + + fn weight(&self, i: usize) -> f64 { + self.weights.get(i).copied().unwrap_or(1.0) + } + + /// The control points `p` with their weights, homogeneous. + fn homogeneous(&self, p: &[Vec2]) -> Vec { + p.iter().enumerate().map(|(i, q)| HPoint::weighted(Vec3::new(q.x, q.y, 0.0), self.weight(i))).collect() + } + + /// The knot domain `[lo, hi]` for `n` points of `degree`. + fn domain(&self, n: usize, degree: usize) -> Option<(f64, f64)> { + Some((*self.knots.get(degree)?, *self.knots.get(n)?)) + } + + /// The same curve run the other way: the knots mirrored, the weights reversed (the points + /// reverse with them). + pub fn reversed(&self) -> Nurbs { + let sum = self.knots.first().copied().unwrap_or(0.0) + self.knots.last().copied().unwrap_or(0.0); + Nurbs { knots: self.knots.iter().rev().map(|k| sum - k).collect(), weights: self.weights.iter().rev().copied().collect() } + } + + /// The point of the spline over `p` (of `degree`) at `t` in [0, 1] across its knot domain. + /// `None` when the knots don't fit the points. + pub fn point(&self, p: &[Vec2], degree: u8, t: f64) -> Option { + self.check(p.len(), degree).ok()?; + let d = usize::from(degree); + let (lo, hi) = self.domain(p.len(), d)?; + self.eval(&self.homogeneous(p), d, lo + (hi - lo) * t.clamp(0.0, 1.0)) + } + + /// The point at knot parameter `u` of the spline of degree `d` over the homogeneous points + /// `h` (de Boor), the knots already checked. + fn eval(&self, h: &[HPoint], d: usize, u: f64) -> Option { + let k = &self.knots; + let n = h.len(); + // The span holding u: the last knot ≤ u that starts a non-empty span. + let mut s = d; + while s + 1 < n && k.get(s + 1).is_some_and(|x| *x <= u) { + s += 1; + } + let mut c: Vec = h.get(s - d..=s)?.to_vec(); + for r in 1..=d { + for j in (r..=d).rev() { + let i = s + j - d; + let (a, b) = (k.get(i).copied()?, k.get(i + d + 1 - r).copied()?); + let alpha = if b > a { (u - a) / (b - a) } else { 0.0 }; + c[j] = c[j - 1] * (1.0 - alpha) + c[j] * alpha; + } + } + let q = c.get(d)?.project()?; + Some(Vec2::new(q.x, q.y)) + } + + /// The Bézier spans of the spline over `p`, homogeneous, in parameter order: every + /// interior knot inserted until it repeats `degree` times (Boehm). Exact up to rounding. + fn spans(&self, p: &[Vec2], degree: u8) -> Option>> { + self.check(p.len(), degree).ok()?; + let d = usize::from(degree); + let (mut k, mut c) = (self.knots.clone(), self.homogeneous(p)); + let (lo, hi) = self.domain(p.len(), d)?; + let mut interior: Vec = self.knots.iter().copied().filter(|x| *x > lo && *x < hi).collect(); + interior.dedup(); + for u in interior { + while k.iter().filter(|x| **x == u).count() < d { + (k, c) = bspline::insert_knot(d, &k, &c, u).ok()?; + } + } + let mut spans = Vec::new(); + for i in d..c.len() { + if k.get(i)? < k.get(i + 1)? { + spans.push(c.get(i - d..=i)?.to_vec()); + } + } + Some(spans) + } + + /// The spline over `p` as its exact [`Seg2`] pieces, one a knot span: Béziers, or conics + /// for a rational quadratic. `None` for other rational splines, which have no such pieces. + pub fn segs(&self, p: &[Vec2], degree: u8) -> Option> { + let spans = self.spans(p, degree)?; + let rational = self.weights.windows(2).any(|w| w[0] != w[1]); + let flat = |q: &HPoint| q.project().map(|v| Vec2::new(v.x, v.y)); + spans + .iter() + .map(|span| { + let pts: Vec = span.iter().map(flat).collect::>()?; + match (rational, pts.as_slice()) { + (false, _) => solidcraft_geom::bezier(&pts), + (true, [a, apex, b]) => { + let w = span.get(1)?.w / (span.first()?.w * span.get(2)?.w).sqrt(); + (w.is_finite() && w > 0.0).then_some(Seg2::Conic { a: *a, apex: *apex, b: *b, w }) + } + _ => None, + } + }) + .collect() + } + + /// The spline over `p`, sampled evenly within each knot span. + pub fn polyline(&self, p: &[Vec2], degree: u8) -> Vec { + let d = usize::from(degree); + let Some((lo, hi)) = self.check(p.len(), degree).ok().and_then(|()| self.domain(p.len(), d)) else { return Vec::new() }; + let mut breaks: Vec = self.knots.iter().copied().filter(|x| *x >= lo && *x <= hi).collect(); + breaks.dedup(); + let h = self.homogeneous(p); + let mut out = Vec::with_capacity(breaks.len() * SPAN_SAMPLES + 1); + for w in breaks.windows(2) { + for i in 0..SPAN_SAMPLES { + out.extend(self.eval(&h, d, w[0] + (w[1] - w[0]) * i as f64 / SPAN_SAMPLES as f64)); + } + } + out.extend(self.eval(&h, d, hi)); + out + } +} + +impl crate::Sketch { + /// Every spline's own knots and weights fit it: on an open control spline, the right count, + /// clamped, with positive weights (a loaded design is checked before it is used). + pub fn validate_spline_knots(&self) -> Result<()> { + for curve in &self.curves { + if let crate::CurveKind::Spline { pts, control, degree, periodic, nurbs: Some(nurbs) } = &curve.kind { + if !*control || *periodic { + return bad("only an open control spline has its own knots"); + } + nurbs.check(pts.len(), *degree)?; + } + } + Ok(()) + } +} diff --git a/crates/sketch/src/periodic.rs b/crates/sketch/src/periodic.rs index 698e58a58..b4f4ff2f4 100644 --- a/crates/sketch/src/periodic.rs +++ b/crates/sketch/src/periodic.rs @@ -102,7 +102,7 @@ impl Sketch { pub fn validate_periodic_splines(&self) -> Result<()> { let mut work = 0usize; for curve in &self.curves { - if let crate::CurveKind::Spline { pts, control, degree, periodic: true } = &curve.kind { + if let crate::CurveKind::Spline { pts, control, degree, periodic: true, .. } = &curve.kind { work = work.saturating_add(pts.len()); if *control || *degree != 3 || work > 1_000_000 || pts.len() > MAX_SPLINE_POINTS { return Err(bad()); @@ -136,7 +136,7 @@ mod tests { (legacy[0][1] - legacy[0][0]).normalized().unwrap().dist((legacy.last().unwrap()[3] - legacy.last().unwrap()[2]).normalized().unwrap()) > 0.01 ); - let global = |t| crate::spline_point_mode(&p, false, 3, true, t); + let global = |t| crate::spline_point_mode(&p, false, 3, true, None, t); let h = 1e-5; assert!(((global(h) - global(0.0)) / h - (global(1.0) - global(1.0 - h)) / h).len() < 0.002); } @@ -160,8 +160,9 @@ mod tests { let c = sk.add_point(Vec2::new(-4.0, 0.0), None).unwrap(); let d = sk.add_point(Vec2::new(-3.0, -2.0), None).unwrap(); let last = sk.add_point(Vec2::ZERO, None).unwrap(); - sk.add_curve(crate::CurveKind::Spline { pts: vec![first, a, b, seam], control: false, degree: 3, periodic: true }, None).unwrap(); - sk.add_curve(crate::CurveKind::Spline { pts: vec![seam, c, d, last], control: false, degree: 3, periodic: true }, None).unwrap(); + sk.add_curve(crate::CurveKind::Spline { pts: vec![first, a, b, seam], control: false, degree: 3, periodic: true, nurbs: None }, None) + .unwrap(); + sk.add_curve(crate::CurveKind::Spline { pts: vec![seam, c, d, last], control: false, degree: 3, periodic: true, nurbs: None }, None).unwrap(); sk.points[first].pos = Vec2::new(0.2, 0.1); assert!(crate::solve_with(&mut sk, &crate::Hold { points: vec![first], radii: vec![] }, None, crate::Analysis::Full, None).ok()); assert_eq!(sk.point(first), sk.point(seam)); @@ -186,7 +187,7 @@ mod tests { let p = vec![Vec2::ZERO, Vec2::new(4.0, 0.0), Vec2::new(3.0, 2.0), Vec2::new(-1.0, 1.0), Vec2::ZERO]; let mut sk = Sketch::new(); let source = crate::LinkSource::SketchCurve { sketch: 99, curve: "source".into() }; - let geometry = crate::LinkGeom::Spline { pts: p.clone(), control: false, degree: 3, periodic: true }; + let geometry = crate::LinkGeom::Spline { pts: p.clone(), control: false, degree: 3, periodic: true, nurbs: None }; let id = sk.add_link(crate::LinkKind::Project, source, &[geometry]).unwrap(); let curve = sk.link_curves(&id)[0]; assert!(matches!(sk.curves[curve].kind, crate::CurveKind::Spline { periodic: true, .. })); @@ -197,7 +198,8 @@ mod tests { let mut singular = Sketch::new(); let points = [Vec2::ZERO, Vec2::X, Vec2::ZERO, Vec2::new(0.0, 1.0), Vec2::ZERO].into_iter().map(|p| singular.add_point(p, None).unwrap()).collect(); - let curve = singular.add_curve(crate::CurveKind::Spline { pts: points, control: false, degree: 3, periodic: true }, None).unwrap(); + let curve = + singular.add_curve(crate::CurveKind::Spline { pts: points, control: false, degree: 3, periodic: true, nurbs: None }, None).unwrap(); let before = singular.clone(); assert!(singular.add_freeform_offset(curve, true, 0.1).is_err()); assert_eq!(singular, before); diff --git a/crates/sketch/src/solver.rs b/crates/sketch/src/solver.rs index 40ea39a1e..c714ae534 100644 --- a/crates/sketch/src/solver.rs +++ b/crates/sketch/src/solver.rs @@ -258,9 +258,9 @@ impl State<'_> { }; crate::curves::ellipse_polyline(self.p(*ci), self.p(*m), r) } - Some(CurveKind::Spline { pts, control, degree, periodic }) => { + Some(CurveKind::Spline { pts, control, degree, periodic, nurbs }) => { let p = self.spline_points(pts, *periodic); - crate::curves::spline_polyline_mode(&p, *control, *degree, *periodic) + crate::curves::spline_polyline_mode(&p, *control, *degree, *periodic, nurbs.as_ref()) } Some(CurveKind::Conic { a, b, apex, rho }) => crate::curves::conic_polyline(self.p(*a), self.p(*apex), self.p(*b), *rho), _ => Vec::new(), @@ -293,12 +293,14 @@ impl State<'_> { let y = delta.cross(u) / (a * r); return (x.hypot(y) - 1.0) * a.min(r); } - Some(CurveKind::Spline { pts, control, degree, periodic }) => { + Some(CurveKind::Spline { pts, control, degree, periodic, nurbs }) => { let p = self.spline_points(pts, *periodic); if p.len() < 2 { return q.dist(p.first().copied().unwrap_or_default()); } - if *control { + if let Some(nurbs) = nurbs { + nurbs.segs(&p, *degree).unwrap_or_default() + } else if *control { let k = (*degree as usize).min(solidcraft_geom::MAX_BEZIER_DEGREE).min(p.len().saturating_sub(1)).max(1); crate::curves::bspline_beziers(&p, k).iter().filter_map(|span| solidcraft_geom::bezier(span)).collect() } else { @@ -393,10 +395,10 @@ impl State<'_> { let (cc, r) = self.round(c); (cc - self.p(p)) / (r * r).max(1e-24) } - CurveKind::Spline { pts, control, degree, periodic } => { + CurveKind::Spline { pts, control, degree, periodic, nurbs } => { let q = self.spline_points(pts, *periodic); let at_end = pts.last() == Some(&p) && pts.first() != Some(&p); - crate::curves::end_curvature(&|t| crate::curves::spline_point_mode(&q, *control, *degree, *periodic, t), at_end) + crate::curves::end_curvature(&|t| crate::curves::spline_point_mode(&q, *control, *degree, *periodic, nurbs.as_ref(), t), at_end) } CurveKind::Conic { a, b, apex, rho } => { let (pa, pb, px) = (self.p(*a), self.p(*b), self.p(*apex)); @@ -2938,7 +2940,7 @@ fn solve_inner( } } for curve in &sk.curves { - if let CurveKind::Spline { pts, control, degree, periodic: true } = &curve.kind { + if let CurveKind::Spline { pts, control, degree, periodic: true, .. } = &curve.kind { let points = pts.iter().map(|i| positions.get(*i).copied()).collect::>>(); if *control || *degree != 3 || points.as_ref().is_none_or(|p| crate::periodic::validate_periodic_points(p).is_err()) { valid = false; diff --git a/crates/sketch/src/tests.rs b/crates/sketch/src/tests.rs index 1e5e61f09..77d82e231 100644 --- a/crates/sketch/src/tests.rs +++ b/crates/sketch/src/tests.rs @@ -657,7 +657,7 @@ fn near_overlaps_that_are_not_one_path_keep_their_regions() { .iter() .map(|p| sk.add_point(*p, None).unwrap()) .collect(); - sk.add_curve(CurveKind::Spline { pts: ids.clone(), control: true, degree: 3, periodic: false }, None).unwrap(); + sk.add_curve(CurveKind::Spline { pts: ids.clone(), control: true, degree: 3, periodic: false, nurbs: None }, None).unwrap(); sk.add_line_pts(ids[3], ids[0], None).unwrap(); let ps = find_profiles(&sk); assert_eq!(ps.len(), 1, "{:?}", ps.iter().map(|p| p.area).collect::>()); @@ -953,7 +953,7 @@ fn exact_profiles_for_high_degree_and_cut_free_form_curves() { .iter() .map(|p| sk.add_point(*p, None).unwrap()) .collect(); - sk.add_curve(CurveKind::Spline { pts: ids.clone(), control: true, degree: 5, periodic: false }, None).unwrap(); + sk.add_curve(CurveKind::Spline { pts: ids.clone(), control: true, degree: 5, periodic: false, nurbs: None }, None).unwrap(); sk.add_line_pts(ids[5], ids[0], None).unwrap(); let pr = find_profiles(&sk); assert_eq!(pr.len(), 1); @@ -962,7 +962,7 @@ fn exact_profiles_for_high_degree_and_cut_free_form_curves() { // A fit spline arch over a base line, cut by a vertical line at x = 10. let mut sk = Sketch::default(); let ids: Vec = [v(0.0, 0.0), v(6.0, 9.0), v(14.0, 9.0), v(20.0, 0.0)].iter().map(|p| sk.add_point(*p, None).unwrap()).collect(); - sk.add_curve(CurveKind::Spline { pts: ids.clone(), control: false, degree: 3, periodic: false }, None).unwrap(); + sk.add_curve(CurveKind::Spline { pts: ids.clone(), control: false, degree: 3, periodic: false, nurbs: None }, None).unwrap(); sk.add_line_pts(ids[3], ids[0], None).unwrap(); let (a, b) = (sk.add_point(v(10.0, -5.0), None).unwrap(), sk.add_point(v(10.0, 20.0), None).unwrap()); sk.add_line_pts(a, b, None).unwrap(); @@ -1033,7 +1033,7 @@ fn a_degree_nine_control_spline_stays_exact_and_closes_a_profile_exactly() { let bump = [v(0.0, 0.0), v(1.5, 4.0), v(3.0, 7.0), v(5.0, 9.5), v(7.5, 11.0), v(12.5, 11.0), v(15.0, 9.5), v(17.0, 7.0), v(18.5, 4.0), v(20.0, 0.0)]; let pts: Vec = bump.iter().map(|q| sk.add_point(*q, None).unwrap()).collect(); - let s = sk.add_curve(CurveKind::Spline { pts: pts.clone(), control: true, degree: 9, periodic: false }, None).unwrap(); + let s = sk.add_curve(CurveKind::Spline { pts: pts.clone(), control: true, degree: 9, periodic: false, nurbs: None }, None).unwrap(); let pieces = sk.exact_pieces(s); assert_eq!(pieces.len(), 1, "{pieces:?}"); let Seg2::Bezier { n, p } = pieces[0] else { panic!("{:?}", pieces[0]) }; @@ -1068,7 +1068,7 @@ fn a_degree_nine_control_spline_stays_exact_and_closes_a_profile_exactly() { // A degree above the cap is still refused. let mut high: Vec = pts.clone(); high.push(sk.add_point(v(21.0, -2.0), None).unwrap()); - assert!(sk.add_curve(CurveKind::Spline { pts: high, control: true, degree: 10, periodic: false }, None).is_err()); + assert!(sk.add_curve(CurveKind::Spline { pts: high, control: true, degree: 10, periodic: false, nurbs: None }, None).is_err()); } /// #755: a line drawn through a junction of a loop, but 2e-5 off it, still splits the loop. The @@ -1295,3 +1295,67 @@ fn bounds_reach_the_extremes_of_circles_and_arcs() { let (lo, hi) = sk.bounds().unwrap(); assert!(lo.dist(v(0.0, 0.0)) < 1e-9 && hi.dist(v(10.0, 10.0)) < 1e-9, "{lo:?} {hi:?}"); } + +/// A control spline with its own knots and weights (a projected free-form edge): its exact pieces +/// are its knot spans, a rational quadratic's are conics, its points follow its knots, it reads +/// back from a saved design the same, and knots that don't fit it are refused. +#[test] +fn a_spline_with_its_own_knots_is_its_spans_exactly() { + let mut sk = Sketch::new(); + // Two cubic Béziers end to end (the joint knot three times), the second twice as long in + // parameter: (0,0) (1,2) (2,2) (3,0) then (3,0) (4,-2) (5,-2) (6,0). + let ctrl = [v(0.0, 0.0), v(1.0, 2.0), v(2.0, 2.0), v(3.0, 0.0), v(4.0, -2.0), v(5.0, -2.0), v(6.0, 0.0)]; + let nurbs = Nurbs { knots: vec![0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 3.0, 3.0, 3.0, 3.0], weights: Vec::new() }; + let pts: Vec = ctrl.iter().map(|q| sk.add_point(*q, None).unwrap()).collect(); + let kind = CurveKind::Spline { pts: pts.clone(), control: true, degree: 3, periodic: false, nurbs: Some(nurbs.clone()) }; + let s = sk.add_curve(kind.clone(), None).unwrap(); + let pieces = sk.exact_pieces(s); + assert_eq!(pieces.len(), 2, "{pieces:?}"); + let Seg2::Cubic { p0, p1, p2, p3 } = pieces[1] else { panic!("{:?}", pieces[1]) }; + for (got, want) in [(p0, ctrl[3]), (p1, ctrl[4]), (p2, ctrl[5]), (p3, ctrl[6])] { + assert!(got.dist(want) < 1e-12, "{got:?} {want:?}"); + } + // t runs over the knots: a third of the way is the joint, where the uniform spline over the + // same points would not be. + assert!(nurbs.point(&ctrl, 3, 1.0 / 3.0).unwrap().dist(ctrl[3]) < 1e-12); + assert!(crate::curves::spline_point(&ctrl, true, 3, 1.0 / 3.0).dist(ctrl[3]) > 1e-3); + let back = nurbs.reversed(); + let rev: Vec = ctrl.iter().rev().copied().collect(); + for k in 0..=12 { + let t = k as f64 / 12.0; + assert!(nurbs.point(&ctrl, 3, t).unwrap().dist(back.point(&rev, 3, 1.0 - t).unwrap()) < 1e-12, "t={t}"); + } + let poly = sk.polyline(s); + assert!(poly.first().unwrap().dist(ctrl[0]) < 1e-12 && poly.last().unwrap().dist(ctrl[6]) < 1e-12); + // Saved and read back: the same curve. + let json = serde_json::to_string(&kind).unwrap(); + assert_eq!(serde_json::from_str::(&json).unwrap(), kind); + // A quarter circle of radius 2 as a rational quadratic: one conic, its middle point on the circle. + let w = std::f64::consts::FRAC_1_SQRT_2; + let quarter = Nurbs { knots: vec![0.0, 0.0, 0.0, 1.0, 1.0, 1.0], weights: vec![1.0, w, 1.0] }; + let arc = [v(2.0, 0.0), v(2.0, 2.0), v(0.0, 2.0)]; + let [Seg2::Conic { w: cw, .. }] = quarter.segs(&arc, 2).unwrap()[..] else { panic!("conic") }; + assert!((cw - w).abs() < 1e-12); + assert!((quarter.point(&arc, 2, 0.5).unwrap().len() - 2.0).abs() < 1e-12); + // Knots that don't fit: the wrong count, not clamped, decreasing, not finite, an interior knot + // past the degree, a weight that isn't positive; and knots on a fit spline. + let bad = [ + Nurbs { knots: vec![0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0], weights: Vec::new() }, + Nurbs { knots: vec![0.0, 0.0, 0.0, 0.5, 1.0, 1.0, 1.0, 3.0, 3.0, 3.0, 3.0], weights: Vec::new() }, + Nurbs { knots: vec![0.0, 0.0, 0.0, 0.0, 2.0, 1.0, 1.0, 3.0, 3.0, 3.0, 3.0], weights: Vec::new() }, + Nurbs { knots: vec![0.0, 0.0, 0.0, 0.0, f64::NAN, 1.0, 1.0, 3.0, 3.0, 3.0, 3.0], weights: Vec::new() }, + Nurbs { knots: vec![0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 3.0, 3.0, 3.0, 3.0], weights: Vec::new() }, + Nurbs { knots: nurbs.knots.clone(), weights: vec![1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0] }, + ]; + for (i, k) in bad.iter().enumerate() { + assert!(k.check(ctrl.len(), 3).is_err(), "{i}"); + assert!( + sk.add_curve(CurveKind::Spline { pts: pts.clone(), control: true, degree: 3, periodic: false, nurbs: Some(k.clone()) }, None).is_err(), + "{i}" + ); + assert!(k.point(&ctrl, 3, 0.5).is_none() && k.segs(&ctrl, 3).is_none() && k.polyline(&ctrl, 3).is_empty(), "{i}"); + } + let fourfold = Nurbs { knots: vec![0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 3.0, 3.0, 3.0, 3.0], weights: Vec::new() }; + assert!(fourfold.check(8, 3).is_err()); + assert!(sk.add_curve(CurveKind::Spline { pts, control: false, degree: 3, periodic: false, nurbs: Some(nurbs) }, None).is_err()); +} diff --git a/crates/sketch/src/text.rs b/crates/sketch/src/text.rs index 7327fb680..e36cab4e9 100644 --- a/crates/sketch/src/text.rs +++ b/crates/sketch/src/text.rs @@ -53,7 +53,7 @@ impl Outline { self.line(to); return; } - self.out.push(LinkGeom::Spline { pts: vec![a, c1, c2, b], control: true, degree: 3, periodic: false }); + self.out.push(LinkGeom::Spline { pts: vec![a, c1, c2, b], control: true, degree: 3, periodic: false, nurbs: None }); self.cur = to; } } diff --git a/crates/sketch/src/thin.rs b/crates/sketch/src/thin.rs index 1d9fb5124..5ca8b85f3 100644 --- a/crates/sketch/src/thin.rs +++ b/crates/sketch/src/thin.rs @@ -378,7 +378,7 @@ fn outline_sketch(boundary: &[Seg2]) -> Result { } Seg2::Cubic { p0, p1, p2, p3 } => { let pts = [p0, p1, p2, p3].iter().map(|p| sk.add_point(*p, None)).collect::>>()?; - sk.add_curve(CurveKind::Spline { pts, control: true, degree: 3, periodic: false }, None)?; + sk.add_curve(CurveKind::Spline { pts, control: true, degree: 3, periodic: false, nurbs: None }, None)?; } _ => return Err(bad("not supported yet: this kind of wall curve")), } diff --git a/crates/sketch/src/virtual_corner_tests.rs b/crates/sketch/src/virtual_corner_tests.rs index 2103875c0..b5357661e 100644 --- a/crates/sketch/src/virtual_corner_tests.rs +++ b/crates/sketch/src/virtual_corner_tests.rs @@ -51,7 +51,7 @@ fn curve_centres_and_spline_interior_points_are_used_and_invalid_incidence_is_sa let last = point(&mut sk, 21., 21.); let mut spline = sk.curves[a].clone(); spline.id = "interior_spline".into(); - spline.kind = CurveKind::Spline { pts: vec![first, interior, last], control: false, degree: 3, periodic: false }; + spline.kind = CurveKind::Spline { pts: vec![first, interior, last], control: false, degree: 3, periodic: false, nurbs: None }; sk.curves.push(spline); for p in [centre, interior] { for c in [a, b] { @@ -91,7 +91,7 @@ fn oversized_reference_input_is_refused_without_scanning_or_mutating_it() { let mut sk = Sketch::new(); let a = sk.add_line(Vec2::new(0., 1.), Vec2::new(2., 1.), None, None, None).unwrap(); let before = sk.points.clone(); - sk.curves[a].kind = CurveKind::Spline { pts: vec![usize::MAX; 1_000_001], control: false, degree: 3, periodic: false }; + sk.curves[a].kind = CurveKind::Spline { pts: vec![usize::MAX; 1_000_001], control: false, degree: 3, periodic: false, nurbs: None }; assert!(sk.virtual_corners().is_empty()); assert_eq!(sk.points, before); assert_eq!(sk.curves[a].kind.point_ids().len(), 1_000_001); diff --git a/crates/ui-egui/src/tools.rs b/crates/ui-egui/src/tools.rs index 0c47fae74..9051b27f3 100644 --- a/crates/ui-egui/src/tools.rs +++ b/crates/ui-egui/src/tools.rs @@ -976,6 +976,7 @@ pub(crate) fn preview_curve( control: t.cmd != "sketch.spline.fit_point", degree: if t.cmd == "sketch.spline.control_point_5" { 5 } else { 3 }, periodic, + nurbs: None, }, None, ) From e6abea809750cf4a2e06695fe1efda1bcf22efa3 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Fri, 30 Oct 2026 23:06:40 -0400 Subject: [PATCH 02/81] Sketch projection: a free-form edge comes in as the one exact spline it is A projected spline edge of several Bezier spans came into the sketch as one curve per span (#1508), so a G2 round's bottom edge was 16 curves and a path naming the corner named one span of it (#3604). The kernel now reads such an edge (a spline, or an elliptical arc of several spans) as the one clamped B-spline it is over the edge's interval, its knots and weights its own, and the sketch takes it as one control spline whose ends sit on the edge's vertices. Planar regions still read edges span by span. The 3604 case builds with its original path and leaves KNOWN_FAILING. Co-Authored-By: Claude Opus 5.5 --- crates/doc/src/project.rs | 39 ++++- crates/engine/src/cmd/sketch_project_tests.rs | 35 +++++ crates/kernel/src/body.rs | 11 +- crates/kernel/src/lib.rs | 1 + crates/kernel/src/prism_curve.rs | 140 +++++++++++++++++- tests/kernel-cases/booleans/KNOWN_FAILING | 1 - 6 files changed, 213 insertions(+), 14 deletions(-) diff --git a/crates/doc/src/project.rs b/crates/doc/src/project.rs index 6b22d6c82..ac1321450 100644 --- a/crates/doc/src/project.rs +++ b/crates/doc/src/project.rs @@ -503,11 +503,33 @@ fn sketch_curves(ss: &crate::eval::SolvedSketch, ci: usize) -> Vec { } /// Edges `edges` of `body` (indices into its mesh's `edges`) on `plane` as their exact curves: -/// lines, circles and arcs, and the Bézier pieces of a free-form curve. `None` for an edge that -/// doesn't lie in a plane parallel to `plane` or isn't read exactly (a mesh body's): it is +/// lines, circles and arcs, and a free-form curve as the one spline it is, its knots and weights +/// its own. `None` for an edge that doesn't lie in a plane parallel to `plane`, isn't read +/// exactly (a mesh body's) or is a spline no sketch holds (past degree 9 or 500 points): it is /// fitted to its polyline instead. fn exact_edges(body: &crate::ModelBody, plane: &Plane, edges: &[usize]) -> Vec>> { - body.body.planar_edges(plane, edges).into_iter().map(|segs| segs?.iter().map(link_geom).collect()).collect() + body.body + .planar_edges(plane, edges) + .into_iter() + .map(|pieces| { + pieces? + .iter() + .map(|piece| match piece { + crate::kernel::PlanarPiece::Seg(s) => link_geom(s), + crate::kernel::PlanarPiece::Spline(s) => link_spline(s), + }) + .collect() + }) + .collect() +} + +/// A free-form edge's B-spline as the control spline that is the same curve, with its own knots +/// and weights. `None` for one a sketch can't hold. +fn link_spline(s: &crate::kernel::PlanarSpline) -> Option { + let degree = u8::try_from(s.degree).ok()?; + let nurbs = solidcraft_sketch::Nurbs { knots: s.knots.clone(), weights: s.weights.clone() }; + nurbs.check(s.points.len(), degree).ok()?; + Some(LinkGeom::Spline { pts: s.points.clone(), control: true, degree, periodic: false, nurbs: Some(nurbs) }) } /// `edges` of `body` projected on `plane`: each exactly ([`exact_edges`]) or fitted to its @@ -549,7 +571,16 @@ fn at_vertices(body: &crate::ModelBody, mesh: &Mesh, plane: &Plane, e: usize, g: for v in [plane.to_local(*first), plane.to_local(*last)] { let mut best: Option<(f64, &mut Vec2)> = None; for piece in g.iter_mut() { - if let LinkGeom::Line(a, b) | LinkGeom::Arc { a, b, .. } | LinkGeom::Conic { a, b, .. } = piece { + let ends = match piece { + LinkGeom::Line(a, b) | LinkGeom::Arc { a, b, .. } | LinkGeom::Conic { a, b, .. } => Some((a, b)), + // A control spline's end points are its ends. + LinkGeom::Spline { pts, control: true, periodic: false, .. } => match pts.as_mut_slice() { + [a, .., b] => Some((a, b)), + _ => None, + }, + _ => None, + }; + if let Some((a, b)) = ends { for p in [a, b] { let d = p.dist(v); if d <= tol && best.as_ref().is_none_or(|(bd, _)| d < *bd) { diff --git a/crates/engine/src/cmd/sketch_project_tests.rs b/crates/engine/src/cmd/sketch_project_tests.rs index 543112cff..fbb4ceb0a 100644 --- a/crates/engine/src/cmd/sketch_project_tests.rs +++ b/crates/engine/src/cmd/sketch_project_tests.rs @@ -936,3 +936,38 @@ fn intersect_on_a_top_face_gives_its_outline() { let ends = outline(&intersect_curves(&block, json!({"plane": "XY", "offset": 20})).unwrap()); assert_eq!(ends, vec![[0.0, 0.0, 0.0, 30.0], [0.0, 0.0, 40.0, 0.0], [0.0, 30.0, 40.0, 30.0], [40.0, 0.0, 40.0, 30.0]]); } + +/// A free-form edge projects as the one exact spline it is, its knots and weights its own: the +/// bottom face of a 40 x 20 x 10 box whose upright edges have G2 rounds (each round's bottom +/// edge a B-spline of several spans) comes into its sketch as four lines and four splines, one a +/// corner, each meeting the lines at their ends (#3604, where each span was a curve of its own). +/// The profile they bound, extruded the box's height, is the box: its sides are upright. +#[test] +fn a_free_form_edge_projects_as_one_spline_with_its_own_knots() { + use solidcraft_sketch::CurveKind; + let volume = |s: &Session, body: &str| solidcraft_kernel::measure(&s.world_state().unwrap().body(body).unwrap().body).unwrap().volume; + let mut s = Session::default(); + run(&mut s, "solid.box", json!({"corner":[0,0,0],"length":40,"width":20,"height":10,"body_name":"B"})); + run(&mut s, "solid.fillet", json!({"body":"B","edges":[[0,0,5],[40,0,5],[40,20,5],[0,20,5]],"radius":5,"type":"g2"})); + let id = run(&mut s, "sketch.create", json!({"plane":{"face":[20,10,0]},"project_edges":true,"name":"Bottom"}))["sketch"].as_u64().unwrap(); + run(&mut s, "sketch.finish", json!({})); + let st = s.model.state(); + let sketch = &st.sketch(id).unwrap().sketch; + let lines = sketch.curves.iter().filter(|c| matches!(c.kind, CurveKind::Line { .. })).count(); + let splines: Vec<_> = sketch.curves.iter().filter(|c| matches!(c.kind, CurveKind::Spline { .. })).collect(); + assert_eq!((lines, splines.len(), sketch.curves.len()), (4, 4, 8), "{:?}", sketch.curves); + for c in &splines { + let CurveKind::Spline { pts, control: true, nurbs: Some(nurbs), .. } = &c.kind else { panic!("{:?}", c.kind) }; + assert_eq!(nurbs.knots.len(), pts.len() + 4, "a cubic's knots"); + let (a, b) = c.kind.ends().unwrap(); + for end in [a, b] { + let meets = sketch.curves.iter().filter(|o| matches!(o.kind, CurveKind::Line { a, b } if a == end || b == end)).count(); + assert_eq!(meets, 1, "{} end {end}", c.id); + } + } + drop(st); + let rounded = volume(&s, "B"); + run(&mut s, "solid.extrude", json!({"sketch":"Bottom","distance":10,"operation":"new","body_name":"P"})); + let prism = volume(&s, "P"); + assert!((prism - rounded).abs() < rounded * 1e-6, "{prism} vs {rounded}"); +} diff --git a/crates/kernel/src/body.rs b/crates/kernel/src/body.rs index 211ab4859..502595bff 100644 --- a/crates/kernel/src/body.rs +++ b/crates/kernel/src/body.rs @@ -1287,10 +1287,11 @@ impl Body { } /// Edges `indices` (record edge indices) in `plane`'s coordinates, exactly: lines, circular - /// arcs, and free-form curves as the Bézier spans they are, for a sketch to project them. - /// `None` for an edge that doesn't lie in a plane parallel to `plane`, isn't read exactly or - /// isn't there, and for every edge of a mesh body. - pub fn planar_edges(&self, plane: &solidcraft_geom::Plane, indices: &[usize]) -> Vec>> { + /// arcs, single free-form segments, and a free-form curve of several spans as the one + /// B-spline it is, for a sketch to project them. `None` for an edge that doesn't lie in a + /// plane parallel to `plane`, isn't read exactly or isn't there, and for every edge of a mesh + /// body. + pub fn planar_edges(&self, plane: &solidcraft_geom::Plane, indices: &[usize]) -> Vec>> { if self.is_mesh() { return vec![None; indices.len()]; } @@ -1299,7 +1300,7 @@ impl Body { .iter() .map(|i| { let mut work = 262_144usize; - crate::prism_curve::Run::of(&self.record, *i, true).and_then(|run| crate::prism_curve::projected(&run, plane, tol, &mut work)) + crate::prism_curve::Run::of(&self.record, *i, true).and_then(|run| crate::prism_curve::projected_curves(&run, plane, tol, &mut work)) }) .collect() } diff --git a/crates/kernel/src/lib.rs b/crates/kernel/src/lib.rs index 6c457444c..461fed2fa 100644 --- a/crates/kernel/src/lib.rs +++ b/crates/kernel/src/lib.rs @@ -210,6 +210,7 @@ pub use point_path::{ pub use polybool::faceted_boolean; pub use polyhedron::{HalfSpace, convex_polyhedron, draft, offset_faces, shell}; pub use prism::{PLANAR_FIT_TOL, extrude_planar_regions, planar_regions_boolean}; +pub use prism_curve::{PlanarPiece, PlanarSpline}; pub use prism_measure::{PrismSection, certified_prism_equivalent, certified_prism_section}; pub use repair::{Hole, RebuiltFace, RefusedFace, RepairOptions, RepairReport, SewnGap, repair}; pub use sew::{EdgeSpec, FaceSpec, SurfSpec, sew, sew_touching}; diff --git a/crates/kernel/src/prism_curve.rs b/crates/kernel/src/prism_curve.rs index 508ef1f06..4b4e47aa0 100644 --- a/crates/kernel/src/prism_curve.rs +++ b/crates/kernel/src/prism_curve.rs @@ -299,14 +299,146 @@ pub(crate) fn segment(run: &Run, plane: &Plane, tol: f64, work: &mut usize) -> O read(run, plane, tol, work, false) } -/// `run` in `plane` exactly, for a sketch to project it: as [`segment`], and a curve of several -/// Bézier spans (a chain of a font's curves, a spline through points) as one segment per span, -/// each the line, conic or Bézier it is. `None` when the edge doesn't lie in a plane parallel to -/// `plane` or isn't read exactly. +/// `run` in `plane` exactly as segments: as [`segment`], and a curve of several Bézier spans +/// (a chain of a font's curves, a spline through points) as one segment per span, each the +/// line, conic or Bézier it is, for a planar region's outline. `None` when the edge doesn't lie +/// in a plane parallel to `plane` or isn't read exactly. pub(crate) fn projected(run: &Run, plane: &Plane, tol: f64, work: &mut usize) -> Option> { read(run, plane, tol, work, true) } +/// A free-form curve of several Bézier spans in a plane, as the one B-spline it is: its degree, +/// clamped knots, control points in the plane's coordinates and weights (none: a polynomial +/// B-spline). Its first and last control points are its ends. +#[derive(Clone, Debug, PartialEq)] +pub struct PlanarSpline { + pub degree: usize, + pub knots: Vec, + pub points: Vec, + pub weights: Vec, +} + +/// One piece of an edge read exactly in a plane: a line, arc or single free-form segment, or a +/// free-form curve of several spans as one [`PlanarSpline`]. +#[derive(Clone, Debug, PartialEq)] +pub enum PlanarPiece { + Seg(Seg2), + Spline(PlanarSpline), +} + +/// `run` in `plane` exactly, for a sketch to project it: as [`segment`], and a curve of several +/// Bézier spans (a spline edge, an elliptical arc past a quarter turn, a chain of a font's +/// curves) as the one B-spline it is, its knots and weights its own. `None` when the edge +/// doesn't lie in a plane parallel to `plane` or isn't read exactly. +pub(crate) fn projected_curves(run: &Run, plane: &Plane, tol: f64, work: &mut usize) -> Option> { + if let Some(segs) = read(run, plane, tol, work, false) { + return Some(segs.into_iter().map(PlanarPiece::Seg).collect()); + } + one_spline(run, plane, tol, work).map(|s| vec![PlanarPiece::Spline(s)]) +} + +/// `run`'s spline (or ellipse) over its interval, in the direction it runs, as one clamped +/// B-spline in `plane`: the piece of the curve between the interval's ends (Boehm insertion, +/// exact up to rounding), its control points read in the plane. `None` when a control point lies +/// off the level of the curve's start (the curve is not in a plane parallel to `plane`), the +/// ends miss the run's ends, or the work budget runs out. +fn one_spline(run: &Run, plane: &Plane, tol: f64, work: &mut usize) -> Option { + if !tol.is_finite() || tol <= 0. || run.interval[1] <= run.interval[0] { + return None; + } + charge(work, 1)?; + let [t0, t1] = run.interval; + let clamped = |knots: &[f64], ctrl: Vec, work: &mut usize| -> Option<(usize, Vec, Vec)> { + let degree = knots.len().checked_sub(ctrl.len() + 1)?; + if !(1..=MAX_DEGREE).contains(°ree) || ctrl.len() > MAX_CONTROLS || knots.len() > 8192 { + return None; + } + if knots.iter().any(|t| !t.is_finite()) || knots.windows(2).any(|w| w[1] < w[0]) || ctrl.iter().any(|p| !p.is_finite()) { + return None; + } + charge(work, ctrl.len().checked_mul(degree + 1)?.checked_mul(2)?)?; + let (k, c) = bspline::segment(degree, knots, &ctrl, t0, t1).ok()?; + Some((degree, k, c)) + }; + // In the curve's own direction, then the way the run goes. + let (degree, knots, ctrl) = match run.curve { + Curve::Spline { knots, points } => along(run, clamped(knots, points.iter().map(|p| HPoint::weighted(v3(*p), 1.0)).collect(), work)?)?, + Curve::RationalSpline { knots, homogeneous } => { + along(run, clamped(knots, homogeneous.iter().map(|p| HPoint { x: p[0], y: p[1], z: p[2], w: p[3] }).collect(), work)?)? + } + // Rational quadratic spans, already the way the run goes, joined: each joint knot twice. + Curve::Ellipse { .. } => { + let spans = spans_of(run, work)?; + let mut knots = vec![0.0; 3]; + let mut ctrl: Vec = Vec::new(); + for (i, span) in spans.iter().enumerate() { + let [p0, p1, p2] = span.as_slice() else { return None }; + if let Some(last) = ctrl.last() { + if (last.w - p0.w).abs() > 1e-12 * last.w.abs().max(p0.w.abs()) { + return None; + } + } else { + ctrl.push(*p0); + } + ctrl.extend([*p1, *p2]); + knots.extend([(i + 1) as f64; 2]); + } + knots.push(spans.len() as f64); + (2, knots, ctrl) + } + _ => return None, + }; + let max_w = ctrl.iter().map(|p| p.w).fold(0., f64::max); + if !(max_w.is_finite() && max_w > 0.) { + return None; + } + let (Some(first), Some(last)) = (ctrl.first().and_then(|p| p.project()), ctrl.last().and_then(|p| p.project())) else { return None }; + let level = plane.height(first); + let (a, b) = (plane.to_local(first), plane.to_local(last)); + if first.dist(run.ends[0]) > tol || last.dist(run.ends[1]) > tol { + return None; + } + let mut points = Vec::with_capacity(ctrl.len()); + let mut weights = Vec::with_capacity(ctrl.len()); + for p in &ctrl { + if p.w / max_w < 1e-12 { + return None; + } + let v = p.project()?; + let error = (v.x.abs() + v.y.abs() + v.z.abs() + plane.origin.len()) * f64::EPSILON * 256.; + if (plane.height(v) - level).abs() + error > tol || error > tol * 0.1 { + return None; + } + let local = plane.to_local(v); + if !(local.x.is_finite() && local.y.is_finite()) { + return None; + } + points.push(local); + weights.push(p.w / max_w); + } + // The ends exactly where the curve ends. + if let Some(p) = points.first_mut() { + *p = a; + } + if let Some(p) = points.last_mut() { + *p = b; + } + if weights.iter().all(|w| (w - 1.).abs() <= 1e-12) { + weights.clear(); + } + Some(PlanarSpline { degree, knots, points, weights }) +} + +/// A clamped B-spline `(degree, knots, control points)` run the way `run` goes: as it is +/// forward, its knots mirrored and its control points reversed back. +fn along(run: &Run, (degree, knots, ctrl): (usize, Vec, Vec)) -> Option<(usize, Vec, Vec)> { + if run.forward { + return Some((degree, knots, ctrl)); + } + let sum = knots.first()? + knots.last()?; + Some((degree, knots.iter().rev().map(|k| sum - k).collect(), ctrl.into_iter().rev().collect())) +} + fn read(run: &Run, plane: &Plane, tol: f64, work: &mut usize, each_span: bool) -> Option> { if !tol.is_finite() || tol <= 0. { return None; diff --git a/tests/kernel-cases/booleans/KNOWN_FAILING b/tests/kernel-cases/booleans/KNOWN_FAILING index a71ceae24..bd9b14258 100644 --- a/tests/kernel-cases/booleans/KNOWN_FAILING +++ b/tests/kernel-cases/booleans/KNOWN_FAILING @@ -2,4 +2,3 @@ # rig gate (.github/workflows/kernel-rig.yml) fails on a case that fails and is not listed here, # and on a listed case that passes: a fix removes its line in the same pull request. # Baseline: develop 5ada4fc8a with SMLib 90aabff (the run on 60b1c6a, aarch64 Linux). -3604-cut-with-g2-swept-tool-along-projected-edge step 12 (solid.sweep): the path curves are not connected end to end From f61f25c7f512a326b3815cf313f90375aac669eb Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 01:35:43 -0400 Subject: [PATCH 03/81] Fillet rig: blends past an outer rim of their faces build, on SMLib smlib-blends-past-rims The owner's ruling: a round or chamfer that runs past an outer edge of its face into open air builds, tangent where it has room and cut by the face beyond where it runs out. SMLib's branch smlib-blends-past-rims builds them by the rig's analytic answers. Off the known-failing list: the disc's rim past its 2 mm wall (190), the hole's top rim R12 past the plate's bottom, the chamfer past the cylinder's bottom (2893), each closing on the wall continued as itself, and 926's chamfer ending on the boss's wall, which now builds to its answer too. The sloped basins' R4 rim rounds (1080, mitred rounds built together where one overflows) build to their analytic volumes (to 6e-9), and stay listed with that reason: their continuity check (g1 at every blend seam) takes in the mitres' creases, G0 by the mitre ruling. 2893-chamfer-two-distances-elliptical-rim is graded as a solid (the owner: it builds) and stays listed, waiting on the ruling on unequal chamfers along a rim whose angle varies. 5158-fillet-round-just-past-a-10mm-face stays listed with its cause found: the round passes 5e-6 under the box's top back edge, inside the body's tolerance. Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 7 +++---- tests/kernel-cases/fillets/KNOWN_FAILING | 16 ++++++---------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/tests/kernel-cases/fillets/2893-chamfer-two-distances-elliptical-rim/expected.json b/tests/kernel-cases/fillets/2893-chamfer-two-distances-elliptical-rim/expected.json index b9bf3046b..646de2443 100644 --- a/tests/kernel-cases/fillets/2893-chamfer-two-distances-elliptical-rim/expected.json +++ b/tests/kernel-cases/fillets/2893-chamfer-two-distances-elliptical-rim/expected.json @@ -2,10 +2,9 @@ "sources": [ "tangency-labs/solidcraft#2893" ], - "what": "a cylinder r5 tilted 26.6 deg from Z cut flat at z = 10, its elliptical rim chamfered 1 and 2: built, or refused as not supported, never a wrong solid", + "what": "a cylinder r5 tilted 26.6 deg from Z cut flat at z = 10, its elliptical rim chamfered 1 and 2: one closed valid solid", "source": "invariants", - "method": "the axis (1, 0, 2)/sqrt5 through (0, 0, -10) meets z = 10 at (10, 0, 10); the rim is the ellipse there with semi-axes 5 (along y) and 5 sqrt5/2 (along x); (10, 5, 10) is on it. An unequal chamfer of an ellipse has no closed-form volume: one closed valid solid, or a refusal that names the rim as not supported yet (never an SMLib status).", - "outcome": "solid_or_refused", - "refusal": "not supported yet", + "method": "the axis (1, 0, 2)/sqrt5 through (0, 0, -10) meets z = 10 at (10, 0, 10); the rim is the ellipse there with semi-axes 5 (along y) and 5 sqrt5/2 (along x); (10, 5, 10) is on it. An unequal chamfer of an ellipse has no closed-form volume: one closed valid solid (the owner, 2026-10-31: it builds).", + "outcome": "solid", "body_count": 1 } diff --git a/tests/kernel-cases/fillets/KNOWN_FAILING b/tests/kernel-cases/fillets/KNOWN_FAILING index 19b8560ab..a2bba0078 100644 --- a/tests/kernel-cases/fillets/KNOWN_FAILING +++ b/tests/kernel-cases/fillets/KNOWN_FAILING @@ -2,22 +2,18 @@ # rig gate (.github/workflows/fillet-rig.yml) fails on a case that fails and is not listed here, # and on a listed case that passes: a fix removes its line in the same pull request. # Baseline: develop 242bbc89f with the SMLib fixes of 2026-10-29 (integration-overnight + b78bd4a), aarch64 Linux. -1080-fillet-equal-slope-basin-1-mm-rim-loop-4 not supported yet: a convex round past its face is not yet built by subtraction -1080-fillet-sloped-basin-0-5-mm-rim-r4-4-edges not supported yet: a convex round past its face is not yet built by subtraction -1080-fillet-sloped-basin-1-mm-rim-r4-2-edges not supported yet: a convex round past its face is not yet built by subtraction -1080-fillet-sloped-basin-1-mm-rim-r4-4-edges not supported yet: a convex round past its face is not yet built by subtraction +1080-fillet-equal-slope-basin-1-mm-rim-loop-4 builds to the analytic volume (rel 5e-9), but the continuity check (g1 at every blend seam) takes in the mitre's creases, G0 by the mitre ruling: the case's continuity seams need the owner's word +1080-fillet-sloped-basin-0-5-mm-rim-r4-4-edges builds to the analytic volume (rel 3e-9), but the continuity check (g1 at every blend seam) takes in the mitre's creases, G0 by the mitre ruling: the case's continuity seams need the owner's word +1080-fillet-sloped-basin-1-mm-rim-r4-2-edges builds to the analytic volume (rel 6e-9), but the continuity check (g1 at every blend seam) takes in the mitre's creases, G0 by the mitre ruling: the case's continuity seams need the owner's word +1080-fillet-sloped-basin-1-mm-rim-r4-4-edges builds to the analytic volume (rel 3e-9), but the continuity check (g1 at every blend seam) takes in the mitre's creases, G0 by the mitre ruling: the case's continuity seams need the owner's word 1207-fillet-bar-top-edge-after-boss-arc-round-r0-5 SMLib's check refuses the round: internal coincident control points in a B-spline curve (an internal pole) -190-fillet-disc-rim-past-its-2mm-wall SMLib status 1001: a convex round past its face is not yet built by subtraction 2893-chamfer-distance-and-angle-past-the-wall-refused refused for another reason: SMLib SM_ERR_INVALID_INPUT, not a check saying the angle runs past the wall -2893-chamfer-two-distances-elliptical-rim SMLib status 1001 on the elliptical rim's chamfer -2893-chamfer-two-distances-past-the-bottom SMLib status 1001: SmFilletNx1ClosedCorner cannot compute the closed rim's corner geometry, where the chamfer past the bottom rim should build the frustum +2893-chamfer-two-distances-elliptical-rim SMLib status 1001: the two arcs of the rim take their chamfer offsets each at its own midpoint, where the faces' angle differs (78.5 and 101.5 deg), and their chamfers do not meet at the tangent corners (held for the owner's ruling on unequal chamfers of a varying angle) 4782-fillet-bar-edge-wider-than-both-faces SMLib status 1001: a convex round past both its faces is not yet built by subtraction -5158-fillet-round-just-past-a-10mm-face SMLib status 1001: a convex round 0.01 past its face is not yet built by subtraction (10.0001-10.04 open) +5158-fillet-round-just-past-a-10mm-face SMLib status 1001: the round passes 5e-6 under the box's top back edge, inside the body's tolerance (1e-5), and subtracting its removal region maps that edge to two of the region's faces (SmTopologyIntersector); 10.0001-10.04 open 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 cov-chamfer-concave-edge-through-up-down-joined-squares SMLib status 1001 on the concave chamfer's tangent chain cov-chamfer-outer-corner-edge-of-a-shelled-box-with-a-lip SMLib's chamfer result is not a closed solid where it ends on the lip cov-fillet-arc-edge-on-an-oblique-cut-of-a-bar SMLib's check refuses the round: internal coincident control points in a B-spline curve every-block-cylinder-crease-top-edge-after-arc-round-r1 the r1 round's contact seam with the block's side face reads 60 degrees (the cylinder wall's normal) at its end on the crease (8.660, 5, 15.284): G0 where the round is built tangent -every-hole-top-rim-r12-past-plate-bottom SMLib status 1001: a convex round past its face on the tangent side is not yet built by subtraction From 09bc14dbd889099a6e2c5eb00d0a9413d9c1101e Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 01:34:06 -0400 Subject: [PATCH 04/81] Naming: test that a round of a round's end has no seam with that round's faces The r1 round of a block's top edge, chained onto the end curve of the r2 round of its arc at a cylinder (rig fillets/every-block-cylinder-crease- top-edge-after-arc-round-r1), ends where it runs into the cylinder. That edge is no seam of the r1 round: the cylinder is a face of the r2 round, not of the r1. blend_seams takes it for one today (the r2 round's name F3:blend:F1:+z|F2:side holds a | of its own), and the rig reads it as a contact seam at 60 degrees. Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/naming_history_tests.rs | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/crates/engine/src/naming_history_tests.rs b/crates/engine/src/naming_history_tests.rs index fe531a30f..18165a21a 100644 --- a/crates/engine/src/naming_history_tests.rs +++ b/crates/engine/src/naming_history_tests.rs @@ -375,6 +375,34 @@ fn blend_seams_are_a_rounds_contacts_and_the_blends_beside_it() { assert!(corner.iter().all(|x| x.kind == BlendSeamKind::Blend), "{seams:?}"); } +/// A round along a chain onto an earlier round's end has that round for one of its faces, and +/// that round's own faces are not its own: where it runs into the cylinder the earlier round +/// rolls on, its end face, is no seam of it (a block's arc at a cylinder rounded r2, then the +/// block's top edge with the round's end curve on its side face rounded r1; the earlier round's +/// name holds a `|` of its own, `F3:blend:F1:+z|F2:side`). +#[test] +fn a_round_of_a_round_s_end_has_no_seam_with_that_round_s_faces() { + use solidcraft_doc::naming::{blend_seams, face_names}; + let mut s = Session::default(); + run(&mut s, "solid.box", json!({"length": 40, "width": 10, "height": 15, "corner": [0, -5, 0], "body_name": "Block"})); + run(&mut s, "solid.cylinder", json!({"radius": 10, "height": 30, "base": [0, 0, 0], "operation": "join", "targets": ["Block"]})); + run(&mut s, "solid.fillet", json!({"edges": [[10, 0, 15]], "radius": 2})); + run(&mut s, "solid.fillet", json!({"edges": [[30, 5, 15]], "radius": 1})); + let state = s.model.state(); + let body = &state.bodies[0]; + let names = face_names(body); + let mesh = body.mesh(); + let sides = |edge: usize| -> Vec<&str> { mesh.edge_faces[edge].iter().filter_map(|f| names.get(*f as usize).map(String::as_str)).collect() }; + let seams = blend_seams(body); + assert!(!seams.is_empty()); + for seam in &seams { + let faces = sides(seam.edge); + if faces.iter().any(|n| n.starts_with("F2:side")) { + assert!(faces.iter().any(|n| n.starts_with("F3:blend:")), "a seam of the r2 round only: {faces:?}"); + } + } +} + /// A fillet of a shell's inner corners names those edges. Thinning the wall past the outer /// round removes them. The fillet must say the names are gone, not blend the seam nearest /// the old pick, which now sits on the axis of the inner round (#775). From 469a3b2f9d128f1521e1a3f06819e26308f7ea7b Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 01:34:06 -0400 Subject: [PATCH 05/81] Naming: a blend's seams split its edge's name at the | between its two faces A blend face's name holds the edge it replaced, |, and a side of that edge can be a blend face whose own name holds a |. Whether a face is a contact of the blend was read as the edge's name starting or ending with the face's name next to a |, so the r2 round's own face F2:side read as a contact of the r1 round F4:blend:F1:+y|F3:blend:F1:+z|F2:side. The edge's name is now split into its two faces, a blend side read whole as the two faces of its own edge. Co-Authored-By: Claude Opus 5.5 --- crates/doc/src/naming.rs | 44 +++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/crates/doc/src/naming.rs b/crates/doc/src/naming.rs index 96a59e0e2..a4b61e389 100644 --- a/crates/doc/src/naming.rs +++ b/crates/doc/src/naming.rs @@ -340,11 +340,7 @@ pub fn blend_seams(b: &ModelBody) -> Vec { all(j).into_iter().any(|name| { let (core, instance) = split_instance(name); let face = crate::piece_names::strip_qualifiers(core); - edges.iter().any(|(edge, at)| { - at == instance - && (edge.strip_prefix(face.as_str()).is_some_and(|r| r.starts_with('|')) - || edge.strip_suffix(face.as_str()).is_some_and(|r| r.ends_with('|'))) - }) + edges.iter().any(|(edge, at)| at == instance && edge_sides(edge).is_some_and(|(a, b)| a == face || b == face)) }) }; let mut out = Vec::new(); @@ -363,6 +359,44 @@ pub fn blend_seams(b: &ModelBody) -> Vec { out } +/// The two faces an edge name `|` joins. A blend face's own name holds the edge it +/// replaced (`F:blend:|`), so a side's name can hold `|` too: the split is the +/// one `|` outside every blend face's edge (`F1:+y` and `F3:blend:F1:+z|F2:side` for +/// `F1:+y|F3:blend:F1:+z|F2:side`). `None` for a name that is not two faces. +fn edge_sides(edge: &str) -> Option<(&str, &str)> { + let first = face_name_end(edge, 0)?; + if edge.as_bytes().get(first) != Some(&b'|') || face_name_end(edge, first + 1)? != edge.len() { + return None; + } + Some((edge.get(..first)?, edge.get(first + 1..)?)) +} + +/// Where the face name starting at byte `from` of `s` ends: at the next `|`, or for a blend face +/// past the two faces of the edge its name holds (and theirs, for blends of blends). +fn face_name_end(s: &str, from: usize) -> Option { + const MARK: &str = ":blend:"; + // The faces still to read: a blend face's name is read as the two of its edge. + let (mut pending, mut at) = (1usize, from); + loop { + let rest = s.get(at..)?; + let bar = rest.find('|').unwrap_or(rest.len()); + if let Some(m) = rest.get(..bar)?.find(MARK) { + pending += 1; + at += m + MARK.len(); + continue; + } + pending -= 1; + at += bar; + if pending == 0 { + return Some(at); + } + if s.as_bytes().get(at) != Some(&b'|') { + return None; + } + at += 1; + } +} + /// A name and the copy it names (`@F.`, a pattern's or a paste's copy of a /// tool face; empty for the original). fn split_instance(name: &str) -> (&str, &str) { From 1d818a2d1e400d53f90436728b171c9c858de935 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 02:44:31 -0400 Subject: [PATCH 06/81] Fillet rig: five refused blends build, off the known-failing list 926 (the chamfer ending on the boss's wall), the oblique cut's r0.1 round, the every-block r1 round (its seam with the cylinder is no contact seam, after the blend_seams fix), the up-down squares' concave chamfers and the shelled box's lip chamfer build with SMLib branch smlib-blend-refusals (f8650b8 and later). 1207 r0.5 passes SMLib's check on its rails now and stays listed for the next cause: its end rib on the boss, which starts where the round and the boss are tangent. Co-Authored-By: Claude Opus 5.5 --- tests/kernel-cases/fillets/KNOWN_FAILING | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/kernel-cases/fillets/KNOWN_FAILING b/tests/kernel-cases/fillets/KNOWN_FAILING index a2bba0078..d976a4a79 100644 --- a/tests/kernel-cases/fillets/KNOWN_FAILING +++ b/tests/kernel-cases/fillets/KNOWN_FAILING @@ -6,14 +6,10 @@ 1080-fillet-sloped-basin-0-5-mm-rim-r4-4-edges builds to the analytic volume (rel 3e-9), but the continuity check (g1 at every blend seam) takes in the mitre's creases, G0 by the mitre ruling: the case's continuity seams need the owner's word 1080-fillet-sloped-basin-1-mm-rim-r4-2-edges builds to the analytic volume (rel 6e-9), but the continuity check (g1 at every blend seam) takes in the mitre's creases, G0 by the mitre ruling: the case's continuity seams need the owner's word 1080-fillet-sloped-basin-1-mm-rim-r4-4-edges builds to the analytic volume (rel 3e-9), but the continuity check (g1 at every blend seam) takes in the mitre's creases, G0 by the mitre ruling: the case's continuity seams need the owner's word -1207-fillet-bar-top-edge-after-boss-arc-round-r0-5 SMLib's check refuses the round: internal coincident control points in a B-spline curve (an internal pole) +1207-fillet-bar-top-edge-after-boss-arc-round-r0-5 SMLib's check refuses the round: internal coincident control points in its end rib on the boss, which starts where the round and the boss are tangent (the boss's intersection marched there in spans down to 6e-8 mm) 2893-chamfer-distance-and-angle-past-the-wall-refused refused for another reason: SMLib SM_ERR_INVALID_INPUT, not a check saying the angle runs past the wall 2893-chamfer-two-distances-elliptical-rim SMLib status 1001: the two arcs of the rim take their chamfer offsets each at its own midpoint, where the faces' angle differs (78.5 and 101.5 deg), and their chamfers do not meet at the tangent corners (held for the owner's ruling on unequal chamfers of a varying angle) 4782-fillet-bar-edge-wider-than-both-faces SMLib status 1001: a convex round past both its faces is not yet built by subtraction 5158-fillet-round-just-past-a-10mm-face SMLib status 1001: the round passes 5e-6 under the box's top back edge, inside the body's tolerance (1e-5), and subtracting its removal region maps that edge to two of the region's faces (SmTopologyIntersector); 10.0001-10.04 open 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 -cov-chamfer-concave-edge-through-up-down-joined-squares SMLib status 1001 on the concave chamfer's tangent chain -cov-chamfer-outer-corner-edge-of-a-shelled-box-with-a-lip SMLib's chamfer result is not a closed solid where it ends on the lip -cov-fillet-arc-edge-on-an-oblique-cut-of-a-bar SMLib's check refuses the round: internal coincident control points in a B-spline curve -every-block-cylinder-crease-top-edge-after-arc-round-r1 the r1 round's contact seam with the block's side face reads 60 degrees (the cylinder wall's normal) at its end on the crease (8.660, 5, 15.284): G0 where the round is built tangent From 8550ac7e4045afbb2df7c1ba5bc204a0216d65de Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 01:28:23 -0400 Subject: [PATCH 07/81] Kernel rig: the trough and the pocket whose floors fall to a drain build SMLib now offsets a vertex where four faces meet (two walls and two facets at the floor's corners, four facets at the drain) to two vertices joined by a new edge (tangency-labs/smlib branch smlib-shells). Both volumes match their closed forms. The pocket's lining, hanging from the top's rim round the pocket, stands apart from the slab's outer walls with the cavity rising between them to the open top: the case says two shells in the one body. Co-Authored-By: Claude Opus 5.5 --- tests/kernel-cases/shell/KNOWN_FAILING | 2 -- .../expected.json | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/kernel-cases/shell/KNOWN_FAILING b/tests/kernel-cases/shell/KNOWN_FAILING index 224e4bf00..491e3688d 100644 --- a/tests/kernel-cases/shell/KNOWN_FAILING +++ b/tests/kernel-cases/shell/KNOWN_FAILING @@ -8,6 +8,4 @@ 616-shell-open-a-rib-side-face-of-a-lid SMLib status 1001 cov-shell-again-open-at-an-inner-wall-of-a-shelled-box SMLib status 1001 cov-shell-plate-with-a-hole-through-its-arc-side SMLib status 1001 where the hole's wall meets the arc side -cov-shell-pocket-whose-floor-falls-to-a-drain SMLib status 1001 where four faces meet at the pocket floor's corners -cov-shell-trough-whose-floor-falls-to-a-drain SMLib status 1001 where four faces meet at a corner cov-shell-up-down-joined-squares-open-at-a-side-wall SMLib status 1001 diff --git a/tests/kernel-cases/shell/cov-shell-pocket-whose-floor-falls-to-a-drain/expected.json b/tests/kernel-cases/shell/cov-shell-pocket-whose-floor-falls-to-a-drain/expected.json index a2c6c676f..1c60969ae 100644 --- a/tests/kernel-cases/shell/cov-shell-pocket-whose-floor-falls-to-a-drain/expected.json +++ b/tests/kernel-cases/shell/cov-shell-pocket-whose-floor-falls-to-a-drain/expected.json @@ -2,8 +2,9 @@ "sources": [], "what": "a slab 140 x 90 x 50 with a 30 mm pocket whose floor falls 1 deg from its edges to a central drain (four faces meet at each of the pocket floor's concave corners), shelled 3 mm open at the top", "source": "analytic", - "method": "The floor below z = 0 is a pyramid, apex at the centre h = 30 tan 1 deg = 0.523652 below: two triangular prisms (a triangle on XZ swept along y, one on YZ swept along x) intersected. Slab 140 x 90 x 50 less the pocket x 20..120, y 15..75 down to z = 20 and the pyramid below it: V0 = 630000 - (100 60 30 + 100 60 h/3). Shell 3 open at the top, offset faces extended to meet: the cavity is x 3..137, y 3..87 from z = 3 up to the top, except over the pocket's walls moved 3 out (x 17..123, y 12..78), where it rises only to the pocket's floor facets moved 3 down (their max, exactly over the cells where each is highest): cavity 297136.906075. V = 151815.790029", + "method": "The floor below z = 0 is a pyramid, apex at the centre h = 30 tan 1 deg = 0.523652 below: two triangular prisms (a triangle on XZ swept along y, one on YZ swept along x) intersected. Slab 140 x 90 x 50 less the pocket x 20..120, y 15..75 down to z = 20 and the pyramid below it: V0 = 630000 - (100 60 30 + 100 60 h/3). Shell 3 open at the top, offset faces extended to meet: the cavity is x 3..137, y 3..87 from z = 3 up to the top, except over the pocket's walls moved 3 out (x 17..123, y 12..78), where it rises only to the pocket's floor facets moved 3 down (their max, exactly over the cells where each is highest): cavity 297136.906075. The pocket's lining (its walls and floor, 3 thick, hanging from the top's rim round the pocket) stands apart from the slab's outer walls, the cavity rising between them to the open top: two lumps in the one body. V = 151815.790029", "body_count": 1, + "shells": 2, "volume_mm3": 151815.7900294403, "tolerance": { "rel": 1e-05 From 5f826a1a649f6225e59f3e6bfa090de3dc1fb118 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 01:43:36 -0400 Subject: [PATCH 08/81] Kernel rig: the plate with a hole through its arc side shells open at its far end SMLib's merge now intersects the offsets of an edge's faces where they could not be mated along it (the hole's offset poking out through the half-round side's; tangency-labs/solidcore#1795): one closed valid solid with the one face open, as the owner ruled. Co-Authored-By: Claude Opus 5.5 --- tests/kernel-cases/shell/KNOWN_FAILING | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/kernel-cases/shell/KNOWN_FAILING b/tests/kernel-cases/shell/KNOWN_FAILING index 491e3688d..22716291a 100644 --- a/tests/kernel-cases/shell/KNOWN_FAILING +++ b/tests/kernel-cases/shell/KNOWN_FAILING @@ -7,5 +7,4 @@ 545-shell-ring-cut-frame-open-at-an-outer-wall SMLib status 1001 616-shell-open-a-rib-side-face-of-a-lid SMLib status 1001 cov-shell-again-open-at-an-inner-wall-of-a-shelled-box SMLib status 1001 -cov-shell-plate-with-a-hole-through-its-arc-side SMLib status 1001 where the hole's wall meets the arc side cov-shell-up-down-joined-squares-open-at-a-side-wall SMLib status 1001 From 25692b119b65725e805babba1e9ac1591666199f Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 01:43:37 -0400 Subject: [PATCH 09/81] Kernel rig: the ring cut frame and the up-down join shell MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SMLib's inset now keeps only the regions that are cavity, not the one the offsets close where they overlap (between the two faces of #545's 0.5 floor, round the up-down join's two empty octants). The frame's core under the recess is hollowed to a sealed void, so the case says two shells and its closed form, 21044 mm³. Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 11 ++++++++--- tests/kernel-cases/shell/KNOWN_FAILING | 2 -- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/kernel-cases/shell/545-shell-ring-cut-frame-open-at-an-outer-wall/expected.json b/tests/kernel-cases/shell/545-shell-ring-cut-frame-open-at-an-outer-wall/expected.json index 1105ded79..dbbb7af82 100644 --- a/tests/kernel-cases/shell/545-shell-ring-cut-frame-open-at-an-outer-wall/expected.json +++ b/tests/kernel-cases/shell/545-shell-ring-cut-frame-open-at-an-outer-wall/expected.json @@ -3,7 +3,12 @@ "tangency-labs/solidcraft#545" ], "what": "the frame of examples/regressions/ring_cut_below_recess_thin_floor (a recess from the top, a ring cut from the bottom, a 0.5 mm floor between) shelled 0.5 mm open at the ring cut's outer wall (action matrix (apps/solidcraft-cli/tests/action_matrix.rs): regressions/ring_cut_below_recess_thin_floor, Frame/F6:side:l2 face.shell)", - "source": "invariants", - "method": "every wall of the frame is at least 0.5 thick except the 0.5 mm floor, which a 0.5 shell hollows to nothing there: whether that floor's cavity closes is the offset's choice, so no closed form: one closed valid solid is the right answer", - "body_count": 1 + "source": "analytic", + "method": "every wall of the frame is at least 0.5 thick except the 0.5 mm floor, which a 0.5 shell hollows to nothing: the floor stays solid, and the core under the recess (x, y 16..84, z 0..18) is hollowed to a sealed void, x, y 16.5..83.5, z 0.5..17.5, the floor and the core's walls between it and the open cavity. The cavity is that void, the ring between the squares 0.5..99.5 and 2..98 for z 0.5..18, the ring between 0.5..99.5 and 5.5..94.5 for z 18..29.5, and x 97.5..98, y 2..98, z 0.5..18 behind the open wall: 67^2 17 + (99^2 - 96^2) 17.5 + (99^2 - 89^2) 11.5 + 0.5 96 17.5 = 109010.5. V = 130054.5 - 109010.5 = 21044, the body's outer shell and the void's", + "body_count": 1, + "shells": 2, + "volume_mm3": 21044.0, + "tolerance": { + "rel": 1e-06 + } } diff --git a/tests/kernel-cases/shell/KNOWN_FAILING b/tests/kernel-cases/shell/KNOWN_FAILING index 22716291a..b948626dd 100644 --- a/tests/kernel-cases/shell/KNOWN_FAILING +++ b/tests/kernel-cases/shell/KNOWN_FAILING @@ -4,7 +4,5 @@ # Baseline: 45f69c0e5 with SMLib 60b1c6a, aarch64 Linux. 316-shell-open-beside-a-bottom-round-r2-4-as-large-as-the-wall-refused builds a shell where the rim has no thickness instead of refusing it 316-shell-open-beside-a-bottom-round-r2-as-large-as-the-wall-refused builds a shell where the rim has no thickness instead of refusing it -545-shell-ring-cut-frame-open-at-an-outer-wall SMLib status 1001 616-shell-open-a-rib-side-face-of-a-lid SMLib status 1001 cov-shell-again-open-at-an-inner-wall-of-a-shelled-box SMLib status 1001 -cov-shell-up-down-joined-squares-open-at-a-side-wall SMLib status 1001 From 18f08bf8347004a525282a6451c8611960bbc412 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 02:04:05 -0400 Subject: [PATCH 10/81] Kernel rig: #616's lid shells open at a rib's side, with the 0.15 lip SMLib keeps the skirt top's offset where its loops wind the other way under the opening, the cavity's floor (the owner's ruling of 2026-10-31: build it; a lip thinner than the wall is no break-through). Co-Authored-By: Claude Opus 5.5 --- tests/kernel-cases/shell/KNOWN_FAILING | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/kernel-cases/shell/KNOWN_FAILING b/tests/kernel-cases/shell/KNOWN_FAILING index b948626dd..f2b1fbc4e 100644 --- a/tests/kernel-cases/shell/KNOWN_FAILING +++ b/tests/kernel-cases/shell/KNOWN_FAILING @@ -4,5 +4,4 @@ # Baseline: 45f69c0e5 with SMLib 60b1c6a, aarch64 Linux. 316-shell-open-beside-a-bottom-round-r2-4-as-large-as-the-wall-refused builds a shell where the rim has no thickness instead of refusing it 316-shell-open-beside-a-bottom-round-r2-as-large-as-the-wall-refused builds a shell where the rim has no thickness instead of refusing it -616-shell-open-a-rib-side-face-of-a-lid SMLib status 1001 cov-shell-again-open-at-an-inner-wall-of-a-shelled-box SMLib status 1001 From 78b765e83638207b7047ea4571215d34f9abb3b6 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 02:07:16 -0400 Subject: [PATCH 11/81] Known failing tests: the action matrix's shells and chamfers as they fail with SMLib batch 7 The ring cut frame's and the up-down join's shells build now, and so do the up-down join's and modern-plastic's chamfers (SMLib smlib-blend-refusals). #616's lid in the corpus still fails SMLib's loop check, the shelled box shelled again at an inner wall is unchanged, and the oblique cut of a cylinder's fillet still fails SmSurfOfRevolution's Test #7: 3 actions of 7. Co-Authored-By: Claude Opus 5.5 --- tests/KNOWN_FAILING_TESTS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/KNOWN_FAILING_TESTS b/tests/KNOWN_FAILING_TESTS index d906f9091..be44c07bd 100644 --- a/tests/KNOWN_FAILING_TESTS +++ b/tests/KNOWN_FAILING_TESTS @@ -8,7 +8,7 @@ # for junit and junit-gpu-1..4), run `cargo xtask known-failing --junit `, then drop each # FIXED line and add each REGRESSION line with its cause, from the test's failure message. # Baseline: develop 38fd4a4f6 (CI run 41157648345, x86_64 Linux), after the SMLib eaa998a pin. -solidcraft-cli::action_matrix::action_matrix_sample 7 baseline actions fail on SMLib: 4 shells (status 1001 x3; Bad Loop Orient on issue-616-lid-ribs), 2 chamfers (status 1001 on up-down-join; not a closed solid on modern-plastic), 1 fillet (SmSurfOfRevolution Test #7 on oblique_cut_of_cylinder) +solidcraft-cli::action_matrix::action_matrix_sample 3 baseline actions fail on SMLib: 2 shells (Bad Loop Orient on issue-616-lid-ribs; status 1001 on filleted-shelled-box, shelled again open at an inner wall), 1 fillet (SmSurfOfRevolution Test #7 on oblique_cut_of_cylinder) solidcraft-cli::naming_corpus::corpus_designs_name_alike_every_build_and_fail_where_a_reference_is_gone oracle/83-boundary-loop-thicken does not load: step 8, SMLib thicken status 1001 solidcraft-engine::tests::fillet_fit_taper_closes_to_a_point SMLib fillet status 1001 on the taper fit (radius 16 closing to 0) solidcraft-engine::tests::robustness::shell_after_a_cut_whose_end_touches_an_arc_side SMLib shell status 1001 (a heavy test: pushes and nightly only) From f7d4e53442453f98677012c8a0711612fb52dfbc Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:56:36 -0400 Subject: [PATCH 12/81] SMLib: pin 26cc451 (batch 7: rounds past a rim, blend refusals that build, shells) Co-Authored-By: Claude Opus 5.5 --- crates/smlib/SMLIB_PREBUILT | 16 ++++++++-------- crates/smlib/SMLIB_REV | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/smlib/SMLIB_PREBUILT b/crates/smlib/SMLIB_PREBUILT index d8a4e3414..a06f8e51f 100644 --- a/crates/smlib/SMLIB_PREBUILT +++ b/crates/smlib/SMLIB_PREBUILT @@ -1,10 +1,10 @@ # Rust target, SHA-256 of smlib-.tar.gz in the release prebuilt- of # tangency-labs/smlib. Written by scripts/fetch-smlib.sh --pin; never edited by hand. -aarch64-apple-darwin d88d464dc6bee7f571a3dd489f3d3d5378c70c70ab43c8076b8f8d051c0c2413 -aarch64-pc-windows-msvc 492fb4d4f89d3330f520f8284123d8bea97a44340583e74d3a3f360197f683d6 -aarch64-unknown-linux-gnu 03f9ed4de21e32301e08d54d916b06a0520c99b2c990bf445e0f624b134dcd49 -i686-pc-windows-msvc f7bb4c871b82d2a33e0a173abe446351b00d06ae877e4f0a9681b561c686d320 -wasm32-unknown-unknown b9a556940efd1ac774c630a4634e170f0d66e004021d3af43598c72bf640f2d0 -x86_64-apple-darwin cd96282ce6f6a3660c266b0b9a9ef15015b2af3328e88baca699906f50a4d5c9 -x86_64-pc-windows-msvc fd9f752fe5398eccc21c4b1fd4a48f31cf0bcad2c1408e514308a6e5ec39ef06 -x86_64-unknown-linux-gnu a778927cd0f163cfededb2c3e34e43c04612dd8f0a1770e36f2de8eabaa7cd77 +aarch64-apple-darwin 3a782c2d9f89878fcb19c0ea9dfc29853204a6f6af37576722ed6334b06552c0 +aarch64-pc-windows-msvc f7a5cbe28c65a8d9dd88e22939ac3c12d5b54431ad16f1b0a1f6aa5882de2b9d +aarch64-unknown-linux-gnu bb1166f65589ce2c385550708992d0798e010d6689952ae07232aeec438e5879 +i686-pc-windows-msvc cadf6d7c35b3e20345e064d4369c777d62561afac5cf5b7be52da6dd6f9aa785 +wasm32-unknown-unknown 250573fd99e9b109ae9f8ac16ecd4a5e55dfcd13c060763c89167bc2ee4bd4b8 +x86_64-apple-darwin 13cf77518ccbd9a3095e0d2eaabb7844c94079aa4ef88ef10fe5a2bf1eb18438 +x86_64-pc-windows-msvc 44b729d524b85de5b0aba2f24cdb6a9e449d644ef3ea4129dabbf5338b835018 +x86_64-unknown-linux-gnu 7fe1a151932370b6ab4dee1e3fad30f62e4b9d2a1ac7bd1ca423061a15276a09 diff --git a/crates/smlib/SMLIB_REV b/crates/smlib/SMLIB_REV index 4576f5ba6..ebe434a06 100644 --- a/crates/smlib/SMLIB_REV +++ b/crates/smlib/SMLIB_REV @@ -1 +1 @@ -2fc375f4836c25cc87a4b2ee9082a2419f78939a +26cc45185b7ee6faba5b684f83d7bc2c53c1a559 From 5fe9df533094f8f23e3f03ba5e992fbe388f363c Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 09:15:21 -0400 Subject: [PATCH 13/81] Known failing tests: the shell after a cut whose end touches an arc side builds on SMLib batch 7 Co-Authored-By: Claude Opus 5.5 --- tests/KNOWN_FAILING_TESTS | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/KNOWN_FAILING_TESTS b/tests/KNOWN_FAILING_TESTS index be44c07bd..9a5c194fc 100644 --- a/tests/KNOWN_FAILING_TESTS +++ b/tests/KNOWN_FAILING_TESTS @@ -11,7 +11,6 @@ solidcraft-cli::action_matrix::action_matrix_sample 3 baseline actions fail on SMLib: 2 shells (Bad Loop Orient on issue-616-lid-ribs; status 1001 on filleted-shelled-box, shelled again open at an inner wall), 1 fillet (SmSurfOfRevolution Test #7 on oblique_cut_of_cylinder) solidcraft-cli::naming_corpus::corpus_designs_name_alike_every_build_and_fail_where_a_reference_is_gone oracle/83-boundary-loop-thicken does not load: step 8, SMLib thicken status 1001 solidcraft-engine::tests::fillet_fit_taper_closes_to_a_point SMLib fillet status 1001 on the taper fit (radius 16 closing to 0) -solidcraft-engine::tests::robustness::shell_after_a_cut_whose_end_touches_an_arc_side SMLib shell status 1001 (a heavy test: pushes and nightly only) solidcraft-kernel::blend::corner_tests::a_round_ending_in_an_earlier_round_matches_both_together SMLib fillet status 1001 on the round that ends in the earlier one solidcraft-kernel::blend::corner_tests::corner_blends_hold_at_any_scale at 0.01x the arc case's rounds remove 72.783 (scaled back) against 72.713 at 1x (9.6e-4 off, 1e-4 allowed) solidcraft-kernel::blend_corner::tests::issue2422_vertical_after_separate_bottom_rounds SMLib's check refuses the fillet: edge and vertex tolerance 0.97 against the body's 0.01 (#2422) From 8ec40d25e1d79287be1e5ebcc7f362ae082d80bf Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:47:57 -0400 Subject: [PATCH 14/81] Surface fair test: the energy falls strictly, the face moves, and the edges are read after the fair Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/cmd/surface.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/engine/src/cmd/surface.rs b/crates/engine/src/cmd/surface.rs index 4d1d01f6a..fe8662a34 100644 --- a/crates/engine/src/cmd/surface.rs +++ b/crates/engine/src/cmd/surface.rs @@ -1976,15 +1976,16 @@ mod tests { let before: Vec = st.body("Shell").unwrap().body.edges(0.1).unwrap().iter().flat_map(|e| e.points.clone()).collect(); assert!(!before.is_empty()); let area_before = area(&s, "Shell"); - // The fairing reports both energies, the second no larger than the first. + // The fairing reports both energies. The fit is not the fairest surface on its own rim, so + // the energy falls strictly and the face moves: its area changes. let reply = run(&mut s, "surface.fair", json!({"body": "Shell", "tolerance": 1.0, "iterations": 3})); let (energy_before, energy_after) = energies(&reply); let area_after = area(&s, "Shell"); - eprintln!("surface.fair: {reply}\nenergies {energy_before:e} → {energy_after:e}, area {area_before} → {area_after}"); - assert!(energy_before > 0.0 && energy_after <= energy_before, "{energy_before:e} → {energy_after:e}"); - // The face moved (the fit is not the flattest surface on its own rim), but not its edges: - // every boundary point of the body is where it was, bit for bit. - assert!((area_after - area_before).abs() > 0.0 || energy_after < energy_before); + assert!(energy_before > 0.0 && energy_after < energy_before, "{energy_before:e} → {energy_after:e}"); + assert_ne!(area_after, area_before, "the fairing did not move the face"); + // The edges do not move: every boundary point of the faired body is where it was, bit for + // bit, and the sheet is still the one face. + let st = s.world_state().unwrap(); let after: Vec = st.body("Shell").unwrap().body.edges(0.1).unwrap().iter().flat_map(|e| e.points.clone()).collect(); assert_eq!(after, before, "fairing must not move the face's edges"); assert_eq!(st.body("Shell").unwrap().body.face_count(), 1); From 697ea2ca85dcda0c737f8a07c040d1a708af0eee Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:48:34 -0400 Subject: [PATCH 15/81] Sketch scaling test: the first dimension sets l1 to 40 and scales both joined rectangles about the origin Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/cmd/sketch_ux_tests.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/cmd/sketch_ux_tests.rs b/crates/engine/src/cmd/sketch_ux_tests.rs index d1a34fef5..103fb7f80 100644 --- a/crates/engine/src/cmd/sketch_ux_tests.rs +++ b/crates/engine/src/cmd/sketch_ux_tests.rs @@ -1617,8 +1617,17 @@ fn the_first_dimension_scales_shapes_joined_by_a_constraint() { run(&mut s, "sketch.rectangle.two_point", json!({"p0": [0, 0], "p1": [20, 10]})); run(&mut s, "sketch.rectangle.two_point", json!({"p0": [30, 10], "p1": [45, 20]})); run(&mut s, "sketch.constraint.coincident", json!({"a": "l1.start", "b": "l5.start"})); + let before = sketch(&s); + let f = 40.0 / pt(&s, "l1.end").dist(pt(&s, "l1.start")); let out = run(&mut s, "sketch.dimension", json!({"entities": ["l1"], "value": "40 mm", "scale_sketch": true})); - assert!(out.get("scaled").is_some(), "{out}"); + assert!((out["scaled"].as_f64().unwrap() - f).abs() < 1e-6, "{out}"); + // l1 measures its value, and every point of both rectangles, the joined one too, scaled + // about the origin by the same factor: the joined rectangle keeps its shape at its scaled place. + assert!((pt(&s, "l1.end").dist(pt(&s, "l1.start")) - 40.0).abs() < 1e-6); + let after = sketch(&s); + for (p, q) in before.points.iter().zip(&after.points) { + assert!(q.pos.dist(p.pos * f) < 1e-6, "{} {:?} -> {:?}", p.id, p.pos, q.pos); + } } /// The cursor fallback shares the held solves' frame budget; a scripted drag can finish later. From e60cde8dcd2a6a02f48d7000d9294167fc5c80f8 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:49:23 -0400 Subject: [PATCH 16/81] Frames tests: a pick on a moved component or an instance removes the exact round and bore volumes Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/frames_tests.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/frames_tests.rs b/crates/engine/src/frames_tests.rs index e67f940a0..a3d5cd299 100644 --- a/crates/engine/src/frames_tests.rs +++ b/crates/engine/src/frames_tests.rs @@ -72,9 +72,13 @@ fn sketches_and_planes_move_with_the_component() { fn world_picks_map_into_the_component() { let mut s = moved_part(); let v0 = volume(&mut s); + assert!((v0 - 6000.0).abs() < 1e-6, "{v0}"); // 30 x 20 x 10 // The edge along X at the top front: world (65, 0, 10). run(&mut s, "solid.fillet", json!({"edges": [[65, 0, 10]], "radius": 2})); - assert!(volume(&mut s) < v0 - 1.0, "the fillet cut material"); + let filleted = volume(&mut s); + // A round of radius 2 along the 30 mm edge removes r²(1 − π/4) of section along its length. + let round = 4.0 * (1.0 - std::f64::consts::PI / 4.0) * 30.0; + assert!((v0 - filleted - round).abs() < 4e-7 * v0, "the fillet cut {} against {round}", v0 - filleted); // The modified face has no certified lineage; explicitly freeze its picked plane. // Its world pick still maps into the moved component exactly once. run(&mut s, "sketch.create", json!({"plane": {"face": [70, 10, 10],"fixed":true}, "name": "Pad"})); @@ -88,7 +92,10 @@ fn world_picks_map_into_the_component() { assert!(near(pad, Vec3::new(70.0, 10.0, 10.0)), "{pad:?}"); let v1 = volume(&mut s); let h = run(&mut s, "solid.hole", json!({"position": [60, 10, 10], "diameter": 4, "depth": 5})); - assert!(volume(&mut s) < v1 - 1.0, "the hole cut material: {h}"); + // A simple (flat-bottomed) hole: a cylinder of radius 2, 5 deep, clear of the round at y < 2. + let bore = std::f64::consts::PI * 4.0 * 5.0; + let v2 = volume(&mut s); + assert!((v1 - v2 - bore).abs() < 4e-7 * v1, "the hole cut {} against {bore}: {h}", v1 - v2); // A box made at world (100, 0, 0) in the active (moved) component shows there. run(&mut s, "solid.box", json!({"length": 5, "width": 5, "height": 5, "corner": [100, 0, 0], "operation": "new"})); let last = s.model.state().bodies.last().map(|b| b.name.clone()).unwrap(); @@ -108,7 +115,11 @@ fn picks_on_an_instance_map_through_its_placement() { // An edge of the second instance only (world y = 40). run(&mut s, "solid.fillet", json!({"edges": [[5, 40, 10]], "radius": 2})); let v1 = volume(&mut s); - assert!(v1 < v0 - 1.0, "{v0} {v1}"); + // Two 10 mm cubes; the round of radius 2 along one 10 mm edge of the component removes + // r²(1 − π/4)·10 from every instance, the picked one and the other. + assert!((v0 - 2000.0).abs() < 1e-6, "{v0}"); + let round = 4.0 * (1.0 - std::f64::consts::PI / 4.0) * 10.0; + assert!((v0 - v1 - 2.0 * round).abs() < 4e-7 * v0, "{v0} {v1}"); } /// (c) Moving a body into a moved component keeps it where it is in the world. From d7bbf09e0b1ee799247082aca5bafa7393d08b5d Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:49:46 -0400 Subject: [PATCH 17/81] Issue 1080 tests: the rib's rounds and the mitred corner chamfers and rounds have their exact volumes Co-Authored-By: Claude Opus 5.5 --- crates/kernel/src/issue_1080_tests.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/crates/kernel/src/issue_1080_tests.rs b/crates/kernel/src/issue_1080_tests.rs index 702a0495c..290e07ae7 100644 --- a/crates/kernel/src/issue_1080_tests.rs +++ b/crates/kernel/src/issue_1080_tests.rs @@ -92,7 +92,11 @@ fn chamfers_crossing_each_other_are_refused() { // Below half the width both build. let b = crate::chamfer(&rib, &edges, 1.5).unwrap(); assert!((b.volume_at(0.01).unwrap() - (3200.0 - 2.0 * 0.5 * 1.5 * 1.5 * 40.0)).abs() < 1e-6); - assert!(crate::fillet(&rib, &edges, 1.5).is_ok()); + // Two rounds of radius 1.5 along 40: each removes (1 − π/4)·1.5² of section. + let b = crate::fillet(&rib, &edges, 1.5).unwrap(); + let want = 3200.0 - 2.0 * (1.0 - std::f64::consts::FRAC_PI_4) * 2.25 * 40.0; + let v = crate::measure(&b).unwrap().volume; + assert!((v - want).abs() < 1e-6 * want, "{v} vs {want}"); } /// Edges meeting at a corner mitre: their chamfers overlap there and are not refused for it. @@ -100,6 +104,14 @@ fn chamfers_crossing_each_other_are_refused() { fn chamfers_meeting_at_a_corner_still_build() { let b = box_solid(Vec3::new(0.0, 0.0, 0.0), Vec3::new(20.0, 20.0, 20.0)).unwrap(); let edges = [Vec3::new(10.0, 0.0, 20.0), Vec3::new(20.0, 10.0, 20.0), Vec3::new(10.0, 20.0, 20.0), Vec3::new(0.0, 10.0, 20.0)]; - assert!(crate::chamfer(&b, &edges, 5.0).is_ok()); - assert!(crate::fillet(&b, &edges, 5.0).is_ok()); + // The chamfers leave the 20 x 20 x 15 block under a frustum from 20 x 20 to 10 x 10, 5 high: + // 6000 + (5/3)(400 + 100 + √(400·100)). + let v = crate::measure(&crate::chamfer(&b, &edges, 5.0).unwrap()).unwrap().volume; + let want = 6000.0 + 5.0 / 3.0 * (400.0 + 100.0 + 200.0); + assert!((v - want).abs() < 1e-6 * want, "{v} vs {want}"); + // The rounds: (1 − π/4)·25 of section along each edge's 10 mm between the corners, and in each + // 5 mm corner cube the two cylinders' intersection is kept, ∫₀⁵ (25 − w²) dw = 250/3 of 125. + let v = crate::measure(&crate::fillet(&b, &edges, 5.0).unwrap()).unwrap().volume; + let want = 8000.0 - 4.0 * (1.0 - std::f64::consts::FRAC_PI_4) * 25.0 * 10.0 - 4.0 * (125.0 - 250.0 / 3.0); + assert!((v - want).abs() < 1e-6 * want, "{v} vs {want}"); } From 0e51ffbff6a3f6226fe4e898cf1bb63d3b4e76ca Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:51:44 -0400 Subject: [PATCH 18/81] Engine tests: lip_after_boss checks each lip's and groove's exact band, hole_as_deep_as_the_plate each hole's exact bore Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/tests.rs | 48 ++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index e27f33782..4e9eb73fa 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -3116,9 +3116,13 @@ fn lip_after_boss() { run(&mut s, "plastic.boss", json!({"position": [70, 40, 2], "diameter": 7, "height": 12, "hole_diameter": 2.5})); let v0 = volume(&mut s); run(&mut s, "plastic.lip", json!({"face": [1, 25, 30], "width": 1, "height": 2})); - let v = volume(&mut s); - assert!(v > v0 + 1.0, "{v0} {v}"); - // Bosses up to the rim, with ribs, against a wall; lips, grooves and outside rims. + // The band inside the rim, 1 wide and 2 high: (78 × 48 − 76 × 46) × 2; the bosses stop + // at z = 14, well under it. + let inside = (78.0 * 48.0 - 76.0 * 46.0) * 2.0; + assert!(rel(volume(&mut s) - v0, inside) < 1e-6, "{}", volume(&mut s) - v0); + // Bosses up to the rim, with ribs, against a wall; lips, grooves and outside rims. None + // reaches the rim's bands, so each lip adds, and the groove (no gap) takes, its band: the + // inside one (78 × 48 − 76 × 46) × 2, the outside one (80 × 50 − 78 × 48) × 2. let bosses = [ json!({"position": [15, 15, 2], "diameter": 8, "height": 28, "hole_diameter": 3}), // Ribs out to the inner walls (15 − 4 − 9 = 2), and short of them. @@ -3127,13 +3131,14 @@ fn lip_after_boss() { json!({"position": [5.5, 25, 2], "diameter": 7, "height": 12, "hole_diameter": 2.5}), json!({"position": [40, 25, 2], "diameter": 8, "height": 20, "draft": "1 deg", "fillet": 1}), ]; + let outside = (80.0 * 50.0 - 78.0 * 48.0) * 2.0; let lips = [ - json!({"face": [1, 25, 30], "width": 1, "height": 2}), - json!({"face": [1, 25, 30], "width": 1, "height": 2, "type": "groove"}), - json!({"face": [1, 25, 30], "width": 1, "height": 2, "side": "outside"}), + (json!({"face": [1, 25, 30], "width": 1, "height": 2}), inside), + (json!({"face": [1, 25, 30], "width": 1, "height": 2, "type": "groove"}), -inside), + (json!({"face": [1, 25, 30], "width": 1, "height": 2, "side": "outside"}), outside), ]; for (i, b) in bosses.iter().enumerate() { - for (j, l) in lips.iter().enumerate() { + for (j, (l, band)) in lips.iter().enumerate() { let mut s = Session::default(); run(&mut s, "solid.box", json!({"length": 80, "width": 50, "height": 30})); run(&mut s, "solid.shell", json!({"faces": [[40, 25, 30]], "thickness": 2})); @@ -3142,7 +3147,7 @@ fn lip_after_boss() { let v0 = volume(&mut s); let r = s.execute("plastic.lip", l); assert!(r.is_ok(), "boss {i} lip {j}: {r:?}"); - assert!((volume(&mut s) - v0).abs() > 1.0, "boss {i} lip {j}"); + assert!(rel(volume(&mut s) - v0, *band) < 1e-6, "boss {i} lip {j}: {} vs {band}", volume(&mut s) - v0); } } } @@ -3168,16 +3173,24 @@ fn hole_as_deep_as_the_plate() { let mut s = Session::default(); run(&mut s, "solid.box", json!({"length": 50, "width": 25, "height": 10})); let v0 = volume(&mut s); + // The depth is to the drill point's shoulder: the bore, radius 3, runs the plate's 10 and the + // point is in the air below it. run(&mut s, "solid.hole", json!({"position": [25, 12.5, 10], "diameter": 6, "depth": 10, "type": "drilled"})); let v = volume(&mut s); - assert!(v < v0 - PI * 9.0 * 9.0 && v > v0 - PI * 9.0 * 10.0 - 1.0, "{v0} {v}"); - // Other sizes and places, the defaults, and a tapped hole. - for (i, p) in [ - json!({"position": [10, 10, 10], "diameter": 5, "depth": 10, "type": "drilled"}), - json!({"position": [40, 15, 10], "diameter": 5, "depth": 10}), - json!({"position": [12, 6, 10], "diameter": 8.5, "depth": 10}), - json!({"position": [30, 7, 10], "thread": "M6", "depth": 10}), - json!({"position": [20, 18, 10], "diameter": 4, "depth": 10, "tip_angle": 90}), + assert!((v0 - v - PI * 9.0 * 10.0).abs() < 4e-7 * v0, "{v0} {v}"); + // Other sizes and places, the defaults, and a tapped hole: each a through bore of its drill, + // 10 long. The 8.5 at (12, 6) overlaps the 5 at (10, 10) (√20 apart, under 2.5 + 4.25), so + // it takes its bore less the lens they share, 10 long. + let (r, q, d) = (2.5f64, 4.25f64, 20f64.sqrt()); + let lens = r * r * ((d * d + r * r - q * q) / (2.0 * d * r)).acos() + q * q * ((d * d + q * q - r * r) / (2.0 * d * q)).acos() + - 0.5 * ((-d + r + q) * (d + r - q) * (d - r + q) * (d + r + q)).sqrt(); + for (i, (p, cut)) in [ + (json!({"position": [10, 10, 10], "diameter": 5, "depth": 10, "type": "drilled"}), PI * 6.25 * 10.0), + (json!({"position": [40, 15, 10], "diameter": 5, "depth": 10}), PI * 6.25 * 10.0), + (json!({"position": [12, 6, 10], "diameter": 8.5, "depth": 10}), (PI * q * q - lens) * 10.0), + // M6 × 1: the tap maker's 5.0 drill. + (json!({"position": [30, 7, 10], "thread": "M6", "depth": 10}), PI * 6.25 * 10.0), + (json!({"position": [20, 18, 10], "diameter": 4, "depth": 10, "tip_angle": 90}), PI * 4.0 * 10.0), ] .into_iter() .enumerate() @@ -3185,7 +3198,8 @@ fn hole_as_deep_as_the_plate() { let before = volume(&mut s); let r = s.execute("solid.hole", &p); assert!(r.is_ok(), "{i} {p}: {r:?}"); - assert!(volume(&mut s) < before - 1.0, "{i} {p}"); + let v = volume(&mut s); + assert!((before - v - cut).abs() < 4e-7 * before, "{i} {p}: {} vs {cut}", before - v); } } From e03c72a3e9fd930484a2d0b76b5c53bf29a12ee5 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:51:50 -0400 Subject: [PATCH 19/81] Robustness tests: lip_after_boss and hole_as_deep_as_the_plate live once, in the engine's tests.rs with exact volumes Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/tests/robustness.rs | 70 +-------------------------- 1 file changed, 1 insertion(+), 69 deletions(-) diff --git a/crates/engine/src/tests/robustness.rs b/crates/engine/src/tests/robustness.rs index 4f126969e..7c5a22962 100644 --- a/crates/engine/src/tests/robustness.rs +++ b/crates/engine/src/tests/robustness.rs @@ -5,7 +5,7 @@ use std::f64::consts::PI; use serde_json::{Value, json}; -use super::{run, volume}; +use super::run; use crate::Session; use crate::fuzz; @@ -366,74 +366,6 @@ fn fixed_seeds_run_clean() { const FIXED_SEEDS: &[u64] = &[3, 5, 11, 16, 21, 29, 33, 35]; -/// A drilled hole as deep as the plate: the drill point breaks through the bottom. -#[test] -fn hole_as_deep_as_the_plate() { - let mut s = Session::default(); - run(&mut s, "solid.box", json!({"length": 50, "width": 25, "height": 10})); - let v0 = volume(&mut s); - run(&mut s, "solid.hole", json!({"position": [25, 12.5, 10], "diameter": 6, "depth": 10, "type": "drilled"})); - let v = volume(&mut s); - assert!(v < v0 - PI * 9.0 * 9.0 && v > v0 - PI * 9.0 * 10.0 - 1.0, "{v0} {v}"); - // Other sizes and places, the defaults, and a tapped hole. - for (i, p) in [ - json!({"position": [10, 10, 10], "diameter": 5, "depth": 10, "type": "drilled"}), - json!({"position": [40, 15, 10], "diameter": 5, "depth": 10}), - json!({"position": [12, 6, 10], "diameter": 8.5, "depth": 10}), - json!({"position": [30, 7, 10], "thread": "M6", "depth": 10}), - json!({"position": [20, 18, 10], "diameter": 4, "depth": 10, "tip_angle": 90}), - ] - .into_iter() - .enumerate() - { - let before = volume(&mut s); - let r = s.execute("solid.hole", &p); - assert!(r.is_ok(), "{i} {p}: {r:?}"); - assert!(volume(&mut s) < before - 1.0, "{i} {p}"); - } -} - -/// An enclosure built in the usual order: shell, bosses, then the lip on the rim. -#[test] -fn lip_after_boss() { - let mut s = Session::default(); - run(&mut s, "solid.box", json!({"length": 80, "width": 50, "height": 30})); - run(&mut s, "solid.shell", json!({"faces": [[40, 25, 30]], "thickness": 2})); - run(&mut s, "plastic.boss", json!({"position": [10, 10, 2], "diameter": 7, "height": 12, "hole_diameter": 2.5})); - run(&mut s, "plastic.boss", json!({"position": [70, 40, 2], "diameter": 7, "height": 12, "hole_diameter": 2.5})); - let v0 = volume(&mut s); - run(&mut s, "plastic.lip", json!({"face": [1, 25, 30], "width": 1, "height": 2})); - let v = volume(&mut s); - assert!(v > v0 + 1.0, "{v0} {v}"); - // Bosses up to the rim, with ribs, against a wall; lips, grooves and outside rims. - let bosses = [ - json!({"position": [15, 15, 2], "diameter": 8, "height": 28, "hole_diameter": 3}), - // Ribs out to the inner walls (15 − 4 − 9 = 2), and short of them. - json!({"position": [15, 15, 2], "diameter": 8, "height": 12, "ribs": 4, "rib_thickness": 1.5, "rib_length": 9}), - json!({"position": [15, 15, 2], "diameter": 8, "height": 12, "ribs": 4, "rib_thickness": 1.5, "rib_length": 6}), - json!({"position": [5.5, 25, 2], "diameter": 7, "height": 12, "hole_diameter": 2.5}), - json!({"position": [40, 25, 2], "diameter": 8, "height": 20, "draft": "1 deg", "fillet": 1}), - ]; - let lips = [ - json!({"face": [1, 25, 30], "width": 1, "height": 2}), - json!({"face": [1, 25, 30], "width": 1, "height": 2, "type": "groove"}), - json!({"face": [1, 25, 30], "width": 1, "height": 2, "side": "outside"}), - ]; - for (i, b) in bosses.iter().enumerate() { - for (j, l) in lips.iter().enumerate() { - let mut s = Session::default(); - run(&mut s, "solid.box", json!({"length": 80, "width": 50, "height": 30})); - run(&mut s, "solid.shell", json!({"faces": [[40, 25, 30]], "thickness": 2})); - let r = s.execute("plastic.boss", b); - assert!(r.is_ok(), "boss {i}: {r:?}"); - let v0 = volume(&mut s); - let r = s.execute("plastic.lip", l); - assert!(r.is_ok(), "boss {i} lip {j}: {r:?}"); - assert!((volume(&mut s) - v0).abs() > 1.0, "boss {i} lip {j}"); - } - } -} - /// A lip, a groove and an outside lip on the rim of a rounded, shelled enclosure (#29: the /// lip's walls continue the shell's walls, which a boolean join couldn't do). #[test] From 321e567244bfd4e400279af87c41946c01900f1f Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:52:02 -0400 Subject: [PATCH 20/81] Engine tests: loft_cut goes; loft_spacing's hollow elbow covers its section counts and more Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/tests.rs | 1 - crates/engine/src/tests/loft_cut.rs | 53 ----------------------------- 2 files changed, 54 deletions(-) delete mode 100644 crates/engine/src/tests/loft_cut.rs diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 4e9eb73fa..598d39e50 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -391,7 +391,6 @@ mod flush_join_loft; mod gltf_import; mod import_component; mod large_step_import; -mod loft_cut; mod loft_ring; mod loft_spacing; mod mirror_placed; diff --git a/crates/engine/src/tests/loft_cut.rs b/crates/engine/src/tests/loft_cut.rs deleted file mode 100644 index 7bb5dcf30..000000000 --- a/crates/engine/src/tests/loft_cut.rs +++ /dev/null @@ -1,53 +0,0 @@ -//! A hollow elbow: a tube lofted from round sections along an arc, minus a narrower tube lofted the -//! same way (and running 5 mm past both ends, so the cut opens the ends). -//! -//! The boolean gave up with "no result" for some section counts and not for their neighbours: the -//! points of the intersection curves lie on the seam between the two halves of a loft's circle, -//! where truck's search for their parameters (from the previous point's) failed. - -use std::f64::consts::PI; - -use super::*; - -/// `sections` circles of radius `radius` centred on an arc of radius `path` turning `angle` -/// (radians), in planes normal to the arc, lofted into the body `body`; `over` extends the -/// sections past both ends along the tangent. -fn tube(s: &mut Session, body: &str, radius: f64, path: f64, angle: f64, sections: usize, over: f64) { - let mut stations: Vec<[f64; 4]> = (0..sections) - .map(|i| { - let t = angle * i as f64 / (sections - 1) as f64; - [path * t.cos(), path * t.sin(), -t.sin(), t.cos()] - }) - .collect(); - if over > 0.0 { - let (a, b) = (stations[0], stations[sections - 1]); - stations.insert(0, [a[0] - over * a[2], a[1] - over * a[3], a[2], a[3]]); - stations.push([b[0] + over * b[2], b[1] + over * b[3], b[2], b[3]]); - } - let mut list = Vec::new(); - for (i, [x, y, tx, ty]) in stations.iter().enumerate() { - let name = format!("{body}{i}"); - run(s, "sketch.create", json!({"plane": {"origin": [x, y, 0], "x_dir": [0, 0, 1], "y_dir": [ty, -tx, 0]}, "name": name})); - run(s, "sketch.circle.center", json!({"center": [0, 0], "radius": radius})); - run(s, "sketch.finish", json!({})); - list.push(json!({"sketch": name})); - } - run(s, "solid.loft", json!({"sections": list, "operation": "new", "name": format!("Loft{body}"), "body_name": body})); -} - -#[test] -fn a_hollow_elbow_cut_from_two_lofted_tubes() { - let (path, outer, inner) = (100.0, 30.0, 18.0); - // Each of these gave up in truck's `parameter boundary` step. - for (degrees, sections) in [(60.0, 5), (60.0, 7), (90.0, 10), (120.0, 7), (120.0, 13)] { - let angle = degrees * PI / 180.0; - let mut s = Session::default(); - tube(&mut s, "Outer", outer, path, angle, sections, 0.0); - tube(&mut s, "Inner", inner, path, angle, sections, 5.0); - run(&mut s, "solid.combine", json!({"target": "Outer", "tools": ["Inner"], "operation": "cut", "name": "Hollow"})); - assert_eq!(s.model.state().bodies.len(), 1, "{degrees} degrees, {sections} sections"); - let want = PI * (outer * outer - inner * inner) * path * angle; - let got = volume(&mut s); - assert!(rel(got, want) < 3e-3, "{degrees} degrees, {sections} sections: {got} vs {want}"); - } -} From 94e67d4caf76674e1f8426e8517aef3d27c68fa3 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:53:02 -0400 Subject: [PATCH 21/81] Kernel loft test: the square-to-circle loft has the oracle's exact ruled volume, without printing Co-Authored-By: Claude Opus 5.5 --- crates/kernel/src/tests.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/crates/kernel/src/tests.rs b/crates/kernel/src/tests.rs index 641f5aad6..80e913288 100644 --- a/crates/kernel/src/tests.rs +++ b/crates/kernel/src/tests.rs @@ -726,9 +726,11 @@ fn loft_and_sweep() { let sq = Loop2::polygon(&[Vec2::new(-20.0, -20.0), Vec2::new(20.0, -20.0), Vec2::new(20.0, 20.0), Vec2::new(-20.0, 20.0)]); let top = Plane::XY.offset(40.0); let l = loft(&[(Plane::XY, sq), (top, Loop2::circle(Vec2::ZERO, 10.0))]).unwrap(); - let m = measure(&l).unwrap(); - println!("loft volume {} faces {:?}", m.volume, m.merged); - assert!(m.volume > 314.0 * 40.0 && m.volume < 1600.0 * 40.0); + // Ruled, each side on the rational quarter of the circle between its corners' directions: the + // section at t has area (1 − t)² A_S + t² A_C + t(1 − t) M, M = ½∮(S × C' + C × S'), so + // V = h (A_S/3 + A_C/3 + M/6) = 35080.725 (M = 1433.790 by quadrature; tests/oracle/17-loft). + let v = measure(&l).unwrap().volume; + assert!(rel(v, 35080.725116) < 1e-6, "{v}"); // A tube: up 30, quarter bend of radius 20, across 30. let disc = Region2 { outer: Loop2::circle(Vec2::ZERO, 3.0), holes: vec![] }; let path = [ @@ -742,9 +744,6 @@ fn loft_and_sweep() { PathSeg::Line { a: Vec3::new(20.0, 0.0, 50.0), b: Vec3::new(50.0, 0.0, 50.0) }, ]; let t = sweep(&Plane::XY, &disc, &path).unwrap(); - for tol in [0.1, 0.01, 0.003, 0.001] { - println!("tube tess {tol}: {}", t.mesh(&crate::MeshTolerance::chord(tol)).unwrap().measure().volume); - } let area = PI * 9.0; let expect = area * (30.0 + 30.0 + 20.0 * std::f64::consts::FRAC_PI_2); assert!(rel(measure(&t).unwrap().volume, expect) < 1e-3, "{} vs {expect}", measure(&t).unwrap().volume); From 4c7d4f5c0305b99d6cb001c9ce4320ae4e19d064 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:54:27 -0400 Subject: [PATCH 22/81] Tessellation lens test: the lens's triangles fill exactly the rhombus through its arcs' midpoints Co-Authored-By: Claude Opus 5.5 --- crates/kernel/src/tess/tests.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/kernel/src/tess/tests.rs b/crates/kernel/src/tess/tests.rs index 81730249d..befd7f9b3 100644 --- a/crates/kernel/src/tess/tests.rs +++ b/crates/kernel/src/tess/tests.rs @@ -862,7 +862,18 @@ fn a_face_bounded_by_two_short_arcs_keeps_an_area_to_mesh() { let made = ok(assemble(parts, false)); let (plan, _) = ok(plan(&made.brep, 0.5, None)); let lens = made.faces.first().and_then(|&f| plan.faces.get(f)).expect("the lens's plan"); - assert!(!lens.triangles.is_empty(), "the lens has triangles"); + // One round of halving puts a node at each arc's middle, (0, ±(r − c)) (the plane's (u, v) + // is its (x, y)): the triangles fill the rhombus with diagonals 2·half and 2(r − c). + let area: f64 = lens + .triangles + .iter() + .map(|t| { + let [a, b, c] = t.map(|i| lens.uv[i as usize]); + 0.5 * ((b[0] - a[0]) * (c[1] - a[1]) - (c[0] - a[0]) * (b[1] - a[1])) + }) + .sum(); + let rhombus = 2.0 * half * (r - c); + assert!((area - rhombus).abs() < 1e-9 * rhombus, "{area} vs {rhombus}"); } /// Half of a square pyramid's sides as one spline face: degree 1, closed round the square From 0d94d5f774e93d7592279e44e6914312fd325735 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:54:41 -0400 Subject: [PATCH 23/81] Pattern test: six chamfered holes take exactly five more holes' bore and chamfer rings Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/cmd/patterns_tests.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/cmd/patterns_tests.rs b/crates/engine/src/cmd/patterns_tests.rs index ce8b06f40..8f4678f54 100644 --- a/crates/engine/src/cmd/patterns_tests.rs +++ b/crates/engine/src/cmd/patterns_tests.rs @@ -926,8 +926,13 @@ fn circular_pattern_of_a_hole_and_its_chamfers_copies_all_of_them() { assert!(rel(v0, v1) < 1e-9); run(&mut s, "solid.pattern.circular", json!({"features": ["Bore", "TopChamfer", "BottomChamfer"], "axis": "Z", "count": 6, "angle": 360})); let v = volume(&mut s); - println!("{v1} -> {v}"); - assert!(v < v1 - 5.0 * 0.9 * (std::f64::consts::PI * 9.0 * 10.0), "pattern had no effect: {v1} -> {v}"); + // One chamfered hole takes its bore, π·3²·10, and two rings of the chamfer's triangle, + // 0.5 × 0.5 / 2, about the bore's axis at its centroid's radius 3 + 0.5/3 (Pappus). The + // copies, 20 apart on the radius 20, do not meet: the pattern takes five more. + let pi = std::f64::consts::PI; + let hole = pi * 9.0 * 10.0 + 2.0 * 2.0 * pi * (3.0 + 0.5 / 3.0) * 0.125; + assert!((v1 - (pi * 900.0 * 10.0 - hole)).abs() < 4e-7 * v1, "{v1}"); + assert!((v - (v1 - 5.0 * hole)).abs() < 4e-7 * v1, "{v1} -> {v}, expected {}", v1 - 5.0 * hole); } /// The features are copied in timeline order, not in the order they were picked in: a chamfer From c44cbe9acbc922f499788885f87cb8fe4f3f2d5b Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:55:02 -0400 Subject: [PATCH 24/81] Kernel pocket floor fillet test: the corner rounds and the floor loop round add their exact volumes, by Pappus at the corners Co-Authored-By: Claude Opus 5.5 --- crates/kernel/src/tests.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/crates/kernel/src/tests.rs b/crates/kernel/src/tests.rs index 80e913288..f73098b08 100644 --- a/crates/kernel/src/tests.rs +++ b/crates/kernel/src/tests.rs @@ -1380,18 +1380,23 @@ fn pocket_floor_loop_fillet() { cur = fillet(&cur, &[Vec3::new(65.0, 15.0, 16.0), Vec3::new(15.0, 15.0, 16.0), Vec3::new(65.0, 45.0, 16.0), Vec3::new(15.0, 45.0, 16.0)], 5.0) .unwrap(); let v1 = measure(&cur).unwrap().volume; + // The 50 x 30 x 8 pocket, less the four concave R5 rounds of its corners filling r²(1 − π/4) + // of section along their 8. + let want1 = 80.0 * 60.0 * 20.0 - 50.0 * 30.0 * 8.0 + 4.0 * 25.0 * (1.0 - PI / 4.0) * 8.0; + assert!(rel(v1, want1) < 1e-6, "{v1} vs {want1}"); let floor: Vec = [(40.0, 15.0), (65.0, 30.0), (40.0, 45.0), (15.0, 30.0)].iter().map(|(x, y)| Vec3::new(*x, *y, 12.0)).collect(); let mut pts = floor.clone(); let d = 5.0 - 5.0 / 2f64.sqrt(); pts.extend([(15.0 + d, 15.0 + d), (65.0 - d, 15.0 + d), (65.0 - d, 45.0 - d), (15.0 + d, 45.0 - d)].iter().map(|(x, y)| Vec3::new(*x, *y, 12.0))); let f = fillet(&cur, &pts, 2.0).unwrap(); let m = measure(&f).unwrap(); - // Added: the fillet profile (r²(1 − π/4)) swept along the floor outline (Pappus for the - // corners: the profile's centroid sits 2 − 4·2/(3(4 − π))·… inward; check loosely). - let straight = 2.0 * (40.0 + 20.0); - let added_lines = (4.0 - PI) * straight; - assert!(m.volume > v1 + added_lines && m.volume < v1 + added_lines + 4.0 * 2.0 * PI * 5.0, "{} {}", m.volume, v1); - println!("pocket: {:?} vol {}", m.merged, m.volume); + // Added: the R2 round's section, a = r²(1 − π/4), along the floor outline's straight 2(40 + 20), + // and round its four R5 corners by Pappus: a quarter turn each at the radius of the section's + // centroid, which sits r(10 − 3π)/(3(4 − π)) in from the wall, at 5 from the corner's axis. + let a = 4.0 * (1.0 - PI / 4.0); + let centroid = 5.0 - 2.0 * (10.0 - 3.0 * PI) / (3.0 * (4.0 - PI)); + let want = v1 + a * 2.0 * (40.0 + 20.0) + 4.0 * a * (PI / 2.0) * centroid; + assert!(rel(m.volume, want) < 1e-6, "{} vs {want}", m.volume); } #[test] From 16bef10974ebbba73704541ffc4a71c63d2b320f Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:56:06 -0400 Subject: [PATCH 25/81] Shell regression: the saddle-corner shell opened on the top box's side has its exact volume Co-Authored-By: Claude Opus 5.5 --- crates/engine/tests/shell_regressions.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/engine/tests/shell_regressions.rs b/crates/engine/tests/shell_regressions.rs index 213ee9146..3abd8b70c 100644 --- a/crates/engine/tests/shell_regressions.rs +++ b/crates/engine/tests/shell_regressions.rs @@ -46,6 +46,13 @@ fn shell_box_on_box_overhanging_saddle_corner() { let mut s = box_on_box(2.5); run(&mut s, "solid.shell", json!({"faces": [[7.5, 17.5, 38.75]], "thickness": 1.5})); sound(&s); + // The bottom closed and the top box's left face x = 7.5 open, so the cavity in the top box + // runs out to it: [1.5, 23.5] × [1.5, 16] × [1.5, 33.5] in the lower box, + // [7.5, 21] × [1.5, 16] × [33.5, 41] over it and [7.5, 21] × [16, 18.5] × [36.5, 41] in the + // overhang, out of the solid's 25 × 17.5 × 35 + 15 × 20 × 7.5. + let want = 25.0 * 17.5 * 35.0 + 15.0 * 20.0 * 7.5 - 22.0 * 14.5 * 32.0 - 13.5 * 14.5 * 7.5 - 13.5 * 2.5 * 4.5; + let got = volume(&s); + assert!((got - want).abs() < 1e-6 * want, "shell volume {got}, want {want}"); } /// The same saddle corner with the bottom open: every face round the corner moves, and the From 699ddb6b3da2b99dd17eb2b7f19705aa48be12f4 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:56:36 -0400 Subject: [PATCH 26/81] SMLib history test: every operand's order is the identity on its record's faces and edges Co-Authored-By: Claude Opus 5.5 --- crates/kernel/src/boolean_history_tests.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/kernel/src/boolean_history_tests.rs b/crates/kernel/src/boolean_history_tests.rs index 852564a14..22db43f17 100644 --- a/crates/kernel/src/boolean_history_tests.rs +++ b/crates/kernel/src/boolean_history_tests.rs @@ -446,9 +446,16 @@ mod smlib { crate::sphere(Vec3::new(10.0, 10.0, 10.0), 4.0).unwrap(), crate::torus(Vec3::new(0.0, 0.0, 0.0), 10.0, 2.0).unwrap(), ]; + // SMLib imports a record's faces and edges in the record's order, and the record is + // already canonical: SMLib's face and edge i are the record's i (the order is the + // identity, or empty, which says the same), with no edge split into pieces. for (i, b) in bodies.iter().enumerate() { let (_, order) = crate::native::smlib_body_ordered(b).unwrap(); - assert!(order.is_some(), "body {i}"); + let order = order.unwrap_or_else(|| panic!("body {i}: no order")); + let identity = |to: &[usize], n: usize| to.is_empty() || to.iter().copied().eq(0..n); + assert!(identity(&order.faces, b.face_count()), "body {i}: faces {:?}", order.faces); + assert!(identity(&order.edges, b.edge_count()), "body {i}: edges {:?}", order.edges); + assert!(order.pieces.is_empty(), "body {i}: {:?}", order.pieces); } } From ec421252d7e23577249c49c128924f0734d51d55 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:56:53 -0400 Subject: [PATCH 27/81] Boolean history tests: the SMLib module's box-minus-sphere, box-minus-cylinder and box-union-box copies go; the top-level ones check more Co-Authored-By: Claude Opus 5.5 --- crates/kernel/src/boolean_history_tests.rs | 34 ---------------------- 1 file changed, 34 deletions(-) diff --git a/crates/kernel/src/boolean_history_tests.rs b/crates/kernel/src/boolean_history_tests.rs index 22db43f17..279762ac0 100644 --- a/crates/kernel/src/boolean_history_tests.rs +++ b/crates/kernel/src/boolean_history_tests.rs @@ -459,40 +459,6 @@ mod smlib { } } - #[test] - fn box_minus_sphere() { - let a = boxed(0.0, 0.0, 0.0, 10.0, 10.0, 10.0); - let b = crate::sphere(Vec3::new(10.0, 10.0, 10.0), 4.0).unwrap(); - let r = through_smlib(&a, &b, BoolOp::Cut); - let h = verified(&r, &[&a, &b], 0.02); - // The three notched box faces, the three untouched, and the sphere's patches inside. - assert_eq!(changes(h)[..2].iter().sum::() + changes(h)[2], h.faces.len(), "{}", show(h)); - assert!( - meets(h).iter().all(|(x, y)| matches!((x, y), (FaceOrigin::Face { operand: 0, .. }, FaceOrigin::Face { operand: 1, .. }))), - "{}", - show(h) - ); - } - - #[test] - fn box_minus_cylinder() { - let a = boxed(0.0, 0.0, 0.0, 10.0, 10.0, 10.0); - let b = crate::cylinder(Vec3::new(5.0, 5.0, -1.0), Vec3::Z, 2.0, 12.0).unwrap(); - let r = through_smlib(&a, &b, BoolOp::Cut); - let h = verified(&r, &[&a, &b], 0.01); - assert!(from(h, face(0, 0)).len() + from(h, face(0, 1)).len() >= 1, "{}", show(h)); - } - - #[test] - fn box_union_box() { - let a = boxed(0.0, 0.0, 0.0, 10.0, 10.0, 10.0); - let b = boxed(5.0, 2.0, 2.0, 15.0, 8.0, 8.0); - let r = through_smlib(&a, &b, BoolOp::Union); - let h = verified(&r, &[&a, &b], 0.02); - assert_eq!(h.faces.len(), 11, "{}", show(h)); - assert_eq!(meets(h).len(), 4, "{}", show(h)); - } - /// Cubes sharing an edge, and cubes sharing a vertex: SMLib's union touches itself there; /// it comes back as two closed shells, the shared edge and vertices split into one copy per /// cube, each copy with its edge's history (verified against the geometry). The copies say From f87f22874f4bec36485ec2209aec699fdfd63199 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:57:45 -0400 Subject: [PATCH 28/81] Modify history tests: shell, offset and thicken are one test each through the public API, with the volumes, refusals and history the SMLib copies checked Co-Authored-By: Claude Opus 5.5 --- crates/kernel/src/modify_history_tests.rs | 115 +++++++--------------- 1 file changed, 34 insertions(+), 81 deletions(-) diff --git a/crates/kernel/src/modify_history_tests.rs b/crates/kernel/src/modify_history_tests.rs index 7c5b503a5..45d2d36f2 100644 --- a/crates/kernel/src/modify_history_tests.rs +++ b/crates/kernel/src/modify_history_tests.rs @@ -55,6 +55,10 @@ fn face_at(b: &Body, p: Vec3) -> usize { (0..b.face_count()).min_by(|x, y| to_face(&m, *x, p).total_cmp(&to_face(&m, *y, p))).unwrap() } +fn volume(b: &Body) -> f64 { + crate::measure(b).unwrap().volume +} + fn cube() -> Body { box_solid(Vec3::ZERO, Vec3::new(40.0, 30.0, 20.0)).unwrap() } @@ -227,6 +231,8 @@ fn shell_lines_the_walls_with_offsets() { let b = cube(); let top = Vec3::new(20.0, 15.0, 20.0); let r = crate::shell(&b, &[top], 2.0).unwrap(); + // The cavity is 36 x 26 x 18 (the floor 2 thick, the top open). + assert!((volume(&r) - (24000.0 - 36.0 * 26.0 * 18.0)).abs() < 1e-3, "{}", volume(&r)); let h = verified(&r, &b, reach(2.0)); // Five inner walls, each an offset of the face it lines; the top is left as a rim. let top = face_at(&b, top); @@ -236,7 +242,7 @@ fn shell_lines_the_walls_with_offsets() { assert_eq!(h.faces[walls[0]].change, Change::Generated); } assert!(with(h, &[FaceOrigin::Offset { operand: 0, face: top }]).is_empty()); - assert_eq!(changes(h), [0, 6, 0, 0, 5]); + assert_eq!(changes(h), [0, 6, 0, 0, 5], "{h:?}"); } #[test] @@ -306,10 +312,17 @@ fn offset_moves_a_face() { let b = ell(); let top = Vec3::new(5.0, 5.0, 20.0); let r = crate::offset_faces(&b, &[top], 3.0).unwrap(); + // The L's plan is 40 x 15 + 15 x 15 = 825; 23 high. + assert!((volume(&r) - 825.0 * 23.0).abs() < 1e-3, "{}", volume(&r)); let h = verified(&r, &b, Reach { made: 0.0, moved: 3.0 * 1.1 }); assert_eq!(h.faces.len(), b.face_count()); - assert_eq!(with(h, &[face(face_at(&b, top))]).len(), 1); + let moved = with(h, &[face(face_at(&b, top))]); + assert_eq!(moved.len(), 1); + assert_eq!(h.faces[moved[0]].change, Change::Modified); assert!(h.edges.iter().all(|e| matches!(e.origins.as_slice(), [EdgeOrigin::Edge { .. }]))); + // Into the body by its whole height: nothing is left behind the face. + let e = crate::offset_faces(&b, &[top], -20.0).unwrap_err(); + assert!(e.to_string().contains("no room"), "{e}"); } #[test] @@ -403,10 +416,24 @@ fn surfaces_keep_their_faces() { fn thicken_offsets_the_surface() { let s = crate::patch_region(&Plane::XY, &Region2 { outer: square(0.0, 0.0, 10.0, 10.0), holes: vec![] }).unwrap(); let t = crate::thicken(&s, 2.0, false).unwrap(); + assert!((volume(&t) - 200.0).abs() < 1e-6, "{}", volume(&t)); + // Along the sheet's normal (+Z). + let m = t.mesh(&crate::MeshTolerance::chord(TOL)).unwrap(); + let (lo, hi) = m.positions.iter().fold((f64::MAX, f64::MIN), |(lo, hi), p| (lo.min(p.z), hi.max(p.z))); + assert!(lo.abs() < 1e-9 && (hi - 2.0).abs() < 1e-9, "z {lo}..{hi}"); let h = verified(&t, &s, reach(2.0)); - assert_eq!(with(h, &[face(0)]).len(), 1); - assert_eq!(with(h, &[FaceOrigin::Offset { operand: 0, face: 0 }]).len(), 1); - assert_eq!(blends(h).len(), 4); + assert_eq!(with(h, &[face(0)]).len(), 1, "{h:?}"); + assert_eq!(with(h, &[FaceOrigin::Offset { operand: 0, face: 0 }]).len(), 1, "{h:?}"); + assert_eq!(blends(h).len(), 4, "{h:?}"); + let both = crate::thicken(&s, 2.0, true).unwrap(); + let m = both.mesh(&crate::MeshTolerance::chord(TOL)).unwrap(); + let (lo, hi) = m.positions.iter().fold((f64::MAX, f64::MIN), |(lo, hi), p| (lo.min(p.z), hi.max(p.z))); + assert!((lo + 1.0).abs() < 1e-9 && (hi - 1.0).abs() < 1e-9, "z {lo}..{hi}"); + let h = verified(&both, &s, reach(1.0)); + assert_eq!(with(h, &[FaceOrigin::Offset { operand: 0, face: 0 }]).len(), 2, "{h:?}"); + assert_eq!(blends(h).len(), 4, "{h:?}"); + let against = crate::thicken(&s, -2.0, false).unwrap(); + assert!((volume(&against) - 200.0).abs() < 1e-6); } #[test] @@ -494,44 +521,13 @@ fn chamfer_after_box_cuts() { } } -/// Shell, offset faces and thicken through SMLib (`crate::offset_backend`), their histories -/// checked against the geometry as truck's are, and their numbers against the analytic ones. +/// Shell, offset faces and draft straight through `crate::offset_backend`: refusals, and their +/// histories checked against the geometry and their numbers against the analytic ones. #[cfg(feature = "smlib")] mod smlib { use super::*; use crate::offset_backend; - fn volume(b: &Body) -> f64 { - crate::measure(b).unwrap().volume - } - - #[test] - fn shell_lines_the_walls_with_offsets() { - let b = cube(); - let top = Vec3::new(20.0, 15.0, 20.0); - let r = offset_backend::shell(&b, &[top], 2.0).unwrap(); - // The cavity is 36 x 26 x 18 (the floor 2 thick, the top open). - assert!((volume(&r) - (24000.0 - 36.0 * 26.0 * 18.0)).abs() < 1e-3, "{}", volume(&r)); - let h = verified(&r, &b, reach(2.0)); - let top = face_at(&b, top); - for f in (0..6).filter(|f| *f != top) { - let walls = with(h, &[FaceOrigin::Offset { operand: 0, face: f }]); - assert_eq!(walls.len(), 1, "{h:?}"); - assert_eq!(h.faces[walls[0]].change, Change::Generated); - } - assert!(with(h, &[FaceOrigin::Offset { operand: 0, face: top }]).is_empty()); - assert_eq!(changes(h), [0, 6, 0, 0, 5], "{h:?}"); - } - - #[test] - fn shell_of_a_body_that_is_not_convex() { - let b = ell(); - let r = offset_backend::shell(&b, &[Vec3::new(5.0, 5.0, 20.0)], 2.0).unwrap(); - let h = verified(&r, &b, reach(2.0 * 1.5)); - let offsets = h.faces.iter().filter(|f| matches!(f.origins.as_slice(), [FaceOrigin::Offset { .. }])).count(); - assert_eq!(offsets, 7, "{h:?}"); - } - /// tangency-labs/solidcore#380: a closed shell whose wall leaves no room inside the body is /// refused before SMLib's offset sees it, by the body's own inradius (the L's legs are 15 /// wide, the largest ball fits at the inner corner: 15 * sqrt(2) / (1 + sqrt(2)) = 8.79), @@ -573,25 +569,6 @@ mod smlib { assert!(e.contains("the 1.5 mm walls would meet along a line"), "{e}"); } - #[test] - fn offset_moves_a_face() { - let b = ell(); - let top = Vec3::new(5.0, 5.0, 20.0); - let healed = crate::boolean_record::healed(&b).unwrap(); - let chosen = [face_at(&healed, top)]; - let r = offset_backend::offset_faces(&healed, &chosen, 3.0).unwrap(); - // The L's plan is 40 x 15 + 15 x 15 = 825; 23 high. - assert!((volume(&r) - 825.0 * 23.0).abs() < 1e-3, "{}", volume(&r)); - let h = verified(&r, &healed, Reach { made: 0.0, moved: 3.0 * 1.1 }); - assert_eq!(h.faces.len(), healed.face_count()); - let moved = with(h, &[face(chosen[0])]); - assert_eq!(moved.len(), 1); - assert_eq!(h.faces[moved[0]].change, Change::Modified); - // Into the body by its whole height: nothing is left behind the face. - let e = offset_backend::offset_faces(&healed, &chosen, -20.0).unwrap_err(); - assert!(e.to_string().contains("no room"), "{e}"); - } - #[test] fn draft_tilts_a_side_and_keeps_its_name() { let b = cube(); @@ -616,28 +593,4 @@ mod smlib { let e = offset_backend::draft(&b, &[Vec3::new(20.0, 15.0, 20.0)], &Plane::XY, Vec3::Z, 5.0 * deg).unwrap_err(); assert!(e.to_string().contains("not supported yet"), "{e}"); } - - #[test] - fn thicken_offsets_the_surface() { - let s = crate::patch_region(&Plane::XY, &Region2 { outer: square(0.0, 0.0, 10.0, 10.0), holes: vec![] }).unwrap(); - let t = offset_backend::thicken(&s, 2.0, false).unwrap(); - assert!((volume(&t) - 200.0).abs() < 1e-6, "{}", volume(&t)); - // Along the sheet's normal (+Z). - let m = t.mesh(&crate::MeshTolerance::chord(TOL)).unwrap(); - let (lo, hi) = m.positions.iter().fold((f64::MAX, f64::MIN), |(lo, hi), p| (lo.min(p.z), hi.max(p.z))); - assert!(lo.abs() < 1e-9 && (hi - 2.0).abs() < 1e-9, "z {lo}..{hi}"); - let h = verified(&t, &s, reach(2.0)); - assert_eq!(with(h, &[face(0)]).len(), 1, "{h:?}"); - assert_eq!(with(h, &[FaceOrigin::Offset { operand: 0, face: 0 }]).len(), 1, "{h:?}"); - assert_eq!(blends(h).len(), 4, "{h:?}"); - let both = offset_backend::thicken(&s, 2.0, true).unwrap(); - let m = both.mesh(&crate::MeshTolerance::chord(TOL)).unwrap(); - let (lo, hi) = m.positions.iter().fold((f64::MAX, f64::MIN), |(lo, hi), p| (lo.min(p.z), hi.max(p.z))); - assert!((lo + 1.0).abs() < 1e-9 && (hi - 1.0).abs() < 1e-9, "z {lo}..{hi}"); - let h = verified(&both, &s, reach(1.0)); - assert_eq!(with(h, &[FaceOrigin::Offset { operand: 0, face: 0 }]).len(), 2, "{h:?}"); - assert_eq!(blends(h).len(), 4, "{h:?}"); - let against = offset_backend::thicken(&s, -2.0, false).unwrap(); - assert!((volume(&against) - 200.0).abs() < 1e-6); - } } From f81c4b1575850d769ff5ee7176de876cecdaefd9 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:58:21 -0400 Subject: [PATCH 29/81] Chamfer history test: the chamfer after each box cut is exactly one face on the painted block too Co-Authored-By: Claude Opus 5.5 --- crates/kernel/src/modify_history_tests.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/kernel/src/modify_history_tests.rs b/crates/kernel/src/modify_history_tests.rs index 45d2d36f2..3cb4910b8 100644 --- a/crates/kernel/src/modify_history_tests.rs +++ b/crates/kernel/src/modify_history_tests.rs @@ -511,9 +511,9 @@ fn chamfer_after_box_cuts() { for (name, cut, tool) in box_cuts_of(&b) { let r = crate::chamfer(&cut, &[at], 2.0).unwrap(); let h = verified(&r, &cut, reach(2.0 * 1.5)); - // On the painted block the chamfer face keeps the boundaries the cut left. - let faces = with(h, &[edge(edge_at(&cut, at))]).len(); - assert!(if painted { faces >= 1 } else { faces == 1 }, "{name} (painted: {painted}): {h:?}"); + // The picked edge is one edge of the cut body on either block (its round is one face, + // `fillet_after_box_cuts`), so its chamfer is one face too. + assert_eq!(with(h, &[edge(edge_at(&cut, at))]).len(), 1, "{name} (painted: {painted}): {h:?}"); let mut through = h.clone(); through.substitute(0, cut.history().unwrap()).unwrap(); through.check(&r, &[&b, &tool]).unwrap(); From 9c0d6bd1fd29726cfd9667087893685386a9f420 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:58:38 -0400 Subject: [PATCH 30/81] Grid test: a pole side's face is the five triangles fanned from its one grid node, none degenerate Co-Authored-By: Claude Opus 5.5 --- crates/kernel/src/tess/grid.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/kernel/src/tess/grid.rs b/crates/kernel/src/tess/grid.rs index 1da7da392..b89ecd923 100644 --- a/crates/kernel/src/tess/grid.rs +++ b/crates/kernel/src/tess/grid.rs @@ -323,8 +323,15 @@ mod tests { // A triangle-like patch whose top side is a pole (two copies of one point in 3D). let b = vec![[0.0, 0.0], [0.5, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0]]; let Some(q) = quad(&b) else { panic!("a quad") }; - let Some((_, tris)) = structured(&b, &q, &[0.5], &[0.5]) else { panic!("meshes") }; - assert!(!tris.is_empty()); + let Some((extra, tris)) = structured(&b, &q, &[0.5], &[0.5]) else { panic!("meshes") }; + // One grid node, (0.5, 0.5), fanned to each of the five boundary segments: one triangle + // each, the pole's single segment among them, every one of positive area, tiling the box. + assert_eq!(extra, [[0.5, 0.5]]); + assert_eq!(tris.len(), 5); + let mut uv = b.clone(); + uv.extend(extra); + assert!(tris.iter().all(|t| signed_area(&uv, *t).is_some_and(|a| a > 0.0))); + assert!((area(&uv, &tris) - 1.0).abs() < 1e-12); } #[test] From 648413556c9929cb117a251d9dfbe011095cf32b Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:59:58 -0400 Subject: [PATCH 31/81] Kernel tests: the twelve ignored print-only debug tests and surveys go; coplanar_curved_booleans checks the flush-capped cylinder cuts and unions they printed Co-Authored-By: Claude Opus 5.5 --- crates/kernel/src/tests.rs | 280 ++----------------------------------- 1 file changed, 12 insertions(+), 268 deletions(-) diff --git a/crates/kernel/src/tests.rs b/crates/kernel/src/tests.rs index f73098b08..3da88a628 100644 --- a/crates/kernel/src/tests.rs +++ b/crates/kernel/src/tests.rs @@ -1022,78 +1022,6 @@ fn similar_spheres_meet() { } } -#[test] -#[ignore] -fn debug_convergence() { - let b = extrude(&Plane::XY, &[Region2 { outer: Loop2::circle(Vec2::ZERO, 15.0), holes: vec![] }], 0.0, 50.0).unwrap().pop().unwrap(); - for t in [0.1, 0.05, 0.02, 0.01, 0.005, 0.002] { - let m = b.mesh(&crate::MeshTolerance::chord(t)).unwrap(); - let mm = m.measure(); - println!("tol {t}: tris {} vol {} err {:.3e}", m.triangles.len(), mm.volume, mm.volume / (PI * 225.0 * 50.0) - 1.0); - } - let m = b.mesh(&crate::MeshTolerance::chord(0.05)).unwrap(); - for f in 0..4u32 { - let ns: Vec = - m.triangles.iter().zip(&m.tri_face).filter(|(_, ff)| **ff == f).flat_map(|(t, _)| t.iter().map(|k| m.normals[*k as usize])).collect(); - println!("face {f}: {} normals, first {:?}, max |n.z| {}", ns.len(), ns.first(), ns.iter().map(|n| n.z.abs()).fold(0.0, f64::max)); - } -} - -#[test] -#[ignore] -fn debug_coplanar() { - let b = box_solid(Vec3::ZERO, Vec3::new(40.0, 30.0, 20.0)).unwrap(); - for (z0, z1) in [(0.0, 20.0), (-5.0, 20.0), (0.0, 25.0), (-5.0, 25.0), (5.0, 20.0), (5.0, 25.0)] { - let c = cylinder(Vec3::new(20.0, 15.0, z0), Vec3::Z, 5.0, z1 - z0).unwrap(); - let r = boolean(&b, &c, BoolOp::Cut); - println!("cut z {z0}..{z1}: {:?}", r.map(|o| o.map(|b| measure(&b).unwrap().volume))); - let r = boolean(&b, &c, BoolOp::Union); - println!("union z {z0}..{z1}: {:?}", r.map(|o| o.map(|b| measure(&b).unwrap().volume))); - } - let r = - Region2 { outer: Loop2::polygon(&[Vec2::new(0.0, 0.0), Vec2::new(40.0, 0.0), Vec2::new(40.0, 30.0), Vec2::new(0.0, 30.0)]), holes: vec![] }; - for ang in [PI / 2.0, PI, 1.5 * PI, 2.0 * PI] { - let q = revolve(&Plane::XY, std::slice::from_ref(&r), Vec2::ZERO, Vec2::Y, ang).unwrap().pop().unwrap(); - let m = measure(&q).unwrap(); - println!("revolve {ang}: vol {} expect {} faces {}", m.volume, ang / 2.0 * 1600.0 * 30.0, m.faces); - } -} - -#[test] -#[ignore] -fn debug_blind() { - let b = box_solid(Vec3::ZERO, Vec3::new(40.0, 30.0, 20.0)).unwrap(); - let t = box_solid(Vec3::new(10.0, 10.0, 5.0), Vec3::new(20.0, 20.0, 25.0)).unwrap(); - println!("box pocket: {:?}", boolean(&b, &t, BoolOp::Cut).map(|o| o.map(|b| measure(&b).unwrap().volume))); - let t = box_solid(Vec3::new(10.0, 10.0, 5.0), Vec3::new(20.0, 20.0, 15.0)).unwrap(); - println!("box void: {:?}", boolean(&b, &t, BoolOp::Cut).map(|o| o.map(|b| measure(&b).unwrap().volume))); - for r in [5.0, 4.3] { - for z in [5.0, 7.3, 13.1] { - let c = cylinder(Vec3::new(20.3, 15.1, z), Vec3::Z, r, 30.0).unwrap(); - println!("cyl r{r} z{z}: {:?}", boolean(&b, &c, BoolOp::Cut).map(|o| o.map(|b| measure(&b).unwrap().volume))); - } - } - let c = cylinder(Vec3::new(20.0, 15.0, 25.0), -Vec3::Z, 5.0, 20.0).unwrap(); - println!("cyl down: {:?}", boolean(&b, &c, BoolOp::Cut).map(|o| o.map(|b| measure(&b).unwrap().volume))); - let s = sphere(Vec3::new(20.0, 15.0, 20.0), 5.0).unwrap(); - println!("sphere: {:?}", boolean(&b, &s, BoolOp::Cut).map(|o| o.map(|b| measure(&b).unwrap().volume))); -} - -#[test] -#[ignore] -fn debug_revolve_doc_case() { - let r = - Region2 { outer: Loop2::polygon(&[Vec2::new(0.0, 0.0), Vec2::new(40.0, 0.0), Vec2::new(40.0, 30.0), Vec2::new(0.0, 30.0)]), holes: vec![] }; - for ang in [PI / 2.0, -PI / 2.0] { - let q = revolve(&Plane::XY, std::slice::from_ref(&r), Vec2::ZERO, Vec2::Y, ang).unwrap().pop().unwrap(); - let m = measure(&q).unwrap(); - println!("ang {ang}: vol {} bbox {:?}", m.volume, m.bbox); - } - let r2 = Region2 { outer: r.outer.reversed(), holes: vec![] }; - let q = revolve(&Plane::XY, std::slice::from_ref(&r2), Vec2::ZERO, Vec2::Y, PI / 2.0).unwrap().pop().unwrap(); - println!("reversed: {}", measure(&q).unwrap().volume); -} - #[test] fn chamfer_top_loop_mitres() { let b = box_solid(Vec3::ZERO, Vec3::new(40.0, 30.0, 20.0)).unwrap(); @@ -1202,111 +1130,6 @@ fn chamfer_wider_than_sloped_basin_rim_builds() { } } -#[test] -#[ignore] -fn debug_chamfer_cut() { - let b = box_solid(Vec3::ZERO, Vec3::new(40.0, 30.0, 20.0)).unwrap(); - // Prism along x: triangle in the YZ plane beyond the top-front edge. - let plane = Plane { origin: Vec3::new(-5.0, 0.0, 0.0), x: Vec3::Y, y: Vec3::Z }; - let tri = Loop2::polygon(&[Vec2::new(2.3, 20.3), Vec2::new(-0.3, 17.7), Vec2::new(10.0, 30.0)]); - let tri = if tri.signed_area() < 0.0 { tri.reversed() } else { tri }; - let tool = extrude(&plane, &[Region2 { outer: tri, holes: vec![] }], 0.0, 50.0).unwrap().pop().unwrap(); - println!("tool vol {}", measure(&tool).unwrap().volume); - let r = boolean(&b, &tool, BoolOp::Cut).unwrap().unwrap(); - let m = measure(&r).unwrap(); - println!("cut: {} faces {} {:?}", m.volume, m.faces, m.merged); - for f in r.faces(0.01).unwrap() { - println!("face {} area {:.3} c {:?} n {:?}", f.index, f.area, f.centroid, f.plane_normal); - } - for tol in [0.1, 0.01, 0.001] { - println!("tess {tol}: {}", r.mesh(&crate::MeshTolerance::chord(tol)).unwrap().measure().volume); - } -} - -#[test] -#[ignore] -fn debug_revolved_hole_tool() { - let b = box_solid(Vec3::ZERO, Vec3::new(60.0, 40.0, 15.0)).unwrap(); - // Drill point profile in the XZ plane through x = 50: revolve about the vertical line x = 50. - let pl = Plane { origin: Vec3::new(50.0, 20.0, 0.0), x: Vec3::X, y: Vec3::Z }; - let r = 3.0; - let tip = r / 59f64.to_radians().tan(); - let prof = - Region2 { outer: Loop2::polygon(&[Vec2::new(0.0, 16.0), Vec2::new(0.0, 5.0 - tip), Vec2::new(r, 5.0), Vec2::new(r, 16.0)]), holes: vec![] }; - let tool = revolve(&pl, &[prof], Vec2::ZERO, Vec2::Y, std::f64::consts::TAU).unwrap().pop().unwrap(); - println!("tool vol {}", measure(&tool).unwrap().volume); - let res = boolean(&b, &tool, BoolOp::Cut); - println!("cut: {:?}", res.map(|o| o.map(|x| measure(&x).unwrap().volume))); - let expect = 36000.0 - std::f64::consts::PI * 9.0 * 10.0 - std::f64::consts::PI * 9.0 * tip / 3.0; - println!("expect {expect}"); -} - -#[test] -#[ignore] -fn debug_sphere() { - let s = sphere(Vec3::new(1.0, 2.0, 3.0), 10.0).unwrap(); - let m = measure(&s).unwrap(); - println!("vol {} area {} faces {} bbox {:?}", m.volume, m.area, m.faces, m.bbox); - for f in s.faces(0.05).unwrap() { - println!("face {} area {:.3} c {:?}", f.index, f.area, f.centroid); - } - let b = box_solid(Vec3::new(-25.0, -25.0, -20.0), Vec3::new(25.0, 25.0, 0.0)).unwrap(); - for (name, c) in [("origin", Vec3::ZERO), ("up", Vec3::new(0.0, 0.0, 3.0)), ("off", Vec3::new(1.3, 2.1, 0.7))] { - let sp = sphere(c, 15.0).unwrap(); - println!("{name} cut {:?}", boolean(&b, &sp, BoolOp::Cut).map(|o| o.map(|x| measure(&x).unwrap().volume))); - println!("{name} and {:?}", boolean(&b, &sp, BoolOp::Intersect).map(|o| o.map(|x| measure(&x).unwrap().volume))); - } -} - -#[test] -#[ignore] -fn debug_countersink() { - let b = box_solid(Vec3::ZERO, Vec3::new(60.0, 40.0, 15.0)).unwrap(); - for (name, pts) in [ - ("csink", vec![Vec2::new(0.0, 0.6), Vec2::new(6.6, 0.6), Vec2::new(3.0, -3.0), Vec2::new(3.0, -31.0), Vec2::new(0.0, -31.0)]), - ("csink-thru-top", vec![Vec2::new(0.0, 0.6), Vec2::new(6.6, 0.6), Vec2::new(3.0, -3.0), Vec2::new(3.0, -16.3), Vec2::new(0.0, -16.3)]), - ( - "cbore", - vec![Vec2::new(0.0, 0.6), Vec2::new(7.0, 0.6), Vec2::new(7.0, -5.0), Vec2::new(4.0, -5.0), Vec2::new(4.0, -31.0), Vec2::new(0.0, -31.0)], - ), - ] { - for (pn, pl) in [ - ("xz@top", Plane::new(Vec3::new(35.0, 20.0, 15.0), Vec3::X, Vec3::Z).unwrap()), - ("yz@top", Plane::new(Vec3::new(35.0, 20.0, 15.0), Vec3::Y, Vec3::Z).unwrap()), - ("diag", Plane::new(Vec3::new(35.0, 20.0, 15.0), Vec3::new(0.6, 0.8, 0.0), Vec3::Z).unwrap()), - ] { - let tool = revolve(&pl, &[Region2 { outer: Loop2::polygon(&pts), holes: vec![] }], Vec2::ZERO, Vec2::Y, std::f64::consts::TAU) - .unwrap() - .pop() - .unwrap(); - println!( - "{name} {pn}: tool {} cut {:?}", - measure(&tool).unwrap().volume, - boolean(&b, &tool, BoolOp::Cut).map(|o| o.map(|x| measure(&x).unwrap().volume)) - ); - } - } -} - -#[test] -#[ignore] -fn debug_cbore_seq() { - let b = box_solid(Vec3::ZERO, Vec3::new(60.0, 40.0, 15.0)).unwrap(); - let pl = Plane::from_normal(Vec3::new(15.0, 20.0, 15.0), Vec3::Z).unwrap(); - for (s1, s2, r2top) in [(0.0, 0.0, 0.6), (0.613, 1.226, 0.6), (0.3, 0.9, 2.37)] { - let t1 = extrude(&pl, &[Region2 { outer: Loop2::circle_from(Vec2::ZERO, 4.0, s1), holes: vec![] }], -31.0, 0.6).unwrap().pop().unwrap(); - let c1 = boolean(&b, &t1, BoolOp::Cut).unwrap().unwrap(); - let t2 = extrude(&pl, &[Region2 { outer: Loop2::circle_from(Vec2::ZERO, 7.0, s2), holes: vec![] }], -5.0, r2top).unwrap().pop().unwrap(); - println!( - "seams {s1} {s2}: first {} second {:?}", - measure(&c1).unwrap().volume, - boolean(&c1, &t2, BoolOp::Cut).map(|o| o.map(|x| measure(&x).unwrap().volume)) - ); - let c2 = boolean(&b, &t2, BoolOp::Cut).unwrap().unwrap(); - println!(" swapped: {:?}", boolean(&c2, &t1, BoolOp::Cut).map(|o| o.map(|x| measure(&x).unwrap().volume))); - } -} - #[test] fn mesh_bodies_move_measure_and_refuse_solid_ops() { // Unit cube as 12 triangles with repeated corners (welded on construction). @@ -1352,26 +1175,6 @@ fn concave_fillet() { assert_eq!(m.merged.face_types.get("cylinder"), Some(&1)); } -#[test] -#[ignore] -fn debug_pocket_corners() { - let b = box_solid(Vec3::ZERO, Vec3::new(80.0, 60.0, 20.0)).unwrap(); - let p = box_solid(Vec3::new(15.0, 15.0, 12.0), Vec3::new(65.0, 45.0, 25.0)).unwrap(); - let mut cur = boolean(&b, &p, BoolOp::Cut).unwrap().unwrap(); - for e in [Vec3::new(65.0, 15.0, 16.0), Vec3::new(15.0, 15.0, 16.0), Vec3::new(65.0, 45.0, 16.0), Vec3::new(15.0, 45.0, 16.0)] { - match fillet(&cur, &[e], 5.0) { - Ok(n) => { - println!("ok {e:?} vol {}", measure(&n).unwrap().volume); - cur = n; - } - Err(err) => { - println!("fail {e:?}: {err}"); - break; - } - } - } -} - #[test] fn pocket_floor_loop_fillet() { let b = box_solid(Vec3::ZERO, Vec3::new(80.0, 60.0, 20.0)).unwrap(); @@ -1429,7 +1232,18 @@ fn coplanar_curved_booleans() { assert!(rel(measure(&cut).unwrap().volume, 32000.0 - half * 20.0) < 1e-3); let i = boolean(&a, &c, BoolOp::Intersect).unwrap().unwrap(); assert!(rel(measure(&i).unwrap().volume, half * 20.0) < 1e-3); - println!("union {:?}", m.merged); + // A cylinder of radius 5 through the middle of a 40 x 30 x 20 box, its caps flush with the + // box's top or bottom or past them: the cut takes the part inside, π·25 a mm of height, and + // the union adds the parts outside. A cylinder inside but for a flush cap adds nothing. + let b = box_solid(Vec3::ZERO, Vec3::new(40.0, 30.0, 20.0)).unwrap(); + let disc = PI * 25.0; + for (z0, z1, inside, outside) in [(0.0, 20.0, 20.0, 0.0), (-5.0, 20.0, 20.0, 5.0), (0.0, 25.0, 20.0, 5.0), (-5.0, 25.0, 20.0, 10.0), (5.0, 20.0, 15.0, 0.0), (5.0, 25.0, 15.0, 5.0)] { + let c = cylinder(Vec3::new(20.0, 15.0, z0), Vec3::Z, 5.0, z1 - z0).unwrap(); + let cut = measure(&boolean(&b, &c, BoolOp::Cut).unwrap().unwrap()).unwrap().volume; + assert!(rel(cut, 24000.0 - disc * inside) < 1e-6, "cut z {z0}..{z1}: {cut}"); + let union = measure(&boolean(&b, &c, BoolOp::Union).unwrap().unwrap()).unwrap().volume; + assert!(rel(union, 24000.0 + disc * outside) < 1e-6, "union z {z0}..{z1}: {union}"); + } } #[test] @@ -2102,57 +1916,6 @@ fn fillet_partial_mixed_arc_and_line_perimeter_run() { } } -/// Boolean survey: random boxes, cylinders and spheres combined every way; prints what fails. -#[test] -#[ignore] -fn boolean_survey() { - let mut seed: u64 = 0x2545_f491_4f6c_dd1d; - let mut rnd = || { - seed ^= seed << 13; - seed ^= seed >> 7; - seed ^= seed << 17; - (seed % 1_000_000) as f64 / 1_000_000.0 - }; - let mut shapes: Vec<(String, Body)> = Vec::new(); - for i in 0..40 { - let kind = i % 4; - let (x, y, z) = ((rnd() - 0.5) * 20.0, (rnd() - 0.5) * 20.0, (rnd() - 0.5) * 20.0); - // Snap some coordinates to a 5 mm grid: coincident faces and tangencies. - let snap = |v: f64, s: bool| if s { (v / 5.0).round() * 5.0 } else { v }; - let s = rnd() < 0.5; - let (x, y, z) = (snap(x, s), snap(y, s), snap(z, s)); - let a = 5.0 + snap(rnd() * 20.0, s); - let ax = (rnd() * 3.0) as usize % 3; - let b = match kind { - 0 => box_solid(Vec3::new(x, y, z), Vec3::new(x + a, y + a * 0.8, z + a * 0.6)), - 1 => cylinder(Vec3::new(x, y, z), [Vec3::X, Vec3::Y, Vec3::Z][ax], a * 0.4, a), - 2 => sphere(Vec3::new(x, y, z), a * 0.5), - _ => box_solid(Vec3::new(x, y, z), Vec3::new(x + a * 0.5, y + a, z + a * 0.3)), - }; - if let Ok(b) = b { - shapes.push((format!("{}{i}@({x:.3},{y:.3},{z:.3}) a={a:.3} ax={ax}", ["box", "cyl", "sph", "slab"][kind]), b)); - } - } - let (mut ok, mut empty, mut fail) = (0, 0, Vec::new()); - for i in 0..shapes.len() { - for j in i + 1..(i + 4).min(shapes.len()) { - for op in [BoolOp::Union, BoolOp::Cut, BoolOp::Intersect] { - let (na, a) = &shapes[i]; - let (nb, b) = &shapes[j]; - match boolean(a, b, op) { - Ok(Some(_)) => ok += 1, - Ok(None) => empty += 1, - Err(e) => fail.push(format!("{na} {op:?} {nb}: {}", e.to_string().chars().take(140).collect::())), - } - } - } - } - println!("ok {ok} empty {empty} failed {}", fail.len()); - for f in &fail { - println!(" {f}"); - } -} - #[test] fn booleans_found_by_the_survey() { // A tool wholly inside: a void (the solid keeps an inner shell). @@ -2342,25 +2105,6 @@ fn a_bend_as_tight_as_the_tube_sweeps_a_valid_solid() { assert!(rel(v, want) < 1e-6, "{v} vs {want}"); } -#[test] -#[ignore] -fn boolean_identity_survey() { - let n: u64 = std::env::var("N").ok().and_then(|x| x.parse().ok()).unwrap_or(100); - let seeds: Vec = match std::env::var("SEEDS") { - Ok(s) => s.split(',').filter_map(|x| x.parse().ok()).collect(), - Err(_) => (0..n).collect(), - }; - let mut bad = 0; - for seed in seeds { - let c = crate::fuzz::boolean_case(seed); - if c.outcome != "ok" { - bad += 1; - println!("{seed}: {} {} | {:?} | {:?}", c.outcome, c.detail, c.a, c.b); - } - } - println!("{bad}/{n} failed"); -} - /// A quarter turn of a rectangle with an edge on the axis: no zero-area face along the axis, so /// a cylinder can be cut through the corner (it failed in every boolean attempt before). #[test] From 35805f899ea17a61871c13cda0bec439718b9ddb Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 09:01:02 -0400 Subject: [PATCH 32/81] Kernel: the #883 board fixture generator is an example, not an ignored test Co-Authored-By: Claude Opus 5.5 --- crates/kernel/examples/step_board_fixture.rs | 87 ++++++++++++++++++++ crates/kernel/src/step_in/tests.rs | 54 ------------ 2 files changed, 87 insertions(+), 54 deletions(-) create mode 100644 crates/kernel/examples/step_board_fixture.rs diff --git a/crates/kernel/examples/step_board_fixture.rs b/crates/kernel/examples/step_board_fixture.rs new file mode 100644 index 000000000..69691c535 --- /dev/null +++ b/crates/kernel/examples/step_board_fixture.rs @@ -0,0 +1,87 @@ +//! A board-like assembly for issue #883, the worst case for a large STEP import: every +//! component is its own product with a package body and its own pins (nothing shared). +//! +//! ```sh +//! scripts/fetch-smlib.sh +//! SOLIDCRAFT_STEP_PCB_COMPONENTS=600 SOLIDCRAFT_STEP_PCB_PINS=15 \ +//! cargo run --release -p solidcraft-kernel --features smlib --example step_board_fixture -- board.step +//! ``` +//! +//! 600 components of 15 pins give 52 MB. The defaults are 500 and 16; the path defaults to +//! `board.step`. + +#[cfg(not(feature = "smlib"))] +fn main() { + eprintln!("step_board_fixture needs SMLib: run scripts/fetch-smlib.sh, then add --features smlib"); + std::process::exit(2); +} + +#[cfg(feature = "smlib")] +fn main() { + if let Err(e) = run::main() { + eprintln!("step_board_fixture: {e}"); + std::process::exit(1); + } +} + +#[cfg(feature = "smlib")] +mod run { + use solidcraft_geom::Vec3; + use solidcraft_kernel::{Body, ExportBody, ExportProduct, StepHeader, box_solid, cylinder, fillet, step_export_products}; + + /// A count from `SOLIDCRAFT_`, or `default` when it is unset. + fn count(name: &str, default: usize) -> Result { + solidcraft_geom::env::var(name).map_or(Ok(default), |s| s.parse().map_err(|e| format!("SOLIDCRAFT_{name}: {e}"))) + } + + /// A package: a box with its vertical edges and then its top edges rounded (left sharp where + /// a round does not build). + fn package(w: f64, d: f64, h: f64) -> Result { + let b = box_solid(Vec3::ZERO, Vec3::new(w, d, h)).map_err(|e| e.to_string())?; + let vertical = [Vec3::new(0.0, 0.0, h / 2.0), Vec3::new(w, 0.0, h / 2.0), Vec3::new(w, d, h / 2.0), Vec3::new(0.0, d, h / 2.0)]; + let top = [Vec3::new(w / 2.0, 0.0, h), Vec3::new(w, d / 2.0, h), Vec3::new(w / 2.0, d, h), Vec3::new(0.0, d / 2.0, h)]; + let b = fillet(&b, &vertical, 0.3).unwrap_or(b); + Ok(fillet(&b, &top, 0.1).unwrap_or(b)) + } + + pub fn main() -> Result<(), String> { + let components = count("STEP_PCB_COMPONENTS", 500)?; + let pins = count("STEP_PCB_PINS", 16)?; + let path = std::env::args().nth(1).unwrap_or_else(|| "board.step".into()); + let mut owned: Vec> = Vec::new(); + for c in 0..components { + let w = 4.0 + (c % 7) as f64 * 0.37; + let d = 3.0 + (c % 5) as f64 * 0.29; + let mut bodies = vec![package(w, d, 1.2 + (c % 3) as f64 * 0.1)?]; + for p in 0..pins { + let side = if p % 2 == 0 { -0.6 } else { d + 0.6 }; + let x = 0.3 + (p / 2) as f64 * (w - 0.6) / (pins / 2).max(1) as f64 + c as f64 * 1e-4; + bodies.push(cylinder(Vec3::new(x, side, -1.5), Vec3::Z, 0.25, 2.0 + (p % 3) as f64 * 0.01).map_err(|e| e.to_string())?); + } + owned.push(bodies); + } + let mut products: Vec = owned + .iter() + .enumerate() + .map(|(c, bodies)| ExportProduct { + name: format!("U{c}"), + bodies: bodies.iter().enumerate().map(|(k, b)| ExportBody { name: format!("U{c}_{k}"), body: b, color: Some([0.2, 0.2, 0.2]) }).collect(), + children: Vec::new(), + }) + .collect(); + let side = (components as f64).sqrt().ceil() as usize; + let children = (0..components) + .map(|c| { + let (x, y) = ((c % side) as f64 * 12.0, (c / side) as f64 * 10.0); + (c, [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [x, y, 1.6, 1.0]], format!("U{c}")) + }) + .collect(); + products.push(ExportProduct { name: "Board".into(), bodies: Vec::new(), children }); + let root = products.len() - 1; + let header = StepHeader { file_name: "board.step".into(), ..Default::default() }; + let text = step_export_products(&products, root, &header).map_err(|e| e.to_string())?; + std::fs::write(&path, &text).map_err(|e| format!("{path}: {e}"))?; + println!("wrote {path}: {} bytes, {components} components", text.len()); + Ok(()) + } +} diff --git a/crates/kernel/src/step_in/tests.rs b/crates/kernel/src/step_in/tests.rs index 99049a2c4..9583c575b 100644 --- a/crates/kernel/src/step_in/tests.rs +++ b/crates/kernel/src/step_in/tests.rs @@ -1545,60 +1545,6 @@ fn faces_with_too_many_bounds_are_refused() { assert!(start.elapsed() < std::time::Duration::from_secs(10), "took {:?}", start.elapsed()); } -/// A board-like assembly for issue #883: `SOLIDCRAFT_STEP_PCB_FIXTURE=path` writes it (with -/// `SOLIDCRAFT_STEP_PCB_COMPONENTS` and `SOLIDCRAFT_STEP_PCB_PINS`; 600 and 15 give 52 MB). Every component is -/// its own product with a package body and its own pins (nothing shared), the worst case for -/// a large import. -#[test] -#[ignore = "manual fixture generator for large STEP imports"] -fn generate_board_assembly_fixture() { - use crate::step_out::{ExportBody, ExportProduct, StepHeader, step_export_products}; - let count: usize = solidcraft_geom::env::var("STEP_PCB_COMPONENTS").map(|s| s.parse().unwrap()).unwrap_or(500); - let pins: usize = solidcraft_geom::env::var("STEP_PCB_PINS").map(|s| s.parse().unwrap()).unwrap_or(16); - let mut owned: Vec> = Vec::new(); - for c in 0..count { - let w = 4.0 + (c % 7) as f64 * 0.37; - let d = 3.0 + (c % 5) as f64 * 0.29; - let mut bodies = vec![fillet_box(w, d, 1.2 + (c % 3) as f64 * 0.1)]; - for p in 0..pins { - let side = if p % 2 == 0 { -0.6 } else { d + 0.6 }; - let x = 0.3 + (p / 2) as f64 * (w - 0.6) / (pins / 2).max(1) as f64 + c as f64 * 1e-4; - bodies.push(cylinder(Vec3::new(x, side, -1.5), Vec3::Z, 0.25, 2.0 + (p % 3) as f64 * 0.01).unwrap()); - } - owned.push(bodies); - } - let mut products: Vec = owned - .iter() - .enumerate() - .map(|(c, bodies)| ExportProduct { - name: format!("U{c}"), - bodies: bodies.iter().enumerate().map(|(k, b)| ExportBody { name: format!("U{c}_{k}"), body: b, color: Some([0.2, 0.2, 0.2]) }).collect(), - children: Vec::new(), - }) - .collect(); - let side = (count as f64).sqrt().ceil() as usize; - let children = (0..count) - .map(|c| { - let (x, y) = ((c % side) as f64 * 12.0, (c / side) as f64 * 10.0); - (c, [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [x, y, 1.6, 1.0]], format!("U{c}")) - }) - .collect(); - products.push(ExportProduct { name: "Board".into(), bodies: Vec::new(), children }); - let root = products.len() - 1; - let text = step_export_products(&products, root, &StepHeader { file_name: "board.step".into(), ..Default::default() }).unwrap(); - let path = solidcraft_geom::env::var("STEP_PCB_FIXTURE").unwrap_or_else(|| "board.step".into()); - std::fs::write(&path, &text).unwrap(); - println!("wrote {path}: {} bytes, {} components", text.len(), count); -} - -fn fillet_box(w: f64, d: f64, h: f64) -> Body { - let b = box_solid(Vec3::ZERO, Vec3::new(w, d, h)).unwrap(); - let vertical = [Vec3::new(0.0, 0.0, h / 2.0), Vec3::new(w, 0.0, h / 2.0), Vec3::new(w, d, h / 2.0), Vec3::new(0.0, d, h / 2.0)]; - let top = [Vec3::new(w / 2.0, 0.0, h), Vec3::new(w, d / 2.0, h), Vec3::new(w / 2.0, d, h), Vec3::new(0.0, d / 2.0, h)]; - let b = fillet(&b, &vertical, 0.3).unwrap_or(b); - fillet(&b, &top, 0.1).unwrap_or(b) -} - /// Independent boxes as one STEP file (about 3 KB a box). fn boxes_step(count: usize, name: &str) -> String { let bodies: Vec<_> = (0..count) From 43551498dd4157cc529989a26e5c5009ccaf46ff Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 09:01:52 -0400 Subject: [PATCH 33/81] STEP import test: a seam sphere whose meridian stops short of the pole imports as the whole 2 mm ball Co-Authored-By: Claude Opus 5.5 --- crates/kernel/src/step_in/tests.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/kernel/src/step_in/tests.rs b/crates/kernel/src/step_in/tests.rs index 9583c575b..725a8f93b 100644 --- a/crates/kernel/src/step_in/tests.rs +++ b/crates/kernel/src/step_in/tests.rs @@ -135,11 +135,13 @@ fn a_void_reads_as_a_cavity_whichever_way_its_shell_flag_points() { } } +/// A ball whose one face is bounded by a meridian edge from the north pole that stops short of +/// the south pole (at 2.5 rad), run out and back: the face is the whole sphere less a slit of no +/// area, so it is the same 2 mm ball as when the seam runs pole to pole. #[test] -fn non_antipodal_seam_sphere_does_not_panic() { +fn non_antipodal_seam_sphere_imports_as_a_whole_ball() { let text = seam_sphere_step(Vec3::ZERO, 2.0, Vec3::Z, Vec3::X, 0.0, false, 2.5); - let result = std::panic::catch_unwind(|| step_import(&text)); - assert!(result.is_ok()); + assert_seam_sphere(&text, 2.0); } #[test] From 6704d3094b260b56dbd62b077af41aff3722cbc3 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 09:03:08 -0400 Subject: [PATCH 34/81] Material tests: the nine copies in material_properties go; the persistence file checks the library copy's card and formats 20 and 21 in one loop Co-Authored-By: Claude Opus 5.5 --- .../cmd/material_card_persistence_tests.rs | 33 ++- crates/engine/src/cmd/material_properties.rs | 217 +----------------- 2 files changed, 16 insertions(+), 234 deletions(-) diff --git a/crates/engine/src/cmd/material_card_persistence_tests.rs b/crates/engine/src/cmd/material_card_persistence_tests.rs index 6afe0d20f..0af0766ab 100644 --- a/crates/engine/src/cmd/material_card_persistence_tests.rs +++ b/crates/engine/src/cmd/material_card_persistence_tests.rs @@ -77,6 +77,9 @@ fn omission_retains_null_clears_and_unrelated_material_edits_retain_cards() { .and_then(|c| c.in_format(solidcraft_io::catalog::V1_FORMAT)) .unwrap_err(); assert!(error.to_string().contains("engineering cards")); + // A library copy carries the card as it is. + let copy = solidcraft_io::catalog::LibraryMaterial::from_material(&s.doc.user_materials[1]).unwrap(); + assert_eq!(copy.physical_card, original); s.execute("material.edit", &json!({"material":"Renamed","physical_card":null})).unwrap(); assert!(s.doc.user_materials[1].physical_card.is_none()); s.execute("edit.undo", &json!({})).unwrap(); @@ -137,15 +140,20 @@ fn configurations_rename_and_paste_new_keep_design_owned_material_semantics() { assert!(loaded.configs.rows.iter().any(|r| r.cells.iter().any(|c| c == "Renamed candidate"))); } +/// Formats 20 (before engineering cards) and 21 (with them), as they were written (no pending +/// format list): materials without cards come in with their optical look unchanged, upgraded. #[test] -fn format21_materials_without_cards_keep_their_optical_look() { +fn format20_and_21_materials_without_cards_keep_their_optical_look() { let s = fixture(); - let mut saved = serde_json::to_value(&*s.doc).unwrap(); - saved["format"] = json!("solidcraft/21"); - let loaded = Document::from_json(&saved.to_string()).unwrap(); - assert_eq!(loaded.user_materials, s.doc.user_materials); - assert!(loaded.user_materials[0].physical_card.is_none()); - assert_eq!(loaded.format, solidcraft_doc::format::format_string(solidcraft_doc::format::FORMAT)); + for format in [20, 21] { + let mut saved = serde_json::to_value(&*s.doc).unwrap(); + saved["format"] = json!(format!("solidcraft/{format}")); + saved.as_object_mut().unwrap().remove("format_pending"); + let loaded = Document::from_json(&saved.to_string()).unwrap(); + assert_eq!(loaded.user_materials, s.doc.user_materials, "format {format}"); + assert!(loaded.user_materials[0].physical_card.is_none(), "format {format}"); + assert_eq!(loaded.format, solidcraft_doc::format::format_string(solidcraft_doc::format::FORMAT), "format {format}"); + } } #[test] @@ -208,17 +216,6 @@ fn native_container_keeps_large_si_card_values_sources_conditions_and_density_se assert_eq!(material["physical_validation"]["source_review_required"], json!(["fixture"])); } -#[test] -fn format20_materials_without_cards_upgrade_to21_without_changing_their_optical_look() { - let s = fixture(); - let mut saved = serde_json::to_value(&*s.doc).unwrap(); - saved["format"] = json!("solidcraft/20"); - let loaded = Document::from_json(&saved.to_string()).unwrap(); - assert_eq!(loaded.user_materials, s.doc.user_materials); - assert!(loaded.user_materials[0].physical_card.is_none()); - assert_eq!(loaded.format, solidcraft_doc::format::format_string(solidcraft_doc::format::FORMAT)); -} - #[test] fn card_number_admission_preserves_metadata_without_exempting_other_material_fields() { let s = fixture(); diff --git a/crates/engine/src/cmd/material_properties.rs b/crates/engine/src/cmd/material_properties.rs index fe3acd8c1..ec3285e70 100644 --- a/crates/engine/src/cmd/material_properties.rs +++ b/crates/engine/src/cmd/material_properties.rs @@ -44,7 +44,7 @@ fn validate(_: &mut Session, params: &Value) -> Result { #[cfg(test)] mod tests { use super::*; - use crate::{doc::Document, product_scene}; + use crate::doc::Document; use std::sync::Arc; fn card() -> Value { @@ -69,43 +69,6 @@ mod tests { s } - #[test] - fn card_edits_preserve_mass_optics_and_geometry_and_survive_undo_reopen() { - let mut s = fixture(); - let scene = product_scene::extract(&s).unwrap(); - let mass = s.execute("component.properties", &json!({})).unwrap(); - let before_undo = s.undo.len(); - let out = s.execute("material.edit", &json!({"material":"Synthetic","physical_card":card()})).unwrap(); - assert_eq!(out["physical_validation"]["isotropic_moduli"]["shear_pa"], 4.9e9); - assert_eq!(out["density_comparison"]["assigned_density_kg_m3"], 800.0); - assert_eq!(out["density_comparison"]["matches_within_relative_tolerance"], false); - assert_eq!(out["physical_validation"]["source_review_required"], json!(["fixture"])); - assert_eq!(out["physical_validation"]["analysis_solver_available"], false); - assert_eq!(s.undo.len(), before_undo + 1); - assert_eq!(s.execute("component.properties", &json!({})).unwrap(), mass); - let after = product_scene::extract(&s).unwrap(); - assert!(Arc::ptr_eq(&scene.meshes[0].mesh, &after.meshes[0].mesh)); - assert_eq!(scene.meshes[0].surface, after.meshes[0].surface); - let saved = s.doc.to_json(); - let saved_json: Value = serde_json::from_str(&saved).unwrap(); - assert_eq!(saved_json["format"], crate::doc::format::format_string(crate::doc::format::FORMAT)); - s.execute("edit.undo", &json!({})).unwrap(); - assert!(s.doc.user_materials[0].physical_card.is_none()); - s.execute("edit.redo", &json!({})).unwrap(); - let mut reopened = Session::new(Document::from_json(&saved).unwrap()); - assert_eq!(reopened.execute("component.properties", &json!({})).unwrap(), mass); - assert_eq!(reopened.doc.user_materials, s.doc.user_materials); - let modulus = reopened.doc.user_materials[0].physical_card.as_ref().unwrap().card().directional_modulus([1., 2., 3.]).unwrap(); - assert_eq!(modulus.young_modulus_pa, 12.25e9); - let doc = reopened.doc.clone(); - let before = (reopened.revision, reopened.undo.len(), reopened.camera, reopened.selection.clone()); - let list = reopened.execute("material.list", &json!({})).unwrap(); - let material = list["materials"].as_array().unwrap().iter().find(|m| m["name"] == "Synthetic").unwrap(); - assert_eq!(material["physical_card"], out["physical_card"]); - assert!(Arc::ptr_eq(&doc, &reopened.doc)); - assert_eq!(before, (reopened.revision, reopened.undo.len(), reopened.camera, reopened.selection.clone())); - } - #[test] fn personal_format29_cards_upgrade_to_current_pending_format_without_changing_values() { let mut s = fixture(); @@ -126,184 +89,6 @@ mod tests { assert_eq!(session.execute("component.properties", &json!({})).unwrap(), mass); } - #[test] - fn omission_retains_null_clears_and_unrelated_material_edits_retain_cards() { - let mut s = fixture(); - s.execute("material.create", &json!({"name":"With card","density_g_cm3":0.7,"physical_card":card()})).unwrap(); - let original = s.doc.user_materials[1].physical_card.clone(); - for p in [json!({"density_g_cm3":0.9}), json!({"color":"#112233"}), json!({"name":"Renamed"})] { - let mut p = p; - p["material"] = json!(s.doc.user_materials[1].name); - s.execute("material.edit", &p).unwrap(); - assert_eq!(s.doc.user_materials[1].physical_card, original); - } - let copy = solidcraft_io::catalog::LibraryMaterial::from_material(&s.doc.user_materials[1]).unwrap(); - assert_eq!(copy.physical_card, original); - s.execute("material.edit", &json!({"material":"Renamed","physical_card":null})).unwrap(); - assert!(s.doc.user_materials[1].physical_card.is_none()); - s.execute("edit.undo", &json!({})).unwrap(); - assert_eq!(s.doc.user_materials[1].physical_card, original); - } - - #[test] - fn hostile_cards_refuse_atomically_and_saved_card_admission_is_not_bypassed() { - let mut s = fixture(); - let mut bad = card(); - bad["properties"][1]["data"]["model"]["poisson_ratio"] = json!(0.6); - let mut oversized = card(); - oversized["sources"] = json!(vec![json!({}); 33]); - let mut unknown = card(); - unknown["unrecognized"] = json!(true); - let mut missing = card(); - missing["properties"][0]["source_id"] = json!("missing"); - let doc = s.doc.clone(); - let before = (s.undo.len(), s.redo.len(), s.revision, s.camera, s.selection.clone()); - for candidate in [bad, oversized, unknown, missing, json!(true)] { - assert!(s.execute("material.edit", &json!({"material":"Synthetic","physical_card":candidate})).is_err()); - assert!(s.execute("material.create", &json!({"name":"Refused","density_g_cm3":1,"physical_card":candidate})).is_err()); - assert!(Arc::ptr_eq(&doc, &s.doc)); - assert_eq!(before, (s.undo.len(), s.redo.len(), s.revision, s.camera, s.selection.clone())); - let mut saved = serde_json::to_value(&*s.doc).unwrap(); - saved["user_materials"][0]["physical_card"] = candidate; - assert!(Document::from_json(&saved.to_string()).is_err()); - assert!(serde_json::from_value::(saved).is_err()); - } - // Large finite SI constants are accepted only in this typed card, not geometry. - let mut saved = serde_json::to_value(&*s.doc).unwrap(); - saved["user_materials"][0]["physical_card"] = card(); - assert!(Document::from_json(&saved.to_string()).is_ok()); - saved["hostile_numeric_probe"] = json!(12.25e9); - assert!(Document::from_json(&saved.to_string()).unwrap_err().to_string().contains("number")); - } - - #[test] - fn configurations_rename_and_paste_new_keep_design_owned_material_semantics() { - let mut s = Session::default(); - let part = s.execute("component.create", &json!({"name":"Part"})).unwrap()["component"].as_u64().unwrap(); - s.execute("solid.box", &json!({"body_name":"Specimen","length":10,"width":10,"height":10})).unwrap(); - s.execute("material.create", &json!({"name":"Synthetic","density_g_cm3":0.8,"physical_card":card()})).unwrap(); - s.execute("config.configure", &json!({"materials":["Specimen"]})).unwrap(); - s.execute("config.row", &json!({"name":"Candidate","values":{"material:Specimen":"Synthetic"}})).unwrap(); - s.execute("config.activate", &json!({"row":"Candidate"})).unwrap(); - s.execute("component.activate", &json!({"component":0})).unwrap(); - s.execute("component.paste_new", &json!({"component":part,"translate":[30,0,0]})).unwrap(); - assert_eq!(s.doc.user_materials.len(), 1); - assert_eq!(s.doc.materials.values().filter(|m| *m == "Synthetic").count(), 2); - let original = s.doc.user_materials[0].physical_card.clone(); - s.execute("material.edit", &json!({"material":"Synthetic","name":"Renamed candidate"})).unwrap(); - s.execute("config.activate", &json!({"row":"Default"})).unwrap(); - s.execute("config.activate", &json!({"row":"Candidate"})).unwrap(); - let loaded = Document::from_json(&s.doc.to_json()).unwrap(); - assert_eq!(loaded.user_materials[0].physical_card, original); - assert_eq!(loaded.materials.values().filter(|m| *m == "Renamed candidate").count(), 2); - assert!(loaded.configs.rows.iter().any(|r| r.cells.iter().any(|c| c == "Renamed candidate"))); - } - - #[test] - fn format21_materials_without_cards_keep_their_optical_look() { - let s = fixture(); - let mut saved = serde_json::to_value(&*s.doc).unwrap(); - saved["format"] = json!("solidcraft/21"); - saved.as_object_mut().unwrap().remove("format_pending"); - let loaded = Document::from_json(&saved.to_string()).unwrap(); - assert_eq!(loaded.user_materials, s.doc.user_materials); - assert!(loaded.user_materials[0].physical_card.is_none()); - assert_eq!(loaded.format, crate::doc::format::format_string(crate::doc::format::FORMAT)); - } - - #[test] - fn scalar_catalog_refuses_card_export_without_creating_or_replacing_files_or_history() { - struct ProbeFile(std::path::PathBuf); - impl Drop for ProbeFile { - fn drop(&mut self) { - let _ = std::fs::remove_file(&self.0); - } - } - let unique = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_nanos(); - let file = ProbeFile(std::env::temp_dir().join(format!("solidcraft-card-refusal-{}-{unique}.json", std::process::id()))); - let mut s = Session::default(); - s.execute("material.create", &json!({"name":"Card only","density_g_cm3":0.8,"physical_card":card()})).unwrap(); - s.mark_saved(); - let doc = s.doc.clone(); - let history = (s.undo.len(), s.redo.len(), s.revision); - for existing in [false, true] { - if existing { - std::fs::write(&file.0, b"keep existing catalog").unwrap(); - } - for overwrite in [false, true] { - let error = s - .execute("library.export", &json!({"path":file.0,"format":solidcraft_io::catalog::V1_FORMAT,"overwrite":overwrite})) - .unwrap_err(); - assert!(error.to_string().contains("cannot preserve PBR or engineering cards")); - if existing { - assert_eq!(std::fs::read(&file.0).unwrap(), b"keep existing catalog"); - } else { - assert!(!file.0.exists()); - } - assert!(Arc::ptr_eq(&doc, &s.doc)); - assert_eq!((s.undo.len(), s.redo.len(), s.revision), history); - assert!(!s.is_dirty()); - } - } - } - - #[test] - fn native_container_keeps_large_si_card_values_sources_conditions_and_density_separate() { - let mut s = fixture(); - s.execute("material.edit", &json!({"material":"Synthetic","physical_card":card()})).unwrap(); - let before = s.execute("component.properties", &json!({})).unwrap(); - let scene = product_scene::extract(&s).unwrap(); - let native = solidcraft_io::write_design_container(&s.doc).unwrap(); - assert!(solidcraft_io::is_design_container(&native)); - let loaded = solidcraft_io::read_design(&native).unwrap(); - assert_eq!(loaded.format, crate::doc::format::format_string(crate::doc::format::FORMAT)); - assert_eq!(loaded.user_materials, s.doc.user_materials); - let mut reopened = Session::new(loaded); - assert_eq!(reopened.execute("component.properties", &json!({})).unwrap(), before); - assert_eq!(product_scene::extract(&reopened).unwrap().meshes[0].surface, scene.meshes[0].surface); - let list = reopened.execute("material.list", &json!({})).unwrap(); - let material = list["materials"].as_array().unwrap().iter().find(|m| m["name"] == "Synthetic").unwrap(); - assert_eq!(material["physical_card"], serde_json::to_value(s.doc.user_materials[0].physical_card.as_ref().unwrap()).unwrap()); - assert_eq!(material["density_comparison"]["assigned_density_kg_m3"], 800.0); - assert_eq!(material["density_comparison"]["card_density_kg_m3"], 700.0); - assert_eq!(material["physical_validation"]["source_review_required"], json!(["fixture"])); - } - - #[test] - fn format20_materials_without_cards_upgrade_without_changing_their_optical_look() { - let s = fixture(); - let mut saved = serde_json::to_value(&*s.doc).unwrap(); - saved["format"] = json!("solidcraft/20"); - saved.as_object_mut().unwrap().remove("format_pending"); - let loaded = Document::from_json(&saved.to_string()).unwrap(); - assert_eq!(loaded.user_materials, s.doc.user_materials); - assert!(loaded.user_materials[0].physical_card.is_none()); - assert_eq!(loaded.format, crate::doc::format::format_string(crate::doc::format::FORMAT)); - } - - #[test] - fn card_number_admission_preserves_metadata_without_exempting_other_material_fields() { - let s = fixture(); - let mut saved = serde_json::to_value(&*s.doc).unwrap(); - saved["user_materials"][0]["physical_card"] = card(); - let metadata = json!({"org.example.measurement":{"value":12.25e9,"physical_card":{"untyped":12.25e9}}}); - saved["metadata"] = metadata.clone(); - let loaded = Document::from_json(&saved.to_string()).unwrap(); - let reopened = solidcraft_io::read_design(&solidcraft_io::write_design_container(&loaded).unwrap()).unwrap(); - assert_eq!(serde_json::to_value(&reopened.metadata).unwrap(), metadata); - assert_eq!(reopened.user_materials, loaded.user_materials); - - // Only the exact root user-material card receives SI admission. The same key - // nested elsewhere must not exempt a hostile number from geometry limits. - for field in ["appearance", "unrecognized"] { - let mut hostile = saved.clone(); - hostile["user_materials"][0][field] = json!({"physical_card":{"untyped":12.25e9}}); - assert!(Document::from_json(&hostile.to_string()).unwrap_err().to_string().contains("number")); - } - saved["user_materials"][0]["density"] = json!(12.25e9); - assert!(Document::from_json(&saved.to_string()).unwrap_err().to_string().contains("number")); - } - #[test] fn material_inspection_preserves_legacy_entries_and_reports_unknowns_and_density_separately() { let mut s = fixture(); From 94acc0c435bbe422b5b0da0785ac9171993367e2 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 09:03:29 -0400 Subject: [PATCH 35/81] Sample test: one loop checks every sample builds cleanly and without a panic; the robustness copy goes Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/sample.rs | 37 ++++++++++++++++++++++----- crates/engine/src/tests/robustness.rs | 31 ---------------------- 2 files changed, 30 insertions(+), 38 deletions(-) diff --git a/crates/engine/src/sample.rs b/crates/engine/src/sample.rs index 033e81583..0ca0e60cb 100644 --- a/crates/engine/src/sample.rs +++ b/crates/engine/src/sample.rs @@ -177,17 +177,40 @@ mod tests { assert!(reopened_plate.contains(solidcraft_geom::Vec3::new(40., 35., 2.))); } - /// Every built-in sample builds without a failing feature or joint. + /// Every built-in sample builds without a failing feature or joint, and without a panic on + /// the way: panics inside the kernel are caught natively, but abort the web build (wasm + /// can't unwind; the Plastic Enclosure's bosses used to panic 8 times). #[test] - fn samples_build_cleanly() { + fn samples_build_cleanly_without_panics() { + use std::sync::Arc; + use std::sync::atomic::{AtomicUsize, Ordering}; + let me = std::thread::current().id(); + let count = Arc::new(AtomicUsize::new(0)); + let seen = count.clone(); + let prev = std::panic::take_hook(); + std::panic::set_hook(Box::new(move |_| { + if std::thread::current().id() == me { + seen.fetch_add(1, Ordering::SeqCst); + } + })); + let mut failed = Vec::new(); for s in super::samples() { let mut session = crate::Session::default(); - if let Err(e) = session.run_script(&(s.script)()) { - panic!("{}: {e}", s.name); + let built = session.run_script(&(s.script)()); + let panics = count.swap(0, Ordering::SeqCst); + if panics > 0 { + failed.push(format!("{}: {panics} panic(s)", s.name)); + } + if let Err(e) = built { + failed.push(format!("{}: {e}", s.name)); + continue; + } + failed.extend(session.model.results.iter().filter_map(|r| r.error.as_ref().map(|e| format!("{}: {}: {e}", s.name, r.name)))); + if session.model.state().bodies.is_empty() { + failed.push(format!("{}: no bodies", s.name)); } - let failed: Vec = session.model.results.iter().filter_map(|r| r.error.as_ref().map(|e| format!("{}: {e}", r.name))).collect(); - assert!(failed.is_empty(), "{}: {failed:?}", s.name); - assert!(!session.model.state().bodies.is_empty(), "{}", s.name); } + std::panic::set_hook(prev); + assert!(failed.is_empty(), "{failed:?}"); } } diff --git a/crates/engine/src/tests/robustness.rs b/crates/engine/src/tests/robustness.rs index 7c5a22962..1114777fa 100644 --- a/crates/engine/src/tests/robustness.rs +++ b/crates/engine/src/tests/robustness.rs @@ -174,37 +174,6 @@ fn shell_thicker_than_a_step_says_so() { assert!(e.to_string().contains("not supported yet"), "{e}"); } -/// Panics inside the kernel are caught natively, but abort the web build (wasm can't unwind). -/// Building the samples must not panic at all (the Plastic Enclosure's bosses used to, 8 times). -#[test] -fn samples_build_without_panics() { - use std::sync::Arc; - use std::sync::atomic::{AtomicUsize, Ordering}; - let me = std::thread::current().id(); - let count = Arc::new(AtomicUsize::new(0)); - let c2 = count.clone(); - let prev = std::panic::take_hook(); - std::panic::set_hook(Box::new(move |info| { - if std::thread::current().id() == me { - c2.fetch_add(1, Ordering::SeqCst); - } - let _ = info; - })); - let mut failed = Vec::new(); - for sample in crate::sample::samples() { - let mut s = Session::default(); - for c in (sample.script)()["commands"].as_array().into_iter().flatten() { - let _ = s.execute(c["command"].as_str().unwrap_or(""), &c["params"]); - } - let n = count.swap(0, Ordering::SeqCst); - if n > 0 { - failed.push(format!("{}: {n} panic(s)", sample.name)); - } - } - std::panic::set_hook(prev); - assert!(failed.is_empty(), "{failed:?}"); -} - fn total_volume(s: &Session) -> f64 { s.model.state().bodies.iter().map(|b| solidcraft_kernel::measure(&b.body).map(|m| m.volume).unwrap_or(0.0)).sum() } From 88c7cb6a8231f6822f96124a3b51fa9d048d43ea Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 09:12:14 -0400 Subject: [PATCH 36/81] Known failing: the non-antipodal seam sphere import, refused for a loop of no (u, v) area Co-Authored-By: Claude Opus 5.5 --- tests/KNOWN_FAILING_TESTS | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/KNOWN_FAILING_TESTS b/tests/KNOWN_FAILING_TESTS index 9a5c194fc..22660b1d8 100644 --- a/tests/KNOWN_FAILING_TESTS +++ b/tests/KNOWN_FAILING_TESTS @@ -16,4 +16,5 @@ solidcraft-kernel::blend::corner_tests::corner_blends_hold_at_any_scale at 0.01x solidcraft-kernel::blend_corner::tests::issue2422_vertical_after_separate_bottom_rounds SMLib's check refuses the fillet: edge and vertex tolerance 0.97 against the body's 0.01 (#2422) 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 2.6e-6 to 1.33e-3 past the box (the explicit corner is in progress) 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, which SMLib's exact tight box now sees (the explicit G2 corner builds it inside) +solidcraft-kernel::step_in::tests::non_antipodal_seam_sphere_imports_as_a_whole_ball the import refuses the ball: its face's loop, a meridian slit from the pole run out and back, encloses no (u, v) area, so the whole sphere less a slit is not read as the sphere solidcraft-kernel::tests::fillet_tabbed_plate_outer_loop_and_partial_selection_after_hole the arc and tab rounds together remove 9.20067 against 9.20420 (3.8e-4 off, 1e-5 allowed) From 5e348ae2a88cd11ccb7fee4686c2a9aaf314eb49 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 09:20:20 -0400 Subject: [PATCH 37/81] Tests: rustfmt the board fixture example and the coplanar asserts Co-Authored-By: Claude Opus 5.5 --- crates/kernel/examples/step_board_fixture.rs | 6 +++++- crates/kernel/src/tests.rs | 9 ++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/crates/kernel/examples/step_board_fixture.rs b/crates/kernel/examples/step_board_fixture.rs index 69691c535..393ea5aeb 100644 --- a/crates/kernel/examples/step_board_fixture.rs +++ b/crates/kernel/examples/step_board_fixture.rs @@ -65,7 +65,11 @@ mod run { .enumerate() .map(|(c, bodies)| ExportProduct { name: format!("U{c}"), - bodies: bodies.iter().enumerate().map(|(k, b)| ExportBody { name: format!("U{c}_{k}"), body: b, color: Some([0.2, 0.2, 0.2]) }).collect(), + bodies: bodies + .iter() + .enumerate() + .map(|(k, b)| ExportBody { name: format!("U{c}_{k}"), body: b, color: Some([0.2, 0.2, 0.2]) }) + .collect(), children: Vec::new(), }) .collect(); diff --git a/crates/kernel/src/tests.rs b/crates/kernel/src/tests.rs index 3da88a628..2056d1b2e 100644 --- a/crates/kernel/src/tests.rs +++ b/crates/kernel/src/tests.rs @@ -1237,7 +1237,14 @@ fn coplanar_curved_booleans() { // the union adds the parts outside. A cylinder inside but for a flush cap adds nothing. let b = box_solid(Vec3::ZERO, Vec3::new(40.0, 30.0, 20.0)).unwrap(); let disc = PI * 25.0; - for (z0, z1, inside, outside) in [(0.0, 20.0, 20.0, 0.0), (-5.0, 20.0, 20.0, 5.0), (0.0, 25.0, 20.0, 5.0), (-5.0, 25.0, 20.0, 10.0), (5.0, 20.0, 15.0, 0.0), (5.0, 25.0, 15.0, 5.0)] { + for (z0, z1, inside, outside) in [ + (0.0, 20.0, 20.0, 0.0), + (-5.0, 20.0, 20.0, 5.0), + (0.0, 25.0, 20.0, 5.0), + (-5.0, 25.0, 20.0, 10.0), + (5.0, 20.0, 15.0, 0.0), + (5.0, 25.0, 15.0, 5.0), + ] { let c = cylinder(Vec3::new(20.0, 15.0, z0), Vec3::Z, 5.0, z1 - z0).unwrap(); let cut = measure(&boolean(&b, &c, BoolOp::Cut).unwrap().unwrap()).unwrap().volume; assert!(rel(cut, 24000.0 - disc * inside) < 1e-6, "cut z {z0}..{z1}: {cut}"); From 033d1a122c19898e8bc23443dec43fc3ac85547f Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:29:20 -0400 Subject: [PATCH 38/81] Kernel rig: the two 3871 cone cases were byte-for-byte the 258 cases; the 258 cases carry their sources Co-Authored-By: Claude Opus 5.5 --- ATTRIBUTION.md | 2 - .../258-cone-point-vertex/expected.json | 4 +- .../import/258-cone-to-point/expected.json | 5 +- .../expected.json | 25 -------- .../input.step | 60 ------------------- .../recipe.json | 10 ---- .../expected.json | 26 -------- .../input.step | 56 ----------------- .../recipe.json | 10 ---- 9 files changed, 7 insertions(+), 191 deletions(-) delete mode 100644 tests/kernel-cases/import/3871-cone-base-circle-with-vertex-loop/expected.json delete mode 100644 tests/kernel-cases/import/3871-cone-base-circle-with-vertex-loop/input.step delete mode 100644 tests/kernel-cases/import/3871-cone-base-circle-with-vertex-loop/recipe.json delete mode 100644 tests/kernel-cases/import/3871-cone-bounded-only-by-its-base-circle/expected.json delete mode 100644 tests/kernel-cases/import/3871-cone-bounded-only-by-its-base-circle/input.step delete mode 100644 tests/kernel-cases/import/3871-cone-bounded-only-by-its-base-circle/recipe.json diff --git a/ATTRIBUTION.md b/ATTRIBUTION.md index 88021baec..b7d260861 100644 --- a/ATTRIBUTION.md +++ b/ATTRIBUTION.md @@ -110,8 +110,6 @@ Editable drawing code, native projects and shipped exports are collected under ` | tests/kernel-cases/import/3208-extruded-ellipse-face-over-parameter-seam/input.step | SolidCraft contributors | synthetic STEP file written by hand from ISO 10303-21 for the kernel regression case of tangency-labs/solidcraft#3208 | MIT OR Apache-2.0 | | tests/kernel-cases/import/3352-vertex-off-its-edge-curve/input.step | SolidCraft contributors | synthetic STEP file written by hand from ISO 10303-21 for the kernel regression case of tangency-labs/solidcraft#3352 | MIT OR Apache-2.0 | | tests/kernel-cases/import/3730-void-oriented-shell-false/input.step | SolidCraft contributors | synthetic STEP file written by hand from ISO 10303-21 for the kernel regression case of tangency-labs/solidcraft#3730 | MIT OR Apache-2.0 | -| tests/kernel-cases/import/3871-cone-base-circle-with-vertex-loop/input.step | step-conformance contributors | copy of tests/step-conformance/cone_point_vertex.step (generated from formulas by https://github.com/dan335/step-conformance, corpus/generated, 96f30bb); kernel regression case for tangency-labs/solidcraft#3871 | CC0-1.0 | -| tests/kernel-cases/import/3871-cone-bounded-only-by-its-base-circle/input.step | step-conformance contributors | copy of tests/step-conformance/cone_point.step (generated from formulas by https://github.com/dan335/step-conformance, corpus/generated, 96f30bb); kernel regression case for tangency-labs/solidcraft#3871 | CC0-1.0 | | tests/kernel-cases/import/3880-cylinder-seam-edge/input.step | step-conformance contributors | copy of tests/step-conformance/cylinder_seam.step (generated from formulas by https://github.com/dan335/step-conformance, corpus/generated, 96f30bb); kernel regression case for tangency-labs/solidcraft#3880 | CC0-1.0 | | tests/kernel-cases/import/3880-nurbs-hemisphere-dome/input.step | step-conformance contributors | copy of tests/step-conformance/dome_nurbs.step (generated from formulas by https://github.com/dan335/step-conformance, corpus/generated, 96f30bb); kernel regression case for tangency-labs/solidcraft#3880 | CC0-1.0 | | tests/kernel-cases/import/3963-closed-spline-edge-vertex-past-start/input.step | SolidCraft contributors | synthetic STEP file written by hand from ISO 10303-21 for the kernel regression case of tangency-labs/solidcraft#3963 | MIT OR Apache-2.0 | diff --git a/tests/kernel-cases/import/258-cone-point-vertex/expected.json b/tests/kernel-cases/import/258-cone-point-vertex/expected.json index 5f10c76fb..5cb4e77d1 100644 --- a/tests/kernel-cases/import/258-cone-point-vertex/expected.json +++ b/tests/kernel-cases/import/258-cone-point-vertex/expected.json @@ -1,6 +1,8 @@ { "sources": [ - "tangency-labs/solidcraft#258" + "tangency-labs/solidcraft#258", + "tangency-labs/solidcraft#3871", + "tangency-labs/solidcraft#3901" ], "what": "the same STEP cone with a VERTEX_LOOP at the apex: the mesh stopped 30 mm short of the apex", "source": "analytic", diff --git a/tests/kernel-cases/import/258-cone-to-point/expected.json b/tests/kernel-cases/import/258-cone-to-point/expected.json index 7cb78235f..b8481b9fc 100644 --- a/tests/kernel-cases/import/258-cone-to-point/expected.json +++ b/tests/kernel-cases/import/258-cone-to-point/expected.json @@ -1,6 +1,9 @@ { "sources": [ - "tangency-labs/solidcraft#258" + "tangency-labs/solidcraft#258", + "tangency-labs/solidcraft#3871", + "tangency-labs/solidcraft#3901", + "tangency-labs/solidcraft#3880" ], "what": "a STEP cone 20 mm across coming to a point 30 mm up (no vertex at the apex): the cone face was meshed flat at its base, so the measured shape was far off", "source": "analytic", diff --git a/tests/kernel-cases/import/3871-cone-base-circle-with-vertex-loop/expected.json b/tests/kernel-cases/import/3871-cone-base-circle-with-vertex-loop/expected.json deleted file mode 100644 index 656834297..000000000 --- a/tests/kernel-cases/import/3871-cone-base-circle-with-vertex-loop/expected.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "sources": [ - "tangency-labs/solidcraft#3871", - "tangency-labs/solidcraft#3901" - ], - "what": "the same cone with a VERTEX_LOOP at its point on the cone face: the point must still be reached, not read as a flat disc", - "source": "analytic", - "method": "cone r=10 h=30: V = 1000 pi = 3141.5927; A = pi r^2 + pi r s = 1307.6181; 2 faces", - "body_count": 1, - "volume_mm3": 3141.5927, - "area_mm2": 1307.6181, - "faces": 2, - "bbox": { - "min": [ - -10, - -10, - 0 - ], - "max": [ - 10, - 10, - 30 - ] - } -} diff --git a/tests/kernel-cases/import/3871-cone-base-circle-with-vertex-loop/input.step b/tests/kernel-cases/import/3871-cone-base-circle-with-vertex-loop/input.step deleted file mode 100644 index a0a44ffa2..000000000 --- a/tests/kernel-cases/import/3871-cone-base-circle-with-vertex-loop/input.step +++ /dev/null @@ -1,60 +0,0 @@ -ISO-10303-21; -HEADER; -FILE_DESCRIPTION(('step-conformance generated part'),'2;1'); -FILE_NAME('cone_point_vertex.step','2026-10-12T00:00:00',(''),(''),'step-conformance generate','step-conformance generate',''); -FILE_SCHEMA(('AUTOMOTIVE_DESIGN { 1 0 10303 214 1 1 1 1 }')); -ENDSEC; -DATA; -#1=( LENGTH_UNIT() NAMED_UNIT(*) SI_UNIT(.MILLI.,.METRE.) ); -#2=( NAMED_UNIT(*) PLANE_ANGLE_UNIT() SI_UNIT($,.RADIAN.) ); -#3=( NAMED_UNIT(*) SI_UNIT($,.STERADIAN.) SOLID_ANGLE_UNIT() ); -#4=UNCERTAINTY_MEASURE_WITH_UNIT(LENGTH_MEASURE(1.E-7),#1,'distance_accuracy_value','confusion accuracy'); -#5=( GEOMETRIC_REPRESENTATION_CONTEXT(3) GLOBAL_UNCERTAINTY_ASSIGNED_CONTEXT((#4)) GLOBAL_UNIT_ASSIGNED_CONTEXT((#1,#2,#3)) REPRESENTATION_CONTEXT('','3D') ); -#6=APPLICATION_CONTEXT('automotive design'); -#7=APPLICATION_PROTOCOL_DEFINITION('international standard','automotive_design',2000,#6); -#8=PRODUCT_CONTEXT('',#6,'mechanical'); -#9=PRODUCT_DEFINITION_CONTEXT('part definition',#6,'design'); -#10=PRODUCT('cone_point_vertex','cone_point_vertex','',(#8)); -#11=PRODUCT_DEFINITION_FORMATION('','',#10); -#12=PRODUCT_DEFINITION('design','',#11,#9); -#13=PRODUCT_DEFINITION_SHAPE('','',#12); -#14=CARTESIAN_POINT('',(0.0,0.0,0.0)); -#15=DIRECTION('',(0.0,0.0,1.0)); -#16=DIRECTION('',(1.0,0.0,0.0)); -#17=AXIS2_PLACEMENT_3D('',#14,#15,#16); -#18=CARTESIAN_POINT('',(0.0,0.0,0.0)); -#19=DIRECTION('',(0.0,0.0,1.0)); -#20=DIRECTION('',(1.0,0.0,0.0)); -#21=AXIS2_PLACEMENT_3D('',#18,#19,#20); -#22=CIRCLE('',#21,10.0); -#23=CARTESIAN_POINT('',(10.0,0.0,0.0)); -#24=VERTEX_POINT('',#23); -#25=EDGE_CURVE('',#24,#24,#22,.T.); -#26=CARTESIAN_POINT('',(0.0,0.0,0.0)); -#27=DIRECTION('',(0.0,0.0,1.0)); -#28=DIRECTION('',(1.0,0.0,0.0)); -#29=AXIS2_PLACEMENT_3D('',#26,#27,#28); -#30=PLANE('',#29); -#31=ORIENTED_EDGE('',*,*,#25,.F.); -#32=EDGE_LOOP('',(#31)); -#33=FACE_OUTER_BOUND('',#32,.T.); -#34=ADVANCED_FACE('',(#33),#30,.F.); -#35=CARTESIAN_POINT('',(0.0,0.0,0.0)); -#36=DIRECTION('',(0.0,0.0,-1.0)); -#37=DIRECTION('',(1.0,0.0,0.0)); -#38=AXIS2_PLACEMENT_3D('',#35,#36,#37); -#39=CONICAL_SURFACE('',#38,10.0,0.3217505543966422); -#40=ORIENTED_EDGE('',*,*,#25,.T.); -#41=EDGE_LOOP('',(#40)); -#42=CARTESIAN_POINT('',(0.0,0.0,30.0)); -#43=VERTEX_POINT('',#42); -#44=VERTEX_LOOP('',#43); -#45=FACE_OUTER_BOUND('',#41,.T.); -#46=FACE_BOUND('',#44,.T.); -#47=ADVANCED_FACE('',(#45,#46),#39,.T.); -#48=CLOSED_SHELL('',(#34,#47)); -#49=MANIFOLD_SOLID_BREP('',#48); -#50=ADVANCED_BREP_SHAPE_REPRESENTATION('',(#17,#49),#5); -#51=SHAPE_DEFINITION_REPRESENTATION(#13,#50); -ENDSEC; -END-ISO-10303-21; diff --git a/tests/kernel-cases/import/3871-cone-base-circle-with-vertex-loop/recipe.json b/tests/kernel-cases/import/3871-cone-base-circle-with-vertex-loop/recipe.json deleted file mode 100644 index 8a6bdf43b..000000000 --- a/tests/kernel-cases/import/3871-cone-base-circle-with-vertex-loop/recipe.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "commands": [ - { - "command": "file.insert_step", - "params": { - "path": "$CASE/input.step" - } - } - ] -} diff --git a/tests/kernel-cases/import/3871-cone-bounded-only-by-its-base-circle/expected.json b/tests/kernel-cases/import/3871-cone-bounded-only-by-its-base-circle/expected.json deleted file mode 100644 index f1177ea3f..000000000 --- a/tests/kernel-cases/import/3871-cone-bounded-only-by-its-base-circle/expected.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "sources": [ - "tangency-labs/solidcraft#3871", - "tangency-labs/solidcraft#3901", - "tangency-labs/solidcraft#3880" - ], - "what": "a cone whose face is bounded only by its base circle (no vertex at the point) must reach its point, not come in as a flat disc", - "source": "analytic", - "method": "cone r=10 h=30: V = pi r^2 h / 3 = 1000 pi = 3141.5927; A = pi r^2 + pi r s with s = sqrt(100+900) = 1307.6181; 2 faces", - "body_count": 1, - "volume_mm3": 3141.5927, - "area_mm2": 1307.6181, - "faces": 2, - "bbox": { - "min": [ - -10, - -10, - 0 - ], - "max": [ - 10, - 10, - 30 - ] - } -} diff --git a/tests/kernel-cases/import/3871-cone-bounded-only-by-its-base-circle/input.step b/tests/kernel-cases/import/3871-cone-bounded-only-by-its-base-circle/input.step deleted file mode 100644 index 4be1def48..000000000 --- a/tests/kernel-cases/import/3871-cone-bounded-only-by-its-base-circle/input.step +++ /dev/null @@ -1,56 +0,0 @@ -ISO-10303-21; -HEADER; -FILE_DESCRIPTION(('step-conformance generated part'),'2;1'); -FILE_NAME('cone_point.step','2026-10-12T00:00:00',(''),(''),'step-conformance generate','step-conformance generate',''); -FILE_SCHEMA(('AUTOMOTIVE_DESIGN { 1 0 10303 214 1 1 1 1 }')); -ENDSEC; -DATA; -#1=( LENGTH_UNIT() NAMED_UNIT(*) SI_UNIT(.MILLI.,.METRE.) ); -#2=( NAMED_UNIT(*) PLANE_ANGLE_UNIT() SI_UNIT($,.RADIAN.) ); -#3=( NAMED_UNIT(*) SI_UNIT($,.STERADIAN.) SOLID_ANGLE_UNIT() ); -#4=UNCERTAINTY_MEASURE_WITH_UNIT(LENGTH_MEASURE(1.E-7),#1,'distance_accuracy_value','confusion accuracy'); -#5=( GEOMETRIC_REPRESENTATION_CONTEXT(3) GLOBAL_UNCERTAINTY_ASSIGNED_CONTEXT((#4)) GLOBAL_UNIT_ASSIGNED_CONTEXT((#1,#2,#3)) REPRESENTATION_CONTEXT('','3D') ); -#6=APPLICATION_CONTEXT('automotive design'); -#7=APPLICATION_PROTOCOL_DEFINITION('international standard','automotive_design',2000,#6); -#8=PRODUCT_CONTEXT('',#6,'mechanical'); -#9=PRODUCT_DEFINITION_CONTEXT('part definition',#6,'design'); -#10=PRODUCT('cone_point','cone_point','',(#8)); -#11=PRODUCT_DEFINITION_FORMATION('','',#10); -#12=PRODUCT_DEFINITION('design','',#11,#9); -#13=PRODUCT_DEFINITION_SHAPE('','',#12); -#14=CARTESIAN_POINT('',(0.0,0.0,0.0)); -#15=DIRECTION('',(0.0,0.0,1.0)); -#16=DIRECTION('',(1.0,0.0,0.0)); -#17=AXIS2_PLACEMENT_3D('',#14,#15,#16); -#18=CARTESIAN_POINT('',(0.0,0.0,0.0)); -#19=DIRECTION('',(0.0,0.0,1.0)); -#20=DIRECTION('',(1.0,0.0,0.0)); -#21=AXIS2_PLACEMENT_3D('',#18,#19,#20); -#22=CIRCLE('',#21,10.0); -#23=CARTESIAN_POINT('',(10.0,0.0,0.0)); -#24=VERTEX_POINT('',#23); -#25=EDGE_CURVE('',#24,#24,#22,.T.); -#26=CARTESIAN_POINT('',(0.0,0.0,0.0)); -#27=DIRECTION('',(0.0,0.0,1.0)); -#28=DIRECTION('',(1.0,0.0,0.0)); -#29=AXIS2_PLACEMENT_3D('',#26,#27,#28); -#30=PLANE('',#29); -#31=ORIENTED_EDGE('',*,*,#25,.F.); -#32=EDGE_LOOP('',(#31)); -#33=FACE_OUTER_BOUND('',#32,.T.); -#34=ADVANCED_FACE('',(#33),#30,.F.); -#35=CARTESIAN_POINT('',(0.0,0.0,0.0)); -#36=DIRECTION('',(0.0,0.0,-1.0)); -#37=DIRECTION('',(1.0,0.0,0.0)); -#38=AXIS2_PLACEMENT_3D('',#35,#36,#37); -#39=CONICAL_SURFACE('',#38,10.0,0.3217505543966422); -#40=ORIENTED_EDGE('',*,*,#25,.T.); -#41=EDGE_LOOP('',(#40)); -#42=FACE_OUTER_BOUND('',#41,.T.); -#43=ADVANCED_FACE('',(#42),#39,.T.); -#44=CLOSED_SHELL('',(#34,#43)); -#45=MANIFOLD_SOLID_BREP('',#44); -#46=ADVANCED_BREP_SHAPE_REPRESENTATION('',(#17,#45),#5); -#47=SHAPE_DEFINITION_REPRESENTATION(#13,#46); -ENDSEC; -END-ISO-10303-21; diff --git a/tests/kernel-cases/import/3871-cone-bounded-only-by-its-base-circle/recipe.json b/tests/kernel-cases/import/3871-cone-bounded-only-by-its-base-circle/recipe.json deleted file mode 100644 index 8a6bdf43b..000000000 --- a/tests/kernel-cases/import/3871-cone-bounded-only-by-its-base-circle/recipe.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "commands": [ - { - "command": "file.insert_step", - "params": { - "path": "$CASE/input.step" - } - } - ] -} From 780a0652d96a42bf990b103ebb71fcb6579a23ca Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:31:27 -0400 Subject: [PATCH 39/81] Kernel rig: a volume or area can be graded as a hand-derived range where analysis only bounds it Co-Authored-By: Claude Opus 5.5 --- apps/solidcraft-cli/src/kernel_cases.rs | 35 ++++++++++++++++++++----- tests/kernel-cases/README.md | 1 + 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/apps/solidcraft-cli/src/kernel_cases.rs b/apps/solidcraft-cli/src/kernel_cases.rs index 4cf618080..07dcc4673 100644 --- a/apps/solidcraft-cli/src/kernel_cases.rs +++ b/apps/solidcraft-cli/src/kernel_cases.rs @@ -871,12 +871,18 @@ fn check_case(dir: &str, dumps: Option<&std::path::Path>, validation: solidcraft count(&mut c, "faces", got.faces); count(&mut c, "edges", edges); count(&mut c, "vertices", vertices); - if has("volume_mm3") { - c.rel("volume_mm3", got.volume, want["volume_mm3"].as_f64(), rel); - } - if has("area_mm2") { - c.rel("area_mm2", got.area, want["area_mm2"].as_f64(), rel); - } + // A measure is a value within `rel`, or an inclusive range `[min, max]` where analysis only + // bounds it (a cut removes at most its tool's volume). + let measure = |c: &mut Checks, k: &str, g: f64| { + if has(k) { + match want[k].as_array() { + Some(r) => c.push(k, json!(g), want[k].clone(), within(r, g)), + None => c.rel(k, g, want[k].as_f64(), rel), + } + } + }; + measure(&mut c, "volume_mm3", got.volume); + measure(&mut c, "area_mm2", got.area); if has("center_of_mass") { c.vec("center_of_mass", got.com, v3(&want["center_of_mass"]), abs); } @@ -962,6 +968,14 @@ pub fn run(args: &[String]) -> Result<(), String> { if bad > 0 { Err(format!("{bad} kernel case(s) failed")) } else { Ok(()) } } +/// `g` lies in the inclusive range `[min, max]`; a range without both ends holds nothing. +fn within(range: &[Value], g: f64) -> bool { + match (range.first().and_then(Value::as_f64), range.get(1).and_then(Value::as_f64), range.len()) { + (Some(lo), Some(hi), 2) => lo <= g && g <= hi, + _ => false, + } +} + #[cfg(test)] mod tests { use std::f64::consts::PI; @@ -1021,6 +1035,15 @@ mod tests { assert_eq!(surface_word(&face(1, 1, 1, 1)), "bspline"); } + #[test] + fn a_measure_range_holds_its_ends_and_nothing_outside() { + let r = [json!(22500.0), json!(24000.0)]; + assert!(within(&r, 22500.0) && within(&r, 24000.0) && within(&r, 23000.0)); + assert!(!within(&r, 22499.9) && !within(&r, 24000.1)); + assert!(!within(&[json!(1.0)], 1.0), "one end is no range"); + assert!(!within(&[json!(1.0), json!(2.0), json!(3.0)], 1.5), "three ends are no range"); + } + #[test] fn json_parts_match_within_tolerance_and_whole_numbers_exactly() { let got = json!({"bends": [{"angle_deg": 90.00001, "direction": "up", "count": 3}], "extra": 1}); diff --git a/tests/kernel-cases/README.md b/tests/kernel-cases/README.md index 3267772e7..d894f2308 100644 --- a/tests/kernel-cases/README.md +++ b/tests/kernel-cases/README.md @@ -106,6 +106,7 @@ the frozen truck-geometry PRs, a `kernel-paused` PR), for the report's coverage | `body_count`, `faces`, `edges`, `vertices` | Exact counts, where the geometry fixes them. Faces and edges count whole analytic surfaces and curves once (a full cylinder side is one face). | | `volume_mm3`, `area_mm2`, `center_of_mass`, `bbox` | As in `tests/oracle`: totals over every body, relative tolerance 1e-3 for volume and area, 1e-3 of the box diagonal for positions. | | `faces`, `edges`, `vertices`, `shells`, `body_count` as `[min, max]` | An inclusive range, where the geometry only bounds a count (a modelled thread's faces). | +| `volume_mm3`, `area_mm2` as `[min, max]` | An inclusive range, where analysis only bounds the measure: a cut removes at most its tool's volume, a join adds at most the tool's. `method` derives both ends. | | `continuity` | `{order, edges}`: every seam `edges` names reaches `order` (`g0` … `g4`), as Continuity Analysis (`inspect.continuity`) measures it: from the faces' exact surfaces, at its default 33 stations a seam and its default tolerances (1 µm, 1°, 0.01 / mm, 0.001 / mm², 0.0001 / mm³), never loosened per case. A failure names the worst seam (lowest order; of those, the one furthest past the next order's tolerance), its faces, the order it reaches and that next order's worst value. `edges`: `blend` (default), every seam of a face a fillet or chamfer made (a round, a chamfer face or a corner patch) with the faces either side of the edge it replaced, and every seam of a corner patch with the rounds it joins: what the blend is built to meet (not where a round runs into an end face, nor where two rounds meet without a patch: that seam is the input's, tangent only where the rounded edges were); `corner`, those of them on a corner patch (a blend made from several replaced edges); or a list of points `[[x,y,z], …]`, the edges nearest them, as Continuity Analysis picks them. `exact: true`: every seam reaches `order` and not the next (a case built to an order proves the measurement reads that order, no more and no less). A constant round meets its faces G1 (curvature jumps by 1 / r), a `curvature` round G2, a chamfer G0; a `corner: g2` patch is built G2 to the rounds and faces round it. | | `continuity` (older form) | `{near, within_mm, clear_mm, curvature_jump_per_mm}`: over every tangent seam lying wholly within `within_mm` of `near` (a corner's patch and its neighbours), the curvature jump across it (the faces' normal curvatures square to the seam, from their exact surfaces, at 65 stations a seam) is at most `curvature_jump_per_mm` at every station at least `clear_mm` along the seam from a vertex where two of those seams turn (where a neighbour's own G1 seam ends, which no surface is G2 to both sides of). A rolling ball's corner jumps 1 / r everywhere. | | `surface_types` | The set of kinds the faces' surfaces are, over every body, as the records hold them: `plane`, `cylinder`, `cone`, `sphere`, `torus`, `bspline` (a B-spline or NURBS surface) or `revolution` (a revolved curve). Exact: none missing, none extra. | From d184f4f2de923e2867b7bdadc5f332cb061831a1 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:42:19 -0400 Subject: [PATCH 40/81] Kernel rig: fillets keeps one case per regime; 17 replications of a case in the same regime go The sloped-basin chamfers and rounds at 0.5 mm rims repeat the 1 mm rim's regimes; two of the three knife-edge chamfer tips, the r1 and box r3 curvature corners, the r1 tangent corner, the 1 mm pocket-rim and hole-rim chamfers short of the floor and the r1 together-round each repeat a kept case's regime and grades. #854 moves to 851-chamfer-arc-top-edge-9-5, and the cases that cited a dropped one cite the kept one or state its formula. Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 25 ----- .../recipe.json | 90 --------------- .../expected.json | 25 ----- .../recipe.json | 90 --------------- .../expected.json | 25 ----- .../recipe.json | 90 --------------- .../expected.json | 25 ----- .../recipe.json | 90 --------------- .../expected.json | 28 ----- .../recipe.json | 90 --------------- .../expected.json | 28 ----- .../recipe.json | 105 ------------------ .../expected.json | 28 ----- .../recipe.json | 90 --------------- .../expected.json | 16 --- .../recipe.json | 52 --------- .../expected.json | 25 ----- .../recipe.json | 105 ------------------ .../fillets/851-chamfer-arc-2/expected.json | 11 -- .../fillets/851-chamfer-arc-2/recipe.json | 79 ------------- .../expected.json | 3 +- .../expected.json | 13 --- .../recipe.json | 79 ------------- .../expected.json | 13 --- .../851-chamfer-knife-edge-tip-2/recipe.json | 79 ------------- .../expected.json | 32 ------ .../recipe.json | 38 ------- tests/kernel-cases/fillets/KNOWN_FAILING | 1 - .../expected.json | 24 ---- .../recipe.json | 36 ------ .../expected.json | 30 ----- .../recipe.json | 38 ------- .../expected.json | 4 +- .../every-chamfer-pocket-rim-1/expected.json | 24 ---- .../every-chamfer-pocket-rim-1/recipe.json | 58 ---------- .../expected.json | 4 +- .../expected.json | 4 +- .../expected.json | 24 ---- .../every-hole-top-rim-chamfer-1/recipe.json | 42 ------- .../expected.json | 2 +- 40 files changed, 9 insertions(+), 1656 deletions(-) delete mode 100644 tests/kernel-cases/fillets/1080-chamfer-sloped-basin-0-5-mm-rim-4-past-the-rim/expected.json delete mode 100644 tests/kernel-cases/fillets/1080-chamfer-sloped-basin-0-5-mm-rim-4-past-the-rim/recipe.json delete mode 100644 tests/kernel-cases/fillets/1080-chamfer-sloped-basin-0-5-mm-rim-as-wide-as-the-rim/expected.json delete mode 100644 tests/kernel-cases/fillets/1080-chamfer-sloped-basin-0-5-mm-rim-as-wide-as-the-rim/recipe.json delete mode 100644 tests/kernel-cases/fillets/1080-chamfer-sloped-basin-0-5-mm-rim-half-its-width/expected.json delete mode 100644 tests/kernel-cases/fillets/1080-chamfer-sloped-basin-0-5-mm-rim-half-its-width/recipe.json delete mode 100644 tests/kernel-cases/fillets/1080-chamfer-sloped-basin-1-mm-rim-3-past-the-rim/expected.json delete mode 100644 tests/kernel-cases/fillets/1080-chamfer-sloped-basin-1-mm-rim-3-past-the-rim/recipe.json delete mode 100644 tests/kernel-cases/fillets/1080-fillet-sloped-basin-0-5-mm-rim-r0-25/expected.json delete mode 100644 tests/kernel-cases/fillets/1080-fillet-sloped-basin-0-5-mm-rim-r0-25/recipe.json delete mode 100644 tests/kernel-cases/fillets/1080-fillet-sloped-basin-0-5-mm-rim-r4-4-edges/expected.json delete mode 100644 tests/kernel-cases/fillets/1080-fillet-sloped-basin-0-5-mm-rim-r4-4-edges/recipe.json delete mode 100644 tests/kernel-cases/fillets/1080-fillet-sloped-basin-0-5-mm-rim-r4/expected.json delete mode 100644 tests/kernel-cases/fillets/1080-fillet-sloped-basin-0-5-mm-rim-r4/recipe.json delete mode 100644 tests/kernel-cases/fillets/1207-fillet-bar-top-edge-and-boss-arc-together-r1/expected.json delete mode 100644 tests/kernel-cases/fillets/1207-fillet-bar-top-edge-and-boss-arc-together-r1/recipe.json delete mode 100644 tests/kernel-cases/fillets/5835-chamfer-sloped-basin-4-mm-rim-2-4-edges/expected.json delete mode 100644 tests/kernel-cases/fillets/5835-chamfer-sloped-basin-4-mm-rim-2-4-edges/recipe.json delete mode 100644 tests/kernel-cases/fillets/851-chamfer-arc-2/expected.json delete mode 100644 tests/kernel-cases/fillets/851-chamfer-arc-2/recipe.json delete mode 100644 tests/kernel-cases/fillets/851-chamfer-knife-edge-tip-0-5/expected.json delete mode 100644 tests/kernel-cases/fillets/851-chamfer-knife-edge-tip-0-5/recipe.json delete mode 100644 tests/kernel-cases/fillets/851-chamfer-knife-edge-tip-2/expected.json delete mode 100644 tests/kernel-cases/fillets/851-chamfer-knife-edge-tip-2/recipe.json delete mode 100644 tests/kernel-cases/fillets/9-fillet-corner-r1-curvature-default-setback/expected.json delete mode 100644 tests/kernel-cases/fillets/9-fillet-corner-r1-curvature-default-setback/recipe.json delete mode 100644 tests/kernel-cases/fillets/every-box-corner-three-edges-r1-tangent/expected.json delete mode 100644 tests/kernel-cases/fillets/every-box-corner-three-edges-r1-tangent/recipe.json delete mode 100644 tests/kernel-cases/fillets/every-box-corner-three-edges-r3-curvature-corner/expected.json delete mode 100644 tests/kernel-cases/fillets/every-box-corner-three-edges-r3-curvature-corner/recipe.json delete mode 100644 tests/kernel-cases/fillets/every-chamfer-pocket-rim-1/expected.json delete mode 100644 tests/kernel-cases/fillets/every-chamfer-pocket-rim-1/recipe.json delete mode 100644 tests/kernel-cases/fillets/every-hole-top-rim-chamfer-1/expected.json delete mode 100644 tests/kernel-cases/fillets/every-hole-top-rim-chamfer-1/recipe.json diff --git a/tests/kernel-cases/fillets/1080-chamfer-sloped-basin-0-5-mm-rim-4-past-the-rim/expected.json b/tests/kernel-cases/fillets/1080-chamfer-sloped-basin-0-5-mm-rim-4-past-the-rim/expected.json deleted file mode 100644 index e8c618de6..000000000 --- a/tests/kernel-cases/fillets/1080-chamfer-sloped-basin-0-5-mm-rim-4-past-the-rim/expected.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "sources": [ - "tangency-labs/solidcraft#1080" - ], - "what": "the 0.5 mm front rim of a sloped basin's top chamfered 4: its leg on the top runs off the rim over the slab's front face (a cliff), so it builds as if the top went on and is cut by the front face, which it lowers to z = 28.524233 where it crosses it", - "source": "analytic", - "method": "slab 100 x 60 x 30 less the loft from the rectangle (20, 0.5)-(80, 50) at z = 30 to (30, 20)-(70, 40) at z = 10 (planar walls, a prismatoid: 20/6 (A_top + A_bottom + 4 A_mid)): V0 = 144266.666667. The chamfer's triangle in (y, z): the edge (0.5, 30), its leg on the top to (-3.5, 30), past the front face y = 0, and d down the wall to (0.5 + d (20-0.5)/L, 30 - 20 d/L), L = sqrt((20-0.5)^2 + 400), built as if the top went on and cut by the front face (the owner's ruling of 2026-10-30 (d7): a chamfer that reaches or runs past a rim builds): the triangle clipped to y >= 0, the quadrilateral (0.5, 30), (0, 30), (0, 28.524233), (3.292401, 27.135999). At height z the blend runs between the sloped end walls x = 20 + (30-z)/2 and 80 - (30-z)/2 extended, which cut it: its length there is 30 + z, so it takes Int Int (30 + z) dy dz over its section (y, z). Removed (shoelace for the area and its first moment) 184.526613. V = 144082.140054", - "body_count": 1, - "volume_mm3": 144082.14005363008, - "bbox": { - "min": [ - 0, - 0, - 0 - ], - "max": [ - 100, - 60, - 30 - ] - }, - "tolerance": { - "rel": 1e-06 - } -} diff --git a/tests/kernel-cases/fillets/1080-chamfer-sloped-basin-0-5-mm-rim-4-past-the-rim/recipe.json b/tests/kernel-cases/fillets/1080-chamfer-sloped-basin-0-5-mm-rim-4-past-the-rim/recipe.json deleted file mode 100644 index 186ae196f..000000000 --- a/tests/kernel-cases/fillets/1080-chamfer-sloped-basin-0-5-mm-rim-4-past-the-rim/recipe.json +++ /dev/null @@ -1,90 +0,0 @@ -{ - "commands": [ - { - "command": "solid.box", - "params": { - "length": 100, - "width": 60, - "height": 30, - "body_name": "Slab" - } - }, - { - "command": "sketch.create", - "params": { - "plane": "XY", - "offset": 30, - "name": "Top" - } - }, - { - "command": "sketch.rectangle.two_point", - "params": { - "p0": [ - 20, - 0.5 - ], - "p1": [ - 80, - 50 - ] - } - }, - { - "command": "sketch.finish", - "params": {} - }, - { - "command": "sketch.create", - "params": { - "plane": "XY", - "offset": 10, - "name": "Bottom" - } - }, - { - "command": "sketch.rectangle.two_point", - "params": { - "p0": [ - 30, - 20 - ], - "p1": [ - 70, - 40 - ] - } - }, - { - "command": "sketch.finish", - "params": {} - }, - { - "command": "solid.loft", - "params": { - "sections": [ - { - "sketch": "Top" - }, - { - "sketch": "Bottom" - } - ], - "operation": "cut" - } - }, - { - "command": "solid.chamfer", - "params": { - "edges": [ - [ - 50, - 0.5, - 30 - ] - ], - "distance": 4 - } - } - ] -} diff --git a/tests/kernel-cases/fillets/1080-chamfer-sloped-basin-0-5-mm-rim-as-wide-as-the-rim/expected.json b/tests/kernel-cases/fillets/1080-chamfer-sloped-basin-0-5-mm-rim-as-wide-as-the-rim/expected.json deleted file mode 100644 index c2c4a4bba..000000000 --- a/tests/kernel-cases/fillets/1080-chamfer-sloped-basin-0-5-mm-rim-as-wide-as-the-rim/expected.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "sources": [ - "tangency-labs/solidcraft#1080" - ], - "what": "the 0.5 mm front rim of a sloped basin's top chamfered 0.5, as wide as the rim: its leg on the top ends on the slab's front edge, using the rim's top up, and it builds", - "source": "analytic", - "method": "slab 100 x 60 x 30 less the loft from the rectangle (20, 0.5)-(80, 50) at z = 30 to (30, 20)-(70, 40) at z = 10 (planar walls, a prismatoid: 20/6 (A_top + A_bottom + 4 A_mid)): V0 = 144266.666667. The chamfer's triangle in (y, z): the edge (0.5, 30), its leg on the top to (0, 30), the slab's front edge, and d down the wall to (0.5 + d (20-0.5)/L, 30 - 20 d/L), L = sqrt((20-0.5)^2 + 400) (the owner's ruling of 2026-10-30 (d7): a chamfer that reaches or runs past a rim builds). At height z the blend runs between the sloped end walls x = 20 + (30-z)/2 and 80 - (30-z)/2 extended, which cut it: its length there is 30 + z, so it takes Int Int (30 + z) dy dz over its section (y, z). Removed (shoelace for the area and its first moment) 5.359321. V = 144261.307346", - "body_count": 1, - "volume_mm3": 144261.307345957, - "bbox": { - "min": [ - 0, - 0, - 0 - ], - "max": [ - 100, - 60, - 30 - ] - }, - "tolerance": { - "rel": 1e-06 - } -} diff --git a/tests/kernel-cases/fillets/1080-chamfer-sloped-basin-0-5-mm-rim-as-wide-as-the-rim/recipe.json b/tests/kernel-cases/fillets/1080-chamfer-sloped-basin-0-5-mm-rim-as-wide-as-the-rim/recipe.json deleted file mode 100644 index a1891b16d..000000000 --- a/tests/kernel-cases/fillets/1080-chamfer-sloped-basin-0-5-mm-rim-as-wide-as-the-rim/recipe.json +++ /dev/null @@ -1,90 +0,0 @@ -{ - "commands": [ - { - "command": "solid.box", - "params": { - "length": 100, - "width": 60, - "height": 30, - "body_name": "Slab" - } - }, - { - "command": "sketch.create", - "params": { - "plane": "XY", - "offset": 30, - "name": "Top" - } - }, - { - "command": "sketch.rectangle.two_point", - "params": { - "p0": [ - 20, - 0.5 - ], - "p1": [ - 80, - 50 - ] - } - }, - { - "command": "sketch.finish", - "params": {} - }, - { - "command": "sketch.create", - "params": { - "plane": "XY", - "offset": 10, - "name": "Bottom" - } - }, - { - "command": "sketch.rectangle.two_point", - "params": { - "p0": [ - 30, - 20 - ], - "p1": [ - 70, - 40 - ] - } - }, - { - "command": "sketch.finish", - "params": {} - }, - { - "command": "solid.loft", - "params": { - "sections": [ - { - "sketch": "Top" - }, - { - "sketch": "Bottom" - } - ], - "operation": "cut" - } - }, - { - "command": "solid.chamfer", - "params": { - "edges": [ - [ - 50, - 0.5, - 30 - ] - ], - "distance": 0.5 - } - } - ] -} diff --git a/tests/kernel-cases/fillets/1080-chamfer-sloped-basin-0-5-mm-rim-half-its-width/expected.json b/tests/kernel-cases/fillets/1080-chamfer-sloped-basin-0-5-mm-rim-half-its-width/expected.json deleted file mode 100644 index d85c8fa38..000000000 --- a/tests/kernel-cases/fillets/1080-chamfer-sloped-basin-0-5-mm-rim-half-its-width/expected.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "sources": [ - "tangency-labs/solidcraft#1080" - ], - "what": "the 0.5 mm front rim of a sloped basin's top chamfered 0.25, half the rim's width: it fits", - "source": "analytic", - "method": "slab 100 x 60 x 30 less the loft from the rectangle (20, 0.5)-(80, 50) at z = 30 to (30, 20)-(70, 40) at z = 10 (planar walls, a prismatoid: 20/6 (A_top + A_bottom + 4 A_mid)): V0 = 144266.666667. The chamfer's triangle in (y, z): the edge (0.5, 30), its leg on the top to (0.25, 30) and d down the wall to (0.5 + d (20-0.5)/L, 30 - 20 d/L), L = sqrt((20-0.5)^2 + 400). At height z the blend runs between the sloped end walls x = 20 + (30-z)/2 and 80 - (30-z)/2 extended, which cut it: its length there is 30 + z, so it takes Int Int (30 + z) dy dz over its section (y, z). Removed (shoelace for the area and its first moment) 1.341165. V = 144265.325501", - "body_count": 1, - "volume_mm3": 144265.32550144705, - "bbox": { - "min": [ - 0, - 0, - 0 - ], - "max": [ - 100, - 60, - 30 - ] - }, - "tolerance": { - "rel": 1e-06 - } -} diff --git a/tests/kernel-cases/fillets/1080-chamfer-sloped-basin-0-5-mm-rim-half-its-width/recipe.json b/tests/kernel-cases/fillets/1080-chamfer-sloped-basin-0-5-mm-rim-half-its-width/recipe.json deleted file mode 100644 index 5226fb4f6..000000000 --- a/tests/kernel-cases/fillets/1080-chamfer-sloped-basin-0-5-mm-rim-half-its-width/recipe.json +++ /dev/null @@ -1,90 +0,0 @@ -{ - "commands": [ - { - "command": "solid.box", - "params": { - "length": 100, - "width": 60, - "height": 30, - "body_name": "Slab" - } - }, - { - "command": "sketch.create", - "params": { - "plane": "XY", - "offset": 30, - "name": "Top" - } - }, - { - "command": "sketch.rectangle.two_point", - "params": { - "p0": [ - 20, - 0.5 - ], - "p1": [ - 80, - 50 - ] - } - }, - { - "command": "sketch.finish", - "params": {} - }, - { - "command": "sketch.create", - "params": { - "plane": "XY", - "offset": 10, - "name": "Bottom" - } - }, - { - "command": "sketch.rectangle.two_point", - "params": { - "p0": [ - 30, - 20 - ], - "p1": [ - 70, - 40 - ] - } - }, - { - "command": "sketch.finish", - "params": {} - }, - { - "command": "solid.loft", - "params": { - "sections": [ - { - "sketch": "Top" - }, - { - "sketch": "Bottom" - } - ], - "operation": "cut" - } - }, - { - "command": "solid.chamfer", - "params": { - "edges": [ - [ - 50, - 0.5, - 30 - ] - ], - "distance": 0.25 - } - } - ] -} diff --git a/tests/kernel-cases/fillets/1080-chamfer-sloped-basin-1-mm-rim-3-past-the-rim/expected.json b/tests/kernel-cases/fillets/1080-chamfer-sloped-basin-1-mm-rim-3-past-the-rim/expected.json deleted file mode 100644 index 91c72f822..000000000 --- a/tests/kernel-cases/fillets/1080-chamfer-sloped-basin-1-mm-rim-3-past-the-rim/expected.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "sources": [ - "tangency-labs/solidcraft#1080" - ], - "what": "the 1 mm front rim of a sloped basin's top chamfered 3: its leg on the top runs off the rim over the slab's front face (a cliff), so it builds as if the top went on and is cut by the front face, which it lowers to z = 29.141377 where it crosses it", - "source": "analytic", - "method": "slab 100 x 60 x 30 less the loft from the rectangle (20, 1)-(80, 50) at z = 30 to (30, 20)-(70, 40) at z = 10 (planar walls, a prismatoid: 20/6 (A_top + A_bottom + 4 A_mid)): V0 = 144533.333333. The chamfer's triangle in (y, z): the edge (1, 30), its leg on the top to (-2, 30), past the front face y = 0, and d down the wall to (1 + d (20-1)/L, 30 - 20 d/L), L = sqrt((20-1)^2 + 400), built as if the top went on and cut by the front face (the owner's ruling of 2026-10-30 (d7): a chamfer that reaches or runs past a rim builds): the triangle clipped to y >= 0, the quadrilateral (1, 30), (0, 30), (0, 29.141377), (3.066248, 27.825002). At height z the blend runs between the sloped end walls x = 20 + (30-z)/2 and 80 - (30-z)/2 extended, which cut it: its length there is 30 + z, so it takes Int Int (30 + z) dy dz over its section (y, z). Removed (shoelace for the area and its first moment) 142.112912. V = 144391.220421", - "body_count": 1, - "volume_mm3": 144391.22042136008, - "bbox": { - "min": [ - 0, - 0, - 0 - ], - "max": [ - 100, - 60, - 30 - ] - }, - "tolerance": { - "rel": 1e-06 - } -} diff --git a/tests/kernel-cases/fillets/1080-chamfer-sloped-basin-1-mm-rim-3-past-the-rim/recipe.json b/tests/kernel-cases/fillets/1080-chamfer-sloped-basin-1-mm-rim-3-past-the-rim/recipe.json deleted file mode 100644 index 22e8a389e..000000000 --- a/tests/kernel-cases/fillets/1080-chamfer-sloped-basin-1-mm-rim-3-past-the-rim/recipe.json +++ /dev/null @@ -1,90 +0,0 @@ -{ - "commands": [ - { - "command": "solid.box", - "params": { - "length": 100, - "width": 60, - "height": 30, - "body_name": "Slab" - } - }, - { - "command": "sketch.create", - "params": { - "plane": "XY", - "offset": 30, - "name": "Top" - } - }, - { - "command": "sketch.rectangle.two_point", - "params": { - "p0": [ - 20, - 1 - ], - "p1": [ - 80, - 50 - ] - } - }, - { - "command": "sketch.finish", - "params": {} - }, - { - "command": "sketch.create", - "params": { - "plane": "XY", - "offset": 10, - "name": "Bottom" - } - }, - { - "command": "sketch.rectangle.two_point", - "params": { - "p0": [ - 30, - 20 - ], - "p1": [ - 70, - 40 - ] - } - }, - { - "command": "sketch.finish", - "params": {} - }, - { - "command": "solid.loft", - "params": { - "sections": [ - { - "sketch": "Top" - }, - { - "sketch": "Bottom" - } - ], - "operation": "cut" - } - }, - { - "command": "solid.chamfer", - "params": { - "edges": [ - [ - 50, - 1, - 30 - ] - ], - "distance": 3 - } - } - ] -} diff --git a/tests/kernel-cases/fillets/1080-fillet-sloped-basin-0-5-mm-rim-r0-25/expected.json b/tests/kernel-cases/fillets/1080-fillet-sloped-basin-0-5-mm-rim-r0-25/expected.json deleted file mode 100644 index 5a9285d1c..000000000 --- a/tests/kernel-cases/fillets/1080-fillet-sloped-basin-0-5-mm-rim-r0-25/expected.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "sources": [ - "tangency-labs/solidcraft#1080" - ], - "what": "the 0.5 mm front rim of a sloped basin's top rounded R0.25: it fits on the rim", - "source": "analytic", - "method": "slab 100 x 60 x 30 less the loft from the rectangle (20, 0.5)-(80, 50) at z = 30 to (30, 20)-(70, 40) at z = 10 (planar walls, a prismatoid: 20/6 (A_top + A_bottom + 4 A_mid)): V0 = 144266.666667. The wall leans (20-0.5) out over 20 down: the faces meet at 134.2748 deg, so the round's contacts lie r cot(t/2) = 0.105412 from the edge, on the top at y = 0.394588 and down the wall, its centre under the top contact at z = 30 - r. At height z the blend runs between the sloped end walls x = 20 + (30-z)/2 and 80 - (30-z)/2 extended, which cut it: its length there is 30 + z, so it takes Int Int (30 + z) dy dz over its section (y, z). Removed 0.084803. V = 144266.581864", - "body_count": 1, - "volume_mm3": 144266.58186392413, - "bbox": { - "min": [ - 0, - 0, - 0 - ], - "max": [ - 100, - 60, - 30 - ] - }, - "tolerance": { - "rel": 1e-06 - }, - "continuity": { - "order": "g1" - } -} diff --git a/tests/kernel-cases/fillets/1080-fillet-sloped-basin-0-5-mm-rim-r0-25/recipe.json b/tests/kernel-cases/fillets/1080-fillet-sloped-basin-0-5-mm-rim-r0-25/recipe.json deleted file mode 100644 index ced834e8e..000000000 --- a/tests/kernel-cases/fillets/1080-fillet-sloped-basin-0-5-mm-rim-r0-25/recipe.json +++ /dev/null @@ -1,90 +0,0 @@ -{ - "commands": [ - { - "command": "solid.box", - "params": { - "length": 100, - "width": 60, - "height": 30, - "body_name": "Slab" - } - }, - { - "command": "sketch.create", - "params": { - "plane": "XY", - "offset": 30, - "name": "Top" - } - }, - { - "command": "sketch.rectangle.two_point", - "params": { - "p0": [ - 20, - 0.5 - ], - "p1": [ - 80, - 50 - ] - } - }, - { - "command": "sketch.finish", - "params": {} - }, - { - "command": "sketch.create", - "params": { - "plane": "XY", - "offset": 10, - "name": "Bottom" - } - }, - { - "command": "sketch.rectangle.two_point", - "params": { - "p0": [ - 30, - 20 - ], - "p1": [ - 70, - 40 - ] - } - }, - { - "command": "sketch.finish", - "params": {} - }, - { - "command": "solid.loft", - "params": { - "sections": [ - { - "sketch": "Top" - }, - { - "sketch": "Bottom" - } - ], - "operation": "cut" - } - }, - { - "command": "solid.fillet", - "params": { - "edges": [ - [ - 50, - 0.5, - 30 - ] - ], - "radius": 0.25 - } - } - ] -} diff --git a/tests/kernel-cases/fillets/1080-fillet-sloped-basin-0-5-mm-rim-r4-4-edges/expected.json b/tests/kernel-cases/fillets/1080-fillet-sloped-basin-0-5-mm-rim-r4-4-edges/expected.json deleted file mode 100644 index 85c6c9343..000000000 --- a/tests/kernel-cases/fillets/1080-fillet-sloped-basin-0-5-mm-rim-r4-4-edges/expected.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "sources": [ - "tangency-labs/solidcraft#1080" - ], - "what": "all four of the top rim edges of a sloped basin with a 0.5 mm front rim rounded R4, mitred at the rim's corners: past the thin rim the front round runs over the slab's front face and is cut from the slab", - "source": "analytic", - "method": "slab 100 x 60 x 30 less the loft from the rectangle (20, 0.5)-(80, 50) at z = 30 to (30, 20)-(70, 40) at z = 10 (planar walls, a prismatoid: 20/6 (A_top + A_bottom + 4 A_mid)): V0 = 144266.666667. Each blend's section at height z spans from its wall to its arc (or chamfer line), the front one not past y = 0, the slab's face; its edge runs between its neighbours' walls (the sloped end walls extended), so it takes Int width(z) length(z) dz. At a re-entrant corner of two picked edges the blends meet in a mitre (the owner's ruling of 2026-10-30): each runs on past the corner and the quadrant beyond both walls loses what both take, Int width_1(z) width_2(z) dz. Removed 182.348561. V = 144084.318105", - "body_count": 1, - "volume_mm3": 144084.31810540144, - "bbox": { - "min": [ - 0, - 0, - 0 - ], - "max": [ - 100, - 60, - 30 - ] - }, - "tolerance": { - "rel": 1e-06 - }, - "continuity": { - "order": "g1" - } -} diff --git a/tests/kernel-cases/fillets/1080-fillet-sloped-basin-0-5-mm-rim-r4-4-edges/recipe.json b/tests/kernel-cases/fillets/1080-fillet-sloped-basin-0-5-mm-rim-r4-4-edges/recipe.json deleted file mode 100644 index 1cc404fd5..000000000 --- a/tests/kernel-cases/fillets/1080-fillet-sloped-basin-0-5-mm-rim-r4-4-edges/recipe.json +++ /dev/null @@ -1,105 +0,0 @@ -{ - "commands": [ - { - "command": "solid.box", - "params": { - "length": 100, - "width": 60, - "height": 30, - "body_name": "Slab" - } - }, - { - "command": "sketch.create", - "params": { - "plane": "XY", - "offset": 30, - "name": "Top" - } - }, - { - "command": "sketch.rectangle.two_point", - "params": { - "p0": [ - 20, - 0.5 - ], - "p1": [ - 80, - 50 - ] - } - }, - { - "command": "sketch.finish", - "params": {} - }, - { - "command": "sketch.create", - "params": { - "plane": "XY", - "offset": 10, - "name": "Bottom" - } - }, - { - "command": "sketch.rectangle.two_point", - "params": { - "p0": [ - 30, - 20 - ], - "p1": [ - 70, - 40 - ] - } - }, - { - "command": "sketch.finish", - "params": {} - }, - { - "command": "solid.loft", - "params": { - "sections": [ - { - "sketch": "Top" - }, - { - "sketch": "Bottom" - } - ], - "operation": "cut" - } - }, - { - "command": "solid.fillet", - "params": { - "edges": [ - [ - 50, - 0.5, - 30 - ], - [ - 80, - 27, - 30 - ], - [ - 50, - 50, - 30 - ], - [ - 20, - 27, - 30 - ] - ], - "radius": 4 - } - } - ] -} diff --git a/tests/kernel-cases/fillets/1080-fillet-sloped-basin-0-5-mm-rim-r4/expected.json b/tests/kernel-cases/fillets/1080-fillet-sloped-basin-0-5-mm-rim-r4/expected.json deleted file mode 100644 index ec6e46e78..000000000 --- a/tests/kernel-cases/fillets/1080-fillet-sloped-basin-0-5-mm-rim-r4/expected.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "sources": [ - "tangency-labs/solidcraft#1080" - ], - "what": "the 0.5 mm front rim of a sloped basin's top rounded R4: the round runs over the rim's top past the slab's front face (a cliff) and is cut from the slab", - "source": "analytic", - "method": "slab 100 x 60 x 30 less the loft from the rectangle (20, 0.5)-(80, 50) at z = 30 to (30, 20)-(70, 40) at z = 10 (planar walls, a prismatoid: 20/6 (A_top + A_bottom + 4 A_mid)): V0 = 144266.666667. The wall leans (20-0.5) out over 20 down: the faces meet at 134.2748 deg, so the round's contacts lie r cot(t/2) = 1.686591 from the edge, on the top at y = -1.186591 and down the wall, its centre under the top contact at z = 30 - r. The round is built as if the top went on past y = 0 and cut from the slab (a round past a face on its tangent side builds: the owner's ruling of 2026-10-30), so its section counts only at y >= 0. At height z the blend runs between the sloped end walls x = 20 + (30-z)/2 and 80 - (30-z)/2 extended, which cut it: its length there is 30 + z, so it takes Int Int (30 + z) dy dz over its section (y, z). Removed 17.395317. V = 144249.271350", - "body_count": 1, - "volume_mm3": 144249.27134953788, - "bbox": { - "min": [ - 0, - 0, - 0 - ], - "max": [ - 100, - 60, - 30 - ] - }, - "tolerance": { - "rel": 1e-06 - }, - "continuity": { - "order": "g1" - } -} diff --git a/tests/kernel-cases/fillets/1080-fillet-sloped-basin-0-5-mm-rim-r4/recipe.json b/tests/kernel-cases/fillets/1080-fillet-sloped-basin-0-5-mm-rim-r4/recipe.json deleted file mode 100644 index 47dfe7c87..000000000 --- a/tests/kernel-cases/fillets/1080-fillet-sloped-basin-0-5-mm-rim-r4/recipe.json +++ /dev/null @@ -1,90 +0,0 @@ -{ - "commands": [ - { - "command": "solid.box", - "params": { - "length": 100, - "width": 60, - "height": 30, - "body_name": "Slab" - } - }, - { - "command": "sketch.create", - "params": { - "plane": "XY", - "offset": 30, - "name": "Top" - } - }, - { - "command": "sketch.rectangle.two_point", - "params": { - "p0": [ - 20, - 0.5 - ], - "p1": [ - 80, - 50 - ] - } - }, - { - "command": "sketch.finish", - "params": {} - }, - { - "command": "sketch.create", - "params": { - "plane": "XY", - "offset": 10, - "name": "Bottom" - } - }, - { - "command": "sketch.rectangle.two_point", - "params": { - "p0": [ - 30, - 20 - ], - "p1": [ - 70, - 40 - ] - } - }, - { - "command": "sketch.finish", - "params": {} - }, - { - "command": "solid.loft", - "params": { - "sections": [ - { - "sketch": "Top" - }, - { - "sketch": "Bottom" - } - ], - "operation": "cut" - } - }, - { - "command": "solid.fillet", - "params": { - "edges": [ - [ - 50, - 0.5, - 30 - ] - ], - "radius": 4 - } - } - ] -} diff --git a/tests/kernel-cases/fillets/1207-fillet-bar-top-edge-and-boss-arc-together-r1/expected.json b/tests/kernel-cases/fillets/1207-fillet-bar-top-edge-and-boss-arc-together-r1/expected.json deleted file mode 100644 index e6b72c268..000000000 --- a/tests/kernel-cases/fillets/1207-fillet-bar-top-edge-and-boss-arc-together-r1/expected.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "sources": [ - "tangency-labs/solidcraft#1207" - ], - "what": "the bar's top edge and the partial base arc of a boss standing out over the bar's side, rounded r1 together: the corner patch where they meet must join the bar's round at least G1 (today a 13.1° crease)", - "source": "analytic", - "method": "bar 100x30x10 (y -15..15) joined with a diameter 40 boss 20 tall at the origin, standing out over both sides (V0 = 49756.1794, as 1207-fillet-concave-arc-at-boss). The bar's front top edge (y=-15, z=10) and the boss's base arc over the bar (its two edges, split at the cylinder's seam: the tangent chain) rounded r1 together meet at (13.229, -15, 10), where the third edge, the boss's line on the front face, is concave and runs down. Away from that corner the body is V0 plus the arc round's spandrel strip ending on y=+-15 (integral over rho of [r - sqrt(r^2-(20+r-rho)^2)] rho 2 asin(15/rho) = 7.2537, Simpson) less the front round's spandrel out to the boss wall (integral over y of [r - sqrt(r^2-(y+15-r)^2)] (100 - sqrt(400-y^2)) = 18.5684); the corner patch lies within the cube of side 2r about the vertex, so V is graded as V0 + add - removed with (2r)^3 as its tolerance", - "body_count": 1, - "volume_mm3": 49744.864673399745, - "tolerance": { - "rel": 0.00016082062043035108 - }, - "continuity": { - "order": "g1" - } -} \ No newline at end of file diff --git a/tests/kernel-cases/fillets/1207-fillet-bar-top-edge-and-boss-arc-together-r1/recipe.json b/tests/kernel-cases/fillets/1207-fillet-bar-top-edge-and-boss-arc-together-r1/recipe.json deleted file mode 100644 index 51ea837f5..000000000 --- a/tests/kernel-cases/fillets/1207-fillet-bar-top-edge-and-boss-arc-together-r1/recipe.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "commands": [ - { - "command": "solid.box", - "params": { - "length": 100, - "width": 30, - "height": 10, - "corner": [ - 0, - -15, - 0 - ], - "body_name": "Arm" - } - }, - { - "command": "solid.cylinder", - "params": { - "diameter": 40, - "height": 20, - "base": [ - 0, - 0, - 0 - ], - "operation": "join", - "targets": [ - "Arm" - ] - } - }, - { - "command": "solid.fillet", - "params": { - "edges": [ - [ - 60, - -15, - 10 - ], - [ - 16, - 12, - 10 - ] - ], - "radius": 1 - } - } - ] -} diff --git a/tests/kernel-cases/fillets/5835-chamfer-sloped-basin-4-mm-rim-2-4-edges/expected.json b/tests/kernel-cases/fillets/5835-chamfer-sloped-basin-4-mm-rim-2-4-edges/expected.json deleted file mode 100644 index aafb6a426..000000000 --- a/tests/kernel-cases/fillets/5835-chamfer-sloped-basin-4-mm-rim-2-4-edges/expected.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "sources": [ - "tangency-labs/solidcraft#5835" - ], - "what": "all four of the top rim edges of a sloped basin whose walls slope unequally, its front rim 4 mm wide, chamfered 2: the chamfers meet in mitres at the rim's corners", - "source": "analytic", - "method": "slab 100 x 60 x 30 less the loft from the rectangle (20, 4)-(80, 50) at z = 30 to (30, 20)-(70, 40) at z = 10 (planar walls, a prismatoid: 20/6 (A_top + A_bottom + 4 A_mid)): V0 = 146133.333333. Each blend's section at height z spans from its wall to its arc (or chamfer line), inside its rim; its edge runs between its neighbours' walls (the sloped end walls extended), so it takes Int width(z) length(z) dz. At a re-entrant corner of two picked edges the blends meet in a mitre (the owner's ruling of 2026-10-30): each runs on past the corner and the quadrant beyond both walls loses what both take, Int width_1(z) width_2(z) dz. Removed 370.156402. V = 145763.176931", - "body_count": 1, - "volume_mm3": 145763.17693088384, - "bbox": { - "min": [ - 0, - 0, - 0 - ], - "max": [ - 100, - 60, - 30 - ] - }, - "tolerance": { - "rel": 1e-06 - } -} diff --git a/tests/kernel-cases/fillets/5835-chamfer-sloped-basin-4-mm-rim-2-4-edges/recipe.json b/tests/kernel-cases/fillets/5835-chamfer-sloped-basin-4-mm-rim-2-4-edges/recipe.json deleted file mode 100644 index 83e0b7e83..000000000 --- a/tests/kernel-cases/fillets/5835-chamfer-sloped-basin-4-mm-rim-2-4-edges/recipe.json +++ /dev/null @@ -1,105 +0,0 @@ -{ - "commands": [ - { - "command": "solid.box", - "params": { - "length": 100, - "width": 60, - "height": 30, - "body_name": "Slab" - } - }, - { - "command": "sketch.create", - "params": { - "plane": "XY", - "offset": 30, - "name": "Top" - } - }, - { - "command": "sketch.rectangle.two_point", - "params": { - "p0": [ - 20, - 4 - ], - "p1": [ - 80, - 50 - ] - } - }, - { - "command": "sketch.finish", - "params": {} - }, - { - "command": "sketch.create", - "params": { - "plane": "XY", - "offset": 10, - "name": "Bottom" - } - }, - { - "command": "sketch.rectangle.two_point", - "params": { - "p0": [ - 30, - 20 - ], - "p1": [ - 70, - 40 - ] - } - }, - { - "command": "sketch.finish", - "params": {} - }, - { - "command": "solid.loft", - "params": { - "sections": [ - { - "sketch": "Top" - }, - { - "sketch": "Bottom" - } - ], - "operation": "cut" - } - }, - { - "command": "solid.chamfer", - "params": { - "edges": [ - [ - 50, - 4, - 30 - ], - [ - 80, - 27, - 30 - ], - [ - 50, - 50, - 30 - ], - [ - 20, - 27, - 30 - ] - ], - "distance": 2 - } - } - ] -} diff --git a/tests/kernel-cases/fillets/851-chamfer-arc-2/expected.json b/tests/kernel-cases/fillets/851-chamfer-arc-2/expected.json deleted file mode 100644 index 6caecc299..000000000 --- a/tests/kernel-cases/fillets/851-chamfer-arc-2/expected.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "sources": [ - "tangency-labs/solidcraft#851", - "tangency-labs/solidcraft#854" - ], - "what": "on #851's knife-edge part (tessellation/1263): the arc's top edge chamfered 2", - "source": "invariants", - "method": "a 2 mm chamfer fits on these edges (the arc's chamfer is a cone cut by the back face where the arc runs into it); one closed valid solid whose display mesh closes is the right answer", - "body_count": 1, - "watertight": true -} diff --git a/tests/kernel-cases/fillets/851-chamfer-arc-2/recipe.json b/tests/kernel-cases/fillets/851-chamfer-arc-2/recipe.json deleted file mode 100644 index b6309bcb9..000000000 --- a/tests/kernel-cases/fillets/851-chamfer-arc-2/recipe.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "commands": [ - { - "command": "solid.box", - "params": { - "length": 41.166666666666664, - "width": 21, - "height": 10, - "corner": [ - 0, - -21, - 0 - ], - "body_name": "Plate" - } - }, - { - "command": "solid.box", - "params": { - "length": 21, - "width": 21, - "height": 10, - "corner": [ - 41.166666666666664, - -21, - 0 - ], - "body_name": "Corner" - } - }, - { - "command": "solid.cylinder", - "params": { - "radius": 21, - "height": 10, - "base": [ - 62.166666666666664, - -21, - 0 - ], - "body_name": "Round" - } - }, - { - "command": "solid.combine", - "params": { - "target": "Corner", - "tools": [ - "Round" - ], - "operation": "cut" - } - }, - { - "command": "solid.combine", - "params": { - "target": "Plate", - "tools": [ - "Corner" - ], - "operation": "join" - } - }, - { - "command": "solid.chamfer", - "params": { - "edges": [ - [ - 47.31742426174917, - -6.150757595082503, - 10 - ] - ], - "distance": 2, - "tangent_chain": false - } - } - ] -} diff --git a/tests/kernel-cases/fillets/851-chamfer-arc-top-edge-9-5/expected.json b/tests/kernel-cases/fillets/851-chamfer-arc-top-edge-9-5/expected.json index 454b078ab..2405dbd33 100644 --- a/tests/kernel-cases/fillets/851-chamfer-arc-top-edge-9-5/expected.json +++ b/tests/kernel-cases/fillets/851-chamfer-arc-top-edge-9-5/expected.json @@ -1,7 +1,8 @@ { "sources": [ "tangency-labs/solidcraft#851", - "tangency-labs/solidcraft#1113" + "tangency-labs/solidcraft#1113", + "tangency-labs/solidcraft#854" ], "what": "the top edge of #851's concave R21 wall chamfered 9.5, just under its height", "source": "analytic", diff --git a/tests/kernel-cases/fillets/851-chamfer-knife-edge-tip-0-5/expected.json b/tests/kernel-cases/fillets/851-chamfer-knife-edge-tip-0-5/expected.json deleted file mode 100644 index e9422a6e3..000000000 --- a/tests/kernel-cases/fillets/851-chamfer-knife-edge-tip-0-5/expected.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "sources": [ - "tangency-labs/solidcraft#851" - ], - "what": "the knife edge where #851's concave R21 wall runs out tangent into the back face, chamfered 0.5: the plane through the contacts of the ball of radius 0.5", - "source": "analytic", - "method": "plate x 0..41.1667, y -21..0 and the corner x 41.1667..62.1667 less the cylinder r 21 about (62.1667, -21), 10 high (tessellation/1263): V0 = 10 (62.1667 x 21 - pi 21^2/4) = 9591.394099. The chamfer cuts along the chord between the contacts of the ball of radius d = 0.5 that fits there (as the R0.5 round's): on the back face at x = 62.1667 - sqrt(84 d), on the wall where the line from its axis to the ball's centre meets it. It takes the triangle plane contact, tip, wall contact less the wall's circular segment R^2/2 (b - sin b), b = acos((21-d)/(21+d)): 2.114982 mm^2, times 10. V = 9570.244281", - "body_count": 1, - "volume_mm3": 9570.244281078343, - "continuity": { - "order": "g0" - } -} diff --git a/tests/kernel-cases/fillets/851-chamfer-knife-edge-tip-0-5/recipe.json b/tests/kernel-cases/fillets/851-chamfer-knife-edge-tip-0-5/recipe.json deleted file mode 100644 index 582276da6..000000000 --- a/tests/kernel-cases/fillets/851-chamfer-knife-edge-tip-0-5/recipe.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "commands": [ - { - "command": "solid.box", - "params": { - "length": 41.166666666666664, - "width": 21, - "height": 10, - "corner": [ - 0, - -21, - 0 - ], - "body_name": "Plate" - } - }, - { - "command": "solid.box", - "params": { - "length": 21, - "width": 21, - "height": 10, - "corner": [ - 41.166666666666664, - -21, - 0 - ], - "body_name": "Corner" - } - }, - { - "command": "solid.cylinder", - "params": { - "radius": 21, - "height": 10, - "base": [ - 62.166666666666664, - -21, - 0 - ], - "body_name": "Round" - } - }, - { - "command": "solid.combine", - "params": { - "target": "Corner", - "tools": [ - "Round" - ], - "operation": "cut" - } - }, - { - "command": "solid.combine", - "params": { - "target": "Plate", - "tools": [ - "Corner" - ], - "operation": "join" - } - }, - { - "command": "solid.chamfer", - "params": { - "edges": [ - [ - 62.166666666666664, - 0, - 5 - ] - ], - "distance": 0.5, - "tangent_chain": false - } - } - ] -} diff --git a/tests/kernel-cases/fillets/851-chamfer-knife-edge-tip-2/expected.json b/tests/kernel-cases/fillets/851-chamfer-knife-edge-tip-2/expected.json deleted file mode 100644 index b7d098aca..000000000 --- a/tests/kernel-cases/fillets/851-chamfer-knife-edge-tip-2/expected.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "sources": [ - "tangency-labs/solidcraft#851" - ], - "what": "the knife edge where #851's concave R21 wall runs out tangent into the back face, chamfered 2: the plane through the contacts of the ball of radius 2", - "source": "analytic", - "method": "plate x 0..41.1667, y -21..0 and the corner x 41.1667..62.1667 less the cylinder r 21 about (62.1667, -21), 10 high (tessellation/1263): V0 = 10 (62.1667 x 21 - pi 21^2/4) = 9591.394099. The chamfer cuts along the chord between the contacts of the ball of radius d = 2 that fits there (as the R2 round's): on the back face at x = 62.1667 - sqrt(84 d), on the wall where the line from its axis to the ball's centre meets it. It takes the triangle plane contact, tip, wall contact less the wall's circular segment R^2/2 (b - sin b), b = acos((21-d)/(21+d)): 15.923645 mm^2, times 10. V = 9432.157649", - "body_count": 1, - "volume_mm3": 9432.15764867435, - "continuity": { - "order": "g0" - } -} diff --git a/tests/kernel-cases/fillets/851-chamfer-knife-edge-tip-2/recipe.json b/tests/kernel-cases/fillets/851-chamfer-knife-edge-tip-2/recipe.json deleted file mode 100644 index ff00c1c38..000000000 --- a/tests/kernel-cases/fillets/851-chamfer-knife-edge-tip-2/recipe.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "commands": [ - { - "command": "solid.box", - "params": { - "length": 41.166666666666664, - "width": 21, - "height": 10, - "corner": [ - 0, - -21, - 0 - ], - "body_name": "Plate" - } - }, - { - "command": "solid.box", - "params": { - "length": 21, - "width": 21, - "height": 10, - "corner": [ - 41.166666666666664, - -21, - 0 - ], - "body_name": "Corner" - } - }, - { - "command": "solid.cylinder", - "params": { - "radius": 21, - "height": 10, - "base": [ - 62.166666666666664, - -21, - 0 - ], - "body_name": "Round" - } - }, - { - "command": "solid.combine", - "params": { - "target": "Corner", - "tools": [ - "Round" - ], - "operation": "cut" - } - }, - { - "command": "solid.combine", - "params": { - "target": "Plate", - "tools": [ - "Corner" - ], - "operation": "join" - } - }, - { - "command": "solid.chamfer", - "params": { - "edges": [ - [ - 62.166666666666664, - 0, - 5 - ] - ], - "distance": 2, - "tangent_chain": false - } - } - ] -} diff --git a/tests/kernel-cases/fillets/9-fillet-corner-r1-curvature-default-setback/expected.json b/tests/kernel-cases/fillets/9-fillet-corner-r1-curvature-default-setback/expected.json deleted file mode 100644 index a9e0d8e95..000000000 --- a/tests/kernel-cases/fillets/9-fillet-corner-r1-curvature-default-setback/expected.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "sources": [ - "tangency-labs/solidcraft#9" - ], - "what": "three r1 rounds at a box corner with the curvature (g2) corner at its default setback 1.5 r: the corner patch meets the rounds and faces G2 clear of the vertices where the seams turn", - "source": "invariants", - "method": "as ladder 07-fillets/015 at r1: the corner set back 1.5 and filled with one patch; no closed-form volume: one valid body, 6 faces + 3 rounds + the patch, within the box Graded as ladder 07/019, scaled by r: at a hole corner the round is only tangent (G1) to the plane, its curvature jumping by 1/r, so no patch is G2 to both there; the curvature jump is bounded at stations at least 0.24 mm (0.24 r) from each turn, within 2.2 mm of the corner, at most 0.005 per mm (0.5% of 1/r).", - "body_count": 1, - "faces": 10, - "bbox": { - "min": [ - 0, - 0, - 0 - ], - "max": [ - 60, - 40, - 20 - ] - }, - "continuity": { - "near": [ - 60, - 40, - 20 - ], - "within_mm": 2.2, - "clear_mm": 0.24, - "curvature_jump_per_mm": 0.005 - } -} diff --git a/tests/kernel-cases/fillets/9-fillet-corner-r1-curvature-default-setback/recipe.json b/tests/kernel-cases/fillets/9-fillet-corner-r1-curvature-default-setback/recipe.json deleted file mode 100644 index 2e410d833..000000000 --- a/tests/kernel-cases/fillets/9-fillet-corner-r1-curvature-default-setback/recipe.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "commands": [ - { - "command": "solid.box", - "params": { - "length": 60, - "width": 40, - "height": 20, - "body_name": "Part" - } - }, - { - "command": "solid.fillet", - "params": { - "edges": [ - [ - 60, - 20, - 20 - ], - [ - 30, - 40, - 20 - ], - [ - 60, - 40, - 10 - ] - ], - "radius": 1, - "corner": "g2", - "tangent_chain": false - } - } - ] -} diff --git a/tests/kernel-cases/fillets/KNOWN_FAILING b/tests/kernel-cases/fillets/KNOWN_FAILING index d976a4a79..92f6ca9e7 100644 --- a/tests/kernel-cases/fillets/KNOWN_FAILING +++ b/tests/kernel-cases/fillets/KNOWN_FAILING @@ -3,7 +3,6 @@ # and on a listed case that passes: a fix removes its line in the same pull request. # Baseline: develop 242bbc89f with the SMLib fixes of 2026-10-29 (integration-overnight + b78bd4a), aarch64 Linux. 1080-fillet-equal-slope-basin-1-mm-rim-loop-4 builds to the analytic volume (rel 5e-9), but the continuity check (g1 at every blend seam) takes in the mitre's creases, G0 by the mitre ruling: the case's continuity seams need the owner's word -1080-fillet-sloped-basin-0-5-mm-rim-r4-4-edges builds to the analytic volume (rel 3e-9), but the continuity check (g1 at every blend seam) takes in the mitre's creases, G0 by the mitre ruling: the case's continuity seams need the owner's word 1080-fillet-sloped-basin-1-mm-rim-r4-2-edges builds to the analytic volume (rel 6e-9), but the continuity check (g1 at every blend seam) takes in the mitre's creases, G0 by the mitre ruling: the case's continuity seams need the owner's word 1080-fillet-sloped-basin-1-mm-rim-r4-4-edges builds to the analytic volume (rel 3e-9), but the continuity check (g1 at every blend seam) takes in the mitre's creases, G0 by the mitre ruling: the case's continuity seams need the owner's word 1207-fillet-bar-top-edge-after-boss-arc-round-r0-5 SMLib's check refuses the round: internal coincident control points in its end rib on the boss, which starts where the round and the boss are tangent (the boss's intersection marched there in spans down to 6e-8 mm) diff --git a/tests/kernel-cases/fillets/every-box-corner-three-edges-r1-tangent/expected.json b/tests/kernel-cases/fillets/every-box-corner-three-edges-r1-tangent/expected.json deleted file mode 100644 index 8e1941cf6..000000000 --- a/tests/kernel-cases/fillets/every-box-corner-three-edges-r1-tangent/expected.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "sources": [], - "what": "the three edges at one corner of a box rounded r1 together, rolling-ball (Tangent) corner: three quarter-cylinder rounds and a sphere octant", - "source": "analytic", - "method": "box 40x30x20, the edges at (40,30,20) (lengths 40, 30, 20) rounded r1. Each round removes the spandrel A = (1-pi/4) r^2 = 0.214602 along its edge outside the corner cube [40-r,40]x[30-r,30]x[20-r,20] (lengths 40-r, 30-r, 20-r: A (90-3r)); inside the corner cube what is left is the octant of the ball of radius r about (40-r,30-r,20-r), pi r^3/6, so the cube loses r^3 (1-pi/6). V = 24000 - A (90-3r) - r^3 (1-pi/6) = 24000 - 19.1468 = 23980.8532. Faces 6 + 3 rounds + the sphere octant = 10; every blend seam tangent (G1).", - "body_count": 1, - "volume_mm3": 23980.853238991178, - "faces": 10, - "bbox": { - "min": [ - 0, - 0, - 0 - ], - "max": [ - 40, - 30, - 20 - ] - }, - "continuity": { - "order": "g1" - } -} \ No newline at end of file diff --git a/tests/kernel-cases/fillets/every-box-corner-three-edges-r1-tangent/recipe.json b/tests/kernel-cases/fillets/every-box-corner-three-edges-r1-tangent/recipe.json deleted file mode 100644 index bba2a72d3..000000000 --- a/tests/kernel-cases/fillets/every-box-corner-three-edges-r1-tangent/recipe.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "commands": [ - { - "command": "solid.box", - "params": { - "length": 40, - "width": 30, - "height": 20, - "body_name": "Part" - } - }, - { - "command": "solid.fillet", - "params": { - "edges": [ - [ - 20, - 30, - 20 - ], - [ - 40, - 15, - 20 - ], - [ - 40, - 30, - 10 - ] - ], - "radius": 1 - } - } - ] -} \ No newline at end of file diff --git a/tests/kernel-cases/fillets/every-box-corner-three-edges-r3-curvature-corner/expected.json b/tests/kernel-cases/fillets/every-box-corner-three-edges-r3-curvature-corner/expected.json deleted file mode 100644 index e23a45ca0..000000000 --- a/tests/kernel-cases/fillets/every-box-corner-three-edges-r3-curvature-corner/expected.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "sources": [], - "what": "the three edges at one box corner rounded r3 with Corners: Curvature at its default setback (1.5 r = 4.5): the corner patch meets the rounds and faces G2", - "source": "invariants", - "method": "box 40x30x20, the edges at (40,30,20) rounded r3, corner g2: the corner is set back 4.5 along each edge and filled with one patch built G2 to the three rounds and the three faces (solid.fillet `corner`). The patch is a free-form surface SMLib fits, so no closed-form volume: one valid body, 6 faces + 3 rounds + the patch = 10, within the box. Graded as fillets/9-fillet-corner-r1-curvature-default-setback, scaled by r: at the points where a round's section ends on a face the round is only tangent (G1) to the plane, its curvature jumping by 1/r, so no patch is G2 to both there; the patch's curvature jump is bounded at stations at least 0.24 r from each turn, within 2.2 r of the corner, at most 0.5% of 1/r per mm.", - "body_count": 1, - "faces": 10, - "bbox": { - "min": [ - 0, - 0, - 0 - ], - "max": [ - 40, - 30, - 20 - ] - }, - "continuity": { - "near": [ - 40, - 30, - 20 - ], - "within_mm": 6.6, - "clear_mm": 0.72, - "curvature_jump_per_mm": 0.001667 - } -} \ No newline at end of file diff --git a/tests/kernel-cases/fillets/every-box-corner-three-edges-r3-curvature-corner/recipe.json b/tests/kernel-cases/fillets/every-box-corner-three-edges-r3-curvature-corner/recipe.json deleted file mode 100644 index 6e787ec6a..000000000 --- a/tests/kernel-cases/fillets/every-box-corner-three-edges-r3-curvature-corner/recipe.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "commands": [ - { - "command": "solid.box", - "params": { - "length": 40, - "width": 30, - "height": 20, - "body_name": "Part" - } - }, - { - "command": "solid.fillet", - "params": { - "edges": [ - [ - 20, - 30, - 20 - ], - [ - 40, - 15, - 20 - ], - [ - 40, - 30, - 10 - ] - ], - "radius": 3, - "corner": "g2", - "tangent_chain": false - } - } - ] -} \ No newline at end of file diff --git a/tests/kernel-cases/fillets/every-box-corner-three-edges-r3-curvature-setback-3-5/expected.json b/tests/kernel-cases/fillets/every-box-corner-three-edges-r3-curvature-setback-3-5/expected.json index 5e7f61431..f8d4563bf 100644 --- a/tests/kernel-cases/fillets/every-box-corner-three-edges-r3-curvature-setback-3-5/expected.json +++ b/tests/kernel-cases/fillets/every-box-corner-three-edges-r3-curvature-setback-3-5/expected.json @@ -2,7 +2,7 @@ "sources": [], "what": "the three edges at one box corner rounded r3, Corners: Curvature set back 3.5, just past the radius: the smallest kind of setback that builds", "source": "invariants", - "method": "as every-box-corner-three-edges-r3-curvature-corner with the setback 3.5: past where the rounds' contact lines meet (r = 3 from the vertex on a corner of faces square to each other), so the patch is built (the rule: a setback must be more than the radius). No closed-form volume (a fitted patch): one valid body of 10 faces within the box. Graded as fillets/9-fillet-corner-r1-curvature-default-setback, scaled by r: at the points where a round's section ends on a face the round is only tangent (G1) to the plane, its curvature jumping by 1/r, so no patch is G2 to both there; the patch's curvature jump is bounded at stations at least 0.24 r from each turn, within 2.2 r of the corner, at most 0.5% of 1/r per mm.", + "method": "box 40x30x20, the edges at (40,30,20) rounded r3, corner g2, with the setback 3.5: past where the rounds' contact lines meet (r = 3 from the vertex on a corner of faces square to each other), so the patch is built (the rule: a setback must be more than the radius). No closed-form volume (a fitted patch): one valid body of 10 faces within the box. Graded as fillets/9-fillet-corner-r5-curvature-default-setback, scaled by r: at the points where a round's section ends on a face the round is only tangent (G1) to the plane, its curvature jumping by 1/r, so no patch is G2 to both there; the patch's curvature jump is bounded at stations at least 0.24 r from each turn, within 2.2 r of the corner, at most 0.5% of 1/r per mm.", "body_count": 1, "faces": 10, "bbox": { @@ -27,4 +27,4 @@ "clear_mm": 0.72, "curvature_jump_per_mm": 0.001667 } -} \ No newline at end of file +} diff --git a/tests/kernel-cases/fillets/every-chamfer-pocket-rim-1/expected.json b/tests/kernel-cases/fillets/every-chamfer-pocket-rim-1/expected.json deleted file mode 100644 index 82db428b7..000000000 --- a/tests/kernel-cases/fillets/every-chamfer-pocket-rim-1/expected.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "sources": [], - "what": "a rectangular pocket's four rim edges chamfered 1", - "source": "analytic", - "method": "plate 60x40x10 with the pocket 30x20x5 (x 15..45, y 10..30, floor z = 5, sharp vertical corners): V0 = 24000 - 3000 = 21000. Each convex rim edge loses the triangle d^2/2 along its length (100 in all); at each pocket corner the two chamfers run on past it and meet in a mitre, the quadrant losing what both remove: points (s, t) past both walls with s + u < d and t + u < d (u the depth), int_0^d (d-u)^2 du = d^3/3. d = 1: removed = 50 d^2 + (4/3) d^3 = 51.3333. V = 20948.6667. Faces 15.", - "body_count": 1, - "volume_mm3": 20948.666666666668, - "faces": 15, - "bbox": { - "min": [ - 0, - 0, - 0 - ], - "max": [ - 60, - 40, - 10 - ] - }, - "continuity": { - "order": "g0" - } -} \ No newline at end of file diff --git a/tests/kernel-cases/fillets/every-chamfer-pocket-rim-1/recipe.json b/tests/kernel-cases/fillets/every-chamfer-pocket-rim-1/recipe.json deleted file mode 100644 index e4a9f007e..000000000 --- a/tests/kernel-cases/fillets/every-chamfer-pocket-rim-1/recipe.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "commands": [ - { - "command": "solid.box", - "params": { - "length": 60, - "width": 40, - "height": 10, - "body_name": "Plate" - } - }, - { - "command": "solid.box", - "params": { - "length": 30, - "width": 20, - "height": 6, - "corner": [ - 15, - 10, - 5 - ], - "operation": "cut", - "targets": [ - "Plate" - ] - } - }, - { - "command": "solid.chamfer", - "params": { - "edges": [ - [ - 30, - 10, - 10 - ], - [ - 30, - 30, - 10 - ], - [ - 15, - 20, - 10 - ], - [ - 45, - 20, - 10 - ] - ], - "distance": 1 - } - } - ] -} \ No newline at end of file diff --git a/tests/kernel-cases/fillets/every-fillet-after-fillet-front-then-vertical-r2/expected.json b/tests/kernel-cases/fillets/every-fillet-after-fillet-front-then-vertical-r2/expected.json index 77268e573..77a2ea645 100644 --- a/tests/kernel-cases/fillets/every-fillet-after-fillet-front-then-vertical-r2/expected.json +++ b/tests/kernel-cases/fillets/every-fillet-after-fillet-front-then-vertical-r2/expected.json @@ -2,7 +2,7 @@ "sources": [], "what": "a box's top front edge rounded r2, then the vertical edge meeting it at the corner rounded r2 (Tangent chain on)", "source": "analytic", - "method": "box 40x30x20; the edge y=0, z=20 rounded r2, then the edge x=40, y=0: rounding the second edge after the first, its tangent chain (the default) runs on along the first round's end arc (on the end face, tangent to it) and the third edge at the corner; the rolling ball along that arc, between the end face and the first round of the same radius, is the corner's sphere, so the result is the three-edge rolling-ball corner: V = 24000 - (1-pi/4) 4 (40+20+30-6) - 8 (1-pi/6) = 23924.0826 (every-box-corner-three-edges-r1-tangent's formula at r2). Faces 10. The same as every-fillet-after-fillet-vertical-then-front-r2: the order does not matter.", + "method": "box 40x30x20; the edge y=0, z=20 rounded r2, then the edge x=40, y=0: rounding the second edge after the first, its tangent chain (the default) runs on along the first round's end arc (on the end face, tangent to it) and the third edge at the corner; the rolling ball along that arc, between the end face and the first round of the same radius, is the corner's sphere, so the result is the three-edge rolling-ball corner: V = 24000 - (1-pi/4) 4 (40+20+30-6) - 8 (1-pi/6) = 23924.0826 (every-box-corner-three-edges-r3-tangent's formula at r2). Faces 10. The same as every-fillet-after-fillet-vertical-then-front-r2: the order does not matter.", "body_count": 1, "volume_mm3": 23924.08257310633, "faces": 10, @@ -21,4 +21,4 @@ "continuity": { "order": "g1" } -} \ No newline at end of file +} diff --git a/tests/kernel-cases/fillets/every-hole-both-rims-chamfer-1/expected.json b/tests/kernel-cases/fillets/every-hole-both-rims-chamfer-1/expected.json index 868be7886..d948532d4 100644 --- a/tests/kernel-cases/fillets/every-hole-both-rims-chamfer-1/expected.json +++ b/tests/kernel-cases/fillets/every-hole-both-rims-chamfer-1/expected.json @@ -2,7 +2,7 @@ "sources": [], "what": "both rims of a hole through a plate chamfered 1 in one chamfer", "source": "analytic", - "method": "plate 40x40x10 with a through hole R5 at (20, 20): V0 = 16000 - 250 pi = 15214.6018. Each rim's chamfer removes 2 pi (5 + 1/3) 0.5 = 16.7552 (every-hole-top-rim-chamfer-1): V = 15181.0915. Faces 9.", + "method": "plate 40x40x10 with a through hole R5 at (20, 20): V0 = 16000 - 250 pi = 15214.6018. Each rim's chamfer removes 2 pi (5 + 1/3) 0.5 = 16.7552 (the frustum ring of a rim chamfer d on a hole R: 2 pi (R + d/3) d^2/2): V = 15181.0915. Faces 9.", "body_count": 1, "volume_mm3": 15181.09151496426, "faces": 9, @@ -21,4 +21,4 @@ "continuity": { "order": "g0" } -} \ No newline at end of file +} diff --git a/tests/kernel-cases/fillets/every-hole-top-rim-chamfer-1/expected.json b/tests/kernel-cases/fillets/every-hole-top-rim-chamfer-1/expected.json deleted file mode 100644 index 7c15d501e..000000000 --- a/tests/kernel-cases/fillets/every-hole-top-rim-chamfer-1/expected.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "sources": [], - "what": "the top rim of a hole through a plate chamfered 1 (a cone frustum)", - "source": "analytic", - "method": "plate 40x40x10 with a through hole R5 at (20, 20): V0 = 16000 - 250 pi = 15214.6018. The chamfer removes the right triangle of legs 1 and 1 (area 0.5) beside the rim, its centroid at rho = 5 + 1/3, revolved once (Pappus): 2 pi (16/3) 0.5 = 16.7552. V = 15197.8467. Faces 8; the cone meets the faces at creases (G0).", - "body_count": 1, - "volume_mm3": 15197.846675783405, - "faces": 8, - "bbox": { - "min": [ - 0, - 0, - 0 - ], - "max": [ - 40, - 40, - 10 - ] - }, - "continuity": { - "order": "g0" - } -} \ No newline at end of file diff --git a/tests/kernel-cases/fillets/every-hole-top-rim-chamfer-1/recipe.json b/tests/kernel-cases/fillets/every-hole-top-rim-chamfer-1/recipe.json deleted file mode 100644 index 2de83f239..000000000 --- a/tests/kernel-cases/fillets/every-hole-top-rim-chamfer-1/recipe.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "commands": [ - { - "command": "solid.box", - "params": { - "length": 40, - "width": 40, - "height": 10, - "body_name": "Plate" - } - }, - { - "command": "solid.cylinder", - "params": { - "radius": 5, - "height": 12, - "base": [ - 20, - 20, - -1 - ], - "operation": "cut", - "targets": [ - "Plate" - ] - } - }, - { - "command": "solid.chamfer", - "params": { - "edges": [ - [ - 25, - 20, - 10 - ] - ], - "distance": 1 - } - } - ] -} \ No newline at end of file diff --git a/tests/kernel-cases/fillets/report-fillet-g2-corner-of-bar-running-into-cylinder/expected.json b/tests/kernel-cases/fillets/report-fillet-g2-corner-of-bar-running-into-cylinder/expected.json index f906fb233..9ac5974cf 100644 --- a/tests/kernel-cases/fillets/report-fillet-g2-corner-of-bar-running-into-cylinder/expected.json +++ b/tests/kernel-cases/fillets/report-fillet-g2-corner-of-bar-running-into-cylinder/expected.json @@ -1,7 +1,7 @@ { "what": "three r2 rounds at a top corner of a bar whose far end runs tangent into a cylinder, with the curvature (g2) corner set back 3: SMLib refused the result coming back (a cylinder over more than a turn); reported from the app (2026-10-30, test-peg part)", "source": "analytic", - "method": "a bar 40 x 16 x 10 whose far end is a half disc R8 about (40, 8), a disc R8 about the same centre sketched on its top (the top's outline projected) and extruded 10 up, joined: the bar's sides run tangent into the cylinder, V0 = 6400 + 960 pi; the rolling-ball answer: the three r2 rounds at the bar's other top corner (0, 0, 10): the front round's spandrel from x = 2 to the wall (30.5896671706), the vertical edge's and the left top edge's (1 - pi/4) r^2 over 8 and 14, the corner cube of side 2 less the rolling ball's eighth, 8 - 4 pi/3: removed 53.2858385868; the G2 patch differs from the ball only within the setback cube of side 3 about the vertex, so V is graded as V0 - removed with 3^3 as its tolerance (the rounds outside the cube exactly: ...-outside-setback); the patch meets the rounds and faces round it G2, graded as fillets/9-fillet-corner-r1-curvature-default-setback scaled by r = 2: at a hole corner the round is only tangent (G1) to the plane, so the curvature jump is bounded at stations at least 0.48 mm (0.24 r) from each turn, within 4.4 mm of the corner, at most 0.0025 per mm (0.5% of 1/r)", + "method": "a bar 40 x 16 x 10 whose far end is a half disc R8 about (40, 8), a disc R8 about the same centre sketched on its top (the top's outline projected) and extruded 10 up, joined: the bar's sides run tangent into the cylinder, V0 = 6400 + 960 pi; the rolling-ball answer: the three r2 rounds at the bar's other top corner (0, 0, 10): the front round's spandrel from x = 2 to the wall (30.5896671706), the vertical edge's and the left top edge's (1 - pi/4) r^2 over 8 and 14, the corner cube of side 2 less the rolling ball's eighth, 8 - 4 pi/3: removed 53.2858385868; the G2 patch differs from the ball only within the setback cube of side 3 about the vertex, so V is graded as V0 - removed with 3^3 as its tolerance (the rounds outside the cube exactly: ...-outside-setback); the patch meets the rounds and faces round it G2, graded as fillets/9-fillet-corner-r5-curvature-default-setback scaled by r = 2: at a hole corner the round is only tangent (G1) to the plane, so the curvature jump is bounded at stations at least 0.48 mm (0.24 r) from each turn, within 4.4 mm of the corner, at most 0.0025 per mm (0.5% of 1/r)", "body_count": 1, "volume_mm3": 9362.643108859389, "tolerance": { From de3483ecc547b1ced1d367b57d78e9c6f3aef40a Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:41:55 -0400 Subject: [PATCH 41/81] Kernel rig: five cases outside fillets repeat a kept case's regime and go A square cut is the slanted plane's ordinary crossing; the cam's half turn is the quarter turn's contact at a symmetric angle; the r15 slab stands inside the same coincidence tolerance as the r10; the 90 degree unfold and the 40 degree flange repeat the 72 degree and 20 degree cases' formulas. Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 30 - .../recipe.json | 212 ------- .../expected.json | 10 - .../recipe.json | 51 -- .../expected.json | 15 - .../recipe.json | 40 -- .../expected.json | 21 - .../recipe.json | 132 ---- .../expected.json | 11 - .../recipe.json | 599 ------------------ 10 files changed, 1121 deletions(-) delete mode 100644 tests/kernel-cases/assemblies/cov-joint-cam-eccentric-disc-half-turn/expected.json delete mode 100644 tests/kernel-cases/assemblies/cov-joint-cam-eccentric-disc-half-turn/recipe.json delete mode 100644 tests/kernel-cases/booleans/4095-slab-cut-standing-off-a-bore-r15/expected.json delete mode 100644 tests/kernel-cases/booleans/4095-slab-cut-standing-off-a-bore-r15/recipe.json delete mode 100644 tests/kernel-cases/construction/cov-point-edge-plane-square-cut/expected.json delete mode 100644 tests/kernel-cases/construction/cov-point-edge-plane-square-cut/recipe.json delete mode 100644 tests/kernel-cases/sheet-metal/349-unfold-a-tray-shrunk-by-a-parameter-90-degrees/expected.json delete mode 100644 tests/kernel-cases/sheet-metal/349-unfold-a-tray-shrunk-by-a-parameter-90-degrees/recipe.json delete mode 100644 tests/kernel-cases/sweeps/1391-flange-flush-on-the-end-of-a-bent-tapered-loft-40deg/expected.json delete mode 100644 tests/kernel-cases/sweeps/1391-flange-flush-on-the-end-of-a-bent-tapered-loft-40deg/recipe.json diff --git a/tests/kernel-cases/assemblies/cov-joint-cam-eccentric-disc-half-turn/expected.json b/tests/kernel-cases/assemblies/cov-joint-cam-eccentric-disc-half-turn/expected.json deleted file mode 100644 index b45f6281c..000000000 --- a/tests/kernel-cases/assemblies/cov-joint-cam-eccentric-disc-half-turn/expected.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "sources": [], - "what": "a knife follower on an eccentric disc cam, the cam turned 180 degrees", - "source": "analytic", - "method": "an eccentric disc cam (radius 10, centre 5 off its shaft on z through the origin) with a knife follower on a slider along +x through the shaft, touching at x = 15; the knife's distance at cam turn \u03c6 is s(\u03c6) = e cos \u03c6 + \u221a(R\u00b2 - e\u00b2 sin\u00b2 \u03c6) (e 5, R 10): rise s(0) - s(180) = 15 - 5 = 10; at 180 the knife is at s = 5, 10 mm in: the tappet's centre (20,0,2.5) -> (10,0,2.5)", - "body_count": 3, - "volume_mm3": 5770.796, - "results": [ - { - "step": 13, - "json": { - "lift": { - "rise": 10.0 - } - } - }, - { - "step": 15, - "json": { - "total": { - "center_of_mass": [ - 10.0, - 0.0, - 2.5 - ] - } - } - } - ] -} diff --git a/tests/kernel-cases/assemblies/cov-joint-cam-eccentric-disc-half-turn/recipe.json b/tests/kernel-cases/assemblies/cov-joint-cam-eccentric-disc-half-turn/recipe.json deleted file mode 100644 index 4ac5cfaf3..000000000 --- a/tests/kernel-cases/assemblies/cov-joint-cam-eccentric-disc-half-turn/recipe.json +++ /dev/null @@ -1,212 +0,0 @@ -{ - "commands": [ - { - "command": "solid.box", - "params": { - "length": 20, - "width": 20, - "height": 10, - "corner": [ - -10, - -10, - -10 - ], - "operation": "new", - "body_name": "BaseBox" - } - }, - { - "command": "solid.cylinder", - "params": { - "radius": 10, - "height": 5, - "base": [ - 5, - 0, - 0 - ], - "axis": [ - 0, - 0, - 1 - ], - "operation": "new", - "body_name": "Disc" - } - }, - { - "command": "solid.box", - "params": { - "length": 10, - "width": 4, - "height": 5, - "corner": [ - 15, - -2, - 0 - ], - "operation": "new", - "body_name": "Tappet" - } - }, - { - "command": "component.create", - "params": { - "name": "Base", - "parent": "root", - "activate": false - } - }, - { - "command": "component.move_bodies", - "params": { - "bodies": [ - "BaseBox" - ], - "component": "Base" - } - }, - { - "command": "component.create", - "params": { - "name": "Cam", - "parent": "root", - "activate": false - } - }, - { - "command": "component.move_bodies", - "params": { - "bodies": [ - "Disc" - ], - "component": "Cam" - } - }, - { - "command": "component.create", - "params": { - "name": "Follower", - "parent": "root", - "activate": false - } - }, - { - "command": "component.move_bodies", - "params": { - "bodies": [ - "Tappet" - ], - "component": "Follower" - } - }, - { - "command": "occurrence.ground", - "params": { - "occurrence": "Base:1", - "grounded": true - } - }, - { - "command": "joint.create", - "params": { - "type": "revolute", - "name": "Shaft", - "flip": true, - "a": { - "occurrence": "Base", - "point": [ - 0, - 0, - 0 - ], - "z": [ - 0, - 0, - 1 - ] - }, - "b": { - "occurrence": "Cam", - "point": [ - 0, - 0, - 0 - ], - "z": [ - 0, - 0, - 1 - ] - }, - "quiet": true - } - }, - { - "command": "joint.create", - "params": { - "type": "slider", - "name": "Lift", - "flip": true, - "a": { - "occurrence": "Base", - "point": [ - 15, - 0, - 2.5 - ], - "z": [ - 1, - 0, - 0 - ] - }, - "b": { - "occurrence": "Follower", - "point": [ - 15, - 0, - 2.5 - ], - "z": [ - 1, - 0, - 0 - ] - }, - "quiet": true - } - }, - { - "command": "joint.cam", - "params": { - "a": "Shaft", - "b": "Lift", - "profile": { - "edges": [ - [ - 15, - 0, - 0 - ] - ], - "occurrence": "Cam" - } - } - }, - { - "command": "joint.drive", - "params": { - "joint": "Shaft", - "quiet": true, - "value": 180 - } - }, - { - "command": "occurrence.properties", - "params": { - "occurrence": "Follower:1" - } - } - ] -} diff --git a/tests/kernel-cases/booleans/4095-slab-cut-standing-off-a-bore-r15/expected.json b/tests/kernel-cases/booleans/4095-slab-cut-standing-off-a-bore-r15/expected.json deleted file mode 100644 index 31ff60216..000000000 --- a/tests/kernel-cases/booleans/4095-slab-cut-standing-off-a-bore-r15/expected.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "sources": [ - "tangency-labs/solidcraft#4095" - ], - "what": "a slab cut whose +x face stands 6.60e-05 mm (0.60 x the coincidence tolerance 1.10e-04) off a through-bore's wall (R=15), beside the bore", - "source": "analytic", - "method": "plate 90x60x20 minus the bore pi R^2*20 minus the notch (the slab 6x16 from z=12 up through the top z=20: 6*16*8 = 768), which the bore beside it does not change. V = 90*60*20 - pi*15^2*20 - 768. The bug removed about 5% too much with no warning", - "body_count": 1, - "volume_mm3": 93094.8331 -} \ No newline at end of file diff --git a/tests/kernel-cases/booleans/4095-slab-cut-standing-off-a-bore-r15/recipe.json b/tests/kernel-cases/booleans/4095-slab-cut-standing-off-a-bore-r15/recipe.json deleted file mode 100644 index 723c9275f..000000000 --- a/tests/kernel-cases/booleans/4095-slab-cut-standing-off-a-bore-r15/recipe.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "commands": [ - { - "command": "solid.box", - "params": { - "corner": [ - -45.0, - -30.0, - 0 - ], - "length": 90, - "width": 60, - "height": 20, - "body_name": "Plate" - } - }, - { - "command": "solid.cylinder", - "params": { - "radius": 15, - "height": 22, - "base": [ - 0, - 0, - -1 - ], - "operation": "cut", - "targets": [ - "Plate" - ] - } - }, - { - "command": "solid.box", - "params": { - "corner": [ - -21.000066, - -8, - 12 - ], - "length": 6, - "width": 16, - "height": 14, - "operation": "cut", - "targets": [ - "Plate" - ] - } - } - ] -} \ No newline at end of file diff --git a/tests/kernel-cases/construction/cov-point-edge-plane-square-cut/expected.json b/tests/kernel-cases/construction/cov-point-edge-plane-square-cut/expected.json deleted file mode 100644 index 73dc50567..000000000 --- a/tests/kernel-cases/construction/cov-point-edge-plane-square-cut/expected.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "sources": [], - "what": "where a box edge crosses a plane square to it", - "source": "analytic", - "method": "box 40 x 30 x 20 with a corner at the origin (x 0..40, y 0..30, z 0..20): the edge y 0, z 0 along X meets x = 12 at (12,0,0)", - "construction": { - "P": { - "point": [ - 12, - 0, - 0 - ] - } - } -} diff --git a/tests/kernel-cases/construction/cov-point-edge-plane-square-cut/recipe.json b/tests/kernel-cases/construction/cov-point-edge-plane-square-cut/recipe.json deleted file mode 100644 index bff7913af..000000000 --- a/tests/kernel-cases/construction/cov-point-edge-plane-square-cut/recipe.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "commands": [ - { - "command": "solid.box", - "params": { - "length": 40, - "width": 30, - "height": 20, - "body_name": "Box" - } - }, - { - "command": "construct.point.edge_plane", - "params": { - "edge": { - "edge": [ - 20, - 0, - 0 - ] - }, - "plane": { - "plane": { - "origin": [ - 12, - 0, - 0 - ], - "normal": [ - 1, - 0, - 0 - ] - } - }, - "name": "P" - } - } - ] -} diff --git a/tests/kernel-cases/sheet-metal/349-unfold-a-tray-shrunk-by-a-parameter-90-degrees/expected.json b/tests/kernel-cases/sheet-metal/349-unfold-a-tray-shrunk-by-a-parameter-90-degrees/expected.json deleted file mode 100644 index 0e975cdfe..000000000 --- a/tests/kernel-cases/sheet-metal/349-unfold-a-tray-shrunk-by-a-parameter-90-degrees/expected.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "sources": [ - "tangency-labs/solidcraft#349" - ], - "what": "a 2000 x 2500 tray with four 38.6 mm flanges at 90 degrees whose sketch is driven by parameters W and H, shrunk to 400 x 300 and unfolded (the solver leaves 1e-13 mm residuals: the planar region arrangement failed)", - "source": "analytic", - "method": "a flange of angle th, outer leg length Hf (height, from the virtual sharp along the flange) bends with allowance BA = th(R+Kt) and bend deduction BD = 2(R+t)tan(th/2) - BA; unfolded it lies in the base's plane and reaches Hf - BD beyond the base's edge. T = 2, R = 1, K = 0.5. BD(90) = 2.8584; the flat of the 400 x 300 tray is the same as built directly: reaches 35.7416 past each base edge", - "body_count": 1, - "bbox": { - "min": [ - -35.7415926535898, - -35.7415926535898, - 0 - ], - "max": [ - 435.7415926535898, - 335.7415926535898, - 2 - ] - } -} \ No newline at end of file diff --git a/tests/kernel-cases/sheet-metal/349-unfold-a-tray-shrunk-by-a-parameter-90-degrees/recipe.json b/tests/kernel-cases/sheet-metal/349-unfold-a-tray-shrunk-by-a-parameter-90-degrees/recipe.json deleted file mode 100644 index f5853a1f3..000000000 --- a/tests/kernel-cases/sheet-metal/349-unfold-a-tray-shrunk-by-a-parameter-90-degrees/recipe.json +++ /dev/null @@ -1,132 +0,0 @@ -{ - "commands": [ - { - "command": "parameters.add", - "params": { - "name": "W", - "expression": "2000 mm" - } - }, - { - "command": "parameters.add", - "params": { - "name": "H", - "expression": "2500 mm" - } - }, - { - "command": "sheet.manage_rules", - "params": { - "name": "AL2", - "thickness": "2 mm", - "active": true, - "bend_radius": "1 mm", - "k_factor": 0.5 - } - }, - { - "command": "sketch.create", - "params": { - "plane": "XY", - "name": "Tray" - } - }, - { - "command": "sketch.rectangle.two_point", - "params": { - "p0": [ - 0, - 0 - ], - "p1": [ - 2000, - 2500 - ] - } - }, - { - "command": "sketch.constraint.fix", - "params": { - "entities": [ - "p1" - ] - } - }, - { - "command": "sketch.dimension", - "params": { - "entities": [ - "l1" - ], - "value": "W" - } - }, - { - "command": "sketch.dimension", - "params": { - "entities": [ - "l2" - ], - "value": "H" - } - }, - { - "command": "sketch.finish", - "params": {} - }, - { - "command": "sheet.flange", - "params": { - "type": "base", - "sketch": "Tray" - } - }, - { - "command": "sheet.flange", - "params": { - "type": "edge", - "edges": [ - [ - 1000, - 0, - 2 - ], - [ - 2000, - 1250, - 2 - ], - [ - 1000, - 2500, - 2 - ], - [ - 0, - 1250, - 2 - ] - ], - "height": 38.6, - "angle": 90 - } - }, - { - "command": "parameters.change", - "params": { - "changes": { - "W": "400 mm", - "H": "300 mm" - } - } - }, - { - "command": "sheet.unfold", - "params": {} - }, - { - "command": "inspect.measure", - "params": {} - } - ] -} \ No newline at end of file diff --git a/tests/kernel-cases/sweeps/1391-flange-flush-on-the-end-of-a-bent-tapered-loft-40deg/expected.json b/tests/kernel-cases/sweeps/1391-flange-flush-on-the-end-of-a-bent-tapered-loft-40deg/expected.json deleted file mode 100644 index 89fba1fe9..000000000 --- a/tests/kernel-cases/sweeps/1391-flange-flush-on-the-end-of-a-bent-tapered-loft-40deg/expected.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "sources": [ - "tangency-labs/solidcraft#1391", - "tangency-labs/solidcraft#1556" - ], - "what": "a half tube (6 mm wall, inner radius tapering 60 to 75 mm) lofted through 5 sections along an R300 bend of 40 degrees, with an 8 mm half-annulus flange (inner radius +3 into the wall, outer +25 beyond it) extruded from the end plane outward and joined: the flange face lies in the end plane (\"Union: no result\")", - "source": "analytic", - "method": "each section is a half annulus in a plane through the bend axis, centred on the path, so Pappus holds with the section area A(t) = pi/2 (12 r(t) + 36), r(t) = 60 + 15 t: V_tube = R theta * pi/2 (12 * 67.5 + 36), R = 300, theta = 40 degrees = 278322.8. The flange stands outside the tube end plane and touches the tube only along the coplanar end face, so V = V_tube + V_flange, V_flange = pi/2 (106^2 - 78^2) 8 = 64741.9. One body.", - "body_count": 1, - "volume_mm3": 343064.7855158983 -} \ No newline at end of file diff --git a/tests/kernel-cases/sweeps/1391-flange-flush-on-the-end-of-a-bent-tapered-loft-40deg/recipe.json b/tests/kernel-cases/sweeps/1391-flange-flush-on-the-end-of-a-bent-tapered-loft-40deg/recipe.json deleted file mode 100644 index b60b9bf85..000000000 --- a/tests/kernel-cases/sweeps/1391-flange-flush-on-the-end-of-a-bent-tapered-loft-40deg/recipe.json +++ /dev/null @@ -1,599 +0,0 @@ -{ - "commands": [ - { - "command": "sketch.create", - "params": { - "plane": { - "origin": [ - 0.0, - 0.0, - 0.0 - ], - "x_dir": [ - 0, - 0, - 1 - ], - "y_dir": [ - 0.0, - -1.0, - 0 - ] - }, - "name": "S0" - } - }, - { - "command": "sketch.arc.three_point", - "params": { - "start": [ - 0, - -66.0 - ], - "through": [ - 66.0, - 0 - ], - "end": [ - 0, - 66.0 - ] - } - }, - { - "command": "sketch.line", - "params": { - "points": [ - [ - 0, - 66.0 - ], - [ - 0, - 60.0 - ] - ], - "infer": false - } - }, - { - "command": "sketch.arc.three_point", - "params": { - "start": [ - 0, - 60.0 - ], - "through": [ - 60.0, - 0 - ], - "end": [ - 0, - -60.0 - ] - } - }, - { - "command": "sketch.line", - "params": { - "points": [ - [ - 0, - -60.0 - ], - [ - 0, - -66.0 - ] - ], - "infer": false - } - }, - { - "command": "sketch.finish", - "params": {} - }, - { - "command": "sketch.create", - "params": { - "plane": { - "origin": [ - 52.0944533, - 4.557674096, - 0.0 - ], - "x_dir": [ - 0, - 0, - 1 - ], - "y_dir": [ - 0.173648178, - -0.984807753, - 0 - ] - }, - "name": "S1" - } - }, - { - "command": "sketch.arc.three_point", - "params": { - "start": [ - 0, - -69.75 - ], - "through": [ - 69.75, - 0 - ], - "end": [ - 0, - 69.75 - ] - } - }, - { - "command": "sketch.line", - "params": { - "points": [ - [ - 0, - 69.75 - ], - [ - 0, - 63.75 - ] - ], - "infer": false - } - }, - { - "command": "sketch.arc.three_point", - "params": { - "start": [ - 0, - 63.75 - ], - "through": [ - 63.75, - 0 - ], - "end": [ - 0, - -63.75 - ] - } - }, - { - "command": "sketch.line", - "params": { - "points": [ - [ - 0, - -63.75 - ], - [ - 0, - -69.75 - ] - ], - "infer": false - } - }, - { - "command": "sketch.finish", - "params": {} - }, - { - "command": "sketch.create", - "params": { - "plane": { - "origin": [ - 102.606042998, - 18.092213764, - 0.0 - ], - "x_dir": [ - 0, - 0, - 1 - ], - "y_dir": [ - 0.342020143, - -0.939692621, - 0 - ] - }, - "name": "S2" - } - }, - { - "command": "sketch.arc.three_point", - "params": { - "start": [ - 0, - -73.5 - ], - "through": [ - 73.5, - 0 - ], - "end": [ - 0, - 73.5 - ] - } - }, - { - "command": "sketch.line", - "params": { - "points": [ - [ - 0, - 73.5 - ], - [ - 0, - 67.5 - ] - ], - "infer": false - } - }, - { - "command": "sketch.arc.three_point", - "params": { - "start": [ - 0, - 67.5 - ], - "through": [ - 67.5, - 0 - ], - "end": [ - 0, - -67.5 - ] - } - }, - { - "command": "sketch.line", - "params": { - "points": [ - [ - 0, - -67.5 - ], - [ - 0, - -73.5 - ] - ], - "infer": false - } - }, - { - "command": "sketch.finish", - "params": {} - }, - { - "command": "sketch.create", - "params": { - "plane": { - "origin": [ - 150.0, - 40.192378865, - 0.0 - ], - "x_dir": [ - 0, - 0, - 1 - ], - "y_dir": [ - 0.5, - -0.866025404, - 0 - ] - }, - "name": "S3" - } - }, - { - "command": "sketch.arc.three_point", - "params": { - "start": [ - 0, - -77.25 - ], - "through": [ - 77.25, - 0 - ], - "end": [ - 0, - 77.25 - ] - } - }, - { - "command": "sketch.line", - "params": { - "points": [ - [ - 0, - 77.25 - ], - [ - 0, - 71.25 - ] - ], - "infer": false - } - }, - { - "command": "sketch.arc.three_point", - "params": { - "start": [ - 0, - 71.25 - ], - "through": [ - 71.25, - 0 - ], - "end": [ - 0, - -71.25 - ] - } - }, - { - "command": "sketch.line", - "params": { - "points": [ - [ - 0, - -71.25 - ], - [ - 0, - -77.25 - ] - ], - "infer": false - } - }, - { - "command": "sketch.finish", - "params": {} - }, - { - "command": "sketch.create", - "params": { - "plane": { - "origin": [ - 192.836282906, - 70.186667064, - 0.0 - ], - "x_dir": [ - 0, - 0, - 1 - ], - "y_dir": [ - 0.64278761, - -0.766044443, - 0 - ] - }, - "name": "S4" - } - }, - { - "command": "sketch.arc.three_point", - "params": { - "start": [ - 0, - -81.0 - ], - "through": [ - 81.0, - 0 - ], - "end": [ - 0, - 81.0 - ] - } - }, - { - "command": "sketch.line", - "params": { - "points": [ - [ - 0, - 81.0 - ], - [ - 0, - 75.0 - ] - ], - "infer": false - } - }, - { - "command": "sketch.arc.three_point", - "params": { - "start": [ - 0, - 75.0 - ], - "through": [ - 75.0, - 0 - ], - "end": [ - 0, - -75.0 - ] - } - }, - { - "command": "sketch.line", - "params": { - "points": [ - [ - 0, - -75.0 - ], - [ - 0, - -81.0 - ] - ], - "infer": false - } - }, - { - "command": "sketch.finish", - "params": {} - }, - { - "command": "solid.loft", - "params": { - "sections": [ - { - "sketch": "S0" - }, - { - "sketch": "S1" - }, - { - "sketch": "S2" - }, - { - "sketch": "S3" - }, - { - "sketch": "S4" - } - ], - "operation": "new", - "name": "TubeLoft", - "body_name": "Tube" - } - }, - { - "command": "sketch.create", - "params": { - "plane": { - "origin": [ - 192.836282906, - 70.186667064, - 0.0 - ], - "x_dir": [ - 0, - 0, - 1 - ], - "y_dir": [ - 0.64278761, - -0.766044443, - 0 - ] - }, - "name": "Flange" - } - }, - { - "command": "sketch.arc.three_point", - "params": { - "start": [ - 0, - -106.0 - ], - "through": [ - 106.0, - 0 - ], - "end": [ - 0, - 106.0 - ] - } - }, - { - "command": "sketch.line", - "params": { - "points": [ - [ - 0, - 106.0 - ], - [ - 0, - 78.0 - ] - ], - "infer": false - } - }, - { - "command": "sketch.arc.three_point", - "params": { - "start": [ - 0, - 78.0 - ], - "through": [ - 78.0, - 0 - ], - "end": [ - 0, - -78.0 - ] - } - }, - { - "command": "sketch.line", - "params": { - "points": [ - [ - 0, - -78.0 - ], - [ - 0, - -106.0 - ] - ], - "infer": false - } - }, - { - "command": "sketch.finish", - "params": {} - }, - { - "command": "solid.extrude", - "params": { - "sketch": "Flange", - "distance": 8.0, - "operation": "join", - "targets": [ - "Tube" - ], - "name": "JoinFlange" - } - } - ] -} \ No newline at end of file From d3c8c36ec6130fc1fb743ece559169ea403803e4 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:41:02 -0400 Subject: [PATCH 42/81] Kernel rig: 3243 rim and tooth join graded on its volume (rim plus the trimmed tooth less their 0.01 mm overlap) Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tests/kernel-cases/booleans/3243-rim-and-rounded-tooth-join/expected.json b/tests/kernel-cases/booleans/3243-rim-and-rounded-tooth-join/expected.json index 9d719eb89..c66c39dfa 100644 --- a/tests/kernel-cases/booleans/3243-rim-and-rounded-tooth-join/expected.json +++ b/tests/kernel-cases/booleans/3243-rim-and-rounded-tooth-join/expected.json @@ -3,7 +3,20 @@ "tangency-labs/solidcraft#3243" ], "what": "a join of a cylindrical rim (r 15.27..16.65, to z=5) and a rounded tooth trimmed to the same two cylinders that overlaps it by 0.01 mm in Z", - "source": "invariants", - "method": "the tooth (z 4.99..7.7) and the rim (z 1.76..5) overlap in z 4.99..5 with positive volume, so the join succeeds and gives one closed solid; the result is larger than the rim alone. No closed form is derived for the tooth, so only the outcome, validity and the body count are graded", - "body_count": 1 + "source": "analytic", + "method": "rim: pi*16.65^2*5 - pi*15.27^2*(5 - 1.76) = 1981.190. Tooth: the profile (flanks from x = +-3 at z 4.99 to x = +-0.1706 at z 7.6327, tip arc through (0, 7.7): centre z 7.45012, radius 0.24988) extruded along +y from y 14.9624 (inside r 15.27 for every |x| <= 3, as sqrt(15.27^2 - 9) = 14.9724) to y 16.65 (outside r 16.65), so trimming to the two cylinders leaves exactly {15.27 <= r <= 16.65} over the profile: V = int over the profile of sqrt(16.65^2 - x^2) - sqrt(15.27^2 - x^2) dx dz = 11.6193 (Simpson, converged to 1e-6). The part of it below z 5 (z 4.99..5) lies inside the rim: 0.0831. Join: 1981.190 + 11.619 - 0.083 = 1992.726 (a join that dropped the tooth gives 1981.19, outside the tolerance). Box: the rim's r 16.65 disc, z 0 to the tooth tip 7.7", + "body_count": 1, + "volume_mm3": 1992.726, + "bbox": { + "min": [ + -16.65, + -16.65, + 0.0 + ], + "max": [ + 16.65, + 16.65, + 7.7 + ] + } } From 9aa2651b17fd7026d88e033a4871cab5c5932045 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:41:39 -0400 Subject: [PATCH 43/81] Kernel rig: 3782 emboss on a cylinder graded on its volume, area, faces and box (the wrapped 4 x 5 badge raised 1 mm) Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/tests/kernel-cases/booleans/3782-emboss-on-cylinder-pick-on-far-half/expected.json b/tests/kernel-cases/booleans/3782-emboss-on-cylinder-pick-on-far-half/expected.json index 620853585..096b0d041 100644 --- a/tests/kernel-cases/booleans/3782-emboss-on-cylinder-pick-on-far-half/expected.json +++ b/tests/kernel-cases/booleans/3782-emboss-on-cylinder-pick-on-far-half/expected.json @@ -4,7 +4,22 @@ "tangency-labs/solidcraft#3425" ], "what": "emboss on a cylinder with the face pick on the half of the wall opposite the sketch", - "source": "invariants", - "method": "the cylinder wall is one logical face, so a pick anywhere on it (between the caps) must be accepted: the emboss succeeds with one valid closed solid. No volume is graded (the badge's shape on a curved wall is not fixed by the issue)", - "body_count": 1 + "source": "analytic", + "method": "the cylinder wall is one logical face, so a pick anywhere on it (between the caps) must be accepted. Emboss on a cylinder wraps the sketch's arc length round the wall from the sketch plane's line of tangency (y = 10) and raises it radially: the 4 x 5 badge spans 4 / 10 = 0.4 rad about +y, z 5..10, from r 10 to r 11. Volume: pi*10^2*20 + (0.4/2)*(11^2 - 10^2)*5 = 2000 pi + 21 = 6304.185. Area: 600 pi, less the wall under the badge 0.4*10*5 = 20, plus its cap 0.4*11*5 = 22, two radial side walls 1*5 each and two end walls (0.4/2)*(11^2 - 10^2) = 4.2 each: 600 pi + 20.4 = 1905.356. Faces: the wall (with the badge's hole), two caps, the badge's cap and its four walls = 8. Box: the cylinder's, with y to 11 (the badge's cap at its middle; it spans x = +-11 sin 0.2 = +-2.19)", + "body_count": 1, + "volume_mm3": 6304.185, + "area_mm2": 1905.356, + "faces": 8, + "bbox": { + "min": [ + -10.0, + -10.0, + 0.0 + ], + "max": [ + 10.0, + 11.0, + 20.0 + ] + } } \ No newline at end of file From 391fc51b4e15a69ccf278a204482fa253401bd77 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:44:09 -0400 Subject: [PATCH 44/81] Kernel rig: 3604 G2 swept-tool cut graded on a volume range (filleted box minus the swept corner section) Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/tests/kernel-cases/booleans/3604-cut-with-g2-swept-tool-along-projected-edge/expected.json b/tests/kernel-cases/booleans/3604-cut-with-g2-swept-tool-along-projected-edge/expected.json index 1113b7546..f51291233 100644 --- a/tests/kernel-cases/booleans/3604-cut-with-g2-swept-tool-along-projected-edge/expected.json +++ b/tests/kernel-cases/booleans/3604-cut-with-g2-swept-tool-along-projected-edge/expected.json @@ -4,7 +4,23 @@ "tangency-labs/solidcraft#3613" ], "what": "cut of a box by a swept G2 corner-removal tool along a projected edge chain (left-rear corner; the symmetric front-left chain works)", - "source": "invariants", - "method": "no closed form for the free-form tool: the tool lies on the box's bottom edge and overlaps it, so the cut must succeed with one valid closed solid (the tool is consumed). No volume is graded", - "body_count": 1 + "source": "analytic", + "method": "fillet: the documented curvature section, the quintic Bezier on setback s = 5 (controls p+s t1, p+2s/3 t1, p+s/3 t1, p+s/3 t2, p+2s/3 t2, p+s t2), cuts 113/21 * 25/36 = 3.73677 mm^2 off each vertical edge (Green on the Bezier): Vf = 8000 - 4*10*3.73677 = 7850.529. Tool section: the G2 blend between two lines is the degree 5 Hermite Bezier of the lines' own derivatives, controls (0.8,0) (0.8,0.04) (0.8,0.08) (0.08,0.8) (0.04,0.8) (0,0.8); the part of the profile in the material quadrant has area a = 0.360667 and first moment about the wall S = 0.102152. Swept along the corner curve (length 8.21299, total turn pi/2, curvature at most 0.269, so 1 - k*0.8 > 0 and the tube does not fold), it removes a*L - S*pi/2 = 2.8015; along l3, a straight bottom edge next to that corner (10 long on the left, 30 on the rear: the chain's naming fixes which, analysis does not), a*10 = 3.6067 or a*30 = 10.820. V lies between 7850.529 - 13.622 = 7836.907 and 7850.529 - 6.408 = 7844.121, widened by 1e-4 relative for the measurement: a cut that did nothing (7850.53) or a fillet not made falls outside. Box: the 40 x 20 x 10 box's (the fillets and the cut leave every extreme face)", + "body_count": 1, + "volume_mm3": [ + 7836.1, + 7844.9 + ], + "bbox": { + "min": [ + 0.0, + 0.0, + 0.0 + ], + "max": [ + 40.0, + 20.0, + 10.0 + ] + } } \ No newline at end of file From 166d574cc91bc077bf8b761db0a0d7de9e958ff9 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:45:26 -0400 Subject: [PATCH 45/81] Kernel rig: 4505 coil joined through a cylinder wall graded on its volume, area and box (cylinder plus the wire's screw-swept segment outside r 76) Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/tests/kernel-cases/booleans/4505-join-coil-through-cylinder-wall/expected.json b/tests/kernel-cases/booleans/4505-join-coil-through-cylinder-wall/expected.json index 2e302fc93..b7aa632d6 100644 --- a/tests/kernel-cases/booleans/4505-join-coil-through-cylinder-wall/expected.json +++ b/tests/kernel-cases/booleans/4505-join-coil-through-cylinder-wall/expected.json @@ -4,7 +4,21 @@ "tangency-labs/solidcraft#3636" ], "what": "a coil (diameter 151, pitch 10, 80 high, 5 mm round section) whose section runs through a diameter-152 cylinder's wall, joined to it: truck ground for 125-296 s, then 'boolean Union: no result'", - "source": "invariants", - "method": "the coil's section crosses the wall along its whole length, so the union is one connected solid: one valid closed body. The helical sweep's part outside r 76 has no closed-form volume (the triage's script)", - "body_count": 1 + "source": "analytic", + "method": "the coil is a screw sweep of its axial section, a 5 mm circle centred at r 75.5 (section_position center), 80 / 10 = 8 turns from z 10, so the wire spans r 73..78, z 7.5..92.5: inside r 76 it lies in the cylinder (r 76, z 0..100), and what the join adds is the screw sweep of the section's segment beyond r 76 (chord 0.5 from the centre). Segment: A = 2.5^2 acos(0.2) - 0.5 sqrt(6) = 7.33425, int r dA = 75.5 A + (2/3) 6^(3/2) = 563.5335; a screw motion sweeps 2 pi * turns * int r dA: 16 pi * 563.5335 = 28326.28. V = pi 76^2 100 + 28326.28 = 1842910.2 (the cylinder alone, 1814583.9, is far outside the tolerance). Area: the cylinder's 2 pi 76^2 + 2 pi 76 100, less the band the wire covers on r 76 (2 sqrt(6) * 2 pi 76 * 8 = 18714.97), plus the screw sweep of the wire's outer arc (16 pi int R sqrt(r^2 + (10/2pi)^2 sin^2 phi) dphi over |phi| < acos(0.2), r = 75.5 + 2.5 cos phi: 26603.45) and the two end segments (2 A): 91947.04. Box: r 78 in x and y (8 whole turns reach every direction), z 0..100", + "body_count": 1, + "volume_mm3": 1842910.2, + "area_mm2": 91947.04, + "bbox": { + "min": [ + -78.0, + -78.0, + 0.0 + ], + "max": [ + 78.0, + 78.0, + 100.0 + ] + } } From 7fdbd5ab60b409184311484599078e4854590e3e Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:47:30 -0400 Subject: [PATCH 46/81] Kernel rig: 4879 window cut through a thickened spline revolve graded on a volume range and its faces Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/kernel-cases/booleans/4879-cut-through-thickened-spline-revolve/expected.json b/tests/kernel-cases/booleans/4879-cut-through-thickened-spline-revolve/expected.json index 318d76655..988ca8efd 100644 --- a/tests/kernel-cases/booleans/4879-cut-through-thickened-spline-revolve/expected.json +++ b/tests/kernel-cases/booleans/4879-cut-through-thickened-spline-revolve/expected.json @@ -4,7 +4,12 @@ "tangency-labs/solidcraft#4484" ], "what": "a symmetric through-all cut of a window across a thickened (2 mm) surface revolve of a control-point spline (100 deg about X): truck ran ~20 s to 'boolean Cut: no result' (or never finished)", - "source": "invariants", - "method": "the window (x -2..6, z 6..20, through all y) crosses the shell where it is near the XZ plane and leaves it joined round the rest of its 100 deg, so the result is one valid closed body. The spline shell has no closed-form volume", - "body_count": 1 + "source": "analytic", + "method": "the window (x -2..6, z 6..20, through all y) crosses the shell where it is near the XZ plane and leaves it joined round the rest of its 100 deg, so the result is one valid closed body. The revolve's normal lies in each meridian plane, so the 2 mm thicken is the revolution, through 100 deg, of the band between the cubic spline (clamped, knots 0 0 0 0 .5 1 1 1 1; r 8..11.63, curvature at most 0.128, so a 2 mm offset never folds) and its offset; the window removes, at each point (x, r) of the band with -2 <= x <= 6, the angles where r cos phi >= 6 (acos(6/r) of them; r cos phi <= 20 everywhere). V = int over the band of r (100 deg - [x in -2..6] acos(6/r)) dA, by quadrature: 852.04 thickened outwards (uncut 1053.63), 660.02 inwards (uncut 807.73). Which side the revolve's normal faces is the kernel's convention, so V is graded in [660.02, 852.04], widened 1e-3: a cut that did nothing on the outer side, or lost half the body, falls outside. Faces: the two offset walls, the two end caps, the plane at 100 deg, the XZ plane's two pieces either side of the window, and the window's planes x = -2, x = 6 and z = 6: 10", + "body_count": 1, + "volume_mm3": [ + 659.3, + 852.9 + ], + "faces": 10 } From 18c8add3fbe89299c67b1a541a30ecc27bb448cf Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:49:12 -0400 Subject: [PATCH 47/81] Kernel rig: 4623 join of crossing pleated loft skins graded on its volume and box (both skins less their overlap) Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tests/kernel-cases/booleans/4623-join-crossing-pleated-loft-skins/expected.json b/tests/kernel-cases/booleans/4623-join-crossing-pleated-loft-skins/expected.json index f44f64de6..9fa7e4a42 100644 --- a/tests/kernel-cases/booleans/4623-join-crossing-pleated-loft-skins/expected.json +++ b/tests/kernel-cases/booleans/4623-join-crossing-pleated-loft-skins/expected.json @@ -5,7 +5,20 @@ "tangency-labs/solidcraft#4881" ], "what": "a join of two pleated skins (lofts between 24-pleat star outlines, less the same loft moved in 1.1 mm) that cross along a ring near their bottoms: truck panicked ('tolerance must be no less than 1e-6') or gave no result", - "source": "invariants", - "method": "the narrowing cone skin and the flaring lip skin cross at z = -0.3, so their union is one connected solid: one valid closed body, no panic. The reporter's own script (pleated_union.py, 24 pleats)", - "body_count": 1 + "source": "analytic", + "method": "the narrowing cone skin and the flaring lip skin cross at z = -0.3, so their union is one connected solid: one valid closed body, no panic. The reporter's own script (pleated_union.py, 24 pleats). Every outline has its 48 vertices on the same rays (every 7.5 deg), and a ruled loft takes vertex to vertex, so at each z every loft is the star polygon with radii linear in z on those rays (a convex combination of two points on a ray stays on it), and each inner loft lies inside its outer one at every z (the radii are smaller on every ray). Skin volumes: the section area is quadratic in z (wedge areas r_i r_i+1 sin(7.5 deg) / 2), so Simpson is exact: cone 39321.32 (z -1..88.3), lip 5571.95 (z -1..6). Their overlap, by integrating over z -1..6 and each wedge's angle the radial intersection of the two skins' intervals (1/2 (r1^2 - r0^2) dtheta, converged to 0.3): 449.76. Join: 39321.32 + 5571.95 - 449.76 = 44443.5 (the two skins' plain sum, 44893.3, and either skin alone fall outside the tolerance). Box: the lip's top outline (r 120 on the axes) and the skins' z -1..88.3", + "body_count": 1, + "volume_mm3": 44443.5, + "bbox": { + "min": [ + -120.0, + -120.0, + -1.0 + ], + "max": [ + 120.0, + 120.0, + 88.3 + ] + } } From 5fb3cfa8a6c68aa27010b0dca09be96e1ba0d427 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:52:25 -0400 Subject: [PATCH 48/81] Kernel rig: 831 tapered glyph extrude graded on a volume range and box (the font's S drafted in by 10 deg) Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/tests/kernel-cases/booleans/831-tapered-extrude-text-glyph/expected.json b/tests/kernel-cases/booleans/831-tapered-extrude-text-glyph/expected.json index c3a1b6975..45a72ab8b 100644 --- a/tests/kernel-cases/booleans/831-tapered-extrude-text-glyph/expected.json +++ b/tests/kernel-cases/booleans/831-tapered-extrude-text-glyph/expected.json @@ -3,7 +3,23 @@ "tangency-labs/solidcraft#831" ], "what": "tapered extrude of a text glyph (Bezier outline): refused with a misleading 'mixing lines and arcs' error", - "source": "invariants", - "method": "the letter S, 1 mm tall with -10 deg draft, is one valid closed solid (the glyph is one connected region); no number is derived because the glyph outline is the font's. Its volume is positive and below the plain extrusion's", - "body_count": 1 + "source": "analytic", + "method": "the letter S, 1 mm tall with -10 deg draft, is one valid closed solid (the glyph is one connected region). Its outline is the embedded font's (Liberation Sans 'S', one contour of 46 points, quadratic segments), scaled by the capital height: 10 / 1409 font units. From the outline (Green on the exact quadratic segments): area A = 32.1459, perimeter P = 55.7935, four convex corners of 91.6, 87.2, 96.1 and 84.5 deg at the stroke ends. A -10 deg taper moves the outline in by d = t tan 10 deg at height t, so A(d) = A - P d + C d^2 with C = 1/2 (smooth turning) + sum tan(corner/2) = 4.0065 (mitred corners), and V = A - P tan10/2 + C tan10^2/3 = 27.268. The moved outline is documented within 10 um of the true offset, so V lies within 0.01 * P = 0.56 of that: [26.71, 27.83] (the untapered 32.15 and an outward taper, 37.1, fall outside). Box: the glyph's own extents at z 0, x 0.6600..9.0277, y -0.1419..10.1490, z 0..1", + "body_count": 1, + "volume_mm3": [ + 26.71, + 27.83 + ], + "bbox": { + "min": [ + 0.66, + -0.1419, + 0.0 + ], + "max": [ + 9.0277, + 10.149, + 1.0 + ] + } } From 34e404d38481e6eff1d2876b36d12ce2d79fc0ab Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:55:10 -0400 Subject: [PATCH 49/81] Kernel rig: 2357 ring of 90 cylinder segments graded on its volume and box (the segments less their 90 joint overlaps) Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tests/kernel-cases/crashes/2357-join-ring-of-90-cylinder-segments/expected.json b/tests/kernel-cases/crashes/2357-join-ring-of-90-cylinder-segments/expected.json index 08e80e282..dc442a517 100644 --- a/tests/kernel-cases/crashes/2357-join-ring-of-90-cylinder-segments/expected.json +++ b/tests/kernel-cases/crashes/2357-join-ring-of-90-cylinder-segments/expected.json @@ -3,8 +3,21 @@ "tangency-labs/solidcraft#2357" ], "what": "one join of a ring of 90 straight cylinder segments, each overlapping its neighbour at a 4 degree joint: a caught truck panic, then a refusal after 21 minutes", - "source": "invariants", - "method": "the segments (diameter 5, 7.6 long, centred on radius 100, every 4 degrees) overlap their neighbours (the 4 degree chord at radius 100 is 6.98 < 7.6), so they join into one closed ring: one body with one shell, valid. The joint overlaps have no simple closed form, so no volume is graded. The rig's timeout bounds the time (the issue expects time to grow about linearly with the segment count)", + "source": "analytic", + "method": "the segments (diameter 5, 7.6 long, centred on radius 100, every 4 degrees) overlap their neighbours (the 4 degree chord at radius 100 is 6.98 < 7.6), so they join into one closed ring: one body with one shell, valid. Segments two apart (13.95 between centres, each within 4.55 of its centre) never meet, so V = 90 (pi 2.5^2 7.6 - W) with W the overlap of two neighbours: their axes cross 3.492 from each midpoint at 4 degrees, and W = int over the plane z = 0 of 2 min(sqrt(6.25 - dA^2), sqrt(6.25 - dB^2)) where both points lie within the segments' lengths (dA, dB the distances to the axes): 12.0915 (grid 800^2 and 1600^2 agree to 1e-4). V = 90 (149.2257 - 12.0915) = 12342.07 (the plain sum, 13430.3, is outside the tolerance). Box: each segment reaches c.e + 3.8 |a.e| + 2.5 sqrt(1 - (a.e)^2) along e; the furthest are those at 2 degrees off the x axis (x +-102.570) and 4 degrees off the y axis (y +-102.515); z +-2.5", "body_count": 1, - "shells": 1 + "shells": 1, + "volume_mm3": 12342.07, + "bbox": { + "min": [ + -102.57, + -102.515, + -2.5 + ], + "max": [ + 102.57, + 102.515, + 2.5 + ] + } } From d54d3195ffb8da4c0d67e5f2e3791cc10219390c Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:56:32 -0400 Subject: [PATCH 50/81] Kernel rig: 4542 fluted wall joined on a revolved base graded on its volume and box (the base by Pappus plus the fit-spline ring) Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tests/kernel-cases/crashes/4542-join-fluted-wall-on-revolved-base/expected.json b/tests/kernel-cases/crashes/4542-join-fluted-wall-on-revolved-base/expected.json index 810c21b84..48032ef38 100644 --- a/tests/kernel-cases/crashes/4542-join-fluted-wall-on-revolved-base/expected.json +++ b/tests/kernel-cases/crashes/4542-join-fluted-wall-on-revolved-base/expected.json @@ -3,7 +3,20 @@ "tangency-labs/solidcraft#4542" ], "what": "a fluted cup wall (a 72-point periodic fit spline round r 31.5..32.5 outside, a circle r 25 inside) extruded 90 mm as a join onto the top face of a revolved base disc of r 32: the app hung in the boolean", - "source": "invariants", - "method": "the wall's ring stands on the base's top face (z = 7), overlapping it between r 25 and the disc's rim and overhanging it where the flutes pass r 32, so the join is one connected solid: one valid closed body. The spline's area is not closed-form, so the volume is not graded", - "body_count": 1 + "source": "analytic", + "method": "the wall's ring stands on the base's top face (z = 7), overlapping it between r 25 and the disc's rim and overhanging it where the flutes pass r 32, so the join is one connected solid: one valid closed body. The two only share the face z = 7, so V is their sum. Base: Pappus on the profile (0,0)-(25,0), the arc through (29.5,1.5) to (32,7) (centre (25.25, 6.75), r 6.75463), (32,7)-(0,7): area 214.2728, V = 2 pi int x dA = 20655.013. Wall: the sketch's periodic fit spline is the C2 cyclic cubic through the 72 points with chord-length spans (closed back to the first point), its area by Green on its 72 Bezier pieces 3217.3851 (star-shaped, r 31.5002..32.5002); less the r 25 circle: 1253.8897, times 90 = 112850.069. V = 133505.08 (either part alone, or a wall sunk into the base, falls outside the tolerance). Box: the spline's extremes x, y +-32.5 (it reaches 32.5 on the axes and no further), z 0..97", + "body_count": 1, + "volume_mm3": 133505.08, + "bbox": { + "min": [ + -32.5, + -32.5, + 0.0 + ], + "max": [ + 32.5, + 32.5, + 97.0 + ] + } } From c0c961326a1724b9497caaca24d08abe8f3e7681 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:57:33 -0400 Subject: [PATCH 51/81] Kernel rig: 1985 and 2243 STEP-export enclosures graded on their volume and box (the outline less the cavity, plus gusset and standoffs) Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 19 ++++++++++++++++--- .../expected.json | 19 ++++++++++++++++--- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/tests/kernel-cases/crashes/1985-step-export-enclosure-screw-hole/expected.json b/tests/kernel-cases/crashes/1985-step-export-enclosure-screw-hole/expected.json index 7dedebf3c..67aceaf46 100644 --- a/tests/kernel-cases/crashes/1985-step-export-enclosure-screw-hole/expected.json +++ b/tests/kernel-cases/crashes/1985-step-export-enclosure-screw-hole/expected.json @@ -4,7 +4,20 @@ "tangency-labs/solidcraft#2243" ], "what": "a small enclosure (rounded box, inner cut, corner gusset with a screw hole, two standoffs, USB cut-out) whose STEP export never finished (the export meshes its own file back)", - "source": "invariants", - "method": "the script builds one connected part: the export must finish, and the part is one valid closed solid", - "body_count": 1 + "source": "analytic", + "method": "the script builds one connected part: the export must finish, and the part is one valid closed solid. Body sketch: the rounded rectangle 0..80 x 0..79, corners r 3 (straights 74 and 73), area 80*79 - (4 - pi)*9 = 6312.274, extruded 37.5: 236710.288. Cavity box (2,2,2.5) 74 x 73, open at the top: - 74*73*35 = 189070. Gusset (68,67,2.5) 8 x 8 x 35 in the cavity's back corner: + 2240. Screw hole r 1.25 at (72,71) from z 29.5, inside the gusset: - pi 1.25^2 8 = 39.270. Two standoffs r 2.5, 3 high at (30.11, 69.04) and (58.05, 69.04) on the floor, clear of the walls and the gusset: + 2 * 58.905. USB cut-out (21.33..31.33, -1..3, 5..11) through the 2 mm front wall: - 10*2*6 = 120. V = 49838.83. Box: the outline's 0..80 x 0..79, z 0..37.5", + "body_count": 1, + "volume_mm3": 49838.83, + "bbox": { + "min": [ + 0.0, + 0.0, + 0.0 + ], + "max": [ + 80.0, + 79.0, + 37.5 + ] + } } \ No newline at end of file diff --git a/tests/kernel-cases/crashes/2243-step-export-flanged-enclosure/expected.json b/tests/kernel-cases/crashes/2243-step-export-flanged-enclosure/expected.json index 93668104c..76f92907f 100644 --- a/tests/kernel-cases/crashes/2243-step-export-flanged-enclosure/expected.json +++ b/tests/kernel-cases/crashes/2243-step-export-flanged-enclosure/expected.json @@ -4,7 +4,20 @@ "tangency-labs/solidcraft#1985" ], "what": "a flanged enclosure with two standoffs and no screw hole whose STEP export also never finished", - "source": "invariants", - "method": "one connected part: the export finishes and the part is one valid closed solid", - "body_count": 1 + "source": "analytic", + "method": "one connected part: the export finishes and the part is one valid closed solid. Body sketch: the rounded rectangle 0..80 x 0..79, corners r 3, area 80*79 - (4 - pi)*9 = 6312.274, extruded 32.5. Flange: the rounded rectangle -10..90 x 0..79, corners r 3, area 7892.274, 2.5 thick, holding the body's footprint (its own corners lie outside the body's), so the two give 7892.274*2.5 + 6312.274*30. Cavity box (3,3,2.5) 74 x 73, open at the top: - 74*73*30 = 162060. Gusset (69,68,2.5) 8 x 8 x 30: + 1920. Two standoffs r 2.5, 3 high at (31.11, 70.04) and (59.05, 70.04): + 2 * 58.905. V = 49076.73. Box: the flange's -10..90 x 0..79, z 0..32.5", + "body_count": 1, + "volume_mm3": 49076.73, + "bbox": { + "min": [ + -10.0, + 0.0, + 0.0 + ], + "max": [ + 90.0, + 79.0, + 32.5 + ] + } } \ No newline at end of file From d77aac4164805c5a197ce025910f44bc3dfbf295 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 09:02:39 -0400 Subject: [PATCH 52/81] Kernel rig: both 4092 loft, ribs and pad unions graded on their volume and box Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 19 ++++++++++++++++--- .../expected.json | 19 ++++++++++++++++--- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/tests/kernel-cases/crashes/4092-loft-ribs-rounded-pad-union-panics/expected.json b/tests/kernel-cases/crashes/4092-loft-ribs-rounded-pad-union-panics/expected.json index 073d941c6..910d7b8ea 100644 --- a/tests/kernel-cases/crashes/4092-loft-ribs-rounded-pad-union-panics/expected.json +++ b/tests/kernel-cases/crashes/4092-loft-ribs-rounded-pad-union-panics/expected.json @@ -3,7 +3,20 @@ "tangency-labs/solidcraft#4092" ], "what": "join extrude of a rounded pad over a lofted body with ring and ribs: repeated truck intersection_curve panics, then 'boolean Union: no result'", - "source": "invariants", - "method": "the pad (X -8..8, Y 18..25, Z 36..59) overlaps the body, ribs and ring, so the join is one connected solid; the join must succeed with one valid closed solid and no panic", - "body_count": 1 + "source": "analytic", + "method": "the pad (X -8..8, Y 18..25, Z 36..59) overlaps the body, ribs and ring, so the join is one connected solid; the join must succeed with one valid closed solid and no panic. Body: neck pi 18^2 21; the two-section loft is ruled, the circle r 18 paired with the 30 x 20 ellipse by their common angle parameter (the ellipse an affine image of the circle), so each section is an ellipse (18 + 12 l) x (18 + 2 l): 17 pi int (18 + 12 l)(18 + 2 l) dl = 7786 pi (pairing by normals instead, the largest any pairing gives, adds 17 pi * 1.5 = 80, inside the tolerance); the ellipse chamber pi*30*20*22 (z 38..60) and the flange 70 x 50 r 6 (area 3500 - (4 - pi)*36 = 3469.097, z 60..64, holding the chamber): 101181.25. The handle disc (r 12 about (y 30, z 47), x -5..5), the two ribs (the rounded profile, x -8..-4 and 4..8) and the pad (x -8..8, z 36..59 rounded r 3, y 18..25) add, by integrating over x -8..8, z 35..59 the length in y of the union of every part's y-interval less the body's own (grids 400^2..1600^2 agree to 2.4): 5347.9. V = 106529.2. Box: the flange's x +-35, y -25 to the disc's 42, z 0..64", + "body_count": 1, + "volume_mm3": 106529.2, + "bbox": { + "min": [ + -35.0, + -25.0, + 0.0 + ], + "max": [ + 35.0, + 42.0, + 64.0 + ] + } } \ No newline at end of file diff --git a/tests/kernel-cases/crashes/4092-loft-ribs-rounded-pad-union-reduced/expected.json b/tests/kernel-cases/crashes/4092-loft-ribs-rounded-pad-union-reduced/expected.json index 0d4fbde59..a469e2f6e 100644 --- a/tests/kernel-cases/crashes/4092-loft-ribs-rounded-pad-union-reduced/expected.json +++ b/tests/kernel-cases/crashes/4092-loft-ribs-rounded-pad-union-reduced/expected.json @@ -3,7 +3,20 @@ "tangency-labs/solidcraft#4092" ], "what": "the same without the top flange: the join fails with 'boolean Union: no result'", - "source": "invariants", - "method": "the pad (X -8..8, Y 18..25, Z 36..59) overlaps the body, ribs and ring, so the join is one connected solid; the join must succeed with one valid closed solid and no panic", - "body_count": 1 + "source": "analytic", + "method": "the pad (X -8..8, Y 18..25, Z 36..59) overlaps the body, ribs and ring, so the join is one connected solid; the join must succeed with one valid closed solid and no panic. Body: neck pi 18^2 21; the two-section loft is ruled, the circle r 18 paired with the 30 x 20 ellipse by their common angle parameter (the ellipse an affine image of the circle), so each section is an ellipse (18 + 12 l) x (18 + 2 l): 17 pi int (18 + 12 l)(18 + 2 l) dl = 7786 pi (pairing by normals instead, the largest any pairing gives, adds 17 pi * 1.5 = 80, inside the tolerance); the ellipse chamber pi*30*20*26 (z 38..64): 94844.68. The handle disc (r 12 about (y 30, z 47), x -5..5), the two ribs (the rounded profile, x -8..-4 and 4..8) and the pad (x -8..8, z 36..59 rounded r 3, y 18..25) add, by integrating over x -8..8, z 35..59 the length in y of the union of every part's y-interval less the body's own (grids 400^2..1600^2 agree to 2.4): 5347.9. V = 100192.6. Box: the chamber's x +-30, y -20 to the disc's 42, z 0..64", + "body_count": 1, + "volume_mm3": 100192.6, + "bbox": { + "min": [ + -30.0, + -20.0, + 0.0 + ], + "max": [ + 30.0, + 42.0, + 64.0 + ] + } } \ No newline at end of file From e30459e52417889188a2a4cc555befa4892fe5ef Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:45:31 -0400 Subject: [PATCH 53/81] Kernel rig: 1525 graded on its volume (the convex body's exact 2 mm inward offset), faces and box Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/tests/kernel-cases/shell/1525-shell-box-with-rounds-chamfer-and-fillet/expected.json b/tests/kernel-cases/shell/1525-shell-box-with-rounds-chamfer-and-fillet/expected.json index d71d868c3..f113d6a47 100644 --- a/tests/kernel-cases/shell/1525-shell-box-with-rounds-chamfer-and-fillet/expected.json +++ b/tests/kernel-cases/shell/1525-shell-box-with-rounds-chamfer-and-fillet/expected.json @@ -3,7 +3,21 @@ "tangency-labs/solidcraft#1525" ], "what": "a 50x50x30 box with r10 vertical rounds, a 5 mm chamfer round the base and a 4 mm fillet where the chamfer meets the wall, shelled 2 mm open at the top", - "source": "invariants", - "method": "every radius and the chamfer have room for a 2 mm wall, so the shell must succeed: one valid closed body (no closed-form volume with the blend patches)", - "body_count": 1 + "source": "analytic", + "method": "the body is convex (every edge convex), so the 2 mm shell's cavity is its exact inward offset, open at the top. Body = the square Q = [10,40]^2 swept by a profile at distance f(z) from Q: horizontal section area A(z) = 900 + 120 f + pi f^2. Body: f = 5 + z (chamfer) to z = 4 sqrt2 - 1.828 = 3.828, then the r4 fillet centred at (6, zc), zc = 1 + 4 sqrt2, f = 6 + sqrt(16 - (z - zc)^2) up to zc, then f = 10 (r10 rounds) to z = 30. Cavity (every face moved 2 in: floor z = 2, chamfer plane by 2 along its normal, fillet r2 about the same centre, rounds r8): f = z + 5 - 2 sqrt2 to zc - sqrt2, then 6 + sqrt(4 - (z - zc)^2) to zc, then 8, from z = 2 to 30. V = int_0^30 A_body - int_2^30 A_cavity = 70207.8635 - 56506.1293. Faces: the body's 26 (top, bottom, 4 walls, 4 rounds, 4 + 4 chamfer planes and cones, 4 + 4 fillet cylinders and tori) less the top, their 25 inner copies and the rim", + "body_count": 1, + "volume_mm3": 13701.734185296977, + "faces": 51, + "bbox": { + "min": [ + 0, + 0, + 0 + ], + "max": [ + 50, + 50, + 30 + ] + } } \ No newline at end of file From c740e4de139acb0b699c876e948757c2a6624f9d Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:46:13 -0400 Subject: [PATCH 54/81] Kernel rig: 1494 graded on its volume (box and cylinder less the 1 mm-offset cavity, sharp to rounded concave edges) and box Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/tests/kernel-cases/shell/1494-shell-box-with-cylinder-on-edge-line/expected.json b/tests/kernel-cases/shell/1494-shell-box-with-cylinder-on-edge-line/expected.json index 5763000b7..9cb9e0a8a 100644 --- a/tests/kernel-cases/shell/1494-shell-box-with-cylinder-on-edge-line/expected.json +++ b/tests/kernel-cases/shell/1494-shell-box-with-cylinder-on-edge-line/expected.json @@ -3,7 +3,23 @@ "tangency-labs/solidcraft#1494" ], "what": "a 47.5x45x30 box with a cylinder r7.5 joined on its side whose axis lies in the plane of the box's front face (y=0), shelled 1 mm open at the bottom", - "source": "invariants", - "method": "the cylinder wall's seam lies on the front plane, giving a five-face saddle corner at (47.5,0,2.5). No closed-form volume (the cavity corners follow the offset surfaces); the shell must succeed and give one valid closed body", - "body_count": 1 + "source": "analytic", + "method": "the cylinder wall's seam lies on the front plane, giving a five-face saddle corner at (47.5,0,2.5). Body = box 64125 + cylinder pi 7.5^2 30 = 69426.4376 (they share only the half disc on x = 47.5). Cavity with every kept face moved 1 in and extended to meet (sharp): box [1,46.5] x [1,44] x [0,29] (45.5 x 43 x 29) and the cylinder r6.5 from x = 46.5 to 76.5, less, over x 46.5..48.5, its part with y < 1 (the front face's and the uncovered half disc's offsets): 2 (pi 6.5^2/2 + int_0^1 2 sqrt(6.5^2 - y^2) dy) = 158.6294; cavity 60561.8393, material 8864.5983. A cavity that rounds its two concave edges instead (the true 1 mm offset) is larger by at most (1 - pi/4) per mm of each: the front face / half disc line (its offset at most 13 long inside r6.5) and the half circle r7.5 where the cylinder meets the box (at most 7.5 pi): 7.8463, so material 8856.7520 .. 8864.5983. A shell that fails to open leaves 2 shells; the full solid is 69426", + "body_count": 1, + "volume_mm3": [ + 8856.7, + 8864.7 + ], + "bbox": { + "min": [ + 0, + -7.5, + 0 + ], + "max": [ + 77.5, + 45, + 30 + ] + } } \ No newline at end of file From ba75de350af23a7f30018cd3e7c6c0eb3c39d9d4 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:46:35 -0400 Subject: [PATCH 55/81] Kernel rig: 4492 graded on its box and a volume range (the face's 19 mm sweep added, within the block's sides) Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/tests/kernel-cases/shell/4492-offset-top-face-of-block-with-rounded-top-edges/expected.json b/tests/kernel-cases/shell/4492-offset-top-face-of-block-with-rounded-top-edges/expected.json index 7e05fa4e6..316e23097 100644 --- a/tests/kernel-cases/shell/4492-offset-top-face-of-block-with-rounded-top-edges/expected.json +++ b/tests/kernel-cases/shell/4492-offset-top-face-of-block-with-rounded-top-edges/expected.json @@ -3,7 +3,23 @@ "tangency-labs/solidcraft#4492" ], "what": "the top face of a 40x30x10 block whose four top edges are rounded r3, offset 19 mm up: truck refused it ('a corner whose faces don't meet the same way after the move')", - "source": "invariants", - "method": "the top face's neighbours are the rounds, tangent to it, which cannot extend to meet a plane 19 mm higher; how the gap closes (the rounds carried up with the face, or walls standing on the old face) is the method's choice, so only the outcome is graded: the offset succeeds with one valid closed body", - "body_count": 1 + "source": "analytic", + "method": "the top face's neighbours are the rounds, tangent to it, which cannot extend to meet a plane 19 mm higher; how the gap closes (the rounds carried up with the face, or walls standing on the old face) is the method's choice, so the volume is bounded, not fixed. The block before: 12000 less the four r3 rounds, 2 (40 + 30) 9 (1 - pi/4) less the four corners where two rounds' removals overlap, int_0^3 (3 - sqrt(9 - w^2))^2 dw = 45 - 13.5 pi each: 11739.9557. The result holds the block and the 34 x 24 face's sweep up to z = 29 (+15504: the walls standing on the old face, 27243.9557) and lies within the block's sides and the moved face's plane, 40 x 30 x 29 = 34800 (the rounds carried up give 34539.9557). The unchanged block (11740) falls outside", + "body_count": 1, + "volume_mm3": [ + 27243.9, + 34800.0 + ], + "bbox": { + "min": [ + 0, + 0, + 0 + ], + "max": [ + 40, + 30, + 29 + ] + } } From bdb321cdbae814fe1384d982f0c02f0d85e5eea7 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:47:12 -0400 Subject: [PATCH 56/81] Kernel rig: 745 graded on its volume (the end moved 1 mm plus the spline boss's exact area), faces and box Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/tests/kernel-cases/shell/745-offset-face-on-body-with-distant-freeform-boss/expected.json b/tests/kernel-cases/shell/745-offset-face-on-body-with-distant-freeform-boss/expected.json index ffbe1034b..6c2502033 100644 --- a/tests/kernel-cases/shell/745-offset-face-on-body-with-distant-freeform-boss/expected.json +++ b/tests/kernel-cases/shell/745-offset-face-on-body-with-distant-freeform-boss/expected.json @@ -4,7 +4,21 @@ "tangency-labs/solidcraft#3893" ], "what": "Offset Face on a planar end of a body that has a spline-outlined boss far from the moved face", - "source": "invariants", - "method": "the move is refused today only because the unrelated boss wall is freeform. The operation must succeed and give one valid closed solid; the box end at x=0 moves out by 1 mm (the boss area is a spline integral, so no absolute volume is asserted; the 200 mm3 change is graded in the cut-away variant 745-offset-face-then-cut-boss-away)", - "body_count": 1 + "source": "analytic", + "method": "the move is refused today only because the unrelated boss wall is freeform. The box end at x=0 moves out by 1 mm between its four planar, square neighbours: +1 x 20 x 10 = 200. The boss outline is the line (25,5)-(35,5) and the fit-point spline through (35,5), (37,10), (30,15), (25,5): the sketch's natural cubic with chord-length parameters, three cubic spans, its area by Green's theorem (1/2 closed integral of x dy - y dx, a polynomial per span, integrated exactly) 94.302132; it stays within x 25..37.04, y 5..15.01. V = 8000 + 5 x 94.302132 + 200. Faces: the box's 6 and the boss's top, flat wall and spline wall. The cut-away variant 745-offset-face-then-cut-boss-away grades the same move without the boss", + "body_count": 1, + "volume_mm3": 8671.510661445036, + "faces": 9, + "bbox": { + "min": [ + -1, + 0, + 0 + ], + "max": [ + 40, + 20, + 15 + ] + } } \ No newline at end of file From 1893a5016183438321da01c7ceb53abb124e7c66 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:48:29 -0400 Subject: [PATCH 57/81] Kernel rig: 4567 graded on its volume (the revolved spline less its revolved 2 mm offset), faces and box Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/tests/kernel-cases/shell/4567-shell-spline-revolved-vase/expected.json b/tests/kernel-cases/shell/4567-shell-spline-revolved-vase/expected.json index a0c8f5d8f..55f8c7fda 100644 --- a/tests/kernel-cases/shell/4567-shell-spline-revolved-vase/expected.json +++ b/tests/kernel-cases/shell/4567-shell-spline-revolved-vase/expected.json @@ -6,7 +6,21 @@ "tangency-labs/solidcraft#4743" ], "what": "a vase revolved from a fit-point spline wall, shelled 2 mm from its flat top: truck refused any free-form wall ('offset: only bodies with planes, cylinders, cones, spheres and tori')", - "source": "invariants", - "method": "the spline wall's curvature radius stays well above 2 mm, so the inward 2 mm offset exists: one valid closed body, open at the top. The offset of a spline surface has no closed-form volume, so only the outcome is graded (the reporter's 7-command repro; the removed face is the flat top at y = 46)", - "body_count": 1 + "source": "analytic", + "method": "the wall is the sketch's fit-point spline: the natural cubic through the seven points with chord-length parameters, six cubic spans. Its curvature towards the material stays below 0.0765 / mm (radius 13) and away from it below 0.34 / mm, so its 2 mm inward offset, c - 2 n, is a clean curve; the revolved shell's cavity is that offset revolved (the offset of a surface of revolution is its meridian's offset revolved), open at the flat top y = 46 (removed): it leaves the axis at y = 2.00335 (the bottom is a flat cone point, the two halves' offsets meet there) and reaches y = 46 at x = 3.96953, before its end (4.030, 46.346), so it is trimmed, never extended. Volumes by revolving (V = pi int x^2 dy): body 46402.29333 (exact, polynomial per span), cavity 34793.17040 (pi int x_o^2 dy_o along the offset, with o' = c' (1 - 2 k), Gauss quadrature converged to 1e-9). V = 11609.12293. Faces: the outer wall, the inner wall and the rim; the wall reaches x = 22.8722 at most", + "body_count": 1, + "volume_mm3": 11609.12292605581, + "faces": 3, + "bbox": { + "min": [ + -22.8722, + 0, + -22.8722 + ], + "max": [ + 22.8722, + 46, + 22.8722 + ] + } } From a53f1640e87e9d289351899d040adc99b095692a Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:50:31 -0400 Subject: [PATCH 58/81] Kernel rig: the up-down squares shell graded on its volume (the columns less the 0.346 mm-offset cavity, sharp to rounded concave edges) and box Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/tests/kernel-cases/shell/cov-shell-up-down-joined-squares-open-at-a-side-wall/expected.json b/tests/kernel-cases/shell/cov-shell-up-down-joined-squares-open-at-a-side-wall/expected.json index d609b040b..3357fd5ba 100644 --- a/tests/kernel-cases/shell/cov-shell-up-down-joined-squares-open-at-a-side-wall/expected.json +++ b/tests/kernel-cases/shell/cov-shell-up-down-joined-squares-open-at-a-side-wall/expected.json @@ -1,7 +1,23 @@ { "sources": [], "what": "four squares drawn edge to edge, three extruded 10 up and three 10 down and joined, shelled 0.346 mm open at a side wall (action matrix (apps/solidcraft-cli/tests/action_matrix.rs): typical/up-down-join, Body1/F2:side:l1 face.shell)", - "source": "invariants", - "method": "every wall is 10 x 10 or more and the shell thin: the cavity's corners where the up and down parts overlap only along an edge are the offset's own choice, so no closed form: one closed valid solid is the right answer", - "body_count": 1 + "source": "analytic", + "method": "every wall is 10 x 10 or more and the shell thin; the body is four 10 x 10 columns, two 20 tall (x<00 down): V = 6000. Its faces are all axis planes, so the cavity with every kept face moved 0.346 in and extended to meet (the open face's own plane bounding it) is the set of points more than 0.346 from the outside in the max norm, with a 0.346 slab laid over the open face; summed exactly over the grid of the body's coordinates and those +-0.346: cavity 5232.76615, material 767.23385. Rounding the cavity at the 59.654 mm of concave edges instead (the true offset; where the up and down parts meet only along an edge, at the origin) enlarges it by at most (1 - pi/4) 0.346^2 per mm, with 0.346^3 at each of the 8 edge ends: 1.86396, so material 765.36989 .. 767.23385. A shell that fails to open leaves 2 shells; the full solid is 6000", + "body_count": 1, + "volume_mm3": [ + 765.36, + 767.24 + ], + "bbox": { + "min": [ + -10, + -10, + -10 + ], + "max": [ + 10, + 10, + 10 + ] + } } From be8e728cdaef040fb7486067f56f082a45a81386 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:51:17 -0400 Subject: [PATCH 59/81] Kernel rig: 545 graded on its volume (the frame less its 0.5 mm-offset cavity, sharp to rounded concave edges), its sealed pillar void and box Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/kernel-cases/shell/545-shell-ring-cut-frame-open-at-an-outer-wall/expected.json b/tests/kernel-cases/shell/545-shell-ring-cut-frame-open-at-an-outer-wall/expected.json index dbbb7af82..54418cbd8 100644 --- a/tests/kernel-cases/shell/545-shell-ring-cut-frame-open-at-an-outer-wall/expected.json +++ b/tests/kernel-cases/shell/545-shell-ring-cut-frame-open-at-an-outer-wall/expected.json @@ -10,5 +10,17 @@ "volume_mm3": 21044.0, "tolerance": { "rel": 1e-06 + }, + "bbox": { + "min": [ + 0, + 0, + 0 + ], + "max": [ + 100, + 100, + 30 + ] } } From edb558bd12a621341a935aed5ecd289e3cde4c2e Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:53:01 -0400 Subject: [PATCH 60/81] Kernel rig: the shell-again case graded on its volume (the shelled box less the 0.5 mm-offset cavity in its walls) and box Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/tests/kernel-cases/shell/cov-shell-again-open-at-an-inner-wall-of-a-shelled-box/expected.json b/tests/kernel-cases/shell/cov-shell-again-open-at-an-inner-wall-of-a-shelled-box/expected.json index bb3fc4470..20f65be61 100644 --- a/tests/kernel-cases/shell/cov-shell-again-open-at-an-inner-wall-of-a-shelled-box/expected.json +++ b/tests/kernel-cases/shell/cov-shell-again-open-at-an-inner-wall-of-a-shelled-box/expected.json @@ -1,7 +1,23 @@ { "sources": [], "what": "a 70 x 50 x 30 box with R6 vertical rounds shelled 2 mm open on top, shelled again 0.5 mm open at an inner wall: its 2 mm walls hollowed (action matrix (apps/solidcraft-cli/tests/action_matrix.rs): typical/filleted-shelled-box, Body1/F4:inner:F2:side:l1 face.shell)", - "source": "invariants", - "method": "the 2 mm walls take a 0.5 shell (a 1 mm cavity inside them, open at the picked inner wall); the rounds' offsets are concentric, but the rim and the open faces' cavity ends are the offset's own: one closed valid solid is the right answer", - "body_count": 1 + "source": "analytic", + "method": "the 2 mm walls take a 0.5 shell (a 1 mm cavity inside them, open at the picked inner wall, the flat x -29..29 of y = -23). Rounded rectangle area L W - (4 - pi) r^2. First shell: 70 x 50 R6 x 30 less 66 x 46 r4 x 28 = 19449.4866. Second cavity, every kept face moved 0.5 in (the rounds' offsets concentric) and extended to meet: 69 x 49 r5.5 from z = 0.5 to 29.5 less 67 x 47 r4.5 above z = 1.5 (9610.6791), and where the inner wall is open the cavity reaches its plane, 58 x 0.5 x 28 (812): 10422.6791, material 9026.8074. Rounding the cavity at the 159.13 mm of concave floor edge (the true offset; r4 arcs counted at r4.5) enlarges it by at most (1 - pi/4) 0.25 per mm: 8.7061; the true offset's distance to the kept rounds where the open wall ends (two vertical tangent edges, 28 long) shrinks it by at most a quarter disc r0.5 each: 10.9956; 0.125 for each of the 4 ends. Material 9017.60 .. 9038.30. A shell that fails to open leaves 2 shells; the unchanged body is 19449.5", + "body_count": 1, + "volume_mm3": [ + 9017.6, + 9038.3 + ], + "bbox": { + "min": [ + -35, + -25, + 0 + ], + "max": [ + 35, + 25, + 30 + ] + } } From fd9d159f4a230f84953bd25d3fd75b405f60b9ec Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:54:16 -0400 Subject: [PATCH 61/81] Kernel rig: the arc-sided plate shell graded on its volume (sharp to rounded at the hole's bottom), faces and box Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/tests/kernel-cases/shell/cov-shell-plate-with-a-hole-through-its-arc-side/expected.json b/tests/kernel-cases/shell/cov-shell-plate-with-a-hole-through-its-arc-side/expected.json index 5658e29ad..0af0f7cd2 100644 --- a/tests/kernel-cases/shell/cov-shell-plate-with-a-hole-through-its-arc-side/expected.json +++ b/tests/kernel-cases/shell/cov-shell-plate-with-a-hole-through-its-arc-side/expected.json @@ -1,7 +1,27 @@ { "sources": [], "what": "a 42.5 x 20 x 27.5 plate closed by a half-round side (r10), a blind hole r5 drilled in through that side, shelled 2 mm open at the far end: the edge where the hole's wall meets the arc side is neither a line nor an arc", - "source": "invariants", - "method": "the hole's wall moved 2 out meets the arc side moved 2 in along a curve of two cylinders; whether the cavity's corner at the hole's bottom is sharp or rounded is the offset's choice, so no closed form: one closed valid solid is the right answer", - "body_count": 1 + "source": "analytic", + "method": "the hole's wall moved 2 out meets the arc side moved 2 in along a curve of two cylinders; every edge is convex but the hole's bottom circle, so only the cavity's corner there is the offset's choice, sharp or rounded. Body: profile 42.5 x 20 + pi 10^2 / 2 times 27.5, less the hole r5 inside it (x 0..7.5 and, for x < 0, out to the arc x = -sqrt(100 - (y-10)^2)): int 2 sqrt(25 - (y-12.5)^2) (7.5 + sqrt(100 - (y-10)^2)) dy = 1321.0770; V0 = 26373.6129. Sharp cavity: profile 42.5 x 16 + pi 8^2 / 2 (open at x = 42.5) from z = 2 to 25.5, less the hole's offset r7 up to x = 9.5 where it lies in it (y <= 18): int 2 sqrt(49 - (y-12.5)^2) (9.5 + sqrt(64 - (y-10)^2)) dy = 2369.0772 (the offset r7 is exact up to the hole's mouth: its foot on the r5 wall stays inside the arc); cavity 15973.4005, material 10400.2124. Rounding the cavity's corner at the hole's bottom (the true offset, a torus r2) enlarges it by at most 2 pi int r dA over r 5..7, x 7.5..9.5 less the quarter disc r2: 2 pi (24 - pi (5 + 8/(3 pi))) = 35.3452, so material 10364.8671 .. 10400.2124. Faces: outer 7 (arc, two flat sides, top, bottom, hole wall and bottom) less the open end, inner 7, the rim; 16 with the torus. A shell that fails to open leaves 2 shells; the full solid is 26373.6", + "body_count": 1, + "faces": [ + 15, + 16 + ], + "volume_mm3": [ + 10364.8, + 10400.3 + ], + "bbox": { + "min": [ + -10, + 0, + 0 + ], + "max": [ + 42.5, + 20, + 27.5 + ] + } } From f2aba03f8725413e141dd2482a280bf8fa4eef99 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:55:17 -0400 Subject: [PATCH 62/81] Kernel rig: 616 graded on its volume (the lid less its 0.5 mm-offset cavity, sharp to rounded concave edges) and box Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/tests/kernel-cases/shell/616-shell-open-a-rib-side-face-of-a-lid/expected.json b/tests/kernel-cases/shell/616-shell-open-a-rib-side-face-of-a-lid/expected.json index 37349c4f1..1869739bd 100644 --- a/tests/kernel-cases/shell/616-shell-open-a-rib-side-face-of-a-lid/expected.json +++ b/tests/kernel-cases/shell/616-shell-open-a-rib-side-face-of-a-lid/expected.json @@ -3,7 +3,23 @@ "tangency-labs/solidcraft#616" ], "what": "#616's lid (a 2.4 mm plate with R3 corners, a 3 mm skirt, three openings and four 1.6 mm ribs, all boxes) shelled 0.5 mm with a rib's outer side face open (action matrix (apps/solidcraft-cli/tests/action_matrix.rs): corpus/issue-616-lid-ribs, Lid/F8:-x face.shell)", - "source": "invariants", - "method": "every wall is at least 1.4 thick, so a 0.5 shell fits everywhere; the cavity's corners at the openings and the R3 rounds' offsets make the volume long but not unknown, and the case guards the build: one closed valid solid is the right answer", - "body_count": 1 + "source": "analytic", + "method": "every wall is at least 1.4 thick, so a 0.5 shell fits everywhere. The lid is boxes but for the plate's four R3 corners: as sharp boxes, plate 76.8 x 89.3 x 2.4 + skirt 71.5 x 84 x 3 less the openings (68 x 61 and 44 x 10 through, 22 x 2.65 x 3 in the skirt) + the ribs above the skirt (4 x 1.6 x 6 x 8.7): 9861.756, less the corners 4 (1 - pi/4) 9 x 2.4: V = 9843.2144. Cavity, every kept face moved 0.5 in and extended to meet (the open rib face's plane bounding it): for the boxes the points more than 0.5 from the outside in the max norm, with a 0.5 slab laid over the open face, summed exactly over the grid of the body's coordinates and those +-0.5: 5865.246 (one region, open at the rib), less the corners where the plate's margin cavity (z 0.5..1.9) follows the r2.5 offsets, 4 (1 - pi/4) 6.25 x 1.4: 5857.7349; material 3985.4795. Rounding the cavity at the 413.4 mm of concave edges instead (the true offset) enlarges it by at most (1 - pi/4) 0.25 per mm, with 0.125 at each of the 92 edge ends: 33.6791, so material 3951.8004 .. 3985.4795. A shell that fails to open leaves 2 shells; the full solid is 9843.2", + "body_count": 1, + "volume_mm3": [ + 3951.8, + 3985.5 + ], + "bbox": { + "min": [ + 100, + 0, + 0 + ], + "max": [ + 176.8, + 89.3, + 14.1 + ] + } } From 764719c5386ee01b94511310589d226e580a00f6 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:57:33 -0400 Subject: [PATCH 63/81] Kernel rig: 391 graded on its volume (the shelled housing, sharp to rounded at the flange, less the letters' 0.6 mm deboss) and box Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/tests/kernel-cases/shell/391-deboss-text-on-flange-of-filleted-shelled-body/expected.json b/tests/kernel-cases/shell/391-deboss-text-on-flange-of-filleted-shelled-body/expected.json index 31d705000..3d20394d7 100644 --- a/tests/kernel-cases/shell/391-deboss-text-on-flange-of-filleted-shelled-body/expected.json +++ b/tests/kernel-cases/shell/391-deboss-text-on-flange-of-filleted-shelled-body/expected.json @@ -3,7 +3,23 @@ "tangency-labs/solidcraft#391" ], "what": "text debossed 0.6 mm into the flat flange top of a filleted and shelled tapered housing, well away from the curved walls", - "source": "invariants", - "method": "the flange top (z=6) is planar and the text is clear of the walls, so the deboss must succeed and leave one valid closed body; the letter area is font dependent, so only the outcome and validity are graded", - "body_count": 1 + "source": "analytic", + "method": "the flange top (z=6) is planar and the text is clear of the walls and of the cavity below (z 2.5..3.5), so the deboss removes exactly 0.6 x the letters' area. Housing: flange 114 x 84 x 6 + the box drafted 2 deg (half-widths 45 - z k, 30 - z k, k = tan2) above it, z 6..35, less its r6 rounds as sloped prisms (section r^2 (tan(psi/2) - psi/2), psi = acos(sin^2 2), times height sqrt(1+2k^2)): 207002.5157. Shell 2.5 open at the top, every kept face moved 2.5 in and extended to meet: the flange's slab 109 x 79 x 1 (z 2.5..3.5) and the drafted box's offset (half-widths less 2.5/cos2, rounds r3.5) from z = 3.5 to 35: cavity 149670.2362, material 57332.2795. Rounding the cavity at the concave loop where the drafted walls meet the flange top (the true offset; under 298.32 mm, the walls 88 deg from the flange) enlarges it by at most 2.5^2 (tan44 - 44 deg) per mm: 368.6982. The letters, Liberation Sans' A and B at a 4 mm capital height (1409 units), are 598584.83 + 781544.83 units^2 (their quadratic outlines integrated exactly), 11.1229 mm^2: the deboss removes 6.6737. V = 56956.9075 .. 57325.6057", + "body_count": 1, + "volume_mm3": [ + 56956.9, + 57325.7 + ], + "bbox": { + "min": [ + -57, + -42, + 0 + ], + "max": [ + 57, + 42, + 35 + ] + } } \ No newline at end of file From 4b512f69e37a53252690d011884349a2060b5d14 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:58:46 -0400 Subject: [PATCH 64/81] Kernel rig: shell/3576 was the ladder's drafted box with rounds shelled, recipe for recipe; the ladder case grades it and carries #3576 and #3573 Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 10 --- .../recipe.json | 76 ------------------- 2 files changed, 86 deletions(-) delete mode 100644 tests/kernel-cases/shell/3576-shell-tapered-box-rounded-corners/expected.json delete mode 100644 tests/kernel-cases/shell/3576-shell-tapered-box-rounded-corners/recipe.json diff --git a/tests/kernel-cases/shell/3576-shell-tapered-box-rounded-corners/expected.json b/tests/kernel-cases/shell/3576-shell-tapered-box-rounded-corners/expected.json deleted file mode 100644 index 0fa7a1053..000000000 --- a/tests/kernel-cases/shell/3576-shell-tapered-box-rounded-corners/expected.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "sources": [ - "tangency-labs/solidcraft#3576", - "tangency-labs/solidcraft#3573" - ], - "what": "a 120x80x40 box drafted 5 degrees with 4 mm rounds on the sloping corners, shelled 2 mm open at the top: the inner rounds' edges must lie on their faces (#3573 reports the same design)", - "source": "invariants", - "method": "no closed-form volume (tilted rounds). Invariants: the shell succeeds, one closed body, and the record's geometry check holds (every edge of the four inner rounds lies on its faces; the old offset left them up to 0.02 mm off, which other STEP readers reject)", - "body_count": 1 -} \ No newline at end of file diff --git a/tests/kernel-cases/shell/3576-shell-tapered-box-rounded-corners/recipe.json b/tests/kernel-cases/shell/3576-shell-tapered-box-rounded-corners/recipe.json deleted file mode 100644 index e6ad11c23..000000000 --- a/tests/kernel-cases/shell/3576-shell-tapered-box-rounded-corners/recipe.json +++ /dev/null @@ -1,76 +0,0 @@ -{ - "commands": [ - { - "command": "sketch.create", - "params": { - "plane": "XY" - } - }, - { - "command": "sketch.rectangle.center", - "params": { - "center": [ - 0, - 0 - ], - "corner": [ - 60, - 40 - ] - } - }, - { - "command": "sketch.finish", - "params": {} - }, - { - "command": "solid.extrude", - "params": { - "distance": 40, - "taper": "-5 deg", - "operation": "new" - } - }, - { - "command": "solid.fillet", - "params": { - "edges": [ - [ - 58.25022672948152, - 38.25022672948152, - 20 - ], - [ - 58.25022672948152, - -38.25022672948152, - 20 - ], - [ - -58.25022672948152, - 38.25022672948152, - 20 - ], - [ - -58.25022672948152, - -38.25022672948152, - 20 - ] - ], - "radius": 4 - } - }, - { - "command": "solid.shell", - "params": { - "faces": [ - [ - 0, - 0, - 40 - ] - ], - "thickness": 2 - } - } - ] -} \ No newline at end of file From 63dd6ae6f54e7b9c4b2df4d7dc10404920ecec44 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:55:24 -0400 Subject: [PATCH 65/81] Kernel rig: the two 851 chamfers of 2 graded on their volume (the cone's sweep, and its union with the front edge's prism) Co-Authored-By: Claude Opus 5.5 --- .../fillets/851-chamfer-arc-and-top-front-2/expected.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/kernel-cases/fillets/851-chamfer-arc-and-top-front-2/expected.json b/tests/kernel-cases/fillets/851-chamfer-arc-and-top-front-2/expected.json index 50248e990..9a037c193 100644 --- a/tests/kernel-cases/fillets/851-chamfer-arc-and-top-front-2/expected.json +++ b/tests/kernel-cases/fillets/851-chamfer-arc-and-top-front-2/expected.json @@ -4,8 +4,9 @@ "tangency-labs/solidcraft#854" ], "what": "on #851's knife-edge part (tessellation/1263): the arc's top edge and the top front edge together chamfered 2", - "source": "invariants", - "method": "a 2 mm chamfer fits on these edges (the arc's chamfer is a cone cut by the back face where the arc runs into it); one closed valid solid whose display mesh closes is the right answer", + "source": "analytic", + "method": "plate x 0..41.1667, y -21..0 and the corner x 41.1667..62.1667 less the cylinder r 21 about (62.1667, -21), 10 high (tessellation/1263): V0 = 10 (62.1667 x 21 - pi 21^2/4) = 9591.394099. The arc's chamfer: its section in (rho, z) about the wall's axis, the triangle (rho - 21) + (10 - z) <= 2, swept round it from the front face (through the axis, square to the arc) to the back face y = 0, which the arc runs into tangent at the tip: at radius rho the part spans the angle asin(21/rho), so it takes Int_21^23 rho asin(21/rho) (2 - (rho - 21)) drho = 58.061950 (Simpson; the same derivation as 851-chamfer-arc-top-edge-9-5 at distance 2). The top front edge (y = -21, z = 10, x 0..41.1667) chamfered 2 takes 2^2/2 x 41.1667 = 82.333333. The two chamfers meet at the corner (41.1667, -21, 10), where the top, the front face and the arc's wall are square to each other, so together they take the union of the two: their common part in the plate (u = z - 8 in 0..2, 0 <= y + 21 <= u, x <= 41.1667, rho <= 21 + u) is Int_0^2 Int_0^u (sqrt((21 + u)^2 - Y^2) - 21) dY du = 2.637139, and the front chamfer's sliver past x = 41.1667 lies inside the arc's chamfer already (there rho <= sqrt(21^2 + Y^2) <= 21 + u). V = 9591.394099 - 58.061950 - 82.333333 + 2.637139 = 9453.635955; one closed valid solid whose display mesh closes", "body_count": 1, + "volume_mm3": 9453.6359553261, "watertight": true } From 49c7b982ef7ee5064259a789c54742a57ffd9a20 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:56:11 -0400 Subject: [PATCH 66/81] Kernel rig: the chamfered corner of the lipped shell graded on its volume (the chamfer's triangle through the wall) Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/kernel-cases/fillets/cov-chamfer-outer-corner-edge-of-a-shelled-box-with-a-lip/expected.json b/tests/kernel-cases/fillets/cov-chamfer-outer-corner-edge-of-a-shelled-box-with-a-lip/expected.json index 17ca65bdc..c41cd8687 100644 --- a/tests/kernel-cases/fillets/cov-chamfer-outer-corner-edge-of-a-shelled-box-with-a-lip/expected.json +++ b/tests/kernel-cases/fillets/cov-chamfer-outer-corner-edge-of-a-shelled-box-with-a-lip/expected.json @@ -1,7 +1,8 @@ { "sources": [], "what": "a vertical outer corner edge of an 80 x 50 x 30 box shelled 2 mm open at the top with a 1 x 2 lip raised on its rim, chamfered 3: wider than the wall but clear of the inside corner, its top end on the lip (action matrix (apps/solidcraft-cli/tests/action_matrix.rs): corpus/modern-plastic, Body1 F1:+y|F1:-x edge.chamfer)", - "source": "invariants", - "method": "the chamfer's plane x + (50 - y) = 3 stays clear of the inside corner (2, 48), where x + 50 - y = 4, so it fits along the whole edge; where it ends on the lip's walls is the lip's geometry: one closed valid solid is the right answer", - "body_count": 1 + "source": "analytic", + "method": "shelled: 80*50*30 - 76*46*28 = 22112; the lip is the band along the rim's inner edge (76 x 46 to 78 x 48), raised 2: 496 (as cov-lip-inside-on-a-shelled-box): V0 = 22608. The chamfer's plane x + (50 - y) = 3 stays clear of the inside corner (2, 48), where x + 50 - y = 4, so its triangle (legs 3, area 4.5) lies in the wall and floor all the way up: it takes 4.5 x 30 = 135. At the top the triangle reaches under the lip's corner, whose part x + 50 - y < 3 (the half square (1, 48), (1, 49), (2, 49), 0.5 x 2 = 1) goes or stays by where the chamfer ends on the lip's walls: V = 22473 or 22472, graded as 22472.5 (both within 1e-3)", + "body_count": 1, + "volume_mm3": 22472.5 } From 0bcc24ccd16bb14ace1cbdb598f7105a4636906c Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:56:11 -0400 Subject: [PATCH 67/81] Kernel rig: the concave round into the peg's cylinder graded on a volume range (the torus it must add, the band it can't leave) Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/kernel-cases/fillets/report-fillet-edge-tangent-at-one-end-into-cylinder/expected.json b/tests/kernel-cases/fillets/report-fillet-edge-tangent-at-one-end-into-cylinder/expected.json index 116bf9774..51ebf0ee4 100644 --- a/tests/kernel-cases/fillets/report-fillet-edge-tangent-at-one-end-into-cylinder/expected.json +++ b/tests/kernel-cases/fillets/report-fillet-edge-tangent-at-one-end-into-cylinder/expected.json @@ -1,6 +1,10 @@ { "what": "after the round of a bar's top edge running into a cylinder, an r2 round of the edge where that round meets the cylinder's wall (tangent at its lower end only, a crease elsewhere) with its tangent chain (the concave arc of the top): it was refused as a smooth edge; reported from the app (2026-10-30, test-peg part)", - "source": "invariants", - "method": "a bar 40 x 16 x 10 whose far end is a half disc R8 about (40, 8), a disc R8 about the same centre sketched on its top (the top's outline projected) and extruded 10 up, joined: the bar's sides run tangent into the cylinder, V0 = 6400 + 960 pi; then the front round (the r2 round of the front top edge (y = 0, z = 10) runs into the cylinder's wall: removed = integral over y in [0, 2] of (2 - sqrt(4 - (2 - y)^2)) (40 - sqrt(64 - (8 - y)^2)) dy = 32.3064821881 (Simpson)); the second round fades to nothing at the edge's tangent end, no closed form: one valid body", - "body_count": 1 + "source": "analytic", + "method": "a bar 40 x 16 x 10 whose far end is a half disc R8 about (40, 8), a disc R8 about the same centre sketched on its top (the top's outline projected) and extruded 10 up, joined: the bar's sides run tangent into the cylinder, V0 = 6400 + 960 pi; then the front round (the r2 round of the front top edge (y = 0, z = 10) runs into the cylinder's wall: removed = integral over y in [0, 2] of (2 - sqrt(4 - (2 - y)^2)) (40 - sqrt(64 - (8 - y)^2)) dy = 32.3064821881 (Simpson)): V1 = 9383.622465. The second round is on concave edges (the round and the top meet the cylinder's wall from outside it), so it adds material, and its chain stops where the back top edge, convex, runs on tangent at (40, 16, 10). Lower end: about the cylinder's axis at angles a (from +x) in 126.87..216.87 deg the top runs on flat for 2 or more past the wall (8 + 10 sin a stays in 2..16), so there the round is the rolling ball's torus and adds its whole section, the corner r 8..10, z 10..12 less the quarter disc about (10, 12): Pappus, Int r dA = 8 (4 - pi) + (4 - 2 pi + 8/3) = 7.250740 a radian, over pi/2: 11.389. Upper end: what it adds lies outside V1, within 2 of the chain (on r = 8, angles 90..270 deg, z 8..10): r 8..10, angles within asin(1/4) = 14.48 deg of the chain's, z 6..12; that is z 10..12 over 75.52..284.48 deg (36 a radian: 131.29), and below z = 10 only in front of the bar or over the front round (214.11..284.48 deg, z 6..10, 72 a radian: 88.42) or behind its back face (75.52..104.48 deg, z 8..10: 18.19): 237.9. V in V1 + [11.389, 237.9]; one valid body", + "body_count": 1, + "volume_mm3": [ + 9395.0, + 9622.0 + ] } From 27b7e202a8904c9854f1d3a604ceb2cb58b1e80f Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:56:34 -0400 Subject: [PATCH 68/81] Kernel rig: the two folded 72 degree trays graded on their volume (flat area x thickness) and the walls' reach Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 19 ++++++++++++++++--- .../expected.json | 19 ++++++++++++++++--- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/tests/kernel-cases/sheet-metal/1797-tray-with-torn-corners-at-72-degrees-folded/expected.json b/tests/kernel-cases/sheet-metal/1797-tray-with-torn-corners-at-72-degrees-folded/expected.json index 88118ca75..3abd59d8f 100644 --- a/tests/kernel-cases/sheet-metal/1797-tray-with-torn-corners-at-72-degrees-folded/expected.json +++ b/tests/kernel-cases/sheet-metal/1797-tray-with-torn-corners-at-72-degrees-folded/expected.json @@ -4,7 +4,20 @@ "tangency-labs/solidcraft#1799" ], "what": "a tray whose flanges lean at 72 degrees with the tear corner relief: the torn ends are helices over slanted bends", - "source": "invariants", - "method": "one valid closed body (the helical torn ends must sew into a closed shell)", - "body_count": 1 + "source": "analytic", + "method": "T = 2, R = 1, K = 0.5, gap 0.5. A 72 deg flange leans out 18 deg, its outer face from the virtual sharp on the base's edge line (z = 0): it stands back s = (R+T) tan 36 = 2.179628, its bend has the allowance BA = 0.4 pi (R + T/2) = 2.513274 and its panel the leg 38.6 - s = 36.420372. With K = 0.5 every bend is bent about mid-thickness, so the folded volume is the flat area times T. The base is (120 - 2s) x (90 - 2s); the bends run along its edges to its corners, BA wide. Each corner is closed on the vertical plane halving it (x = y at the origin's): a panel's end is square to the sheet and keeps half the gap from that plane on its nearer, inner face, so at sigma along the panel it lies u(sigma) = g/sqrt2 + T sin72 - (s + sigma) cos72 from the sketch's corner along the edge (1.582124 at the bend, -9.672390 at the top): each panel is a trapezoid of mean length L - 2 u(leg/2) = L + 8.090265. The tear cuts nothing out of the base either and keeps the bends running to the corner where their start lines meet, cutting each bend's end straight in the flat from there to where its panel's closed end starts, s - u(0) = 0.597503 past the trimmed base's corner: each of the 8 bend ends gains a triangle BA x 0.597503 / 2 (folded, a helical end of the same volume at K = 0.5). Flat area 27390.468926 + 6.006757, V = 54792.951364 (the tear adds 12 mm3 to the notch's 405-tray-with-72-degree-flanges-folded, under the volume's tolerance: what tells them apart is validity). Bbox: the walls' outer top edges stand 38.6 cos72 = 11.928056 outside the base's edge lines, their inner top edges 38.6 sin72 + 2 cos72 = 37.328816 above the underside.", + "body_count": 1, + "volume_mm3": 54792.95136427714, + "bbox": { + "min": [ + -11.928055982872973, + -11.928055982872973, + 0 + ], + "max": [ + 131.92805598287296, + 101.92805598287298, + 37.32881551774282 + ] + } } \ No newline at end of file diff --git a/tests/kernel-cases/sheet-metal/405-tray-with-72-degree-flanges-folded/expected.json b/tests/kernel-cases/sheet-metal/405-tray-with-72-degree-flanges-folded/expected.json index 48b917e25..0c4239c6b 100644 --- a/tests/kernel-cases/sheet-metal/405-tray-with-72-degree-flanges-folded/expected.json +++ b/tests/kernel-cases/sheet-metal/405-tray-with-72-degree-flanges-folded/expected.json @@ -4,7 +4,20 @@ "tangency-labs/solidcraft#406" ], "what": "a 120 x 90 tray with four 38.6 mm flanges at 72 degrees closed with the rule's gap: the corners used to stay open as a V", - "source": "invariants", - "method": "one valid closed body: the four flanges end a gap apart at every corner, so they are joined to the base only and the part is one shell", - "body_count": 1 + "source": "analytic", + "method": "T = 2, R = 1, K = 0.5, gap 0.5. A 72 deg flange leans out 18 deg, its outer face from the virtual sharp on the base's edge line (z = 0): it stands back s = (R+T) tan 36 = 2.179628, its bend has the allowance BA = 0.4 pi (R + T/2) = 2.513274 and its panel the leg 38.6 - s = 36.420372. With K = 0.5 every bend is bent about mid-thickness, so the folded volume is the flat area times T. The base is (120 - 2s) x (90 - 2s); the bends run along its edges to its corners, BA wide. Each corner is closed on the vertical plane halving it (x = y at the origin's): a panel's end is square to the sheet and keeps half the gap from that plane on its nearer, inner face, so at sigma along the panel it lies u(sigma) = g/sqrt2 + T sin72 - (s + sigma) cos72 from the sketch's corner along the edge (1.582124 at the bend, -9.672390 at the top): each panel is a trapezoid of mean length L - 2 u(leg/2) = L + 8.090265. The notch cuts nothing. Flat area 27390.468926, V = 54780.937851. Bbox: the walls' outer top edges stand 38.6 cos72 = 11.928056 outside the base's edge lines, their inner top edges 38.6 sin72 + 2 cos72 = 37.328816 above the underside.", + "body_count": 1, + "volume_mm3": 54780.93785112385, + "bbox": { + "min": [ + -11.928055982872973, + -11.928055982872973, + 0 + ], + "max": [ + 131.92805598287296, + 101.92805598287298, + 37.32881551774282 + ] + } } \ No newline at end of file From 9b4162a3348fb368e87f951e8495864700573e99 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:57:03 -0400 Subject: [PATCH 69/81] Kernel rig: the flanged rhombus graded on its volume (flat area x thickness, all four reliefs cut) and its walls' ends Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tests/kernel-cases/sheet-metal/3417-rhombus-with-a-flange-on-each-edge-and-square-reliefs/expected.json b/tests/kernel-cases/sheet-metal/3417-rhombus-with-a-flange-on-each-edge-and-square-reliefs/expected.json index 297dbd5a5..4be282916 100644 --- a/tests/kernel-cases/sheet-metal/3417-rhombus-with-a-flange-on-each-edge-and-square-reliefs/expected.json +++ b/tests/kernel-cases/sheet-metal/3417-rhombus-with-a-flange-on-each-edge-and-square-reliefs/expected.json @@ -5,7 +5,20 @@ "tangency-labs/solidcraft#3280" ], "what": "a 60 mm rhombus (120 and 60 degree corners) with a 90 degree flange on each of its four edges and a square corner relief 8 mm across: the reliefs at the two 120 degree corners would overlap", - "source": "invariants", - "method": "one valid closed body whichever relief is left out; a square relief 8 mm across at a 120 degree corner reaches 2r from the corner along the bisector, so the reliefs at the two opposite 120 degree corners reach each other and are left out together, which makes the result independent of the order the flanges were made in; no volume is graded because the corner closure has no simple closed form", - "body_count": 1 + "source": "analytic", + "method": "T = 2, R = 1, K = 0.5, gap 0.5, square relief 8 across (r = 4). The 90 deg flanges stand back R + T = 3: the base is the rhombus inset 3, side 53.071797, height 45.961524, area 2439.260673. A square relief cuts r along both edges from the trimmed base's corner, square to them: a kite of area r^2 tan(alpha/2), 9.237604 at 60 and 27.712813 at 120 deg, reaching r/cos(alpha/2) = 4.618802 and 8 along the bisector. Here every corner keeps its relief: the two 120 deg corners are the trimmed short diagonal, 53.071797, apart, so their kites are far from meeting (they would meet with the corners under 16 mm apart), every edge is longer than 2r and every other edge further than 8 from a corner. The bends stop at the reliefs: 4 x (53.071797 - 8) long, BA = (pi/2)(R + T/2) = pi wide. Each panel (leg 20 - 3 = 17, its outer face on the rhombus' edge, its inner face 2 in) is closed with its end square to it, half the gap from the corner's bisector on its inner face: (g/2 + T cos(alpha/2)) / sin(alpha/2) from the rhombus' corner along the edge, 3.964102 at 60 and 1.443376 at 120 deg, so each panel is 54.592523 long. Flat area 6644.040285; K = 0.5, so V = T x flat = 13288.080571. Bbox: the walls stand 20 high on the rhombus' edges (y 0 and 51.961524), and the panel ends at the 60 deg corners keep them 3.964102 x cos 60 = 1.982051 from x = 0 and x = 90 (the bends, stopped 4 past the trimmed corners, reach no nearer)", + "body_count": 1, + "volume_mm3": 13288.08057084238, + "bbox": { + "min": [ + 1.9820508075688776, + 0, + 0 + ], + "max": [ + 88.01794919243112, + 51.96152422706631, + 20 + ] + } } \ No newline at end of file From f6847c97c94e98e09bc0f0da770580cd1fd67f0f Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:57:13 -0400 Subject: [PATCH 70/81] Kernel rig: the base with two adjacent flanges and a hole graded on its volume (base, bends and panels folded) Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/kernel-cases/sheet-metal/296-hole-in-a-base-with-two-adjacent-edge-flanges/expected.json b/tests/kernel-cases/sheet-metal/296-hole-in-a-base-with-two-adjacent-edge-flanges/expected.json index 7b3b863b0..0967020c0 100644 --- a/tests/kernel-cases/sheet-metal/296-hole-in-a-base-with-two-adjacent-edge-flanges/expected.json +++ b/tests/kernel-cases/sheet-metal/296-hole-in-a-base-with-two-adjacent-edge-flanges/expected.json @@ -4,7 +4,8 @@ "tangency-labs/solidcraft#355" ], "what": "an 80 x 40 base with a 30 mm flange on the y = 0 edge and a 15 mm flange on the x = 80 edge, and a round hole through the base beside them: sew failed with a non-manifold edge contact", - "source": "invariants", - "method": "the hole is cut straight through the flat base, clear of both bends and of the corner, so it must give one valid closed body; the corner geometry of two adjacent flanges has no simple closed form, so no volume is graded", - "body_count": 1 + "source": "analytic", + "method": "T = 2, R = 2, 90 deg flanges, setback R + T = 4 (K = 0.4 moves only the flat pattern, not the folded part). The earlier flange keeps its length and the later one ends at its bend, and the later one trims the base under the first bend (the convention oracle 75-sm-bracket-holes is graded on): base x 0..76, y 4..40 (5472); bend 1, a quarter annulus of radii 2..4 (3 pi a mm), x 0..76 (228 pi); flange 1's panel y 0..2, z 4..30, x 0..80 (4160); bend 2 y 4..40 (108 pi); flange 2's panel x 78..80, z 4..15, y 4..40 (792); the hole r 3 at (25, 20) straight through the base, clear of both bends and the corner, takes 18 pi. V = 10424 + 318 pi = 11423.026464", + "body_count": 1, + "volume_mm3": 11423.026463841552 } \ No newline at end of file From bfdb79418cd5696a6cf6ab521527995be23c98ee Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:57:13 -0400 Subject: [PATCH 71/81] Kernel rig: the flange beside the ledge graded on a volume range (the flange's two readings of its length) Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/kernel-cases/sheet-metal/978-edge-flange-beside-a-ledge-as-tall-as-its-setback/expected.json b/tests/kernel-cases/sheet-metal/978-edge-flange-beside-a-ledge-as-tall-as-its-setback/expected.json index b6d90092f..5f1042e20 100644 --- a/tests/kernel-cases/sheet-metal/978-edge-flange-beside-a-ledge-as-tall-as-its-setback/expected.json +++ b/tests/kernel-cases/sheet-metal/978-edge-flange-beside-a-ledge-as-tall-as-its-setback/expected.json @@ -3,7 +3,11 @@ "tangency-labs/solidcraft#978" ], "what": "a 90 degree inside flange of radius 1 on an edge that has a ledge beside it exactly as tall as the flange's setback (3 mm): sew failed with a degenerate edge", - "source": "invariants", - "method": "T = 2, flange R = 1: setback R + T = 3 and the ledge (x 97..100, y 0..3) is exactly that tall, so the trim line runs along the ledge's top; the right answer is one valid closed body (the ledge goes with the setback strip), with no graded volume because the flange's extent along the ledge has no single reading", - "body_count": 1 + "source": "analytic", + "method": "T = 2, flange R = 1, inside: the setback R + T = 3 strips y 0..3 off the base, and the ledge (x 97..100, y 0..3) lies wholly in that strip, so the base left is x 0..97, y 3..60 (11058). The bend (a quarter annulus of radii 1..3, 2 pi a mm) and the panel (leg 20 - 3 = 17, 34 a mm) run along the edge either as far as the base's remaining edge (97) or the picked edge (100), the reading the case leaves open: V lies between 11058 + 97 (2 pi + 34) = 14965.468975 and 11058 + 100 (2 pi + 34) = 15086.318531; a flange missing, or the base left untrimmed by the setback, falls outside", + "body_count": 1, + "volume_mm3": [ + 14965.468, + 15086.319 + ] } \ No newline at end of file From 130f2adaf76922c18a44267b7a17808a82622014 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:57:39 -0400 Subject: [PATCH 72/81] Kernel rig: the two G0 window patches graded on the box the part they close keeps Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 18 +++++++++++++++--- .../expected.json | 18 +++++++++++++++--- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/tests/kernel-cases/surfaces/cov-patch-g0-fills-a-240-deg-window-in-a-cylinder/expected.json b/tests/kernel-cases/surfaces/cov-patch-g0-fills-a-240-deg-window-in-a-cylinder/expected.json index 017bac7a0..d76f3ce08 100644 --- a/tests/kernel-cases/surfaces/cov-patch-g0-fills-a-240-deg-window-in-a-cylinder/expected.json +++ b/tests/kernel-cases/surfaces/cov-patch-g0-fills-a-240-deg-window-in-a-cylinder/expected.json @@ -3,7 +3,19 @@ "tangency-labs/solidcraft#759" ], "what": "a window 240 deg round a cylinder's wall (r10 x 40, z 15..25), the faces the cut made taken off and the window patched g0 and stitched", - "source": "invariants", - "method": "the window (as the g1 case) filled G0: the fill meets the window's edges; its shape is the fill's own, so one closed valid solid is the right answer", - "body_count": 1 + "source": "analytic", + "method": "the box x -5..11, y -11..11, z 15..25 cuts the wall where 10 cos a >= -5 (|a| <= 120 deg), as in the g1 case; filled G0, the fill meets the window's edges and its shape is its own, so no volume is graded. The wall left below z 15, above z 25 and round a = 180 deg reaches x = +-10, y = +-10 and z 0..40, and a fill of a rim lying on the cylinder stays inside that box: bbox -10..10, -10..10, 0..40", + "body_count": 1, + "bbox": { + "min": [ + -10, + -10, + 0 + ], + "max": [ + 10, + 10, + 40 + ] + } } diff --git a/tests/kernel-cases/surfaces/cov-patch-g0-fills-a-saddle-window-in-a-torus/expected.json b/tests/kernel-cases/surfaces/cov-patch-g0-fills-a-saddle-window-in-a-torus/expected.json index 7fafe45a8..cc7524461 100644 --- a/tests/kernel-cases/surfaces/cov-patch-g0-fills-a-saddle-window-in-a-torus/expected.json +++ b/tests/kernel-cases/surfaces/cov-patch-g0-fills-a-saddle-window-in-a-torus/expected.json @@ -3,7 +3,19 @@ "tangency-labs/solidcraft#759" ], "what": "a window 240 deg round the saddle-shaped inner wall of a torus (R20, r8) between z = -3 and 3, its cut faces taken off, patched g0 and stitched", - "source": "invariants", - "method": "the box x -6..13, y -13..13, z -3..3 opens the inner wall where 12 cos a >= -6 (|a| <= 120 deg): its rim is two arcs on z = +-3 each way and two curves on x = -6, and it bounds no height field. G0: the fill meets the rim. The fill's shape is its own: one closed valid solid is the right answer.", - "body_count": 1 + "source": "analytic", + "method": "the box x -6..13, y -13..13, z -3..3 opens the inner wall where 12 cos a >= -6 (|a| <= 120 deg): its rim is two arcs on z = +-3 each way and two curves on x = -6, and it bounds no height field. G0: the fill meets the rim. The fill's shape is its own, so no volume is graded. The box opens only the inner wall, so the torus keeps its outer equator (r 28, x and y to +-28) and its top and bottom circles (r 20, z +-8), and the fill of a rim on the inner wall stays inside that box: bbox -28..28, -28..28, -8..8.", + "body_count": 1, + "bbox": { + "min": [ + -28, + -28, + -8 + ], + "max": [ + 28, + 28, + 8 + ] + } } From 8e0f6403c394b2e7a48f04b22aa13ba639f48d62 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:57:47 -0400 Subject: [PATCH 73/81] Kernel rig: the hub's six swept grooves graded on its volume (the revolved hub less each tube's part inside it) Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/kernel-cases/sweeps/4280-circular-pattern-of-sweep-cut-groove-on-hub/expected.json b/tests/kernel-cases/sweeps/4280-circular-pattern-of-sweep-cut-groove-on-hub/expected.json index b65c54305..c429109a9 100644 --- a/tests/kernel-cases/sweeps/4280-circular-pattern-of-sweep-cut-groove-on-hub/expected.json +++ b/tests/kernel-cases/sweeps/4280-circular-pattern-of-sweep-cut-groove-on-hub/expected.json @@ -3,7 +3,8 @@ "tangency-labs/solidcraft#4280" ], "what": "a round groove (r2) swept as a cut along the curved profile of a revolved hub, then circular-patterned 6 times about the hub's axis: 'boolean Cut: no result' in the pattern", - "source": "invariants", - "method": "the six grooves run down the hub's curved face 60 deg apart and don't meet, so the hub stays one valid closed body. The groove follows the surface (its centre on it), which has no closed-form removed volume", - "body_count": 1 + "source": "analytic", + "method": "the hub: the profile x 0..30 at z 0, up x = 30 to z 5, the arc through (30, 5), (18, 11), (10, 20) (centre (38.75, 37.5), R 33.657280, the side away from it, x(z) = 38.75 - sqrt(R^2 - (z - 37.5)^2)), then z = 20 to the axis, revolved about z: V_hub = pi (30^2 x 5 + Int_5^20 x(z)^2 dz) = 29625.699466. Each groove takes the r2 tube about that arc (length 25.613619, flat ends square to it at both ends, its centre on the hub's surface) where it lies in the hub: Int_0^L ds Int_0^2 rho drho Int (1 - rho cos psi / R) [in the hub] dpsi, psi from the arc's normal toward its centre, integrated numerically from that exact geometry (Gauss-Legendre in s and rho, each inside run of psi to its crossings): 162.452357, steady to 3e-6 relative when the grid is doubled (half the tube is 160.935; the turn round the hub's axis and the end wedges move it). The six grooves, 60 deg apart at x >= 8, don't meet: V = V_hub - 6 x 162.452357 = 28650.985325; one valid closed body", + "body_count": 1, + "volume_mm3": 28650.98532494651 } From 889a2f866c29a71398195ae0938b2278510aa072 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:57:47 -0400 Subject: [PATCH 74/81] Kernel rig: the cut mirrored loft graded on the box its sections pin Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/kernel-cases/sweeps/4683-cut-mirrored-loft-with-tilted-last-section/expected.json b/tests/kernel-cases/sweeps/4683-cut-mirrored-loft-with-tilted-last-section/expected.json index 78f08b94b..5a271cb18 100644 --- a/tests/kernel-cases/sweeps/4683-cut-mirrored-loft-with-tilted-last-section/expected.json +++ b/tests/kernel-cases/sweeps/4683-cut-mirrored-loft-with-tilted-last-section/expected.json @@ -3,7 +3,19 @@ "tangency-labs/solidcraft#4683" ], "what": "a box cut from a 6-section loft (spline crown and a flat bottom at z = -1) whose last section lies on a plane tilted 2 deg off its neighbours', mirrored into one body; the box crosses the tilted end and reaches below the bottom face: truck's result shell was missing a face ('no result')", - "source": "invariants", - "method": "the mirrored loft is one solid symmetric about YZ, x -149..149; the box (x 91..240, y 90..210, z -2..118) cuts through its tilted end and out of its flat bottom, so the cut leaves one valid closed body. The loft's free-form volume is not closed-form. Synthetic sections of the report's shape (a crowned spline over a flat base, narrowing along x), not its numbers", - "body_count": 1 + "source": "analytic", + "method": "the mirrored loft is one solid symmetric about YZ; the box (x 91..240, y 90..210, z -2..118) cuts through its tilted end and out of its flat bottom, so the cut leaves one valid closed body. The loft's free-form volume is not closed-form, but its sections pin its box: x to the tilted last section's bottom corners, 149 + 0.034899 = 149.034899 (mirrored, -149.034899), y +-303 and z -1 at the first section's bottom corners (x = 0), z 92 at its crown; the sections' corners (y = 303 - 0.6 x) and crowns (z = 92 - 0.35 x) fall linearly with x through all of them, so the loft between them reaches no further, and the box (x >= 91, y 90..210) takes none of these points. Synthetic sections of the report's shape (a crowned spline over a flat base, narrowing along x), not its numbers", + "body_count": 1, + "bbox": { + "min": [ + -149.034899, + -303, + -1 + ], + "max": [ + 149.034899, + 303, + 92 + ] + } } From 37a4c564777903676905783085142192a095d585 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:58:23 -0400 Subject: [PATCH 75/81] Kernel rig: the three modelled-thread joins and the fine M48 graded on their volume (the basic profile's groove, Pappus) Co-Authored-By: Claude Opus 5.5 --- .../4191-box-joined-over-modelled-thread/expected.json | 8 ++++++-- .../4726-fine-pitch-m48x0.75-thread-25-mm/expected.json | 8 ++++++-- .../expected.json | 8 ++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/tests/kernel-cases/threads/4191-box-joined-over-modelled-thread/expected.json b/tests/kernel-cases/threads/4191-box-joined-over-modelled-thread/expected.json index 93b186f38..d8ef80cae 100644 --- a/tests/kernel-cases/threads/4191-box-joined-over-modelled-thread/expected.json +++ b/tests/kernel-cases/threads/4191-box-joined-over-modelled-thread/expected.json @@ -3,8 +3,12 @@ "tangency-labs/solidcraft#4191" ], "what": "a 20x20x10 block joined round the bottom of an O6 x 50 stud carrying a modelled M6 thread: 'boolean Union: no result' (the same block joined before threading worked)", - "source": "invariants", - "method": "the block encloses the stud's bottom 10 mm, thread and all, so the join is one connected solid: one valid closed body. The modelled thread's volume is not closed-form", + "source": "analytic", + "method": "ISO 68-1 basic profile: H = P sqrt3/2, basic depth 5H/8. External groove (the space between teeth): a trapezoid P/4 wide at the root radius d/2 - 5H/8, widening by 2 tan30 per unit of radius to 7P/8 at d/2. Pappus: volume per turn = 2 pi A rc (A the trapezoid area, rc its centroid radius from the axis); a helical sweep of L/P turns removes exactly (L/P) x that, where each end of the thread is a free end or lies inside material. Stud R = 3, L = 50, M6 (P = 1) over its whole length (its top end free). The block x, y -10..10, z 0..10 encloses the stud's bottom 10 mm, groove and all, so it fills that part: V = 20 x 20 x 10 + pi 3^2 40 - 40 x 5.317130 = 4918.2882 mm3 (the groove's part above z = 10 is 40 turns' worth: its section across any z is the same, the bottom end lying inside the block). Tolerance 1%: a modelled thread is a faceted helical solid (radial chord error up to 1% of the pitch on every wall, i.e. a volume deficit of about 4/3 x sag/R).", "body_count": 1, + "volume_mm3": 4918.2882, + "tolerance": { + "rel": 0.01 + }, "timeout_s": 600 } diff --git a/tests/kernel-cases/threads/4726-fine-pitch-m48x0.75-thread-25-mm/expected.json b/tests/kernel-cases/threads/4726-fine-pitch-m48x0.75-thread-25-mm/expected.json index ac10c9421..195aa2f11 100644 --- a/tests/kernel-cases/threads/4726-fine-pitch-m48x0.75-thread-25-mm/expected.json +++ b/tests/kernel-cases/threads/4726-fine-pitch-m48x0.75-thread-25-mm/expected.json @@ -3,8 +3,12 @@ "tangency-labs/solidcraft#4726" ], "what": "a modelled M48x0.75 thread over the whole 25 mm of a O48 bolt (33 turns): the browser build froze; coarse pitches and 4 mm of it worked, slowly", - "source": "invariants", - "method": "a modelled external thread on its own nominal shaft: one valid closed body within the case's timeout (slow by nature: 600 s); the helical faces have no closed-form volume", + "source": "analytic", + "method": "ISO 68-1 basic profile: H = P sqrt3/2, basic depth 5H/8. External groove (the space between teeth): a trapezoid P/4 wide at the root radius d/2 - 5H/8, widening by 2 tan30 per unit of radius to 7P/8 at d/2. Pappus: volume per turn = 2 pi A rc (A the trapezoid area, rc its centroid radius from the axis); a helical sweep of L/P turns removes exactly (L/P) x that, where each end of the thread is a free end or lies inside material. Bolt R = 24, L = 25, M48x0.75 (P = 0.75) over its whole length, both ends free: V = pi 24^2 25 - (25/0.75) x 25.647420 = 44384.0202 mm3 (the groove is 1.9% of the bolt); one valid closed body within the case's timeout (slow by nature: 600 s). Tolerance 1%: a modelled thread is a faceted helical solid (radial chord error up to 1% of the pitch on every wall, i.e. a volume deficit of about 4/3 x sag/R).", "body_count": 1, + "volume_mm3": 44384.0202, + "tolerance": { + "rel": 0.01 + }, "timeout_s": 600 } diff --git a/tests/kernel-cases/threads/5146-join-m23x1-threaded-shaft-onto-wider-base/expected.json b/tests/kernel-cases/threads/5146-join-m23x1-threaded-shaft-onto-wider-base/expected.json index 5dedb8f88..dbfcaf6d7 100644 --- a/tests/kernel-cases/threads/5146-join-m23x1-threaded-shaft-onto-wider-base/expected.json +++ b/tests/kernel-cases/threads/5146-join-m23x1-threaded-shaft-onto-wider-base/expected.json @@ -3,8 +3,12 @@ "tangency-labs/solidcraft#5146" ], "what": "a O23 shaft with a modelled M23x1 thread joined onto the O26 cylinder it stands on: SolidCraft ended without a clean exit during the combine", - "source": "invariants", - "method": "the shaft's end face lies on the base's top face, so the join is one solid: one valid closed body, within the case's timeout (modelled threads are slow: 600 s)", + "source": "analytic", + "method": "ISO 68-1 basic profile: H = P sqrt3/2, basic depth 5H/8. External groove (the space between teeth): a trapezoid P/4 wide at the root radius d/2 - 5H/8, widening by 2 tan30 per unit of radius to 7P/8 at d/2. Pappus: volume per turn = 2 pi A rc (A the trapezoid area, rc its centroid radius from the axis); a helical sweep of L/P turns removes exactly (L/P) x that, where each end of the thread is a free end or lies inside material. Base R = 13, h = 10; shaft R = 11.5, z 10..30, M23x1 (P = 1) over its whole length, both ends free (the bottom one then lies on the base's top face, which closes it): the shaft's end face lies on the base's top face, so the join is one solid, V = pi 13^2 10 + pi 11.5^2 20 - 20 x 21.577558 = 13187.2530 mm3, within the case's timeout (modelled threads are slow: 600 s). Tolerance 1%: a modelled thread is a faceted helical solid (radial chord error up to 1% of the pitch on every wall, i.e. a volume deficit of about 4/3 x sag/R).", "body_count": 1, + "volume_mm3": 13187.253, + "tolerance": { + "rel": 0.01 + }, "timeout_s": 600 } From 6c2a2f3959d22e3fb404f8e921de7039372d3a7b Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:59:20 -0400 Subject: [PATCH 76/81] Kernel rig: the oblique-cut round graded by its seams (tangent, not curvature-continuous); the flanged rhombus says what it tests (its reliefs stay apart at 60 mm) Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 8 ++++++-- .../expected.json | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/kernel-cases/fillets/cov-fillet-arc-edge-on-an-oblique-cut-of-a-bar/expected.json b/tests/kernel-cases/fillets/cov-fillet-arc-edge-on-an-oblique-cut-of-a-bar/expected.json index 0db969ecf..03fb30443 100644 --- a/tests/kernel-cases/fillets/cov-fillet-arc-edge-on-an-oblique-cut-of-a-bar/expected.json +++ b/tests/kernel-cases/fillets/cov-fillet-arc-edge-on-an-oblique-cut-of-a-bar/expected.json @@ -2,6 +2,10 @@ "sources": [], "what": "a thin bar with a 3 mm concave arc in its profile, its end cut by a plane tilted 21 deg (examples/regressions/oblique_cut_of_cylinder): the edge where the arc's cylinder meets the cut (part of an ellipse) rounded R0.1 (action matrix (apps/solidcraft-cli/tests/action_matrix.rs): regressions/oblique_cut_of_cylinder, Tool F2:side:a1|F4:side:l1 edge.fillet)", "source": "invariants", - "method": "an R0.1 round fits along that edge (the faces meet at a finite angle and the arc's radius is 3); the section along an elliptical edge on a cylinder has no closed form here: one closed valid solid is the right answer", - "body_count": 2 + "method": "an R0.1 round fits along that edge (the faces meet at a finite angle and the arc's radius is 3); the section along an elliptical edge on a cylinder has no closed form here: the volume moves by about 0.01 mm3 in 970000, below any tolerance, so the round is graded by its seams: it meets the arc's cylinder and the cut plane tangentially (G1, as every constant round does), and not G2 (its curvature jumps by 1 / r there)", + "body_count": 2, + "continuity": { + "order": "g1", + "exact": true + } } diff --git a/tests/kernel-cases/sheet-metal/3417-rhombus-with-a-flange-on-each-edge-and-square-reliefs/expected.json b/tests/kernel-cases/sheet-metal/3417-rhombus-with-a-flange-on-each-edge-and-square-reliefs/expected.json index 4be282916..2a5af8272 100644 --- a/tests/kernel-cases/sheet-metal/3417-rhombus-with-a-flange-on-each-edge-and-square-reliefs/expected.json +++ b/tests/kernel-cases/sheet-metal/3417-rhombus-with-a-flange-on-each-edge-and-square-reliefs/expected.json @@ -4,7 +4,7 @@ "tangency-labs/solidcraft#3421", "tangency-labs/solidcraft#3280" ], - "what": "a 60 mm rhombus (120 and 60 degree corners) with a 90 degree flange on each of its four edges and a square corner relief 8 mm across: the reliefs at the two 120 degree corners would overlap", + "what": "a 60 mm rhombus (120 and 60 degree corners) with a 90 degree flange on each of its four edges and a square corner relief 8 mm across at each corner: at this size the four reliefs stay apart and all are cut", "source": "analytic", "method": "T = 2, R = 1, K = 0.5, gap 0.5, square relief 8 across (r = 4). The 90 deg flanges stand back R + T = 3: the base is the rhombus inset 3, side 53.071797, height 45.961524, area 2439.260673. A square relief cuts r along both edges from the trimmed base's corner, square to them: a kite of area r^2 tan(alpha/2), 9.237604 at 60 and 27.712813 at 120 deg, reaching r/cos(alpha/2) = 4.618802 and 8 along the bisector. Here every corner keeps its relief: the two 120 deg corners are the trimmed short diagonal, 53.071797, apart, so their kites are far from meeting (they would meet with the corners under 16 mm apart), every edge is longer than 2r and every other edge further than 8 from a corner. The bends stop at the reliefs: 4 x (53.071797 - 8) long, BA = (pi/2)(R + T/2) = pi wide. Each panel (leg 20 - 3 = 17, its outer face on the rhombus' edge, its inner face 2 in) is closed with its end square to it, half the gap from the corner's bisector on its inner face: (g/2 + T cos(alpha/2)) / sin(alpha/2) from the rhombus' corner along the edge, 3.964102 at 60 and 1.443376 at 120 deg, so each panel is 54.592523 long. Flat area 6644.040285; K = 0.5, so V = T x flat = 13288.080571. Bbox: the walls stand 20 high on the rhombus' edges (y 0 and 51.961524), and the panel ends at the 60 deg corners keep them 3.964102 x cos 60 = 1.982051 from x = 0 and x = 90 (the bends, stopped 4 past the trimmed corners, reach no nearer)", "body_count": 1, @@ -21,4 +21,4 @@ 20 ] } -} \ No newline at end of file +} From cd56cd3ad47d5c9fa3a4d2662ed9a27be0be3343 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 09:05:46 -0400 Subject: [PATCH 77/81] Kernel rig: 3841 is 168's rim touching its coin along a circle, and 4092's reduced recipe is its report less a flange clear of the failing join; the kept cases carry their sources Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 3 +- .../expected.json | 11 - .../recipe.json | 112 ---- .../expected.json | 22 - .../recipe.json | 508 ------------------ 5 files changed, 2 insertions(+), 654 deletions(-) delete mode 100644 tests/kernel-cases/booleans/3841-join-touching-along-one-circle-only/expected.json delete mode 100644 tests/kernel-cases/booleans/3841-join-touching-along-one-circle-only/recipe.json delete mode 100644 tests/kernel-cases/crashes/4092-loft-ribs-rounded-pad-union-reduced/expected.json delete mode 100644 tests/kernel-cases/crashes/4092-loft-ribs-rounded-pad-union-reduced/recipe.json diff --git a/tests/kernel-cases/booleans/168-rim-touching-coin-along-a-circle-only/expected.json b/tests/kernel-cases/booleans/168-rim-touching-coin-along-a-circle-only/expected.json index 612a36e9d..90db81df4 100644 --- a/tests/kernel-cases/booleans/168-rim-touching-coin-along-a-circle-only/expected.json +++ b/tests/kernel-cases/booleans/168-rim-touching-coin-along-a-circle-only/expected.json @@ -1,6 +1,7 @@ { "sources": [ - "tangency-labs/solidcraft#168" + "tangency-labs/solidcraft#168", + "tangency-labs/solidcraft#3841" ], "what": "a rim on a coin's top face that meets the coin along one circle only (no shared area, no shared volume): it must not be joined into it", "source": "analytic", diff --git a/tests/kernel-cases/booleans/3841-join-touching-along-one-circle-only/expected.json b/tests/kernel-cases/booleans/3841-join-touching-along-one-circle-only/expected.json deleted file mode 100644 index 6be4127d4..000000000 --- a/tests/kernel-cases/booleans/3841-join-touching-along-one-circle-only/expected.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "sources": [ - "tangency-labs/solidcraft#3841", - "tangency-labs/solidcraft#168" - ], - "what": "Join of a ring (r10..15) onto a coin (r10) that touch only along a circle: no fusion that moves the ring", - "source": "invariants", - "outcome": "solid_or_refused", - "method": "the bodies share one circular edge and no area, so a join has no single manifold solid to give: the right answer is a clean refusal, or the two bodies left as they are (body_count 2). Fusing them means the kernel moved or rotated the ring", - "body_count": 2 -} diff --git a/tests/kernel-cases/booleans/3841-join-touching-along-one-circle-only/recipe.json b/tests/kernel-cases/booleans/3841-join-touching-along-one-circle-only/recipe.json deleted file mode 100644 index d4f704ab5..000000000 --- a/tests/kernel-cases/booleans/3841-join-touching-along-one-circle-only/recipe.json +++ /dev/null @@ -1,112 +0,0 @@ -{ - "commands": [ - { - "command": "sketch.create", - "params": { - "plane": { - "origin": [ - 0, - 0, - 0 - ], - "x_dir": [ - 1, - 0, - 0 - ], - "y_dir": [ - 0, - 1, - 0 - ] - } - } - }, - { - "command": "sketch.circle.center", - "params": { - "center": [ - 0, - 0 - ], - "radius": 10 - } - }, - { - "command": "sketch.finish", - "params": {} - }, - { - "command": "solid.extrude", - "params": { - "distance": 3, - "operation": "new", - "body_name": "Coin" - } - }, - { - "command": "sketch.create", - "params": { - "plane": { - "origin": [ - 0, - 0, - 3 - ], - "x_dir": [ - 1, - 0, - 0 - ], - "y_dir": [ - 0, - 1, - 0 - ] - } - } - }, - { - "command": "sketch.circle.center", - "params": { - "center": [ - 0, - 0 - ], - "radius": 10 - } - }, - { - "command": "sketch.circle.center", - "params": { - "center": [ - 0, - 0 - ], - "radius": 15 - } - }, - { - "command": "sketch.finish", - "params": {} - }, - { - "command": "solid.extrude", - "params": { - "profiles": [ - { - "point": [ - 12, - 0 - ] - } - ], - "distance": 3, - "operation": "join", - "targets": [ - "Coin" - ] - } - } - ] -} \ No newline at end of file diff --git a/tests/kernel-cases/crashes/4092-loft-ribs-rounded-pad-union-reduced/expected.json b/tests/kernel-cases/crashes/4092-loft-ribs-rounded-pad-union-reduced/expected.json deleted file mode 100644 index a469e2f6e..000000000 --- a/tests/kernel-cases/crashes/4092-loft-ribs-rounded-pad-union-reduced/expected.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "sources": [ - "tangency-labs/solidcraft#4092" - ], - "what": "the same without the top flange: the join fails with 'boolean Union: no result'", - "source": "analytic", - "method": "the pad (X -8..8, Y 18..25, Z 36..59) overlaps the body, ribs and ring, so the join is one connected solid; the join must succeed with one valid closed solid and no panic. Body: neck pi 18^2 21; the two-section loft is ruled, the circle r 18 paired with the 30 x 20 ellipse by their common angle parameter (the ellipse an affine image of the circle), so each section is an ellipse (18 + 12 l) x (18 + 2 l): 17 pi int (18 + 12 l)(18 + 2 l) dl = 7786 pi (pairing by normals instead, the largest any pairing gives, adds 17 pi * 1.5 = 80, inside the tolerance); the ellipse chamber pi*30*20*26 (z 38..64): 94844.68. The handle disc (r 12 about (y 30, z 47), x -5..5), the two ribs (the rounded profile, x -8..-4 and 4..8) and the pad (x -8..8, z 36..59 rounded r 3, y 18..25) add, by integrating over x -8..8, z 35..59 the length in y of the union of every part's y-interval less the body's own (grids 400^2..1600^2 agree to 2.4): 5347.9. V = 100192.6. Box: the chamber's x +-30, y -20 to the disc's 42, z 0..64", - "body_count": 1, - "volume_mm3": 100192.6, - "bbox": { - "min": [ - -30.0, - -20.0, - 0.0 - ], - "max": [ - 30.0, - 42.0, - 64.0 - ] - } -} \ No newline at end of file diff --git a/tests/kernel-cases/crashes/4092-loft-ribs-rounded-pad-union-reduced/recipe.json b/tests/kernel-cases/crashes/4092-loft-ribs-rounded-pad-union-reduced/recipe.json deleted file mode 100644 index d8152af37..000000000 --- a/tests/kernel-cases/crashes/4092-loft-ribs-rounded-pad-union-reduced/recipe.json +++ /dev/null @@ -1,508 +0,0 @@ -{ - "commands": [ - { - "command": "file.new", - "params": { - "name": "Native_loft_pad_union_repro" - } - }, - { - "command": "document.units", - "params": { - "units": "mm" - } - }, - { - "command": "solid.cylinder", - "params": { - "diameter": "36 mm", - "height": "21 mm", - "base": [ - 0, - 0, - 0 - ], - "operation": "new", - "name": "01_Neck_outer_D36_H21", - "body_name": "NATIVE_CAP_BODY" - } - }, - { - "command": "sketch.create", - "params": { - "name": "02_Outer_transition_round", - "plane": "XY", - "offset": "21 mm" - } - }, - { - "command": "sketch.circle.center", - "params": { - "center": [ - 0, - 0 - ], - "diameter": 36 - } - }, - { - "command": "sketch.finish", - "params": {} - }, - { - "command": "sketch.create", - "params": { - "name": "03_Outer_transition_ellipse", - "plane": "XY", - "offset": "38 mm" - } - }, - { - "command": "sketch.ellipse", - "params": { - "center": [ - 0, - 0 - ], - "major": [ - 30.0, - 0 - ], - "minor_radius": 20.0 - } - }, - { - "command": "sketch.finish", - "params": {} - }, - { - "command": "solid.loft", - "params": { - "sections": [ - { - "sketch": "02_Outer_transition_round" - }, - { - "sketch": "03_Outer_transition_ellipse" - } - ], - "operation": "join", - "targets": [ - "NATIVE_CAP_BODY" - ], - "name": "04_Outer_round_to_oval_transition" - } - }, - { - "command": "sketch.create", - "params": { - "name": "05_Upper_chamber_60x40", - "plane": "XY", - "offset": "38 mm" - } - }, - { - "command": "sketch.ellipse", - "params": { - "center": [ - 0, - 0 - ], - "major": [ - 30.0, - 0 - ], - "minor_radius": 20.0 - } - }, - { - "command": "sketch.finish", - "params": {} - }, - { - "command": "solid.extrude", - "params": { - "sketch": "05_Upper_chamber_60x40", - "distance": 26, - "operation": "join", - "targets": [ - "NATIVE_CAP_BODY" - ], - "name": "06_Upper_chamber_blank" - } - }, - { - "command": "sketch.create", - "params": { - "name": "Handle_outer_D24", - "plane": { - "origin": [ - -5, - 0, - 0 - ], - "x_dir": [ - 0, - 1, - 0 - ], - "y_dir": [ - 0, - 0, - 1 - ] - } - } - }, - { - "command": "sketch.circle.center", - "params": { - "center": [ - 30, - 47 - ], - "diameter": 24 - } - }, - { - "command": "sketch.finish", - "params": {} - }, - { - "command": "solid.extrude", - "params": { - "sketch": "Handle_outer_D24", - "distance": 10, - "operation": "join", - "targets": [ - "NATIVE_CAP_BODY" - ], - "name": "Handle_outer_D24_thickness10" - } - }, - { - "command": "sketch.create", - "params": { - "name": "Handle_lower_rib_X-8", - "plane": { - "origin": [ - -8, - 0, - 0 - ], - "x_dir": [ - 0, - 1, - 0 - ], - "y_dir": [ - 0, - 0, - 1 - ] - } - } - }, - { - "command": "sketch.arc.three_point", - "params": { - "start": [ - 18.0, - 37.5 - ], - "end": [ - 19.5, - 36.0 - ], - "through": [ - 18.439339828220177, - 36.43933982822018 - ] - } - }, - { - "command": "sketch.line", - "params": { - "points": [ - [ - 19.5, - 36.0 - ], - [ - 24.4516191451179, - 36.0 - ] - ] - } - }, - { - "command": "sketch.arc.three_point", - "params": { - "start": [ - 24.4516191451179, - 36.0 - ], - "end": [ - 25.20742568340403, - 38.79566835134765 - ], - "through": [ - 25.89963546529897, - 37.10853003117829 - ] - } - }, - { - "command": "sketch.line", - "params": { - "points": [ - [ - 25.20742568340403, - 38.79566835134765 - ], - [ - 20.25580653828613, - 41.68411285266642 - ] - ] - } - }, - { - "command": "sketch.arc.three_point", - "params": { - "start": [ - 20.25580653828613, - 41.68411285266642 - ], - "end": [ - 18.0, - 40.38844450131877 - ], - "through": [ - 18.75290891031588, - 41.68915773017231 - ] - } - }, - { - "command": "sketch.line", - "params": { - "points": [ - [ - 18.0, - 40.38844450131877 - ], - [ - 18.0, - 37.5 - ] - ] - } - }, - { - "command": "sketch.finish", - "params": {} - }, - { - "command": "solid.extrude", - "params": { - "sketch": "Handle_lower_rib_X-8", - "distance": 4, - "operation": "join", - "targets": [ - "NATIVE_CAP_BODY" - ], - "name": "Handle_lower_rib_X-8_R1p5_thickness4" - } - }, - { - "command": "sketch.create", - "params": { - "name": "Handle_lower_rib_X4", - "plane": { - "origin": [ - 4, - 0, - 0 - ], - "x_dir": [ - 0, - 1, - 0 - ], - "y_dir": [ - 0, - 0, - 1 - ] - } - } - }, - { - "command": "sketch.arc.three_point", - "params": { - "start": [ - 18.0, - 37.5 - ], - "end": [ - 19.5, - 36.0 - ], - "through": [ - 18.439339828220177, - 36.43933982822018 - ] - } - }, - { - "command": "sketch.line", - "params": { - "points": [ - [ - 19.5, - 36.0 - ], - [ - 24.4516191451179, - 36.0 - ] - ] - } - }, - { - "command": "sketch.arc.three_point", - "params": { - "start": [ - 24.4516191451179, - 36.0 - ], - "end": [ - 25.20742568340403, - 38.79566835134765 - ], - "through": [ - 25.89963546529897, - 37.10853003117829 - ] - } - }, - { - "command": "sketch.line", - "params": { - "points": [ - [ - 25.20742568340403, - 38.79566835134765 - ], - [ - 20.25580653828613, - 41.68411285266642 - ] - ] - } - }, - { - "command": "sketch.arc.three_point", - "params": { - "start": [ - 20.25580653828613, - 41.68411285266642 - ], - "end": [ - 18.0, - 40.38844450131877 - ], - "through": [ - 18.75290891031588, - 41.68915773017231 - ] - } - }, - { - "command": "sketch.line", - "params": { - "points": [ - [ - 18.0, - 40.38844450131877 - ], - [ - 18.0, - 37.5 - ] - ] - } - }, - { - "command": "sketch.finish", - "params": {} - }, - { - "command": "solid.extrude", - "params": { - "sketch": "Handle_lower_rib_X4", - "distance": 4, - "operation": "join", - "targets": [ - "NATIVE_CAP_BODY" - ], - "name": "Handle_lower_rib_X4_R1p5_thickness4" - } - }, - { - "command": "sketch.create", - "params": { - "name": "Handle_root_pad_R3", - "plane": { - "origin": [ - 0, - 18, - 0 - ], - "x_dir": [ - 1, - 0, - 0 - ], - "y_dir": [ - 0, - 0, - 1 - ] - } - } - }, - { - "command": "sketch.rectangle.rounded", - "params": { - "p0": [ - -8, - 36 - ], - "p1": [ - 8, - 59 - ], - "radius": 3 - } - }, - { - "command": "sketch.finish", - "params": {} - }, - { - "command": "solid.extrude", - "params": { - "sketch": "Handle_root_pad_R3", - "distance": 7, - "direction": "negative", - "operation": "join", - "targets": [ - "NATIVE_CAP_BODY" - ], - "name": "Native_root_pad_R3" - } - } - ] -} \ No newline at end of file From 57edcf61ac13b255a2cc0ee6e1150eca4d7f42b0 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 09:25:48 -0400 Subject: [PATCH 78/81] Kernel rig: the oblique-cut round keeps its old grade until the new blend algorithm lands Its seams grade needs the continuity check to skip the body the round is not on. Fillet cases wait for the new algorithm. Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/kernel-cases/fillets/cov-fillet-arc-edge-on-an-oblique-cut-of-a-bar/expected.json b/tests/kernel-cases/fillets/cov-fillet-arc-edge-on-an-oblique-cut-of-a-bar/expected.json index 03fb30443..0db969ecf 100644 --- a/tests/kernel-cases/fillets/cov-fillet-arc-edge-on-an-oblique-cut-of-a-bar/expected.json +++ b/tests/kernel-cases/fillets/cov-fillet-arc-edge-on-an-oblique-cut-of-a-bar/expected.json @@ -2,10 +2,6 @@ "sources": [], "what": "a thin bar with a 3 mm concave arc in its profile, its end cut by a plane tilted 21 deg (examples/regressions/oblique_cut_of_cylinder): the edge where the arc's cylinder meets the cut (part of an ellipse) rounded R0.1 (action matrix (apps/solidcraft-cli/tests/action_matrix.rs): regressions/oblique_cut_of_cylinder, Tool F2:side:a1|F4:side:l1 edge.fillet)", "source": "invariants", - "method": "an R0.1 round fits along that edge (the faces meet at a finite angle and the arc's radius is 3); the section along an elliptical edge on a cylinder has no closed form here: the volume moves by about 0.01 mm3 in 970000, below any tolerance, so the round is graded by its seams: it meets the arc's cylinder and the cut plane tangentially (G1, as every constant round does), and not G2 (its curvature jumps by 1 / r there)", - "body_count": 2, - "continuity": { - "order": "g1", - "exact": true - } + "method": "an R0.1 round fits along that edge (the faces meet at a finite angle and the arc's radius is 3); the section along an elliptical edge on a cylinder has no closed form here: one closed valid solid is the right answer", + "body_count": 2 } From a250062c2973eb0577e87738e4352c1ac2d473d6 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 09:25:57 -0400 Subject: [PATCH 79/81] Kernel rig: 1985's enclosure is 78 x 77 (74 and 73 inside, 2 mm walls); its volume 38063.827 by hand Co-Authored-By: Claude Opus 5.5 --- .../expected.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/kernel-cases/crashes/1985-step-export-enclosure-screw-hole/expected.json b/tests/kernel-cases/crashes/1985-step-export-enclosure-screw-hole/expected.json index 67aceaf46..30c55ebac 100644 --- a/tests/kernel-cases/crashes/1985-step-export-enclosure-screw-hole/expected.json +++ b/tests/kernel-cases/crashes/1985-step-export-enclosure-screw-hole/expected.json @@ -5,9 +5,9 @@ ], "what": "a small enclosure (rounded box, inner cut, corner gusset with a screw hole, two standoffs, USB cut-out) whose STEP export never finished (the export meshes its own file back)", "source": "analytic", - "method": "the script builds one connected part: the export must finish, and the part is one valid closed solid. Body sketch: the rounded rectangle 0..80 x 0..79, corners r 3 (straights 74 and 73), area 80*79 - (4 - pi)*9 = 6312.274, extruded 37.5: 236710.288. Cavity box (2,2,2.5) 74 x 73, open at the top: - 74*73*35 = 189070. Gusset (68,67,2.5) 8 x 8 x 35 in the cavity's back corner: + 2240. Screw hole r 1.25 at (72,71) from z 29.5, inside the gusset: - pi 1.25^2 8 = 39.270. Two standoffs r 2.5, 3 high at (30.11, 69.04) and (58.05, 69.04) on the floor, clear of the walls and the gusset: + 2 * 58.905. USB cut-out (21.33..31.33, -1..3, 5..11) through the 2 mm front wall: - 10*2*6 = 120. V = 49838.83. Box: the outline's 0..80 x 0..79, z 0..37.5", + "method": "the script builds one connected part: the export must finish, and the part is one valid closed solid. Body sketch: the rounded rectangle 0..78 x 0..77 (outer_width = 74 + 2 * 2, outer_depth = 73 + 2 * 2), corners r 3, area 78*77 - (4 - pi)*9 = 5998.274, extruded 37.5: 224935.278. Cavity box (2,2,2.5) 74 x 73, open at the top: - 74*73*35 = 189070. Gusset (68,67,2.5) 8 x 8 x 35 in the cavity's back corner: + 2240. Screw hole r 1.25 at (72,71) from z 29.5, inside the gusset: - pi 1.25^2 8 = 39.270. Two standoffs r 2.5, 3 high at (30.11, 69.04) and (58.05, 69.04) on the floor, clear of the walls and the gusset: + 2 * 58.905. USB cut-out (21.33..31.33, -1..3, 5..11) through the 2 mm front wall: - 10*2*6 = 120. V = 38063.827. Box: the outline's 0..78 x 0..77, z 0..37.5", "body_count": 1, - "volume_mm3": 49838.83, + "volume_mm3": 38063.827337, "bbox": { "min": [ 0.0, @@ -15,9 +15,9 @@ 0.0 ], "max": [ - 80.0, - 79.0, + 78, + 77, 37.5 ] } -} \ No newline at end of file +} From b0d1ba3457094ec64f76b356ca3a885b6ab72635 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sat, 31 Oct 2026 09:25:57 -0400 Subject: [PATCH 80/81] Kernel rig: the three spline walls' face counts wait for the one-wall decision; their volumes grade them Co-Authored-By: Claude Opus 5.5 --- .../4879-cut-through-thickened-spline-revolve/expected.json | 5 ++--- .../shell/4567-shell-spline-revolved-vase/expected.json | 3 +-- .../expected.json | 5 ++--- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/tests/kernel-cases/booleans/4879-cut-through-thickened-spline-revolve/expected.json b/tests/kernel-cases/booleans/4879-cut-through-thickened-spline-revolve/expected.json index 988ca8efd..00fc271aa 100644 --- a/tests/kernel-cases/booleans/4879-cut-through-thickened-spline-revolve/expected.json +++ b/tests/kernel-cases/booleans/4879-cut-through-thickened-spline-revolve/expected.json @@ -5,11 +5,10 @@ ], "what": "a symmetric through-all cut of a window across a thickened (2 mm) surface revolve of a control-point spline (100 deg about X): truck ran ~20 s to 'boolean Cut: no result' (or never finished)", "source": "analytic", - "method": "the window (x -2..6, z 6..20, through all y) crosses the shell where it is near the XZ plane and leaves it joined round the rest of its 100 deg, so the result is one valid closed body. The revolve's normal lies in each meridian plane, so the 2 mm thicken is the revolution, through 100 deg, of the band between the cubic spline (clamped, knots 0 0 0 0 .5 1 1 1 1; r 8..11.63, curvature at most 0.128, so a 2 mm offset never folds) and its offset; the window removes, at each point (x, r) of the band with -2 <= x <= 6, the angles where r cos phi >= 6 (acos(6/r) of them; r cos phi <= 20 everywhere). V = int over the band of r (100 deg - [x in -2..6] acos(6/r)) dA, by quadrature: 852.04 thickened outwards (uncut 1053.63), 660.02 inwards (uncut 807.73). Which side the revolve's normal faces is the kernel's convention, so V is graded in [660.02, 852.04], widened 1e-3: a cut that did nothing on the outer side, or lost half the body, falls outside. Faces: the two offset walls, the two end caps, the plane at 100 deg, the XZ plane's two pieces either side of the window, and the window's planes x = -2, x = 6 and z = 6: 10", + "method": "the window (x -2..6, z 6..20, through all y) crosses the shell where it is near the XZ plane and leaves it joined round the rest of its 100 deg, so the result is one valid closed body. The revolve's normal lies in each meridian plane, so the 2 mm thicken is the revolution, through 100 deg, of the band between the cubic spline (clamped, knots 0 0 0 0 .5 1 1 1 1; r 8..11.63, curvature at most 0.128, so a 2 mm offset never folds) and its offset; the window removes, at each point (x, r) of the band with -2 <= x <= 6, the angles where r cos phi >= 6 (acos(6/r) of them; r cos phi <= 20 everywhere). V = int over the band of r (100 deg - [x in -2..6] acos(6/r)) dA, by quadrature: 852.04 thickened outwards (uncut 1053.63), 660.02 inwards (uncut 807.73). Which side the revolve's normal faces is the kernel's convention, so V is graded in [660.02, 852.04], widened 1e-3: a cut that did nothing on the outer side, or lost half the body, falls outside. Faces: the two offset walls, the two end caps, the plane at 100 deg, the XZ plane's two pieces either side of the window, and the window's planes x = -2, x = 6 and z = 6: 10 Faces are not graded: whether a spline of several spans is one wall or one face per span is an open decision.", "body_count": 1, "volume_mm3": [ 659.3, 852.9 - ], - "faces": 10 + ] } diff --git a/tests/kernel-cases/shell/4567-shell-spline-revolved-vase/expected.json b/tests/kernel-cases/shell/4567-shell-spline-revolved-vase/expected.json index 55f8c7fda..2aa135667 100644 --- a/tests/kernel-cases/shell/4567-shell-spline-revolved-vase/expected.json +++ b/tests/kernel-cases/shell/4567-shell-spline-revolved-vase/expected.json @@ -7,10 +7,9 @@ ], "what": "a vase revolved from a fit-point spline wall, shelled 2 mm from its flat top: truck refused any free-form wall ('offset: only bodies with planes, cylinders, cones, spheres and tori')", "source": "analytic", - "method": "the wall is the sketch's fit-point spline: the natural cubic through the seven points with chord-length parameters, six cubic spans. Its curvature towards the material stays below 0.0765 / mm (radius 13) and away from it below 0.34 / mm, so its 2 mm inward offset, c - 2 n, is a clean curve; the revolved shell's cavity is that offset revolved (the offset of a surface of revolution is its meridian's offset revolved), open at the flat top y = 46 (removed): it leaves the axis at y = 2.00335 (the bottom is a flat cone point, the two halves' offsets meet there) and reaches y = 46 at x = 3.96953, before its end (4.030, 46.346), so it is trimmed, never extended. Volumes by revolving (V = pi int x^2 dy): body 46402.29333 (exact, polynomial per span), cavity 34793.17040 (pi int x_o^2 dy_o along the offset, with o' = c' (1 - 2 k), Gauss quadrature converged to 1e-9). V = 11609.12293. Faces: the outer wall, the inner wall and the rim; the wall reaches x = 22.8722 at most", + "method": "the wall is the sketch's fit-point spline: the natural cubic through the seven points with chord-length parameters, six cubic spans. Its curvature towards the material stays below 0.0765 / mm (radius 13) and away from it below 0.34 / mm, so its 2 mm inward offset, c - 2 n, is a clean curve; the revolved shell's cavity is that offset revolved (the offset of a surface of revolution is its meridian's offset revolved), open at the flat top y = 46 (removed): it leaves the axis at y = 2.00335 (the bottom is a flat cone point, the two halves' offsets meet there) and reaches y = 46 at x = 3.96953, before its end (4.030, 46.346), so it is trimmed, never extended. Volumes by revolving (V = pi int x^2 dy): body 46402.29333 (exact, polynomial per span), cavity 34793.17040 (pi int x_o^2 dy_o along the offset, with o' = c' (1 - 2 k), Gauss quadrature converged to 1e-9). V = 11609.12293. Faces: the outer wall, the inner wall and the rim; the wall reaches x = 22.8722 at most Faces are not graded: whether a spline of several spans is one wall or one face per span is an open decision.", "body_count": 1, "volume_mm3": 11609.12292605581, - "faces": 3, "bbox": { "min": [ -22.8722, diff --git a/tests/kernel-cases/shell/745-offset-face-on-body-with-distant-freeform-boss/expected.json b/tests/kernel-cases/shell/745-offset-face-on-body-with-distant-freeform-boss/expected.json index 6c2502033..aef6e36cf 100644 --- a/tests/kernel-cases/shell/745-offset-face-on-body-with-distant-freeform-boss/expected.json +++ b/tests/kernel-cases/shell/745-offset-face-on-body-with-distant-freeform-boss/expected.json @@ -5,10 +5,9 @@ ], "what": "Offset Face on a planar end of a body that has a spline-outlined boss far from the moved face", "source": "analytic", - "method": "the move is refused today only because the unrelated boss wall is freeform. The box end at x=0 moves out by 1 mm between its four planar, square neighbours: +1 x 20 x 10 = 200. The boss outline is the line (25,5)-(35,5) and the fit-point spline through (35,5), (37,10), (30,15), (25,5): the sketch's natural cubic with chord-length parameters, three cubic spans, its area by Green's theorem (1/2 closed integral of x dy - y dx, a polynomial per span, integrated exactly) 94.302132; it stays within x 25..37.04, y 5..15.01. V = 8000 + 5 x 94.302132 + 200. Faces: the box's 6 and the boss's top, flat wall and spline wall. The cut-away variant 745-offset-face-then-cut-boss-away grades the same move without the boss", + "method": "the move is refused today only because the unrelated boss wall is freeform. The box end at x=0 moves out by 1 mm between its four planar, square neighbours: +1 x 20 x 10 = 200. The boss outline is the line (25,5)-(35,5) and the fit-point spline through (35,5), (37,10), (30,15), (25,5): the sketch's natural cubic with chord-length parameters, three cubic spans, its area by Green's theorem (1/2 closed integral of x dy - y dx, a polynomial per span, integrated exactly) 94.302132; it stays within x 25..37.04, y 5..15.01. V = 8000 + 5 x 94.302132 + 200. Faces: the box's 6 and the boss's top, flat wall and spline wall. The cut-away variant 745-offset-face-then-cut-boss-away grades the same move without the boss Faces are not graded: whether a spline of several spans is one wall or one face per span is an open decision.", "body_count": 1, "volume_mm3": 8671.510661445036, - "faces": 9, "bbox": { "min": [ -1, @@ -21,4 +20,4 @@ 15 ] } -} \ No newline at end of file +} From 6295833c454335260783c325f148da60c67b6fd5 Mon Sep 17 00:00:00 2001 From: brett19 Date: Sat, 31 Oct 2026 06:50:04 -0700 Subject: [PATCH 81/81] Held flags re-read at SMLib 26cc451: none changes Each held flag's fork site is untouched by 2fc375f..26cc451. The capi's mitre rule (fork 9ba2b12) has no solidcore call to read yet; noted at OVERFLOW_GOES_FIRST. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01MNXLXkZLQ6T7TSi4wswcmk --- crates/smlib/src/core.rs | 4 ++-- crates/smlib/src/core/blend.rs | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/smlib/src/core.rs b/crates/smlib/src/core.rs index e1b37072c..5e0b4e780 100644 --- a/crates/smlib/src/core.rs +++ b/crates/smlib/src/core.rs @@ -256,7 +256,7 @@ pub(crate) fn fixes() -> UpstreamFixes { } /// Opt-in fixes left off because the C++ fork (`SMLIB_REV`) does not behave as they do, so turning -/// them on would part this backend from the C++ one. Each was read in the fork's source at 2fc375f. +/// them on would part this backend from the C++ one. Each was read in the fork's source at 26cc451. /// /// Upstream's defect is still there: `precise_properties_trim_base_v` (WR-563: `SmODEAreaIFEO` starts /// at the domain's lowest v), `fillet_blend_curve_revolved_on_arc` (WR-581: `CalcTorusFilletGeom` takes @@ -290,7 +290,7 @@ pub(crate) fn fixes() -> UpstreamFixes { /// `geometric_g2_continuity`: no fork commit; the C++ still has the defect at SmGeomUtility.cpp:5822 /// (crashes/2992: 183 faces against 831). /// -/// Upstream's defect is still in the fork's source at `SMLIB_REV` 2fc375f: +/// Upstream's defect is still in the fork's source at `SMLIB_REV` 26cc451: /// `fillet_corner_variable_radius_rail_on_opposite_fillet` (WR-645: `MakeVariableRadiusFillet` has /// only the concave corner's rail-rail test before resetting the edges, no test of the rail against /// the opposite fillet), `sphere_from_arcs_common_centre` (WR-103: `CreateSphereFromArcs` compares diff --git a/crates/smlib/src/core/blend.rs b/crates/smlib/src/core/blend.rs index 805560de7..57dffdc43 100644 --- a/crates/smlib/src/core/blend.rs +++ b/crates/smlib/src/core/blend.rs @@ -547,6 +547,8 @@ fn picked_on(b: &Brep, e: EdgeId) -> Option<(solidcore::geom::attribute::Attribu /// edge the overflow only shortened reads as removed whole and is silently left unrounded (the rig's /// fillets/5158-fillet-adjacent-plate-edges-as-thick-as-plate, 1706.89 against 1681.90). Off, the /// rounds are blended together, and those that need the order are refused. +/// Turned on, this port still lacks the capi's rule from fork 9ba2b12, a round mitred to one that +/// goes first goes with it: solidcore's session reports no mitred edges (`GetMitredEdges`). const OVERFLOW_GOES_FIRST: bool = false; /// `overflow_first`: the rounds of [`blend_call`] when blends of several edges overflow their