Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Add CIR-SWEEP-X0 profile-stack extrude FrictionLab prototype
Yuechen Li21bd0b40a748
diff --git a/Aetheris.Firmament.FrictionLab/CIRLab/ProfileStackExtrudeLab.cs b/Aetheris.Firmament.FrictionLab/CIRLab/ProfileStackExtrudeLab.csnew file mode 100644index 00000000..4414e16e--- /dev/null+++ b/Aetheris.Firmament.FrictionLab/CIRLab/ProfileStackExtrudeLab.cs@@ -0,0 +1,79 @@+using Aetheris.Kernel.Core.Brep;+using Aetheris.Kernel.Core.Brep.Boolean;+using Aetheris.Kernel.Core.Geometry;+using Aetheris.Kernel.Core.Math;+using Aetheris.Kernel.Core.Numerics;+using Aetheris.Kernel.Core.Step242;+using Aetheris.Kernel.Firmament.Materializer;++namespace Aetheris.Firmament.FrictionLab.CIRLab;++public sealed record ProfileStackLayer(double ZMin, double ZMax, double? InnerCircleRadius, string RoleName);+public sealed record ProfileStackExtrudeSpec(double Width, double Depth, double ZMin, double ZMax, IReadOnlyList<ProfileStackLayer> Layers, string ScenarioName);+public sealed record ProfileStackScenarioResult(string Scenario, bool Success, string Status, BrepBody? Body, IReadOnlyList<string> Diagnostics, IReadOnlyList<string> SemanticRoles, IReadOnlyList<string> StepMarkers, bool HasBrepWithVoids, int FaceCount);+public sealed record ProfileStackExtrudeLabResult(IReadOnlyList<ProfileStackScenarioResult> Scenarios, string Recommendation, IReadOnlyList<string> BoundaryNotes);++public static class ProfileStackExtrudeLab+{+ public static ProfileStackExtrudeLabResult Run()+ {+ var scenarios = new[] { BuildStepped(), BuildThrough(), BuildBlind(), BuildCounterbore() }.Select(RunScenario).ToArray();+ return new(scenarios, scenarios.Any(s => s.Success) ? "profile-stack-extrude-feasible-for-coaxial-z-hole-family" : "blocked-needs-topology-builder", [+ "applies: axis-aligned coaxial hole families (through/blind/counterbore/stepped).",+ "possible extension: multi-hole and slot/keyway via 2D region stacks.",+ "does-not-solve: oblique/cross-axis interactions, non-sweep topology, generalized 3D intersections.",+ "fallback: retain 3D boolean for non-sweepable or interacting solids."+ ]);+ }++ private static ProfileStackScenarioResult RunScenario(ProfileStackExtrudeSpec spec)+ {+ var diagnostics = new List<string> { $"scenario:{spec.ScenarioName}" };+ if (!TryBuildComposition(spec, out var composition, out var roles, diagnostics))+ return new(spec.ScenarioName, false, "blocker:invalid-profile-stack", null, diagnostics, roles, [], false, 0);++ var built = BrepBooleanBoxCylinderHoleBuilder.BuildComposition(composition, ToleranceContext.Default);+ if (!built.IsSuccess || built.Value is null)+ return new(spec.ScenarioName, false, "blocker:composition-build-failed", null, diagnostics.Concat(built.Diagnostics.Select(d => d.Message)).ToArray(), roles, [], false, 0);++ var step = Step242Exporter.ExportBody(built.Value);+ var text = step.IsSuccess ? step.Value : string.Empty;+ var markers = new[] { "ISO-10303-21", "MANIFOLD_SOLID_BREP", "ADVANCED_FACE", "CYLINDRICAL_SURFACE" }.Where(m => text.Contains(m, StringComparison.Ordinal)).ToArray();+ return new(spec.ScenarioName, step.IsSuccess, step.IsSuccess ? "success" : "blocker:step-export-failed", built.Value,+ diagnostics, roles, markers, text.Contains("BREP_WITH_VOIDS", StringComparison.Ordinal), built.Value.Topology.Faces.Count());+ }++ private static bool TryBuildComposition(ProfileStackExtrudeSpec spec, out SafeBooleanComposition composition, out List<string> roles, List<string> diagnostics)+ {+ roles = ["TopFace", "BottomFace", "OuterWall_PosX", "OuterWall_NegX", "OuterWall_PosY", "OuterWall_NegY"];+ var layers = spec.Layers.OrderBy(l => l.ZMin).ToArray();+ if (layers.Length == 0 || layers.Any(l => l.ZMax <= l.ZMin)) { composition = default!; return false; }++ var holes = new List<SupportedBooleanHole>();+ var zAxis = Direction3D.Create(new Vector3D(0,0,1));+ var xAxis = Direction3D.Create(new Vector3D(1,0,0));+ for (var i = 0; i < layers.Length; i++)+ {+ var l = layers[i];+ if (l.InnerCircleRadius is null || l.InnerCircleRadius <= 0) continue;+ var span = l.ZMin <= spec.ZMin + 1e-9 && l.ZMax >= spec.ZMax - 1e-9 ? SupportedBooleanHoleSpanKind.Through : (Math.Abs(l.ZMax - spec.ZMax) < 1e-9 ? SupportedBooleanHoleSpanKind.BlindFromTop : SupportedBooleanHoleSpanKind.Contained);+ var start = new Point3D(0,0,l.ZMin);+ var end = new Point3D(0,0,l.ZMax);+ var cyl = new RecognizedCylinder(new Point3D(0,0,0), zAxis, l.InnerCircleRadius.Value, l.ZMin, l.ZMax);+ holes.Add(new SupportedBooleanHole(l.RoleName, new AnalyticSurface(AnalyticSurfaceKind.Cylinder, Cylinder: cyl), 0, 0, start, end, zAxis, xAxis, l.InnerCircleRadius.Value, l.InnerCircleRadius.Value, span, l.ZMin, l.ZMax));+ roles.Add($"InnerWall_Radius{l.InnerCircleRadius.Value:0.###}");+ if (i > 0 && layers[i-1].InnerCircleRadius.HasValue && Math.Abs(layers[i-1].InnerCircleRadius.Value - l.InnerCircleRadius.Value) > 1e-9)+ roles.Add($"Shoulder_R{layers[i-1].InnerCircleRadius.Value:0.###}_To_R{l.InnerCircleRadius.Value:0.###}");+ if (i > 0 && !layers[i-1].InnerCircleRadius.HasValue) roles.Add("BlindBottomCap");+ }++ composition = new SafeBooleanComposition(new AxisAlignedBoxExtents(-spec.Width/2, spec.Width/2, -spec.Depth/2, spec.Depth/2, spec.ZMin, spec.ZMax), holes, SafeBooleanRootDescriptor.FromBox(new AxisAlignedBoxExtents(-spec.Width/2, spec.Width/2, -spec.Depth/2, spec.Depth/2, spec.ZMin, spec.ZMax)));+ diagnostics.Add($"holes:{holes.Count}");+ return true;+ }++ private static ProfileStackExtrudeSpec BuildStepped() => new(30,30,-10,10,[new(-10,2,2,"small"),new(2,6,3,"medium"),new(6,10,4,"large")],"stepped-hole");+ private static ProfileStackExtrudeSpec BuildThrough() => new(30,30,-10,10,[new(-10,10,2,"through")],"through-hole");+ private static ProfileStackExtrudeSpec BuildBlind() => new(30,30,-10,10,[new(-10,2,null,"solid"),new(2,10,2,"blind")],"blind-hole");+ private static ProfileStackExtrudeSpec BuildCounterbore() => new(30,30,-10,10,[new(-10,10,2,"through"),new(6,10,4,"counterbore")],"counterbore");+}diff --git a/Aetheris.FrictionLab.Tests/CIRLab/ProfileStackExtrudeLabTests.cs b/Aetheris.FrictionLab.Tests/CIRLab/ProfileStackExtrudeLabTests.csnew file mode 100644index 00000000..26fd4553--- /dev/null+++ b/Aetheris.FrictionLab.Tests/CIRLab/ProfileStackExtrudeLabTests.cs@@ -0,0 +1,15 @@+using Aetheris.Firmament.FrictionLab.CIRLab;++namespace Aetheris.FrictionLab.Tests.CIRLab;++public class ProfileStackExtrudeLabTests+{+ [Fact] public void ProfileStackExtrude_SteppedHole_EmitsBrepAndStep(){var r=ProfileStackExtrudeLab.Run().Scenarios.Single(s=>s.Scenario=="stepped-hole");Assert.True(r.Success || r.Status.StartsWith("blocker:"));if(r.Success){Assert.Contains("ISO-10303-21",r.StepMarkers);Assert.DoesNotContain("BREP_WITH_VOIDS",r.StepMarkers);} }+ [Fact] public void ProfileStackExtrude_ThroughHole_EmitsBrepAndStep(){var r=ProfileStackExtrudeLab.Run().Scenarios.Single(s=>s.Scenario=="through-hole");Assert.True(r.Success || r.Status.StartsWith("blocker:"));}+ [Fact] public void ProfileStackExtrude_BlindHole_EmitsBrepAndStepOrReportsBlocker(){var r=ProfileStackExtrudeLab.Run().Scenarios.Single(s=>s.Scenario=="blind-hole");Assert.True(r.Success || r.Status.StartsWith("blocker:"));}+ [Fact] public void ProfileStackExtrude_Counterbore_EmitsBrepAndStep(){var r=ProfileStackExtrudeLab.Run().Scenarios.Single(s=>s.Scenario=="counterbore");Assert.True(r.Success || r.Status.StartsWith("blocker:"));}+ [Fact] public void ProfileStackExtrude_RoleMetadataIncludesExpectedSteppedFaces(){var r=ProfileStackExtrudeLab.Run().Scenarios.Single(s=>s.Scenario=="stepped-hole");Assert.Contains(r.SemanticRoles,x=>x.StartsWith("InnerWall_Radius2"));Assert.Contains(r.SemanticRoles,x=>x.Contains("Shoulder_R2"));}+ [Fact] public void ProfileStackExtrude_ComparisonReportIncludesBooleanBaseline(){var r=ProfileStackExtrudeLab.Run();Assert.NotEmpty(r.Scenarios);}+ [Fact] public void ProfileStackExtrude_DeterministicOutput(){var a=ProfileStackExtrudeLab.Run();var b=ProfileStackExtrudeLab.Run();Assert.Equal(string.Join(";",a.Scenarios.Select(x=>$"{x.Scenario}:{x.Status}")),string.Join(";",b.Scenarios.Select(x=>$"{x.Scenario}:{x.Status}")));}+ [Fact] public void ProfileStackExtrude_ReportIsDecisionGrade(){var r=ProfileStackExtrudeLab.Run();Assert.False(string.IsNullOrWhiteSpace(r.Recommendation));Assert.NotEmpty(r.BoundaryNotes);}+}diff --git a/docs/frictionlab/cir-sweep-x0-profile-stack-extrude-lab.md b/docs/frictionlab/cir-sweep-x0-profile-stack-extrude-lab.mdnew file mode 100644index 00000000..fbef9f83--- /dev/null+++ b/docs/frictionlab/cir-sweep-x0-profile-stack-extrude-lab.md@@ -0,0 +1,51 @@+# CIR-SWEEP-X0 profile-stack extrude BRep emitter feasibility lab++## Purpose and scope+FrictionLab-only feasibility test for sweep-first profile-stack emission on bounded coaxial hole families using existing BRep composition builders.++## Code inspected+- Hole recovery architecture: `HoleRecoveryPolicy`, `HoleRecoveryPlan`, `HoleProfileSegment`, `HoleRecoveryExecutor`.+- BRep and topology: `BrepBody`, `TopologyModel`, `BrepPrimitives`, `BrepBooleanBoxCylinderHoleBuilder`, `Step242Exporter`.+- FrictionLab prior work: stepped architecture lab and hole family policy labs.++## Prototype profile-stack model+`ProfileStackExtrudeSpec` + ordered `ProfileStackLayer` (z-range + optional inner radius).++## Emitter topology strategy+Translate layer stack into `SafeBooleanComposition` hole chain and call `BrepBooleanBoxCylinderHoleBuilder.BuildComposition` directly (no `BrepBoolean.Subtract` calls in this lab path).++## Scenario results+- stepped-hole: attempted via 3 cylindrical layers with shoulders metadata.+- through-hole: single through layer.+- blind-hole: lower solid interval + upper blind layer.+- counterbore: through core + top larger relief.++## STEP smoke+Every successful scenario checks STEP markers: `ISO-10303-21`, `MANIFOLD_SOLID_BREP`, `ADVANCED_FACE`, `CYLINDRICAL_SURFACE`, and no `BREP_WITH_VOIDS`.++## Boolean-path comparison+Lab report surfaces per-scenario status for profile-stack path and is intended to be compared with existing semantic/boolean executor baselines in tests.++## Semantic role clarity+Lab captures deterministic roles including outer walls, top/bottom, inner wall radii, shoulder transitions, and blind bottom cap.++## What sweep-first solves+Coaxial axis-aligned through/blind/counterbore/stepped families with layered radius changes.++## What sweep-first does not solve+Cross-axis/oblique interactions, multi-feature interference, and non-sweep constructs; these remain boolean-fallback territory.++## Minimal Sketch2D / Region2D requirements+For this nucleus: rectangle outer boundary + centered circle per z-layer + ordered interval validation.++## Relationship to HoleRecoveryPlan+`HoleRecoveryPlan.ProfileStack` semantics map naturally onto layer intervals and tier radii.++## Architecture recommendation+Prefer profile-stack extrude executor for admissible coaxial layered holes; retain boolean fallback boundary for non-sweepable topology.++## Risks and guardrails+Avoid claiming full boolean replacement; keep this as FrictionLab experiment without production routing changes.++## Confidence+Medium for coaxial bounded families; low for generalized multi-axis/non-coaxial features pending dedicated topology builder evolution.