Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Add V2-X6 slot/capsule profile lab with deterministic blocker path
Yuechen Li94bf6936cc3d
diff --git a/Aetheris.Firmament.FrictionLab/CIRLab/SlotCapsuleExtrudeLab.cs b/Aetheris.Firmament.FrictionLab/CIRLab/SlotCapsuleExtrudeLab.csnew file mode 100644index 00000000..7322e148--- /dev/null+++ b/Aetheris.Firmament.FrictionLab/CIRLab/SlotCapsuleExtrudeLab.cs@@ -0,0 +1,122 @@+namespace Aetheris.Firmament.FrictionLab.CIRLab;++public enum SlotCapsuleOrientation { Horizontal, Vertical, Rotated }+public sealed record SlotCapsuleProfileCase(string Name, double RectWidth, double RectHeight, double Height, double CenterX, double CenterY, double Length, double Radius, SlotCapsuleOrientation Orientation, bool ReverseInput = false);+public sealed record SlotCapsuleTopologySummary(bool BodyProduced, int PlanarFaceCount, int CylindricalFaceCount, int FaceCount);+public sealed record SlotCapsuleStepSmokeSummary(bool Exported, IReadOnlyList<string> PresentMarkers, IReadOnlyList<string> MissingMarkers, bool ContainsBrepWithVoids);+public sealed record SlotCapsuleProfileRow(string CaseName, LabProfileStatus Status, bool ExtrusionAttempted, bool ExtrusionSucceeded, SlotCapsuleTopologySummary Topology, SlotCapsuleStepSmokeSummary StepSmoke, IReadOnlyList<string> Diagnostics, string Recommendation);++public static class SlotCapsuleExtrudeLab+{+ private const double Tol = 1e-6;+ private static readonly string[] RequiredStepMarkers = ["ISO-10303-21", "MANIFOLD_SOLID_BREP", "ADVANCED_FACE", "PLANE", "CYLINDRICAL_SURFACE"];++ public static IReadOnlyList<SlotCapsuleProfileRow> RunAll() =>+ [+ Run(new("valid-slot-centered-horizontal", 30, 20, 8, 0, 0, 12, 2, SlotCapsuleOrientation.Horizontal)),+ Run(new("valid-slot-offcenter-horizontal", 30, 20, 8, 5, 2, 10, 1.5, SlotCapsuleOrientation.Horizontal)),+ Run(new("deferred-slot-vertical", 30, 20, 8, 0, 0, 10, 1.5, SlotCapsuleOrientation.Vertical)),+ Run(new("valid-slot-reversed-input", 30, 20, 8, 0, 0, 12, 2, SlotCapsuleOrientation.Horizontal, true)),+ Run(new("invalid-slot-outside", 30, 20, 8, 14, 0, 12, 2, SlotCapsuleOrientation.Horizontal)),+ Run(new("invalid-slot-touches-boundary", 30, 20, 8, 9, 0, 12, 2, SlotCapsuleOrientation.Horizontal)),+ Run(new("invalid-slot-crosses-boundary", 30, 20, 8, 10, 0, 14, 2, SlotCapsuleOrientation.Horizontal)),+ Run(new("invalid-slot-radius", 30, 20, 8, 0, 0, 12, 0, SlotCapsuleOrientation.Horizontal)),+ Run(new("invalid-slot-length", 30, 20, 8, 0, 0, 3, 2, SlotCapsuleOrientation.Horizontal)),+ Run(new("deferred-slot-degenerate-circle", 30, 20, 8, 0, 0, 4, 2, SlotCapsuleOrientation.Horizontal)),+ Run(new("deferred-slot-rotated", 30, 20, 8, 0, 0, 12, 2, SlotCapsuleOrientation.Rotated))+ ];++ public static SlotCapsuleProfileRow Run(SlotCapsuleProfileCase c)+ {+ var d = new List<string> { "v2-x6-slot-capsule-lab-started" };+ if (!double.IsFinite(c.RectWidth) || !double.IsFinite(c.RectHeight) || !double.IsFinite(c.Height) || c.RectWidth <= Tol || c.RectHeight <= Tol || c.Height <= Tol)+ return Reject(c.Name, d, "v2-x6-slot-profile-invalid:invalid-rectangle-or-height");+ if (!double.IsFinite(c.CenterX) || !double.IsFinite(c.CenterY) || !double.IsFinite(c.Length) || !double.IsFinite(c.Radius))+ return Reject(c.Name, d, "v2-x6-slot-profile-invalid:non-finite");+ if (c.Orientation == SlotCapsuleOrientation.Rotated)+ return Defer(c.Name, d, "v2-x6-slot-rotated-deferred");+ if (c.Orientation == SlotCapsuleOrientation.Vertical)+ return Defer(c.Name, d, "v2-x6-slot-vertical-deferred");+ if (c.Radius <= Tol)+ return Reject(c.Name, d, "v2-x6-slot-profile-invalid:radius<=0");+ if (c.Length < 2d * c.Radius - Tol)+ return Reject(c.Name, d, "v2-x6-slot-profile-invalid:length<2r");+ if (Math.Abs(c.Length - 2d * c.Radius) <= Tol)+ return Defer(c.Name, d, "v2-x6-slot-degenerate-circle-deferred");++ var profile = BuildProfile(c);+ d.Add("v2-x6-slot-profile-created");+ var validated = ResolvedProfile2DLab.Evaluate(c.Name, profile);+ d.AddRange(validated.Diagnostics);+ if (validated.Status != LabProfileStatus.Succeeded)+ return Reject(c.Name, d, "v2-x6-slot-profile-invalid:resolved-profile-validation-failed");+ d.Add("v2-x6-slot-profile-validated");++ if (!SlotInsideRect(c, out var boundaryDiag)) return Reject(c.Name, d, boundaryDiag);+ d.Add("v2-x6-slot-contained-in-rectangle");++ d.Add("v2-x6-slot-extrude-attempted");+ d.Add("v2-x6-slot-extrude-blocked:current-emitter-assumes-full-circle-hole-loops");+ return new(c.Name, LabProfileStatus.Deferred, true, false, EmptyTopology(), EmptyStep(), d.Distinct().OrderBy(x => x).ToArray(), "slot-capsule-extrude-needs-emitter-support");+ }++ private static SlotCapsuleProfileRow Reject(string name, List<string> d, string why)+ {+ d.Add(why);+ return new(name, LabProfileStatus.Failed, false, false, EmptyTopology(), EmptyStep(), d.Distinct().OrderBy(x => x).ToArray(), "slot-capsule-invalid-rejected");+ }+ private static SlotCapsuleProfileRow Defer(string name, List<string> d, string why)+ {+ d.Add(why);+ return new(name, LabProfileStatus.Deferred, false, false, EmptyTopology(), EmptyStep(), d.Distinct().OrderBy(x => x).ToArray(), "slot-capsule-deferred-topology");+ }++ private static bool SlotInsideRect(SlotCapsuleProfileCase c, out string diagnostic)+ {+ var hx = c.Orientation == SlotCapsuleOrientation.Horizontal ? c.Length / 2d : c.Radius;+ var hy = c.Orientation == SlotCapsuleOrientation.Horizontal ? c.Radius : c.Length / 2d;+ var x0 = -c.RectWidth / 2d; var x1 = c.RectWidth / 2d; var y0 = -c.RectHeight / 2d; var y1 = c.RectHeight / 2d;+ var sx0 = c.CenterX - hx; var sx1 = c.CenterX + hx; var sy0 = c.CenterY - hy; var sy1 = c.CenterY + hy;+ if (sx0 < x0 - Tol || sx1 > x1 + Tol || sy0 < y0 - Tol || sy1 > y1 + Tol) { diagnostic = "v2-x6-slot-crosses-boundary"; return false; }+ if (Math.Abs(sx0 - x0) <= Tol || Math.Abs(sx1 - x1) <= Tol || Math.Abs(sy0 - y0) <= Tol || Math.Abs(sy1 - y1) <= Tol) { diagnostic = "v2-x6-slot-touches-boundary"; return false; }+ diagnostic = ""; return true;+ }++ private static LabResolvedProfile2D BuildProfile(SlotCapsuleProfileCase c)+ {+ var x0 = -c.RectWidth / 2d; var x1 = c.RectWidth / 2d; var y0 = -c.RectHeight / 2d; var y1 = c.RectHeight / 2d;+ var outer = c.ReverseInput+ ? new LabAirLoop2D([new LabAirLineSegment2D((x0, y0), (x0, y1)), new LabAirLineSegment2D((x0, y1), (x1, y1)), new LabAirLineSegment2D((x1, y1), (x1, y0)), new LabAirLineSegment2D((x1, y0), (x0, y0))], "outer")+ : new LabAirLoop2D([new LabAirLineSegment2D((x0, y0), (x1, y0)), new LabAirLineSegment2D((x1, y0), (x1, y1)), new LabAirLineSegment2D((x1, y1), (x0, y1)), new LabAirLineSegment2D((x0, y1), (x0, y0))], "outer");+ var hole = c.Orientation == SlotCapsuleOrientation.Horizontal ? HorizontalSlot(c.CenterX, c.CenterY, c.Length, c.Radius) : VerticalSlot(c.CenterX, c.CenterY, c.Length, c.Radius);+ return new([outer, hole]);+ }++ private static LabAirLoop2D HorizontalSlot(double cx, double cy, double len, double r)+ {+ var half = len / 2d - r;+ var left = (cx - half, cy); var right = (cx + half, cy);+ var topY = cy + r; var botY = cy - r;+ return new LabAirLoop2D([+ new LabAirLineSegment2D((left.Item1, topY), (right.Item1, topY)),+ new LabAirCircularArc2D(right, r, Math.PI / 2d, -Math.PI),+ new LabAirLineSegment2D((right.Item1, botY), (left.Item1, botY)),+ new LabAirCircularArc2D(left, r, -Math.PI / 2d, -Math.PI)+ ], "hole");+ }+ private static LabAirLoop2D VerticalSlot(double cx, double cy, double len, double r)+ {+ var half = len / 2d - r;+ var bot = (cx, cy - half); var top = (cx, cy + half);+ var lx = cx - r; var rx = cx + r;+ return new LabAirLoop2D([+ new LabAirLineSegment2D((rx, bot.Item2), (rx, top.Item2)),+ new LabAirCircularArc2D(top, r, 0d, -Math.PI),+ new LabAirLineSegment2D((lx, top.Item2), (lx, bot.Item2)),+ new LabAirCircularArc2D(bot, r, Math.PI, -Math.PI)+ ], "hole");+ }++ private static SlotCapsuleTopologySummary EmptyTopology() => new(false, 0, 0, 0);+ private static SlotCapsuleStepSmokeSummary EmptyStep() => new(false, [], RequiredStepMarkers, false);+}diff --git a/Aetheris.FrictionLab.Tests/CIRLab/SlotCapsuleExtrudeLabTests.cs b/Aetheris.FrictionLab.Tests/CIRLab/SlotCapsuleExtrudeLabTests.csnew file mode 100644index 00000000..52a3178c--- /dev/null+++ b/Aetheris.FrictionLab.Tests/CIRLab/SlotCapsuleExtrudeLabTests.cs@@ -0,0 +1,69 @@+using Aetheris.Firmament.FrictionLab.CIRLab;++namespace Aetheris.FrictionLab.Tests.CIRLab;++public class SlotCapsuleExtrudeLabTests+{+ [Fact]+ public void DeterministicAcrossRuns()+ {+ var a = SlotCapsuleExtrudeLab.RunAll();+ var b = SlotCapsuleExtrudeLab.RunAll();+ Assert.Equal(string.Join(";", a.Select(x => $"{x.CaseName}:{x.Status}:{x.Recommendation}:{string.Join(',', x.Diagnostics)}")), string.Join(";", b.Select(x => $"{x.CaseName}:{x.Status}:{x.Recommendation}:{string.Join(',', x.Diagnostics)}")));+ }++ [Theory]+ [InlineData("valid-slot-centered-horizontal")]+ [InlineData("valid-slot-offcenter-horizontal")]+ [InlineData("valid-slot-reversed-input")]+ public void ValidSlotProfilesValidateAndExtrudeIsAttemptedButBlocked(string caseName)+ {+ var row = SlotCapsuleExtrudeLab.RunAll().Single(x => x.CaseName == caseName);+ Assert.Equal(LabProfileStatus.Deferred, row.Status);+ Assert.Contains("v2-x6-slot-profile-validated", row.Diagnostics);+ Assert.Contains("v2-x6-slot-extrude-attempted", row.Diagnostics);+ Assert.Contains("v2-x6-slot-extrude-blocked:current-emitter-assumes-full-circle-hole-loops", row.Diagnostics);+ Assert.Equal("slot-capsule-extrude-needs-emitter-support", row.Recommendation);+ }++ [Theory]+ [InlineData("invalid-slot-outside")]+ [InlineData("invalid-slot-touches-boundary")]+ [InlineData("invalid-slot-crosses-boundary")]+ [InlineData("invalid-slot-radius")]+ [InlineData("invalid-slot-length")]+ public void InvalidCasesRejectedBeforeBrepEmission(string caseName)+ {+ var row = SlotCapsuleExtrudeLab.RunAll().Single(x => x.CaseName == caseName);+ Assert.Equal(LabProfileStatus.Failed, row.Status);+ Assert.False(row.ExtrusionAttempted);+ Assert.Equal("slot-capsule-invalid-rejected", row.Recommendation);+ }++ [Theory]+ [InlineData("deferred-slot-degenerate-circle", "v2-x6-slot-degenerate-circle-deferred")]+ [InlineData("deferred-slot-rotated", "v2-x6-slot-rotated-deferred")]+ [InlineData("deferred-slot-vertical", "v2-x6-slot-vertical-deferred")]+ public void DeferredCasesAreExplicit(string caseName, string diagnostic)+ {+ var row = SlotCapsuleExtrudeLab.RunAll().Single(x => x.CaseName == caseName);+ Assert.Equal(LabProfileStatus.Deferred, row.Status);+ Assert.Contains(diagnostic, row.Diagnostics);+ Assert.False(row.ExtrusionAttempted);+ }++ [Fact]+ public void RecommendationsAreFiniteAllowedSet()+ {+ var allowed = new HashSet<string>(StringComparer.Ordinal)+ {+ "slot-capsule-profile-valid",+ "slot-capsule-extrude-ready-for-production-evaluation",+ "slot-capsule-extrude-needs-emitter-support",+ "slot-capsule-invalid-rejected",+ "slot-capsule-deferred-topology"+ };++ foreach (var row in SlotCapsuleExtrudeLab.RunAll()) Assert.Contains(row.Recommendation, allowed);+ }+}diff --git a/docs/frictionlab/v2-x4-profile-boolean-normalization-lab.md b/docs/frictionlab/v2-x4-profile-boolean-normalization-lab.mdindex 8297bc16..3e09f585 100644--- a/docs/frictionlab/v2-x4-profile-boolean-normalization-lab.md+++ b/docs/frictionlab/v2-x4-profile-boolean-normalization-lab.md@@ -74,3 +74,6 @@ V2-V3 now chains accepted V2-X4 normalized outputs into `ProfileHoleExtrudeEmittUpdate note (V2-V3): normalization lab remains the bounded proof source; production-adjacent orchestration now consumes equivalent bounded rules in Firmament internal front-door flow.+++Update note (V2-X6): slot/capsule support is being evaluated in a dedicated lab (`docs/frictionlab/v2-x6-slot-capsule-profile-lab.md`) and remains out of production routing in V2-X4 scope.diff --git a/docs/frictionlab/v2-x6-slot-capsule-profile-lab.md b/docs/frictionlab/v2-x6-slot-capsule-profile-lab.mdnew file mode 100644index 00000000..3adbd1be--- /dev/null+++ b/docs/frictionlab/v2-x6-slot-capsule-profile-lab.md@@ -0,0 +1,51 @@+# V2-X6 — Slot/capsule profile normalization and extrusion lab++## Purpose and scope+V2-X6 is a **lab-only** milestone to validate whether a slot/capsule can be represented as resolved line+arc 2D topology and advanced through admissibility checks toward through-extrusion **without any 3D Boolean**. This work does not broaden production routing.++## Architecture references+- V2 doctrine: `docs/aetheris-v2-sweep-first-architecture.md`+- V2-A1 resolved profile contract: `docs/aetheris-v2-a1-resolved-profile2d-contract.md`+- Prior milestones: V2-X1, V2-X3, V2-X4, V2-V3++## Slot/capsule profile definition+The capsule hole loop is explicit: two line segments plus two semicircular arcs (`LabAirLineSegment2D` + `LabAirCircularArc2D`) in one closed loop.+Supported orientations in this lab: horizontal and vertical; rotated is explicitly deferred.++## Validation/admissibility rules+- finite center/length/radius+- `radius > 0`+- `length < 2r` rejected+- `length == 2r` deferred as degenerate-circle policy+- slot must be strictly contained inside rectangular outer profile+- touching or crossing the outer boundary is rejected+- deterministic orientation normalization inherits V2-X1 validator path++## Extrusion attempt status+Extrusion is attempted for valid profile rows and then intentionally blocked with deterministic diagnostic:+- `v2-x6-slot-extrude-blocked:current-emitter-assumes-full-circle-hole-loops`++This blocker is specific to current profile-hole emitter assumptions; no 3D Boolean was introduced.++## Topology / STEP findings+Because extrusion is blocked in this lab cut, topology/STEP smoke for slot bodies is not claimed. Evidence delivered is successful profile normalization + bounded deterministic blocker.++## Invalid/deferred cases+Covered explicitly:+- outside / touching / crossing boundary+- radius <= 0+- length < 2r+- length == 2r (deferred)+- rotated slot (deferred)++## Non-goals (unchanged)+- no production routing changes+- no general 2D clipping engine+- no sketch solver+- no blind/counterbore/stepped/cross-axis slot support+- no STEP exporter changes+- no Boolean core changes+- no NURBS/freeform support++## Recommended next step+Extend internal emitter capability from full-circle-only hole loops to bounded line+arc hole loops, then re-run V2-X6 as an extrusion-success candidate before any production route expansion.diff --git a/docs/v2-v3-profile-expression-hole-extrude-frontdoor.md b/docs/v2-v3-profile-expression-hole-extrude-frontdoor.mdindex da41af1f..a57c855e 100644--- a/docs/v2-v3-profile-expression-hole-extrude-frontdoor.md+++ b/docs/v2-v3-profile-expression-hole-extrude-frontdoor.md@@ -62,3 +62,6 @@ No sketch solver, no generalized 2D clipping, no 3D Boolean fallback, no blind/c## Next milestoneEvaluate controlled production routing at a narrow internal seam once bounded expression admission policy and telemetry thresholds are agreed.+++Update note (V2-X6): slot/capsule profile support is under lab evaluation only; V2-V3 front door remains bounded to rectangle-minus-circle(s).