Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Package prismatic section transition emitter

Yuechen Lie822fdfbaf71
diff --git a/Aetheris.Firmament.FrictionLab/CIRLab/PrismaticSectionTransitionEmitterLab.cs b/Aetheris.Firmament.FrictionLab/CIRLab/PrismaticSectionTransitionEmitterLab.cs
index 11292d01..fa6cd811 100644
--- a/Aetheris.Firmament.FrictionLab/CIRLab/PrismaticSectionTransitionEmitterLab.cs
+++ b/Aetheris.Firmament.FrictionLab/CIRLab/PrismaticSectionTransitionEmitterLab.cs
@@ -1,10 +1,4 @@
-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;
+using CorePrismatic = Aetheris.Kernel.Core.Brep.Prismatic;
namespace Aetheris.Firmament.FrictionLab.CIRLab;
@@ -57,21 +51,17 @@ public sealed record PrismaticSectionTransitionRow(
public static class PrismaticSectionTransitionEmitterLab
{
- private const double Tol = 1e-9;
-
public static readonly string[] AllowedRecommendations =
[
"prismatic-section-transition-ready-for-production-evaluation",
"prismatic-section-transition-generic-ready-for-production-evaluation",
+ "prismatic-section-transition-ready-for-controlled-route-evaluation",
"prismatic-section-transition-needs-profile-validation-hardening",
"prismatic-section-transition-needs-correspondence-hardening",
"prismatic-section-transition-invalid-rejected",
"prismatic-section-transition-deferred",
];
- private static readonly string[] RequiredStepMarkers = ["ISO-10303-21", "MANIFOLD_SOLID_BREP", "ADVANCED_FACE", "PLANE"];
- private static readonly string[] ForbiddenStepMarkers = ["CYLINDRICAL_SURFACE", "BREP_WITH_VOIDS"];
-
public static IReadOnlyList<PrismaticSectionTransitionRow> RunAll() =>
[
Run(RectangleToInsetRectangle()),
@@ -80,6 +70,7 @@ public static class PrismaticSectionTransitionEmitterLab
Run(ScaledHexagon()),
Run(AsymmetricTranslatedPentagon()),
Run(new("invalid-non-increasing-z", [RectangleSection(0, 10, 8), RectangleSection(0, 8, 6)], PrismaticCorrespondenceMap.Identity(4))),
+ Run(new("invalid-zero-interval", [RectangleSection(0, 10, 8), RectangleSection(0, 8, 6)], PrismaticCorrespondenceMap.Identity(4))),
Run(new("invalid-mismatched-vertex-count", [RectangleSection(0, 10, 8), RegularPolygonSection(1, 5, 5)], PrismaticCorrespondenceMap.Identity(4))),
Run(new("invalid-missing-correspondence", [RectangleSection(0, 10, 8), RectangleSection(1, 8, 6)], null)),
Run(new("invalid-self-intersecting-profile", [new PrismaticSection(0, [(0, 0), (2, 2), (0, 2), (2, 0)]), RectangleSection(1, 8, 6)], PrismaticCorrespondenceMap.Identity(4))),
@@ -110,330 +101,103 @@ public static class PrismaticSectionTransitionEmitterLab
public static PrismaticSectionTransitionRow Run(PrismaticSectionTransitionCase c)
{
- var diagnostics = new List<string>
- {
- "edge-prismatic-x1-lab-started",
- "edge-prismatic-x3-generic-lab-started",
- $"edge-prismatic-x3-case-started:{c.Name}",
- };
- var validation = Validate(c, diagnostics);
- if (validation.Status != LabProfileStatus.Succeeded)
- {
- return Stop(c.Name, validation.Status, diagnostics, validation.Recommendation);
- }
-
- diagnostics.Add("edge-prismatic-x1-correspondence-created");
- diagnostics.Add("edge-prismatic-x3-correspondence-created");
- diagnostics.Add("edge-prismatic-x3-section-stack-created");
- for (var i = 0; i < c.Sections.Count - 1; i++)
- {
- diagnostics.Add("edge-prismatic-x1-transition-interval-created");
- }
-
- diagnostics.Add("edge-prismatic-x3-prismatic-emitter-invoked");
- var built = PrismaticSectionTransitionEmitter.TryEmit(c.Sections, c.Correspondence!);
- if (built.Body is null)
- {
- diagnostics.Add($"edge-prismatic-x1-transition-face-emission-failed:{built.Diagnostic}");
- return Stop(c.Name, LabProfileStatus.Failed, diagnostics, "prismatic-section-transition-needs-profile-validation-hardening");
- }
-
- diagnostics.Add("edge-prismatic-x1-cap-faces-created");
- diagnostics.Add("edge-prismatic-x1-transition-faces-created");
- diagnostics.Add("edge-prismatic-x1-body-created");
- diagnostics.Add("edge-prismatic-x3-body-created");
- diagnostics.Add("edge-prismatic-x1-no-air-edge-sweep-used");
- diagnostics.Add("edge-prismatic-x3-no-air-edge-sweep-used");
- diagnostics.Add("edge-prismatic-x1-no-brep-bounded-chamfer-used");
- diagnostics.Add("edge-prismatic-x3-no-brep-bounded-chamfer-used");
- diagnostics.Add("edge-prismatic-x1-no-topology-graft-used");
- diagnostics.Add("edge-prismatic-x3-no-topology-graft-used");
- diagnostics.Add("edge-prismatic-x1-no-3d-boolean-used");
- diagnostics.Add("edge-prismatic-x3-no-3d-boolean-used");
-
- var topology = SummarizeTopology(built.Body, c.Sections);
- var step = SummarizeStep(built.Body);
- var stepSucceeded = step.Exported && step.MissingRequiredMarkers.Count == 0 && step.UnexpectedPresentMarkers.Count == 0;
- diagnostics.Add(stepSucceeded ? "edge-prismatic-x1-step-smoke-succeeded" : "edge-prismatic-x1-step-smoke-failed:markers");
- diagnostics.Add(stepSucceeded ? "edge-prismatic-x3-step-smoke-succeeded" : "edge-prismatic-x3-step-smoke-failed:markers");
-
- var n = c.Sections[0].OuterLoop.Count;
- var sectionCount = c.Sections.Count;
- var expectedFaces = 2 + ((sectionCount - 1) * n);
- var topologySucceeded = topology.BodyProduced
- && topology.SectionCount == sectionCount
- && topology.VertexCount == sectionCount * n
- && topology.EdgeCount == (sectionCount * n) + ((sectionCount - 1) * n)
- && topology.TransitionEdgeCount == (sectionCount - 1) * n
- && topology.CapFaceCount == 2
- && topology.TransitionFaceCount == (sectionCount - 1) * n
- && topology.FaceCount == expectedFaces
- && topology.PlanarFaceCount == expectedFaces
- && topology.CylindricalFaceCount == 0
- && topology.LoopCount == expectedFaces
- && topology.CoedgeCount == (2 * n) + (4 * (sectionCount - 1) * n);
-
- if (topologySucceeded)
- {
- diagnostics.Add("edge-prismatic-x3-topology-formula-validated");
- }
+ var request = new CorePrismatic.PrismaticSectionTransitionRequest(
+ c.Sections.Select(s => new CorePrismatic.PrismaticSection(s.Z, s.OuterLoop, s.HasHoles, s.HasArcs, s.OuterLoopCount)).ToArray(),
+ c.Correspondence is null ? null : new CorePrismatic.PrismaticCorrespondenceMap(c.Correspondence.VertexMap),
+ new CorePrismatic.PrismaticSectionTransitionOptions(RunStepSmoke: true, TraceLabel: c.Name));
+ var result = CorePrismatic.PrismaticSectionTransitionEmitter.Emit(request);
+ var recommendation = result.Recommendation == "prismatic-section-transition-ready-for-controlled-route-evaluation"
+ ? "prismatic-section-transition-generic-ready-for-production-evaluation"
+ : result.Recommendation;
return new(
c.Name,
- LabProfileStatus.Succeeded,
- topologySucceeded && stepSucceeded,
- topology,
- step,
- StableDiagnostics(diagnostics),
- topologySucceeded && stepSucceeded
- ? "prismatic-section-transition-generic-ready-for-production-evaluation"
- : "prismatic-section-transition-needs-profile-validation-hardening");
- }
-
- private static (LabProfileStatus Status, string Recommendation) Validate(PrismaticSectionTransitionCase c, List<string> diagnostics)
- {
- if (c.Sections.Count is < 2 or > 3)
- {
- diagnostics.Add("edge-prismatic-x1-invalid-section-rejected");
- diagnostics.Add("edge-prismatic-x3-invalid-profile-rejected");
- return (LabProfileStatus.Failed, "prismatic-section-transition-invalid-rejected");
- }
-
- foreach (var section in c.Sections)
- {
- if (section.HasHoles)
- {
- diagnostics.Add("edge-prismatic-x1-holes-deferred");
- diagnostics.Add("edge-prismatic-x3-holes-deferred");
- return (LabProfileStatus.Deferred, "prismatic-section-transition-deferred");
- }
-
- if (section.HasArcs)
- {
- diagnostics.Add("edge-prismatic-x1-line-arc-deferred");
- diagnostics.Add("edge-prismatic-x3-line-arc-deferred");
- return (LabProfileStatus.Deferred, "prismatic-section-transition-deferred");
- }
-
- if (section.OuterLoopCount != 1)
- {
- diagnostics.Add("edge-prismatic-x1-multiple-loops-deferred");
- diagnostics.Add("edge-prismatic-x3-multiple-loops-deferred");
- return (LabProfileStatus.Deferred, "prismatic-section-transition-deferred");
- }
-
- if (!ValidateProfile(section, out var profileDiagnostic))
- {
- diagnostics.Add(profileDiagnostic);
- diagnostics.Add("edge-prismatic-x3-invalid-profile-rejected");
- return (LabProfileStatus.Failed, "prismatic-section-transition-invalid-rejected");
- }
-
- diagnostics.Add("edge-prismatic-x1-section-validated");
- }
-
- for (var i = 0; i < c.Sections.Count; i++)
- {
- if (!double.IsFinite(c.Sections[i].Z))
- {
- diagnostics.Add("edge-prismatic-x1-invalid-section-rejected");
- diagnostics.Add("edge-prismatic-x3-invalid-profile-rejected");
- return (LabProfileStatus.Failed, "prismatic-section-transition-invalid-rejected");
- }
-
- if (i > 0 && c.Sections[i].Z <= c.Sections[i - 1].Z + Tol)
- {
- diagnostics.Add("edge-prismatic-x1-non-increasing-sections-rejected");
- diagnostics.Add("edge-prismatic-x3-non-increasing-sections-rejected");
- return (LabProfileStatus.Failed, "prismatic-section-transition-invalid-rejected");
- }
- }
-
- var vertexCount = c.Sections[0].OuterLoop.Count;
- if (c.Sections.Any(s => s.OuterLoop.Count != vertexCount))
- {
- diagnostics.Add("edge-prismatic-x1-mismatched-vertex-count-rejected");
- diagnostics.Add("edge-prismatic-x3-mismatched-vertex-count-rejected");
- return (LabProfileStatus.Failed, "prismatic-section-transition-invalid-rejected");
- }
-
- var orientation = SignedArea(c.Sections[0].OuterLoop) > 0d;
- if (c.Sections.Skip(1).Any(s => (SignedArea(s.OuterLoop) > 0d) != orientation))
- {
- diagnostics.Add("edge-prismatic-x1-invalid-profile-rejected");
- diagnostics.Add("edge-prismatic-x3-invalid-profile-rejected");
- return (LabProfileStatus.Failed, "prismatic-section-transition-invalid-rejected");
- }
-
- if (c.Correspondence is null || c.Correspondence.VertexMap.Count != vertexCount || !c.Correspondence.VertexMap.SequenceEqual(Enumerable.Range(0, vertexCount)))
- {
- diagnostics.Add("edge-prismatic-x1-missing-correspondence-rejected");
- diagnostics.Add("edge-prismatic-x3-missing-correspondence-rejected");
- return (LabProfileStatus.Failed, c.Correspondence is null ? "prismatic-section-transition-invalid-rejected" : "prismatic-section-transition-needs-correspondence-hardening");
- }
-
- if (!AllTransitionFacesPlanar(c.Sections))
- {
- diagnostics.Add("edge-prismatic-x1-invalid-profile-rejected");
- diagnostics.Add("edge-prismatic-x3-invalid-profile-rejected");
- return (LabProfileStatus.Failed, "prismatic-section-transition-needs-profile-validation-hardening");
- }
-
- return (LabProfileStatus.Succeeded, "");
+ ToLabStatus(result.Status),
+ result.Status == CorePrismatic.PrismaticSectionTransitionStatus.Succeeded,
+ ToLabTopology(result.Topology),
+ ToLabStep(result.Step),
+ StableDiagnostics(result.Diagnostics.Concat(LabDiagnostics(c.Name, result.Diagnostics))),
+ recommendation);
}
- private static bool ValidateProfile(PrismaticSection section, out string diagnostic)
+ private static IReadOnlyList<string> LabDiagnostics(string caseName, IReadOnlyList<string> v1Diagnostics)
{
- diagnostic = "edge-prismatic-x1-invalid-profile-rejected";
- var loop = section.OuterLoop;
- if (loop.Count < 4 || !double.IsFinite(section.Z))
- {
- return false;
- }
-
- foreach (var point in loop)
- {
- if (!double.IsFinite(point.X) || !double.IsFinite(point.Y))
- {
- return false;
- }
- }
-
- for (var i = 0; i < loop.Count; i++)
- {
- var next = (i + 1) % loop.Count;
- if (Distance(loop[i], loop[next]) <= Tol)
- {
- return false;
- }
- }
-
- if (Math.Abs(SignedArea(loop)) <= Tol)
- {
- return false;
- }
-
- for (var i = 0; i < loop.Count; i++)
- {
- var i2 = (i + 1) % loop.Count;
- for (var j = i + 1; j < loop.Count; j++)
- {
- var j2 = (j + 1) % loop.Count;
- if (i == j || i2 == j || i == j2)
- {
- continue;
- }
-
- if (i == 0 && j2 == 0)
- {
- continue;
- }
-
- if (SegmentsIntersect(loop[i], loop[i2], loop[j], loop[j2]))
- {
- return false;
- }
- }
- }
-
- return true;
- }
-
- private static PrismaticTransitionTopologySummary SummarizeTopology(BrepBody body, IReadOnlyList<PrismaticSection> sections)
- {
- var faceCount = body.Topology.Faces.Count();
- var planarFaceCount = body.Topology.Faces.Count(f => body.GetFaceSurface(f.Id).Kind == SurfaceGeometryKind.Plane);
- var cylindricalFaceCount = body.Topology.Faces.Count(f => body.GetFaceSurface(f.Id).Kind == SurfaceGeometryKind.Cylinder);
- var n = sections[0].OuterLoop.Count;
- var stableFaces = 0;
- var changedFaces = 0;
- for (var s = 0; s < sections.Count - 1; s++)
+ var diagnostics = new List<string>
{
- for (var i = 0; i < n; i++)
- {
- var next = (i + 1) % n;
- if (SamePoint(sections[s].OuterLoop[i], sections[s + 1].OuterLoop[i]) && SamePoint(sections[s].OuterLoop[next], sections[s + 1].OuterLoop[next]))
- {
- stableFaces++;
- }
- else
- {
- changedFaces++;
- }
- }
- }
+ "edge-prismatic-x1-lab-started",
+ "edge-prismatic-x3-generic-lab-started",
+ $"edge-prismatic-x3-case-started:{caseName}",
+ };
- var allX = sections.SelectMany(s => s.OuterLoop.Select(p => p.X)).ToArray();
- var allY = sections.SelectMany(s => s.OuterLoop.Select(p => p.Y)).ToArray();
- return new(
- true,
- sections.Count,
- body.Topology.Vertices.Count(),
- body.Topology.Edges.Count(),
- n,
- n,
- (sections.Count - 1) * n,
- 2,
- (sections.Count - 1) * n,
- stableFaces,
- changedFaces,
- faceCount,
- planarFaceCount,
- cylindricalFaceCount,
- body.Topology.Loops.Count(),
- body.Topology.Coedges.Count(),
- FormattableString.Invariant($"[{allX.Min():0.###},{allY.Min():0.###},{sections.Min(s => s.Z):0.###}]..[{allX.Max():0.###},{allY.Max():0.###},{sections.Max(s => s.Z):0.###}]"));
+ if (v1Diagnostics.Contains("edge-prismatic-v1-correspondence-validated"))
+ {
+ diagnostics.Add("edge-prismatic-x1-correspondence-created");
+ diagnostics.Add("edge-prismatic-x3-correspondence-created");
+ diagnostics.Add("edge-prismatic-x3-section-stack-created");
+ }
+
+ AddIf(v1Diagnostics, diagnostics, "edge-prismatic-v1-section-validated", "edge-prismatic-x1-section-validated");
+ AddIf(v1Diagnostics, diagnostics, "edge-prismatic-v1-transition-interval-created", "edge-prismatic-x1-transition-interval-created");
+ AddIf(v1Diagnostics, diagnostics, "edge-prismatic-v1-cap-faces-created", "edge-prismatic-x1-cap-faces-created");
+ AddIf(v1Diagnostics, diagnostics, "edge-prismatic-v1-transition-faces-created", "edge-prismatic-x1-transition-faces-created");
+ AddIf(v1Diagnostics, diagnostics, "edge-prismatic-v1-body-created", "edge-prismatic-x1-body-created", "edge-prismatic-x3-body-created", "edge-prismatic-x3-prismatic-emitter-invoked");
+ AddIf(v1Diagnostics, diagnostics, "edge-prismatic-v1-step-smoke-succeeded", "edge-prismatic-x1-step-smoke-succeeded", "edge-prismatic-x3-step-smoke-succeeded");
+ AddIf(v1Diagnostics, diagnostics, "edge-prismatic-v1-topology-validated", "edge-prismatic-x3-topology-formula-validated");
+ AddIf(v1Diagnostics, diagnostics, "edge-prismatic-v1-no-air-edge-sweep-used", "edge-prismatic-x1-no-air-edge-sweep-used", "edge-prismatic-x3-no-air-edge-sweep-used");
+ AddIf(v1Diagnostics, diagnostics, "edge-prismatic-v1-no-brep-bounded-chamfer-used", "edge-prismatic-x1-no-brep-bounded-chamfer-used", "edge-prismatic-x3-no-brep-bounded-chamfer-used");
+ AddIf(v1Diagnostics, diagnostics, "edge-prismatic-v1-no-topology-graft-used", "edge-prismatic-x1-no-topology-graft-used", "edge-prismatic-x3-no-topology-graft-used");
+ AddIf(v1Diagnostics, diagnostics, "edge-prismatic-v1-no-3d-boolean-used", "edge-prismatic-x1-no-3d-boolean-used", "edge-prismatic-x3-no-3d-boolean-used");
+ AddIf(v1Diagnostics, diagnostics, "edge-prismatic-v1-non-increasing-sections-rejected", "edge-prismatic-x1-non-increasing-sections-rejected", "edge-prismatic-x3-non-increasing-sections-rejected");
+ AddIf(v1Diagnostics, diagnostics, "edge-prismatic-v1-mismatched-vertex-count-rejected", "edge-prismatic-x1-mismatched-vertex-count-rejected", "edge-prismatic-x3-mismatched-vertex-count-rejected");
+ AddIf(v1Diagnostics, diagnostics, "edge-prismatic-v1-missing-correspondence-rejected", "edge-prismatic-x1-missing-correspondence-rejected", "edge-prismatic-x3-missing-correspondence-rejected");
+ AddIf(v1Diagnostics, diagnostics, "edge-prismatic-v1-invalid-profile-rejected", "edge-prismatic-x1-invalid-profile-rejected", "edge-prismatic-x3-invalid-profile-rejected");
+ AddIf(v1Diagnostics, diagnostics, "edge-prismatic-v1-holes-deferred", "edge-prismatic-x1-holes-deferred", "edge-prismatic-x3-holes-deferred");
+ AddIf(v1Diagnostics, diagnostics, "edge-prismatic-v1-line-arc-deferred", "edge-prismatic-x1-line-arc-deferred", "edge-prismatic-x3-line-arc-deferred");
+ AddIf(v1Diagnostics, diagnostics, "edge-prismatic-v1-multiple-loops-deferred", "edge-prismatic-x1-multiple-loops-deferred", "edge-prismatic-x3-multiple-loops-deferred");
+ AddIf(v1Diagnostics, diagnostics, "edge-prismatic-v1-invalid-section-rejected", "edge-prismatic-x1-invalid-section-rejected", "edge-prismatic-x3-invalid-profile-rejected");
+ return diagnostics;
}
- private static bool AllTransitionFacesPlanar(IReadOnlyList<PrismaticSection> sections)
+ private static void AddIf(IReadOnlyList<string> source, List<string> target, string sourceDiagnostic, params string[] targetDiagnostics)
{
- var n = sections[0].OuterLoop.Count;
- for (var s = 0; s < sections.Count - 1; s++)
+ if (source.Contains(sourceDiagnostic))
{
- for (var i = 0; i < n; i++)
- {
- var next = (i + 1) % n;
- var p0 = new Point3D(sections[s].OuterLoop[i].X, sections[s].OuterLoop[i].Y, sections[s].Z);
- var p1 = new Point3D(sections[s].OuterLoop[next].X, sections[s].OuterLoop[next].Y, sections[s].Z);
- var p2 = new Point3D(sections[s + 1].OuterLoop[next].X, sections[s + 1].OuterLoop[next].Y, sections[s + 1].Z);
- var p3 = new Point3D(sections[s + 1].OuterLoop[i].X, sections[s + 1].OuterLoop[i].Y, sections[s + 1].Z);
- var normal = (p1 - p0).Cross(p2 - p0);
- if (normal.Length <= Tol)
- {
- return false;
- }
-
- if (Math.Abs((p3 - p0).Dot(normal / normal.Length)) > Tol)
- {
- return false;
- }
- }
+ target.AddRange(targetDiagnostics);
}
-
- return true;
}
- private static PrismaticSectionTransitionStepSummary SummarizeStep(BrepBody body)
+ private static LabProfileStatus ToLabStatus(CorePrismatic.PrismaticSectionTransitionStatus status) => status switch
{
- var step = Step242Exporter.ExportBody(body);
- if (!step.IsSuccess || step.Value is null)
- {
- return new(false, [], RequiredStepMarkers, [], ForbiddenStepMarkers);
- }
-
- var present = RequiredStepMarkers.Where(m => step.Value.Contains(m, StringComparison.Ordinal)).ToArray();
- var missing = RequiredStepMarkers.Except(present, StringComparer.Ordinal).ToArray();
- var absent = ForbiddenStepMarkers.Where(m => !step.Value.Contains(m, StringComparison.Ordinal)).ToArray();
- var unexpected = ForbiddenStepMarkers.Where(m => step.Value.Contains(m, StringComparison.Ordinal)).ToArray();
- return new(true, present, missing, absent, unexpected);
- }
-
- private static PrismaticSectionTransitionRow Stop(string caseName, LabProfileStatus status, List<string> diagnostics, string recommendation) =>
- new(caseName, status, false, EmptyTopology(), EmptyStep(), StableDiagnostics(diagnostics), recommendation);
-
- private static PrismaticTransitionTopologySummary EmptyTopology() => new(false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "none");
-
- private static PrismaticSectionTransitionStepSummary EmptyStep() => new(false, [], RequiredStepMarkers, ForbiddenStepMarkers, []);
+ CorePrismatic.PrismaticSectionTransitionStatus.Succeeded => LabProfileStatus.Succeeded,
+ CorePrismatic.PrismaticSectionTransitionStatus.Deferred => LabProfileStatus.Deferred,
+ _ => LabProfileStatus.Failed,
+ };
+
+ private static PrismaticTransitionTopologySummary ToLabTopology(CorePrismatic.PrismaticTransitionTopologySummary t) => new(
+ t.BodyProduced,
+ t.SectionCount,
+ t.VertexCount,
+ t.EdgeCount,
+ t.BottomProfileEdgeCount,
+ t.TopProfileEdgeCount,
+ t.TransitionEdgeCount,
+ t.CapFaceCount,
+ t.TransitionFaceCount,
+ t.StableIntervalFaceCount,
+ t.ChangedIntervalFaceCount,
+ t.FaceCount,
+ t.PlanarFaceCount,
+ t.CylindricalFaceCount,
+ t.LoopCount,
+ t.CoedgeCount,
+ t.Bounds);
+
+ private static PrismaticSectionTransitionStepSummary ToLabStep(CorePrismatic.PrismaticSectionTransitionStepSummary s) => new(
+ s.Exported,
+ s.PresentMarkers,
+ s.MissingRequiredMarkers,
+ s.AbsentMarkers,
+ s.UnexpectedPresentMarkers);
private static PrismaticSection RectangleSection(double z, double width, double depth)
{
@@ -455,167 +219,4 @@ public static class PrismaticSectionTransitionEmitterLab
}
private static IReadOnlyList<string> StableDiagnostics(IEnumerable<string> diagnostics) => diagnostics.Distinct(StringComparer.Ordinal).OrderBy(x => x, StringComparer.Ordinal).ToArray();
-
- private static double SignedArea(IReadOnlyList<(double X, double Y)> loop)
- {
- var area = 0d;
- for (var i = 0; i < loop.Count; i++)
- {
- var next = (i + 1) % loop.Count;
- area += (loop[i].X * loop[next].Y) - (loop[next].X * loop[i].Y);
- }
-
- return area * 0.5d;
- }
-
- private static bool SegmentsIntersect((double X, double Y) a, (double X, double Y) b, (double X, double Y) c, (double X, double Y) d)
- {
- static double Cross((double X, double Y) p, (double X, double Y) q, (double X, double Y) r) => ((q.X - p.X) * (r.Y - p.Y)) - ((q.Y - p.Y) * (r.X - p.X));
- var c1 = Cross(a, b, c);
- var c2 = Cross(a, b, d);
- var c3 = Cross(c, d, a);
- var c4 = Cross(c, d, b);
- return (c1 * c2 < -Tol) && (c3 * c4 < -Tol);
- }
-
- private static double Distance((double X, double Y) a, (double X, double Y) b) => Math.Sqrt(((a.X - b.X) * (a.X - b.X)) + ((a.Y - b.Y) * (a.Y - b.Y)));
-
- private static bool SamePoint((double X, double Y) a, (double X, double Y) b) => Distance(a, b) <= Tol;
-}
-
-public static class PrismaticSectionTransitionEmitter
-{
- private const double Tol = 1e-9;
-
- public static (BrepBody? Body, string Diagnostic) TryEmit(IReadOnlyList<PrismaticSection> sections, PrismaticCorrespondenceMap correspondence)
- {
- _ = correspondence;
- var n = sections[0].OuterLoop.Count;
- var points = sections
- .SelectMany(s => s.OuterLoop.Select(p => new Point3D(p.X, p.Y, s.Z)))
- .ToArray();
-
- var b = new TopologyBuilder();
- var vertices = points.Select(_ => b.AddVertex()).ToArray();
- var profileEdges = new EdgeId[sections.Count][];
- for (var s = 0; s < sections.Count; s++)
- {
- profileEdges[s] = new EdgeId[n];
- for (var i = 0; i < n; i++)
- {
- profileEdges[s][i] = b.AddEdge(vertices[(s * n) + i], vertices[(s * n) + ((i + 1) % n)]);
- }
- }
-
- var transitionEdges = new EdgeId[sections.Count - 1][];
- for (var s = 0; s < sections.Count - 1; s++)
- {
- transitionEdges[s] = new EdgeId[n];
- for (var i = 0; i < n; i++)
- {
- transitionEdges[s][i] = b.AddEdge(vertices[(s * n) + i], vertices[((s + 1) * n) + i]);
- }
- }
-
- var faces = new List<FaceId>
- {
- AddFaceWithLoop(b, profileEdges[0].Select(Use.F).ToArray()),
- AddFaceWithLoop(b, profileEdges[^1].Select(Use.R).ToArray()),
- };
-
- for (var s = 0; s < sections.Count - 1; s++)
- {
- for (var i = 0; i < n; i++)
- {
- var next = (i + 1) % n;
- faces.Add(AddFaceWithLoop(b, [Use.F(profileEdges[s][i]), Use.F(transitionEdges[s][next]), Use.R(profileEdges[s + 1][i]), Use.R(transitionEdges[s][i])]));
- }
- }
-
- var shell = b.AddShell(faces);
- b.AddBody([shell]);
-
- var geometry = new BrepGeometryStore();
- var bindings = new BrepBindingModel();
- var vertexMap = new Dictionary<VertexId, Point3D>();
- for (var i = 0; i < vertices.Length; i++)
- {
- vertexMap[vertices[i]] = points[i];
- }
-
- var curveId = 1;
- foreach (var edge in b.Model.Edges.OrderBy(e => e.Id.Value))
- {
- var p0 = vertexMap[edge.StartVertexId];
- var p1 = vertexMap[edge.EndVertexId];
- var vector = p1 - p0;
- if (vector.Length <= Tol)
- {
- return (null, "zero-length-edge");
- }
-
- geometry.AddCurve(new CurveGeometryId(curveId), CurveGeometry.FromLine(new Line3Curve(p0, Direction3D.Create(vector))));
- bindings.AddEdgeBinding(new EdgeGeometryBinding(edge.Id, new CurveGeometryId(curveId), new ParameterInterval(0d, vector.Length)));
- curveId++;
- }
-
- var surfaceId = 1;
- AddPlane(geometry, bindings, faces[0], new Point3D(0, 0, sections[0].Z), new Vector3D(0, 0, -1), new Vector3D(1, 0, 0), surfaceId++);
- AddPlane(geometry, bindings, faces[1], new Point3D(0, 0, sections[^1].Z), new Vector3D(0, 0, 1), new Vector3D(1, 0, 0), surfaceId++);
-
- var faceIndex = 2;
- for (var s = 0; s < sections.Count - 1; s++)
- {
- for (var i = 0; i < n; i++)
- {
- var next = (i + 1) % n;
- AddPlaneFromQuad(geometry, bindings, faces[faceIndex++], points[(s * n) + i], points[(s * n) + next], points[((s + 1) * n) + next], surfaceId++);
- }
- }
-
- return (new BrepBody(b.Model, geometry, bindings, vertexMap), string.Empty);
- }
-
- private static void AddPlaneFromQuad(BrepGeometryStore geometry, BrepBindingModel bindings, FaceId face, Point3D p0, Point3D p1, Point3D p2, int surfaceId)
- {
- var u = p1 - p0;
- var v = p2 - p1;
- var normal = u.Cross(v);
- if (normal.Length <= Tol)
- {
- normal = new Vector3D(0, 0, 1);
- }
-
- var reference = u.Length > Tol ? u : new Vector3D(1, 0, 0);
- AddPlane(geometry, bindings, face, p0, normal, reference, surfaceId);
- }
-
- private static void AddPlane(BrepGeometryStore geometry, BrepBindingModel bindings, FaceId face, Point3D origin, Vector3D normal, Vector3D reference, int surfaceId)
- {
- geometry.AddSurface(new SurfaceGeometryId(surfaceId), SurfaceGeometry.FromPlane(new PlaneSurface(origin, Direction3D.Create(normal), Direction3D.Create(reference))));
- bindings.AddFaceBinding(new FaceGeometryBinding(face, new SurfaceGeometryId(surfaceId)));
- }
-
- private static LoopId AddLoop(TopologyBuilder b, IReadOnlyList<Use> uses)
- {
- var loopId = b.AllocateLoopId();
- var coedgeIds = uses.Select(_ => b.AllocateCoedgeId()).ToArray();
- for (var i = 0; i < uses.Count; i++)
- {
- var next = coedgeIds[(i + 1) % coedgeIds.Length];
- var previous = coedgeIds[(i + coedgeIds.Length - 1) % coedgeIds.Length];
- b.AddCoedge(new Coedge(coedgeIds[i], uses[i].Edge, loopId, next, previous, uses[i].Reversed));
- }
-
- b.AddLoop(new Loop(loopId, coedgeIds));
- return loopId;
- }
-
- private static FaceId AddFaceWithLoop(TopologyBuilder builder, IReadOnlyList<Use> edgeUses) => builder.AddFace([AddLoop(builder, edgeUses)]);
-
- private readonly record struct Use(EdgeId Edge, bool Reversed)
- {
- public static Use F(EdgeId edge) => new(edge, false);
- public static Use R(EdgeId edge) => new(edge, true);
- }
}
diff --git a/Aetheris.Firmament.FrictionLab/CIRLab/PrismaticTopEdgeChamferLab.cs b/Aetheris.Firmament.FrictionLab/CIRLab/PrismaticTopEdgeChamferLab.cs
index 01600c59..622bf5c4 100644
--- a/Aetheris.Firmament.FrictionLab/CIRLab/PrismaticTopEdgeChamferLab.cs
+++ b/Aetheris.Firmament.FrictionLab/CIRLab/PrismaticTopEdgeChamferLab.cs
@@ -1,6 +1,7 @@
using Aetheris.Kernel.Core.Brep;
using Aetheris.Kernel.Core.Geometry;
using Aetheris.Kernel.Core.Step242;
+using CorePrismatic = Aetheris.Kernel.Core.Brep.Prismatic;
namespace Aetheris.Firmament.FrictionLab.CIRLab;
@@ -98,7 +99,7 @@ public static class PrismaticTopEdgeChamferLab
var correspondence = PrismaticCorrespondenceMap.Identity(4);
diagnostics.Add("edge-prismatic-x2-correspondence-created");
diagnostics.Add("edge-prismatic-x2-prismatic-emitter-invoked");
- var emitted = PrismaticSectionTransitionEmitter.TryEmit(sections, correspondence);
+ var emitted = EmitBody(sections, correspondence);
if (emitted.Body is null)
{
diagnostics.Add($"edge-prismatic-x2-prismatic-emitter-failed:{emitted.Diagnostic}");
@@ -163,7 +164,17 @@ public static class PrismaticTopEdgeChamferLab
}
internal static (BrepBody? Body, string Diagnostic) TryEmitBody(PrismaticTopEdgeChamferCase c) =>
- PrismaticSectionTransitionEmitter.TryEmit(CreateSectionStack(c), PrismaticCorrespondenceMap.Identity(4));
+ EmitBody(CreateSectionStack(c), PrismaticCorrespondenceMap.Identity(4));
+
+ private static (BrepBody? Body, string Diagnostic) EmitBody(IReadOnlyList<PrismaticSection> sections, PrismaticCorrespondenceMap correspondence)
+ {
+ var request = new CorePrismatic.PrismaticSectionTransitionRequest(
+ sections.Select(s => new CorePrismatic.PrismaticSection(s.Z, s.OuterLoop, s.HasHoles, s.HasArcs, s.OuterLoopCount)).ToArray(),
+ new CorePrismatic.PrismaticCorrespondenceMap(correspondence.VertexMap),
+ new CorePrismatic.PrismaticSectionTransitionOptions(RunStepSmoke: false, TraceLabel: "prismatic-top-edge-chamfer-lab"));
+ var result = CorePrismatic.PrismaticSectionTransitionEmitter.Emit(request);
+ return (result.Body, result.Status == CorePrismatic.PrismaticSectionTransitionStatus.Succeeded ? string.Empty : string.Join(",", result.Diagnostics));
+ }
private static PrismaticTopEdgeChamferTopologySummary SummarizeTopology(BrepBody body, PrismaticTopEdgeChamferCase c)
{
diff --git a/Aetheris.FrictionLab.Tests/CIRLab/PrismaticSectionTransitionEmitterV1Tests.cs b/Aetheris.FrictionLab.Tests/CIRLab/PrismaticSectionTransitionEmitterV1Tests.cs
new file mode 100644
index 00000000..242da650
--- /dev/null
+++ b/Aetheris.FrictionLab.Tests/CIRLab/PrismaticSectionTransitionEmitterV1Tests.cs
@@ -0,0 +1,179 @@
+using Aetheris.Kernel.Core.Brep.Prismatic;
+
+namespace Aetheris.FrictionLab.Tests.CIRLab;
+
+public sealed class PrismaticSectionTransitionEmitterV1Tests
+{
+ private static string Stable(PrismaticSectionTransitionResult result) => string.Join("|",
+ result.Status,
+ result.Succeeded,
+ result.Topology.BodyProduced,
+ result.Topology.SectionCount,
+ result.Topology.VertexCount,
+ result.Topology.EdgeCount,
+ result.Topology.BottomProfileEdgeCount,
+ result.Topology.TopProfileEdgeCount,
+ result.Topology.TransitionEdgeCount,
+ result.Topology.CapFaceCount,
+ result.Topology.TransitionFaceCount,
+ result.Topology.StableIntervalFaceCount,
+ result.Topology.ChangedIntervalFaceCount,
+ result.Topology.FaceCount,
+ result.Topology.PlanarFaceCount,
+ result.Topology.CylindricalFaceCount,
+ result.Topology.LoopCount,
+ result.Topology.CoedgeCount,
+ result.Topology.Bounds,
+ result.Step.Exported,
+ string.Join(",", result.Step.PresentMarkers.OrderBy(x => x, StringComparer.Ordinal)),
+ string.Join(",", result.Step.MissingRequiredMarkers.OrderBy(x => x, StringComparer.Ordinal)),
+ string.Join(",", result.Step.AbsentMarkers.OrderBy(x => x, StringComparer.Ordinal)),
+ string.Join(",", result.Step.UnexpectedPresentMarkers.OrderBy(x => x, StringComparer.Ordinal)),
+ string.Join(",", result.Diagnostics.OrderBy(x => x, StringComparer.Ordinal)),
+ result.Recommendation);
+
+ [Fact]
+ public void V1Emitter_IsDeterministic()
+ {
+ var request = SuccessRequest(Rectangle(0, 10, 8), Rectangle(1, 8, 6));
+
+ Assert.Equal(Stable(PrismaticSectionTransitionEmitter.Emit(request)), Stable(PrismaticSectionTransitionEmitter.Emit(request)));
+ }
+
+ [Theory]
+ [InlineData("rectangle", 4, 8, 12, 6, 24)]
+ [InlineData("pentagon", 5, 10, 15, 7, 30)]
+ [InlineData("hexagon", 6, 12, 18, 8, 36)]
+ [InlineData("asymmetric", 5, 10, 15, 7, 30)]
+ public void V1TwoSectionCases_SucceedWithTopologyFormulaAndStepSmoke(string name, int n, int vertices, int edges, int faces, int coedges)
+ {
+ var result = PrismaticSectionTransitionEmitter.Emit(name switch
+ {
+ "rectangle" => SuccessRequest(Rectangle(0, 10, 8), Rectangle(1, 8, 6)),
+ "pentagon" => SuccessRequest(RegularPolygon(0, 5, 5), RegularPolygon(2, 4, 5)),
+ "hexagon" => SuccessRequest(RegularPolygon(0, 6, 6), RegularPolygon(2, 4.5, 6)),
+ _ => SuccessRequest(
+ new PrismaticSection(0, [(-4, -2), (1, -3), (5, 0), (2, 3.5), (-3, 2.5)]),
+ new PrismaticSection(2, [(-3.25, -2.35), (1.75, -3.35), (5.75, -0.35), (2.75, 3.15), (-2.25, 2.15)])),
+ });
+
+ Assert.Equal(PrismaticSectionTransitionStatus.Succeeded, result.Status);
+ Assert.True(result.Succeeded);
+ Assert.NotNull(result.Body);
+ Assert.Equal(2, result.Topology.SectionCount);
+ Assert.Equal(vertices, result.Topology.VertexCount);
+ Assert.Equal(edges, result.Topology.EdgeCount);
+ Assert.Equal(n, result.Topology.BottomProfileEdgeCount);
+ Assert.Equal(n, result.Topology.TopProfileEdgeCount);
+ Assert.Equal(n, result.Topology.TransitionEdgeCount);
+ Assert.Equal(2, result.Topology.CapFaceCount);
+ Assert.Equal(n, result.Topology.TransitionFaceCount);
+ Assert.Equal(faces, result.Topology.FaceCount);
+ Assert.Equal(faces, result.Topology.PlanarFaceCount);
+ Assert.Equal(0, result.Topology.CylindricalFaceCount);
+ Assert.Equal(faces, result.Topology.LoopCount);
+ Assert.Equal(coedges, result.Topology.CoedgeCount);
+ Assert.True(result.Step.Exported);
+ Assert.Empty(result.Step.MissingRequiredMarkers);
+ Assert.Empty(result.Step.UnexpectedPresentMarkers);
+ Assert.Contains("ISO-10303-21", result.Step.PresentMarkers);
+ Assert.Contains("MANIFOLD_SOLID_BREP", result.Step.PresentMarkers);
+ Assert.Contains("ADVANCED_FACE", result.Step.PresentMarkers);
+ Assert.Contains("PLANE", result.Step.PresentMarkers);
+ Assert.Contains("CYLINDRICAL_SURFACE", result.Step.AbsentMarkers);
+ Assert.Contains("BREP_WITH_VOIDS", result.Step.AbsentMarkers);
+ Assert.Contains("edge-prismatic-v1-topology-validated", result.Diagnostics);
+ Assert.Equal("prismatic-section-transition-ready-for-controlled-route-evaluation", result.Recommendation);
+ }
+
+ [Fact]
+ public void V1ThreeSectionStablePlusTransition_PreservesSplitIntervalFaces()
+ {
+ var result = PrismaticSectionTransitionEmitter.Emit(SuccessRequest(Rectangle(0, 10, 8), Rectangle(5, 10, 8), Rectangle(6, 8, 6)));
+
+ Assert.Equal(PrismaticSectionTransitionStatus.Succeeded, result.Status);
+ Assert.Equal(3, result.Topology.SectionCount);
+ Assert.Equal(12, result.Topology.VertexCount);
+ Assert.Equal(20, result.Topology.EdgeCount);
+ Assert.Equal(8, result.Topology.TransitionEdgeCount);
+ Assert.Equal(2, result.Topology.CapFaceCount);
+ Assert.Equal(8, result.Topology.TransitionFaceCount);
+ Assert.Equal(4, result.Topology.StableIntervalFaceCount);
+ Assert.Equal(4, result.Topology.ChangedIntervalFaceCount);
+ Assert.Equal(10, result.Topology.FaceCount);
+ Assert.Equal(10, result.Topology.PlanarFaceCount);
+ Assert.Equal(10, result.Topology.LoopCount);
+ Assert.Equal(40, result.Topology.CoedgeCount);
+ }
+
+ [Theory]
+ [InlineData("non-increasing", "Rejected", "edge-prismatic-v1-non-increasing-sections-rejected", "edge-prismatic-v1-request-rejected:non-increasing-z")]
+ [InlineData("zero-interval", "Rejected", "edge-prismatic-v1-non-increasing-sections-rejected", "edge-prismatic-v1-request-rejected:non-increasing-z")]
+ [InlineData("mismatch", "Rejected", "edge-prismatic-v1-mismatched-vertex-count-rejected", "edge-prismatic-v1-request-rejected:mismatched-vertex-count")]
+ [InlineData("missing-correspondence", "Rejected", "edge-prismatic-v1-missing-correspondence-rejected", "edge-prismatic-v1-request-rejected:missing-correspondence")]
+ [InlineData("self-intersecting", "Rejected", "edge-prismatic-v1-invalid-profile-rejected", "edge-prismatic-v1-request-rejected:invalid-profile")]
+ [InlineData("holes", "Deferred", "edge-prismatic-v1-holes-deferred", "edge-prismatic-v1-request-deferred:holes")]
+ [InlineData("arcs", "Deferred", "edge-prismatic-v1-line-arc-deferred", "edge-prismatic-v1-request-deferred:line-arc-profile")]
+ [InlineData("multiple-loops", "Deferred", "edge-prismatic-v1-multiple-loops-deferred", "edge-prismatic-v1-request-deferred:multiple-loops")]
+ public void V1InvalidAndDeferredCases_AreClassifiedDeterministically(string name, string status, string diagnostic, string reason)
+ {
+ var result = PrismaticSectionTransitionEmitter.Emit(name switch
+ {
+ "non-increasing" => SuccessRequest(Rectangle(1, 10, 8), Rectangle(0, 8, 6)),
+ "zero-interval" => SuccessRequest(Rectangle(0, 10, 8), Rectangle(0, 8, 6)),
+ "mismatch" => SuccessRequest(Rectangle(0, 10, 8), RegularPolygon(1, 5, 5), 4),
+ "missing-correspondence" => new PrismaticSectionTransitionRequest([Rectangle(0, 10, 8), Rectangle(1, 8, 6)], null, new PrismaticSectionTransitionOptions(true, name)),
+ "self-intersecting" => SuccessRequest(new PrismaticSection(0, [(0, 0), (2, 2), (0, 2), (2, 0)]), Rectangle(1, 8, 6), 4),
+ "holes" => SuccessRequest(Rectangle(0, 10, 8) with { HasHoles = true }, Rectangle(1, 8, 6) with { HasHoles = true }),
+ "arcs" => SuccessRequest(Rectangle(0, 10, 8) with { HasArcs = true }, Rectangle(1, 8, 6) with { HasArcs = true }),
+ _ => SuccessRequest(Rectangle(0, 10, 8) with { OuterLoopCount = 2 }, Rectangle(1, 8, 6) with { OuterLoopCount = 2 }),
+ });
+
+ Assert.Equal(status, result.Status.ToString());
+ Assert.False(result.Succeeded);
+ Assert.Null(result.Body);
+ Assert.False(result.Topology.BodyProduced);
+ Assert.Contains(diagnostic, result.Diagnostics);
+ Assert.Contains(reason, result.Diagnostics);
+ }
+
+ [Fact]
+ public void V1GuardrailDiagnostics_ConfirmNoForbiddenRoutes()
+ {
+ var result = PrismaticSectionTransitionEmitter.Emit(SuccessRequest(Rectangle(0, 10, 8), Rectangle(1, 8, 6)));
+
+ Assert.Contains("edge-prismatic-v1-no-air-edge-sweep-used", result.Diagnostics);
+ Assert.Contains("edge-prismatic-v1-no-brep-bounded-chamfer-used", result.Diagnostics);
+ Assert.Contains("edge-prismatic-v1-no-topology-graft-used", result.Diagnostics);
+ Assert.Contains("edge-prismatic-v1-no-3d-boolean-used", result.Diagnostics);
+ Assert.Contains("edge-prismatic-v1-no-production-route-replacement", result.Diagnostics);
+ }
+
+ private static PrismaticSectionTransitionRequest SuccessRequest(params PrismaticSection[] sections) =>
+ SuccessRequest(sections, sections[0].OuterLoop.Count);
+
+ private static PrismaticSectionTransitionRequest SuccessRequest(PrismaticSection first, PrismaticSection second, int correspondenceCount) =>
+ SuccessRequest([first, second], correspondenceCount);
+
+ private static PrismaticSectionTransitionRequest SuccessRequest(PrismaticSection[] sections, int correspondenceCount) =>
+ new(sections, PrismaticCorrespondenceMap.Identity(correspondenceCount), new PrismaticSectionTransitionOptions(true, "test"));
+
+ private static PrismaticSection Rectangle(double z, double width, double depth)
+ {
+ var x = width * 0.5d;
+ var y = depth * 0.5d;
+ return new(z, [(-x, -y), (x, -y), (x, y), (-x, y)]);
+ }
+
+ private static PrismaticSection RegularPolygon(double z, double radius, int vertices)
+ {
+ var points = Enumerable.Range(0, vertices)
+ .Select(i =>
+ {
+ var a = ((Math.PI * 2d) * i / vertices) - (Math.PI * 0.5d);
+ return (X: Math.Cos(a) * radius, Y: Math.Sin(a) * radius);
+ })
+ .ToArray();
+ return new(z, points);
+ }
+}
diff --git a/Aetheris.Kernel.Core/Brep/Prismatic/PrismaticSectionTransitionEmitter.cs b/Aetheris.Kernel.Core/Brep/Prismatic/PrismaticSectionTransitionEmitter.cs
new file mode 100644
index 00000000..b0b893dc
--- /dev/null
+++ b/Aetheris.Kernel.Core/Brep/Prismatic/PrismaticSectionTransitionEmitter.cs
@@ -0,0 +1,595 @@
+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.Brep.Prismatic;
+
+internal enum PrismaticSectionTransitionStatus
+{
+ Succeeded,
+ Rejected,
+ Deferred,
+ Failed,
+}
+
+internal sealed record PrismaticSection(double Z, IReadOnlyList<(double X, double Y)> OuterLoop, bool HasHoles = false, bool HasArcs = false, int OuterLoopCount = 1);
+
+internal sealed record PrismaticCorrespondenceMap(IReadOnlyList<int> VertexMap)
+{
+ public static PrismaticCorrespondenceMap Identity(int vertexCount) => new(Enumerable.Range(0, vertexCount).ToArray());
+}
+
+internal sealed record PrismaticSectionTransitionOptions(bool RunStepSmoke = false, string? TraceLabel = null);
+
+internal sealed record PrismaticSectionTransitionRequest(
+ IReadOnlyList<PrismaticSection> Sections,
+ PrismaticCorrespondenceMap? Correspondence,
+ PrismaticSectionTransitionOptions? Options = null);
+
+internal sealed record PrismaticTransitionTopologySummary(
+ bool BodyProduced,
+ int SectionCount,
+ int VertexCount,
+ int EdgeCount,
+ int BottomProfileEdgeCount,
+ int TopProfileEdgeCount,
+ int TransitionEdgeCount,
+ int CapFaceCount,
+ int TransitionFaceCount,
+ int StableIntervalFaceCount,
+ int ChangedIntervalFaceCount,
+ int FaceCount,
+ int PlanarFaceCount,
+ int CylindricalFaceCount,
+ int LoopCount,
+ int CoedgeCount,
+ string Bounds);
+
+internal sealed record PrismaticSectionTransitionStepSummary(
+ bool Exported,
+ IReadOnlyList<string> PresentMarkers,
+ IReadOnlyList<string> MissingRequiredMarkers,
+ IReadOnlyList<string> AbsentMarkers,
+ IReadOnlyList<string> UnexpectedPresentMarkers);
+
+internal sealed record PrismaticSectionTransitionResult(
+ PrismaticSectionTransitionStatus Status,
+ BrepBody? Body,
+ PrismaticTransitionTopologySummary Topology,
+ PrismaticSectionTransitionStepSummary Step,
+ IReadOnlyList<string> Diagnostics,
+ string Recommendation)
+{
+ public bool Succeeded => Status == PrismaticSectionTransitionStatus.Succeeded && Body is not null;
+}
+
+internal static class PrismaticSectionTransitionEmitter
+{
+ private const double Tol = 1e-9;
+
+ private static readonly string[] RequiredStepMarkers = ["ISO-10303-21", "MANIFOLD_SOLID_BREP", "ADVANCED_FACE", "PLANE"];
+ private static readonly string[] ForbiddenStepMarkers = ["CYLINDRICAL_SURFACE", "BREP_WITH_VOIDS"];
+
+ public static PrismaticSectionTransitionResult Emit(PrismaticSectionTransitionRequest request)
+ {
+ var diagnostics = new List<string> { "edge-prismatic-v1-emitter-started" };
+ if (!string.IsNullOrWhiteSpace(request.Options?.TraceLabel))
+ {
+ diagnostics.Add($"edge-prismatic-v1-trace:{request.Options.TraceLabel}");
+ }
+
+ var validation = Validate(request, diagnostics);
+ if (validation.Status != PrismaticSectionTransitionStatus.Succeeded)
+ {
+ return Stop(validation.Status, diagnostics, validation.Recommendation);
+ }
+
+ diagnostics.Add("edge-prismatic-v1-request-validated");
+ for (var i = 0; i < request.Sections.Count - 1; i++)
+ {
+ diagnostics.Add("edge-prismatic-v1-transition-interval-created");
+ }
+
+ var built = TryBuildBody(request.Sections, request.Correspondence!);
+ if (built.Body is null)
+ {
+ diagnostics.Add($"edge-prismatic-v1-request-rejected:{built.Diagnostic}");
+ return Stop(PrismaticSectionTransitionStatus.Failed, diagnostics, "prismatic-section-transition-needs-profile-validation-hardening");
+ }
+
+ diagnostics.Add("edge-prismatic-v1-cap-faces-created");
+ diagnostics.Add("edge-prismatic-v1-transition-faces-created");
+ diagnostics.Add("edge-prismatic-v1-body-created");
+ diagnostics.Add("edge-prismatic-v1-no-air-edge-sweep-used");
+ diagnostics.Add("edge-prismatic-v1-no-brep-bounded-chamfer-used");
+ diagnostics.Add("edge-prismatic-v1-no-topology-graft-used");
+ diagnostics.Add("edge-prismatic-v1-no-3d-boolean-used");
+ diagnostics.Add("edge-prismatic-v1-no-production-route-replacement");
+
+ var topology = SummarizeTopology(built.Body, request.Sections);
+ var topologySucceeded = ValidateTopologyFormula(topology, request.Sections);
+ if (topologySucceeded)
+ {
+ diagnostics.Add("edge-prismatic-v1-topology-validated");
+ }
+
+ var step = request.Options?.RunStepSmoke == true ? SummarizeStep(built.Body) : EmptyStep();
+ var stepSucceeded = request.Options?.RunStepSmoke != true || (step.Exported && step.MissingRequiredMarkers.Count == 0 && step.UnexpectedPresentMarkers.Count == 0);
+ if (request.Options?.RunStepSmoke == true)
+ {
+ diagnostics.Add(stepSucceeded ? "edge-prismatic-v1-step-smoke-succeeded" : "edge-prismatic-v1-step-smoke-failed:markers");
+ }
+
+ if (!topologySucceeded)
+ {
+ return new(
+ PrismaticSectionTransitionStatus.Failed,
+ built.Body,
+ topology,
+ step,
+ StableDiagnostics(diagnostics),
+ "prismatic-section-transition-needs-profile-validation-hardening");
+ }
+
+ if (!stepSucceeded)
+ {
+ return new(
+ PrismaticSectionTransitionStatus.Failed,
+ built.Body,
+ topology,
+ step,
+ StableDiagnostics(diagnostics),
+ "prismatic-section-transition-needs-profile-validation-hardening");
+ }
+
+ return new(
+ PrismaticSectionTransitionStatus.Succeeded,
+ built.Body,
+ topology,
+ step,
+ StableDiagnostics(diagnostics),
+ "prismatic-section-transition-ready-for-controlled-route-evaluation");
+ }
+
+ private static (PrismaticSectionTransitionStatus Status, string Recommendation) Validate(PrismaticSectionTransitionRequest request, List<string> diagnostics)
+ {
+ if (request.Sections.Count < 2)
+ {
+ diagnostics.Add("edge-prismatic-v1-invalid-section-rejected");
+ diagnostics.Add("edge-prismatic-v1-request-rejected:fewer-than-two-sections");
+ return (PrismaticSectionTransitionStatus.Rejected, "prismatic-section-transition-invalid-rejected");
+ }
+
+ if (request.Sections.Count > 3)
+ {
+ diagnostics.Add("edge-prismatic-v1-invalid-section-rejected");
+ diagnostics.Add("edge-prismatic-v1-request-deferred:more-than-three-sections");
+ return (PrismaticSectionTransitionStatus.Deferred, "prismatic-section-transition-deferred");
+ }
+
+ foreach (var section in request.Sections)
+ {
+ if (section.HasHoles)
+ {
+ diagnostics.Add("edge-prismatic-v1-holes-deferred");
+ diagnostics.Add("edge-prismatic-v1-request-deferred:holes");
+ return (PrismaticSectionTransitionStatus.Deferred, "prismatic-section-transition-deferred");
+ }
+
+ if (section.HasArcs)
+ {
+ diagnostics.Add("edge-prismatic-v1-line-arc-deferred");
+ diagnostics.Add("edge-prismatic-v1-request-deferred:line-arc-profile");
+ return (PrismaticSectionTransitionStatus.Deferred, "prismatic-section-transition-deferred");
+ }
+
+ if (section.OuterLoopCount != 1)
+ {
+ diagnostics.Add("edge-prismatic-v1-multiple-loops-deferred");
+ diagnostics.Add("edge-prismatic-v1-request-deferred:multiple-loops");
+ return (PrismaticSectionTransitionStatus.Deferred, "prismatic-section-transition-deferred");
+ }
+
+ if (!ValidateProfile(section))
+ {
+ diagnostics.Add("edge-prismatic-v1-invalid-profile-rejected");
+ diagnostics.Add("edge-prismatic-v1-request-rejected:invalid-profile");
+ return (PrismaticSectionTransitionStatus.Rejected, "prismatic-section-transition-invalid-rejected");
+ }
+
+ diagnostics.Add("edge-prismatic-v1-section-validated");
+ }
+
+ for (var i = 0; i < request.Sections.Count; i++)
+ {
+ if (!double.IsFinite(request.Sections[i].Z))
+ {
+ diagnostics.Add("edge-prismatic-v1-invalid-section-rejected");
+ diagnostics.Add("edge-prismatic-v1-request-rejected:non-finite-z");
+ return (PrismaticSectionTransitionStatus.Rejected, "prismatic-section-transition-invalid-rejected");
+ }
+
+ if (i > 0 && request.Sections[i].Z <= request.Sections[i - 1].Z + Tol)
+ {
+ diagnostics.Add("edge-prismatic-v1-non-increasing-sections-rejected");
+ diagnostics.Add("edge-prismatic-v1-request-rejected:non-increasing-z");
+ return (PrismaticSectionTransitionStatus.Rejected, "prismatic-section-transition-invalid-rejected");
+ }
+ }
+
+ var vertexCount = request.Sections[0].OuterLoop.Count;
+ if (request.Sections.Any(s => s.OuterLoop.Count != vertexCount))
+ {
+ diagnostics.Add("edge-prismatic-v1-mismatched-vertex-count-rejected");
+ diagnostics.Add("edge-prismatic-v1-request-rejected:mismatched-vertex-count");
+ return (PrismaticSectionTransitionStatus.Rejected, "prismatic-section-transition-invalid-rejected");
+ }
+
+ var orientation = SignedArea(request.Sections[0].OuterLoop) > 0d;
+ if (request.Sections.Skip(1).Any(s => (SignedArea(s.OuterLoop) > 0d) != orientation))
+ {
+ diagnostics.Add("edge-prismatic-v1-invalid-profile-rejected");
+ diagnostics.Add("edge-prismatic-v1-request-rejected:unstable-orientation");
+ return (PrismaticSectionTransitionStatus.Rejected, "prismatic-section-transition-invalid-rejected");
+ }
+
+ if (request.Correspondence is null)
+ {
+ diagnostics.Add("edge-prismatic-v1-missing-correspondence-rejected");
+ diagnostics.Add("edge-prismatic-v1-request-rejected:missing-correspondence");
+ return (PrismaticSectionTransitionStatus.Rejected, "prismatic-section-transition-invalid-rejected");
+ }
+
+ if (request.Correspondence.VertexMap.Count != vertexCount || !request.Correspondence.VertexMap.SequenceEqual(Enumerable.Range(0, vertexCount)))
+ {
+ diagnostics.Add("edge-prismatic-v1-missing-correspondence-rejected");
+ diagnostics.Add("edge-prismatic-v1-request-rejected:non-identity-correspondence");
+ return (PrismaticSectionTransitionStatus.Rejected, "prismatic-section-transition-needs-correspondence-hardening");
+ }
+
+ diagnostics.Add("edge-prismatic-v1-correspondence-validated");
+
+ if (!AllTransitionFacesPlanar(request.Sections))
+ {
+ diagnostics.Add("edge-prismatic-v1-invalid-profile-rejected");
+ diagnostics.Add("edge-prismatic-v1-request-rejected:non-planar-transition-face");
+ return (PrismaticSectionTransitionStatus.Rejected, "prismatic-section-transition-needs-profile-validation-hardening");
+ }
+
+ return (PrismaticSectionTransitionStatus.Succeeded, string.Empty);
+ }
+
+ private static bool ValidateProfile(PrismaticSection section)
+ {
+ var loop = section.OuterLoop;
+ if (loop.Count < 4 || !double.IsFinite(section.Z))
+ {
+ return false;
+ }
+
+ foreach (var point in loop)
+ {
+ if (!double.IsFinite(point.X) || !double.IsFinite(point.Y))
+ {
+ return false;
+ }
+ }
+
+ for (var i = 0; i < loop.Count; i++)
+ {
+ var next = (i + 1) % loop.Count;
+ if (Distance(loop[i], loop[next]) <= Tol)
+ {
+ return false;
+ }
+ }
+
+ if (System.Math.Abs(SignedArea(loop)) <= Tol)
+ {
+ return false;
+ }
+
+ for (var i = 0; i < loop.Count; i++)
+ {
+ var i2 = (i + 1) % loop.Count;
+ for (var j = i + 1; j < loop.Count; j++)
+ {
+ var j2 = (j + 1) % loop.Count;
+ if (i == j || i2 == j || i == j2)
+ {
+ continue;
+ }
+
+ if (i == 0 && j2 == 0)
+ {
+ continue;
+ }
+
+ if (SegmentsIntersect(loop[i], loop[i2], loop[j], loop[j2]))
+ {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ private static bool ValidateTopologyFormula(PrismaticTransitionTopologySummary topology, IReadOnlyList<PrismaticSection> sections)
+ {
+ var n = sections[0].OuterLoop.Count;
+ var sectionCount = sections.Count;
+ var expectedFaces = 2 + ((sectionCount - 1) * n);
+ return topology.BodyProduced
+ && topology.SectionCount == sectionCount
+ && topology.VertexCount == sectionCount * n
+ && topology.EdgeCount == (sectionCount * n) + ((sectionCount - 1) * n)
+ && topology.TransitionEdgeCount == (sectionCount - 1) * n
+ && topology.CapFaceCount == 2
+ && topology.TransitionFaceCount == (sectionCount - 1) * n
+ && topology.FaceCount == expectedFaces
+ && topology.PlanarFaceCount == expectedFaces
+ && topology.CylindricalFaceCount == 0
+ && topology.LoopCount == expectedFaces
+ && topology.CoedgeCount == (2 * n) + (4 * (sectionCount - 1) * n);
+ }
+
+ private static (BrepBody? Body, string Diagnostic) TryBuildBody(IReadOnlyList<PrismaticSection> sections, PrismaticCorrespondenceMap correspondence)
+ {
+ _ = correspondence;
+ var n = sections[0].OuterLoop.Count;
+ var points = sections
+ .SelectMany(s => s.OuterLoop.Select(p => new Point3D(p.X, p.Y, s.Z)))
+ .ToArray();
+
+ var b = new TopologyBuilder();
+ var vertices = points.Select(_ => b.AddVertex()).ToArray();
+ var profileEdges = new EdgeId[sections.Count][];
+ for (var s = 0; s < sections.Count; s++)
+ {
+ profileEdges[s] = new EdgeId[n];
+ for (var i = 0; i < n; i++)
+ {
+ profileEdges[s][i] = b.AddEdge(vertices[(s * n) + i], vertices[(s * n) + ((i + 1) % n)]);
+ }
+ }
+
+ var transitionEdges = new EdgeId[sections.Count - 1][];
+ for (var s = 0; s < sections.Count - 1; s++)
+ {
+ transitionEdges[s] = new EdgeId[n];
+ for (var i = 0; i < n; i++)
+ {
+ transitionEdges[s][i] = b.AddEdge(vertices[(s * n) + i], vertices[((s + 1) * n) + i]);
+ }
+ }
+
+ var faces = new List<FaceId>
+ {
+ AddFaceWithLoop(b, profileEdges[0].Select(Use.F).ToArray()),
+ AddFaceWithLoop(b, profileEdges[^1].Select(Use.R).ToArray()),
+ };
+
+ for (var s = 0; s < sections.Count - 1; s++)
+ {
+ for (var i = 0; i < n; i++)
+ {
+ var next = (i + 1) % n;
+ faces.Add(AddFaceWithLoop(b, [Use.F(profileEdges[s][i]), Use.F(transitionEdges[s][next]), Use.R(profileEdges[s + 1][i]), Use.R(transitionEdges[s][i])]));
+ }
+ }
+
+ var shell = b.AddShell(faces);
+ b.AddBody([shell]);
+
+ var geometry = new BrepGeometryStore();
+ var bindings = new BrepBindingModel();
+ var vertexMap = new Dictionary<VertexId, Point3D>();
+ for (var i = 0; i < vertices.Length; i++)
+ {
+ vertexMap[vertices[i]] = points[i];
+ }
+
+ var curveId = 1;
+ foreach (var edge in b.Model.Edges.OrderBy(e => e.Id.Value))
+ {
+ var p0 = vertexMap[edge.StartVertexId];
+ var p1 = vertexMap[edge.EndVertexId];
+ var vector = p1 - p0;
+ if (vector.Length <= Tol)
+ {
+ return (null, "zero-length-edge");
+ }
+
+ geometry.AddCurve(new CurveGeometryId(curveId), CurveGeometry.FromLine(new Line3Curve(p0, Direction3D.Create(vector))));
+ bindings.AddEdgeBinding(new EdgeGeometryBinding(edge.Id, new CurveGeometryId(curveId), new ParameterInterval(0d, vector.Length)));
+ curveId++;
+ }
+
+ var surfaceId = 1;
+ AddPlane(geometry, bindings, faces[0], new Point3D(0, 0, sections[0].Z), new Vector3D(0, 0, -1), new Vector3D(1, 0, 0), surfaceId++);
+ AddPlane(geometry, bindings, faces[1], new Point3D(0, 0, sections[^1].Z), new Vector3D(0, 0, 1), new Vector3D(1, 0, 0), surfaceId++);
+
+ var faceIndex = 2;
+ for (var s = 0; s < sections.Count - 1; s++)
+ {
+ for (var i = 0; i < n; i++)
+ {
+ var next = (i + 1) % n;
+ AddPlaneFromQuad(geometry, bindings, faces[faceIndex++], points[(s * n) + i], points[(s * n) + next], points[((s + 1) * n) + next], surfaceId++);
+ }
+ }
+
+ return (new BrepBody(b.Model, geometry, bindings, vertexMap), string.Empty);
+ }
+
+ private static PrismaticTransitionTopologySummary SummarizeTopology(BrepBody body, IReadOnlyList<PrismaticSection> sections)
+ {
+ var faceCount = body.Topology.Faces.Count();
+ var planarFaceCount = body.Topology.Faces.Count(f => body.GetFaceSurface(f.Id).Kind == SurfaceGeometryKind.Plane);
+ var cylindricalFaceCount = body.Topology.Faces.Count(f => body.GetFaceSurface(f.Id).Kind == SurfaceGeometryKind.Cylinder);
+ var n = sections[0].OuterLoop.Count;
+ var stableFaces = 0;
+ var changedFaces = 0;
+ for (var s = 0; s < sections.Count - 1; s++)
+ {
+ for (var i = 0; i < n; i++)
+ {
+ var next = (i + 1) % n;
+ if (SamePoint(sections[s].OuterLoop[i], sections[s + 1].OuterLoop[i]) && SamePoint(sections[s].OuterLoop[next], sections[s + 1].OuterLoop[next]))
+ {
+ stableFaces++;
+ }
+ else
+ {
+ changedFaces++;
+ }
+ }
+ }
+
+ var allX = sections.SelectMany(s => s.OuterLoop.Select(p => p.X)).ToArray();
+ var allY = sections.SelectMany(s => s.OuterLoop.Select(p => p.Y)).ToArray();
+ return new(
+ true,
+ sections.Count,
+ body.Topology.Vertices.Count(),
+ body.Topology.Edges.Count(),
+ n,
+ n,
+ (sections.Count - 1) * n,
+ 2,
+ (sections.Count - 1) * n,
+ stableFaces,
+ changedFaces,
+ faceCount,
+ planarFaceCount,
+ cylindricalFaceCount,
+ body.Topology.Loops.Count(),
+ body.Topology.Coedges.Count(),
+ FormattableString.Invariant($"[{allX.Min():0.###},{allY.Min():0.###},{sections.Min(s => s.Z):0.###}]..[{allX.Max():0.###},{allY.Max():0.###},{sections.Max(s => s.Z):0.###}]"));
+ }
+
+ private static bool AllTransitionFacesPlanar(IReadOnlyList<PrismaticSection> sections)
+ {
+ var n = sections[0].OuterLoop.Count;
+ for (var s = 0; s < sections.Count - 1; s++)
+ {
+ for (var i = 0; i < n; i++)
+ {
+ var next = (i + 1) % n;
+ var p0 = new Point3D(sections[s].OuterLoop[i].X, sections[s].OuterLoop[i].Y, sections[s].Z);
+ var p1 = new Point3D(sections[s].OuterLoop[next].X, sections[s].OuterLoop[next].Y, sections[s].Z);
+ var p2 = new Point3D(sections[s + 1].OuterLoop[next].X, sections[s + 1].OuterLoop[next].Y, sections[s + 1].Z);
+ var p3 = new Point3D(sections[s + 1].OuterLoop[i].X, sections[s + 1].OuterLoop[i].Y, sections[s + 1].Z);
+ var normal = (p1 - p0).Cross(p2 - p0);
+ if (normal.Length <= Tol)
+ {
+ return false;
+ }
+
+ if (System.Math.Abs((p3 - p0).Dot(normal / normal.Length)) > Tol)
+ {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ private static PrismaticSectionTransitionStepSummary SummarizeStep(BrepBody body)
+ {
+ var step = Step242Exporter.ExportBody(body);
+ if (!step.IsSuccess || step.Value is null)
+ {
+ return new(false, [], RequiredStepMarkers, [], ForbiddenStepMarkers);
+ }
+
+ var present = RequiredStepMarkers.Where(m => step.Value.Contains(m, StringComparison.Ordinal)).ToArray();
+ var missing = RequiredStepMarkers.Except(present, StringComparer.Ordinal).ToArray();
+ var absent = ForbiddenStepMarkers.Where(m => !step.Value.Contains(m, StringComparison.Ordinal)).ToArray();
+ var unexpected = ForbiddenStepMarkers.Where(m => step.Value.Contains(m, StringComparison.Ordinal)).ToArray();
+ return new(true, present, missing, absent, unexpected);
+ }
+
+ private static PrismaticSectionTransitionResult Stop(PrismaticSectionTransitionStatus status, List<string> diagnostics, string recommendation) =>
+ new(status, null, EmptyTopology(), EmptyStep(), StableDiagnostics(diagnostics), recommendation);
+
+ private static PrismaticTransitionTopologySummary EmptyTopology() => new(false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "none");
+
+ private static PrismaticSectionTransitionStepSummary EmptyStep() => new(false, [], RequiredStepMarkers, ForbiddenStepMarkers, []);
+
+ private static IReadOnlyList<string> StableDiagnostics(IEnumerable<string> diagnostics) => diagnostics.Distinct(StringComparer.Ordinal).OrderBy(x => x, StringComparer.Ordinal).ToArray();
+
+ private static double SignedArea(IReadOnlyList<(double X, double Y)> loop)
+ {
+ var area = 0d;
+ for (var i = 0; i < loop.Count; i++)
+ {
+ var next = (i + 1) % loop.Count;
+ area += (loop[i].X * loop[next].Y) - (loop[next].X * loop[i].Y);
+ }
+
+ return area * 0.5d;
+ }
+
+ private static bool SegmentsIntersect((double X, double Y) a, (double X, double Y) b, (double X, double Y) c, (double X, double Y) d)
+ {
+ static double Cross((double X, double Y) p, (double X, double Y) q, (double X, double Y) r) => ((q.X - p.X) * (r.Y - p.Y)) - ((q.Y - p.Y) * (r.X - p.X));
+ var c1 = Cross(a, b, c);
+ var c2 = Cross(a, b, d);
+ var c3 = Cross(c, d, a);
+ var c4 = Cross(c, d, b);
+ return (c1 * c2 < -Tol) && (c3 * c4 < -Tol);
+ }
+
+ private static double Distance((double X, double Y) a, (double X, double Y) b) => System.Math.Sqrt(((a.X - b.X) * (a.X - b.X)) + ((a.Y - b.Y) * (a.Y - b.Y)));
+
+ private static bool SamePoint((double X, double Y) a, (double X, double Y) b) => Distance(a, b) <= Tol;
+
+ private static void AddPlaneFromQuad(BrepGeometryStore geometry, BrepBindingModel bindings, FaceId face, Point3D p0, Point3D p1, Point3D p2, int surfaceId)
+ {
+ var u = p1 - p0;
+ var v = p2 - p1;
+ var normal = u.Cross(v);
+ if (normal.Length <= Tol)
+ {
+ normal = new Vector3D(0, 0, 1);
+ }
+
+ var reference = u.Length > Tol ? u : new Vector3D(1, 0, 0);
+ AddPlane(geometry, bindings, face, p0, normal, reference, surfaceId);
+ }
+
+ private static void AddPlane(BrepGeometryStore geometry, BrepBindingModel bindings, FaceId face, Point3D origin, Vector3D normal, Vector3D reference, int surfaceId)
+ {
+ geometry.AddSurface(new SurfaceGeometryId(surfaceId), SurfaceGeometry.FromPlane(new PlaneSurface(origin, Direction3D.Create(normal), Direction3D.Create(reference))));
+ bindings.AddFaceBinding(new FaceGeometryBinding(face, new SurfaceGeometryId(surfaceId)));
+ }
+
+ private static LoopId AddLoop(TopologyBuilder b, IReadOnlyList<Use> uses)
+ {
+ var loopId = b.AllocateLoopId();
+ var coedgeIds = uses.Select(_ => b.AllocateCoedgeId()).ToArray();
+ for (var i = 0; i < uses.Count; i++)
+ {
+ var next = coedgeIds[(i + 1) % coedgeIds.Length];
+ var previous = coedgeIds[(i + coedgeIds.Length - 1) % coedgeIds.Length];
+ b.AddCoedge(new Coedge(coedgeIds[i], uses[i].Edge, loopId, next, previous, uses[i].Reversed));
+ }
+
+ b.AddLoop(new Loop(loopId, coedgeIds));
+ return loopId;
+ }
+
+ private static FaceId AddFaceWithLoop(TopologyBuilder builder, IReadOnlyList<Use> edgeUses) => builder.AddFace([AddLoop(builder, edgeUses)]);
+
+ private readonly record struct Use(EdgeId Edge, bool Reversed)
+ {
+ public static Use F(EdgeId edge) => new(edge, false);
+ public static Use R(EdgeId edge) => new(edge, true);
+ }
+}
diff --git a/Aetheris.Kernel.Core/Properties/InternalsVisibleTo.cs b/Aetheris.Kernel.Core/Properties/InternalsVisibleTo.cs
index 9f0f286c..0f112634 100644
--- a/Aetheris.Kernel.Core/Properties/InternalsVisibleTo.cs
+++ b/Aetheris.Kernel.Core/Properties/InternalsVisibleTo.cs
@@ -1,3 +1,5 @@
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Aetheris.Kernel.Core.Tests")]
+[assembly: InternalsVisibleTo("Aetheris.Firmament.FrictionLab")]
+[assembly: InternalsVisibleTo("Aetheris.FrictionLab.Tests")]
diff --git a/docs/edge-a1-chamfer-fillet-support-compatibility-matrix.md b/docs/edge-a1-chamfer-fillet-support-compatibility-matrix.md
index db462437..91b6aa5f 100644
--- a/docs/edge-a1-chamfer-fillet-support-compatibility-matrix.md
+++ b/docs/edge-a1-chamfer-fillet-support-compatibility-matrix.md
@@ -8,7 +8,7 @@ The current AirChamfer golden path is strong but narrow: controlled convex plana
Legacy bounded chamfer/fillet behavior remains authoritative wherever production behavior exists. In particular, `BrepBoundedChamfer` and `BrepBoundedFillet` are still the production routes for the currently supported bounded cases, and AirEdgeSweep/AirChamfer evidence must not be read as route replacement.
-EDGE-A2 reclassifies some chamfer cases as profile/profile-stack candidates rather than AirEdgeSweep candidates: vertical edges of history-known extrusions should be tested as profile modifications, and top/bottom extrusion edges should be tested as profile-stack or section-transition constructions. EDGE-PROFILE-X1 now provides lab evidence for the vertical-edge/profile-authored subset, EDGE-PROFILE-V1 packages that proof into an internal production-adjacent emitter, and EDGE-PROFILE-X2 provides lab-only section-transition evidence for one top horizontal +X side chamfer while documenting current profile-stack generalization blockers. EDGE-PRISMATIC-A0 classifies those top/bottom/horizontal history-known chamfers under the **prismatic section-transition** roadmap, EDGE-PRISMATIC-X1 introduces the first reusable lab-only prismatic emitter, and EDGE-PRISMATIC-X2 re-expresses the top +X witness through that emitter. Production statuses remain unchanged until a separately gated route is admitted.
+EDGE-A2 reclassifies some chamfer cases as profile/profile-stack candidates rather than AirEdgeSweep candidates: vertical edges of history-known extrusions should be tested as profile modifications, and top/bottom extrusion edges should be tested as profile-stack or section-transition constructions. EDGE-PROFILE-X1 now provides lab evidence for the vertical-edge/profile-authored subset, EDGE-PROFILE-V1 packages that proof into an internal production-adjacent emitter, and EDGE-PROFILE-X2 provides lab-only section-transition evidence for one top horizontal +X side chamfer while documenting current profile-stack generalization blockers. EDGE-PRISMATIC-A0 classifies those top/bottom/horizontal history-known chamfers under the **prismatic section-transition** roadmap, EDGE-PRISMATIC-X1 introduces the first reusable lab-only prismatic emitter, EDGE-PRISMATIC-X2 re-expresses the top +X witness through that emitter, EDGE-PRISMATIC-X3 proves equal-count line-only generic polygon cases, and EDGE-PRISMATIC-V1 packages that capability behind an internal production-adjacent seam. Production statuses remain unchanged until a separately gated route is admitted.
The matrix separates five concerns that were previously easy to conflate:
@@ -273,3 +273,8 @@ This milestone does not include:
- test weakening;
- triangle migration retry;
- sketch solver or clipping engine work.
+
+
+## EDGE-PRISMATIC-V1 status note
+
+The prismatic section-transition row is now **internal production-adjacent / not routed** for Z-axis two/three-section, line-only, one-outer-loop, no-hole, equal-count identity-correspondence transitions. Rectangle, pentagon, hexagon, asymmetric pentagon, and stable+transition rectangle cases validate the topology formula and STEP smoke through the existing exporter. No production chamfer/fillet behavior, ProfileStack behavior, STEP exporter/importer behavior, Boolean core behavior, AirEdgeSweep behavior, public API, triangle migration, sketch solver, clipping engine, or NURBS/freeform support changed.
diff --git a/docs/edge-prismatic-a0-section-transition-contract-audit.md b/docs/edge-prismatic-a0-section-transition-contract-audit.md
index 479fef7f..58a56ddb 100644
--- a/docs/edge-prismatic-a0-section-transition-contract-audit.md
+++ b/docs/edge-prismatic-a0-section-transition-contract-audit.md
@@ -447,3 +447,7 @@ EDGE-PRISMATIC-X3 now broadens the contract evidence with a lab-only generic pol
The observed two-section topology convention matches the audit formula: `vertices = 2n`, `edges = 3n`, `faces = n + 2`, `planar faces = n + 2`, `cylindrical faces = 0`, `loops = n + 2`, and `coedges = 6n`. Invalid/deferred rows still reject or defer before emission for mismatched counts, missing correspondence, invalid profiles, non-increasing/zero section spans, holes, line+arc markers, and multiple-loop markers.
This remains contract evidence only. It does not change production chamfer/fillet behavior, production route selection, `ProfileStackExtrudeExecutor`, AirEdgeSweep, `BrepBoundedChamfer`, STEP exporter/importer code, Boolean core code, triangle migration, sketch solving, clipping, or NURBS/freeform support.
+
+## V1 implementation status
+
+EDGE-PRISMATIC-V1 implements the first production-adjacent internal seam for the A0 contract under `Aetheris.Kernel.Core.Brep.Prismatic.PrismaticSectionTransitionEmitter`. It admits only Z-stacked two/three section, line-only, one-outer-loop, no-hole, equal-count, identity-correspondence transitions with planar faces and direct closed BRep emission. It does not change production ProfileStack behavior, chamfer/fillet routing, STEP import/export behavior, Boolean core behavior, AirEdgeSweep behavior, or public APIs.
diff --git a/docs/edge-prismatic-v1-section-transition-emitter.md b/docs/edge-prismatic-v1-section-transition-emitter.md
new file mode 100644
index 00000000..1cfb21b5
--- /dev/null
+++ b/docs/edge-prismatic-v1-section-transition-emitter.md
@@ -0,0 +1,185 @@
+# EDGE-PRISMATIC-V1 — Internal prismatic section-transition emitter seam
+
+## 1. Purpose and scope
+
+EDGE-PRISMATIC-V1 packages the lab-proven prismatic section-transition emitter behind an internal, production-adjacent seam named `PrismaticSectionTransitionEmitter`. The seam is intentionally bounded: it makes the admissibility, request/result model, diagnostics, topology summary, and optional STEP smoke explicit without routing any production operation through the emitter.
+
+The component lives in `Aetheris.Kernel.Core.Brep.Prismatic` and is `internal`. It is visible to FrictionLab and test assemblies for controlled evidence only. There are no public API changes and no production route replacements.
+
+## 2. References
+
+- EDGE-PRISMATIC-A0: `docs/edge-prismatic-a0-section-transition-contract-audit.md`.
+- EDGE-PRISMATIC-X1: `docs/frictionlab/edge-prismatic-x1-section-transition-emitter-lab.md`.
+- EDGE-PRISMATIC-X2: `docs/frictionlab/edge-prismatic-x2-top-edge-chamfer-through-prismatic-emitter-lab.md`.
+- EDGE-PRISMATIC-X3: `docs/frictionlab/edge-prismatic-x3-generic-line-profile-transition-lab.md`.
+- V2 sweep-first architecture: `docs/aetheris-v2-sweep-first-architecture.md`.
+- Resolved Profile2D contract: `docs/aetheris-v2-a1-resolved-profile2d-contract.md`.
+- Constructive chamfer reframing audit: `docs/edge-a2-constructive-chamfer-reframing-audit.md`.
+
+## 3. Component and internal API shape
+
+The production-adjacent seam is:
+
+- `PrismaticSectionTransitionEmitter.Emit(PrismaticSectionTransitionRequest request)`.
+- `PrismaticSectionTransitionRequest` with sections, explicit correspondence, options, and deterministic diagnostics produced in the result.
+- `PrismaticSectionTransitionResult` with status, optional body, topology summary, optional STEP smoke summary, diagnostics, and recommendation.
+- `PrismaticSection`, `PrismaticCorrespondenceMap`, `PrismaticSectionTransitionOptions`, `PrismaticTransitionTopologySummary`, and `PrismaticSectionTransitionStepSummary`.
+
+Result statuses are `Succeeded`, `Rejected`, `Deferred`, and `Failed`. Successful first-scope requests return a closed `BrepBody`; rejected/deferred requests return no body.
+
+## 4. Supported first-scope contract
+
+V1 admits only:
+
+- Z-axis stacked sections.
+- Two or three sections.
+- One line-only outer loop per section.
+- No holes.
+- No arcs.
+- No multiple outer loops.
+- Equal vertex/edge count across all sections.
+- Explicit identity correspondence by index.
+- Stable orientation across sections.
+- Planar transition faces only.
+- Deterministic orientation and deterministic diagnostics.
+- Direct closed BRep emission.
+- Optional STEP smoke through the existing `Step242Exporter`.
+
+## 5. Data model
+
+### Sections and profiles
+
+A `PrismaticSection` contains a Z value and an ordered closed outer-loop vertex list in XY. The loop is implicit: the final profile edge connects the last vertex back to the first vertex. First scope profiles are line-only; holes, arcs, and multiple loops are represented as unsupported flags and deterministically deferred.
+
+### Correspondence
+
+`PrismaticCorrespondenceMap.Identity(n)` is the only admitted correspondence in V1. This makes the first vertex in each section correspond to the first vertex in every other section, the second to the second, and so on. Non-identity or missing correspondence is rejected before emission.
+
+### Result and topology summary
+
+The result reports topology counts for vertices, edges, cap faces, transition faces, planar/cylindrical faces, loops, coedges, stable-vs-changed interval faces, and bounds. This makes the seam machine-checkable without inspecting STEP text as the primary source of topology truth.
+
+## 6. Emission model
+
+For admitted requests the emitter:
+
+1. Creates section vertices at each `(x, y, z)` profile point.
+2. Creates profile edges within each section.
+3. Creates transition edges between corresponding vertices across adjacent sections.
+4. Creates one cap face at the first section and one cap face at the last section.
+5. Creates one transition face per corresponding profile edge per interval.
+6. Binds each edge to a line curve.
+7. Binds each cap and transition face to a plane surface.
+8. Preserves split faces at section boundaries.
+9. Does not merge coplanar faces in V1.
+
+## 7. Success cases and topology formula
+
+The focused tests cover:
+
+1. Two-section rectangle -> centered inset rectangle.
+2. Two-section scaled pentagon.
+3. Two-section scaled hexagon.
+4. Two-section asymmetric translated pentagon.
+5. Three-section stable+transition rectangle.
+
+For a two-section line-only profile with `n` vertices, observed and asserted counts are:
+
+- vertices: `2n`;
+- edges: `3n`;
+- faces: `n + 2`;
+- planar faces: `n + 2`;
+- cylindrical faces: `0`;
+- transition faces: `n`;
+- cap faces: `2`;
+- loops: `n + 2` under the current one-loop-per-face convention;
+- coedges: `6n`, with `4n` transition coedges and `2n` cap coedges.
+
+Observed V1 values:
+
+| Case | n | Vertices | Edges | Faces | Planar | Cylindrical | Loops | Coedges |
+| --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
+| rectangle -> inset rectangle | 4 | 8 | 12 | 6 | 6 | 0 | 6 | 24 |
+| scaled pentagon | 5 | 10 | 15 | 7 | 7 | 0 | 7 | 30 |
+| scaled hexagon | 6 | 12 | 18 | 8 | 8 | 0 | 8 | 36 |
+| asymmetric translated pentagon | 5 | 10 | 15 | 7 | 7 | 0 | 7 | 30 |
+| three-section stable+transition rectangle | 4 | 12 | 20 | 10 | 10 | 0 | 10 | 40 |
+
+The three-section rectangle preserves split interval faces: four stable lower interval faces and four changed upper transition faces.
+
+## 8. STEP smoke findings
+
+When `RunStepSmoke` is enabled the result records marker checks against the existing STEP exporter. Successful V1 cases require these markers to be present:
+
+- `ISO-10303-21`;
+- `MANIFOLD_SOLID_BREP`;
+- `ADVANCED_FACE`;
+- `PLANE`.
+
+Successful V1 cases require these markers to remain absent:
+
+- `CYLINDRICAL_SURFACE`;
+- `BREP_WITH_VOIDS`.
+
+STEP smoke is validation only. V1 does not change the STEP exporter or importer.
+
+## 9. Invalid and deferred cases
+
+V1 rejects deterministically for:
+
+- fewer than two sections;
+- non-finite Z;
+- non-increasing Z, including zero interval span;
+- invalid profile;
+- self-intersecting profile;
+- mismatched vertex count;
+- missing correspondence;
+- non-identity correspondence;
+- reversed/unstable orientation;
+- non-planar transition faces.
+
+V1 defers deterministically for:
+
+- more than three sections;
+- holes;
+- line+arc profiles;
+- multiple outer loops.
+
+Diagnostics are stable strings such as `edge-prismatic-v1-request-rejected:<reason>` and `edge-prismatic-v1-request-deferred:<reason>` plus specific machine-checkable diagnostics including `edge-prismatic-v1-invalid-profile-rejected`, `edge-prismatic-v1-mismatched-vertex-count-rejected`, and `edge-prismatic-v1-holes-deferred`.
+
+## 10. No-trim/no-graft/no-forbidden-route guarantee
+
+V1 emits the whole closed BRep directly from section evidence. It does not trim an existing body, graft topology, mutate a body, invoke AirEdgeSweep, invoke `BrepBoundedChamfer`, invoke 3D Boolean, use a sketch solver, use a clipping engine, or introduce NURBS/freeform support. Successful diagnostics include:
+
+- `edge-prismatic-v1-no-air-edge-sweep-used`;
+- `edge-prismatic-v1-no-brep-bounded-chamfer-used`;
+- `edge-prismatic-v1-no-topology-graft-used`;
+- `edge-prismatic-v1-no-3d-boolean-used`;
+- `edge-prismatic-v1-no-production-route-replacement`.
+
+## 11. Relationship to `ProfileStackExtrudeExecutor`
+
+`ProfileStackExtrudeExecutor` is unchanged and is not replaced by V1. Current circular-hole interval behavior remains separate. V1 is only an internal production-adjacent seam around equal-count line-only outer section transitions, not a Firmament/ProfileStack production lowering route.
+
+## 12. Relationship to chamfer architecture
+
+Future history-known top/bottom/horizontal chamfers may be evaluated against this prismatic lane because they can be represented as explicit section evolution. Vertical-edge chamfers remain aligned with `ProfileVertexChamferExtrudeEmitter`. No-history/local-edge chamfers remain aligned with AirChamfer/AirEdgeSweep evidence and existing legacy bounded behavior. V1 changes none of those routes.
+
+## 13. Non-goals
+
+V1 does not add production integration, Firmament lowering, top-edge route replacement, arbitrary axes, inferred correspondence, coplanar merge policy, line+arc profiles, holes, square-to-round adapters, AirEdgeSweep/no-history chamfer routing, triangle migration, sketch solving, clipping, or NURBS/freeform support.
+
+## 14. Tests run
+
+Minimum targeted validation for the V1 seam includes:
+
+- `dotnet test Aetheris.FrictionLab.Tests/Aetheris.FrictionLab.Tests.csproj -c Release -f net10.0 --filter "PrismaticSectionTransition"`.
+
+The milestone gate also runs the requested FrictionLab, Kernel.Core, Kernel.Firmament, CLI, and full shared test commands after packaging.
+
+## 15. Recommended next milestone
+
+Recommended next steps are either:
+
+- EDGE-PRISMATIC-V2 controlled top-edge chamfer route evaluation through this seam; or
+- EDGE-PRISMATIC-X4 coplanar split/merge policy audit before any route replacement is considered.
diff --git a/docs/frictionlab/edge-prismatic-x1-section-transition-emitter-lab.md b/docs/frictionlab/edge-prismatic-x1-section-transition-emitter-lab.md
index aeff4ea2..6dd0ff92 100644
--- a/docs/frictionlab/edge-prismatic-x1-section-transition-emitter-lab.md
+++ b/docs/frictionlab/edge-prismatic-x1-section-transition-emitter-lab.md
@@ -220,3 +220,7 @@ The X2 result confirms that the emitter is a real client path for the top-edge c
## 13. EDGE-PRISMATIC-X3 follow-up
EDGE-PRISMATIC-X3 broadens the X1 evidence from rectangle and first pentagon rows into a generic line-only equal-count polygon transition lab. It adds deterministic two-section pentagon, hexagon, and asymmetric translated-polygon rows, validates the two-section topology formula (`vertices = 2n`, `edges = 3n`, `faces = n + 2`, `coedges = 6n`), and preserves the same lab-only no-AirEdgeSweep/no-BrepBoundedChamfer/no-graft/no-3D-Boolean constraints.
+
+## V1 packaging status
+
+EDGE-PRISMATIC-V1 packages the X1 lab emitter capability behind the internal production-adjacent `Aetheris.Kernel.Core.Brep.Prismatic.PrismaticSectionTransitionEmitter` seam. The FrictionLab X1 caller now remains a thin lab compatibility layer over that seam so the original evidence stays green while request/result diagnostics, topology summary, optional STEP smoke, and guardrails are centralized.
diff --git a/docs/frictionlab/edge-prismatic-x2-top-edge-chamfer-through-prismatic-emitter-lab.md b/docs/frictionlab/edge-prismatic-x2-top-edge-chamfer-through-prismatic-emitter-lab.md
index 8efa027b..04c09fe0 100644
--- a/docs/frictionlab/edge-prismatic-x2-top-edge-chamfer-through-prismatic-emitter-lab.md
+++ b/docs/frictionlab/edge-prismatic-x2-top-edge-chamfer-through-prismatic-emitter-lab.md
@@ -140,3 +140,7 @@ If broader evidence is desired before route admission, X3 is the safer next step
## 12. EDGE-PRISMATIC-X3 follow-up
EDGE-PRISMATIC-X3 confirms that the `PrismaticSectionTransitionEmitter` is not chamfer-specific. The generic lab emits rectangle-to-inset-rectangle, scaled pentagon, scaled hexagon, and asymmetric equal-count polygon transitions through the same direct prismatic emitter path, with STEP smoke and topology-formula validation, while leaving X2's top-edge chamfer witness and all production chamfer/fillet behavior unchanged.
+
+## V1 packaging status
+
+EDGE-PRISMATIC-V1 is now the preferred reusable seam for this lab witness. X2 remains lab-only and does not route production top-edge chamfers, but its section stack can be emitted through the internal production-adjacent `PrismaticSectionTransitionEmitter` rather than carrying an independent emitter implementation.
diff --git a/docs/frictionlab/edge-prismatic-x3-generic-line-profile-transition-lab.md b/docs/frictionlab/edge-prismatic-x3-generic-line-profile-transition-lab.md
index a818645f..1d7cdd11 100644
--- a/docs/frictionlab/edge-prismatic-x3-generic-line-profile-transition-lab.md
+++ b/docs/frictionlab/edge-prismatic-x3-generic-line-profile-transition-lab.md
@@ -153,3 +153,7 @@ X3 supports `prismatic-section-transition-generic-ready-for-production-evaluatio
2. **EDGE-PRISMATIC-X4 coplanar split/merge policy audit** if the next uncertainty is whether stable and changed coplanar interval faces should remain split or be merged for production-adjacent output.
Do not broaden to arcs, holes, different vertex counts, inferred correspondence, clipping, sketch solving, or NURBS/freeform support as part of this X3 result.
+
+## V1 packaging status
+
+EDGE-PRISMATIC-V1 packages the generic X3 evidence into the internal production-adjacent `PrismaticSectionTransitionEmitter` seam. The rectangle, scaled pentagon, scaled hexagon, and asymmetric translated pentagon cases remain regression evidence for the equal-count line-only first-scope contract.