Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Add V2-X8 triangle/hex prism parity lab and tests

Yuechen Li1c7cd94cc2cd
diff --git a/Aetheris.Firmament.FrictionLab/CIRLab/TriangleHexPrismProfileParityLab.cs b/Aetheris.Firmament.FrictionLab/CIRLab/TriangleHexPrismProfileParityLab.cs
new file mode 100644
index 00000000..bf651ad6
--- /dev/null
+++ b/Aetheris.Firmament.FrictionLab/CIRLab/TriangleHexPrismProfileParityLab.cs
@@ -0,0 +1,119 @@
+using Aetheris.Kernel.Core.Brep;
+using Aetheris.Kernel.Core.Geometry;
+using Aetheris.Kernel.Core.Step242;
+using Aetheris.Kernel.Firmament.Materializer;
+
+namespace Aetheris.Firmament.FrictionLab.CIRLab;
+
+public sealed record PrismProfileParityCase(string Name, PrismKind Kind, double SizeA, double SizeB, double Height, bool IsValidExpected);
+public enum PrismKind { Triangle, Hex }
+public sealed record PrismProfileTopologySummary(bool BodyProduced, int VertexCount, int EdgeCount, int FaceCount, int PlanarFaceCount, int CylindricalFaceCount, int LoopCount, int CoedgeCount, (double X,double Y,double Z) Min, (double X,double Y,double Z) Max);
+public sealed record PrismProfileStepSmokeSummary(bool Exported, IReadOnlyList<string> PresentMarkers, IReadOnlyList<string> MissingMarkers, bool ContainsBrepWithVoids, bool ContainsCylindricalSurface);
+public sealed record PrismProfileParityRow(string CaseName, PrismKind Kind, bool IsValidInput, bool BaselineSucceeded, bool CandidateSucceeded, PrismProfileTopologySummary BaselineTopology, PrismProfileTopologySummary CandidateTopology, bool TopologyParityWithBaseline, PrismProfileStepSmokeSummary StepSmoke, IReadOnlyList<string> Diagnostics, string Recommendation);
+
+public static class TriangleHexPrismProfileParityLab
+{
+ private static readonly string[] RequiredStepMarkers = ["ISO-10303-21", "MANIFOLD_SOLID_BREP", "ADVANCED_FACE", "PLANE"];
+
+ public static IReadOnlyList<PrismProfileParityRow> RunAll() =>
+ [
+ Run(new("triangle-basic", PrismKind.Triangle, 12, 8, 10, true)),
+ Run(new("triangle-alt", PrismKind.Triangle, 7.5, 6.25, 4, true)),
+ Run(new("hex-basic", PrismKind.Hex, 10, 0, 12, true)),
+ Run(new("hex-alt", PrismKind.Hex, 6.5, 0, 3.5, true)),
+ Run(new("triangle-invalid-height", PrismKind.Triangle, 10, 8, 0, false)),
+ Run(new("hex-invalid-size", PrismKind.Hex, -2, 0, 4, false)),
+ Run(new("triangle-invalid-nan", PrismKind.Triangle, double.NaN, 8, 4, false))
+ ];
+
+ public static PrismProfileParityRow Run(PrismProfileParityCase c)
+ {
+ var d = new List<string> { "v2-x8-prism-profile-parity-lab-started", "v2-x8-no-3d-boolean-used" };
+ var baseline = BuildBaseline(c, d);
+ var candidate = BuildCandidate(c, d);
+ if (!baseline.IsSuccess || !candidate.IsSuccess)
+ {
+ d.Add("v2-x8-invalid-input-rejected");
+ return new(c.Name, c.Kind, false, baseline.IsSuccess, candidate.IsSuccess,
+ baseline.Topology, candidate.Topology, false, EmptyStep(), d.Distinct().OrderBy(x => x).ToArray(), "prism-profile-invalid-rejected");
+ }
+
+ var topologyParity = baseline.Topology == candidate.Topology;
+ if (topologyParity) d.Add("v2-x8-topology-parity-succeeded");
+ else d.Add($"v2-x8-topology-parity-mismatch:{c.Name}");
+
+ var step = SummarizeStep(candidate.Body!);
+ if (step.Exported && step.MissingMarkers.Count == 0 && !step.ContainsBrepWithVoids && !step.ContainsCylindricalSurface) d.Add("v2-x8-step-smoke-succeeded");
+ else d.Add($"v2-x8-step-smoke-failed:{c.Name}");
+
+ var recommendation = topologyParity && step.Exported && step.MissingMarkers.Count == 0 && !step.ContainsBrepWithVoids && !step.ContainsCylindricalSurface
+ ? "prism-profile-ready-for-production-migration"
+ : "prism-profile-needs-emitter-parity-work";
+
+ return new(c.Name, c.Kind, true, true, true, baseline.Topology, candidate.Topology, topologyParity, step, d.Distinct().OrderBy(x => x).ToArray(), recommendation);
+ }
+
+ private static (bool IsSuccess, BrepBody? Body, PrismProfileTopologySummary Topology) BuildBaseline(PrismProfileParityCase c, List<string> d)
+ {
+ var result = c.Kind == PrismKind.Triangle ? BrepPrimitives.CreateTriangularPrism(c.SizeA, c.SizeB, c.Height) : BrepPrimitives.CreateHexagonalPrism(c.SizeA, c.Height);
+ d.Add(c.Kind == PrismKind.Triangle ? "v2-x8-baseline-triangle-created" : "v2-x8-baseline-hex-created");
+ return !result.IsSuccess || result.Value is null ? (false, null, EmptyTopology()) : (true, result.Value, SummarizeTopology(result.Value));
+ }
+
+ private static (bool IsSuccess, BrepBody? Body, PrismProfileTopologySummary Topology) BuildCandidate(PrismProfileParityCase c, List<string> d)
+ {
+ var req = new LineArcProfileExtrudeRequest([ToLoop(c)], c.Height);
+ d.Add("v2-x8-line-profile-adapted");
+ var result = LineArcProfileExtrudeEmitter.TryEmit(req);
+ d.Add(c.Kind == PrismKind.Triangle ? "v2-x8-candidate-triangle-created" : "v2-x8-candidate-hex-created");
+ return result.Status != LineArcProfileExtrudeStatus.Succeeded || result.Body is null ? (false, null, EmptyTopology()) : (true, result.Body, SummarizeTopology(result.Body));
+ }
+
+ private static LineArcProfileLoop2D ToLoop(PrismProfileParityCase c)
+ {
+ if (c.Kind == PrismKind.Triangle)
+ {
+ var hw = c.SizeA / 2d; var hd = c.SizeB / 2d;
+ return new([
+ new LineArcLineSegment2D((-hw, -hd), (hw, -hd)),
+ new LineArcLineSegment2D((hw, -hd), (0, hd)),
+ new LineArcLineSegment2D((0, hd), (-hw, -hd))
+ ], false);
+ }
+
+ var r = c.SizeA / Math.Sqrt(3d);
+ var pts = Enumerable.Range(0, 6).Select(i => (r * Math.Cos(Math.PI * i / 3d), r * Math.Sin(Math.PI * i / 3d))).ToArray();
+ return new([
+ new LineArcLineSegment2D(pts[0], pts[1]),
+ new LineArcLineSegment2D(pts[1], pts[2]),
+ new LineArcLineSegment2D(pts[2], pts[3]),
+ new LineArcLineSegment2D(pts[3], pts[4]),
+ new LineArcLineSegment2D(pts[4], pts[5]),
+ new LineArcLineSegment2D(pts[5], pts[0])
+ ], false);
+ }
+
+ private static PrismProfileTopologySummary SummarizeTopology(BrepBody body)
+ {
+ var verts = body.Topology.Vertices.Count(); var edges = body.Topology.Edges.Count(); var faces = body.Topology.Faces.Count();
+ var planar = body.Topology.Faces.Count(f => body.GetFaceSurface(f.Id).Kind == SurfaceGeometryKind.Plane);
+ var cyl = body.Topology.Faces.Count(f => body.GetFaceSurface(f.Id).Kind == SurfaceGeometryKind.Cylinder);
+ var loops = body.Topology.Loops.Count(); var coedges = body.Topology.Coedges.Count();
+ var points = body.Topology.Vertices.Select(v => body.TryGetVertexPoint(v.Id, out var p) ? p : default).ToArray();
+ var minX = points.Min(p => p.X); var minY = points.Min(p => p.Y); var minZ = points.Min(p => p.Z);
+ var maxX = points.Max(p => p.X); var maxY = points.Max(p => p.Y); var maxZ = points.Max(p => p.Z);
+ return new(true, verts, edges, faces, planar, cyl, loops, coedges, (minX,minY,minZ), (maxX,maxY,maxZ));
+ }
+
+ private static PrismProfileStepSmokeSummary SummarizeStep(BrepBody body)
+ {
+ var ex = Step242Exporter.ExportBody(body);
+ if (!ex.IsSuccess || ex.Value is null) return new(false, [], RequiredStepMarkers, false, false);
+ var txt = ex.Value;
+ var present = RequiredStepMarkers.Where(m => txt.Contains(m, StringComparison.Ordinal)).OrderBy(x => x).ToArray();
+ return new(true, present, RequiredStepMarkers.Except(present).OrderBy(x=>x).ToArray(), txt.Contains("BREP_WITH_VOIDS", StringComparison.Ordinal), txt.Contains("CYLINDRICAL_SURFACE", StringComparison.Ordinal));
+ }
+
+ private static PrismProfileTopologySummary EmptyTopology() => new(false, 0, 0, 0, 0, 0, 0, 0, (0,0,0), (0,0,0));
+ private static PrismProfileStepSmokeSummary EmptyStep() => new(false, [], [], false, false);
+}
diff --git a/Aetheris.FrictionLab.Tests/CIRLab/TriangleHexPrismProfileParityLabTests.cs b/Aetheris.FrictionLab.Tests/CIRLab/TriangleHexPrismProfileParityLabTests.cs
new file mode 100644
index 00000000..9480825f
--- /dev/null
+++ b/Aetheris.FrictionLab.Tests/CIRLab/TriangleHexPrismProfileParityLabTests.cs
@@ -0,0 +1,80 @@
+using Aetheris.Firmament.FrictionLab.CIRLab;
+
+namespace Aetheris.FrictionLab.Tests.CIRLab;
+
+public class TriangleHexPrismProfileParityLabTests
+{
+ private static string Stable(PrismProfileParityRow r)
+ => $"{r.CaseName}|{r.Kind}|{r.IsValidInput}|{r.BaselineSucceeded}|{r.CandidateSucceeded}|{r.TopologyParityWithBaseline}|{r.BaselineTopology.FaceCount}|{r.CandidateTopology.FaceCount}|{r.BaselineTopology.PlanarFaceCount}|{r.CandidateTopology.PlanarFaceCount}|{r.StepSmoke.Exported}|{string.Join(',', r.Diagnostics)}|{r.Recommendation}";
+
+ [Fact]
+ public void PrismProfileParityLab_IsDeterministic()
+ {
+ var a = TriangleHexPrismProfileParityLab.RunAll();
+ var b = TriangleHexPrismProfileParityLab.RunAll();
+ Assert.Equal(a.Select(Stable), b.Select(Stable));
+ }
+
+ [Fact]
+ public void TriangleAndHex_ValidRows_ProduceBodiesAndNo3DBoolean()
+ {
+ var rows = TriangleHexPrismProfileParityLab.RunAll().Where(r => r.IsValidInput).ToArray();
+ Assert.All(rows, row =>
+ {
+ Assert.True(row.BaselineSucceeded);
+ Assert.True(row.CandidateSucceeded);
+ Assert.Contains("v2-x8-no-3d-boolean-used", row.Diagnostics);
+ Assert.True(row.StepSmoke.Exported);
+ });
+
+ Assert.All(rows.Where(x => x.Kind == PrismKind.Triangle), row =>
+ {
+ Assert.Equal(5, row.CandidateTopology.PlanarFaceCount);
+ Assert.Equal(0, row.CandidateTopology.CylindricalFaceCount);
+ });
+
+ Assert.All(rows.Where(x => x.Kind == PrismKind.Hex), row =>
+ {
+ Assert.Equal(8, row.CandidateTopology.PlanarFaceCount);
+ Assert.Equal(0, row.CandidateTopology.CylindricalFaceCount);
+ });
+ }
+
+ [Fact]
+ public void ValidRows_ReportParityOrExplicitMismatch()
+ {
+ var rows = TriangleHexPrismProfileParityLab.RunAll().Where(r => r.IsValidInput).ToArray();
+ Assert.All(rows, row =>
+ {
+ if (!row.TopologyParityWithBaseline)
+ {
+ Assert.Contains(row.Diagnostics, d => d.StartsWith("v2-x8-topology-parity-mismatch:", StringComparison.Ordinal));
+ }
+ });
+ }
+
+ [Fact]
+ public void InvalidRows_AreRejectedDeterministically()
+ {
+ var rows = TriangleHexPrismProfileParityLab.RunAll().Where(r => !r.IsValidInput).ToArray();
+ Assert.NotEmpty(rows);
+ Assert.All(rows, row =>
+ {
+ Assert.Equal("prism-profile-invalid-rejected", row.Recommendation);
+ Assert.Contains("v2-x8-invalid-input-rejected", row.Diagnostics);
+ });
+ }
+
+ [Fact]
+ public void Recommendations_AreFinite()
+ {
+ var allowed = new HashSet<string>(StringComparer.Ordinal)
+ {
+ "prism-profile-ready-for-production-migration",
+ "prism-profile-needs-emitter-parity-work",
+ "prism-profile-invalid-rejected",
+ "prism-profile-deferred-convention-mismatch"
+ };
+ Assert.All(TriangleHexPrismProfileParityLab.RunAll(), row => Assert.Contains(row.Recommendation, allowed));
+ }
+}
diff --git a/docs/frictionlab/v2-x8-triangle-hex-prism-profile-parity-lab.md b/docs/frictionlab/v2-x8-triangle-hex-prism-profile-parity-lab.md
new file mode 100644
index 00000000..814a7733
--- /dev/null
+++ b/docs/frictionlab/v2-x8-triangle-hex-prism-profile-parity-lab.md
@@ -0,0 +1,58 @@
+# V2-X8 — Triangle/hex prism line-profile extrusion parity lab
+
+## Purpose and scope
+Lab-only parity probe compares existing triangle/hex prism baseline constructors against candidate emission through `LineArcProfileExtrudeEmitter` using resolved line-only loops. No production routing is changed.
+
+## Doctrine and prior milestone references
+- V2 doctrine: `docs/aetheris-v2-sweep-first-architecture.md`
+- V2-A1: `docs/aetheris-v2-a1-resolved-profile2d-contract.md`
+- V2-X7: `docs/frictionlab/v2-x7-line-arc-profile-extrude-lab.md`
+- V2-V4: `docs/v2-v4-line-arc-profile-extrude-production-evaluation.md`
+- V2-A2: `docs/v2-a2-prismatic-operation-migration-audit.md`
+
+Triangle then hex were chosen because both are line-only outer loops with existing fixture/test evidence and bounded planar topology expectations.
+
+## Baseline and candidate paths
+- Baseline triangle: `BrepPrimitives.CreateTriangularPrism(baseWidth, baseDepth, height)`.
+- Baseline hex: `BrepPrimitives.CreateHexagonalPrism(acrossFlats, height)`.
+- Candidate path: adapt same profile convention into one non-hole `LineArcProfileLoop2D`, then call `LineArcProfileExtrudeEmitter.TryEmit`.
+
+## Coordinate convention findings
+- Triangle: `( -w/2,-d/2 ) -> ( +w/2,-d/2 ) -> ( 0,+d/2 )`, centered along Z via symmetric height.
+- Hex: regular hex with circumradius `acrossFlats/sqrt(3)` and angles `k*pi/3`, centered at origin and symmetric in Z.
+
+## Test cases and results
+Cases include two valid triangle dimensions, two valid hex dimensions, and invalid height/size/non-finite rows. Lab rows are deterministic across repeat runs and include deterministic diagnostics.
+
+## Topology parity findings
+For valid rows, baseline and candidate topology summaries are compared on:
+- body produced,
+- vertex/edge/face counts,
+- planar/cylindrical face counts,
+- loop/coedge counts,
+- extents.
+
+If mismatch occurs, diagnostic `v2-x8-topology-parity-mismatch:<case>` is emitted.
+
+## STEP smoke findings
+Candidate bodies are STEP-smoke checked for:
+- required markers: `ISO-10303-21`, `MANIFOLD_SOLID_BREP`, `ADVANCED_FACE`, `PLANE`;
+- exclusion markers: `CYLINDRICAL_SURFACE`, `BREP_WITH_VOIDS`.
+
+## Invalid/deferred handling
+Invalid numeric inputs reject deterministically and emit `v2-x8-invalid-input-rejected` with recommendation `prism-profile-invalid-rejected`.
+
+## Migration readiness statement
+Current lab rows are designed to provide bounded parity evidence only. Production migration decision should use this parity output plus existing fixture/build-export coverage.
+
+## Non-goals
+- no production routing migration,
+- no slot migration,
+- no full clipping engine,
+- no STEP exporter change,
+- no Boolean core change.
+
+## Recommended next step
+- If parity rows remain fully green: proceed to V2-V5 triangle production migration candidate.
+- Then V2-V6 hex production migration candidate.
+- If mismatch appears: harden emitter/convention mapping before production migration.
diff --git a/docs/v2-a2-prismatic-operation-migration-audit.md b/docs/v2-a2-prismatic-operation-migration-audit.md
index f650c7e0..35489a85 100644
--- a/docs/v2-a2-prismatic-operation-migration-audit.md
+++ b/docs/v2-a2-prismatic-operation-migration-audit.md
@@ -206,3 +206,7 @@ This milestone explicitly does **not** do:
- NURBS/freeform support,
- STEP exporter/importer or Boolean core changes,
- blind/counterbore/stepped/cross-axis expansion.
+
+## Update note (V2-X8)
+
+V2-X8 lab-only parity probe added for triangle/hex prism baseline-vs-emitter comparison (line-only loops), with deterministic topology + STEP smoke diagnostics and invalid input rejection rows. No production routing changed.