From 51316b7ec76bed72044031ef227d5b4610cbbe94 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Fri, 30 Oct 2026 06:57:37 -0400 Subject: [PATCH] Import rig: the horn torus quarter written to STEP and read back, as a case The round trip's volume moves from the STEP unit test to an import rig case (616.850, Pappus); the unit test keeps the writer's logic, the degenerate torus written as one B-spline face and no toroidal surface or surface of revolution. The case fails today where the revolve does (KNOWN_FAILING). Co-Authored-By: Claude Opus 5.5 --- crates/kernel/src/step_in/tests.rs | 6 +- tests/kernel-cases/import/KNOWN_FAILING | 1 + .../expected.json | 8 +++ .../recipe.json | 56 +++++++++++++++++++ 4 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 tests/kernel-cases/import/cov-step-horn-torus-quarter-round-trip/expected.json create mode 100644 tests/kernel-cases/import/cov-step-horn-torus-quarter-round-trip/recipe.json diff --git a/crates/kernel/src/step_in/tests.rs b/crates/kernel/src/step_in/tests.rs index ba854a77fa..606f556099 100644 --- a/crates/kernel/src/step_in/tests.rs +++ b/crates/kernel/src/step_in/tests.rs @@ -1127,7 +1127,8 @@ fn surface_of_revolution_sense_follows_iso() { /// A tube revolved about a line it touches (a horn torus, as a tight sweep makes) is written as /// one rational B-spline face whose loop passes the pole twice, with no zero-length edge there: -/// no TOROIDAL_SURFACE (it would be degenerate) and no surface of revolution. +/// no TOROIDAL_SURFACE (it would be degenerate) and no surface of revolution. (Its volume, built +/// and read back, is the rig's import/cov-step-horn-torus-quarter-round-trip.) #[test] fn horn_torus_written_as_one_spline_face() { let prof = Region2 { outer: Loop2::circle(Vec2::new(5.0, 0.0), 5.0), holes: vec![] }; @@ -1135,9 +1136,6 @@ fn horn_torus_written_as_one_spline_face() { let text = step_export(&[&b], "t").unwrap(); assert!(!text.contains("TOROIDAL_SURFACE") && !text.contains("SURFACE_OF_REVOLUTION")); assert_eq!(text.matches("ADVANCED_FACE(").count(), 3, "{text}"); - let imp = round_trip(&b); - let v = std::f64::consts::PI * 25.0 * std::f64::consts::TAU * 5.0 / 4.0; - assert!(rel(measure(&imp.bodies[0].body).unwrap().volume, v) < 1e-3); } /// How a torus-capped cylinder ([`torus_capped_cylinder`]) ends. diff --git a/tests/kernel-cases/import/KNOWN_FAILING b/tests/kernel-cases/import/KNOWN_FAILING index 0f96696619..7eafa4152d 100644 --- a/tests/kernel-cases/import/KNOWN_FAILING +++ b/tests/kernel-cases/import/KNOWN_FAILING @@ -2,3 +2,4 @@ # 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). +cov-step-horn-torus-quarter-round-trip SMLib revolve status 1001 on a profile touching its axis (the part is never built) diff --git a/tests/kernel-cases/import/cov-step-horn-torus-quarter-round-trip/expected.json b/tests/kernel-cases/import/cov-step-horn-torus-quarter-round-trip/expected.json new file mode 100644 index 0000000000..57087204af --- /dev/null +++ b/tests/kernel-cases/import/cov-step-horn-torus-quarter-round-trip/expected.json @@ -0,0 +1,8 @@ +{ + "sources": [], + "what": "a quarter horn torus (a circle r5 touching its axis, revolved 90 deg) written to STEP and read back: the same solid", + "source": "analytic", + "method": "the disc r5 about (5, 0) on XZ touches the Z axis at the origin; Pappus, its centroid 5 from the axis: V = pi 25 x 2 pi 5 / 4 = 616.850275; read back into a new design, the same", + "body_count": 1, + "volume_mm3": 616.8502750680849 +} diff --git a/tests/kernel-cases/import/cov-step-horn-torus-quarter-round-trip/recipe.json b/tests/kernel-cases/import/cov-step-horn-torus-quarter-round-trip/recipe.json new file mode 100644 index 0000000000..c6fbabf62c --- /dev/null +++ b/tests/kernel-cases/import/cov-step-horn-torus-quarter-round-trip/recipe.json @@ -0,0 +1,56 @@ +{ + "commands": [ + { + "command": "sketch.create", + "params": { + "plane": "XZ", + "name": "Tube" + } + }, + { + "command": "sketch.circle.center", + "params": { + "center": [ + 5, + 0 + ], + "radius": 5 + } + }, + { + "command": "sketch.finish", + "params": {} + }, + { + "command": "solid.revolve", + "params": { + "sketch": "Tube", + "axis": "Z", + "angle": "90 deg", + "body_name": "Horn" + } + }, + { + "command": "file.export", + "params": { + "path": "$OUT/kernel-case-horn-torus.step", + "format": "step", + "bodies": [ + "Horn" + ] + } + }, + { + "command": "file.new", + "params": { + "name": "Reimported" + } + }, + { + "command": "file.insert_step", + "params": { + "path": "$OUT/kernel-case-horn-torus.step" + } + } + ] +}