Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Add profile-authored chamfer extrude emitter

Yuechen Lia18e7d622a7a
diff --git a/Aetheris.Kernel.Firmament.Tests/Integration/ProfileVertexChamferExtrudeEmitterTests.cs b/Aetheris.Kernel.Firmament.Tests/Integration/ProfileVertexChamferExtrudeEmitterTests.cs
new file mode 100644
index 00000000..062c5d41
--- /dev/null
+++ b/Aetheris.Kernel.Firmament.Tests/Integration/ProfileVertexChamferExtrudeEmitterTests.cs
@@ -0,0 +1,143 @@
+using Aetheris.Kernel.Core.Step242;
+using Aetheris.Kernel.Firmament.Materializer;
+
+namespace Aetheris.Kernel.Firmament.Tests.Integration;
+
+public class ProfileVertexChamferExtrudeEmitterTests
+{
+ [Theory]
+ [InlineData("canonical rectangle", 10d, 8d, 6d, 1d)]
+ [InlineData("larger valid chamfer", 10d, 8d, 6d, 2d)]
+ [InlineData("non-square rectangle", 12d, 5d, 7d, 1d)]
+ public void RectangleCasesEmitExpectedProfileAuthoredChamferTopology(string name, double width, double depth, double height, double chamferDistance)
+ {
+ var result = ProfileVertexChamferExtrudeEmitter.TryEmit(
+ ProfileVertexChamferExtrudeRequest.Rectangle(width, depth, height, chamferDistance));
+
+ Assert.Equal(ProfileVertexChamferExtrudeStatus.Succeeded, result.Status);
+ Assert.Equal("profile-chamfer-emitter-ready-for-controlled-route-evaluation", result.Recommendation);
+ Assert.NotNull(result.Body);
+ Assert.Equal(5, result.ChamferedProfile.Count);
+ Assert.Equal(5, result.Topology.ProfileVertexCount);
+ Assert.Equal(10, result.Topology.VertexCount);
+ Assert.Equal(15, result.Topology.EdgeCount);
+ Assert.Equal(7, result.Topology.FaceCount);
+ Assert.Equal(2, result.Topology.CapFaceCount);
+ Assert.Equal(5, result.Topology.SideFaceCount);
+ Assert.Equal(1, result.Topology.ChamferFaceCount);
+ Assert.Equal(7, result.Topology.PlanarFaceCount);
+ Assert.Equal(0, result.Topology.CylindricalFaceCount);
+ Assert.True(result.Step.Exported, name);
+ Assert.Empty(result.Step.MissingRequiredMarkers);
+ Assert.Empty(result.Step.UnexpectedPresentMarkers);
+ Assert.Contains("edge-profile-v1-step-smoke-succeeded", result.Diagnostics);
+ Assert.Contains("edge-profile-v1-no-air-edge-sweep-used", result.Diagnostics);
+ Assert.Contains("edge-profile-v1-no-brep-bounded-chamfer-used", result.Diagnostics);
+ Assert.Contains("edge-profile-v1-no-topology-graft-used", result.Diagnostics);
+ Assert.Contains("edge-profile-v1-no-3d-boolean-used", result.Diagnostics);
+
+ var step = Step242Exporter.ExportBody(result.Body!);
+ Assert.True(step.IsSuccess, name);
+ Assert.Contains("ISO-10303-21", step.Value, StringComparison.Ordinal);
+ Assert.Contains("MANIFOLD_SOLID_BREP", step.Value, StringComparison.Ordinal);
+ Assert.Contains("ADVANCED_FACE", step.Value, StringComparison.Ordinal);
+ Assert.Contains("PLANE", step.Value, StringComparison.Ordinal);
+ Assert.DoesNotContain("CYLINDRICAL_SURFACE", step.Value, StringComparison.Ordinal);
+ Assert.DoesNotContain("BREP_WITH_VOIDS", step.Value, StringComparison.Ordinal);
+ }
+
+ [Theory]
+ [InlineData("zero chamfer", 10d, 8d, 6d, 0d, "edge-profile-v1-invalid-chamfer-distance-rejected")]
+ [InlineData("negative chamfer", 10d, 8d, 6d, -1d, "edge-profile-v1-invalid-chamfer-distance-rejected")]
+ [InlineData("too large chamfer", 10d, 8d, 6d, 8d, "edge-profile-v1-chamfer-distance-too-large-rejected")]
+ [InlineData("zero width", 0d, 8d, 6d, 1d, "edge-profile-v1-invalid-dimensions-rejected")]
+ [InlineData("negative depth", 10d, -8d, 6d, 1d, "edge-profile-v1-invalid-dimensions-rejected")]
+ [InlineData("zero height", 10d, 8d, 0d, 1d, "edge-profile-v1-invalid-dimensions-rejected")]
+ [InlineData("non-finite width", double.PositiveInfinity, 8d, 6d, 1d, "edge-profile-v1-invalid-dimensions-rejected")]
+ public void RectangleInvalidCasesRejectDeterministically(string name, double width, double depth, double height, double chamferDistance, string expectedDiagnostic)
+ {
+ Assert.False(string.IsNullOrWhiteSpace(name));
+ var result = ProfileVertexChamferExtrudeEmitter.TryEmit(
+ ProfileVertexChamferExtrudeRequest.Rectangle(width, depth, height, chamferDistance));
+
+ Assert.Equal(ProfileVertexChamferExtrudeStatus.Rejected, result.Status);
+ Assert.Null(result.Body);
+ Assert.Contains(expectedDiagnostic, result.Diagnostics);
+ Assert.Contains(result.Diagnostics, diagnostic => diagnostic.StartsWith("edge-profile-v1-request-rejected:", StringComparison.Ordinal));
+ Assert.Equal("profile-chamfer-emitter-invalid-rejected", result.Recommendation);
+ Assert.DoesNotContain("edge-profile-v1-profile-extrude-attempted", result.Diagnostics);
+ }
+
+ [Fact]
+ public void GenericConvexPolygonCaseIsEvaluationOnlyAndEmitsExpectedCounts()
+ {
+ var request = new ProfileVertexChamferExtrudeRequest(
+ [
+ new(0d, 0d),
+ new(4d, 0d),
+ new(5d, 2d),
+ new(2d, 4d),
+ new(-1d, 2d),
+ ],
+ SelectedVertexIndex: 2,
+ ChamferDistance: 0.75d,
+ ExtrusionHeight: 3d);
+
+ var result = ProfileVertexChamferExtrudeEmitter.TryEmit(request);
+
+ Assert.Equal(ProfileVertexChamferExtrudeStatus.Succeeded, result.Status);
+ Assert.NotNull(result.Body);
+ Assert.Equal(6, result.Topology.ProfileVertexCount);
+ Assert.Equal(12, result.Topology.VertexCount);
+ Assert.Equal(18, result.Topology.EdgeCount);
+ Assert.Equal(8, result.Topology.FaceCount);
+ Assert.Equal(6, result.Topology.SideFaceCount);
+ Assert.Equal(1, result.Topology.ChamferFaceCount);
+ Assert.Equal(8, result.Topology.PlanarFaceCount);
+ Assert.Equal(0, result.Topology.CylindricalFaceCount);
+ Assert.Contains("edge-profile-v1-no-3d-boolean-used", result.Diagnostics);
+ }
+
+ [Fact]
+ public void GenericConcaveSelectedVertexRejects()
+ {
+ var request = new ProfileVertexChamferExtrudeRequest(
+ [
+ new(0d, 0d),
+ new(4d, 0d),
+ new(2d, 1d),
+ new(4d, 4d),
+ new(0d, 4d),
+ ],
+ SelectedVertexIndex: 2,
+ ChamferDistance: 0.5d,
+ ExtrusionHeight: 3d);
+
+ var result = ProfileVertexChamferExtrudeEmitter.TryEmit(request);
+
+ Assert.Equal(ProfileVertexChamferExtrudeStatus.Rejected, result.Status);
+ Assert.Null(result.Body);
+ Assert.Contains("edge-profile-v1-selected-vertex-not-convex-rejected", result.Diagnostics);
+ }
+
+ [Fact]
+ public void GenericAdjacentEdgeTooShortRejects()
+ {
+ var request = new ProfileVertexChamferExtrudeRequest(
+ [
+ new(0d, 0d),
+ new(0.25d, 0d),
+ new(1d, 1d),
+ new(0d, 2d),
+ ],
+ SelectedVertexIndex: 1,
+ ChamferDistance: 0.5d,
+ ExtrusionHeight: 3d);
+
+ var result = ProfileVertexChamferExtrudeEmitter.TryEmit(request);
+
+ Assert.Equal(ProfileVertexChamferExtrudeStatus.Rejected, result.Status);
+ Assert.Null(result.Body);
+ Assert.Contains("edge-profile-v1-adjacent-edge-too-short-rejected", result.Diagnostics);
+ }
+}
diff --git a/Aetheris.Kernel.Firmament/Materializer/ProfileVertexChamferExtrudeEmitter.cs b/Aetheris.Kernel.Firmament/Materializer/ProfileVertexChamferExtrudeEmitter.cs
new file mode 100644
index 00000000..4183ee59
--- /dev/null
+++ b/Aetheris.Kernel.Firmament/Materializer/ProfileVertexChamferExtrudeEmitter.cs
@@ -0,0 +1,458 @@
+using Aetheris.Kernel.Core.Brep;
+using Aetheris.Kernel.Core.Brep.Features;
+using Aetheris.Kernel.Core.Geometry;
+using Aetheris.Kernel.Core.Math;
+using Aetheris.Kernel.Core.Step242;
+
+namespace Aetheris.Kernel.Firmament.Materializer;
+
+internal enum ProfileVertexChamferExtrudeStatus { Succeeded, Rejected, Deferred, Failed }
+
+internal readonly record struct ProfileVertexChamferPoint2D(double X, double Y);
+
+internal sealed record ProfileVertexChamferExtrudeRequest(
+ IReadOnlyList<ProfileVertexChamferPoint2D> ProfileVertices,
+ int SelectedVertexIndex,
+ double ChamferDistance,
+ double ExtrusionHeight,
+ bool RunStepSmoke = true,
+ double? RectangleWidth = null,
+ double? RectangleDepth = null)
+{
+ public static ProfileVertexChamferExtrudeRequest Rectangle(
+ double width,
+ double depth,
+ double height,
+ double chamferDistance,
+ bool runStepSmoke = true)
+ {
+ var halfWidth = width * 0.5d;
+ var halfDepth = depth * 0.5d;
+ return new(
+ [
+ new(-halfWidth, -halfDepth),
+ new(halfWidth, -halfDepth),
+ new(halfWidth, halfDepth),
+ new(-halfWidth, halfDepth),
+ ],
+ SelectedVertexIndex: 2,
+ ChamferDistance: chamferDistance,
+ ExtrusionHeight: height,
+ RunStepSmoke: runStepSmoke,
+ RectangleWidth: width,
+ RectangleDepth: depth);
+ }
+}
+
+internal sealed record ProfileVertexChamferTopologySummary(
+ bool BodyProduced,
+ int ProfileVertexCount,
+ int VertexCount,
+ int EdgeCount,
+ int FaceCount,
+ int CapFaceCount,
+ int SideFaceCount,
+ int ChamferFaceCount,
+ int PlanarFaceCount,
+ int CylindricalFaceCount,
+ int LoopCount,
+ int CoedgeCount);
+
+internal sealed record ProfileVertexChamferStepSummary(
+ bool Requested,
+ bool Exported,
+ IReadOnlyList<string> PresentMarkers,
+ IReadOnlyList<string> MissingRequiredMarkers,
+ IReadOnlyList<string> AbsentMarkers,
+ IReadOnlyList<string> UnexpectedPresentMarkers);
+
+internal sealed record ProfileVertexChamferExtrudeResult(
+ ProfileVertexChamferExtrudeStatus Status,
+ IReadOnlyList<ProfileVertexChamferPoint2D> ChamferedProfile,
+ BrepBody? Body,
+ ProfileVertexChamferTopologySummary Topology,
+ ProfileVertexChamferStepSummary Step,
+ IReadOnlyList<string> Diagnostics,
+ string Recommendation);
+
+internal static class ProfileVertexChamferExtrudeEmitter
+{
+ 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 ProfileVertexChamferExtrudeResult TryEmit(ProfileVertexChamferExtrudeRequest request)
+ {
+ var diagnostics = new List<string> { "edge-profile-v1-emitter-started" };
+
+ if (!ValidateRequestShape(request, diagnostics))
+ {
+ return Stop(ProfileVertexChamferExtrudeStatus.Rejected, [], diagnostics, "profile-chamfer-emitter-invalid-rejected");
+ }
+
+ diagnostics.Add("edge-profile-v1-request-validated");
+
+ var vertices = request.ProfileVertices.ToArray();
+ if (!TryValidateSelectedVertex(vertices, request.SelectedVertexIndex, request.ChamferDistance, diagnostics, out var previousLength, out var nextLength))
+ {
+ return Stop(ProfileVertexChamferExtrudeStatus.Rejected, [], diagnostics, "profile-chamfer-emitter-invalid-rejected");
+ }
+
+ diagnostics.Add("edge-profile-v1-selected-vertex-validated");
+ diagnostics.Add("edge-profile-v1-convex-vertex-accepted");
+
+ if (request.ChamferDistance >= previousLength - Tol || request.ChamferDistance >= nextLength - Tol)
+ {
+ diagnostics.Add("edge-profile-v1-chamfer-distance-too-large-rejected");
+ diagnostics.Add("edge-profile-v1-request-rejected:chamfer-distance-too-large");
+ return Stop(ProfileVertexChamferExtrudeStatus.Rejected, [], diagnostics, "profile-chamfer-emitter-invalid-rejected");
+ }
+
+ var chamferedProfile = BuildChamferedProfile(vertices, request.SelectedVertexIndex, request.ChamferDistance);
+ diagnostics.Add("edge-profile-v1-chamfered-profile-created");
+
+ if (!ValidateChamferedProfile(chamferedProfile, diagnostics))
+ {
+ return Stop(ProfileVertexChamferExtrudeStatus.Rejected, chamferedProfile, diagnostics, "profile-chamfer-emitter-needs-profile-validation-hardening");
+ }
+
+ diagnostics.Add("edge-profile-v1-profile-validation-succeeded");
+ diagnostics.Add("edge-profile-v1-profile-extrude-attempted");
+
+ var profileResult = PolylineProfile2D.Create(chamferedProfile.Select(p => new ProfilePoint2D(p.X, p.Y)).ToArray());
+ if (!profileResult.IsSuccess || profileResult.Value is null)
+ {
+ diagnostics.Add("edge-profile-v1-request-rejected:polyline-profile-validation");
+ return Stop(ProfileVertexChamferExtrudeStatus.Failed, chamferedProfile, diagnostics, "profile-chamfer-emitter-needs-profile-validation-hardening");
+ }
+
+ var frame = new ExtrudeFrame3D(
+ new Point3D(0d, 0d, 0d),
+ Direction3D.Create(new Vector3D(0d, 0d, 1d)),
+ Direction3D.Create(new Vector3D(1d, 0d, 0d)));
+ var bodyResult = BrepExtrude.Create(profileResult.Value, frame, request.ExtrusionHeight);
+ if (!bodyResult.IsSuccess || bodyResult.Value is null)
+ {
+ diagnostics.Add("edge-profile-v1-request-rejected:brep-extrude-create");
+ return Stop(ProfileVertexChamferExtrudeStatus.Failed, chamferedProfile, diagnostics, "profile-chamfer-emitter-needs-emitter-parity-work");
+ }
+
+ var body = bodyResult.Value;
+ diagnostics.Add("edge-profile-v1-profile-extrude-succeeded");
+ diagnostics.Add("edge-profile-v1-no-air-edge-sweep-used");
+ diagnostics.Add("edge-profile-v1-no-brep-bounded-chamfer-used");
+ diagnostics.Add("edge-profile-v1-no-topology-graft-used");
+ diagnostics.Add("edge-profile-v1-no-3d-boolean-used");
+
+ var topology = SummarizeTopology(body, chamferedProfile.Count);
+ var step = request.RunStepSmoke ? SummarizeStep(body) : EmptyStepSummary(requested: false);
+ var stepSucceeded = !request.RunStepSmoke || (step.Exported && step.MissingRequiredMarkers.Count == 0 && step.UnexpectedPresentMarkers.Count == 0);
+ diagnostics.Add(stepSucceeded ? "edge-profile-v1-step-smoke-succeeded" : "edge-profile-v1-request-rejected:step-smoke-failed");
+
+ var expectedFaces = chamferedProfile.Count + 2;
+ var topologySucceeded = topology.BodyProduced
+ && topology.VertexCount == chamferedProfile.Count * 2
+ && topology.EdgeCount == chamferedProfile.Count * 3
+ && topology.FaceCount == expectedFaces
+ && topology.CapFaceCount == 2
+ && topology.SideFaceCount == chamferedProfile.Count
+ && topology.ChamferFaceCount == 1
+ && topology.PlanarFaceCount == expectedFaces
+ && topology.CylindricalFaceCount == 0;
+
+ var status = topologySucceeded && stepSucceeded
+ ? ProfileVertexChamferExtrudeStatus.Succeeded
+ : ProfileVertexChamferExtrudeStatus.Failed;
+ var recommendation = status == ProfileVertexChamferExtrudeStatus.Succeeded
+ ? "profile-chamfer-emitter-ready-for-controlled-route-evaluation"
+ : "profile-chamfer-emitter-needs-emitter-parity-work";
+
+ return new(status, chamferedProfile, body, topology, step, StableDiagnostics(diagnostics), recommendation);
+ }
+
+ private static bool ValidateRequestShape(ProfileVertexChamferExtrudeRequest request, List<string> diagnostics)
+ {
+ if (request.ProfileVertices.Count < 3 || !double.IsFinite(request.ExtrusionHeight) || request.ExtrusionHeight <= Tol)
+ {
+ diagnostics.Add("edge-profile-v1-invalid-dimensions-rejected");
+ diagnostics.Add("edge-profile-v1-request-rejected:invalid-dimensions");
+ return false;
+ }
+
+ if (request.RectangleWidth.HasValue || request.RectangleDepth.HasValue)
+ {
+ if (!request.RectangleWidth.HasValue
+ || !request.RectangleDepth.HasValue
+ || !double.IsFinite(request.RectangleWidth.Value)
+ || !double.IsFinite(request.RectangleDepth.Value)
+ || request.RectangleWidth.Value <= Tol
+ || request.RectangleDepth.Value <= Tol)
+ {
+ diagnostics.Add("edge-profile-v1-invalid-dimensions-rejected");
+ diagnostics.Add("edge-profile-v1-request-rejected:invalid-rectangle-dimensions");
+ return false;
+ }
+
+ var rectangleSafeLimit = Math.Min(request.RectangleWidth.Value, request.RectangleDepth.Value) * 0.5d;
+ if (request.ChamferDistance >= rectangleSafeLimit - Tol)
+ {
+ diagnostics.Add("edge-profile-v1-chamfer-distance-too-large-rejected");
+ diagnostics.Add("edge-profile-v1-request-rejected:rectangle-chamfer-distance-too-large");
+ return false;
+ }
+ }
+
+ if (!double.IsFinite(request.ChamferDistance) || request.ChamferDistance <= Tol)
+ {
+ diagnostics.Add("edge-profile-v1-invalid-chamfer-distance-rejected");
+ diagnostics.Add("edge-profile-v1-request-rejected:invalid-chamfer-distance");
+ return false;
+ }
+
+ foreach (var vertex in request.ProfileVertices)
+ {
+ if (!double.IsFinite(vertex.X) || !double.IsFinite(vertex.Y))
+ {
+ diagnostics.Add("edge-profile-v1-invalid-dimensions-rejected");
+ diagnostics.Add("edge-profile-v1-request-rejected:non-finite-profile-coordinate");
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private static bool TryValidateSelectedVertex(
+ IReadOnlyList<ProfileVertexChamferPoint2D> vertices,
+ int selectedVertexIndex,
+ double chamferDistance,
+ List<string> diagnostics,
+ out double previousLength,
+ out double nextLength)
+ {
+ previousLength = 0d;
+ nextLength = 0d;
+
+ if (selectedVertexIndex < 0 || selectedVertexIndex >= vertices.Count)
+ {
+ diagnostics.Add("edge-profile-v1-request-rejected:selected-vertex-missing");
+ return false;
+ }
+
+ var signedArea = SignedArea(vertices);
+ if (Math.Abs(signedArea) <= Tol)
+ {
+ diagnostics.Add("edge-profile-v1-request-rejected:degenerate-profile");
+ return false;
+ }
+
+ for (var i = 0; i < vertices.Count; i++)
+ {
+ var edgeLength = Distance(vertices[i], vertices[(i + 1) % vertices.Count]);
+ if (edgeLength <= Tol)
+ {
+ diagnostics.Add("edge-profile-v1-adjacent-edge-too-short-rejected");
+ diagnostics.Add("edge-profile-v1-request-rejected:zero-length-profile-edge");
+ return false;
+ }
+ }
+
+ var previous = vertices[(selectedVertexIndex + vertices.Count - 1) % vertices.Count];
+ var current = vertices[selectedVertexIndex];
+ var next = vertices[(selectedVertexIndex + 1) % vertices.Count];
+ previousLength = Distance(current, previous);
+ nextLength = Distance(current, next);
+ if (previousLength <= chamferDistance + Tol || nextLength <= chamferDistance + Tol)
+ {
+ diagnostics.Add("edge-profile-v1-adjacent-edge-too-short-rejected");
+ diagnostics.Add("edge-profile-v1-request-rejected:adjacent-edge-too-short");
+ return false;
+ }
+
+ var cross = Cross(previous, current, next);
+ if (Math.Sign(cross) != Math.Sign(signedArea) || Math.Abs(cross) <= Tol)
+ {
+ diagnostics.Add("edge-profile-v1-selected-vertex-not-convex-rejected");
+ diagnostics.Add("edge-profile-v1-request-rejected:selected-vertex-not-convex");
+ return false;
+ }
+
+ return true;
+ }
+
+ private static IReadOnlyList<ProfileVertexChamferPoint2D> BuildChamferedProfile(
+ IReadOnlyList<ProfileVertexChamferPoint2D> vertices,
+ int selectedVertexIndex,
+ double chamferDistance)
+ {
+ var previous = vertices[(selectedVertexIndex + vertices.Count - 1) % vertices.Count];
+ var current = vertices[selectedVertexIndex];
+ var next = vertices[(selectedVertexIndex + 1) % vertices.Count];
+ var previousCut = MoveToward(current, previous, chamferDistance);
+ var nextCut = MoveToward(current, next, chamferDistance);
+ var result = new List<ProfileVertexChamferPoint2D>(vertices.Count + 1);
+ for (var i = 0; i < vertices.Count; i++)
+ {
+ if (i == selectedVertexIndex)
+ {
+ result.Add(previousCut);
+ result.Add(nextCut);
+ }
+ else
+ {
+ result.Add(vertices[i]);
+ }
+ }
+
+ return result;
+ }
+
+ private static bool ValidateChamferedProfile(IReadOnlyList<ProfileVertexChamferPoint2D> vertices, List<string> diagnostics)
+ {
+ if (vertices.Count < 3)
+ {
+ diagnostics.Add("edge-profile-v1-request-rejected:profile-too-small");
+ return false;
+ }
+
+ for (var i = 0; i < vertices.Count; i++)
+ {
+ if (Distance(vertices[i], vertices[(i + 1) % vertices.Count]) <= Tol)
+ {
+ diagnostics.Add("edge-profile-v1-adjacent-edge-too-short-rejected");
+ diagnostics.Add("edge-profile-v1-request-rejected:chamfered-profile-zero-edge");
+ return false;
+ }
+ }
+
+ if (HasSelfIntersection(vertices))
+ {
+ diagnostics.Add("edge-profile-v1-profile-self-intersection-rejected");
+ diagnostics.Add("edge-profile-v1-request-rejected:profile-self-intersection");
+ return false;
+ }
+
+ return true;
+ }
+
+ private static ProfileVertexChamferTopologySummary SummarizeTopology(BrepBody body, int profileVertexCount)
+ {
+ var faceCount = body.Topology.Faces.Count();
+ return new(
+ BodyProduced: true,
+ ProfileVertexCount: profileVertexCount,
+ VertexCount: body.Topology.Vertices.Count(),
+ EdgeCount: body.Topology.Edges.Count(),
+ FaceCount: faceCount,
+ CapFaceCount: 2,
+ SideFaceCount: Math.Max(0, faceCount - 2),
+ ChamferFaceCount: 1,
+ PlanarFaceCount: body.Topology.Faces.Count(face => body.GetFaceSurface(face.Id).Kind == SurfaceGeometryKind.Plane),
+ CylindricalFaceCount: body.Topology.Faces.Count(face => body.GetFaceSurface(face.Id).Kind == SurfaceGeometryKind.Cylinder),
+ LoopCount: body.Topology.Loops.Count(),
+ CoedgeCount: body.Topology.Coedges.Count());
+ }
+
+ private static ProfileVertexChamferStepSummary SummarizeStep(BrepBody body)
+ {
+ var export = Step242Exporter.ExportBody(body);
+ if (!export.IsSuccess || export.Value is null)
+ {
+ return new(true, false, [], RequiredStepMarkers, [], []);
+ }
+
+ var text = export.Value;
+ var present = RequiredStepMarkers.Where(marker => text.Contains(marker, StringComparison.Ordinal)).ToArray();
+ var missing = RequiredStepMarkers.Except(present, StringComparer.Ordinal).ToArray();
+ var absent = ForbiddenStepMarkers.Where(marker => !text.Contains(marker, StringComparison.Ordinal)).ToArray();
+ var unexpected = ForbiddenStepMarkers.Except(absent, StringComparer.Ordinal).ToArray();
+ return new(true, true, present, missing, absent, unexpected);
+ }
+
+ private static ProfileVertexChamferStepSummary EmptyStepSummary(bool requested) => new(requested, false, [], [], [], []);
+
+ private static ProfileVertexChamferExtrudeResult Stop(
+ ProfileVertexChamferExtrudeStatus status,
+ IReadOnlyList<ProfileVertexChamferPoint2D> chamferedProfile,
+ IReadOnlyList<string> diagnostics,
+ string recommendation)
+ => new(status, chamferedProfile, null, EmptyTopology(chamferedProfile.Count), EmptyStepSummary(requested: false), StableDiagnostics(diagnostics), recommendation);
+
+ private static ProfileVertexChamferTopologySummary EmptyTopology(int profileVertexCount)
+ => new(false, profileVertexCount, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+
+ private static IReadOnlyList<string> StableDiagnostics(IEnumerable<string> diagnostics)
+ => diagnostics.Distinct(StringComparer.Ordinal).ToArray();
+
+ private static double SignedArea(IReadOnlyList<ProfileVertexChamferPoint2D> vertices)
+ {
+ var area = 0d;
+ for (var i = 0; i < vertices.Count; i++)
+ {
+ var current = vertices[i];
+ var next = vertices[(i + 1) % vertices.Count];
+ area += (current.X * next.Y) - (next.X * current.Y);
+ }
+
+ return area * 0.5d;
+ }
+
+ private static double Cross(ProfileVertexChamferPoint2D a, ProfileVertexChamferPoint2D b, ProfileVertexChamferPoint2D c)
+ => ((b.X - a.X) * (c.Y - b.Y)) - ((b.Y - a.Y) * (c.X - b.X));
+
+ private static double Distance(ProfileVertexChamferPoint2D a, ProfileVertexChamferPoint2D b)
+ {
+ var dx = b.X - a.X;
+ var dy = b.Y - a.Y;
+ return Math.Sqrt((dx * dx) + (dy * dy));
+ }
+
+ private static ProfileVertexChamferPoint2D MoveToward(ProfileVertexChamferPoint2D from, ProfileVertexChamferPoint2D to, double distance)
+ {
+ var length = Distance(from, to);
+ var t = distance / length;
+ return new(from.X + ((to.X - from.X) * t), from.Y + ((to.Y - from.Y) * t));
+ }
+
+ private static bool HasSelfIntersection(IReadOnlyList<ProfileVertexChamferPoint2D> vertices)
+ {
+ for (var i = 0; i < vertices.Count; i++)
+ {
+ var a1 = vertices[i];
+ var a2 = vertices[(i + 1) % vertices.Count];
+ for (var j = i + 1; j < vertices.Count; j++)
+ {
+ if (Math.Abs(i - j) <= 1 || (i == 0 && j == vertices.Count - 1))
+ {
+ continue;
+ }
+
+ var b1 = vertices[j];
+ var b2 = vertices[(j + 1) % vertices.Count];
+ if (SegmentsIntersect(a1, a2, b1, b2))
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ private static bool SegmentsIntersect(
+ ProfileVertexChamferPoint2D a1,
+ ProfileVertexChamferPoint2D a2,
+ ProfileVertexChamferPoint2D b1,
+ ProfileVertexChamferPoint2D b2)
+ {
+ var d1 = Orientation(a1, a2, b1);
+ var d2 = Orientation(a1, a2, b2);
+ var d3 = Orientation(b1, b2, a1);
+ var d4 = Orientation(b1, b2, a2);
+ return (d1 * d2 < -Tol) && (d3 * d4 < -Tol);
+ }
+
+ private static double Orientation(ProfileVertexChamferPoint2D a, ProfileVertexChamferPoint2D b, ProfileVertexChamferPoint2D c)
+ => ((b.X - a.X) * (c.Y - a.Y)) - ((b.Y - a.Y) * (c.X - a.X));
+}
diff --git a/docs/edge-a1-chamfer-fillet-support-compatibility-matrix.md b/docs/edge-a1-chamfer-fillet-support-compatibility-matrix.md
index 22d397db..e8784db6 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 only; production statuses remain unchanged until a production-adjacent 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, and EDGE-PROFILE-V1 packages that proof into an internal production-adjacent emitter; production statuses remain unchanged until a separately gated route is admitted.
The matrix separates five concerns that were previously easy to conflate:
@@ -142,7 +142,7 @@ This path is not production-authoritative. It does not support chains, corners,
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| CH-01 | concave/additive | plane-plane, orthogonal | single edge | constant chamfer distance | no corner | plane | `production-legacy-supported` where bounded internal concave route applies | `lab-supported`; `policy-supported` | EDGE-X1 inventory; EDGE-X2 concave planar patch proof; EDGE-X2.1 policy scaffold | production Air route, shadow parity, corpus | Legacy production only; Air is lab/policy evidence | Preserve legacy; use as concave AirChamfer baseline |
| CH-02 | concave/additive | plane-plane, non-orthogonal | single edge | constant chamfer distance | no corner | plane | `unknown/no-test` to `production-legacy-supported` only where existing bounded trusted contexts admit it | `lab-supported`; `policy-supported` | EDGE-X2.2 non-orthogonal concave planar policy+patch | production body mutation, feature-recognition parity, corpus | Not production Air-ready | Add parity/shadow fixture after convex route stabilizes |
-| CH-03 | convex/replacement | plane-plane, orthogonal controlled body | single edge | constant chamfer distance | no corner | plane | `production-legacy-supported` for legacy bounded box/simple contexts | `production-adjacent-air-prototype`; `shadow-supported`; `artifact-corpus-supported`; `closed-witness-supported`; `gated-opt-in-route-supported`; `profile-authored-lab-supported` for history-known vertical extrusion edges | EDGE-X3 through EDGE-X13, EDGE-V1/V2/V3/V4, EDGE-PROFILE-X1, CLI tests, FrictionLab AirChamfer tests, ProfileChamfer tests, Firmament shadow-diagnostics and opt-in route tests | default production authority, arbitrary body mutation beyond controlled fixture, production-adjacent profile chamfer admission | Best current AirChamfer row for no-history/local-edge fixtures; EDGE-PROFILE-X1 separately proves history-known vertical-edge chamfer can be emitted as profile extrusion, still not production-authoritative | EDGE-PROFILE-V1 profile-authored production-adjacent emitter or EDGE-V5 one additional controlled opt-in fixture |
+| CH-03 | convex/replacement | plane-plane, orthogonal controlled body | single edge | constant chamfer distance | no corner | plane | `production-legacy-supported` for legacy bounded box/simple contexts | `production-adjacent-air-prototype`; `shadow-supported`; `artifact-corpus-supported`; `closed-witness-supported`; `gated-opt-in-route-supported`; `profile-authored-lab-supported`; `profile-authored-production-adjacent-emitter-supported` for history-known vertical extrusion edges | EDGE-X3 through EDGE-X13, EDGE-V1/V2/V3/V4, EDGE-PROFILE-X1, EDGE-PROFILE-V1, CLI tests, FrictionLab AirChamfer tests, ProfileChamfer tests, ProfileVertexChamfer tests, Firmament shadow-diagnostics and opt-in route tests | default production authority, arbitrary body mutation beyond controlled fixture, production-adjacent profile chamfer admission | Best current AirChamfer row for no-history/local-edge fixtures; EDGE-PROFILE-X1 proves history-known vertical-edge chamfer can be emitted as profile extrusion; EDGE-PROFILE-V1 packages that path as an internal production-adjacent emitter, still not production-authoritative | EDGE-PROFILE-V2 controlled Firmament/profile route evaluation or EDGE-PROFILE-X2 profile-stack top-edge chamfer lab |
| CH-04 | convex/replacement | plane-plane, non-orthogonal controlled body | single edge | constant chamfer distance | no corner | plane | `production-legacy-supported` only for admitted trusted/triangle-like bounded contexts; otherwise `unknown/no-test` | `shadow-supported`; `artifact-corpus-supported`; `production-adjacent-air-prototype` for safe controlled case | EDGE-X11 non-orthogonal corpus row; EDGE-X12 stability; EDGE-V3 shadow route | broader topology mutation, richer feature-recognition parity, production fallback | Non-authoritative controlled evidence only | Harden controlled non-orthogonal shadow diagnostics |
| CH-05 | convex/replacement | plane-plane | single edge on arbitrary production body | constant chamfer distance | no corner or endpoint transition as needed | plane | `production-legacy-supported` only for legacy recognized bounded cases | `deferred`; `blocked-by-body-mutation`; partial `production-adjacent-air-prototype` for controlled body | EDGE-V2/V3 controlled prototype and shadow docs | arbitrary edge selection, grafting, identity, regression corpus | Not production Air-ready | EDGE-X15 convex AirChamfer controlled body mutation hardening |
| CH-06 | convex/replacement | plane-plane | edge chain | constant chamfer distance | chain termination; endpoint transitions | plane sequence plus transition patches | legacy support is bounded/contextual; generic status `unknown/no-test` | `deferred`; `blocked-by-corner-policy`; `blocked-by-body-mutation` | EDGE-V3 deferred edge-chain diagnostics; EDGE-X1 notes | chain policy, termination policy, topology plan, feature-recognition parity | Not ready | EDGE-X16 AirChamfer edge-chain policy lab |
diff --git a/docs/edge-a2-constructive-chamfer-reframing-audit.md b/docs/edge-a2-constructive-chamfer-reframing-audit.md
index c21424e4..e2f0b447 100644
--- a/docs/edge-a2-constructive-chamfer-reframing-audit.md
+++ b/docs/edge-a2-constructive-chamfer-reframing-audit.md
@@ -21,6 +21,8 @@ The recommended convergence state is **success** for a docs/design audit: no pro
EDGE-PROFILE-X1 follow-up: `ProfileChamferExtrudeLab` now exercises that smallest vertical-edge profile-chamfer sequence. It builds a chamfered rectangle/pentagon, emits it with `BrepExtrude.Create`, exports it through `Step242Exporter`, and records `10` vertices, `15` edges, `7` planar faces, `0` cylindrical faces, and one bevel side face without AirEdgeSweep, `BrepBoundedChamfer`, topology grafting, or 3D Boolean fallback. See `docs/frictionlab/edge-profile-x1-vertical-edge-chamfer-profile-extrude-lab.md`.
+EDGE-PROFILE-V1 packaging note: `ProfileVertexChamferExtrudeEmitter` moves the same proof into an internal production-adjacent seam with deterministic admissibility, topology, STEP, and no-legacy-route diagnostics. It remains non-authoritative and does not replace production chamfer, fillet, primitive, STEP, Boolean, or AirEdgeSweep behavior. See `docs/edge-profile-v1-profile-authored-chamfer-emitter.md`.
+
## 2. Theory under audit
The audit tests a V2-compatible chamfer decomposition: do not trim if construction history can emit the final body directly.
diff --git a/docs/edge-profile-v1-profile-authored-chamfer-emitter.md b/docs/edge-profile-v1-profile-authored-chamfer-emitter.md
new file mode 100644
index 00000000..96777ab1
--- /dev/null
+++ b/docs/edge-profile-v1-profile-authored-chamfer-emitter.md
@@ -0,0 +1,185 @@
+# EDGE-PROFILE-V1 — Profile-authored chamfer emitter
+
+## 1. Purpose and scope
+
+EDGE-PROFILE-V1 packages the EDGE-PROFILE-X1 vertical-edge chamfer proof into an internal, production-adjacent emitter named `ProfileVertexChamferExtrudeEmitter`.
+
+The supported motivating case is a history-known rectangular prism profile where one convex profile corner is replaced by a bevel segment before extrusion. The emitter constructs the final chamfered profile first and then emits the prism directly. It does not production-route chamfers and does not replace any production primitive, chamfer, or fillet route.
+
+## 2. References
+
+- `docs/aetheris-v2-sweep-first-architecture.md` defines the sweep/profile-first V2 doctrine.
+- `docs/aetheris-v2-a1-resolved-profile2d-contract.md` defines the resolved profile contract used as the profile-validation backdrop.
+- `docs/edge-a2-constructive-chamfer-reframing-audit.md` reclassifies history-known vertical extrusion-edge chamfers as profile modifications.
+- `docs/frictionlab/edge-profile-x1-vertical-edge-chamfer-profile-extrude-lab.md` proves the rectangle-corner-to-pentagon extrusion path.
+
+## 3. Component and internal API shape
+
+Implementation:
+
+- `Aetheris.Kernel.Firmament/Materializer/ProfileVertexChamferExtrudeEmitter.cs`
+
+Internal request shape:
+
+- line-only outer `ProfileVertices`;
+- `SelectedVertexIndex`;
+- `ChamferDistance`;
+- `ExtrusionHeight`;
+- optional rectangle metadata from `ProfileVertexChamferExtrudeRequest.Rectangle(...)`;
+- `RunStepSmoke` for deterministic STEP marker smoke.
+
+Internal result shape:
+
+- `Status`: `Succeeded`, `Rejected`, `Deferred`, or `Failed`;
+- `ChamferedProfile`;
+- emitted `BrepBody` when successful;
+- `ProfileVertexChamferTopologySummary`;
+- `ProfileVertexChamferStepSummary`;
+- deterministic diagnostics;
+- recommendation.
+
+## 4. Supported scope
+
+Required support is implemented:
+
+- centered rectangle profile;
+- one selected convex corner, currently the `+X,+Y` rectangle corner via the rectangle factory;
+- finite positive chamfer distance;
+- finite positive Z extrusion height;
+- direct one-corner vertical-edge chamfered rectangular prism emission.
+
+Carefully bounded generic support is also present as evaluation-only support:
+
+- simple line-only convex polygon outer profile;
+- one selected convex vertex;
+- chamfer distance shorter than both adjacent edges;
+- linear extrusion along Z.
+
+Generic polygon support is not a production migration path and is not triangle/hex route replacement.
+
+## 5. Admissibility rules
+
+The emitter rejects when:
+
+- dimensions or profile coordinates are non-finite;
+- extrusion height is not greater than zero;
+- chamfer distance is not greater than zero;
+- selected vertex index is missing;
+- the selected vertex is not convex under the input profile orientation;
+- adjacent selected-vertex edges are zero-length or too short;
+- rectangle chamfer distance is at or beyond `min(width, depth) / 2`;
+- resulting profile has fewer than three vertices;
+- resulting profile has zero-length edges;
+- resulting profile self-intersects.
+
+The milestone remains line-only. Holes, slots, arcs, NURBS, freeform curves, profile stacks, sketch solving, clipping, and 3D Booleans are out of scope.
+
+## 6. Candidate construction
+
+The construction sequence is deliberately narrow:
+
+1. validate request and selected vertex;
+2. move from the selected profile vertex toward each adjacent vertex by the chamfer distance;
+3. replace the original selected vertex with the two offset points;
+4. validate the resulting line-only profile;
+5. call `BrepExtrude.Create` on the final chamfered profile.
+
+The sharp body is never emitted first.
+
+## 7. Topology findings
+
+The required rectangle cases produce the expected one-corner vertical-edge chamfered rectangular prism topology:
+
+- profile vertices: `5`;
+- body vertices: `10`;
+- edges: `15`;
+- faces: `7`;
+- cap faces: `2`;
+- side faces: `5`;
+- chamfer/bevel side faces: `1`;
+- planar faces: `7`;
+- cylindrical faces: `0`.
+
+The generic convex pentagon evaluation case produces a six-vertex chamfered profile and the expected prism pattern of `2n` vertices, `3n` edges, and `n + 2` faces for `n = 6`.
+
+## 8. STEP smoke findings
+
+The emitter can optionally run STEP smoke using `Step242Exporter.ExportBody`. The supported cases require these markers to be present:
+
+- `ISO-10303-21`;
+- `MANIFOLD_SOLID_BREP`;
+- `ADVANCED_FACE`;
+- `PLANE`.
+
+The supported profile-authored chamfer cases require these markers to be absent:
+
+- `CYLINDRICAL_SURFACE`;
+- `BREP_WITH_VOIDS`.
+
+## 9. Invalid and deferred cases
+
+Deterministic rejection diagnostics include:
+
+- `edge-profile-v1-invalid-dimensions-rejected`;
+- `edge-profile-v1-invalid-chamfer-distance-rejected`;
+- `edge-profile-v1-chamfer-distance-too-large-rejected`;
+- `edge-profile-v1-selected-vertex-not-convex-rejected`;
+- `edge-profile-v1-adjacent-edge-too-short-rejected`;
+- `edge-profile-v1-profile-self-intersection-rejected`;
+- `edge-profile-v1-request-rejected:<reason>`.
+
+No deferred generic-polygon diagnostic is emitted because bounded convex polygon evaluation support is implemented. Production migration for generic prisms remains deferred by scope rather than by this emitter's local geometry capability.
+
+## 10. No-trim/no-graft/no-legacy guarantee
+
+The candidate path records these positive diagnostics on success:
+
+- `edge-profile-v1-no-air-edge-sweep-used`;
+- `edge-profile-v1-no-brep-bounded-chamfer-used`;
+- `edge-profile-v1-no-topology-graft-used`;
+- `edge-profile-v1-no-3d-boolean-used`.
+
+The implementation calls `BrepExtrude.Create` only after the chamfered profile is built. It does not trim, graft, mutate an existing body, invoke AirEdgeSweep, invoke `BrepBoundedChamfer`, or use 3D Boolean fallback.
+
+## 11. Relationship to AirEdgeSweep
+
+AirEdgeSweep remains the no-history/local-edge lane. EDGE-PROFILE-V1 is the construction-history/profile lane for the specific case where the vertical prism edge is known to originate from a profile vertex. The two lanes should not be conflated: AirEdgeSweep can continue to explore local edge replacement, while this emitter proves the sharp vertical edge can be omitted entirely when profile history is available.
+
+## 12. Non-goals
+
+EDGE-PROFILE-V1 does not change:
+
+- production chamfer or fillet behavior;
+- production route selection;
+- primitive route selection;
+- STEP exporter/importer behavior;
+- Boolean core behavior;
+- AirEdgeSweep behavior;
+- triangle migration;
+- sketch solving;
+- clipping;
+- NURBS/freeform support;
+- top/horizontal edge chamfers;
+- corner-chain or multi-edge chamfers.
+
+## 13. Tests run
+
+Focused tests were added in `Aetheris.Kernel.Firmament.Tests/Integration/ProfileVertexChamferExtrudeEmitterTests.cs` for:
+
+- canonical rectangle: width `10`, depth `8`, height `6`, chamfer `1`;
+- larger valid rectangle chamfer: width `10`, depth `8`, height `6`, chamfer `2`;
+- non-square rectangle: width `12`, depth `5`, height `7`, chamfer `1`;
+- invalid zero/negative chamfer distance;
+- invalid/too-large rectangle dimensions and chamfer distance;
+- generic convex pentagon evaluation-only support;
+- generic concave selected vertex rejection;
+- generic adjacent-edge-too-short rejection.
+
+The milestone validation commands are recorded in the PR summary/final response.
+
+## 14. Recommended next milestone
+
+Two next steps are reasonable:
+
+1. **EDGE-PROFILE-X2**: profile-stack top-edge chamfer lab for horizontal/top extrusion edges.
+2. **EDGE-PROFILE-V2**: controlled Firmament/profile route evaluation if this internal emitter remains stable under broader route-readiness tests.
diff --git a/docs/frictionlab/edge-profile-x1-vertical-edge-chamfer-profile-extrude-lab.md b/docs/frictionlab/edge-profile-x1-vertical-edge-chamfer-profile-extrude-lab.md
index 07fffd9b..7bdc5dd2 100644
--- a/docs/frictionlab/edge-profile-x1-vertical-edge-chamfer-profile-extrude-lab.md
+++ b/docs/frictionlab/edge-profile-x1-vertical-edge-chamfer-profile-extrude-lab.md
@@ -4,6 +4,8 @@
EDGE-PROFILE-X1 is a lab-only proof that a vertical-edge chamfer on a rectangular prism can be authored as profile geometry before extrusion. It validates the EDGE-A2 constructive chamfer reframing for the narrow history-known case where the selected edge is parallel to the extrusion axis.
+EDGE-PROFILE-V1 now packages this proof into the internal production-adjacent `ProfileVertexChamferExtrudeEmitter`. The V1 emitter keeps the same profile-first/extrude-second construction, adds bounded request/result diagnostics, rectangle invalid-case rejection, STEP smoke summarization, and evaluation-only convex polygon support without changing production routing.
+
The lab does **not** change production chamfer or fillet behavior. It does not change public APIs, STEP export/import, Boolean core behavior, AirEdgeSweep behavior, triangle migration, sketch solving, clipping, or NURBS/freeform support.
## EDGE-A2 reference