Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Add RULED-A2 linear extrusion production fixture

Yuechen Li85b54f54effa
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242LinearExtrusionSurfaceProductionTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242LinearExtrusionSurfaceProductionTests.cs
new file mode 100644
index 00000000..22dab84f
--- /dev/null
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242LinearExtrusionSurfaceProductionTests.cs
@@ -0,0 +1,116 @@
+using Aetheris.Kernel.Core.Brep;
+using Aetheris.Kernel.Core.Geometry;
+using Aetheris.Kernel.Core.Geometry.Curves;
+using Aetheris.Kernel.Core.Geometry.Surfaces;
+using Aetheris.Kernel.Core.Math;
+using Aetheris.Kernel.Core.Step242;
+using Aetheris.Kernel.Core.Topology;
+
+namespace Aetheris.Kernel.Core.Tests.Step242;
+
+public sealed class Step242LinearExtrusionSurfaceProductionTests
+{
+ [Fact]
+ public void EllipseDirectrixLinearExtrusion_ExportsReimportsAsExactSweptSurface()
+ {
+ var body = CreateEllipticStripSurfaceBody();
+
+ var export = Step242Exporter.ExportBody(body, new Step242ExportOptions { ProductName = "RULED-A2 elliptic linear-extrusion strip" });
+ Assert.True(export.IsSuccess, string.Join(Environment.NewLine, export.Diagnostics.Select(d => d.Message)));
+ Assert.Contains("SURFACE_OF_LINEAR_EXTRUSION", export.Value, StringComparison.Ordinal);
+ Assert.Contains("ELLIPSE", export.Value, StringComparison.Ordinal);
+ Assert.DoesNotContain("B_SPLINE_SURFACE_WITH_KNOTS", export.Value, StringComparison.Ordinal);
+
+ var artifactPath = WriteArtifact(export.Value);
+ Assert.True(File.Exists(artifactPath));
+
+ var reimport = Step242Importer.ImportBody(export.Value);
+ Assert.True(reimport.IsSuccess, string.Join(Environment.NewLine, reimport.Diagnostics.Select(d => d.Message)));
+
+ Assert.Single(reimport.Value.Topology.Bodies);
+ Assert.Single(reimport.Value.Topology.Shells);
+ Assert.Single(reimport.Value.Topology.Faces);
+ Assert.Single(reimport.Value.Topology.Loops);
+ Assert.Equal(4, reimport.Value.Topology.Edges.Count());
+ Assert.Equal(4, reimport.Value.Topology.Vertices.Count());
+
+ var surface = Assert.Single(reimport.Value.Geometry.Surfaces).Value;
+ Assert.Equal(SurfaceGeometryKind.LinearExtrusion, surface.Kind);
+ Assert.True(surface.LinearExtrusion.HasValue);
+ Assert.Equal(CurveGeometryKind.Ellipse3, surface.LinearExtrusion.Value.Directrix.Kind);
+ }
+
+ private static BrepBody CreateEllipticStripSurfaceBody()
+ {
+ var builder = new TopologyBuilder();
+ var v0 = builder.AddVertex();
+ var v1 = builder.AddVertex();
+ var v2 = builder.AddVertex();
+ var v3 = builder.AddVertex();
+
+ var e0 = builder.AddEdge(v0, v1);
+ var e1 = builder.AddEdge(v1, v2);
+ var e2 = builder.AddEdge(v3, v2);
+ var e3 = builder.AddEdge(v0, v3);
+
+ var loopId = builder.AllocateLoopId();
+ var c0 = builder.AllocateCoedgeId();
+ var c1 = builder.AllocateCoedgeId();
+ var c2 = builder.AllocateCoedgeId();
+ var c3 = builder.AllocateCoedgeId();
+ builder.AddCoedge(new Coedge(c0, e0, loopId, c1, c3, false));
+ builder.AddCoedge(new Coedge(c1, e1, loopId, c2, c0, false));
+ builder.AddCoedge(new Coedge(c2, e2, loopId, c3, c1, true));
+ builder.AddCoedge(new Coedge(c3, e3, loopId, c0, c2, true));
+ builder.AddLoop(new Loop(loopId, [c0, c1, c2, c3]));
+
+ var faceId = builder.AddFace([loopId]);
+ var shellId = builder.AddShell([faceId]);
+ builder.AddBody([shellId]);
+
+ var normal = Direction3D.Create(new Vector3D(0, 0, 1));
+ var xAxis = Direction3D.Create(new Vector3D(1, 0, 0));
+ var zLine = Direction3D.Create(new Vector3D(0, 0, 1));
+ var bottomEllipse = new Ellipse3Curve(Point3D.Origin, normal, majorRadius: 4d, minorRadius: 2d, xAxis);
+ var topEllipse = new Ellipse3Curve(new Point3D(0, 0, 5), normal, majorRadius: 4d, minorRadius: 2d, xAxis);
+ var p0 = bottomEllipse.Evaluate(0d);
+ var p1 = bottomEllipse.Evaluate(global::System.Math.PI);
+ var p2 = topEllipse.Evaluate(global::System.Math.PI);
+ var p3 = topEllipse.Evaluate(0d);
+
+ var geometry = new BrepGeometryStore();
+ var surfaceGeometryId = new SurfaceGeometryId(1);
+ geometry.AddSurface(surfaceGeometryId, SurfaceGeometry.FromLinearExtrusion(new LinearExtrusionSurface(
+ CurveGeometry.FromEllipse(bottomEllipse),
+ new Vector3D(0, 0, 5))));
+ geometry.AddCurve(new CurveGeometryId(1), CurveGeometry.FromEllipse(bottomEllipse));
+ geometry.AddCurve(new CurveGeometryId(2), CurveGeometry.FromLine(new Line3Curve(p1, zLine)));
+ geometry.AddCurve(new CurveGeometryId(3), CurveGeometry.FromEllipse(topEllipse));
+ geometry.AddCurve(new CurveGeometryId(4), CurveGeometry.FromLine(new Line3Curve(p0, zLine)));
+
+ var bindings = new BrepBindingModel();
+ bindings.AddFaceBinding(new FaceGeometryBinding(faceId, surfaceGeometryId));
+ bindings.AddEdgeBinding(new EdgeGeometryBinding(e0, new CurveGeometryId(1), new ParameterInterval(0d, global::System.Math.PI)));
+ bindings.AddEdgeBinding(new EdgeGeometryBinding(e1, new CurveGeometryId(2), new ParameterInterval(0d, 5d)));
+ bindings.AddEdgeBinding(new EdgeGeometryBinding(e2, new CurveGeometryId(3), new ParameterInterval(0d, global::System.Math.PI)));
+ bindings.AddEdgeBinding(new EdgeGeometryBinding(e3, new CurveGeometryId(4), new ParameterInterval(0d, 5d)));
+
+ var vertexPoints = new Dictionary<VertexId, Point3D>
+ {
+ [v0] = p0,
+ [v1] = p1,
+ [v2] = p2,
+ [v3] = p3
+ };
+
+ return new BrepBody(builder.Model, geometry, bindings, vertexPoints);
+ }
+
+ private static string WriteArtifact(string stepText)
+ {
+ var path = Path.Combine(Step242CorpusManifestRunner.RepoRoot(), "testdata", "step242", "generated", "ruled-a2", "ellipse-linear-extrusion-production.step");
+ Directory.CreateDirectory(Path.GetDirectoryName(path)!);
+ File.WriteAllText(path, stepText);
+ return path;
+ }
+}
diff --git a/Aetheris.Kernel.Core/Step242/Step242Exporter.cs b/Aetheris.Kernel.Core/Step242/Step242Exporter.cs
index d93e1464..b0d91ab7 100644
--- a/Aetheris.Kernel.Core/Step242/Step242Exporter.cs
+++ b/Aetheris.Kernel.Core/Step242/Step242Exporter.cs
@@ -552,6 +552,12 @@ public static class Step242Exporter
return KernelResult<string>.Success(writer.AddEntity("CIRCLE", "$", Step242TextWriter.Ref(axisPlacementId), Step242TextWriter.Number(circle.Radius)));
}
+ if (curve.Kind == CurveGeometryKind.Ellipse3 && curve.Ellipse3 is Ellipse3Curve ellipse)
+ {
+ var axisPlacementId = BuildAxisPlacement(writer, ellipse.Center, ellipse.Normal, ellipse.XAxis);
+ return KernelResult<string>.Success(writer.AddEntity("ELLIPSE", "$", Step242TextWriter.Ref(axisPlacementId), Step242TextWriter.Number(ellipse.MajorRadius), Step242TextWriter.Number(ellipse.MinorRadius)));
+ }
+
return Failure($"Unsupported swept directrix curve kind '{curve.Kind}'.", source);
}
diff --git a/Aetheris.Kernel.Core/Step242/Step242SubsetDecoder.cs b/Aetheris.Kernel.Core/Step242/Step242SubsetDecoder.cs
index d348d8e3..60f4ae9e 100644
--- a/Aetheris.Kernel.Core/Step242/Step242SubsetDecoder.cs
+++ b/Aetheris.Kernel.Core/Step242/Step242SubsetDecoder.cs
@@ -311,6 +311,15 @@ internal static class Step242SubsetDecoder
: KernelResult<CurveGeometry>.Success(CurveGeometry.FromCircle(circleResult.Value));
}
+ var ellipseConstructor = TryGetConstructor(curveEntity.Instance, "ELLIPSE");
+ if (ellipseConstructor is not null)
+ {
+ var ellipseResult = ReadEllipseCurve(document, new Step242ParsedEntity(curveEntity.Id, new Step242SimpleEntityInstance(ellipseConstructor)));
+ return !ellipseResult.IsSuccess
+ ? KernelResult<CurveGeometry>.Failure(ellipseResult.Diagnostics)
+ : KernelResult<CurveGeometry>.Success(CurveGeometry.FromEllipse(ellipseResult.Value));
+ }
+
return Failure<CurveGeometry>($"{context}: directrix curve '{curveEntity.Name}' is unsupported.", source);
}
diff --git a/docs/implementation/ruled-a2-linear-extrusion-production-and-snapshot-refresh.md b/docs/implementation/ruled-a2-linear-extrusion-production-and-snapshot-refresh.md
new file mode 100644
index 00000000..516e1600
--- /dev/null
+++ b/docs/implementation/ruled-a2-linear-extrusion-production-and-snapshot-refresh.md
@@ -0,0 +1,66 @@
+# RULED-A2: Linear-extrusion production fixture and NIST snapshot audit
+
+## Production geometry added
+
+RULED-A2 adds a Core STEP production fixture that builds an Aetheris B-rep body in memory and exports it through `Step242Exporter`. The fixture is an intentionally open single-face surface body: one bounded elliptic strip whose support surface is `SurfaceGeometryKind.LinearExtrusion`.
+
+The constructed directrix is an `ELLIPSE` in the XY plane with major radius 4 and minor radius 2. The extrusion vector is `(0, 0, 5)`. The face boundary uses two half-ellipse edges and two linear seam edges, so the artifact is a bounded CAD surface body rather than a hand-authored STEP probe.
+
+Generated artifact path:
+
+- `testdata/step242/generated/ruled-a2/ellipse-linear-extrusion-production.step`
+
+## Why `SURFACE_OF_LINEAR_EXTRUSION` is exact
+
+The support surface is the translational sweep of a non-circular conic directrix along a straight vector. Because the directrix is elliptical rather than circular, the surface should not simplify to the current elementary `CYLINDRICAL_SURFACE` lane. Exporting it as `SURFACE_OF_LINEAR_EXTRUSION` preserves the directrix plus vector semantics exactly and avoids degrading the surface to `B_SPLINE_SURFACE_WITH_KNOTS`.
+
+## Directrix subset used
+
+RULED-A1 supported line/circle swept directrices for the skeleton probes. RULED-A2 extends the swept-surface directrix subset to include `ELLIPSE` for both export and import decoding. This is intentionally narrow: it only enables the existing `Ellipse3Curve` representation as a swept directrix and does not add general curve-library expansion or `RULED_SURFACE` support.
+
+## Reimport evidence
+
+`Step242LinearExtrusionSurfaceProductionTests` verifies that the production fixture:
+
+1. exports successfully through `Step242Exporter`;
+2. contains `SURFACE_OF_LINEAR_EXTRUSION` and `ELLIPSE`;
+3. does not contain `B_SPLINE_SURFACE_WITH_KNOTS`;
+4. reimports through `Step242Importer`;
+5. reimports as a single body, shell, face, loop, four edges, and four vertices;
+6. preserves `SurfaceGeometryKind.LinearExtrusion` with an `Ellipse3` directrix.
+
+## FreeCAD validation status
+
+FreeCAD validation remains optional and is not made mandatory for CI. In this environment, no FreeCAD command-line executable was found on `PATH`, so the generated AP242 artifact could not be externally validated here. The intended optional command is:
+
+```powershell
+.\tools\Validate-Step-FreeCAD.ps1 .\testdata\step242\generated\ruled-a2\ellipse-linear-extrusion-production.step
+```
+
+## NIST snapshot refresh details
+
+The RULED-A1 semantic change preserves exact swept-surface semantics during canonical STEP output. That can change byte-stable canonical hashes without changing import success, diagnostics status, or topology counts. The previously affected audit tests are the NIST per-file and aggregate audit snapshot checks in `Step242NistAuditHarnessTests`:
+
+- `NistCorpus_PerFile_AuditReport_IsStable_AndMatchesSnapshot`
+- `NistCorpus_AggregateAuditReport_IsByteStableAcrossConsecutiveRuns_AndMatchesSnapshot`
+
+For RULED-A2, the broad NIST/audit/snapshot filter was run after the production fixture/directrix work. It passed against the checked-in snapshots, which confirms that the snapshot baseline in this branch already reflects the intentional swept-surface semantic delta and that no additional blind hash refresh was necessary. The validation preserved the expected audit invariants: import status remained stable, diagnostics status remained stable, topology counts remained stable, files reimported through the harness, and there was no unrelated snapshot churn.
+
+Validation command used for this audit:
+
+```bash
+dotnet test Aetheris.Kernel.Core.Tests/Aetheris.Kernel.Core.Tests.csproj -f net10.0 --no-build --filter "Nist|Snapshot|Audit|Step242"
+```
+
+## Deferred work
+
+Deferred explicitly from RULED-A2:
+
+- Firmament ruled syntax;
+- AIR ruled transition primitive;
+- general ruled surface construction;
+- `SURFACE_OF_REVOLUTION` production geometry;
+- degree-1 B-spline production construction;
+- `RULED_SURFACE` support;
+- mandatory FreeCAD/SolidWorks CI;
+- SolidWorks validation.
diff --git a/testdata/step242/generated/ruled-a2/ellipse-linear-extrusion-production.step b/testdata/step242/generated/ruled-a2/ellipse-linear-extrusion-production.step
new file mode 100644
index 00000000..800ad91c
--- /dev/null
+++ b/testdata/step242/generated/ruled-a2/ellipse-linear-extrusion-production.step
@@ -0,0 +1,69 @@
+ISO-10303-21;
+HEADER;
+FILE_DESCRIPTION(('Aetheris AP242 subset export'),'2;1');
+FILE_NAME('aetheris_export.step','1970-01-01T00:00:00',('Aetheris'),('Aetheris'),'Aetheris.Kernel','Aetheris.Kernel','');
+FILE_SCHEMA(('AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF'));
+ENDSEC;
+DATA;
+#1=CARTESIAN_POINT($,(0,0,0));
+#2=DIRECTION($,(0,0,1));
+#3=DIRECTION($,(1,0,0));
+#4=AXIS2_PLACEMENT_3D($,#1,#2,#3);
+#5=ELLIPSE($,#4,4,2);
+#6=DIRECTION($,(0,0,1));
+#7=VECTOR($,#6,5);
+#8=SURFACE_OF_LINEAR_EXTRUSION($,#5,#7);
+#9=CARTESIAN_POINT($,(4,0,0));
+#10=VERTEX_POINT($,#9);
+#11=CARTESIAN_POINT($,(-4,0,0));
+#12=VERTEX_POINT($,#11);
+#13=CARTESIAN_POINT($,(0,0,0));
+#14=DIRECTION($,(0,0,1));
+#15=DIRECTION($,(1,0,0));
+#16=AXIS2_PLACEMENT_3D($,#13,#14,#15);
+#17=ELLIPSE($,#16,4,2);
+#18=EDGE_CURVE($,#10,#12,#17,.T.);
+#19=ORIENTED_EDGE($,$,$,#18,.T.);
+#20=CARTESIAN_POINT($,(-4,0,5));
+#21=VERTEX_POINT($,#20);
+#22=CARTESIAN_POINT($,(-4,0,0));
+#23=DIRECTION($,(0,0,1));
+#24=VECTOR($,#23,1);
+#25=LINE($,#22,#24);
+#26=EDGE_CURVE($,#12,#21,#25,.T.);
+#27=ORIENTED_EDGE($,$,$,#26,.T.);
+#28=CARTESIAN_POINT($,(4,0,5));
+#29=VERTEX_POINT($,#28);
+#30=CARTESIAN_POINT($,(0,0,5));
+#31=DIRECTION($,(0,0,1));
+#32=DIRECTION($,(1,0,0));
+#33=AXIS2_PLACEMENT_3D($,#30,#31,#32);
+#34=ELLIPSE($,#33,4,2);
+#35=EDGE_CURVE($,#29,#21,#34,.T.);
+#36=ORIENTED_EDGE($,$,$,#35,.F.);
+#37=CARTESIAN_POINT($,(4,0,0));
+#38=DIRECTION($,(0,0,1));
+#39=VECTOR($,#38,1);
+#40=LINE($,#37,#39);
+#41=EDGE_CURVE($,#10,#29,#40,.T.);
+#42=ORIENTED_EDGE($,$,$,#41,.F.);
+#43=EDGE_LOOP($,(#19,#27,#36,#42));
+#44=FACE_OUTER_BOUND('',#43,.T.);
+#45=ADVANCED_FACE('',(#44),#8,.T.);
+#46=CLOSED_SHELL($,(#45));
+#47=MANIFOLD_SOLID_BREP('RULED-A2 elliptic linear-extrusion strip',#46);
+#48=APPLICATION_CONTEXT('mechanical design');
+#49=PRODUCT_CONTEXT('',#48,'mechanical');
+#50=PRODUCT('AETHERIS','RULED-A2 elliptic linear-extrusion strip','',(#49));
+#51=PRODUCT_DEFINITION_FORMATION('','',#50);
+#52=PRODUCT_DEFINITION_CONTEXT('design',#48,'design');
+#53=PRODUCT_DEFINITION('','',#51,#52);
+#54=PRODUCT_DEFINITION_SHAPE('','',#53);
+#55=(LENGTH_UNIT()NAMED_UNIT(*)SI_UNIT(.MILLI.,.METRE.));
+#56=(NAMED_UNIT(*)PLANE_ANGLE_UNIT()SI_UNIT($,.RADIAN.));
+#57=(NAMED_UNIT(*)SI_UNIT($,.STERADIAN.)SOLID_ANGLE_UNIT());
+#58=(GEOMETRIC_REPRESENTATION_CONTEXT(3)GLOBAL_UNIT_ASSIGNED_CONTEXT((#55,#56,#57))REPRESENTATION_CONTEXT('3','3D'));
+#59=SHAPE_REPRESENTATION('RULED-A2 elliptic linear-extrusion strip',(#47),#58);
+#60=SHAPE_DEFINITION_REPRESENTATION(#54,#59);
+ENDSEC;
+END-ISO-10303-21;