Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Publish authoritative BRep extrusion plans

Yuechen Lib1f1866bc49d
diff --git a/Aetheris.CLI/CliRunner.cs b/Aetheris.CLI/CliRunner.cs
index 8ca96ccd..d35053a0 100644
--- a/Aetheris.CLI/CliRunner.cs
+++ b/Aetheris.CLI/CliRunner.cs
@@ -438,6 +438,9 @@ public static class CliRunner
var parsed = ProfileAuthoringParser.Parse(source);
if (parsed.Profile is null) { stderr.WriteLine(string.Join(Environment.NewLine, parsed.Diagnostics)); return 1; }
var validation = ResolvedProfile2DValidator.Validate(parsed.Profile);
+ var plan = validation.IsValid
+ ? ProfileExtrusionBRepPlanner.TryPlan(new LineArcProfileExtrudeRequest(parsed.Profile.Loops.Select(l => new LineArcProfileLoop2D(l.Segments.Select(s => s.Geometry).ToArray(), !l.IsOuter)).ToArray(), parsed.Height, parsed.Profile.EffectiveConstructionPlane, parsed.Profile.LocalStartDepth, parsed.Profile.LocalEndDepth), parsed.Profile)
+ : new ProfileExtrusionPlanResult(false, null, validation.Diagnostics);
var report = new
{
profile = new
@@ -451,7 +454,19 @@ public static class CliRunner
return new { x.Name, guide = guide.Name, guideKind = guide.Kind, parentGuide = guide.Parent, stableId = x.Provenance.StableId, derivation = x.Provenance.Derivation, geometry = x.Geometry.GetType().Name };
}),
validation.IsValid, validation.SignedArea, validation.Diagnostics,
- extrusionHeight = parsed.Height
+ extrusionHeight = parsed.Height,
+ brepPlan = plan.Plan is null ? null : new
+ {
+ plan.Plan.StableId, authoritative = plan.Plan.IsAuthoritative,
+ constructionPlane = DescribeConstructionPlane(plan.Plan.Construction.Frame),
+ localDepth = new { start = plan.Plan.Construction.LocalStartDepth, end = plan.Plan.Construction.LocalEndDepth },
+ topology = new { vertices = plan.Plan.Vertices.Count, curves = plan.Plan.Curves.Count, edges = plan.Plan.Edges.Count, loops = plan.Plan.Loops.Count, coedges = plan.Plan.CoedgeCount, surfaces = plan.Plan.Surfaces.Count, faces = plan.Plan.Faces.Count, shells = 1, bodies = 1 },
+ roles = plan.Plan.Faces.Select(x => new { x.StableId, role = x.Role.ToString(), loops = x.LoopIds.Select(id => id.Value), x.SameSense }),
+ correspondence = plan.Plan.Correspondence.Descendants.Select(x => new { x.StableId, role = x.Role.ToString(), x.SourceStableId, edge = x.Edge?.Value, face = x.Face?.Value, loop = x.Loop?.Value }),
+ materializer = "ProfileExtrusionBRepMaterializer",
+ plan.Plan.Provenance,
+ plan.Plan.Diagnostics
+ }
}
};
if (json) stdout.WriteLine(JsonSerializer.Serialize(report, JsonOptions)); else stdout.WriteLine($"Profile {parsed.Profile.Name}: {(validation.IsValid ? "valid" : "invalid")}");
diff --git a/Aetheris.Kernel.Firmament.Tests/Integration/ConstructionPlaneExtrudeTests.cs b/Aetheris.Kernel.Firmament.Tests/Integration/ConstructionPlaneExtrudeTests.cs
index 0cfb761d..62bb4d66 100644
--- a/Aetheris.Kernel.Firmament.Tests/Integration/ConstructionPlaneExtrudeTests.cs
+++ b/Aetheris.Kernel.Firmament.Tests/Integration/ConstructionPlaneExtrudeTests.cs
@@ -95,6 +95,38 @@ public sealed class ConstructionPlaneExtrudeTests
}
}
+ [Fact]
+ public void AuthoritativePlan_ClosesDirectedUsesBeforeMaterialization_AndCarriesNonZInnerCylinder()
+ {
+ var plane = Trace("plan-x", new(10, 2, 3), new(1, 0, 0), new(0, 0, 1));
+ var request = new LineArcProfileExtrudeRequest([Rectangle(), new LineArcProfileLoop2D([new LineArcFullCircle2D((0, 0), .5)], true)], 4, plane);
+ var planned = ProfileExtrusionBRepPlanner.TryPlan(request);
+ var plan = Assert.IsType<ProfileExtrusionBRepPlan>(planned.Plan);
+ Assert.True(plan.IsAuthoritative);
+ Assert.Equal("construction:plan-x", plan.Construction.Frame.StableId);
+ Assert.All(plan.Loops, loop => Assert.All(loop.Uses.Select((use, i) => (use, next: loop.Uses[(i + 1) % loop.Uses.Count])), pair => Assert.Equal(pair.use.Traversal.EndVertexId, pair.next.Traversal.StartVertexId)));
+ Assert.Contains(plan.Surfaces, s => s.Geometry.Cylinder is { } c && Math.Abs(c.Axis.ToVector().Dot(plane.AxisZ.ToVector()) - 1d) < 1e-12);
+ var materialized = ProfileExtrusionBRepMaterializer.TryMaterialize(plan);
+ Assert.True(materialized.Succeeded, string.Join("; ", materialized.Diagnostics));
+ var step = Step242Exporter.ExportBody(materialized.Body!);
+ Assert.True(step.IsSuccess);
+ Assert.True(Step242Importer.ImportBody(step.Value!).IsSuccess);
+ }
+
+ [Fact]
+ public void ResolvedInnerCircularLoop_PublishesPlanOwnedCylindricalWallCorrespondence()
+ {
+ var plane = Trace("inner-x", new(10, 0, 0), new(1, 0, 0), new(0, 0, 1));
+ var outer = Rectangle().Curves.Select((curve, index) => new ResolvedProfileSegment2D($"E{index}", curve, new($"profile:InnerProfile.Outer.E{index}", $"concept:E{index}", "fixture", "fixture", "XY"))).ToArray();
+ var profile = new ResolvedProfile2D("InnerProfile", "inner-x", [
+ new ResolvedProfileLoop2D("Outer", true, outer),
+ new ResolvedProfileLoop2D("Bore", false, [new("Circle", new LineArcFullCircle2D((0, 0), .5), new("profile:InnerProfile.Bore.Circle", "concept:Circle", "fixture", "fixture", "XY"))])], plane);
+ var result = LineArcProfileExtrudeEmitter.TryEmit(profile, 4);
+ Assert.Equal(LineArcProfileExtrudeStatus.Succeeded, result.Status);
+ Assert.NotNull(result.BRepPlan);
+ Assert.Contains(result.Correspondence!.Descendants, x => x.SourceStableId == "profile:InnerProfile.Bore" && x.Role == SemanticTopologyRole.HoleWallFace && x.Face is not null);
+ }
+
private static ConstructionPlane Trace(string id, ConceptIrPoint3 origin, ConceptIrVector3 normal, ConceptIrVector3 up)
{
Assert.True(ConstructionPlane.TryTrace("construction:" + id, new("concept:" + id, origin, normal, "fixture", up), "fixture", out var plane, out var diagnostic), diagnostic);
diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringParser.cs b/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringParser.cs
index 213a6585..90b066b3 100644
--- a/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringParser.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringParser.cs
@@ -54,8 +54,8 @@ public static class ProfileAuthoringParser
if(lines.TryGetValue(trace,out var line)){if(!OnLine(a,line)||!OnLine(b,line))d.Add($"profile-endpoint-not-on-guide:{n}:{trace}"); g=new LineArcLineSegment2D(a,b);}
else if(circles.TryGetValue(trace,out var circle)){if(!OnCircle(a,circle)||!OnCircle(b,circle)||!m.Groups["sweep"].Success){d.Add($"profile-arc-invalid:{n}:{trace}");continue;}var sa=Math.Atan2(a.Y-circle.C.Y,a.X-circle.C.X);var sw=Math.Atan2(b.Y-circle.C.Y,b.X-circle.C.X)-sa;var ccw=m.Groups["sweep"].Value=="CounterClockwise";while(ccw&&sw<=0)sw+=2*Math.PI;while(!ccw&&sw>=0)sw-=2*Math.PI;g=new LineArcCircularArc2D(circle.C,circle.R,sa,sw);}
else {d.Add($"profile-guide-missing:{n}:{trace}");continue;} segments.Add(new(n,g,new($"profile:{h.Groups["n"].Value}.Outer.{n}",$"concept:{h.Groups["layout"].Value}.{trace}","source",$"Trace({trace})","XY"))); }
- var e=Extrude.Match(source);var height=e.Success?Math.Abs(N(e,"b")-N(e,"a")):0;if(!e.Success||e.Groups["p"].Value!=h.Groups["n"].Value)d.Add("profile-extrude-missing-or-mismatched");
- return d.Count>0?(null,height,d):(new ResolvedProfile2D(h.Groups["n"].Value,h.Groups["layout"].Value,[new ResolvedProfileLoop2D("Outer",true,segments)],constructionPlane),height,d);
+ var e=Extrude.Match(source);var localStart=e.Success?N(e,"a"):0;var localEnd=e.Success?N(e,"b"):0;var height=e.Success?Math.Abs(localEnd-localStart):0;if(!e.Success||e.Groups["p"].Value!=h.Groups["n"].Value)d.Add("profile-extrude-missing-or-mismatched");
+ return d.Count>0?(null,height,d):(new ResolvedProfile2D(h.Groups["n"].Value,h.Groups["layout"].Value,[new ResolvedProfileLoop2D("Outer",true,segments)],constructionPlane,localStart,localEnd),height,d);
}
private static double N(Match m,string n)=>double.Parse(m.Groups[n].Value,CultureInfo.InvariantCulture); private static bool OnLine((double X,double Y)p,LineArcLineSegment2D l)=>Math.Abs((l.End.X-l.Start.X)*(p.Y-l.Start.Y)-(l.End.Y-l.Start.Y)*(p.X-l.Start.X))<1e-7; private static bool OnCircle((double X,double Y)p,((double X,double Y)C,double R)c)=>Math.Abs(Math.Sqrt((p.X-c.C.X)*(p.X-c.C.X)+(p.Y-c.C.Y)*(p.Y-c.C.Y))-c.R)<1e-7;
}
diff --git a/Aetheris.Kernel.Firmament/Materializer/LineArcProfileExtrudeEmitter.cs b/Aetheris.Kernel.Firmament/Materializer/LineArcProfileExtrudeEmitter.cs
index a4bc551e..bce8a6c3 100644
--- a/Aetheris.Kernel.Firmament/Materializer/LineArcProfileExtrudeEmitter.cs
+++ b/Aetheris.Kernel.Firmament/Materializer/LineArcProfileExtrudeEmitter.cs
@@ -1,9 +1,4 @@
-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;
+using System.Diagnostics;
namespace Aetheris.Kernel.Firmament.Materializer;
@@ -12,185 +7,66 @@ public sealed record LineArcLineSegment2D((double X, double Y) Start, (double X,
public sealed record LineArcCircularArc2D((double X, double Y) Center, double Radius, double StartAngleRadians, double SweepAngleRadians) : LineArcProfileCurve2D;
public sealed record LineArcFullCircle2D((double X, double Y) Center, double Radius) : LineArcProfileCurve2D;
public sealed record LineArcProfileLoop2D(IReadOnlyList<LineArcProfileCurve2D> Curves, bool IsHole);
-/// <summary>Local 2D boundary plus a traced immutable material frame. Height remains a local +Z distance.</summary>
-public sealed record LineArcProfileExtrudeRequest(IReadOnlyList<LineArcProfileLoop2D> Loops, double Height, ConstructionPlane? ConstructionPlane = null);
+
+/// <summary>Local profile and local depth interval. Height-only callers retain the historic centered interval.</summary>
+public sealed record LineArcProfileExtrudeRequest(
+ IReadOnlyList<LineArcProfileLoop2D> Loops,
+ double Height,
+ ConstructionPlane? ConstructionPlane = null,
+ double? LocalStartDepth = null,
+ double? LocalEndDepth = null);
+
public enum LineArcProfileExtrudeStatus { Succeeded, Rejected, Deferred, Failed }
-public sealed record LineArcProfileExtrudeResult(LineArcProfileExtrudeStatus Status, BrepBody? Body, IReadOnlyList<string> Diagnostics, SemanticTopologyCorrespondence? Correspondence = null);
+public sealed record ProfileExtrusionTiming(TimeSpan PlanConstruction, TimeSpan BRepMaterialization);
+
+/// <summary>The plan is published before materialization; correspondence is owned by that plan.</summary>
+public sealed record LineArcProfileExtrudeResult(
+ LineArcProfileExtrudeStatus Status,
+ Aetheris.Kernel.Core.Brep.BrepBody? Body,
+ IReadOnlyList<string> Diagnostics,
+ SemanticTopologyCorrespondence? Correspondence = null,
+ ProfileExtrusionBRepPlan? BRepPlan = null,
+ ProfileExtrusionTiming? Timing = null);
+/// <summary>
+/// Compatibility entry point. It is intentionally only a plan consumer: topology authority is
+/// <see cref="ProfileExtrusionBRepPlanner"/>, and this class only materializes its exact entities.
+/// </summary>
public static class LineArcProfileExtrudeEmitter
{
- private const double Tol = 1e-6;
-
public static LineArcProfileExtrudeResult TryEmit(LineArcProfileExtrudeRequest request)
- {
- var d = new List<string> { "v2-v4-line-arc-profile-extrude-attempted" };
- if (!Validate(request, d)) return new(LineArcProfileExtrudeStatus.Rejected, null, d);
- d.Add("v2-v4-profile-validated");
- var ok = TryBuild(request, null, d, out var body, out var correspondence);
- if (!ok || body is null) return new(LineArcProfileExtrudeStatus.Failed, null, d.Append("v2-v4-line-arc-profile-extrude-rejected:emitter validation failed").ToArray());
- d.Add("v2-v4-cap-faces-emitted");
- d.Add("v2-v4-no-3d-boolean-used");
- d.Add("v2-v4-line-arc-profile-extrude-succeeded");
- return new(LineArcProfileExtrudeStatus.Succeeded, body, d.Distinct().OrderBy(x => x).ToArray(), correspondence);
- }
+ => Emit(request, null);
- /// <summary>Materializes a resolved authored Profile and retains direct plan-to-topology correspondence.</summary>
+ /// <summary>Materializes a resolved authored Profile through its authoritative BRepPlan.</summary>
public static LineArcProfileExtrudeResult TryEmit(ResolvedProfile2D profile, double height)
{
var validation = ResolvedProfile2DValidator.Validate(profile);
- if (!validation.IsValid) return new(LineArcProfileExtrudeStatus.Rejected, null, validation.Diagnostics);
- var request = new LineArcProfileExtrudeRequest(profile.Loops.Select(l => new LineArcProfileLoop2D(l.Segments.Select(s => s.Geometry).ToArray(), !l.IsOuter)).ToArray(), height, profile.EffectiveConstructionPlane);
- var diagnostics = new List<string> { "v2-v4-line-arc-profile-extrude-attempted", "semantic-selection-correspondence-requested" };
- if (!Validate(request, diagnostics)) return new(LineArcProfileExtrudeStatus.Rejected, null, diagnostics);
- var ok = TryBuild(request, profile, diagnostics, out var body, out var correspondence);
- return ok && body is not null
- ? new(LineArcProfileExtrudeStatus.Succeeded, body, diagnostics.Distinct().OrderBy(x => x).ToArray(), correspondence)
- : new(LineArcProfileExtrudeStatus.Failed, null, diagnostics.Append("v2-v4-line-arc-profile-extrude-rejected:emitter validation failed").ToArray());
+ if (!validation.IsValid)
+ return new(LineArcProfileExtrudeStatus.Rejected, null, validation.Diagnostics);
+ var request = new LineArcProfileExtrudeRequest(
+ profile.Loops.Select(l => new LineArcProfileLoop2D(l.Segments.Select(s => s.Geometry).ToArray(), !l.IsOuter)).ToArray(),
+ height,
+ profile.EffectiveConstructionPlane,
+ profile.LocalStartDepth,
+ profile.LocalEndDepth);
+ return Emit(request, profile);
}
- private static bool Validate(LineArcProfileExtrudeRequest req, List<string> d)
+ private static LineArcProfileExtrudeResult Emit(LineArcProfileExtrudeRequest request, ResolvedProfile2D? source)
{
- if (!double.IsFinite(req.Height) || req.Height <= Tol) { d.Add("v2-v4-line-arc-profile-extrude-rejected:invalid height"); return false; }
- if (req.Loops.Count == 0 || req.Loops.Count(l => !l.IsHole) != 1) { d.Add("v2-v4-line-arc-profile-extrude-rejected:unsupported topology"); return false; }
- foreach (var loop in req.Loops)
- {
- if (loop.Curves.Count == 0) { d.Add("v2-v4-line-arc-profile-extrude-rejected:invalid profile"); return false; }
- foreach (var c in loop.Curves)
- {
- switch (c)
- {
- case LineArcLineSegment2D s when Math.Sqrt(Math.Pow(s.End.X-s.Start.X,2)+Math.Pow(s.End.Y-s.Start.Y,2)) <= Tol: d.Add("v2-v4-line-arc-profile-extrude-rejected:invalid profile"); return false;
- case LineArcCircularArc2D a when !double.IsFinite(a.Radius) || a.Radius <= Tol || Math.Abs(a.SweepAngleRadians) <= Tol: d.Add("v2-v4-line-arc-profile-extrude-rejected:unsupported curve"); return false;
- case LineArcFullCircle2D fc when !double.IsFinite(fc.Radius) || fc.Radius <= Tol: d.Add("v2-v4-line-arc-profile-extrude-rejected:unsupported curve"); return false;
- }
- }
- }
- return true;
- }
-
- private static bool TryBuild(LineArcProfileExtrudeRequest profile, ResolvedProfile2D? sourceProfile, List<string> d, out BrepBody? body, out SemanticTopologyCorrespondence? correspondence)
- {
- body = null; correspondence = null;
- var h = profile.Height;
- var frame = profile.ConstructionPlane ?? ConstructionPlane.WorldXY;
- var b = new TopologyBuilder();
- var z0 = -h / 2d; var z1 = h / 2d;
- var bottomLoops = new List<LoopId>(); var topLoops = new List<LoopId>();
- var sideFaces = new List<(LoopId Loop, SurfaceGeometry Surface, string Diag, string? Source, EdgeId Bottom, EdgeId Top, EdgeId StartVertical, EdgeId EndVertical)>();
- var descendants = new List<SemanticTopologyDescendant>();
- var points = new Dictionary<VertexId, Point3D>();
- var edgeCurves = new Dictionary<EdgeId, CurveGeometry>();
- // A profile loop owns its vertices. Adjacent curves that meet at the same
- // resolved point must reuse the same top/bottom vertices and vertical edge;
- // geometric coincidence is not an authoritative topology connection.
- var bottomVertices = new Dictionary<(long X, long Y), VertexId>();
- var topVertices = new Dictionary<(long X, long Y), VertexId>();
- var verticalEdges = new Dictionary<(long X, long Y), EdgeId>();
- (long X, long Y) Key((double X, double Y) p) => ((long)Math.Round(p.X / Tol), (long)Math.Round(p.Y / Tol));
- VertexId Vertex((double X, double Y) p, double z, Dictionary<(long X, long Y), VertexId> cache)
- {
- var key = Key(p);
- if (cache.TryGetValue(key, out var existing)) return existing;
- var created = b.AddVertex(); points[created] = frame.ToWorld(p, z); cache.Add(key, created); return created;
- }
- EdgeId Vertical((double X, double Y) p, VertexId bottom, VertexId top)
- {
- var key = Key(p);
- if (verticalEdges.TryGetValue(key, out var existing)) return existing;
- var created = b.AddEdge(bottom, top);
- edgeCurves[created] = CurveGeometry.FromLine(new Line3Curve(points[bottom], Direction3D.Create(points[top] - points[bottom])));
- verticalEdges.Add(key, created); return created;
- }
+ var planClock = Stopwatch.StartNew();
+ var planned = ProfileExtrusionBRepPlanner.TryPlan(request, source);
+ planClock.Stop();
+ if (!planned.Succeeded || planned.Plan is null)
+ return new(LineArcProfileExtrudeStatus.Rejected, null, planned.Diagnostics, null, null, new(planClock.Elapsed, TimeSpan.Zero));
- for (var loopIndex = 0; loopIndex < profile.Loops.Count; loopIndex++)
- {
- var loop = profile.Loops[loopIndex];
- var bottomUses = new List<Use>(); var topUses = new List<Use>();
- for (var curveIndex = 0; curveIndex < loop.Curves.Count; curveIndex++)
- {
- var curve = loop.Curves[curveIndex];
- var source = sourceProfile?.Loops[loopIndex].Segments[curveIndex].Provenance.StableId;
- switch (curve)
- {
- case LineArcLineSegment2D line:
- {
- var vb0 = Vertex(line.Start, z0, bottomVertices); var vb1 = Vertex(line.End, z0, bottomVertices); var vt0 = Vertex(line.Start, z1, topVertices); var vt1 = Vertex(line.End, z1, topVertices);
- var eb = b.AddEdge(vb0, vb1); var et = b.AddEdge(vt0, vt1); var es0 = Vertical(line.Start, vb0, vt0); var es1 = Vertical(line.End, vb1, vt1);
- edgeCurves[eb] = CurveGeometry.FromLine(new Line3Curve(points[vb0], Direction3D.Create(points[vb1] - points[vb0])));
- edgeCurves[et] = CurveGeometry.FromLine(new Line3Curve(points[vt0], Direction3D.Create(points[vt1] - points[vt0])));
- bottomUses.Add(loop.IsHole ? Use.R(eb) : Use.F(eb)); topUses.Add(loop.IsHole ? Use.R(et) : Use.F(et));
- var loopId = AddLoop(b, [Use.F(eb), Use.F(es1), Use.R(et), Use.R(es0)]);
- var dx = line.End.X - line.Start.X; var dy = line.End.Y - line.Start.Y; var nx = loop.IsHole ? -dy : dy; var ny = loop.IsHole ? dx : -dx;
- sideFaces.Add((loopId, SurfaceGeometry.FromPlane(new PlaneSurface(frame.ToWorld(line.Start, z0), Direction3D.Create(frame.ToWorldDirection(new Vector3D(nx, ny, 0))), frame.AxisZ)), "v2-v4-line-edge-side-face-emitted", source, eb, et, es0, es1));
- break;
- }
- case LineArcCircularArc2D arc:
- {
- var s = (arc.Center.X + arc.Radius * Math.Cos(arc.StartAngleRadians), arc.Center.Y + arc.Radius * Math.Sin(arc.StartAngleRadians));
- var e = (arc.Center.X + arc.Radius * Math.Cos(arc.StartAngleRadians + arc.SweepAngleRadians), arc.Center.Y + arc.Radius * Math.Sin(arc.StartAngleRadians + arc.SweepAngleRadians));
- var vb0=Vertex(s,z0,bottomVertices);var vb1=Vertex(e,z0,bottomVertices);var vt0=Vertex(s,z1,topVertices);var vt1=Vertex(e,z1,topVertices);
- var eb=b.AddEdge(vb0,vb1); var et=b.AddEdge(vt0,vt1); var es0=Vertical(s,vb0,vt0); var es1=Vertical(e,vb1,vt1);
- edgeCurves[eb]=CurveGeometry.FromCircle(new Circle3Curve(frame.ToWorld(arc.Center,z0),frame.AxisZ,arc.Radius,frame.AxisX));
- edgeCurves[et]=CurveGeometry.FromCircle(new Circle3Curve(frame.ToWorld(arc.Center,z1),frame.AxisZ,arc.Radius,frame.AxisX));
- bottomUses.Add(loop.IsHole ? Use.R(eb) : Use.F(eb)); topUses.Add(loop.IsHole ? Use.R(et) : Use.F(et));
- sideFaces.Add((AddLoop(b,[Use.F(eb),Use.F(es1),Use.R(et),Use.R(es0)]), SurfaceGeometry.FromCylinder(new CylinderSurface(frame.ToWorld(arc.Center,z0),frame.AxisZ,arc.Radius,frame.AxisX)), "v2-v4-arc-edge-side-face-emitted", source, eb, et, es0, es1));
- break;
- }
- case LineArcFullCircle2D circle:
- {
- var vb=b.AddVertex(); var vt=b.AddVertex(); points[vb]=frame.ToWorld(circle.Center,z0); points[vt]=frame.ToWorld(circle.Center,z1);
- var eb=b.AddEdge(vb,vb); var et=b.AddEdge(vt,vt); var es=b.AddEdge(vb,vt);
- edgeCurves[eb]=CurveGeometry.FromCircle(new Circle3Curve(points[vb],frame.AxisZ,circle.Radius,frame.AxisX));
- edgeCurves[et]=CurveGeometry.FromCircle(new Circle3Curve(points[vt],frame.AxisZ,circle.Radius,frame.AxisX));
- edgeCurves[es]=CurveGeometry.FromLine(new Line3Curve(points[vb],Direction3D.Create(points[vt]-points[vb])));
- bottomUses.Add(loop.IsHole ? Use.R(eb) : Use.F(eb)); topUses.Add(loop.IsHole ? Use.R(et) : Use.F(et));
- sideFaces.Add((AddLoop(b,[Use.F(eb),Use.F(es),Use.R(et),Use.R(es)]), SurfaceGeometry.FromCylinder(new CylinderSurface(points[vb],frame.AxisZ,circle.Radius,frame.AxisX)), "v2-v4-full-circle-side-face-emitted", source, eb, et, es, es));
- break;
- }
- }
- }
- bottomLoops.Add(AddLoop(b, bottomUses));
- topLoops.Add(AddLoop(b, topUses));
- }
-
- var bottomFace = b.AddFace(bottomLoops); var topFace = b.AddFace(topLoops); var faceIds = new List<FaceId> { bottomFace, topFace };
- foreach (var sf in sideFaces) { faceIds.Add(b.AddFace([sf.Loop])); d.Add(sf.Diag); }
- var shell = b.AddShell(faceIds); b.AddBody([shell]);
- var g = new BrepGeometryStore(); var bind = new BrepBindingModel(); var cid = 1;
- foreach (var e in b.Model.Edges.OrderBy(x => x.Id.Value)) { g.AddCurve(new CurveGeometryId(cid), edgeCurves[e.Id]); bind.AddEdgeBinding(new EdgeGeometryBinding(e.Id, new CurveGeometryId(cid), new ParameterInterval(0, 2 * Math.PI))); cid++; }
- g.AddSurface(new SurfaceGeometryId(1), SurfaceGeometry.FromPlane(new PlaneSurface(frame.ToWorld((0,0),z0), Direction3D.Create(-frame.AxisZ.ToVector()), frame.AxisX)));
- g.AddSurface(new SurfaceGeometryId(2), SurfaceGeometry.FromPlane(new PlaneSurface(frame.ToWorld((0,0),z1), frame.AxisZ, frame.AxisX)));
- bind.AddFaceBinding(new FaceGeometryBinding(bottomFace, new SurfaceGeometryId(1))); bind.AddFaceBinding(new FaceGeometryBinding(topFace, new SurfaceGeometryId(2)));
- var sid = 3; for (var i = 0; i < sideFaces.Count; i++) { g.AddSurface(new SurfaceGeometryId(sid), sideFaces[i].Surface); bind.AddFaceBinding(new FaceGeometryBinding(faceIds[2+i], new SurfaceGeometryId(sid))); sid++; }
- body = new BrepBody(b.Model, g, bind, points);
- if (sourceProfile is not null)
- {
- for (var i = 0; i < sideFaces.Count; i++)
- {
- var side = sideFaces[i]; if (side.Source is null) continue;
- var prefix = $"material:{sourceProfile.Name}:{side.Source}";
- descendants.Add(new($"{prefix}:local-start", "Edge", SemanticTopologyRole.LocalStartBoundary, side.Source, Edge: side.Bottom, ParentStableId: side.Source));
- descendants.Add(new($"{prefix}:local-end", "Edge", SemanticTopologyRole.LocalEndBoundary, side.Source, Edge: side.Top, ParentStableId: side.Source));
- // Compatibility aliases: Top/Bottom mean local +Z/-Z, never world Z.
- descendants.Add(new($"{prefix}:bottom", "Edge", SemanticTopologyRole.BottomBoundary, side.Source, Edge: side.Bottom, ParentStableId: side.Source));
- descendants.Add(new($"{prefix}:top", "Edge", SemanticTopologyRole.TopBoundary, side.Source, Edge: side.Top, ParentStableId: side.Source));
- descendants.Add(new($"{prefix}:vertical-start", "Edge", SemanticTopologyRole.VerticalExtrusionEdge, side.Source, Edge: side.StartVertical, ParentStableId: side.Source));
- descendants.Add(new($"{prefix}:vertical-end", "Edge", SemanticTopologyRole.VerticalExtrusionEdge, side.Source, Edge: side.EndVertical, ParentStableId: side.Source));
- descendants.Add(new($"{prefix}:side", "Face", SemanticTopologyRole.ExtrusionSideFace, side.Source, Face: faceIds[2 + i], ParentStableId: side.Source));
- }
- for (var i = 0; i < sourceProfile.Loops.Count; i++)
- {
- var loopSource = $"profile:{sourceProfile.Name}.{sourceProfile.Loops[i].Name}";
- descendants.Add(new($"material:{sourceProfile.Name}:{loopSource}:local-start-loop", "Loop", SemanticTopologyRole.LocalStartCapLoop, loopSource, Loop: bottomLoops[i], ParentStableId: loopSource));
- descendants.Add(new($"material:{sourceProfile.Name}:{loopSource}:local-end-loop", "Loop", SemanticTopologyRole.LocalEndCapLoop, loopSource, Loop: topLoops[i], ParentStableId: loopSource));
- descendants.Add(new($"material:{sourceProfile.Name}:{loopSource}:bottom-loop", "Loop", SemanticTopologyRole.BottomFaceBoundaryLoop, loopSource, Loop: bottomLoops[i], ParentStableId: loopSource));
- descendants.Add(new($"material:{sourceProfile.Name}:{loopSource}:top-loop", "Loop", SemanticTopologyRole.TopFaceBoundaryLoop, loopSource, Loop: topLoops[i], ParentStableId: loopSource));
- }
- correspondence = new(sourceProfile.Name, descendants, ["ConceptPlane:" + frame.SourceConceptId, "ConstructionPlane:" + frame.StableId, "Profile", "ResolvedProfile2D", "LineArcProfileExtrude", "AuthoritativeBRepPlan"]);
- }
- return true;
+ var materializationClock = Stopwatch.StartNew();
+ var materialized = ProfileExtrusionBRepMaterializer.TryMaterialize(planned.Plan);
+ materializationClock.Stop();
+ var diagnostics = planned.Diagnostics.Concat(materialized.Diagnostics).Distinct().OrderBy(x => x, StringComparer.Ordinal).ToArray();
+ var timing = new ProfileExtrusionTiming(planClock.Elapsed, materializationClock.Elapsed);
+ return materialized.Succeeded && materialized.Body is not null
+ ? new(LineArcProfileExtrudeStatus.Succeeded, materialized.Body, diagnostics, planned.Plan.Correspondence, planned.Plan, timing)
+ : new(LineArcProfileExtrudeStatus.Failed, null, diagnostics, planned.Plan.Correspondence, planned.Plan, timing);
}
-
- 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/Aetheris.Kernel.Firmament/Materializer/ProfileExtrusionBRepPlan.cs b/Aetheris.Kernel.Firmament/Materializer/ProfileExtrusionBRepPlan.cs
new file mode 100644
index 00000000..860ad3b2
--- /dev/null
+++ b/Aetheris.Kernel.Firmament/Materializer/ProfileExtrusionBRepPlan.cs
@@ -0,0 +1,283 @@
+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;
+
+/// <summary>Construction AIR normalized from a local Profile plus one immutable material frame.</summary>
+public sealed record ProfileExtrusionConstructionAir(
+ string StableId, string ProfileStableId, ConstructionPlane Frame,
+ double LocalStartDepth, double LocalEndDepth, IReadOnlyList<LineArcProfileLoop2D> Loops,
+ IReadOnlyList<string> Provenance);
+
+public enum ProfileExtrusionPlanRole
+{
+ LocalStartVertex, LocalEndVertex, LocalStartBoundary, LocalEndBoundary, LongitudinalBoundary,
+ LocalStartCapLoop, LocalEndCapLoop, SideLoop, LocalStartCapFace, LocalEndCapFace, SideFace,
+ OuterBoundary, InnerBoundary, BodyShell, Body
+}
+
+public sealed record ProfileExtrusionPlanVertex(string StableId, VertexId Id, Point3D WorldPoint, ProfileExtrusionPlanRole Role, string SourceStableId);
+public sealed record ProfileExtrusionPlanCurve(string StableId, CurveGeometryId Id, CurveGeometry Geometry, ParameterInterval Trim, bool OrientedEdgeSense, string SourceStableId);
+public sealed record ProfileExtrusionPlanEdge(string StableId, EdgeId Id, VertexId StartVertexId, VertexId EndVertexId, CurveGeometryId CurveId, string SourceStableId, ProfileExtrusionPlanRole Role);
+public sealed record ProfileExtrusionPlanDirectedEdgeUse(string StableId, CoedgeId Id, EdgeId EdgeId, bool IsReversed, DirectedEdgeUse Traversal);
+public sealed record ProfileExtrusionPlanLoop(string StableId, LoopId Id, IReadOnlyList<ProfileExtrusionPlanDirectedEdgeUse> Uses, string SourceStableId, ProfileExtrusionPlanRole Role);
+public sealed record ProfileExtrusionPlanSurface(string StableId, SurfaceGeometryId Id, SurfaceGeometry Geometry, bool SameSense, string SourceStableId, ProfileExtrusionPlanRole Role);
+public sealed record ProfileExtrusionPlanFace(string StableId, FaceId Id, IReadOnlyList<LoopId> LoopIds, SurfaceGeometryId SurfaceId, bool SameSense, string SourceStableId, ProfileExtrusionPlanRole Role);
+public sealed record ProfileExtrusionPlanShell(string StableId, ShellId Id, IReadOnlyList<FaceId> FaceIds);
+public sealed record ProfileExtrusionPlanBody(string StableId, BodyId Id, IReadOnlyList<ShellId> ShellIds);
+
+/// <summary>
+/// Immutable exact topology authority for Profile extrusion. It is deliberately composed of reusable
+/// BRep primitives so local-frame Hole X2 can append its own curves, surfaces, loops and descendants
+/// without a second topology system.
+/// </summary>
+public sealed record ProfileExtrusionBRepPlan(
+ string StableId,
+ ProfileExtrusionConstructionAir Construction,
+ IReadOnlyList<ProfileExtrusionPlanVertex> Vertices,
+ IReadOnlyList<ProfileExtrusionPlanCurve> Curves,
+ IReadOnlyList<ProfileExtrusionPlanEdge> Edges,
+ IReadOnlyList<ProfileExtrusionPlanLoop> Loops,
+ IReadOnlyList<ProfileExtrusionPlanSurface> Surfaces,
+ IReadOnlyList<ProfileExtrusionPlanFace> Faces,
+ ProfileExtrusionPlanShell Shell,
+ ProfileExtrusionPlanBody Body,
+ SemanticTopologyCorrespondence Correspondence,
+ IReadOnlyList<string> Provenance,
+ IReadOnlyList<string> Diagnostics)
+{
+ public bool IsAuthoritative => true;
+ public int CoedgeCount => Loops.Sum(x => x.Uses.Count);
+}
+
+public sealed record ProfileExtrusionPlanResult(bool Succeeded, ProfileExtrusionBRepPlan? Plan, IReadOnlyList<string> Diagnostics);
+public sealed record ProfileExtrusionMaterializationResult(bool Succeeded, BrepBody? Body, IReadOnlyList<string> Diagnostics);
+
+public static class ProfileExtrusionBRepPlanner
+{
+ private const double Tol = 1e-6;
+
+ public static ProfileExtrusionPlanResult TryPlan(LineArcProfileExtrudeRequest request, ResolvedProfile2D? sourceProfile = null)
+ {
+ var diagnostics = new List<string> { "ProfileExtrusionConstructionAir", "ProfileExtrusionBRepPlan" };
+ if (!Validate(request, diagnostics)) return new(false, null, diagnostics);
+ var frame = request.ConstructionPlane ?? ConstructionPlane.WorldXY;
+ var start = request.LocalStartDepth ?? -request.Height / 2d;
+ var end = request.LocalEndDepth ?? request.Height / 2d;
+ var sourceId = sourceProfile?.Name ?? "request:profile";
+ var air = new ProfileExtrusionConstructionAir(
+ $"air:profile-extrusion:{sourceId}:{frame.StableId}", sourceId, frame, start, end, request.Loops,
+ ["Profile", "ConstructionPlane:" + frame.StableId, "local-coordinate-construction"]);
+
+ var vertices = new List<ProfileExtrusionPlanVertex>(); var curves = new List<ProfileExtrusionPlanCurve>();
+ var edges = new List<ProfileExtrusionPlanEdge>(); var loops = new List<ProfileExtrusionPlanLoop>();
+ var surfaces = new List<ProfileExtrusionPlanSurface>(); var faces = new List<ProfileExtrusionPlanFace>();
+ var descendants = new List<SemanticTopologyDescendant>();
+ var vertexByPoint = new Dictionary<(long X, long Y, bool End), ProfileExtrusionPlanVertex>();
+ var verticalByPoint = new Dictionary<(long X, long Y), ProfileExtrusionPlanEdge>();
+ var nextVertex = 1; var nextCurve = 1; var nextEdge = 1; var nextCoedge = 1; var nextLoop = 1; var nextSurface = 1; var nextFace = 1;
+ (long X, long Y) Key((double X, double Y) p) => ((long)Math.Round(p.X / Tol), (long)Math.Round(p.Y / Tol));
+ string LoopSource(int li) => sourceProfile is null ? $"profile:{sourceId}.Loop{li}" : $"profile:{sourceProfile.Name}.{sourceProfile.Loops[li].Name}";
+ string SegmentSource(int li, int si) => sourceProfile?.Loops[li].Segments[si].Provenance.StableId ?? $"{LoopSource(li)}.Segment{si}";
+
+ ProfileExtrusionPlanVertex Vertex((double X, double Y) point, bool isEnd, string source)
+ {
+ var key = (Key(point).X, Key(point).Y, isEnd);
+ if (vertexByPoint.TryGetValue(key, out var existing)) return existing;
+ var role = isEnd ? ProfileExtrusionPlanRole.LocalEndVertex : ProfileExtrusionPlanRole.LocalStartVertex;
+ var created = new ProfileExtrusionPlanVertex($"plan:{source}:vertex:{(isEnd ? "local-end" : "local-start")}", new VertexId(nextVertex++), frame.ToWorld(point, isEnd ? end : start), role, source);
+ vertices.Add(created); vertexByPoint.Add(key, created); return created;
+ }
+ ProfileExtrusionPlanCurve Curve(string stable, CurveGeometry geometry, ParameterInterval trim, string source, bool orientedEdgeSense = true)
+ { var created = new ProfileExtrusionPlanCurve(stable, new CurveGeometryId(nextCurve++), geometry, trim, orientedEdgeSense, source); curves.Add(created); return created; }
+ ProfileExtrusionPlanEdge Edge(string stable, ProfileExtrusionPlanVertex a, ProfileExtrusionPlanVertex b, ProfileExtrusionPlanCurve curve, string source, ProfileExtrusionPlanRole role)
+ { var created = new ProfileExtrusionPlanEdge(stable, new EdgeId(nextEdge++), a.Id, b.Id, curve.Id, source, role); edges.Add(created); return created; }
+ ProfileExtrusionPlanEdge Vertical((double X, double Y) point, ProfileExtrusionPlanVertex a, ProfileExtrusionPlanVertex b, string source)
+ {
+ var key = Key(point); if (verticalByPoint.TryGetValue(key, out var existing)) return existing;
+ var curve = Curve($"plan:{source}:curve:longitudinal", CurveGeometry.FromLine(new Line3Curve(a.WorldPoint, Direction3D.Create(b.WorldPoint - a.WorldPoint))), new(0, Math.Abs(end - start)), source);
+ var created = Edge($"plan:{source}:edge:longitudinal", a, b, curve, source, ProfileExtrusionPlanRole.LongitudinalBoundary); verticalByPoint.Add(key, created); return created;
+ }
+ ProfileExtrusionPlanLoop Loop(string stable, IReadOnlyList<(ProfileExtrusionPlanEdge Edge, bool Reverse)> uses, string source, ProfileExtrusionPlanRole role)
+ {
+ var material = uses.Select((u, index) => new ProfileExtrusionPlanDirectedEdgeUse(
+ $"{stable}:use:{index}", new CoedgeId(nextCoedge++), u.Edge.Id, u.Reverse,
+ DirectedEdgeUse.Resolve(new Edge(u.Edge.Id, u.Edge.StartVertexId, u.Edge.EndVertexId), u.Reverse))).ToArray();
+ var loop = new ProfileExtrusionPlanLoop(stable, new LoopId(nextLoop++), material, source, role); loops.Add(loop); return loop;
+ }
+
+ var startCapLoops = new List<ProfileExtrusionPlanLoop>(); var endCapLoops = new List<ProfileExtrusionPlanLoop>();
+ var sideSpecs = new List<(ProfileExtrusionPlanLoop Loop, SurfaceGeometry Surface, string SegmentSource, string LoopSource, ProfileExtrusionPlanEdge StartCap, ProfileExtrusionPlanEdge EndCap, ProfileExtrusionPlanEdge StartLongitudinal, ProfileExtrusionPlanEdge EndLongitudinal, bool IsHole)>();
+ for (var li = 0; li < request.Loops.Count; li++)
+ {
+ var loop = request.Loops[li]; var startUses = new List<(ProfileExtrusionPlanEdge, bool)>(); var endUses = new List<(ProfileExtrusionPlanEdge, bool)>();
+ for (var si = 0; si < loop.Curves.Count; si++)
+ {
+ var curve = loop.Curves[si]; var segmentSource = SegmentSource(li, si); var prefix = $"plan:{segmentSource}";
+ ProfileExtrusionPlanVertex sv0; ProfileExtrusionPlanVertex sv1; ProfileExtrusionPlanVertex ev0; ProfileExtrusionPlanVertex ev1;
+ ProfileExtrusionPlanEdge startEdge; ProfileExtrusionPlanEdge endEdge; ProfileExtrusionPlanEdge startLongitudinal; ProfileExtrusionPlanEdge endLongitudinal; SurfaceGeometry sideSurface;
+ switch (curve)
+ {
+ case LineArcLineSegment2D line:
+ {
+ sv0 = Vertex(line.Start, false, segmentSource); sv1 = Vertex(line.End, false, segmentSource); ev0 = Vertex(line.Start, true, segmentSource); ev1 = Vertex(line.End, true, segmentSource);
+ startEdge = Edge(prefix + ":edge:local-start", sv0, sv1, Curve(prefix + ":curve:local-start", CurveGeometry.FromLine(new Line3Curve(sv0.WorldPoint, Direction3D.Create(sv1.WorldPoint - sv0.WorldPoint))), new(0, (sv1.WorldPoint - sv0.WorldPoint).Length), segmentSource), segmentSource, ProfileExtrusionPlanRole.LocalStartBoundary);
+ endEdge = Edge(prefix + ":edge:local-end", ev0, ev1, Curve(prefix + ":curve:local-end", CurveGeometry.FromLine(new Line3Curve(ev0.WorldPoint, Direction3D.Create(ev1.WorldPoint - ev0.WorldPoint))), new(0, (ev1.WorldPoint - ev0.WorldPoint).Length), segmentSource), segmentSource, ProfileExtrusionPlanRole.LocalEndBoundary);
+ startLongitudinal = Vertical(line.Start, sv0, ev0, segmentSource); endLongitudinal = Vertical(line.End, sv1, ev1, segmentSource);
+ var dx = line.End.X - line.Start.X; var dy = line.End.Y - line.Start.Y; var nx = loop.IsHole ? -dy : dy; var ny = loop.IsHole ? dx : -dx;
+ sideSurface = SurfaceGeometry.FromPlane(new PlaneSurface(frame.ToWorld(line.Start, start), Direction3D.Create(frame.ToWorldDirection(new Vector3D(nx, ny, 0))), frame.AxisZ));
+ break;
+ }
+ case LineArcCircularArc2D arc:
+ {
+ var s = (arc.Center.X + arc.Radius * Math.Cos(arc.StartAngleRadians), arc.Center.Y + arc.Radius * Math.Sin(arc.StartAngleRadians)); var e = (arc.Center.X + arc.Radius * Math.Cos(arc.StartAngleRadians + arc.SweepAngleRadians), arc.Center.Y + arc.Radius * Math.Sin(arc.StartAngleRadians + arc.SweepAngleRadians));
+ sv0 = Vertex(s, false, segmentSource); sv1 = Vertex(e, false, segmentSource); ev0 = Vertex(s, true, segmentSource); ev1 = Vertex(e, true, segmentSource);
+ var rawEnd = arc.StartAngleRadians + arc.SweepAngleRadians; var trim = new ParameterInterval(Math.Min(arc.StartAngleRadians, rawEnd), Math.Max(arc.StartAngleRadians, rawEnd)); var oriented = arc.SweepAngleRadians > 0d;
+ startEdge = Edge(prefix + ":edge:local-start", sv0, sv1, Curve(prefix + ":curve:local-start", CurveGeometry.FromCircle(new Circle3Curve(frame.ToWorld(arc.Center, start), frame.AxisZ, arc.Radius, frame.AxisX)), trim, segmentSource, oriented), segmentSource, ProfileExtrusionPlanRole.LocalStartBoundary);
+ endEdge = Edge(prefix + ":edge:local-end", ev0, ev1, Curve(prefix + ":curve:local-end", CurveGeometry.FromCircle(new Circle3Curve(frame.ToWorld(arc.Center, end), frame.AxisZ, arc.Radius, frame.AxisX)), trim, segmentSource, oriented), segmentSource, ProfileExtrusionPlanRole.LocalEndBoundary);
+ startLongitudinal = Vertical(s, sv0, ev0, segmentSource); endLongitudinal = Vertical(e, sv1, ev1, segmentSource);
+ sideSurface = SurfaceGeometry.FromCylinder(new CylinderSurface(frame.ToWorld(arc.Center, start), frame.AxisZ, arc.Radius, frame.AxisX));
+ break;
+ }
+ case LineArcFullCircle2D circle:
+ {
+ sv0 = Vertex(circle.Center, false, segmentSource); sv1 = sv0; ev0 = Vertex(circle.Center, true, segmentSource); ev1 = ev0;
+ var trim = new ParameterInterval(0, 2 * Math.PI);
+ startEdge = Edge(prefix + ":edge:local-start", sv0, sv0, Curve(prefix + ":curve:local-start", CurveGeometry.FromCircle(new Circle3Curve(sv0.WorldPoint, frame.AxisZ, circle.Radius, frame.AxisX)), trim, segmentSource), segmentSource, ProfileExtrusionPlanRole.LocalStartBoundary);
+ endEdge = Edge(prefix + ":edge:local-end", ev0, ev0, Curve(prefix + ":curve:local-end", CurveGeometry.FromCircle(new Circle3Curve(ev0.WorldPoint, frame.AxisZ, circle.Radius, frame.AxisX)), trim, segmentSource), segmentSource, ProfileExtrusionPlanRole.LocalEndBoundary);
+ startLongitudinal = Vertical(circle.Center, sv0, ev0, segmentSource); endLongitudinal = startLongitudinal;
+ sideSurface = SurfaceGeometry.FromCylinder(new CylinderSurface(sv0.WorldPoint, frame.AxisZ, circle.Radius, frame.AxisX));
+ break;
+ }
+ default: throw new InvalidOperationException("ProfileExtrusionUnsupportedCurve");
+ }
+ // Loop winding is authored in local Profile coordinates (outer CCW, inner CW).
+ // Preserve it here; cap-face orientation is carried by the planned cap plane, not by
+ // reversing individual coedges and breaking directed closure.
+ startUses.Add((startEdge, false)); endUses.Add((endEdge, false));
+ var sideLoop = Loop(prefix + ":loop:side", [(startEdge, false), (endLongitudinal, false), (endEdge, true), (startLongitudinal, true)], segmentSource, ProfileExtrusionPlanRole.SideLoop);
+ sideSpecs.Add((sideLoop, sideSurface, segmentSource, LoopSource(li), startEdge, endEdge, startLongitudinal, endLongitudinal, loop.IsHole));
+ }
+ var loopSource = LoopSource(li); var roleStart = ProfileExtrusionPlanRole.LocalStartCapLoop; var roleEnd = ProfileExtrusionPlanRole.LocalEndCapLoop;
+ startCapLoops.Add(Loop($"plan:{loopSource}:loop:local-start", startUses, loopSource, roleStart)); endCapLoops.Add(Loop($"plan:{loopSource}:loop:local-end", endUses, loopSource, roleEnd));
+ }
+
+ var startSurface = new ProfileExtrusionPlanSurface("plan:cap:local-start:surface", new SurfaceGeometryId(nextSurface++), SurfaceGeometry.FromPlane(new PlaneSurface(frame.ToWorld((0, 0), start), Direction3D.Create(-frame.AxisZ.ToVector()), frame.AxisX)), true, sourceId, ProfileExtrusionPlanRole.LocalStartCapFace);
+ var endSurface = new ProfileExtrusionPlanSurface("plan:cap:local-end:surface", new SurfaceGeometryId(nextSurface++), SurfaceGeometry.FromPlane(new PlaneSurface(frame.ToWorld((0, 0), end), frame.AxisZ, frame.AxisX)), true, sourceId, ProfileExtrusionPlanRole.LocalEndCapFace);
+ surfaces.Add(startSurface); surfaces.Add(endSurface);
+ var startFace = new ProfileExtrusionPlanFace("plan:cap:local-start:face", new FaceId(nextFace++), startCapLoops.Select(x => x.Id).ToArray(), startSurface.Id, true, sourceId, ProfileExtrusionPlanRole.LocalStartCapFace);
+ var endFace = new ProfileExtrusionPlanFace("plan:cap:local-end:face", new FaceId(nextFace++), endCapLoops.Select(x => x.Id).ToArray(), endSurface.Id, true, sourceId, ProfileExtrusionPlanRole.LocalEndCapFace);
+ faces.Add(startFace); faces.Add(endFace);
+ foreach (var (sideLoop, surface, segmentSource, loopSource, startEdge, endEdge, startLongitudinal, endLongitudinal, isHole) in sideSpecs)
+ {
+ var plannedSurface = new ProfileExtrusionPlanSurface($"plan:{segmentSource}:surface:side", new SurfaceGeometryId(nextSurface++), surface, true, segmentSource, ProfileExtrusionPlanRole.SideFace); surfaces.Add(plannedSurface);
+ var sideFace = new ProfileExtrusionPlanFace($"plan:{segmentSource}:face:side", new FaceId(nextFace++), [sideLoop.Id], plannedSurface.Id, true, segmentSource, ProfileExtrusionPlanRole.SideFace); faces.Add(sideFace);
+ if (sourceProfile is not null)
+ {
+ var prefix = $"material:{sourceProfile.Name}:{segmentSource}";
+ descendants.Add(new(prefix + ":local-start", "Edge", SemanticTopologyRole.LocalStartBoundary, segmentSource, Edge: startEdge.Id, ParentStableId: segmentSource));
+ descendants.Add(new(prefix + ":local-end", "Edge", SemanticTopologyRole.LocalEndBoundary, segmentSource, Edge: endEdge.Id, ParentStableId: segmentSource));
+ descendants.Add(new(prefix + ":bottom", "Edge", SemanticTopologyRole.BottomBoundary, segmentSource, Edge: startEdge.Id, ParentStableId: segmentSource));
+ descendants.Add(new(prefix + ":top", "Edge", SemanticTopologyRole.TopBoundary, segmentSource, Edge: endEdge.Id, ParentStableId: segmentSource));
+ descendants.Add(new(prefix + ":vertical-start", "Edge", SemanticTopologyRole.VerticalExtrusionEdge, segmentSource, Edge: startLongitudinal.Id, ParentStableId: segmentSource));
+ descendants.Add(new(prefix + ":vertical-end", "Edge", SemanticTopologyRole.VerticalExtrusionEdge, segmentSource, Edge: endLongitudinal.Id, ParentStableId: segmentSource));
+ descendants.Add(new(prefix + ":side", "Face", isHole && surface.Kind == SurfaceGeometryKind.Cylinder ? SemanticTopologyRole.HoleWallFace : SemanticTopologyRole.ExtrusionSideFace, segmentSource, Face: sideFace.Id, ParentStableId: segmentSource));
+ if (isHole && surface.Kind == SurfaceGeometryKind.Cylinder)
+ descendants.Add(new($"material:{sourceProfile.Name}:{loopSource}:cylindrical-wall:{sideFace.Id.Value}", "Face", SemanticTopologyRole.HoleWallFace, loopSource, Face: sideFace.Id, ParentStableId: loopSource));
+ }
+ }
+ if (sourceProfile is not null)
+ for (var li = 0; li < sourceProfile.Loops.Count; li++)
+ {
+ var loopSource = LoopSource(li); var prefix = $"material:{sourceProfile.Name}:{loopSource}";
+ descendants.Add(new(prefix + ":local-start-loop", "Loop", SemanticTopologyRole.LocalStartCapLoop, loopSource, Loop: startCapLoops[li].Id, ParentStableId: loopSource));
+ descendants.Add(new(prefix + ":local-end-loop", "Loop", SemanticTopologyRole.LocalEndCapLoop, loopSource, Loop: endCapLoops[li].Id, ParentStableId: loopSource));
+ descendants.Add(new(prefix + ":bottom-loop", "Loop", SemanticTopologyRole.BottomFaceBoundaryLoop, loopSource, Loop: startCapLoops[li].Id, ParentStableId: loopSource));
+ descendants.Add(new(prefix + ":top-loop", "Loop", SemanticTopologyRole.TopFaceBoundaryLoop, loopSource, Loop: endCapLoops[li].Id, ParentStableId: loopSource));
+ }
+ var shell = new ProfileExtrusionPlanShell("plan:shell:0", new ShellId(1), faces.Select(x => x.Id).ToArray()); var body = new ProfileExtrusionPlanBody("plan:body:0", new BodyId(1), [shell.Id]);
+ var correspondence = new SemanticTopologyCorrespondence(sourceId, descendants, ["ConceptPlane:" + frame.SourceConceptId, "ConstructionPlane:" + frame.StableId, "Profile", "ResolvedProfile2D", "ProfileExtrusionConstructionAir", "ProfileExtrusionBRepPlan", "AuthoritativeBRepPlan"]);
+ diagnostics.AddRange(["ProfileExtrusionPlanAuthoritative", "ProfileExtrusionTopologyPlanned", "v2-v4-no-3d-boolean-used"]);
+ return new(true, new ProfileExtrusionBRepPlan($"brep-plan:profile-extrusion:{sourceId}:{frame.StableId}", air, vertices, curves, edges, loops, surfaces, faces, shell, body, correspondence, correspondence.ProvenanceChain, diagnostics), diagnostics);
+ }
+
+ private static bool Validate(LineArcProfileExtrudeRequest req, List<string> d)
+ {
+ var start = req.LocalStartDepth ?? -req.Height / 2d; var end = req.LocalEndDepth ?? req.Height / 2d;
+ if (!double.IsFinite(req.Height) || req.Height <= Tol) { d.Add("ProfileExtrusionPlanInvalid: invalid height"); return false; }
+ if (!double.IsFinite(start) || !double.IsFinite(end) || end - start <= Tol) { d.Add("ProfileExtrusionPlanInvalid: local depth interval"); return false; }
+ if (req.Loops.Count == 0 || req.Loops.Count(l => !l.IsHole) != 1) { d.Add("ProfileExtrusionPlanInvalid: exactly one outer loop"); return false; }
+ var frame = req.ConstructionPlane ?? ConstructionPlane.WorldXY;
+ if (Math.Abs(frame.Determinant - 1d) > 1e-10) { d.Add("ProfileExtrusionFrameInvalid: construction plane must be right handed"); return false; }
+ foreach (var loop in req.Loops)
+ {
+ if (loop.Curves.Count == 0) { d.Add("ProfileExtrusionLoopOpen: empty loop"); return false; }
+ foreach (var curve in loop.Curves)
+ switch (curve)
+ {
+ case LineArcLineSegment2D line when Distance(line.Start, line.End) <= Tol: d.Add("ProfileExtrusionPlanInvalid: zero length line"); return false;
+ case LineArcCircularArc2D arc when !double.IsFinite(arc.Radius) || arc.Radius <= Tol || Math.Abs(arc.SweepAngleRadians) <= Tol: d.Add("ProfileExtrusionUnsupportedCurve: invalid arc"); return false;
+ case LineArcFullCircle2D circle when !double.IsFinite(circle.Radius) || circle.Radius <= Tol: d.Add("ProfileExtrusionUnsupportedCurve: invalid circle"); return false;
+ case not (LineArcLineSegment2D or LineArcCircularArc2D or LineArcFullCircle2D): d.Add("ProfileExtrusionUnsupportedCurve"); return false;
+ }
+ }
+ return true;
+ }
+
+ private static double Distance((double X, double Y) a, (double X, double Y) b) => Math.Sqrt((a.X - b.X) * (a.X - b.X) + (a.Y - b.Y) * (a.Y - b.Y));
+}
+
+/// <summary>Strict plan consumer. It has no geometric matching, adjacency inference, or semantic planning branch.</summary>
+public static class ProfileExtrusionBRepMaterializer
+{
+ public static ProfileExtrusionMaterializationResult TryMaterialize(ProfileExtrusionBRepPlan plan)
+ {
+ var diagnostics = new List<string> { "ProfileExtrusionPlanMaterializationStarted" };
+ if (!Validate(plan, diagnostics)) return new(false, null, diagnostics);
+ try
+ {
+ var builder = new TopologyBuilder(); var points = new Dictionary<VertexId, Point3D>();
+ foreach (var v in plan.Vertices.OrderBy(x => x.Id.Value)) { var actual = builder.AddVertex(); if (actual != v.Id) return Diverged(); points.Add(v.Id, v.WorldPoint); }
+ foreach (var e in plan.Edges.OrderBy(x => x.Id.Value)) { var actual = builder.AddEdge(e.StartVertexId, e.EndVertexId); if (actual != e.Id) return Diverged(); }
+ foreach (var l in plan.Loops.OrderBy(x => x.Id.Value))
+ {
+ if (builder.AllocateLoopId() != l.Id) return Diverged();
+ var ids = l.Uses.OrderBy(x => x.Id.Value).Select(x => x.Id).ToArray();
+ for (var i = 0; i < l.Uses.Count; i++) { var use = l.Uses[i]; builder.AddCoedge(new Coedge(use.Id, use.EdgeId, l.Id, ids[(i + 1) % ids.Length], ids[(i + ids.Length - 1) % ids.Length], use.IsReversed)); }
+ builder.AddLoop(new Loop(l.Id, ids));
+ }
+ foreach (var f in plan.Faces.OrderBy(x => x.Id.Value)) { var actual = builder.AddFace(f.LoopIds); if (actual != f.Id) return Diverged(); }
+ if (builder.AddShell(plan.Shell.FaceIds) != plan.Shell.Id || builder.AddBody(plan.Body.ShellIds) != plan.Body.Id) return Diverged();
+ var geometry = new BrepGeometryStore(); var bindings = new BrepBindingModel();
+ foreach (var c in plan.Curves.OrderBy(x => x.Id.Value)) geometry.AddCurve(c.Id, c.Geometry);
+ foreach (var e in plan.Edges) { var curve = plan.Curves.Single(x => x.Id == e.CurveId); bindings.AddEdgeBinding(new EdgeGeometryBinding(e.Id, e.CurveId, curve.Trim, curve.OrientedEdgeSense)); }
+ foreach (var s in plan.Surfaces.OrderBy(x => x.Id.Value)) geometry.AddSurface(s.Id, s.Geometry);
+ foreach (var f in plan.Faces) bindings.AddFaceBinding(new FaceGeometryBinding(f.Id, f.SurfaceId, f.SameSense));
+ diagnostics.Add("ProfileExtrusionPlanMaterialized");
+ return new(true, new BrepBody(builder.Model, geometry, bindings, points), diagnostics);
+ }
+ catch (Exception ex) { diagnostics.Add("ProfileExtrusionMaterializerDiverged: " + ex.Message); return new(false, null, diagnostics); }
+
+ ProfileExtrusionMaterializationResult Diverged() { diagnostics.Add("ProfileExtrusionMaterializerDiverged: planned identity did not match materialized identity"); return new(false, null, diagnostics); }
+ }
+
+ private static bool Validate(ProfileExtrusionBRepPlan plan, List<string> d)
+ {
+ if (!plan.IsAuthoritative || plan.Vertices.Count == 0 || plan.Edges.Count == 0 || plan.Faces.Count < 3) { d.Add("ProfileExtrusionPlanInvalid: incomplete topology"); return false; }
+ foreach (var loop in plan.Loops)
+ {
+ if (loop.Uses.Count == 0) { d.Add("ProfileExtrusionLoopOpen: empty planned loop"); return false; }
+ for (var i = 0; i < loop.Uses.Count; i++)
+ {
+ var use = loop.Uses[i]; var next = loop.Uses[(i + 1) % loop.Uses.Count];
+ if (use.Traversal.EndVertexId != next.Traversal.StartVertexId) { d.Add($"ProfileExtrusionLoopOrientationInvalid: {loop.StableId}"); return false; }
+ }
+ }
+ if (plan.Faces.Any(f => !plan.Surfaces.Any(s => s.Id == f.SurfaceId))) { d.Add("ProfileExtrusionSurfaceBindingInvalid"); return false; }
+ return true;
+ }
+}
diff --git a/Aetheris.Kernel.Firmament/Materializer/ResolvedProfile2D.cs b/Aetheris.Kernel.Firmament/Materializer/ResolvedProfile2D.cs
index 6ef61a3f..d4d9960b 100644
--- a/Aetheris.Kernel.Firmament/Materializer/ResolvedProfile2D.cs
+++ b/Aetheris.Kernel.Firmament/Materializer/ResolvedProfile2D.cs
@@ -4,7 +4,7 @@ namespace Aetheris.Kernel.Firmament.Materializer;
public sealed record ProfileSegmentProvenance(string StableId, string ConceptStableId, string SourceSpan, string Derivation, string SourceFrame);
public sealed record ResolvedProfileSegment2D(string Name, LineArcProfileCurve2D Geometry, ProfileSegmentProvenance Provenance);
public sealed record ResolvedProfileLoop2D(string Name, bool IsOuter, IReadOnlyList<ResolvedProfileSegment2D> Segments);
-public sealed record ResolvedProfile2D(string Name, string PlaneFrame, IReadOnlyList<ResolvedProfileLoop2D> Loops, ConstructionPlane? ConstructionPlane = null)
+public sealed record ResolvedProfile2D(string Name, string PlaneFrame, IReadOnlyList<ResolvedProfileLoop2D> Loops, ConstructionPlane? ConstructionPlane = null, double? LocalStartDepth = null, double? LocalEndDepth = null)
{
public ConstructionPlane EffectiveConstructionPlane => ConstructionPlane ?? Materializer.ConstructionPlane.WorldXY;
}
@@ -16,24 +16,29 @@ public static class ResolvedProfile2DValidator
public static ResolvedProfileValidationResult Validate(ResolvedProfile2D profile)
{
var d = new List<string>();
- if (profile.Loops.Count != 1 || !profile.Loops[0].IsOuter) d.Add($"profile:{profile.Name}: exactly one declared outer loop is required");
- var loop = profile.Loops.SingleOrDefault();
- if (loop is null || loop.Segments.Count < 3) return new(false, 0, d.Append($"profile:{profile.Name}: outer loop requires at least three segments").ToArray());
+ if (profile.Loops.Count == 0 || profile.Loops.Count(x => x.IsOuter) != 1) d.Add($"profile:{profile.Name}: exactly one declared outer loop is required");
+ var outer = profile.Loops.SingleOrDefault(x => x.IsOuter);
+ if (outer is null) return new(false, 0, d.Append($"profile:{profile.Name}: outer loop is required").ToArray());
var names = new HashSet<string>(StringComparer.Ordinal);
- for (var i=0;i<loop.Segments.Count;i++)
+ foreach (var loop in profile.Loops)
{
- var s=loop.Segments[i]; if(!names.Add(s.Name))d.Add($"profile:{profile.Name}: duplicate segment '{s.Name}'");
- if(!Endpoints(s.Geometry,out var start,out var end)){d.Add($"profile:{profile.Name}: unsupported unbounded segment '{s.Name}'");continue;}
- if(Distance(start,end)<=Tol)d.Add($"profile:{profile.Name}: zero-length segment '{s.Name}'");
- var next=loop.Segments[(i+1)%loop.Segments.Count]; if(Endpoints(next.Geometry,out var ns,out _)&&Distance(end,ns)>Tol)d.Add($"profile:{profile.Name}: endpoint mismatch '{s.Name}' -> '{next.Name}'");
+ if (loop.Segments.Count == 0 || (loop.Segments.Count < 3 && !(loop.Segments.Count == 1 && loop.Segments[0].Geometry is LineArcFullCircle2D))) d.Add($"profile:{profile.Name}: loop '{loop.Name}' requires a closed boundary");
+ for (var i=0;i<loop.Segments.Count;i++)
+ {
+ var s=loop.Segments[i]; if(!names.Add(s.Name))d.Add($"profile:{profile.Name}: duplicate segment '{s.Name}'");
+ if (s.Geometry is LineArcFullCircle2D && loop.Segments.Count == 1) continue;
+ if(!Endpoints(s.Geometry,out var start,out var end)){d.Add($"profile:{profile.Name}: unsupported unbounded segment '{s.Name}'");continue;}
+ if(Distance(start,end)<=Tol)d.Add($"profile:{profile.Name}: zero-length segment '{s.Name}'");
+ var next=loop.Segments[(i+1)%loop.Segments.Count]; if(Endpoints(next.Geometry,out var ns,out _)&&Distance(end,ns)>Tol)d.Add($"profile:{profile.Name}: endpoint mismatch '{s.Name}' -> '{next.Name}'");
+ }
+ for (var i=0;i<loop.Segments.Count;i++) for (var j=i+1;j<loop.Segments.Count;j++)
+ {
+ var a=loop.Segments[i]; var b=loop.Segments[j];
+ if (SameLine(a.Geometry,b.Geometry)) d.Add($"profile:{profile.Name}: duplicate coincident segment '{a.Name}' / '{b.Name}'");
+ if (!Adjacent(i,j,loop.Segments.Count) && a.Geometry is LineArcLineSegment2D && b.Geometry is LineArcLineSegment2D && Endpoints(a.Geometry,out var as_,out var ae) && Endpoints(b.Geometry,out var bs,out var be) && ProperIntersection(as_,ae,bs,be)) d.Add($"profile:{profile.Name}: self-intersection '{a.Name}' / '{b.Name}'");
+ }
}
- for (var i=0;i<loop.Segments.Count;i++) for (var j=i+1;j<loop.Segments.Count;j++)
- {
- var a=loop.Segments[i]; var b=loop.Segments[j];
- if (SameLine(a.Geometry,b.Geometry)) d.Add($"profile:{profile.Name}: duplicate coincident segment '{a.Name}' / '{b.Name}'");
- if (!Adjacent(i,j,loop.Segments.Count) && a.Geometry is LineArcLineSegment2D && b.Geometry is LineArcLineSegment2D && Endpoints(a.Geometry,out var as_,out var ae) && Endpoints(b.Geometry,out var bs,out var be) && ProperIntersection(as_,ae,bs,be)) d.Add($"profile:{profile.Name}: self-intersection '{a.Name}' / '{b.Name}'");
- }
- var area=loop.Segments.Sum(s=>Endpoints(s.Geometry,out var a,out var b)?a.X*b.Y-b.X*a.Y:0)/2d;
+ var area=outer.Segments.Sum(s=>Endpoints(s.Geometry,out var a,out var b)?a.X*b.Y-b.X*a.Y:0)/2d;
if(area<=Tol)d.Add($"profile:{profile.Name}: outer winding must be CounterClockwise with nonzero area");
return new(d.Count==0,area,d);
}
diff --git a/docs/cadmata/concept-visualization-x1.md b/docs/cadmata/concept-visualization-x1.md
index 7b2b2d4a..7e694ed0 100644
--- a/docs/cadmata/concept-visualization-x1.md
+++ b/docs/cadmata/concept-visualization-x1.md
@@ -84,3 +84,7 @@ authoritative section stack. Selecting a Hole follows its compiler-published
entry/exit loops, boundary edges, and all slab-split wall faces. The next
visualization pressure case remains post-EdgeFinish replacement correspondence;
replacement faces must not be inferred heuristically.
+
+## Profile extrusion BRepPlan X1
+
+For ordinary Profile extrusion, Cadmata continues to receive the Concept plane, Construction Plane, local Profile, world BRep body, and semantic descendants. The new plan inspector can supply a debug-only source segment → planned entity → material descendant chain without duplicating a frontend topology model. Cadmata must reference plan correspondence rather than reconstruct roles from viewport geometry.
diff --git a/docs/firmament/concept-plane-drilled-holes-x1.md b/docs/firmament/concept-plane-drilled-holes-x1.md
index 57ad97cb..10da9e2e 100644
--- a/docs/firmament/concept-plane-drilled-holes-x1.md
+++ b/docs/firmament/concept-plane-drilled-holes-x1.md
@@ -99,3 +99,7 @@ it must not infer values from screenshots.
`dotnet build Aetheris.slnx -f net10.0 --no-restore /m:1` both succeeded on the
current worktree. The build reports pre-existing JavaScript dependency
vulnerability warnings from the JavaScript SDK audit; it has no .NET errors.
+
+## LOCAL-FRAME-HOLE-X2 extension point
+
+PROFILE-EXTRUSION-BREPPLAN-X1 supplies the required single topology authority for a future local-frame hole. A Hole should lower to local Construction AIR and append/reuse `ProfileExtrusionBRepPlan` primitives for mouth loops, shaft cylinders, optional cone/tip entities, and plan-owned semantic descendants. It reuses the immutable frame, local/world mapping, cap and cylinder orientations, directed loop closure, materializer, STEP emission, and Cadmata correspondence. Host subtraction and drill-point cones remain deliberately unimplemented here.
diff --git a/docs/firmament/construction-planes-x1.md b/docs/firmament/construction-planes-x1.md
index 481ceb39..a9db8b90 100644
--- a/docs/firmament/construction-planes-x1.md
+++ b/docs/firmament/construction-planes-x1.md
@@ -35,4 +35,8 @@ Semantic descendants now publish `LocalStartBoundary`, `LocalEndBoundary`, `Loca
`aetheris inspect-profile <file> --json` reports the compact construction-frame tuple near the Profile identity. Cadmata receives compiler-owned Concept-plane, Construction-plane, and world-mapped Profile entities; it does not infer a frame from BRep geometry.
+## Profile extrusion BRepPlan X1
+
+Construction Planes define local material coordinates. Authoritative BRepPlans carry those coordinates into exact topology. `ProfileExtrusionConstructionAir` normalizes a local Profile plus the immutable frame and local interval; `ProfileExtrusionBRepPlan` owns all vertices, supports, edges, directed uses, loops, faces, senses, shell/body, and source correspondence before any BRep is made. The default world-XY frame is the same route, not a parallel planner. `inspect-profile --json` includes that pre-materialization plan.
+
Current scope is a proper rigid frame and standalone/additive planar line/arc Profile extrusion. Reflections, scaling, shearing, arbitrary completed-plan transforms, mutable face attachment, generic constraints, and host-subtracted local-frame holes remain unsupported. LOCAL-FRAME-HOLE-X2 should consume `ConstructionPlane` directly for placement and add only the bounded host/subtraction contract; it must not add topology attachment or recompute the frame.
diff --git a/docs/firmament/semantic-selections-x1.md b/docs/firmament/semantic-selections-x1.md
index b912be56..c149d367 100644
--- a/docs/firmament/semantic-selections-x1.md
+++ b/docs/firmament/semantic-selections-x1.md
@@ -26,7 +26,7 @@ X1 admits direct, scaffold-authored Profile extrusion. `ProfileSegments` is sour
The immutable result forms are `VertexSet`, `EdgeSet`, `FaceSet`, `LoopSet`, and `Chain`. Every materialized descendant has a stable diagnostic id, source identity, topology role, parent/source relationship, and optional exact topology handle used internally by the materializer. Authoring never receives mutable BRep collections.
-The profile emitter records correspondence while it creates the authoritative body: profile segment to top/bottom boundary edge, vertical extrusion edges, and side face; profile loop to cap boundary loop. The resolver consumes only that correspondence plus the body planned by the emitter. It does not scan emitted STEP, inspect coordinates, or recognize radii.
+The Profile extrusion planner records correspondence before materialization: profile segment to local start/end boundary edge, longitudinal edge, and side face; profile loop to local start/end cap loop; circular inner wall to its cylinder face. The resolver consumes that plan-owned correspondence plus the materialized body. It does not scan emitted STEP, inspect coordinates, or recognize radii.
`ExactlyOne`, `OneOrMore`, `ConnectedChain`, `ClosedLoop`, and `NonEmptyFaceSet` are explicit contracts. Chain/loop validation uses `DirectedEdgeUse`: duplicate edges, disconnected components, branch vertices, missing closure, and a closed result requested as an open chain fail deterministically.
diff --git a/docs/kernel/profile-extrusion-brepplan-x1.md b/docs/kernel/profile-extrusion-brepplan-x1.md
new file mode 100644
index 00000000..d8c9bdb9
--- /dev/null
+++ b/docs/kernel/profile-extrusion-brepplan-x1.md
@@ -0,0 +1,13 @@
+# PROFILE-EXTRUSION-BREPPLAN-X1
+
+`ProfileExtrusionBRepPlan` is the authoritative topology boundary for standalone line/arc Profile extrusion. **The BRepPlan owns topology. Emitters materialize plans; they do not invent construction.**
+
+The production route is resolved local `Profile` plus a `ConstructionPlane` (or immutable `WorldXY`) and local start/end depths, then `ProfileExtrusionConstructionAir`, then `ProfileExtrusionBRepPlan`, then `ProfileExtrusionBRepMaterializer`, BRep, and AP242. The plan is inspectable with `aetheris inspect-profile <source> --json` before materialization.
+
+The plan contains typed vertices, curves with exact trim and edge sense, edges, explicit `DirectedEdgeUse` coedges, cap/side loops, exact plane/cylinder surfaces, face `SameSense`, shell/body, frame and depth interval, deterministic plan IDs, and correspondence. IDs are derived from resolved Profile/loop/segment provenance plus local role; numeric kernel IDs are deterministic plan-order realization IDs, never random GUIDs.
+
+`LineArcProfileExtrudeEmitter` is retained only as the compatibility entry point. It calls the planner and then the strict materializer. The materializer validates planned directed closure and bindings, allocates the plan identities in plan order, binds supplied exact geometry, and publishes no independently-created correspondence.
+
+Local start/end are canonical roles. Legacy top/bottom names are compatibility aliases for local +Z/-Z only. Cap planes use -/+ local Z, line sides use the frame-mapped profile-facing normal, and arc sides use a cylinder whose axis is local Z and reference direction is local X. Inner loops retain authored local winding and yield cap inner loops and cylindrical wall faces; no coordinate search is used.
+
+The reusable extension seam for LOCAL-FRAME-HOLE-X2 is the plan primitive set: add planned vertices/curves/surfaces/loops/faces and plan-owned descendants to `ProfileExtrusionBRepPlan` (or its successor generic construction-plan container), then consume it with `ProfileExtrusionBRepMaterializer`. A hole can reuse the frame mapping, cap conventions, cylinder binding, `DirectedEdgeUse`, correspondence publication, STEP path, and Cadmata source-to-descendant handoff. Drill cones and host subtraction are intentionally not part of X1.