Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Add V2-X8.1 triangle chamfer adjacency parity lab

Yuechen Lia1689a12d9f1
diff --git a/Aetheris.Firmament.FrictionLab/CIRLab/TrianglePrismChamferAdjacencyParityLab.cs b/Aetheris.Firmament.FrictionLab/CIRLab/TrianglePrismChamferAdjacencyParityLab.cs
new file mode 100644
index 00000000..5237cf72
--- /dev/null
+++ b/Aetheris.Firmament.FrictionLab/CIRLab/TrianglePrismChamferAdjacencyParityLab.cs
@@ -0,0 +1,141 @@
+using Aetheris.Kernel.Core.Brep.EdgeFinishing;
+using Aetheris.Kernel.Core.Brep;
+using Aetheris.Kernel.Core.Geometry;
+using Aetheris.Kernel.Core.Topology;
+using Aetheris.Kernel.Firmament.Materializer;
+
+namespace Aetheris.Firmament.FrictionLab.CIRLab;
+
+public sealed record TrianglePrismAdjacencyGraphSummary(int VertexCount, int EdgeCount, int FaceCount, int PlanarFaceCount, IReadOnlyList<string> EdgeRows, IReadOnlyList<string> VertexRows);
+public sealed record TrianglePrismChamferCandidateSummary(int CornerCandidateCount, int CornerAdmissibleCount, IReadOnlyList<string> RejectionDiagnostics);
+public sealed record TrianglePrismChamferAdjacencyParityRow(string CaseName, bool LegacyProduced, bool CandidateProduced, TrianglePrismAdjacencyGraphSummary LegacyAdjacency, TrianglePrismAdjacencyGraphSummary CandidateAdjacency, TrianglePrismChamferCandidateSummary LegacyChamfer, TrianglePrismChamferCandidateSummary CandidateChamfer, bool FeatureRecognitionParity, string? FirstDivergence, IReadOnlyList<string> Diagnostics, string Recommendation);
+
+public static class TrianglePrismChamferAdjacencyParityLab
+{
+ public static IReadOnlyList<TrianglePrismChamferAdjacencyParityRow> RunAll() =>
+ [
+ Run("triangle-basic", 12, 8, 10, 0.75),
+ Run("triangle-non-orth-chamfer", 9.5, 7.25, 6.5, 0.55),
+ Run("triangle-alt", 7.5, 6.25, 4, 0.4)
+ ];
+
+ public static TrianglePrismChamferAdjacencyParityRow Run(string caseName, double width, double depth, double height, double chamferDistance)
+ {
+ var diagnostics = new List<string> { "v2-x8-1-triangle-chamfer-adjacency-lab-started", "v2-x8-1-no-3d-boolean-used" };
+
+ var legacyResult = BrepPrimitives.CreateTriangularPrism(width, depth, height);
+ var legacyBody = legacyResult.IsSuccess ? legacyResult.Value : null;
+ if (legacyBody is not null) diagnostics.Add("v2-x8-1-legacy-triangle-created");
+
+ var req = new LineArcProfileExtrudeRequest([TriangleLoop(width, depth)], height);
+ var candidateResult = LineArcProfileExtrudeEmitter.TryEmit(req);
+ var candidateBody = candidateResult.Status == LineArcProfileExtrudeStatus.Succeeded ? candidateResult.Body : null;
+ if (candidateBody is not null) diagnostics.Add("v2-x8-1-linearc-triangle-created");
+
+ if (legacyBody is null || candidateBody is null)
+ {
+ diagnostics.Add("v2-x8-1-blocker-classified:candidate-construction-bug");
+ return new(caseName, legacyBody is not null, candidateBody is not null, EmptyAdjacency(), EmptyAdjacency(), EmptyChamfer(), EmptyChamfer(), false, "body-production-failed", diagnostics, "triangle-feature-recognition-keep-legacy-route");
+ }
+
+ var legacyAdj = SummarizeAdjacency(legacyBody);
+ var candidateAdj = SummarizeAdjacency(candidateBody);
+ diagnostics.Add("v2-x8-1-adjacency-summary-captured");
+
+ var legacyChamfer = SummarizeCornerCandidates(legacyBody, chamferDistance);
+ var candidateChamfer = SummarizeCornerCandidates(candidateBody, chamferDistance);
+ diagnostics.Add("v2-x8-1-chamfer-candidates-captured");
+
+ var firstDivergence = FirstDivergence(legacyAdj, candidateAdj, legacyChamfer, candidateChamfer);
+ var parity = firstDivergence is null;
+ if (parity) diagnostics.Add("v2-x8-1-feature-recognition-parity-succeeded");
+ else
+ {
+ diagnostics.Add($"v2-x8-1-feature-recognition-parity-mismatch:{firstDivergence}");
+ diagnostics.Add($"v2-x8-1-first-divergence:{firstDivergence}");
+ }
+
+ var recommendation = parity
+ ? "triangle-feature-recognition-parity-ready"
+ : firstDivergence!.StartsWith("adjacency", StringComparison.Ordinal)
+ ? "triangle-feature-recognition-needs-adjacency-parity"
+ : "triangle-feature-recognition-needs-corner-resolution-contract";
+
+ if (!parity)
+ diagnostics.Add($"v2-x8-1-blocker-classified:{recommendation}");
+
+ return new(caseName, true, true, legacyAdj, candidateAdj, legacyChamfer, candidateChamfer, parity, firstDivergence, diagnostics.Distinct().OrderBy(x => x, StringComparer.Ordinal).ToArray(), recommendation);
+ }
+
+ private static TrianglePrismChamferCandidateSummary SummarizeCornerCandidates(BrepBody body, double distance)
+ {
+ var result = BrepBoundedChamfer.ChamferTrustedPolyhedralSingleCorner(body, BrepBoundedChamferCorner.XMaxYMaxZMax, distance);
+ var rejected = result.Diagnostics.Select(d => d.Message).OrderBy(x => x, StringComparer.Ordinal).ToArray();
+ return new(1, result.IsSuccess ? 1 : 0, rejected);
+ }
+
+ private static TrianglePrismAdjacencyGraphSummary SummarizeAdjacency(BrepBody body)
+ {
+ var edgeRows = body.Topology.Edges
+ .OrderBy(e => e.Id.Value)
+ .Select(e =>
+ {
+ var loopFace = LoopFaceMap(body);
+ var adjacentFaces = body.Topology.Coedges.Where(c => c.EdgeId == e.Id).Select(c => loopFace[c.LoopId]).Distinct().OrderBy(f => f.Value).ToArray();
+ var curveKind = body.TryGetEdgeCurve(e.Id, out var curve) && curve is not null ? curve.Kind.ToString() : "none";
+ var sp = body.TryGetVertexPoint(e.StartVertexId, out var s) ? s : default;
+ var ep = body.TryGetVertexPoint(e.EndVertexId, out var t) ? t : default;
+ return $"e:{e.Id.Value}|af:{adjacentFaces.Length}|ck:{curveKind}|s:{sp.X:F3},{sp.Y:F3},{sp.Z:F3}|e:{ep.X:F3},{ep.Y:F3},{ep.Z:F3}";
+ })
+ .ToArray();
+
+ var vertexRows = body.Topology.Vertices
+ .OrderBy(v => v.Id.Value)
+ .Select(v =>
+ {
+ var incidentEdges = body.Topology.Edges.Count(e => e.StartVertexId == v.Id || e.EndVertexId == v.Id);
+ var incidentFaces = body.Topology.Coedges.Where(c =>
+ {
+ if (!body.Topology.TryGetEdge(c.EdgeId, out var edge) || edge is null) return false;
+ return edge.StartVertexId == v.Id || edge.EndVertexId == v.Id;
+ }).Select(c => LoopFaceMap(body)[c.LoopId]).Distinct().Count();
+ return $"v:{v.Id.Value}|ie:{incidentEdges}|if:{incidentFaces}";
+ }).ToArray();
+
+ return new(body.Topology.Vertices.Count(), body.Topology.Edges.Count(), body.Topology.Faces.Count(), body.Topology.Faces.Count(f => body.GetFaceSurface(f.Id).Kind == SurfaceGeometryKind.Plane), edgeRows, vertexRows);
+ }
+
+ private static Dictionary<LoopId, FaceId> LoopFaceMap(BrepBody body)
+ {
+ var map = new Dictionary<LoopId, FaceId>();
+ foreach (var face in body.Topology.Faces)
+ foreach (var loopId in face.LoopIds)
+ map[loopId] = face.Id;
+ return map;
+ }
+
+ private static string? FirstDivergence(TrianglePrismAdjacencyGraphSummary legacyAdj, TrianglePrismAdjacencyGraphSummary candidateAdj, TrianglePrismChamferCandidateSummary legacyChamfer, TrianglePrismChamferCandidateSummary candidateChamfer)
+ {
+ if (legacyAdj.FaceCount != candidateAdj.FaceCount || legacyAdj.EdgeCount != candidateAdj.EdgeCount || legacyAdj.VertexCount != candidateAdj.VertexCount)
+ return "adjacency:topology-count-mismatch";
+ if (!legacyAdj.EdgeRows.SequenceEqual(candidateAdj.EdgeRows, StringComparer.Ordinal)) return "adjacency:edge-row-mismatch";
+ if (!legacyAdj.VertexRows.SequenceEqual(candidateAdj.VertexRows, StringComparer.Ordinal)) return "adjacency:vertex-row-mismatch";
+ if (legacyChamfer.CornerAdmissibleCount != candidateChamfer.CornerAdmissibleCount) return "corner:admissible-count-mismatch";
+ if (!legacyChamfer.RejectionDiagnostics.SequenceEqual(candidateChamfer.RejectionDiagnostics, StringComparer.Ordinal)) return "corner:rejection-diagnostic-mismatch";
+ return null;
+ }
+
+ private static LineArcProfileLoop2D TriangleLoop(double width, double depth)
+ {
+ var hw = width / 2d;
+ var hd = depth / 2d;
+ return new([
+ new LineArcLineSegment2D((-hw, -hd), (hw, -hd)),
+ new LineArcLineSegment2D((hw, -hd), (0, hd)),
+ new LineArcLineSegment2D((0, hd), (-hw, -hd))
+ ], false);
+ }
+
+ private static TrianglePrismAdjacencyGraphSummary EmptyAdjacency() => new(0, 0, 0, 0, [], []);
+ private static TrianglePrismChamferCandidateSummary EmptyChamfer() => new(0, 0, []);
+}
diff --git a/Aetheris.FrictionLab.Tests/CIRLab/TrianglePrismChamferAdjacencyParityLabTests.cs b/Aetheris.FrictionLab.Tests/CIRLab/TrianglePrismChamferAdjacencyParityLabTests.cs
new file mode 100644
index 00000000..86a1f2f3
--- /dev/null
+++ b/Aetheris.FrictionLab.Tests/CIRLab/TrianglePrismChamferAdjacencyParityLabTests.cs
@@ -0,0 +1,61 @@
+using Aetheris.Firmament.FrictionLab.CIRLab;
+
+namespace Aetheris.FrictionLab.Tests.CIRLab;
+
+public class TrianglePrismChamferAdjacencyParityLabTests
+{
+ private static string Stable(TrianglePrismChamferAdjacencyParityRow r)
+ => $"{r.CaseName}|{r.LegacyProduced}|{r.CandidateProduced}|{r.FeatureRecognitionParity}|{r.FirstDivergence}|{r.LegacyAdjacency.FaceCount}|{r.CandidateAdjacency.FaceCount}|{r.LegacyChamfer.CornerAdmissibleCount}|{r.CandidateChamfer.CornerAdmissibleCount}|{string.Join(',', r.Diagnostics)}|{r.Recommendation}";
+
+ [Fact]
+ public void Lab_IsDeterministic()
+ {
+ var a = TrianglePrismChamferAdjacencyParityLab.RunAll();
+ var b = TrianglePrismChamferAdjacencyParityLab.RunAll();
+ Assert.Equal(a.Select(Stable), b.Select(Stable));
+ }
+
+ [Fact]
+ public void Rows_ProduceLegacyAndCandidateAndCaptureDiagnostics()
+ {
+ var rows = TrianglePrismChamferAdjacencyParityLab.RunAll();
+ Assert.All(rows, row =>
+ {
+ Assert.True(row.LegacyProduced);
+ Assert.True(row.CandidateProduced);
+ Assert.Contains("v2-x8-1-no-3d-boolean-used", row.Diagnostics);
+ Assert.Contains("v2-x8-1-adjacency-summary-captured", row.Diagnostics);
+ Assert.Contains("v2-x8-1-chamfer-candidates-captured", row.Diagnostics);
+ Assert.NotEmpty(row.LegacyAdjacency.EdgeRows);
+ Assert.NotEmpty(row.CandidateAdjacency.EdgeRows);
+ });
+ }
+
+ [Fact]
+ public void Rows_ReportParityOrMismatchWithRecommendation()
+ {
+ var allowed = new HashSet<string>(StringComparer.Ordinal)
+ {
+ "triangle-feature-recognition-parity-ready",
+ "triangle-feature-recognition-needs-emitter-ordering-parity",
+ "triangle-feature-recognition-needs-adjacency-parity",
+ "triangle-feature-recognition-needs-corner-resolution-contract",
+ "triangle-feature-recognition-keep-legacy-route"
+ };
+
+ foreach (var row in TrianglePrismChamferAdjacencyParityLab.RunAll())
+ {
+ Assert.Contains(row.Recommendation, allowed);
+ if (row.FeatureRecognitionParity)
+ {
+ Assert.Equal("triangle-feature-recognition-parity-ready", row.Recommendation);
+ }
+ else
+ {
+ Assert.NotNull(row.FirstDivergence);
+ Assert.Contains(row.Diagnostics, d => d.StartsWith("v2-x8-1-feature-recognition-parity-mismatch:", StringComparison.Ordinal));
+ Assert.DoesNotContain("triangle-feature-recognition-parity-ready", row.Recommendation);
+ }
+ }
+ }
+}
diff --git a/docs/frictionlab/v2-x8-1-triangle-chamfer-adjacency-parity-lab.md b/docs/frictionlab/v2-x8-1-triangle-chamfer-adjacency-parity-lab.md
new file mode 100644
index 00000000..8d371eb0
--- /dev/null
+++ b/docs/frictionlab/v2-x8-1-triangle-chamfer-adjacency-parity-lab.md
@@ -0,0 +1,54 @@
+# V2-X8.1 — Triangle chamfer adjacency feature-recognition parity lab
+
+## Purpose and scope
+Lab-only diagnostic probe that compares legacy triangle prism construction against a `LineArcProfileExtrudeEmitter` candidate for downstream bounded chamfer/corner recognition parity. No production routing changes are included.
+
+## Why this exists
+V2-V5 attempted production migration and was reverted after non-orthogonal triangle chamfer gates failed with `No bounded corner-resolution candidate was admissible`. V2-X8 summary topology parity was therefore insufficient.
+
+## Feature-recognition parity definition
+For each case, parity means:
+- comparable topology counts,
+- comparable edge/vertex adjacency rows,
+- comparable bounded-corner admissibility outcomes,
+- no first divergence diagnostic.
+
+## Construction compared
+- Legacy: `BrepPrimitives.CreateTriangularPrism(width, depth, height)`.
+- Candidate: line-only triangle loop with coordinates `(-w/2,-d/2)`, `(w/2,-d/2)`, `(0,d/2)` routed through `LineArcProfileExtrudeEmitter.TryEmit`.
+
+## Chamfer path inspected
+The lab invokes `BrepBoundedChamfer.ChamferTrustedPolyhedralSingleCorner(..., XMaxYMaxZMax, distance)` on both bodies and captures admissibility/rejections.
+
+## Cases
+- `triangle-basic`
+- `triangle-non-orth-chamfer`
+- `triangle-alt`
+
+## Findings summary
+The lab records deterministic diagnostics:
+- `v2-x8-1-triangle-chamfer-adjacency-lab-started`
+- `v2-x8-1-legacy-triangle-created`
+- `v2-x8-1-linearc-triangle-created`
+- `v2-x8-1-adjacency-summary-captured`
+- `v2-x8-1-chamfer-candidates-captured`
+- parity success/mismatch and first-divergence payloads
+- `v2-x8-1-no-3d-boolean-used`
+- blocker classification payload when mismatch exists
+
+## Blocker classification and recommendation
+This lab emits one of:
+- `triangle-feature-recognition-parity-ready`
+- `triangle-feature-recognition-needs-adjacency-parity`
+- `triangle-feature-recognition-needs-corner-resolution-contract`
+- `triangle-feature-recognition-keep-legacy-route`
+
+## Non-goals
+- No production migration.
+- No chamfer test weakening.
+- No STEP/Boolean core changes.
+- No hex or slot migration.
+
+## Next milestone
+If parity rows stay green: prepare a tightly scoped renewed triangle production migration attempt with seam-hardening assertions.
+If parity mismatches: isolate emitter ordering/adjacency convention deltas before any production retry.
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
index a3e1a844..22b0ecea 100644
--- a/docs/frictionlab/v2-x8-triangle-hex-prism-profile-parity-lab.md
+++ b/docs/frictionlab/v2-x8-triangle-hex-prism-profile-parity-lab.md
@@ -61,3 +61,7 @@ Current lab rows are designed to provide bounded parity evidence only. Productio
## Update note (consumed by V2-V5)
Triangle parity evidence from this lab was evaluated in V2-V5; production triangle migration was reverted after downstream Firmament chamfer parity regression, so lab evidence remains preparatory rather than consumed for final routing change. Hex parity rows remain continuity evidence for a future bounded migration milestone.
+
+## Update note (V2-X8.1)
+
+Feature-recognition parity for triangle prism chamfer/corner behavior is now tracked separately in `docs/frictionlab/v2-x8-1-triangle-chamfer-adjacency-parity-lab.md` because V2-X8 summary topology parity was not sufficient for V2-V5 production migration readiness.
diff --git a/docs/v2-v5-triangle-prism-profile-extrude-production.md b/docs/v2-v5-triangle-prism-profile-extrude-production.md
index 7d337022..1b001d98 100644
--- a/docs/v2-v5-triangle-prism-profile-extrude-production.md
+++ b/docs/v2-v5-triangle-prism-profile-extrude-production.md
@@ -51,3 +51,7 @@ Observed effect:
## Next recommended migration
- Resolve triangle chamfer adjacency/parity at the emitter-integration seam first.
- Keep V2-X8 hex parity continuity; then proceed to likely V2-V6 hex migration only after triangle seam parity strategy is proven safe.
+
+## Update note (V2-X8.1)
+
+A dedicated follow-up lab now probes triangle chamfer adjacency/corner feature-recognition parity between legacy and line-arc candidate paths: `docs/frictionlab/v2-x8-1-triangle-chamfer-adjacency-parity-lab.md`.