Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Add EDGE-X5 convex planar AirChamfer geometry artifact lab
Yuechen Li9bb662f4c415
diff --git a/Aetheris.Firmament.FrictionLab/CIRLab/AirChamferGeometryArtifactLab.cs b/Aetheris.Firmament.FrictionLab/CIRLab/AirChamferGeometryArtifactLab.csnew file mode 100644index 00000000..3d791ad0--- /dev/null+++ b/Aetheris.Firmament.FrictionLab/CIRLab/AirChamferGeometryArtifactLab.cs@@ -0,0 +1,182 @@+using System.Numerics;++namespace Aetheris.Firmament.FrictionLab.CIRLab;++public sealed record AirChamferGeometryArtifactFace(+ string Name,+ string FaceFamily,+ Vector3 Normal,+ double Area,+ IReadOnlyList<Vector3> BoundaryVertices);++public sealed record AirChamferGeometryArtifactEdge(+ string Name,+ Vector3 Start,+ Vector3 End,+ bool IsOffsetCurve,+ bool IsTransitionEdge);++public sealed record AirChamferGeometryArtifact(+ string ReplacementMode,+ AirChamferGeometryArtifactFace TrimmedFacePatchA,+ AirChamferGeometryArtifactFace TrimmedFacePatchB,+ AirChamferGeometryArtifactFace ChamferFace,+ IReadOnlyList<AirChamferGeometryArtifactEdge> OffsetCurves,+ IReadOnlyList<AirChamferGeometryArtifactEdge> TransitionEdges,+ bool OriginalEdgeMarkedForReplacement,+ bool CornerPatchesDeferred,+ int CornerPatchCount,+ bool IsOpenLocalWitness,+ int FaceCount,+ int PlanarFaceCount,+ int ChamferFaceCount,+ int AffectedAdjacentFaceCount,+ int OffsetCurveCount,+ int TransitionEdgeCount);++public sealed record AirChamferGeometryArtifactResult(+ AirChamferTopologyPlanCase Case,+ AirChamferTopologyPlanResult TopologyPlan,+ AirChamferGeometryArtifact? Artifact,+ string Decision,+ string Recommendation,+ IReadOnlyList<string> Diagnostics);++public sealed record AirChamferGeometryArtifactRow(+ string CaseName,+ string Decision,+ string Recommendation,+ bool ArtifactProduced,+ int FaceCount,+ int PlanarFaceCount,+ int ChamferFaceCount,+ int OffsetCurveCount,+ int TransitionEdgeCount,+ int CornerPatchCount,+ IReadOnlyList<string> Diagnostics);++public static class AirChamferGeometryArtifactLab+{+ private const float Tol = 1e-6f;++ public static readonly IReadOnlySet<string> AllowedRecommendations = new HashSet<string>(StringComparer.Ordinal)+ {+ "air-chamfer-geometry-artifact-ready-for-closed-witness-lab",+ "air-chamfer-geometry-artifact-needs-topology-plan-hardening",+ "air-chamfer-geometry-artifact-rejected-invalid",+ "air-chamfer-geometry-artifact-deferred-chain-or-corner",+ "air-chamfer-geometry-artifact-keep-legacy-route"+ };++ public static IReadOnlyList<AirChamferTopologyPlanCase> Cases() => AirChamferTopologyPlanLab.Cases();+ public static IReadOnlyList<AirChamferGeometryArtifactRow> RunAll() => Cases().Select(Evaluate).Select(ToRow).ToArray();++ public static AirChamferGeometryArtifactResult Evaluate(AirChamferTopologyPlanCase c)+ {+ var diagnostics = new List<string>+ {+ "edge-x5-geometry-artifact-lab-started",+ "edge-x5-judgment-engine-used",+ "edge-x5-no-production-behavior-changed",+ "edge-x5-no-3d-boolean-used"+ };++ var topology = AirChamferTopologyPlanLab.Evaluate(c);+ diagnostics.AddRange(topology.Diagnostics.Where(d => d.Contains("judgment", StringComparison.Ordinal)));++ AirChamferGeometryArtifact? artifact = null;+ var decision = topology.Decision;+ if (topology.Plan is { } plan && decision == "plan-convex-replacement-topology")+ {+ diagnostics.Add("edge-x5-topology-plan-created");+ artifact = BuildArtifact(plan, diagnostics);+ decision = "create-convex-replacement-geometry-artifact";+ diagnostics.Add("edge-x5-geometry-artifact-created");+ diagnostics.Add("edge-x5-step-smoke-deferred:open-local-artifact-export-unsupported");+ }++ var recommendation = decision switch+ {+ "create-convex-replacement-geometry-artifact" => "air-chamfer-geometry-artifact-ready-for-closed-witness-lab",+ "defer-edge-chain-policy" or "defer-corner-policy" => "air-chamfer-geometry-artifact-deferred-chain-or-corner",+ "fallback-legacy-chamfer" or "defer-legacy-dependent-topology" => "air-chamfer-geometry-artifact-keep-legacy-route",+ var d when d.StartsWith("reject-", StringComparison.Ordinal) => "air-chamfer-geometry-artifact-rejected-invalid",+ _ => "air-chamfer-geometry-artifact-needs-topology-plan-hardening"+ };++ return new(c, topology, artifact, decision, recommendation, diagnostics.Distinct().OrderBy(x => x, StringComparer.Ordinal).ToArray());+ }++ private static AirChamferGeometryArtifact BuildArtifact(AirChamferTopologyPlan plan, List<string> diagnostics)+ {+ var edgeDirection = Vector3.Normalize(plan.TargetEdgeEnd - plan.TargetEdgeStart);+ var faceAOffset = Vector3.Normalize(plan.FaceANormal) * (float)plan.ChamferDistance;+ var faceBOffset = Vector3.Normalize(plan.FaceBNormal) * (float)plan.ChamferDistance;++ var a0 = plan.TargetEdgeStart + faceAOffset;+ var a1 = plan.TargetEdgeEnd + faceAOffset;+ var b0 = plan.TargetEdgeStart + faceBOffset;+ var b1 = plan.TargetEdgeEnd + faceBOffset;++ diagnostics.Add("edge-x5-offset-curves-materialized");++ var offsetA = new AirChamferGeometryArtifactEdge("offset-curve-a", a0, a1, true, false);+ var offsetB = new AirChamferGeometryArtifactEdge("offset-curve-b", b0, b1, true, false);+ var transition0 = new AirChamferGeometryArtifactEdge("transition-edge-start", a0, b0, false, true);+ var transition1 = new AirChamferGeometryArtifactEdge("transition-edge-end", a1, b1, false, true);+ diagnostics.Add("edge-x5-transition-edges-materialized");++ var chamferNormal = Vector3.Normalize(Vector3.Cross(a1 - a0, b0 - a0));+ var chamferArea = TriangleArea(a0, a1, b1) + TriangleArea(a0, b1, b0);++ var trimmedFaceA = new AirChamferGeometryArtifactFace("trimmed-face-a", "planar", Vector3.Normalize(plan.FaceANormal), SegmentLength(a0, a1) * plan.ChamferDistance, [a0, a1]);+ var trimmedFaceB = new AirChamferGeometryArtifactFace("trimmed-face-b", "planar", Vector3.Normalize(plan.FaceBNormal), SegmentLength(b0, b1) * plan.ChamferDistance, [b0, b1]);+ var chamferFace = new AirChamferGeometryArtifactFace("chamfer-face", "planar", chamferNormal, chamferArea, [a0, a1, b1, b0]);++ diagnostics.Add("edge-x5-trimmed-face-a-artifact-created");+ diagnostics.Add("edge-x5-trimmed-face-b-artifact-created");+ diagnostics.Add("edge-x5-chamfer-face-artifact-created");+ diagnostics.Add("edge-x5-original-edge-marked-for-replacement");+ diagnostics.Add("edge-x5-corner-patches-deferred");++ ValidateArtifact(edgeDirection, offsetA, offsetB, transition0, transition1, trimmedFaceA, trimmedFaceB, chamferFace, diagnostics);++ return new(+ plan.ReplacementMode,+ trimmedFaceA,+ trimmedFaceB,+ chamferFace,+ [offsetA, offsetB],+ [transition0, transition1],+ OriginalEdgeMarkedForReplacement: true,+ CornerPatchesDeferred: true,+ CornerPatchCount: 0,+ IsOpenLocalWitness: true,+ FaceCount: 3,+ PlanarFaceCount: 3,+ ChamferFaceCount: 1,+ AffectedAdjacentFaceCount: 2,+ OffsetCurveCount: 2,+ TransitionEdgeCount: 2);+ }++ private static void ValidateArtifact(Vector3 edgeDirection, AirChamferGeometryArtifactEdge offsetA, AirChamferGeometryArtifactEdge offsetB, AirChamferGeometryArtifactEdge transition0, AirChamferGeometryArtifactEdge transition1, AirChamferGeometryArtifactFace faceA, AirChamferGeometryArtifactFace faceB, AirChamferGeometryArtifactFace chamfer, List<string> diagnostics)+ {+ if (!Finite(faceA.Normal) || !Finite(faceB.Normal) || !Finite(chamfer.Normal)) throw new InvalidOperationException("Non-finite normals in artifact.");+ if (!(faceA.Area > 0d && faceB.Area > 0d && chamfer.Area > 0d)) throw new InvalidOperationException("Non-positive area in artifact.");+ if (!IsParallel(offsetA.End - offsetA.Start, edgeDirection) || !IsParallel(offsetB.End - offsetB.Start, edgeDirection)) throw new InvalidOperationException("Offset curves are not parallel to edge.");+ if (!AlmostEqual(transition0.Start, offsetA.Start) || !AlmostEqual(transition0.End, offsetB.Start) || !AlmostEqual(transition1.Start, offsetA.End) || !AlmostEqual(transition1.End, offsetB.End)) throw new InvalidOperationException("Transition edges do not connect offset endpoints.");++ diagnostics.Add("edge-x5-artifact-orientation-validated");+ diagnostics.Add("edge-x5-artifact-area-validated");+ }++ private static AirChamferGeometryArtifactRow ToRow(AirChamferGeometryArtifactResult r)+ => new(r.Case.CaseName, r.Decision, r.Recommendation, r.Artifact is not null, r.Artifact?.FaceCount ?? 0, r.Artifact?.PlanarFaceCount ?? 0, r.Artifact?.ChamferFaceCount ?? 0, r.Artifact?.OffsetCurveCount ?? 0, r.Artifact?.TransitionEdgeCount ?? 0, r.Artifact?.CornerPatchCount ?? 0, r.Diagnostics);++ private static double TriangleArea(Vector3 a, Vector3 b, Vector3 c) => 0.5d * Vector3.Cross(b - a, c - a).Length();+ private static double SegmentLength(Vector3 a, Vector3 b) => (b - a).Length();+ private static bool Finite(Vector3 v) => float.IsFinite(v.X) && float.IsFinite(v.Y) && float.IsFinite(v.Z);+ private static bool IsParallel(Vector3 a, Vector3 b) => Vector3.Cross(a, b).Length() <= Tol;+ private static bool AlmostEqual(Vector3 a, Vector3 b) => (a - b).Length() <= Tol;+}diff --git a/Aetheris.FrictionLab.Tests/CIRLab/AirChamferGeometryArtifactLabTests.cs b/Aetheris.FrictionLab.Tests/CIRLab/AirChamferGeometryArtifactLabTests.csnew file mode 100644index 00000000..bf8be089--- /dev/null+++ b/Aetheris.FrictionLab.Tests/CIRLab/AirChamferGeometryArtifactLabTests.cs@@ -0,0 +1,73 @@+using Aetheris.Firmament.FrictionLab.CIRLab;++namespace Aetheris.FrictionLab.Tests.CIRLab;++public sealed class AirChamferGeometryArtifactLabTests+{+ [Fact]+ public void RunAll_IsDeterministicAcrossRepeatedRuns()+ {+ var a = AirChamferGeometryArtifactLab.RunAll();+ var b = AirChamferGeometryArtifactLab.RunAll();+ Assert.Equal(a.Select(r => $"{r.CaseName}|{r.Decision}|{r.Recommendation}|{r.ArtifactProduced}|{string.Join(",", r.Diagnostics)}"), b.Select(r => $"{r.CaseName}|{r.Decision}|{r.Recommendation}|{r.ArtifactProduced}|{string.Join(",", r.Diagnostics)}"));+ }++ [Fact]+ public void Diagnostics_IncludeJudgmentEngineUsage()+ {+ var row = AirChamferGeometryArtifactLab.Evaluate(AirChamferGeometryArtifactLab.Cases().Single(x => x.CaseName == "canonical-orthogonal-convex-planar-single-edge"));+ Assert.Contains("edge-x5-judgment-engine-used", row.Diagnostics);+ }++ [Fact]+ public void CanonicalConvexPlanar_CreatesExpectedArtifact()+ {+ var result = AirChamferGeometryArtifactLab.Evaluate(AirChamferGeometryArtifactLab.Cases().Single(x => x.CaseName == "canonical-orthogonal-convex-planar-single-edge"));+ var artifact = Assert.IsType<AirChamferGeometryArtifact>(result.Artifact);++ Assert.Equal(3, artifact.FaceCount);+ Assert.Equal(3, artifact.PlanarFaceCount);+ Assert.Equal(1, artifact.ChamferFaceCount);+ Assert.Equal(2, artifact.AffectedAdjacentFaceCount);+ Assert.Equal(2, artifact.OffsetCurveCount);+ Assert.Equal(2, artifact.TransitionEdgeCount);+ Assert.Equal(0, artifact.CornerPatchCount);+ Assert.True(artifact.CornerPatchesDeferred);+ Assert.True(artifact.OriginalEdgeMarkedForReplacement);++ Assert.True(artifact.TrimmedFacePatchA.Area > 0d);+ Assert.True(artifact.TrimmedFacePatchB.Area > 0d);+ Assert.True(artifact.ChamferFace.Area > 0d);+ Assert.True(float.IsFinite(artifact.TrimmedFacePatchA.Normal.X));+ Assert.True(float.IsFinite(artifact.TrimmedFacePatchB.Normal.X));+ Assert.True(float.IsFinite(artifact.ChamferFace.Normal.X));++ var offsetA = artifact.OffsetCurves.Single(x => x.Name == "offset-curve-a");+ var offsetB = artifact.OffsetCurves.Single(x => x.Name == "offset-curve-b");+ var transitionStart = artifact.TransitionEdges.Single(x => x.Name == "transition-edge-start");+ var transitionEnd = artifact.TransitionEdges.Single(x => x.Name == "transition-edge-end");++ Assert.Equal(offsetA.Start, transitionStart.Start);+ Assert.Equal(offsetB.Start, transitionStart.End);+ Assert.Equal(offsetA.End, transitionEnd.Start);+ Assert.Equal(offsetB.End, transitionEnd.End);++ Assert.Contains("edge-x5-no-3d-boolean-used", result.Diagnostics);+ Assert.Contains("edge-x5-step-smoke-deferred:open-local-artifact-export-unsupported", result.Diagnostics);+ }++ [Theory]+ [InlineData("convex-planar-unsafe-envelope")]+ [InlineData("invalid-distance")]+ [InlineData("invalid-edge")]+ [InlineData("invalid-face-adjacency")]+ [InlineData("ambiguous-classification")]+ [InlineData("edge-chain")]+ [InlineData("corner-chain")]+ [InlineData("triangle-legacy-dependent")]+ public void InvalidDeferredOrLegacyCases_StopBeforeArtifact(string caseName)+ {+ var result = AirChamferGeometryArtifactLab.Evaluate(AirChamferGeometryArtifactLab.Cases().Single(x => x.CaseName == caseName));+ Assert.Null(result.Artifact);+ }+}diff --git a/docs/frictionlab/edge-x4-convex-planar-air-chamfer-topology-plan-lab.md b/docs/frictionlab/edge-x4-convex-planar-air-chamfer-topology-plan-lab.mdindex edcef71b..0e37ea92 100644--- a/docs/frictionlab/edge-x4-convex-planar-air-chamfer-topology-plan-lab.md+++ b/docs/frictionlab/edge-x4-convex-planar-air-chamfer-topology-plan-lab.md@@ -90,3 +90,7 @@ EDGE-X4 emits deterministic diagnostics including:## Recommended next milestone- EDGE-X5: convex planar chamfer replacement geometry artifact lab.- If blockers appear, topology-plan hardening and policy refinement before geometry work.+++## EDGE-X5 follow-on note+EDGE-X5 consumes this topology plan to build an open/local convex replacement geometry artifact (trimmed adjacent patches + chamfer face + transition/offset edges), while still stopping before production body mutation.diff --git a/docs/frictionlab/edge-x5-convex-planar-air-chamfer-geometry-artifact-lab.md b/docs/frictionlab/edge-x5-convex-planar-air-chamfer-geometry-artifact-lab.mdnew file mode 100644index 00000000..0ca16706--- /dev/null+++ b/docs/frictionlab/edge-x5-convex-planar-air-chamfer-geometry-artifact-lab.md@@ -0,0 +1,94 @@+# EDGE-X5 — Convex planar AirChamfer replacement geometry artifact lab++## Purpose and scope+EDGE-X5 consumes the EDGE-X4 topology replacement plan and creates a **lab-only, open/local geometry witness** for a convex planar single-edge AirChamfer replacement. No production BRep mutation is performed.++## References+- `docs/edge-a0-air-edge-sweep-fillet-chamfer-audit.md`+- `docs/frictionlab/edge-x1-chamfer-fillet-capability-matrix.md`+- `docs/frictionlab/edge-x2-concave-planar-chamfer-patch-lab.md`+- `docs/frictionlab/edge-x3-convex-planar-air-chamfer-judgment-policy-lab.md`+- `docs/frictionlab/edge-x4-convex-planar-air-chamfer-topology-plan-lab.md`++## Why geometry artifact comes after topology plan+EDGE-X4 proved deterministic replacement topology planning (counts and replacement mode) without geometry emission. EDGE-X5 uses that deterministic plan as the input contract, then materializes geometry witness pieces while preserving policy-first gating.++## Judgment-backed policy flow+1. Evaluate admissibility with EDGE-X3 judgment-backed policy.+2. If convex-planar admission reaches `defer-convex-replacement-geometry`, consume EDGE-X4 to build `plan-convex-replacement-topology`.+3. Build geometry artifact only from admitted plan.++## Topology plan consumed+`single-edge-convex-planar` replacement mode, with:+- target edge: 1+- offset curves: 2+- chamfer faces: 1+- transition edges: 2+- affected adjacent faces: 2+- corner patches: 0/deferred++## Geometry artifact model+`AirChamferGeometryArtifactLab` builds:+- trimmed adjacent face patch A (planar)+- trimmed adjacent face patch B (planar)+- chamfer face (planar)+- offset curve A (line segment)+- offset curve B (line segment)+- two transition edges (line segments)+- original edge replacement marker+- corner patches deferred marker++## Fixture cases and results+Accepted/artifact path:+- canonical orthogonal convex planar single-edge+- safe non-orthogonal convex planar single-edge (if admitted by EDGE-X4)++Rejected/deferred before artifact:+- unsafe envelope+- invalid distance+- invalid edge+- invalid/missing/parallel adjacency+- ambiguous classification+- edge chain+- corner chain+- legacy-dependent topology fixture++## Topology/artifact counts+For produced artifact:+- faces: 3+- planar faces: 3+- new chamfer faces: 1+- affected adjacent faces: 2+- offset curves: 2+- transition edges: 2+- corner patches: 0 (deferred)+- original edge removed/replaced: true (marker)++## Orientation and area validation+Lab validates:+- finite normals for all faces+- positive area for trimmed patches and chamfer face+- offset curves parallel to original edge direction+- transition edges connect matching offset endpoints+- deterministic orientation diagnostics emitted++## STEP/export status+Artifact is open/local witness, so STEP smoke is explicitly deferred with deterministic diagnostic:+- `edge-x5-step-smoke-deferred:open-local-artifact-export-unsupported`++## No-3D-Boolean guarantee+EDGE-X5 emits `edge-x5-no-3d-boolean-used` and does not route through Boolean geometry fallback.++## Invalid/deferred cases+Invalid/deferred/legacy cases stop before artifact construction and produce recommendation-aligned outcomes.++## Non-goals+- no production chamfer/fillet behavior changes+- no full body mutation+- no fillet geometry+- no edge/corner chain implementation+- no STEP exporter/importer changes+- no Boolean core changes++## Recommended next milestone+Proceed to EDGE-X6 closed local witness lab. Production-adjacent convex AirChamfer prototype (EDGE-V1) should wait until closed witness evidence is sufficient.