Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Add traced construction plane support to profile extrusion
Yuechen Li882d23602f21
diff --git a/Aetheris.CLI/CliRunner.cs b/Aetheris.CLI/CliRunner.csindex ab5538bd..8ca96ccd 100644--- a/Aetheris.CLI/CliRunner.cs+++ b/Aetheris.CLI/CliRunner.cs@@ -443,6 +443,7 @@ public static class CliRunnerprofile = new{parsed.Profile.Name, parsed.Profile.PlaneFrame,+ constructionPlane = DescribeConstructionPlane(parsed.Profile.EffectiveConstructionPlane),loops = parsed.Profile.Loops.Count,segments = parsed.Profile.Loops.SelectMany(x => x.Segments).Select(x =>{@@ -457,6 +458,16 @@ public static class CliRunnerreturn validation.IsValid ? 0 : 1;}+ private static object DescribeConstructionPlane(ConstructionPlane plane) => new+ {+ plane.StableId, plane.SourceConceptId,+ origin = new[] { plane.Origin.X, plane.Origin.Y, plane.Origin.Z },+ axisX = new[] { plane.AxisX.ToVector().X, plane.AxisX.ToVector().Y, plane.AxisX.ToVector().Z },+ axisY = new[] { plane.AxisY.ToVector().X, plane.AxisY.ToVector().Y, plane.AxisY.ToVector().Z },+ axisZ = new[] { plane.AxisZ.ToVector().X, plane.AxisZ.ToVector().Y, plane.AxisZ.ToVector().Z },+ plane.Handedness, plane.Determinant, plane.SourceSpan, plane.Provenance+ };+private static (string Name, string Kind, string? Parent) DescribeProfileGuide(string stableId){const string prefix = "concept:";diff --git a/Aetheris.Kernel.Firmament.Tests/Integration/ConstructionPlaneExtrudeTests.cs b/Aetheris.Kernel.Firmament.Tests/Integration/ConstructionPlaneExtrudeTests.csnew file mode 100644index 00000000..0cfb761d--- /dev/null+++ b/Aetheris.Kernel.Firmament.Tests/Integration/ConstructionPlaneExtrudeTests.cs@@ -0,0 +1,111 @@+using Aetheris.Kernel.Core.Geometry;+using Aetheris.Kernel.Core.Brep.Verification;+using Aetheris.Kernel.Core.Step242;+using Aetheris.Kernel.Firmament.FirmamentV2;+using Aetheris.Kernel.Firmament.Materializer;++namespace Aetheris.Kernel.Firmament.Tests.Integration;++public sealed class ConstructionPlaneExtrudeTests+{+ [Fact]+ public void TracedPositiveXPlane_MapsLocalProfileAndEmitsExactWorldXCaps()+ {+ var plane = Trace("side", new(10, 2, 3), new(1, 0, 0), new(0, 0, 1));+ Assert.Equal(1d, plane.Determinant, 12);+ Assert.Equal((10d, 4d, 6d), Tuple(plane.ToWorld((2, 3))));+ Assert.Equal((2d, 3d, 0d), plane.ToLocal(plane.ToWorld((2, 3))));++ var result = LineArcProfileExtrudeEmitter.TryEmit(new LineArcProfileExtrudeRequest([Rectangle()], 4, plane));+ var body = Assert.IsType<Aetheris.Kernel.Core.Brep.BrepBody>(result.Body);+ var capNormals = body.Geometry.Surfaces.Select(x => x.Value).Where(x => x.Kind == SurfaceGeometryKind.Plane).Take(2).Select(x => x.Plane!.Value.Normal.ToVector()).ToArray();+ Assert.Contains(capNormals, n => Math.Abs(n.X - 1) < 1e-10);+ Assert.Contains(capNormals, n => Math.Abs(n.X + 1) < 1e-10);+ Assert.All(Points(body), point => Assert.InRange(point.X, 8d, 12d));+ var step = Step242Exporter.ExportBody(body);+ Assert.True(step.IsSuccess);+ Assert.Contains("AXIS2_PLACEMENT_3D", step.Value!);+ Assert.True(Step242Importer.ImportBody(step.Value!).IsSuccess);+ }++ [Fact]+ public void ArbitraryProperPlane_PreservesCircularRadiusAndAxis()+ {+ // Normal (0, 3/5, 4/5) and an X hint make a well-conditioned deterministic proper frame.+ var plane = Trace("rotated", new(7, -2, 11), new(0, .6, .8), new(1, 0, 0));+ var loop = new LineArcProfileLoop2D([+ new LineArcLineSegment2D((-3, 2), (3, 2)),+ new LineArcCircularArc2D((3, 0), 2, Math.PI / 2, -Math.PI),+ new LineArcLineSegment2D((3, -2), (-3, -2)),+ new LineArcCircularArc2D((-3, 0), 2, -Math.PI / 2, -Math.PI)], false);+ var result = LineArcProfileExtrudeEmitter.TryEmit(new LineArcProfileExtrudeRequest([loop], 5, plane));+ var body = Assert.IsType<Aetheris.Kernel.Core.Brep.BrepBody>(result.Body);+ var cylinders = body.Geometry.Surfaces.Select(x => x.Value.Cylinder).Where(x => x is not null).Select(x => x!.Value).ToArray();+ Assert.Equal(2, cylinders.Length);+ Assert.All(cylinders, cylinder =>+ {+ Assert.Equal(2d, cylinder.Radius, 12);+ Assert.Equal(1d, cylinder.Axis.ToVector().Dot(plane.AxisZ.ToVector()), 12);+ });+ Assert.All(Points(body), point => { var local = plane.ToLocal(point); Assert.Equal(point, plane.ToWorld((local.X, local.Y), local.Z), new Point3Comparer()); });+ }++ [Fact]+ public void ProfileUsingConstructionPlane_ParsesTraceAndRetainsProvenance()+ {+ const string source = """+ Concept Struct SideLayout {+ Datum: Plane { Origin: [10mm, 2mm, 3mm]; Normal: [1, 0, 0]; Up: [0, 0, 1] }+ }+ Construction Plane PositiveXWorkplane { Trace: SideLayout.Datum }+ Profile SideProfile Using PositiveXWorkplane {+ Rect2 Outline { Center: [0mm, 0mm]; Size: [4mm, 2mm] }+ Segment Bottom { Trace: Outline.Bottom; From: Outline.BottomLeft; To: Outline.BottomRight }+ Segment Right { Trace: Outline.Right; From: Outline.BottomRight; To: Outline.TopRight }+ Segment Top { Trace: Outline.Top; From: Outline.TopRight; To: Outline.TopLeft }+ Segment Left { Trace: Outline.Left; From: Outline.TopLeft; To: Outline.BottomLeft }+ }+ Extrude Solid { Profile: SideProfile; From: -2mm; To: 2mm }+ """;+ var parsed = ProfileAuthoringParser.Parse(source);+ var profile = Assert.IsType<ResolvedProfile2D>(parsed.Profile);+ Assert.Equal("construction:PositiveXWorkplane", profile.EffectiveConstructionPlane.StableId);+ var emitted = ResolvedProfile2DValidator.Extrude(profile, parsed.Height);+ Assert.Contains(emitted.Correspondence!.ProvenanceChain, x => x.StartsWith("ConceptPlane:", StringComparison.Ordinal));+ Assert.Contains(emitted.Correspondence.Descendants, x => x.Role == SemanticTopologyRole.LocalEndBoundary);+ }++ [Fact]+ public void M8_EquivalentFramesPreserveMassAndMapCentroid()+ {+ var frames = new[]+ {+ ConstructionPlane.WorldXY,+ Trace("x", new(10, 2, 3), new(1, 0, 0), new(0, 0, 1)),+ Trace("r", new(7, -2, 11), new(0, .6, .8), new(1, 0, 0)),+ };+ var results = frames.Select(frame => BrepMassProperties.Evaluate(Assert.IsType<Aetheris.Kernel.Core.Brep.BrepBody>(LineArcProfileExtrudeEmitter.TryEmit(new LineArcProfileExtrudeRequest([Rectangle()], 4, frame)).Body))).ToArray();+ Assert.All(results, mass => { Assert.NotEqual(BrepMassPropertiesStatus.Unavailable, mass.Status); Assert.True(mass.IsEnclosed); Assert.True(mass.IsOrientationConsistent); });+ Assert.All(results.Skip(1), mass => { Assert.Equal(results[0].AbsoluteVolume, mass.AbsoluteVolume, 6); Assert.Equal(results[0].SurfaceArea, mass.SurfaceArea, 6); });+ for (var i = 0; i < frames.Length; i++)+ {+ Assert.True(results[i].Centroid.HasValue);+ var centroid = results[i].Centroid!.Value;+ Assert.Equal(frames[i].Origin.X, centroid.X, 6); Assert.Equal(frames[i].Origin.Y, centroid.Y, 6); Assert.Equal(frames[i].Origin.Z, centroid.Z, 6);+ }+ }++ 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);+ return plane!;+ }++ private static LineArcProfileLoop2D Rectangle() => new([+ new LineArcLineSegment2D((-2, -1), (2, -1)), new LineArcLineSegment2D((2, -1), (2, 1)),+ new LineArcLineSegment2D((2, 1), (-2, 1)), new LineArcLineSegment2D((-2, 1), (-2, -1))], false);+ private static (double, double, double) Tuple(Aetheris.Kernel.Core.Math.Point3D p) => (p.X, p.Y, p.Z);+ private static IReadOnlyList<Aetheris.Kernel.Core.Math.Point3D> Points(Aetheris.Kernel.Core.Brep.BrepBody body) => body.Topology.Vertices.Select(vertex => { Assert.True(body.TryGetVertexPoint(vertex.Id, out var point)); return point; }).ToArray();+ private sealed class Point3Comparer : IEqualityComparer<Aetheris.Kernel.Core.Math.Point3D>+ { public bool Equals(Aetheris.Kernel.Core.Math.Point3D x, Aetheris.Kernel.Core.Math.Point3D y) => Math.Abs(x.X-y.X)<1e-10 && Math.Abs(x.Y-y.Y)<1e-10 && Math.Abs(x.Z-y.Z)<1e-10; public int GetHashCode(Aetheris.Kernel.Core.Math.Point3D obj) => 0; }+}diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/ConceptIr.cs b/Aetheris.Kernel.Firmament/FirmamentV2/ConceptIr.csindex f6c8ccff..8fbdb3ab 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/ConceptIr.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/ConceptIr.cs@@ -52,7 +52,7 @@ public sealed record ConceptIrBox3Value(string StableId, ConceptIrPoint3 Min, Copublic IReadOnlyList<double> Size => [Max.X - Min.X, Max.Y - Min.Y, Max.Z - Min.Z];public ConceptIrPoint3 Center => new((Min.X + Max.X) / 2d, (Min.Y + Max.Y) / 2d, (Min.Z + Max.Z) / 2d);}-public sealed record ConceptIrPlaneValue(string StableId, ConceptIrPoint3 Origin, ConceptIrVector3 Normal, string Provenance)+public sealed record ConceptIrPlaneValue(string StableId, ConceptIrPoint3 Origin, ConceptIrVector3 Normal, string Provenance, ConceptIrVector3? OrientationHint = null): ConceptIrValue(StableId, ConceptIrValueKind.Plane, Provenance);public sealed record ConceptIrAxisValue(string StableId, ConceptIrPoint3 Origin, ConceptIrVector3 Direction, string Provenance): ConceptIrValue(StableId, ConceptIrValueKind.Axis, Provenance);@@ -311,6 +311,28 @@ internal static class ConceptIrResolvermodifyBlock, ir);}+ /// <summary>Resolves a compile-time Concept plane for a Construction Plane trace without materializing a BRep feature.</summary>+ public static bool TryResolvePlane(string source, string reference, out ConceptIrPlaneValue? plane, out string? diagnostic)+ {+ plane = null; diagnostic = null;+ var match = Regex.Match(reference, @"^(?<instance>[A-Za-z_][A-Za-z0-9_]*)\.(?<member>[A-Za-z_][A-Za-z0-9_]*)$", RegexOptions.CultureInvariant);+ if (!match.Success) { diagnostic = "ConstructionPlaneTraceMissing: Trace must name ConceptStruct.Plane"; return false; }+ var diagnostics = new List<string>(); var selections = new List<ConceptIrStaticSelection>();+ var instances = new Dictionary<string, ConceptIrStructInstance>(StringComparer.Ordinal);+ foreach (Match declaration in ConceptStructHeader.Matches(source))+ {+ var open = source.IndexOf('{', declaration.Index); var close = FindMatchingBrace(source, open);+ if (close < 0) { diagnostic = InvalidSpatialDerivation; return false; }+ var name = declaration.Groups["name"].Value;+ var body = source[(open + 1)..close];+ instances[name] = new(name, [], ResolveMembers(name, body, open + 1, "", ParseEnums(source, diagnostics), selections, diagnostics), false, "CompileTimeOnlyErased", new(declaration.Index, close - declaration.Index + 1));+ }+ if (!instances.TryGetValue(match.Groups["instance"].Value, out var instance) || !instance.Members.TryGetValue(match.Groups["member"].Value, out var value))+ { diagnostic = "ConceptPlaneNotFound: " + reference; return false; }+ if (value is not ConceptIrPlaneValue resolved) { diagnostic = "ConstructionPlaneTraceMissing: " + reference + " is not a Plane"; return false; }+ plane = resolved; return true;+ }+private static IReadOnlyList<FirmamentV2SemanticHoleDecl> ParseConceptHoles(string body,int bodyOffset,@@ -726,6 +748,14 @@ internal static class ConceptIrResolvervar face = Regex.Match(expression, @"^(?<box>[A-Za-z_][A-Za-z0-9_]*)\.Face\((?<axis>[+-][XYZ])\)$", RegexOptions.CultureInvariant);if (face.Success && EvaluateMember(face.Groups["box"].Value) is ConceptIrBox3Value faceBox)return new ConceptIrPlaneValue(Id(provenance), FaceCenter(faceBox, face.Groups["axis"].Value), Vector(face.Groups["axis"].Value), provenance);+ var plane = Regex.Match(expression, @"^Plane\s*\{(?<body>.*)\}$", RegexOptions.Singleline | RegexOptions.CultureInvariant);+ if (plane.Success)+ {+ var planeBody = plane.Groups["body"].Value;+ if (!TryVectorField(planeBody, "Origin", out var origin) || !TryVectorField(planeBody, "Normal", out var normal)) { diagnostics.Add(InvalidSpatialDerivation); return null; }+ var hasUp = TryVectorField(planeBody, "Up", out var up);+ return new ConceptIrPlaneValue(Id(provenance), new(origin.X, origin.Y, origin.Z), new(normal.X, normal.Y, normal.Z), provenance, hasUp ? new(up.X, up.Y, up.Z) : null);+ }var axis = Regex.Match(expression, @"^(?<box>[A-Za-z_][A-Za-z0-9_]*)\.Center\.Axis\((?<axis>[+-][XYZ])\)$", RegexOptions.CultureInvariant);if (axis.Success && EvaluateMember(axis.Groups["box"].Value) is ConceptIrBox3Value axisBox)return new ConceptIrAxisValue(Id(provenance), axisBox.Center, Vector(axis.Groups["axis"].Value), provenance);@@ -753,6 +783,13 @@ internal static class ConceptIrResolverreturn null;}+ private static bool TryVectorField(string body, string name, out (double X, double Y, double Z) vector)+ {+ var match = Regex.Match(body, $@"\b{Regex.Escape(name)}\s*:\s*\[(?<x>[-+.\d]+)(?:mm)?\s*,\s*(?<y>[-+.\d]+)(?:mm)?\s*,\s*(?<z>[-+.\d]+)(?:mm)?\s*\]", RegexOptions.CultureInvariant);+ if (match.Success && double.TryParse(match.Groups["x"].Value, NumberStyles.Float, CultureInfo.InvariantCulture, out var x) && double.TryParse(match.Groups["y"].Value, NumberStyles.Float, CultureInfo.InvariantCulture, out var y) && double.TryParse(match.Groups["z"].Value, NumberStyles.Float, CultureInfo.InvariantCulture, out var z) && double.IsFinite(x) && double.IsFinite(y) && double.IsFinite(z)) { vector = (x, y, z); return true; }+ vector = default; return false;+ }+private ConceptIrValue? EvaluateMatch(string expression, ParsedConceptMember target){var header = Regex.Match(expression, @"^Match\s+(?<scrutinee>[A-Za-z_][A-Za-z0-9_]*)\s*\{", RegexOptions.CultureInvariant);diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringParser.cs b/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringParser.csindex c998b002..213a6585 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringParser.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringParser.cs@@ -12,6 +12,7 @@ public static class ProfileAuthoringParserprivate static readonly Regex Circle = new(@"\bCircle2\s+(?<n>\w+)\s*\{\s*Center\s*:\s*(?<c>\w+)\s*;?\s*Radius\s*:\s*(?<r>[-+.\d]+)mm", RegexOptions.Singleline);private static readonly Regex Rect = new(@"\bRect2\s+(?<n>\w+)\s*\{\s*Center\s*:\s*\[(?<x>[-+.\d]+)mm\s*,\s*(?<y>[-+.\d]+)mm\]\s*;?\s*Size\s*:\s*\[(?<w>[-+.\d]+)mm\s*,\s*(?<h>[-+.\d]+)mm\]", RegexOptions.Singleline);private static readonly Regex Header = new(@"\bProfile\s+(?<n>\w+)\s+Using\s+(?<layout>\w+)\s*\{(?<body>[\s\S]*)", RegexOptions.CultureInvariant);+ private static readonly Regex ConstructionPlaneDeclaration = new(@"\bConstruction\s+Plane\s+(?<name>\w+)\s*\{\s*Trace\s*:\s*(?<trace>[\w.]+)\s*;?\s*\}", RegexOptions.Singleline | RegexOptions.CultureInvariant);private static readonly Regex Segment = new(@"\bSegment\s+(?<n>\w+)\s*\{\s*Trace\s*:\s*(?<trace>[\w.]+)\s*;?\s*From\s*:\s*(?<from>[\w.]+)\s*;?\s*To\s*:\s*(?<to>[\w.]+)(?:\s*;?\s*Sweep\s*:\s*(?<sweep>Clockwise|CounterClockwise))?", RegexOptions.Singleline);private static readonly Regex Extrude = new(@"\bExtrude\s+\w+\s*\{\s*Profile\s*:\s*(?<p>\w+)\s*;?\s*From\s*:\s*(?<a>[-+.\d]+)mm\s*;?\s*To\s*:\s*(?<b>[-+.\d]+)mm", RegexOptions.Singleline);@@ -19,6 +20,16 @@ public static class ProfileAuthoringParserpublic static (ResolvedProfile2D? Profile, double Height, IReadOnlyList<string> Diagnostics) Parse(string source){var d=new List<string>(); var h=Header.Match(source); if(!h.Success)return(null,0,["profile-source-missing-profile"]);+ ConstructionPlane? constructionPlane = null;+ var planeDeclaration = ConstructionPlaneDeclaration.Matches(source).Cast<Match>().SingleOrDefault(x => string.Equals(x.Groups["name"].Value, h.Groups["layout"].Value, StringComparison.Ordinal));+ if (planeDeclaration is not null)+ {+ if (!ConceptIrResolver.TryResolvePlane(source, planeDeclaration.Groups["trace"].Value, out var conceptPlane, out var traceDiagnostic) || conceptPlane is null)+ d.Add(traceDiagnostic ?? "ConstructionPlaneTraceMissing");+ else if (!ConstructionPlane.TryTrace("construction:" + planeDeclaration.Groups["name"].Value, conceptPlane, $"offset:{planeDeclaration.Index}", out constructionPlane, out var frameDiagnostic))+ d.Add(frameDiagnostic ?? "ConstructionPlaneFrameInvalid");+ }+ else constructionPlane = ConstructionPlane.WorldXY; // Existing Concept-layout Profiles retain their global-XY compatibility frame.var pts=new Dictionary<string,(double X,double Y)>(StringComparer.Ordinal);foreach(Match m in Point.Matches(source))pts[m.Groups["n"].Value]=(N(m,"x"),N(m,"y"));foreach (Match m in Rect.Matches(source))@@ -44,7 +55,7 @@ public static class ProfileAuthoringParserelse 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,"XY",[new ResolvedProfileLoop2D("Outer",true,segments)]),height,d);+ 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);}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/ConstructionPlane.cs b/Aetheris.Kernel.Firmament/Materializer/ConstructionPlane.csnew file mode 100644index 00000000..61fbd194--- /dev/null+++ b/Aetheris.Kernel.Firmament/Materializer/ConstructionPlane.cs@@ -0,0 +1,75 @@+using Aetheris.Kernel.Core.Math;+using Aetheris.Kernel.Firmament.FirmamentV2;++namespace Aetheris.Kernel.Firmament.Materializer;++/// <summary>+/// Immutable material-authoring frame traced from a resolved Concept plane. It is+/// deliberately independent of BRep faces and is never recomputed from topology.+/// </summary>+public sealed record ConstructionPlane(+ string StableId,+ string SourceConceptId,+ Point3D Origin,+ Direction3D AxisX,+ Direction3D AxisY,+ Direction3D AxisZ,+ string SourceSpan,+ string Provenance)+{+ public const string RightHanded = "RightHanded";+ public string Handedness => RightHanded;+ public double Determinant => AxisX.ToVector().Cross(AxisY.ToVector()).Dot(AxisZ.ToVector());++ public Point3D ToWorld((double X, double Y) point, double localZ = 0d)+ => Origin + AxisX.ToVector() * point.X + AxisY.ToVector() * point.Y + AxisZ.ToVector() * localZ;++ public Vector3D ToWorldVector((double X, double Y) vector)+ => AxisX.ToVector() * vector.X + AxisY.ToVector() * vector.Y;++ public Vector3D ToWorldDirection(Vector3D local)+ => AxisX.ToVector() * local.X + AxisY.ToVector() * local.Y + AxisZ.ToVector() * local.Z;++ public (double X, double Y, double Z) ToLocal(Point3D point)+ {+ var displacement = point - Origin;+ return (displacement.Dot(AxisX.ToVector()), displacement.Dot(AxisY.ToVector()), displacement.Dot(AxisZ.ToVector()));+ }++ public static ConstructionPlane WorldXY { get; } = new(+ "construction:world-xy", "concept:world-xy", new Point3D(0, 0, 0),+ Direction3D.Create(new Vector3D(1, 0, 0)), Direction3D.Create(new Vector3D(0, 1, 0)), Direction3D.Create(new Vector3D(0, 0, 1)),+ "compatibility-default", "DefaultConstructionPlane");++ public static bool TryTrace(string stableId, ConceptIrPlaneValue source, string sourceSpan, out ConstructionPlane? plane, out string? diagnostic)+ {+ plane = null; diagnostic = null;+ if (!double.IsFinite(source.Origin.X) || !double.IsFinite(source.Origin.Y) || !double.IsFinite(source.Origin.Z))+ { diagnostic = "ConstructionPlaneFrameInvalid: origin must be finite"; return false; }+ if (!Direction3D.TryCreate(new Vector3D(source.Normal.X, source.Normal.Y, source.Normal.Z), out var z))+ { diagnostic = "ConceptPlaneNormalDegenerate: normal must be nonzero"; return false; }++ var hintValue = source.OrientationHint is { } hint+ ? new Vector3D(hint.X, hint.Y, hint.Z)+ : DeterministicHint(z.ToVector());+ var projected = hintValue - z.ToVector() * hintValue.Dot(z.ToVector());+ if (!Direction3D.TryCreate(projected, out var y))+ { diagnostic = "ConceptPlaneOrientationDegenerate: orientation hint must not be parallel to normal"; return false; }+ if (!Direction3D.TryCreate(y.ToVector().Cross(z.ToVector()), out var x))+ { diagnostic = "ConstructionPlaneFrameInvalid: unable to derive AxisX"; return false; }+ // Recompute Y so roundoff cannot make a nearly-right-handed frame drift.+ y = Direction3D.Create(z.ToVector().Cross(x.ToVector()));+ var result = new ConstructionPlane(stableId, source.StableId, new(source.Origin.X, source.Origin.Y, source.Origin.Z), x, y, z, sourceSpan, source.Provenance);+ if (Math.Abs(result.Determinant - 1d) > 1e-10)+ { diagnostic = $"ConstructionPlaneNotRightHanded: determinant={result.Determinant:R}"; return false; }+ plane = result;+ return true;+ }++ private static Vector3D DeterministicHint(Vector3D normal)+ {+ // Fixed axis order makes compilation stable without camera-relative terminology.+ var candidates = new[] { new Vector3D(0, 0, 1), new Vector3D(0, 1, 0), new Vector3D(1, 0, 0) };+ return candidates.OrderBy(v => Math.Abs(v.Dot(normal))).First();+ }+}diff --git a/Aetheris.Kernel.Firmament/Materializer/LineArcProfileExtrudeEmitter.cs b/Aetheris.Kernel.Firmament/Materializer/LineArcProfileExtrudeEmitter.csindex 383537c1..a4bc551e 100644--- a/Aetheris.Kernel.Firmament/Materializer/LineArcProfileExtrudeEmitter.cs+++ b/Aetheris.Kernel.Firmament/Materializer/LineArcProfileExtrudeEmitter.cs@@ -12,7 +12,8 @@ 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);-public sealed record LineArcProfileExtrudeRequest(IReadOnlyList<LineArcProfileLoop2D> Loops, double Height);+/// <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);public enum LineArcProfileExtrudeStatus { Succeeded, Rejected, Deferred, Failed }public sealed record LineArcProfileExtrudeResult(LineArcProfileExtrudeStatus Status, BrepBody? Body, IReadOnlyList<string> Diagnostics, SemanticTopologyCorrespondence? Correspondence = null);@@ -38,7 +39,7 @@ public static class LineArcProfileExtrudeEmitter{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);+ 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);@@ -71,6 +72,7 @@ public static class LineArcProfileExtrudeEmitter{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>();@@ -89,7 +91,7 @@ public static class LineArcProfileExtrudeEmitter{var key = Key(p);if (cache.TryGetValue(key, out var existing)) return existing;- var created = b.AddVertex(); points[created] = new Point3D(p.X, p.Y, z); cache.Add(key, created); return created;+ 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){@@ -119,7 +121,7 @@ public static class LineArcProfileExtrudeEmitterbottomUses.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(new Point3D(line.Start.X, line.Start.Y, z0), Direction3D.Create(new Vector3D(nx, ny, 0)), Direction3D.Create(new Vector3D(0, 0, 1)))), "v2-v4-line-edge-side-face-emitted", source, eb, et, es0, es1));+ 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:@@ -128,21 +130,21 @@ public static class LineArcProfileExtrudeEmittervar 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(new Point3D(arc.Center.X,arc.Center.Y,z0),Direction3D.Create(new Vector3D(0,0,1)),arc.Radius,Direction3D.Create(new Vector3D(1,0,0))));- edgeCurves[et]=CurveGeometry.FromCircle(new Circle3Curve(new Point3D(arc.Center.X,arc.Center.Y,z1),Direction3D.Create(new Vector3D(0,0,1)),arc.Radius,Direction3D.Create(new Vector3D(1,0,0))));+ 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(new Point3D(arc.Center.X,arc.Center.Y,z0),Direction3D.Create(new Vector3D(0,0,1)),arc.Radius,Direction3D.Create(new Vector3D(1,0,0)))), "v2-v4-arc-edge-side-face-emitted", source, eb, et, es0, es1));+ 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]=new(circle.Center.X,circle.Center.Y,z0); points[vt]=new(circle.Center.X,circle.Center.Y,z1);+ 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],Direction3D.Create(new Vector3D(0,0,1)),circle.Radius,Direction3D.Create(new Vector3D(1,0,0))));- edgeCurves[et]=CurveGeometry.FromCircle(new Circle3Curve(points[vt],Direction3D.Create(new Vector3D(0,0,1)),circle.Radius,Direction3D.Create(new Vector3D(1,0,0))));+ 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],Direction3D.Create(new Vector3D(0,0,1)),circle.Radius,Direction3D.Create(new Vector3D(1,0,0)))), "v2-v4-full-circle-side-face-emitted", source, eb, et, es, es));+ 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;}}@@ -156,8 +158,8 @@ public static class LineArcProfileExtrudeEmittervar 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(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(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);@@ -167,6 +169,9 @@ public static class LineArcProfileExtrudeEmitter{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));@@ -176,10 +181,12 @@ public static class LineArcProfileExtrudeEmitterfor (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, ["Profile", "ResolvedProfile2D", "LineArcProfileExtrude", "AuthoritativeBRepPlan"]);+ correspondence = new(sourceProfile.Name, descendants, ["ConceptPlane:" + frame.SourceConceptId, "ConstructionPlane:" + frame.StableId, "Profile", "ResolvedProfile2D", "LineArcProfileExtrude", "AuthoritativeBRepPlan"]);}return true;}diff --git a/Aetheris.Kernel.Firmament/Materializer/ResolvedProfile2D.cs b/Aetheris.Kernel.Firmament/Materializer/ResolvedProfile2D.csindex 86cb0bc5..6ef61a3f 100644--- a/Aetheris.Kernel.Firmament/Materializer/ResolvedProfile2D.cs+++ b/Aetheris.Kernel.Firmament/Materializer/ResolvedProfile2D.cs@@ -4,7 +4,10 @@ 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);+public sealed record ResolvedProfile2D(string Name, string PlaneFrame, IReadOnlyList<ResolvedProfileLoop2D> Loops, ConstructionPlane? ConstructionPlane = null)+{+ public ConstructionPlane EffectiveConstructionPlane => ConstructionPlane ?? Materializer.ConstructionPlane.WorldXY;+}public sealed record ResolvedProfileValidationResult(bool IsValid, double SignedArea, IReadOnlyList<string> Diagnostics);public static class ResolvedProfile2DValidatordiff --git a/Aetheris.Kernel.Firmament/Materializer/SemanticTopologySelections.cs b/Aetheris.Kernel.Firmament/Materializer/SemanticTopologySelections.csindex 4fc5fb76..72f1d8f5 100644--- a/Aetheris.Kernel.Firmament/Materializer/SemanticTopologySelections.cs+++ b/Aetheris.Kernel.Firmament/Materializer/SemanticTopologySelections.cs@@ -5,7 +5,7 @@ using System.Text.RegularExpressions;namespace Aetheris.Kernel.Firmament.Materializer;/// <summary>Stable roles assigned while an authoritative plan is materialized. These are not geometric queries.</summary>-public enum SemanticTopologyRole { Unknown, ProfileVertex, VerticalExtrusionEdge, TopBoundary, BottomBoundary, ExtrusionSideFace, TopFaceBoundaryLoop, BottomFaceBoundaryLoop, HoleEntryLoop, HoleExitLoop, HoleWallFace, SlotEntryLoop, SlotExitLoop, SlotWallFace, SlotStraightWallFace, SlotEndWallFace, ComposeTransition }+public enum SemanticTopologyRole { Unknown, ProfileVertex, VerticalExtrusionEdge, LocalStartBoundary, LocalEndBoundary, LocalStartCapLoop, LocalEndCapLoop, TopBoundary, BottomBoundary, ExtrusionSideFace, TopFaceBoundaryLoop, BottomFaceBoundaryLoop, HoleEntryLoop, HoleExitLoop, HoleWallFace, SlotEntryLoop, SlotExitLoop, SlotWallFace, SlotStraightWallFace, SlotEndWallFace, ComposeTransition }public enum SemanticSelectionRequirement { ExactlyOne, OneOrMore, ConnectedChain, ClosedLoop, NonEmptyFaceSet }public enum SemanticSelectionFailure { None, SemanticSourceNotFound, NoMaterializedDescendants, AmbiguousBodyContext, SelectionCardinalityMismatch, DescendantsNotConnected, DescendantsBranch, DescendantsDoNotClose, MixedBoundaryRoles, UnsupportedTopologyChange, SelectionConsumerMismatch }diff --git a/Aetheris.Server/Api/CadmataFixtureService.cs b/Aetheris.Server/Api/CadmataFixtureService.csindex 979a254d..4276e528 100644--- a/Aetheris.Server/Api/CadmataFixtureService.cs+++ b/Aetheris.Server/Api/CadmataFixtureService.cs@@ -12,6 +12,7 @@ internal static class CadmataFixtureServiceprivate static readonly IReadOnlyDictionary<string, string> FixturePaths = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase){["direct-profile"] = "fixtures/FirmamentV2/Profile/valid/scaffold-rectangle.firmament",+ ["construction-plane-positive-x"] = "fixtures/FirmamentV2/Profile/valid/construction-plane-positive-x.firmament",["split-compose-chamfer"] = "fixtures/FirmamentV2/ProfileComposition/valid/semantic-split-compose-chamfer.firmament",["semantic-shaft-hole"] = "fixtures/FirmamentV2/Hole/valid/semantic-shaft-selection.firmament",["ctc-01-x3"] = "testdata/firmament/reconstructions/nist_ctc_01/ctc01_prismatic_blockout_x3.firmament",@@ -67,12 +68,19 @@ internal static class CadmataFixtureService{var entities = new List<CadmataVisualizationEntityDto>();foreach (var profile in profiles)+ {+ var frame = profile.EffectiveConstructionPlane;+ var axes = new[] { frame.Origin, frame.Origin + frame.AxisX.ToVector() * 8, frame.Origin, frame.Origin + frame.AxisY.ToVector() * 8, frame.Origin, frame.Origin + frame.AxisZ.ToVector() * 8 }+ .Select(p => new CadmataPointDto(p.X, p.Y, p.Z)).ToArray();+ entities.Add(new(frame.StableId, "ConstructionPlane", profile.PlaneFrame, "constructionPlanes", "ConstructionFrame", new("polyline", axes), frame.SourceSpan, [frame.SourceConceptId], null, null, null, null, null, null, null, new Dictionary<string, string> { ["sourceConceptId"] = frame.SourceConceptId, ["handedness"] = frame.Handedness, ["determinant"] = frame.Determinant.ToString("R") }));+ entities.Add(new(frame.SourceConceptId, "ConceptPlane", frame.SourceConceptId, "conceptPlanes", "ConceptGuide", new("polyline", axes), frame.SourceSpan, null, null, null, [frame.StableId], null, null, null, null, null));foreach (var segment in profile.Loops.SelectMany(loop => loop.Segments)){var guideId = segment.Provenance.ConceptStableId;- entities.Add(new(guideId, "ConceptGuide", guideId.Replace("concept:", "", StringComparison.Ordinal), "profileGuides", "ConstructionGuide", Geometry(segment.Geometry), segment.Provenance.SourceSpan, null, [segment.Provenance.StableId], null, null, null, null, null, null, null));+ entities.Add(new(guideId, "ConceptGuide", guideId.Replace("concept:", "", StringComparison.Ordinal), "profileGuides", "ConstructionGuide", Geometry(segment.Geometry, frame), segment.Provenance.SourceSpan, [frame.StableId], [segment.Provenance.StableId], null, null, null, null, null, null, null));var descendants = correspondence?.Descendants.Where(d => d.SourceStableId == segment.Provenance.StableId).ToArray() ?? [];- entities.Add(new(segment.Provenance.StableId, "ProfileSegment", segment.Name, "profileLoops", "ProfileBoundary", Geometry(segment.Geometry), segment.Provenance.SourceSpan, [guideId], null, descendants.Where(d => d.Kind == "ArrangementFragment").Select(d => d.StableId).ToArray(), descendants.Where(d => d.Kind != "ArrangementFragment").Select(d => d.StableId).ToArray(), null, null, null, null, new Dictionary<string, string> { ["derivation"] = segment.Provenance.Derivation }));+ entities.Add(new(segment.Provenance.StableId, "ProfileSegment", segment.Name, "profileLoops", "ProfileBoundary", Geometry(segment.Geometry, frame), segment.Provenance.SourceSpan, [guideId, frame.StableId], null, descendants.Where(d => d.Kind == "ArrangementFragment").Select(d => d.StableId).ToArray(), descendants.Where(d => d.Kind != "ArrangementFragment").Select(d => d.StableId).ToArray(), null, null, null, null, new Dictionary<string, string> { ["derivation"] = segment.Provenance.Derivation, ["constructionPlaneId"] = frame.StableId }));+ }}if (fixtureId == "semantic-shaft-hole"){@@ -118,12 +126,13 @@ internal static class CadmataFixtureServicevar selection = new CadmataVisualizationSelectionDto($"selection:{fixtureId}", hasSemanticFeatures ? "semantic feature descendants" : "compiler-published profile boundary", hasSemanticFeatures ? "FaceSet" : "LoopSet", selectionSourceIds, selectionSourceIds, !hasSemanticFeatures, []);return new("cadmata-concept-viz-x1", fixtureId, sourcePath, entities, [selection], diagnostics.Select(d => new CadmataVisualizationDiagnosticDto("Compiler.Trace", d, "info")).ToArray(), new Dictionary<string, double> { ["entityCount"] = entities.Count, ["faceCount"] = body.Topology.Faces.Count(), ["edgeCount"] = body.Topology.Edges.Count() });}- private static CadmataGeometryDto Geometry(LineArcProfileCurve2D curve) => curve switch+ private static CadmataGeometryDto Geometry(LineArcProfileCurve2D curve, ConstructionPlane frame) => curve switch{- LineArcLineSegment2D line => new("polyline", [new(line.Start.X, line.Start.Y, 0), new(line.End.X, line.End.Y, 0)]),- LineArcCircularArc2D arc => new("polyline", ArcPoints(arc)),+ LineArcLineSegment2D line => new("polyline", [World(line.Start, frame), World(line.End, frame)]),+ LineArcCircularArc2D arc => new("polyline", ArcPoints(arc).Select(p => World((p.X, p.Y), frame)).ToArray()),_ => new("polyline", []),};+ private static CadmataPointDto World((double X, double Y) local, ConstructionPlane frame) { var point = frame.ToWorld(local); return new(point.X, point.Y, point.Z); }private static IReadOnlyList<CadmataPointDto> ArcPoints(LineArcCircularArc2D arc) => Enumerable.Range(0, 25).Select(i => { var a = arc.StartAngleRadians + arc.SweepAngleRadians * i / 24d; return new CadmataPointDto(arc.Center.X + arc.Radius * Math.Cos(a), arc.Center.Y + arc.Radius * Math.Sin(a), 0); }).ToArray();private static string FindRepositoryRoot(){diff --git a/docs/firmament/concept-plane-drilled-holes-x1.md b/docs/firmament/concept-plane-drilled-holes-x1.mdindex 0cab9fda..57ad97cb 100644--- a/docs/firmament/concept-plane-drilled-holes-x1.md+++ b/docs/firmament/concept-plane-drilled-holes-x1.md@@ -2,7 +2,10 @@## Status-This milestone is **not implemented** in the current production compiler. This+This Hole milestone is **not implemented** in the current production compiler. The+immutable local material-frame prerequisite is now implemented by+[CONSTRUCTION-PLANES-X1](construction-planes-x1.md); local-frame host subtraction and+drill-point cones remain deferred. Thisdocument records the verified boundary so that a future implementation can extendthe existing compiler-owned `AirHoleFeature` family instead of creating a parallelfeature system or accidentally treating a mutable BRep face as an authoring@@ -96,4 +99,3 @@ it must not infer values from screenshots.`dotnet build Aetheris.slnx -f net10.0 --no-restore /m:1` both succeeded on thecurrent worktree. The build reports pre-existing JavaScript dependencyvulnerability warnings from the JavaScript SDK audit; it has no .NET errors.-diff --git a/docs/firmament/construction-planes-x1.md b/docs/firmament/construction-planes-x1.mdnew file mode 100644index 00000000..481ceb39--- /dev/null+++ b/docs/firmament/construction-planes-x1.md@@ -0,0 +1,38 @@+# Construction Planes X1++Concept geometry declares spatial intent. Construction Planes turn that intent into local material coordinates.++A Construction Plane is an immutable, compiler-known proper frame traced from a pre-solved `Concept Struct` plane. It is not face attachment, a mutable sketch plane, a nearest-face lookup, or a constraint solver.++```firmament+Concept Struct SideLayout {+ PositiveXDatum: Plane {+ Origin: [10mm, 2mm, 3mm]+ Normal: [1, 0, 0]+ Up: [0, 0, 1]+ }+}++Construction Plane PositiveXWorkplane { Trace: SideLayout.PositiveXDatum }++Profile SideProfile Using PositiveXWorkplane {+ Rect2 Outline { Center: [0mm, 0mm]; Size: [20mm, 10mm] }+ // named Line2/Segment boundary declarations...+}+```++`Normal` becomes local `AxisZ`. `Up` is projected into the plane as local `AxisY`; `AxisX = AxisY × AxisZ`, and `AxisY` is recomputed as `AxisZ × AxisX`. This produces normalized, orthogonal, deterministic right-handed frames (`determinant = +1`). If `Up` is omitted, a fixed world-axis priority is used, never a camera-relative word. Degenerate normals and parallel orientation hints are rejected with frame-specific diagnostics.++The mapping is explicit:++`world(local(u,v,w)) = Origin + u AxisX + v AxisY + w AxisZ`.++Features remain ordinary in local coordinates. The compiler emits their exact world-space geometry from the Construction Plane basis. `Point2`, profile bounds, curves, and depth retain their local meaning; extrusion follows local +Z. The compatibility `XY`/`WorldXY` Profile source uses the immutable world-XY Construction Plane.++The line/arc Profile materializer consumes that frame directly. It creates transformed vertices and line curves; cap planes use ±local Z; line side faces use transformed local normals; circular arcs create cylinders whose axis is local Z and whose seam is local X. It does not transform a completed BRep, tessellate, spatially match topology, or use a Boolean.++Semantic descendants now publish `LocalStartBoundary`, `LocalEndBoundary`, `LocalStartCapLoop`, and `LocalEndCapLoop`. Existing `Top`/`Bottom` aliases remain for compatibility, but explicitly mean local +Z/-Z and never global Z. Provenance is published as `ConceptPlane -> ConstructionPlane -> Profile -> LineArcProfileExtrude`.++`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.++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/fixtures/FirmamentV2/Profile/valid/construction-plane-positive-x.firmament b/fixtures/FirmamentV2/Profile/valid/construction-plane-positive-x.firmamentnew file mode 100644index 00000000..f266703f--- /dev/null+++ b/fixtures/FirmamentV2/Profile/valid/construction-plane-positive-x.firmament@@ -0,0 +1,15 @@+Concept Struct SideLayout {+ PositiveXDatum: Plane { Origin: [10mm, 2mm, 3mm]; Normal: [1, 0, 0]; Up: [0, 0, 1] }+}++Construction Plane PositiveXWorkplane { Trace: SideLayout.PositiveXDatum }++Profile SideProfile Using PositiveXWorkplane {+ Rect2 Outline { Center: [0mm, 0mm]; Size: [20mm, 10mm] }+ Segment Bottom { Trace: Outline.Bottom; From: Outline.BottomLeft; To: Outline.BottomRight }+ Segment Right { Trace: Outline.Right; From: Outline.BottomRight; To: Outline.TopRight }+ Segment Top { Trace: Outline.Top; From: Outline.TopRight; To: Outline.TopLeft }+ Segment Left { Trace: Outline.Left; From: Outline.TopLeft; To: Outline.BottomLeft }+}++Extrude Solid { Profile: SideProfile; From: -5mm; To: 5mm }