Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Add production-adjacent profile hole extrude emitter

Yuechen Li5483f59e0e83
diff --git a/Aetheris.Kernel.Firmament.Tests/Integration/ProfileHoleExtrudeEmitterTests.cs b/Aetheris.Kernel.Firmament.Tests/Integration/ProfileHoleExtrudeEmitterTests.cs
new file mode 100644
index 00000000..051fa1d2
--- /dev/null
+++ b/Aetheris.Kernel.Firmament.Tests/Integration/ProfileHoleExtrudeEmitterTests.cs
@@ -0,0 +1,63 @@
+using Aetheris.Kernel.Core.Brep;
+using Aetheris.Kernel.Core.Geometry;
+using Aetheris.Kernel.Core.Step242;
+using Aetheris.Kernel.Firmament.Materializer;
+
+namespace Aetheris.Kernel.Firmament.Tests.Integration;
+
+public class ProfileHoleExtrudeEmitterTests
+{
+ [Theory]
+ [MemberData(nameof(ValidCases))]
+ public void Emitter_ValidCases_EmitExpectedTopology(object requestObj, int holes)
+ {
+ var req = (ProfileHoleExtrudeRequest)requestObj;
+ var result = ProfileHoleExtrudeEmitter.TryEmit(req);
+ Assert.Equal(ProfileHoleExtrudeStatus.Succeeded, result.Status);
+ Assert.NotNull(result.Body);
+ Assert.Contains("v2-v1-profile-hole-extrude-no-3d-boolean-subtract", result.Diagnostics);
+
+ var body = result.Body!;
+ var planar = body.Topology.Faces.Count(f => body.GetFaceSurface(f.Id).Kind == SurfaceGeometryKind.Plane);
+ var cyl = body.Topology.Faces.Count(f => body.GetFaceSurface(f.Id).Kind == SurfaceGeometryKind.Cylinder);
+ Assert.Equal(6, planar);
+ Assert.Equal(holes, cyl);
+
+ var step = Step242Exporter.ExportBody(body);
+ Assert.True(step.IsSuccess);
+ var text = step.Value!;
+ Assert.Contains("ISO-10303-21", text);
+ Assert.Contains("MANIFOLD_SOLID_BREP", text);
+ Assert.Contains("ADVANCED_FACE", text);
+ Assert.Contains("PLANE", text);
+ Assert.Contains("CYLINDRICAL_SURFACE", text);
+ Assert.DoesNotContain("BREP_WITH_VOIDS", text);
+ }
+
+ [Theory]
+ [MemberData(nameof(InvalidCases))]
+ public void Emitter_InvalidCases_RejectBeforeBrep(object requestObj)
+ {
+ var req = (ProfileHoleExtrudeRequest)requestObj;
+ var result = ProfileHoleExtrudeEmitter.TryEmit(req);
+ Assert.Equal(ProfileHoleExtrudeStatus.Rejected, result.Status);
+ Assert.Null(result.Body);
+ Assert.Contains(result.Diagnostics, x => x.StartsWith("v2-v1-profile-hole-extrude-rejected:"));
+ }
+
+ public static IEnumerable<object[]> ValidCases()
+ {
+ yield return [new ProfileHoleExtrudeRequest(20, 20, 10, [new(0, 0, 3)]), 1];
+ yield return [new ProfileHoleExtrudeRequest(30, 20, 8, [new(4, 2, 2)]), 1];
+ yield return [new ProfileHoleExtrudeRequest(30, 20, 8, [new(-6, 0, 2), new(6, 0, 2)]), 2];
+ }
+
+ public static IEnumerable<object[]> InvalidCases()
+ {
+ yield return [new ProfileHoleExtrudeRequest(20, 20, 10, [new(20, 20, 2)])];
+ yield return [new ProfileHoleExtrudeRequest(20, 20, 10, [new(7, 0, 3)])];
+ yield return [new ProfileHoleExtrudeRequest(30, 20, 8, [new(-2, 0, 3), new(2, 0, 3)])];
+ yield return [new ProfileHoleExtrudeRequest(20, 20, 0, [new(0, 0, 3)])];
+ yield return [new ProfileHoleExtrudeRequest(20, 20, 8, [new(0, 0, 0)])];
+ }
+}
diff --git a/Aetheris.Kernel.Firmament/Materializer/ProfileHoleExtrudeEmitter.cs b/Aetheris.Kernel.Firmament/Materializer/ProfileHoleExtrudeEmitter.cs
new file mode 100644
index 00000000..545645f0
--- /dev/null
+++ b/Aetheris.Kernel.Firmament/Materializer/ProfileHoleExtrudeEmitter.cs
@@ -0,0 +1,213 @@
+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.Topology;
+
+namespace Aetheris.Kernel.Firmament.Materializer;
+
+internal sealed record ProfileHoleLoop2D(double CenterX, double CenterY, double Radius);
+
+internal sealed record ProfileHoleExtrudeRequest(
+ double Width,
+ double Depth,
+ double Height,
+ IReadOnlyList<ProfileHoleLoop2D> Holes);
+
+internal enum ProfileHoleExtrudeStatus
+{
+ Succeeded,
+ Rejected,
+ Failed
+}
+
+internal sealed record ProfileHoleExtrudeResult(
+ ProfileHoleExtrudeStatus Status,
+ BrepBody? Body,
+ IReadOnlyList<string> Diagnostics);
+
+internal static class ProfileHoleExtrudeEmitter
+{
+ public static ProfileHoleExtrudeResult TryEmit(ProfileHoleExtrudeRequest request)
+ {
+ var d = new List<string> { "v2-v1-profile-hole-extrude-attempted" };
+ if (!TryValidate(request, d))
+ {
+ return new(ProfileHoleExtrudeStatus.Rejected, null, d);
+ }
+
+ d.Add("v2-v1-profile-hole-extrude-accepted");
+ d.Add("v2-v1-profile-hole-extrude-no-3d-boolean-subtract");
+ var built = BuildBody(request);
+ if (!built.IsSuccess || built.Body is null)
+ {
+ d.Add($"v2-v1-profile-hole-extrude-failed:{built.Diagnostic}");
+ return new(ProfileHoleExtrudeStatus.Failed, null, d);
+ }
+
+ d.Add("v2-v1-profile-hole-extrude-succeeded");
+ return new(ProfileHoleExtrudeStatus.Succeeded, built.Body, d);
+ }
+
+ private static bool TryValidate(ProfileHoleExtrudeRequest req, List<string> d)
+ {
+ const double tol = 1e-9;
+ if (!double.IsFinite(req.Width) || !double.IsFinite(req.Depth) || !double.IsFinite(req.Height) || req.Width <= tol || req.Depth <= tol || req.Height <= tol)
+ {
+ d.Add("v2-v1-profile-hole-extrude-rejected:invalid-outer-or-height");
+ return false;
+ }
+
+ var hw = req.Width / 2d;
+ var hh = req.Depth / 2d;
+ for (var i = 0; i < req.Holes.Count; i++)
+ {
+ var h = req.Holes[i];
+ if (!double.IsFinite(h.CenterX) || !double.IsFinite(h.CenterY) || !double.IsFinite(h.Radius) || h.Radius <= tol)
+ {
+ d.Add($"v2-v1-profile-hole-extrude-rejected:invalid-hole-radius[{i}]");
+ return false;
+ }
+
+ if (h.CenterX - h.Radius <= -hw + tol || h.CenterX + h.Radius >= hw - tol || h.CenterY - h.Radius <= -hh + tol || h.CenterY + h.Radius >= hh - tol)
+ {
+ d.Add($"v2-v1-profile-hole-extrude-rejected:hole-outside-or-touches-boundary[{i}]");
+ return false;
+ }
+
+ for (var j = i + 1; j < req.Holes.Count; j++)
+ {
+ var k = req.Holes[j];
+ var dx = h.CenterX - k.CenterX;
+ var dy = h.CenterY - k.CenterY;
+ if ((dx * dx) + (dy * dy) <= Math.Pow(h.Radius + k.Radius, 2d) + tol)
+ {
+ d.Add($"v2-v1-profile-hole-extrude-rejected:holes-overlap[{i},{j}]");
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ private static (bool IsSuccess, BrepBody? Body, string Diagnostic) BuildBody(ProfileHoleExtrudeRequest request)
+ {
+ var minX = -request.Width / 2d;
+ var maxX = request.Width / 2d;
+ var minY = -request.Depth / 2d;
+ var maxY = request.Depth / 2d;
+ var z0 = -request.Height / 2d;
+ var z1 = request.Height / 2d;
+
+ var b = new TopologyBuilder();
+ var ob = new[] { b.AddVertex(), b.AddVertex(), b.AddVertex(), b.AddVertex() };
+ var ot = new[] { b.AddVertex(), b.AddVertex(), b.AddVertex(), b.AddVertex() };
+ var holeCount = request.Holes.Count;
+ var hb = new VertexId[holeCount];
+ var ht = new VertexId[holeCount];
+ for (var i = 0; i < holeCount; i++) { hb[i] = b.AddVertex(); ht[i] = b.AddVertex(); }
+
+ var be = new[] { b.AddEdge(ob[0], ob[1]), b.AddEdge(ob[1], ob[2]), b.AddEdge(ob[2], ob[3]), b.AddEdge(ob[3], ob[0]) };
+ var te = new[] { b.AddEdge(ot[0], ot[1]), b.AddEdge(ot[1], ot[2]), b.AddEdge(ot[2], ot[3]), b.AddEdge(ot[3], ot[0]) };
+ var se = new[] { b.AddEdge(ob[0], ot[0]), b.AddEdge(ob[1], ot[1]), b.AddEdge(ob[2], ot[2]), b.AddEdge(ob[3], ot[3]) };
+ var hbe = new EdgeId[holeCount]; var hte = new EdgeId[holeCount]; var hse = new EdgeId[holeCount];
+ for (var i = 0; i < holeCount; i++) { hbe[i] = b.AddEdge(hb[i], hb[i]); hte[i] = b.AddEdge(ht[i], ht[i]); hse[i] = b.AddEdge(hb[i], ht[i]); }
+
+ var bottomLoops = new List<LoopId> { AddLoop(b, [Use.F(be[0]), Use.F(be[1]), Use.F(be[2]), Use.F(be[3])]) };
+ for (var i = 0; i < holeCount; i++) bottomLoops.Add(AddLoop(b, [Use.R(hbe[i])]));
+ var bottomFace = b.AddFace(bottomLoops);
+
+ var topLoops = new List<LoopId> { AddLoop(b, [Use.R(te[0]), Use.R(te[1]), Use.R(te[2]), Use.R(te[3])]) };
+ for (var i = 0; i < holeCount; i++) topLoops.Add(AddLoop(b, [Use.F(hte[i])]));
+ var topFace = b.AddFace(topLoops);
+
+ var faces = new List<FaceId> { bottomFace, topFace };
+ for (var i = 0; i < 4; i++)
+ {
+ var n = (i + 1) % 4;
+ faces.Add(b.AddFace([AddLoop(b, [Use.F(be[i]), Use.F(se[n]), Use.R(te[i]), Use.R(se[i])])]));
+ }
+ for (var i = 0; i < holeCount; i++) faces.Add(b.AddFace([AddLoop(b, [Use.F(hbe[i]), Use.F(hse[i]), Use.R(hte[i]), Use.R(hse[i])])]));
+
+ var shell = b.AddShell(faces);
+ b.AddBody([shell]);
+
+ var g = new BrepGeometryStore();
+ var bind = new BrepBindingModel();
+ var map = new Dictionary<VertexId, Point3D>
+ {
+ [ob[0]] = new(minX, minY, z0), [ob[1]] = new(maxX, minY, z0), [ob[2]] = new(maxX, maxY, z0), [ob[3]] = new(minX, maxY, z0),
+ [ot[0]] = new(minX, minY, z1), [ot[1]] = new(maxX, minY, z1), [ot[2]] = new(maxX, maxY, z1), [ot[3]] = new(minX, maxY, z1)
+ };
+ for (var i = 0; i < holeCount; i++)
+ {
+ var hole = request.Holes[i];
+ map[hb[i]] = new(hole.CenterX, hole.CenterY, z0);
+ map[ht[i]] = new(hole.CenterX, hole.CenterY, z1);
+ }
+
+ var cid = 1;
+ foreach (var e in b.Model.Edges.OrderBy(x => x.Id.Value))
+ {
+ var p0 = map[e.StartVertexId];
+ var p1 = map[e.EndVertexId];
+ CurveGeometry curve;
+ if (e.StartVertexId == e.EndVertexId)
+ {
+ var hIdx = Array.FindIndex(hb, v => v == e.StartVertexId);
+ if (hIdx < 0) hIdx = Array.FindIndex(ht, v => v == e.StartVertexId);
+ curve = CurveGeometry.FromCircle(new Circle3Curve(p0, Direction3D.Create(new Vector3D(0, 0, 1)), request.Holes[hIdx].Radius, Direction3D.Create(new Vector3D(1, 0, 0))));
+ bind.AddEdgeBinding(new EdgeGeometryBinding(e.Id, new CurveGeometryId(cid), new ParameterInterval(0, 2 * Math.PI)));
+ }
+ else
+ {
+ curve = CurveGeometry.FromLine(new Line3Curve(p0, Direction3D.Create(p1 - p0)));
+ bind.AddEdgeBinding(new EdgeGeometryBinding(e.Id, new CurveGeometryId(cid), new ParameterInterval(0, (p1 - p0).Length)));
+ }
+ g.AddCurve(new CurveGeometryId(cid++), curve);
+ }
+
+ g.AddSurface(new SurfaceGeometryId(1), SurfaceGeometry.FromPlane(new PlaneSurface(new Point3D(0, 0, z0), Direction3D.Create(new Vector3D(0, 0, -1)), Direction3D.Create(new Vector3D(1, 0, 0)))));
+ g.AddSurface(new SurfaceGeometryId(2), SurfaceGeometry.FromPlane(new PlaneSurface(new Point3D(0, 0, z1), Direction3D.Create(new Vector3D(0, 0, 1)), Direction3D.Create(new Vector3D(1, 0, 0)))));
+ g.AddSurface(new SurfaceGeometryId(3), SurfaceGeometry.FromPlane(new PlaneSurface(new Point3D(minX, minY, z0), Direction3D.Create(new Vector3D(0, -1, 0)), Direction3D.Create(new Vector3D(0, 0, 1)))));
+ g.AddSurface(new SurfaceGeometryId(4), SurfaceGeometry.FromPlane(new PlaneSurface(new Point3D(maxX, minY, z0), Direction3D.Create(new Vector3D(1, 0, 0)), Direction3D.Create(new Vector3D(0, 0, 1)))));
+ g.AddSurface(new SurfaceGeometryId(5), SurfaceGeometry.FromPlane(new PlaneSurface(new Point3D(maxX, maxY, z0), Direction3D.Create(new Vector3D(0, 1, 0)), Direction3D.Create(new Vector3D(0, 0, 1)))));
+ g.AddSurface(new SurfaceGeometryId(6), SurfaceGeometry.FromPlane(new PlaneSurface(new Point3D(minX, maxY, z0), Direction3D.Create(new Vector3D(-1, 0, 0)), Direction3D.Create(new Vector3D(0, 0, 1)))));
+ for (var i = 0; i < holeCount; i++)
+ {
+ var h = request.Holes[i];
+ g.AddSurface(new SurfaceGeometryId(7 + i), SurfaceGeometry.FromCylinder(new CylinderSurface(new Point3D(h.CenterX, h.CenterY, z0), Direction3D.Create(new Vector3D(0, 0, 1)), h.Radius, Direction3D.Create(new Vector3D(1, 0, 0)))));
+ }
+
+ bind.AddFaceBinding(new FaceGeometryBinding(faces[0], new SurfaceGeometryId(1)));
+ bind.AddFaceBinding(new FaceGeometryBinding(faces[1], new SurfaceGeometryId(2)));
+ bind.AddFaceBinding(new FaceGeometryBinding(faces[2], new SurfaceGeometryId(3)));
+ bind.AddFaceBinding(new FaceGeometryBinding(faces[3], new SurfaceGeometryId(4)));
+ bind.AddFaceBinding(new FaceGeometryBinding(faces[4], new SurfaceGeometryId(5)));
+ bind.AddFaceBinding(new FaceGeometryBinding(faces[5], new SurfaceGeometryId(6)));
+ for (var i = 0; i < holeCount; i++) bind.AddFaceBinding(new FaceGeometryBinding(faces[6 + i], new SurfaceGeometryId(7 + i)));
+ return (true, new BrepBody(b.Model, g, bind, map), string.Empty);
+ }
+
+ private static LoopId AddLoop(TopologyBuilder b, IReadOnlyList<Use> uses)
+ {
+ var lid = b.AllocateLoopId();
+ var cids = uses.Select(_ => b.AllocateCoedgeId()).ToArray();
+ for (var i = 0; i < uses.Count; i++)
+ {
+ var n = cids[(i + 1) % cids.Length];
+ var p = cids[(i + cids.Length - 1) % cids.Length];
+ b.AddCoedge(new Coedge(cids[i], uses[i].Edge, lid, n, p, uses[i].Rev));
+ }
+ b.AddLoop(new Loop(lid, cids));
+ return lid;
+ }
+
+ private readonly record struct Use(EdgeId Edge, bool Rev)
+ {
+ public static Use F(EdgeId e) => new(e, false);
+ public static Use R(EdgeId e) => new(e, true);
+ }
+}
diff --git a/docs/frictionlab/v2-x3-profile-with-hole-extrude-lab.md b/docs/frictionlab/v2-x3-profile-with-hole-extrude-lab.md
index d3a5928b..2d3dd723 100644
--- a/docs/frictionlab/v2-x3-profile-with-hole-extrude-lab.md
+++ b/docs/frictionlab/v2-x3-profile-with-hole-extrude-lab.md
@@ -60,3 +60,6 @@ Current lab recommendation for successful valid cases: `profile-hole-extrude-rea
## Recommended next step
Proceed to production evaluation focused on emitter parity/hardening and contract migration from lab profile model to production profile contract.
+
+## V2-V1 follow-up note
+V2-V1 consumed this lab evidence by adding a bounded production-adjacent internal emitter (`ProfileHoleExtrudeEmitter`) with parity tests; executor integration remained deferred behind existing fallbacks.
diff --git a/docs/v2-v1-profile-hole-extrude-production-evaluation.md b/docs/v2-v1-profile-hole-extrude-production-evaluation.md
new file mode 100644
index 00000000..b90407ee
--- /dev/null
+++ b/docs/v2-v1-profile-hole-extrude-production-evaluation.md
@@ -0,0 +1,74 @@
+# V2-V1 Production Evaluation — ProfileHoleExtrude through-hole emission
+
+## Purpose and scope
+This milestone evaluates V2-X3's profile-topology-first through-hole extrusion as a bounded production-adjacent emitter for rectangular outer loops with circular through-holes, without `BrepBoolean.Subtract`.
+
+## Architectural references
+- V2 doctrine: `docs/aetheris-v2-sweep-first-architecture.md`
+- Resolved profile contract (V2-A1): `docs/aetheris-v2-a1-resolved-profile2d-contract.md`
+- V2-X1 lab: `docs/frictionlab/v2-x1-resolved-profile2d-lab.md`
+- V2-X3 lab evidence: `docs/frictionlab/v2-x3-profile-with-hole-extrude-lab.md`
+
+## Adoption decision
+Decision: **production-adjacent emitter added, production route integration deferred**.
+
+Added internal component:
+- `Aetheris.Kernel.Firmament/Materializer/ProfileHoleExtrudeEmitter.cs`
+
+Not changed in this milestone:
+- no STEP exporter/importer behavior changes,
+- no Boolean core behavior changes,
+- no broad executor/materializer routing replacement,
+- no blind/counterbore/stepped-hole support added.
+
+## Admissibility boundary (exact)
+Accepted input boundary in `ProfileHoleExtrudeEmitter`:
+- rectangular prism outer profile (`Width`, `Depth` > 0),
+- one or more circular holes (full circles only),
+- full-height linear extrusion (`Height` > 0),
+- hole loops strictly inside boundary,
+- non-overlapping hole loops,
+- through-hole only.
+
+Rejected/deferred:
+- holes outside/touching boundary,
+- overlapping holes,
+- non-positive radius,
+- non-positive height,
+- non-rectangular or arbitrary curve loop shapes (not represented by this emitter input type),
+- blind/counterbore/stepped holes.
+
+## No-Boolean-subtract guarantee
+The candidate path emits BRep topology directly (builder + explicit topology/geometry binding) and does not call `BrepBoolean.Subtract`.
+Diagnostics include:
+- `v2-v1-profile-hole-extrude-attempted`
+- `v2-v1-profile-hole-extrude-accepted`
+- `v2-v1-profile-hole-extrude-succeeded`
+- `v2-v1-profile-hole-extrude-rejected:<reason>`
+- `v2-v1-profile-hole-extrude-no-3d-boolean-subtract`
+
+## Topology/STEP parity findings
+Validated cases preserve the expected V2-X3 shape contract:
+- planar face count = 6,
+- cylindrical face count = hole count,
+- STEP smoke contains `ISO-10303-21`, `MANIFOLD_SOLID_BREP`, `ADVANCED_FACE`, `PLANE`, `CYLINDRICAL_SURFACE`,
+- STEP smoke does not contain `BREP_WITH_VOIDS`.
+
+## Fallback behavior
+No production executor integration in V2-V1, therefore existing recovery/materializer paths and fallbacks remain unchanged.
+
+## Tests run
+- Added focused emitter tests in `Aetheris.Kernel.Firmament.Tests/Integration/ProfileHoleExtrudeEmitterTests.cs` for required valid and invalid cases.
+- Existing focused suite execution is retained and reported in milestone run output.
+
+## Remaining limitations
+- Emitter currently uses a narrow internal request model, not direct `ResolvedProfile2D` wiring.
+- Multiple-outer-loop and open-profile rejection are handled upstream/lab contract today, not by this emitter's request type.
+- Integration diagnostics for fallback routes (`...-failed-fallback`, `...-legacy-through-hole`) are deferred until routing integration.
+
+## Next recommended milestone
+V2-V2:
+1. add guarded integration attempt in through-hole rectangular-box Z-axis routes,
+2. keep strict fallback to legacy route,
+3. emit route-level fallback diagnostics,
+4. compare semantic parity against existing routes with CLI-level coverage.