Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Support hyperbola geometry and blind-drill clearance inspection
Yuechen Liad855a3b53b4
diff --git a/Aetheris.CLI.Tests/InspectSelectionsTests.cs b/Aetheris.CLI.Tests/InspectSelectionsTests.csindex fa64a7be..1b201739 100644--- a/Aetheris.CLI.Tests/InspectSelectionsTests.cs+++ b/Aetheris.CLI.Tests/InspectSelectionsTests.cs@@ -43,6 +43,26 @@ public sealed class InspectSelectionsTestsAssert.All(json.RootElement.GetProperty("selectionResults").EnumerateArray(), result => Assert.True(result.GetProperty("succeeded").GetBoolean()));}+ [Fact]+ public void InspectSelections_ComposedBlindDrillReportsConservativeClearanceContract()+ {+ var root = FindRepoRoot();+ var source = Path.Combine(root, "fixtures", "FirmamentV2", "ProfileComposition", "valid", "construction-plane-blind-drill-clearance.firmament");+ var stdout = new StringWriter(); var stderr = new StringWriter();++ var exit = Aetheris.CLI.CliRunner.Run(["inspect-selections", source, "--json"], stdout, stderr);++ Assert.Equal(0, exit); Assert.True(string.IsNullOrWhiteSpace(stderr.ToString()), stderr.ToString());+ using var json = JsonDocument.Parse(stdout.ToString());+ var contract = json.RootElement.GetProperty("holeContract");+ Assert.Equal("FullRadiusThroughTotalDepth", contract.GetProperty("validationPolicy").GetString());+ Assert.True(contract.GetProperty("contractSatisfied").GetBoolean());+ Assert.Equal("CorridorProven", contract.GetProperty("hostTraversalClassification").GetString());+ Assert.All(contract.GetProperty("chordProofs").EnumerateArray(), proof => Assert.Equal("FullRadiusClearance", proof.GetProperty("toolPart").GetString()));+ Assert.Equal(5, json.RootElement.GetProperty("selections").GetArrayLength());+ Assert.All(json.RootElement.GetProperty("selections").EnumerateArray(), result => Assert.True(result.GetProperty("succeeded").GetBoolean()));+ }+private static string FindRepoRoot(){var directory = new DirectoryInfo(AppContext.BaseDirectory);diff --git a/Aetheris.CLI/CliRunner.cs b/Aetheris.CLI/CliRunner.csindex 3862f439..814ab9bf 100644--- a/Aetheris.CLI/CliRunner.cs+++ b/Aetheris.CLI/CliRunner.cs@@ -509,14 +509,48 @@ public static class CliRunnervar stack = PrismaticSectionStackCompiler.Normalize(parsedCompose, out var composeDiagnostics);var emittedCompose = stack is null ? null : PrismaticSectionStackEmitter.Emit(stack);if (stack is null || emittedCompose?.Body is null || emittedCompose.Correspondence is null) { stderr.WriteLine(string.Join(Environment.NewLine, composeDiagnostics)); return 1; }- var composeRequests = SemanticSelectionSourceParser.Parse(source, parsedCompose.Profiles.Values.First(), stack.Feature.Name, out var composeParseDiagnostics);+ BlindDrillToolCorridorEvidence? corridor = null;+ var bridgeDiagnostics = Array.Empty<string>();+ if ((stack.Feature.ConstructionPlaneBlindDrills?.Count ?? 0) > 0)+ {+ var finalPlan = SectionStackBlindDrillComposeBridge.TryApply(stack, emittedCompose.Plan!, out var bridge, out corridor);+ bridgeDiagnostics = bridge.ToArray();+ if (finalPlan?.TopologyPlan is null) { stderr.WriteLine(string.Join(Environment.NewLine, bridgeDiagnostics)); return 1; }+ var materialized = PrismaticSectionStackBrepMaterializer.TryMaterialize(finalPlan.TopologyPlan);+ if (materialized.Body is null) { stderr.WriteLine(string.Join(Environment.NewLine, materialized.Diagnostics)); return 1; }+ emittedCompose = new PrismaticSectionStackEmissionResult(materialized.Body, finalPlan, emittedCompose.Diagnostics.Concat(bridgeDiagnostics).ToArray(), finalPlan.Correspondence);+ }+ var composeRequests = SemanticSelectionSourceParser.Parse(source, parsedCompose.Profiles.Values.First(), stack.Feature.Name, out var composeParseDiagnostics).ToList();+ if (corridor is not null)+ {+ composeRequests.AddRange([+ new("inspect:mouth-loop", "MouthLoop", stack.Feature.Name, [corridor.HoleId], SemanticTopologyRole.HoleEntryLoop, SemanticSelectionRequirement.ClosedLoop, "inspect-selections"),+ new("inspect:shaft-wall-faces", "ShaftWallFaces", stack.Feature.Name, [corridor.HoleId], SemanticTopologyRole.HoleWallFace, SemanticSelectionRequirement.NonEmptyFaceSet, "inspect-selections"),+ new("inspect:shaft-to-drill-point-loop", "ShaftToDrillPointLoop", stack.Feature.Name, [corridor.HoleId], SemanticTopologyRole.HoleShaftToDrillPointLoop, SemanticSelectionRequirement.ClosedLoop, "inspect-selections"),+ new("inspect:drill-point-faces", "DrillPointFaces", stack.Feature.Name, [corridor.HoleId], SemanticTopologyRole.HoleDrillPointFace, SemanticSelectionRequirement.NonEmptyFaceSet, "inspect-selections"),+ new("inspect:tip-vertex", "TipVertex", stack.Feature.Name, [corridor.HoleId], SemanticTopologyRole.HoleTipVertex, SemanticSelectionRequirement.ExactlyOne, "inspect-selections")+ ]);+ }var composeResults = composeRequests.Select(request => SemanticTopologySelectionResolver.Resolve(emittedCompose.Body, emittedCompose.Correspondence, request)).ToArray();stdout.WriteLine(JsonSerializer.Serialize(new{body = emittedCompose.Correspondence.BodyStableId,selections = composeResults.Select(result => new { name = result.Request.Label, stableId = result.Request.StableId, sourceIdentities = result.Request.SourceStableIds, body = result.Request.BodyStableId, expectedShape = result.Request.Require.ToString(), topologyRole = result.Request.Role?.ToString(), succeeded = result.Succeeded, failure = result.Failure.ToString(), connectivity = new { result.IsConnected, result.IsClosed }, traversalOrder = result.OrderedChain.Select(x => x.StableId), materializedDescendants = result.Descendants.Select(x => new { x.StableId, x.Kind, role = x.Role.ToString(), x.SourceStableId, x.ParentStableId }), provenance = emittedCompose.Correspondence.ProvenanceChain, consumer = result.Request.Consumer, diagnostics = result.Diagnostics }),+ holeContract = corridor is null ? null : new+ {+ ValidationPolicy = corridor.ValidationPolicy.ToString(), corridor.HoleId, corridor.HostId, corridor.ConstructionPlaneId,+ corridor.Radius, corridor.ShaftDepth, corridor.TipLength, corridor.TotalDepth,+ ClearanceCylinderLength = corridor.TotalDepth,+ HostTraversalClassification = corridor.Classification.ToString(),+ RelevantHostSlabs = corridor.ShaftSliceProofs.Select(x => new { z = new[] { x.ZFrom, x.ZTo }, x.Provenance }),+ ChordProofs = corridor.ShaftSliceProofs.Select(x => new { z = new[] { x.ZFrom, x.ZTo }, axial = new[] { x.AxisFrom, x.AxisTo }, cross = new[] { x.CrossFrom, x.CrossTo }, x.ToolPart, classification = x.Classification.ToString(), x.Detail, x.Provenance }),+ corridor.RemainingWall,+ ContractSatisfied = corridor.Classification == BlindDrillToolCorridorClassification.CorridorProven,+ ConservativeRejection = corridor.Classification == BlindDrillToolCorridorClassification.FullRadiusTipClearanceFailed,+ diagnostics = corridor.Diagnostics+ },arrangement = stack.Slabs.Select(s => new { slab = new[] { s.From, s.To }, fragments = s.Arrangement?.AtomicFragments.Select(f => new { f.StableId, source = f.Source.Provenance.StableId, f.FromParameter, f.ToParameter, f.MaterialOnLeft, f.Retained }) }),- diagnostics = composeDiagnostics.Concat(composeParseDiagnostics).Distinct()+ diagnostics = composeDiagnostics.Concat(composeParseDiagnostics).Concat(bridgeDiagnostics).Distinct()}, JsonOptions));return composeDiagnostics.Count == 0 && composeParseDiagnostics.Count == 0 && composeResults.All(x => x.Succeeded) ? 0 : 1;}diff --git a/Aetheris.Kernel.Core.Tests/Geometry/CurvePrimitivesTests.cs b/Aetheris.Kernel.Core.Tests/Geometry/CurvePrimitivesTests.csindex 161acf64..d5d02964 100644--- a/Aetheris.Kernel.Core.Tests/Geometry/CurvePrimitivesTests.cs+++ b/Aetheris.Kernel.Core.Tests/Geometry/CurvePrimitivesTests.cs@@ -1,4 +1,5 @@using Aetheris.Kernel.Core.Geometry.Curves;+using Aetheris.Kernel.Core.Geometry.Surfaces;using Aetheris.Kernel.Core.Math;using Aetheris.Kernel.Core.Numerics;@@ -98,6 +99,54 @@ public sealed class CurvePrimitivesTestsreferenceAxis: Direction3D.Create(new Vector3D(1, 0, 0))));}+ [Fact]+ public void Hyperbola_EvaluateDerivativesAndReverse_AreAnalyticAndDeterministic()+ {+ var hyperbola = new Hyperbola3Curve(+ new Point3D(3d, -2d, 5d),+ Direction3D.Create(new Vector3D(0d, 0d, 1d)),+ Direction3D.Create(new Vector3D(1d, 0d, 0d)),+ semiAxisA: 4d,+ semiAxisB: 3d,+ HyperbolaBranch.PositiveAxisU);++ AssertPoint(hyperbola.Evaluate(0d), new Point3D(7d, -2d, 5d));+ AssertVector(hyperbola.FirstDerivative(0d), new Vector3D(0d, 3d, 0d));+ AssertVector(hyperbola.SecondDerivative(0d), new Vector3D(4d, 0d, 0d));+ AssertPoint(hyperbola.Reverse().Evaluate(0.7d), hyperbola.Evaluate(-0.7d));+ AssertVector(hyperbola.AxisU.ToVector().Cross(hyperbola.AxisV.ToVector()), hyperbola.PlaneNormal.ToVector());+ }++ [Theory]+ [InlineData("x")]+ [InlineData("minus-x")]+ [InlineData("y")]+ [InlineData("minus-y")]+ public void TransverseConeWorldZIntersection_ProducesForwardHyperbolaOnCone(string orientation)+ {+ var axis = orientation switch+ {+ "x" => new Vector3D(1d, 0d, 0d),+ "minus-x" => new Vector3D(-1d, 0d, 0d),+ "y" => new Vector3D(0d, 1d, 0d),+ _ => new Vector3D(0d, -1d, 0d),+ };+ var reference = Direction3D.Create(new Vector3D(0d, 0d, 1d));+ var cone = new ConeSurface(new Point3D(1d, 2d, 3d), Direction3D.Create(axis), double.Pi / 6d, reference);+ var result = TransverseConePlaneIntersection.IntersectWorldZ(cone, 5d);++ Assert.True(result.IsSuccess);+ var curve = result.Value;+ var point = curve.Evaluate(0.4d);+ var offset = point - cone.Apex;+ var axial = offset.Dot(cone.Axis.ToVector());+ var radial = (offset - (cone.Axis.ToVector() * axial)).Length;+ Assert.True(axial > 0d);+ Assert.Equal(axial * double.Tan(cone.SemiAngleRadians), radial, 10);+ Assert.Equal(2d / double.Tan(cone.SemiAngleRadians), curve.SemiAxisA, 10);+ Assert.Equal(2d, curve.SemiAxisB, 10);+ }+private static void AssertPoint(Point3D actual, Point3D expected){AssertVector(actual - expected, Vector3D.Zero);diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242HyperbolaEdgeTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242HyperbolaEdgeTests.csnew file mode 100644index 00000000..8b1cccf1--- /dev/null+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242HyperbolaEdgeTests.cs@@ -0,0 +1,87 @@+using Aetheris.Kernel.Core.Brep;+using Aetheris.Kernel.Core.Brep.Tessellation;+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.Step242;+using Aetheris.Kernel.Core.Topology;++namespace Aetheris.Kernel.Core.Tests.Step242;++public sealed class Step242HyperbolaEdgeTests+{+ [Fact]+ public void BoundedHyperbolaEdge_ExportsAndReimportsAsExactAnalyticSupport()+ {+ var source = BuildPlanarHyperbolaWire(HyperbolaBranch.PositiveAxisU);+ var exported = Step242Exporter.ExportBody(source, new Step242ExportOptions { BrepExportPreflightMode = BrepExportPreflightMode.Enforce });++ Assert.True(exported.IsSuccess, string.Join(Environment.NewLine, exported.Diagnostics.Select(d => d.Message)));+ Assert.Contains("HYPERBOLA", exported.Value, StringComparison.Ordinal);+ Assert.Contains("TRIMMED_CURVE", exported.Value, StringComparison.Ordinal);++ var imported = Step242Importer.ImportBody(exported.Value);+ Assert.True(imported.IsSuccess, string.Join(Environment.NewLine, imported.Diagnostics.Select(d => d.Message)));+ var hyperbola = Assert.Single(imported.Value.Geometry.Curves, pair => pair.Value.Kind == CurveGeometryKind.Hyperbola3).Value.Hyperbola3!.Value;+ Assert.Equal(3d, hyperbola.SemiAxisA, 12);+ Assert.Equal(2d, hyperbola.SemiAxisB, 12);+ Assert.Equal(new Point3D(4d, -5d, 0d), hyperbola.Center);+ }++ [Fact]+ public void NegativeBranch_ExportsTheSamePhysicalBranchWithoutSplineFallback()+ {+ var source = BuildPlanarHyperbolaWire(HyperbolaBranch.NegativeAxisU);+ var exported = Step242Exporter.ExportBody(source, new Step242ExportOptions { BrepExportPreflightMode = BrepExportPreflightMode.Enforce });+ Assert.True(exported.IsSuccess, string.Join(Environment.NewLine, exported.Diagnostics.Select(d => d.Message)));+ var imported = Step242Importer.ImportBody(exported.Value);+ Assert.True(imported.IsSuccess, string.Join(Environment.NewLine, imported.Diagnostics.Select(d => d.Message)));++ var sourceEndpoint = source.Geometry.Curves.Single(pair => pair.Value.Kind == CurveGeometryKind.Hyperbola3).Value.Hyperbola3!.Value.Evaluate(0.7d);+ var importedEndpoint = imported.Value.Geometry.Curves.Single(pair => pair.Value.Kind == CurveGeometryKind.Hyperbola3).Value.Hyperbola3!.Value.Evaluate(0.7d);+ Assert.True((sourceEndpoint - importedEndpoint).Length <= 1e-8d);+ }++ [Fact]+ public void BoundedHyperbolaEdge_TessellatesAsDerivedDisplayGeometry()+ {+ var tessellation = BrepDisplayTessellator.Tessellate(BuildPlanarHyperbolaWire(HyperbolaBranch.PositiveAxisU));+ Assert.True(tessellation.IsSuccess, string.Join(Environment.NewLine, tessellation.Diagnostics.Select(d => d.Message)));+ Assert.NotEmpty(tessellation.Value.FacePatches);+ }++ private static BrepBody BuildPlanarHyperbolaWire(HyperbolaBranch branch)+ {+ var z = Direction3D.Create(new Vector3D(0d, 0d, 1d));+ var x = Direction3D.Create(new Vector3D(1d, 0d, 0d));+ var hyperbola = new Hyperbola3Curve(new Point3D(4d, -5d, 0d), z, x, 3d, 2d, branch);+ var first = hyperbola.Evaluate(-0.4d);+ var second = hyperbola.Evaluate(0.7d);+ var third = new Point3D(4d, -8d, 0d);++ var topology = new TopologyModel();+ var vertices = new[] { new VertexId(1), new VertexId(2), new VertexId(3) };+ foreach (var vertex in vertices) topology.AddVertex(new Vertex(vertex));+ topology.AddEdge(new Edge(new EdgeId(1), vertices[0], vertices[1]));+ topology.AddEdge(new Edge(new EdgeId(2), vertices[1], vertices[2]));+ topology.AddEdge(new Edge(new EdgeId(3), vertices[2], vertices[0]));+ for (var i = 0; i < 3; i++) topology.AddCoedge(new Coedge(new CoedgeId(i + 1), new EdgeId(i + 1), new LoopId(1), new CoedgeId((i + 1) % 3 + 1), new CoedgeId((i + 2) % 3 + 1), false));+ topology.AddLoop(new Loop(new LoopId(1), [new CoedgeId(1), new CoedgeId(2), new CoedgeId(3)]));+ topology.AddFace(new Face(new FaceId(1), [new LoopId(1)]));+ topology.AddShell(new Shell(new ShellId(1), [new FaceId(1)]));+ topology.AddBody(new Body(new BodyId(1), [new ShellId(1)]));++ var geometry = new BrepGeometryStore();+ geometry.AddCurve(new CurveGeometryId(1), CurveGeometry.FromHyperbola(hyperbola));+ geometry.AddCurve(new CurveGeometryId(2), CurveGeometry.FromLine(new Line3Curve(second, Direction3D.Create(third - second))));+ geometry.AddCurve(new CurveGeometryId(3), CurveGeometry.FromLine(new Line3Curve(third, Direction3D.Create(first - third))));+ geometry.AddSurface(new SurfaceGeometryId(1), SurfaceGeometry.FromPlane(new PlaneSurface(Point3D.Origin, z, x)));+ var bindings = new BrepBindingModel();+ bindings.AddEdgeBinding(new EdgeGeometryBinding(new EdgeId(1), new CurveGeometryId(1), new ParameterInterval(-0.4d, 0.7d)));+ bindings.AddEdgeBinding(new EdgeGeometryBinding(new EdgeId(2), new CurveGeometryId(2), new ParameterInterval(0d, (third - second).Length)));+ bindings.AddEdgeBinding(new EdgeGeometryBinding(new EdgeId(3), new CurveGeometryId(3), new ParameterInterval(0d, (first - third).Length)));+ bindings.AddFaceBinding(new FaceGeometryBinding(new FaceId(1), new SurfaceGeometryId(1)));+ return new BrepBody(topology, geometry, bindings, new Dictionary<VertexId, Point3D> { [vertices[0]] = first, [vertices[1]] = second, [vertices[2]] = third });+ }+}diff --git a/Aetheris.Kernel.Core/Brep/BrepExportPreflight.cs b/Aetheris.Kernel.Core/Brep/BrepExportPreflight.csindex 590182f5..1d0a1ac4 100644--- a/Aetheris.Kernel.Core/Brep/BrepExportPreflight.cs+++ b/Aetheris.Kernel.Core/Brep/BrepExportPreflight.cs@@ -234,6 +234,7 @@ public static class BrepExportPreflightCurveGeometryKind.Line3 when curve.Line3 is Line3Curve line => line.Evaluate(t),CurveGeometryKind.Circle3 when curve.Circle3 is Circle3Curve circle => circle.Evaluate(t),CurveGeometryKind.Ellipse3 when curve.Ellipse3 is Ellipse3Curve ellipse => ellipse.Evaluate(t),+ CurveGeometryKind.Hyperbola3 when curve.Hyperbola3 is Hyperbola3Curve hyperbola => hyperbola.Evaluate(t),CurveGeometryKind.BSpline3 when curve.BSpline3 is BSpline3Curve spline => spline.Evaluate(t),_ => null,};diff --git a/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.cs b/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.csindex a7a2ed26..279d45f5 100644--- a/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.cs+++ b/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.cs@@ -3492,6 +3492,19 @@ public static class BrepDisplayTessellatorAppendUniquePoint(flattened, point);}+ break;+ case CurveGeometryKind.Hyperbola3:+ var hyperbolaPointsResult = SamplePlanarHyperbola(body, coedge, isTraversalSwapped, curve.Hyperbola3!.Value, segmentStart, segmentEnd, plane, faceId, options);+ if (!hyperbolaPointsResult.IsSuccess)+ {+ return KernelResult<IReadOnlyList<Point3D>>.Failure(hyperbolaPointsResult.Diagnostics);+ }++ foreach (var point in hyperbolaPointsResult.Value)+ {+ AppendUniquePoint(flattened, point);+ }+break;default:var curveKind = curve.UnsupportedKind ?? curve.Kind.ToString();@@ -3940,6 +3953,13 @@ public static class BrepDisplayTessellatorSampleEllipseCurve(ellipse, interval, segments),IsClosed: false));+ case CurveGeometryKind.Hyperbola3:+ var hyperbola = curve.Hyperbola3!.Value;+ return KernelResult<DisplayEdgePolyline>.Success(new DisplayEdgePolyline(+ edgeId,+ SampleHyperbolaCurve(hyperbola, interval, options),+ IsClosed: false));+default:return KernelResult<DisplayEdgePolyline>.Failure([CreateNotImplemented($"Edge {edgeId.Value} has unsupported curve kind '{curve.Kind}'.")]);}@@ -4032,6 +4052,7 @@ public static class BrepDisplayTessellatorCurveGeometryKind.Circle3 => KernelResult<Point3D>.Success(curve.Circle3!.Value.Evaluate(parameter)),CurveGeometryKind.BSpline3 => KernelResult<Point3D>.Success(curve.BSpline3!.Value.Evaluate(parameter)),CurveGeometryKind.Ellipse3 => KernelResult<Point3D>.Success(curve.Ellipse3!.Value.Evaluate(parameter)),+ CurveGeometryKind.Hyperbola3 => KernelResult<Point3D>.Success(curve.Hyperbola3!.Value.Evaluate(parameter)),_ => KernelResult<Point3D>.Failure([CreateNotImplemented($"Edge {edgeId.Value} endpoint evaluation does not support curve kind '{curve.UnsupportedKind ?? curve.Kind.ToString()}'.", PlanarCurveFlatteningUnsupportedSource)]),};}@@ -4057,6 +4078,7 @@ public static class BrepDisplayTessellatorCurveGeometryKind.Circle3 => KernelResult<Point3D>.Success(curve.Circle3!.Value.Evaluate(parameter)),CurveGeometryKind.BSpline3 => KernelResult<Point3D>.Success(curve.BSpline3!.Value.Evaluate(parameter)),CurveGeometryKind.Ellipse3 => KernelResult<Point3D>.Success(curve.Ellipse3!.Value.Evaluate(parameter)),+ CurveGeometryKind.Hyperbola3 => KernelResult<Point3D>.Success(curve.Hyperbola3!.Value.Evaluate(parameter)),_ => KernelResult<Point3D>.Failure([CreateNotImplemented($"Edge {edgeId.Value} endpoint evaluation does not support curve kind '{curve.UnsupportedKind ?? curve.Kind.ToString()}'.", PlanarCurveFlatteningUnsupportedSource)]),};}@@ -4100,6 +4122,73 @@ public static class BrepDisplayTessellatorreturn System.Math.Max(2, segmentCount);}+ private static KernelResult<IReadOnlyList<Point3D>> SamplePlanarHyperbola(+ BrepBody body,+ Coedge coedge,+ bool traversalSwapped,+ Hyperbola3Curve hyperbola,+ Point3D start,+ Point3D end,+ PlaneSurface plane,+ FaceId faceId,+ DisplayTessellationOptions options)+ {+ const double planeContainmentTolerance = 1e-7d;+ var normalAlignment = double.Abs(hyperbola.PlaneNormal.ToVector().Dot(plane.Normal.ToVector()));+ var centerOffset = double.Abs((hyperbola.Center - plane.Origin).Dot(plane.Normal.ToVector()));+ if (normalAlignment < 1d - 1e-7d || centerOffset > planeContainmentTolerance)+ {+ return KernelResult<IReadOnlyList<Point3D>>.Failure([+ CreateNotImplemented($"Face {faceId.Value} edge {coedge.EdgeId.Value} planar hyperbola flattening requires the hyperbola plane to match the face plane.", PlanarCurveFlatteningUnsupportedSource)]);+ }++ if (!body.Bindings.TryGetEdgeBinding(coedge.EdgeId, out var binding) || binding.TrimInterval is not ParameterInterval trim)+ {+ return KernelResult<IReadOnlyList<Point3D>>.Failure([+ CreateInvalidArgument($"Face {faceId.Value} edge {coedge.EdgeId.Value} requires a bounded hyperbola trim.", PlanarCurveFlatteningFailedSource)]);+ }++ var sampled = SampleHyperbolaCurve(hyperbola, trim, options).ToList();+ if (coedge.IsReversed ^ traversalSwapped ^ !binding.OrientedEdgeSense)+ {+ sampled.Reverse();+ }+ sampled[0] = start;+ sampled[^1] = end;+ return KernelResult<IReadOnlyList<Point3D>>.Success(sampled.Skip(1).ToArray());+ }++ private static IReadOnlyList<Point3D> SampleHyperbolaCurve(Hyperbola3Curve hyperbola, ParameterInterval trim, DisplayTessellationOptions options)+ {+ // This is a display/M8 carrier only. It adaptively controls the exact+ // midpoint-to-chord deviation and tangent turn, while preserving the exact+ // bounded support endpoints. The B-rep still owns Hyperbola3Curve.+ var points = new List<Point3D> { hyperbola.Evaluate(trim.Start) };+ AppendHyperbolaSegment(hyperbola, trim.Start, trim.End, hyperbola.Evaluate(trim.Start), hyperbola.Evaluate(trim.End), options, points, 0);+ return points;+ }++ private static void AppendHyperbolaSegment(Hyperbola3Curve hyperbola, double start, double end, Point3D startPoint, Point3D endPoint, DisplayTessellationOptions options, List<Point3D> points, int depth)+ {+ var middle = start + ((end - start) * 0.5d);+ var middlePoint = hyperbola.Evaluate(middle);+ var chord = endPoint - startPoint;+ var chordLength = chord.Length;+ var midpointDeviation = chordLength <= 1e-14d+ ? (middlePoint - startPoint).Length+ : ((middlePoint - startPoint).Cross(chord).Length / chordLength);+ var tangentTurn = double.Acos(System.Math.Clamp(+ hyperbola.Tangent(start).ToVector().Dot(hyperbola.Tangent(end).ToVector()), -1d, 1d));+ var canSplit = depth < 32 && points.Count < options.MaximumSegments;+ if (canSplit && (midpointDeviation > options.ChordTolerance || tangentTurn > options.AngularToleranceRadians))+ {+ AppendHyperbolaSegment(hyperbola, start, middle, startPoint, middlePoint, options, points, depth + 1);+ AppendHyperbolaSegment(hyperbola, middle, end, middlePoint, endPoint, options, points, depth + 1);+ return;+ }+ if ((endPoint - points[^1]).LengthSquared > 1e-24d) points.Add(endPoint);+ }+private static int CalculateSegmentCount(double angleSpan, double radius, DisplayTessellationOptions options){var byAngle = (int)double.Ceiling(angleSpan / options.AngularToleranceRadians);diff --git a/Aetheris.Kernel.Core/Brep/Verification/BrepMassProperties.cs b/Aetheris.Kernel.Core/Brep/Verification/BrepMassProperties.csindex 4378e46a..701304a6 100644--- a/Aetheris.Kernel.Core/Brep/Verification/BrepMassProperties.cs+++ b/Aetheris.Kernel.Core/Brep/Verification/BrepMassProperties.cs@@ -92,6 +92,18 @@ public static class BrepMassPropertiesreturn exact;}+ // A normalized section stack is an exact Z-prism whose boundary is+ // composed only of horizontal planes and vertical planes/cylinders.+ // The display-tessellation M8 lane otherwise measures arc chord error+ // rather than the authoritative analytic boundary. This recognizer+ // consumes only the materialized B-rep graph and bindings: for every+ // constant-Z interval it integrates the oriented line/arc section+ // boundary exactly. It deliberately declines any non-prismatic face.+ if (TryEvaluateExactVerticalLineArcPrism(body, effective, topology, out exact))+ {+ return exact;+ }+var coarse = EvaluateAtResolution(body, effective, refinement: 1);if (coarse.Error is not null){@@ -151,6 +163,239 @@ public static class BrepMassPropertiesprivate static BrepMassPropertiesResult Unavailable(BrepMassPropertiesOptions options, BrepMassPropertiesTopologyDiagnostics topology, string reason)=> new(BrepMassPropertiesStatus.Unavailable, 0d, 0d, 0d, null, topology.IsEnclosed, topology.IsOrientationConsistent, [], "DeterministicTrimmedFaceTriangulationBoundaryIntegral", null, options, topology, topology.Messages.Append(reason).ToArray());+ /// <summary>+ /// Exact volume recognizer for a materialized line/arc prismatic shell.+ /// It intentionally has no knowledge of Firmament section stacks: its only+ /// inputs are topology, vertex positions, and exact plane/cylinder curves.+ /// </summary>+ private static bool TryEvaluateExactVerticalLineArcPrism(+ BrepBody body,+ BrepMassPropertiesOptions options,+ BrepMassPropertiesTopologyDiagnostics topology,+ out BrepMassPropertiesResult result)+ {+ result = default!;+ const double tolerance = 1e-8d;+ var vertices = body.Topology.Vertices+ .Select(vertex => body.TryGetVertexPoint(vertex.Id, out var point) ? (vertex.Id, Point: (Point3D?)point) : (vertex.Id, Point: (Point3D?)null))+ .ToDictionary(x => x.Id, x => x.Point);+ if (vertices.Count == 0 || vertices.Values.Any(point => point is null)) return false;++ var levels = vertices.Values.Select(point => point!.Value.Z).DistinctBy(z => System.Math.Round(z / tolerance)).OrderBy(z => z).ToArray();+ if (levels.Length < 2) return false;++ var faces = body.Topology.Faces.ToArray();+ if (faces.Length == 0) return false;+ foreach (var face in faces)+ {+ if (!body.TryGetFaceSurfaceGeometry(face.Id, out var surface) || surface is null+ || surface.Kind is not (SurfaceGeometryKind.Plane or SurfaceGeometryKind.Cylinder))+ return false;+ if (surface.Kind == SurfaceGeometryKind.Cylinder && System.Math.Abs(surface.Cylinder!.Value.Axis.ToVector().Z) < 1d - tolerance)+ return false;+ if (surface.Kind == SurfaceGeometryKind.Plane+ && System.Math.Abs(surface.Plane!.Value.Normal.ToVector().Z) > tolerance+ && System.Math.Abs(surface.Plane!.Value.Normal.ToVector().Z) < 1d - tolerance)+ return false;+ }++ var total = 0d;+ var intervalEvidence = new List<string>();+ var contributions = new List<BrepMassPropertiesFaceContribution>();+ for (var index = 0; index < levels.Length - 1; index++)+ {+ var from = levels[index];+ var to = levels[index + 1];+ if (to - from <= tolerance) continue;+ var boundaryEdges = new HashSet<EdgeId>();+ foreach (var face in faces)+ {+ if (!IsVerticalSideFace(body, face, vertices, from, to, tolerance)) continue;+ foreach (var loopId in face.LoopIds)+ foreach (var coedgeId in body.GetCoedgeIds(loopId))+ {+ var edgeId = body.GetCoedgeEdgeId(coedgeId);+ var edge = body.Topology.GetEdge(edgeId);+ var a = vertices[edge.StartVertexId]!.Value;+ var b = vertices[edge.EndVertexId]!.Value;+ if (System.Math.Abs(a.Z - from) <= tolerance && System.Math.Abs(b.Z - from) <= tolerance)+ boundaryEdges.Add(edgeId);+ }+ }++ if (boundaryEdges.Count == 0) return false;+ if (!TryEvaluateSectionArea(boundaryEdges, body, vertices, out var area)) return false;+ if (area <= tolerance) return false;+ total += area * (to - from);+ intervalEvidence.Add($"z=[{from:R},{to:R}];area={area:R}");+ }++ if (total <= tolerance) return false;+ foreach (var face in faces)+ {+ var kind = body.TryGetFaceSurfaceGeometry(face.Id, out var surface) ? surface?.Kind : null;+ contributions.Add(new(face.Id, kind, 0d, 0d, 0, body.Bindings.TryGetFaceBinding(face.Id, out var binding), binding.SameSense, true));+ }+ var analyticRoundoffBound = System.Math.Max(1e-8d, System.Math.Abs(total) * 1e-14d);+ result = new BrepMassPropertiesResult(+ BrepMassPropertiesStatus.NumericalConverged,+ total,+ total,+ 0d,+ null,+ topology.IsEnclosed,+ topology.IsOrientationConsistent,+ contributions,+ "ExactVerticalLineArcPrismSectionIntegration",+ analyticRoundoffBound,+ options,+ topology,+ ["Exact materialized plane/cylinder section integration; no construction metadata or tessellation was used.", ..intervalEvidence]);+ return true;+ }++ /// <summary>+ /// Reconstructs the section's closed line loops from side-face boundary edges+ /// and classifies containment geometrically. Side-face loop winding is a 3D+ /// shell convention and is not the 2D material-loop winding; treating its+ /// raw edge binding direction as area orientation was the source of the+ /// nested Remove regression.+ /// </summary>+ private static bool TryEvaluateSectionArea(+ IReadOnlyCollection<EdgeId> edgeIds,+ BrepBody body,+ IReadOnlyDictionary<VertexId, Point3D?> vertices,+ out double area)+ {+ area = 0d;+ var adjacency = new Dictionary<VertexId, List<(EdgeId Edge, VertexId Other)>>();+ foreach (var edgeId in edgeIds)+ {+ if (!body.TryGetEdgeCurveGeometry(edgeId, out var curve) || curve?.Kind is not (CurveGeometryKind.Line3 or CurveGeometryKind.Circle3)) return false;+ var edge = body.Topology.GetEdge(edgeId);+ if (!adjacency.TryAdd(edge.StartVertexId, [(edgeId, edge.EndVertexId)])) adjacency[edge.StartVertexId].Add((edgeId, edge.EndVertexId));+ if (!adjacency.TryAdd(edge.EndVertexId, [(edgeId, edge.StartVertexId)])) adjacency[edge.EndVertexId].Add((edgeId, edge.StartVertexId));+ }+ if (adjacency.Count == 0 || adjacency.Values.Any(uses => uses.Count != 2)) return false;++ var remaining = new HashSet<EdgeId>(edgeIds);+ var loops = new List<(List<Point3D> Points, List<(EdgeId Edge, VertexId From)> Uses)>();+ while (remaining.Count > 0)+ {+ var firstEdge = remaining.OrderBy(id => id.Value).First();+ var first = body.Topology.GetEdge(firstEdge);+ var start = first.StartVertexId;+ var current = start;+ var loop = new List<Point3D>();+ var uses = new List<(EdgeId Edge, VertexId From)>();+ while (true)+ {+ if (!vertices.TryGetValue(current, out var point) || point is null) return false;+ loop.Add(point.Value);+ var next = adjacency[current].Where(candidate => remaining.Contains(candidate.Edge)).OrderBy(candidate => candidate.Edge.Value).FirstOrDefault();+ if (next == default) return false;+ remaining.Remove(next.Edge);+ uses.Add((next.Edge, current));+ current = next.Other;+ if (current == start) break;+ if (loop.Count > edgeIds.Count + 1) return false;+ }+ if (loop.Count < 3) return false;+ loops.Add((loop, uses));+ }++ for (var i = 0; i < loops.Count; i++)+ {+ var candidate = loops[i];+ var signedArea = 0d;+ foreach (var use in candidate.Uses)+ {+ if (!TrySignedPlanarCurveAreaTwice(body, use.Edge, use.From, out var contribution)) return false;+ signedArea += contribution / 2d;+ }+ var probe = new Point3D(candidate.Points.Average(p => p.X), candidate.Points.Average(p => p.Y), candidate.Points[0].Z);+ var depth = loops.Where((_, index) => index != i).Count(loop => PointInPolygon(probe, loop.Points));+ area += (depth & 1) == 0 ? System.Math.Abs(signedArea) : -System.Math.Abs(signedArea);+ }+ return area > 0d;+ }++ private static bool PointInPolygon(Point3D point, IReadOnlyList<Point3D> polygon)+ {+ var inside = false;+ for (int i = 0, j = polygon.Count - 1; i < polygon.Count; j = i++)+ {+ var a = polygon[i]; var b = polygon[j];+ if ((a.Y > point.Y) == (b.Y > point.Y)) continue;+ var x = ((b.X - a.X) * (point.Y - a.Y) / (b.Y - a.Y)) + a.X;+ if (point.X < x) inside = !inside;+ }+ return inside;+ }++ private static bool IsVerticalSideFace(+ BrepBody body,+ Face face,+ IReadOnlyDictionary<VertexId, Point3D?> vertices,+ double from,+ double to,+ double tolerance)+ {+ if (!body.TryGetFaceSurfaceGeometry(face.Id, out var surface) || surface is null) return false;+ if (surface.Kind == SurfaceGeometryKind.Plane && System.Math.Abs(surface.Plane!.Value.Normal.ToVector().Z) > tolerance) return false;+ var hasFullVertical = false;+ foreach (var loopId in face.LoopIds)+ foreach (var coedgeId in body.GetCoedgeIds(loopId))+ {+ var edge = body.Topology.GetEdge(body.GetCoedgeEdgeId(coedgeId));+ var a = vertices[edge.StartVertexId]!.Value;+ var b = vertices[edge.EndVertexId]!.Value;+ if (System.Math.Abs(a.X - b.X) <= tolerance && System.Math.Abs(a.Y - b.Y) <= tolerance+ && ((System.Math.Abs(a.Z - from) <= tolerance && System.Math.Abs(b.Z - to) <= tolerance)+ || (System.Math.Abs(a.Z - to) <= tolerance && System.Math.Abs(b.Z - from) <= tolerance)))+ {+ hasFullVertical = true;+ break;+ }+ }+ return hasFullVertical;+ }++ private static bool TrySignedPlanarCurveAreaTwice(BrepBody body, EdgeId edgeId, VertexId fromVertex, out double areaTwice)+ {+ areaTwice = 0d;+ if (!body.Bindings.TryGetEdgeBinding(edgeId, out var binding)+ || binding.TrimInterval is not { } trim+ || !body.Geometry.TryGetCurve(binding.CurveGeometryId, out var curve)+ || curve is null)+ return false;+ var edge = body.Topology.GetEdge(edgeId);+ var isTopologyForward = edge.StartVertexId == fromVertex;+ if (!isTopologyForward && edge.EndVertexId != fromVertex) return false;+ var followsTrim = isTopologyForward == binding.OrientedEdgeSense;+ var (start, end) = followsTrim ? (trim.Start, trim.End) : (trim.End, trim.Start);+ switch (curve.Kind)+ {+ case CurveGeometryKind.Line3 when curve.Line3 is { } line:+ {+ var a = line.Evaluate(start); var b = line.Evaluate(end);+ areaTwice = a.X * b.Y - b.X * a.Y;+ return true;+ }+ case CurveGeometryKind.Circle3 when curve.Circle3 is { } circle && System.Math.Abs(circle.Normal.ToVector().Z) > 1d - 1e-8d:+ {+ var sign = circle.Normal.ToVector().Z >= 0d ? 1d : -1d;+ var a = start * sign; var b = end * sign;+ areaTwice = (circle.Center.X * circle.Radius * (System.Math.Sin(b) - System.Math.Sin(a)))+ - (circle.Center.Y * circle.Radius * (System.Math.Cos(b) - System.Math.Cos(a)))+ + (circle.Radius * circle.Radius * (b - a));+ return true;+ }+ default:+ return false;+ }+ }+private static bool TryEvaluateExactSphereCylinderSeamBody(BrepBody body,BrepMassPropertiesOptions options,diff --git a/Aetheris.Kernel.Core/Geometry/CurveGeometry.cs b/Aetheris.Kernel.Core/Geometry/CurveGeometry.csindex 76291f89..593a14e6 100644--- a/Aetheris.Kernel.Core/Geometry/CurveGeometry.cs+++ b/Aetheris.Kernel.Core/Geometry/CurveGeometry.cs@@ -8,6 +8,7 @@ public enum CurveGeometryKindCircle3,BSpline3,Ellipse3,+ Hyperbola3,Unsupported,}@@ -16,13 +17,14 @@ public enum CurveGeometryKind/// </summary>public sealed record CurveGeometry{- private CurveGeometry(CurveGeometryKind kind, Line3Curve? line3, Circle3Curve? circle3, BSpline3Curve? bSpline3, Ellipse3Curve? ellipse3, string? unsupportedKind)+ private CurveGeometry(CurveGeometryKind kind, Line3Curve? line3, Circle3Curve? circle3, BSpline3Curve? bSpline3, Ellipse3Curve? ellipse3, Hyperbola3Curve? hyperbola3, string? unsupportedKind){Kind = kind;Line3 = line3;Circle3 = circle3;BSpline3 = bSpline3;Ellipse3 = ellipse3;+ Hyperbola3 = hyperbola3;UnsupportedKind = unsupportedKind;}@@ -35,16 +37,18 @@ public sealed record CurveGeometrypublic BSpline3Curve? BSpline3 { get; }public Ellipse3Curve? Ellipse3 { get; }+ public Hyperbola3Curve? Hyperbola3 { get; }public string? UnsupportedKind { get; }- public static CurveGeometry FromLine(Line3Curve line) => new(CurveGeometryKind.Line3, line, null, null, null, null);+ public static CurveGeometry FromLine(Line3Curve line) => new(CurveGeometryKind.Line3, line, null, null, null, null, null);- public static CurveGeometry FromCircle(Circle3Curve circle) => new(CurveGeometryKind.Circle3, null, circle, null, null, null);+ public static CurveGeometry FromCircle(Circle3Curve circle) => new(CurveGeometryKind.Circle3, null, circle, null, null, null, null);- public static CurveGeometry FromBSpline(BSpline3Curve curve) => new(CurveGeometryKind.BSpline3, null, null, curve, null, null);+ public static CurveGeometry FromBSpline(BSpline3Curve curve) => new(CurveGeometryKind.BSpline3, null, null, curve, null, null, null);- public static CurveGeometry FromEllipse(Ellipse3Curve ellipse) => new(CurveGeometryKind.Ellipse3, null, null, null, ellipse, null);+ public static CurveGeometry FromEllipse(Ellipse3Curve ellipse) => new(CurveGeometryKind.Ellipse3, null, null, null, ellipse, null, null);+ public static CurveGeometry FromHyperbola(Hyperbola3Curve hyperbola) => new(CurveGeometryKind.Hyperbola3, null, null, null, null, hyperbola, null);- public static CurveGeometry FromUnsupported(string kindName) => new(CurveGeometryKind.Unsupported, null, null, null, null, kindName);+ public static CurveGeometry FromUnsupported(string kindName) => new(CurveGeometryKind.Unsupported, null, null, null, null, null, kindName);}diff --git a/Aetheris.Kernel.Core/Geometry/Curves/Hyperbola3Curve.cs b/Aetheris.Kernel.Core/Geometry/Curves/Hyperbola3Curve.csnew file mode 100644index 00000000..547a6e1b--- /dev/null+++ b/Aetheris.Kernel.Core/Geometry/Curves/Hyperbola3Curve.cs@@ -0,0 +1,69 @@+using Aetheris.Kernel.Core.Math;++namespace Aetheris.Kernel.Core.Geometry.Curves;++/// <summary>+/// One explicit branch of an analytic hyperbola. The support is parameterized+/// as C + branch*A*cosh(t)*U + B*sinh(t)*V. A bounded B-rep use owns its trim+/// interval; this support deliberately remains unbounded.+/// </summary>+public readonly record struct Hyperbola3Curve+{+ public Hyperbola3Curve(Point3D center, Direction3D planeNormal, Direction3D axisU, double semiAxisA, double semiAxisB, HyperbolaBranch branch)+ {+ if (!double.IsFinite(center.X) || !double.IsFinite(center.Y) || !double.IsFinite(center.Z)) throw new ArgumentOutOfRangeException(nameof(center));+ if (!double.IsFinite(semiAxisA) || semiAxisA <= 0d) throw new ArgumentOutOfRangeException(nameof(semiAxisA));+ if (!double.IsFinite(semiAxisB) || semiAxisB <= 0d) throw new ArgumentOutOfRangeException(nameof(semiAxisB));+ var normal = planeNormal.ToVector(); var reference = axisU.ToVector(); var projected = reference - normal * reference.Dot(normal);+ if (!Direction3D.TryCreate(projected, out var u)) throw new ArgumentOutOfRangeException(nameof(axisU), "AxisU must lie in the hyperbola plane.");+ if (!Direction3D.TryCreate(normal.Cross(u.ToVector()), out var v)) throw new ArgumentOutOfRangeException(nameof(planeNormal), "Plane normal and AxisU must define a right-handed frame.");+ Center = center; PlaneNormal = planeNormal; AxisU = u; AxisV = v; SemiAxisA = semiAxisA; SemiAxisB = semiAxisB; Branch = branch;+ }++ public Point3D Center { get; }+ public Direction3D PlaneNormal { get; }+ public Direction3D AxisU { get; }+ public Direction3D AxisV { get; }+ public double SemiAxisA { get; }+ public double SemiAxisB { get; }+ public HyperbolaBranch Branch { get; }+ public double BranchSign => Branch == HyperbolaBranch.PositiveAxisU ? 1d : -1d;++ public Point3D Evaluate(double parameter)+ {+ if (!double.IsFinite(parameter) || double.Abs(parameter) > 700d) throw new ArgumentOutOfRangeException(nameof(parameter), "Hyperbola parameter must be finite and safely evaluable.");+ var p = Center + AxisU.ToVector() * (BranchSign * SemiAxisA * double.Cosh(parameter)) + AxisV.ToVector() * (SemiAxisB * double.Sinh(parameter));+ if (!double.IsFinite(p.X) || !double.IsFinite(p.Y) || !double.IsFinite(p.Z)) throw new ArgumentOutOfRangeException(nameof(parameter), "Hyperbola evaluation is non-finite.");+ return p;+ }+ public Vector3D FirstDerivative(double parameter)+ {+ ValidateParameter(parameter);+ return AxisU.ToVector() * (BranchSign * SemiAxisA * double.Sinh(parameter)) + AxisV.ToVector() * (SemiAxisB * double.Cosh(parameter));+ }++ public Vector3D SecondDerivative(double parameter)+ {+ ValidateParameter(parameter);+ return AxisU.ToVector() * (BranchSign * SemiAxisA * double.Cosh(parameter)) + AxisV.ToVector() * (SemiAxisB * double.Sinh(parameter));+ }++ public Direction3D Tangent(double parameter) => Direction3D.Create(FirstDerivative(parameter));++ /// <summary>+ /// Returns the same geometric branch with reversed parameter direction. B-rep edge+ /// orientation remains owned by <see cref="Brep.EdgeGeometryBinding"/>; this helper is+ /// useful only where a support itself must be reparameterized.+ /// </summary>+ public Hyperbola3Curve Reverse() => new(Center, Direction3D.Create(-PlaneNormal.ToVector()), AxisU, SemiAxisA, SemiAxisB, Branch);++ private static void ValidateParameter(double parameter)+ {+ if (!double.IsFinite(parameter) || double.Abs(parameter) > 700d)+ {+ throw new ArgumentOutOfRangeException(nameof(parameter), "Hyperbola parameter must be finite and safely evaluable.");+ }+ }+}++public enum HyperbolaBranch { PositiveAxisU, NegativeAxisU }diff --git a/Aetheris.Kernel.Core/Geometry/Surfaces/TransverseConePlaneIntersection.cs b/Aetheris.Kernel.Core/Geometry/Surfaces/TransverseConePlaneIntersection.csnew file mode 100644index 00000000..e44aa4a1--- /dev/null+++ b/Aetheris.Kernel.Core/Geometry/Surfaces/TransverseConePlaneIntersection.cs@@ -0,0 +1,73 @@+using Aetheris.Kernel.Core.Diagnostics;+using Aetheris.Kernel.Core.Geometry.Curves;+using Aetheris.Kernel.Core.Math;+using Aetheris.Kernel.Core.Results;++namespace Aetheris.Kernel.Core.Geometry.Surfaces;++/// <summary>+/// Exact, deliberately narrow intersection for a signed-permutation transverse cone+/// and a world-Z section plane. It is not a general surface/surface intersection+/// service: this is the analytic route used by section-stack partition planning.+/// </summary>+public static class TransverseConePlaneIntersection+{+ private const double DirectionTolerance = 1e-10d;+ private const double DegeneracyTolerance = 1e-10d;++ public static KernelResult<Hyperbola3Curve> IntersectWorldZ(ConeSurface cone, double worldZ)+ {+ if (!double.IsFinite(worldZ))+ {+ return Failure("World-Z plane coordinate must be finite.", "Geometry.TransverseConePlane.NonFinitePlane");+ }++ var axis = cone.Axis.ToVector();+ var isSignedX = double.Abs(double.Abs(axis.X) - 1d) <= DirectionTolerance+ && double.Abs(axis.Y) <= DirectionTolerance && double.Abs(axis.Z) <= DirectionTolerance;+ var isSignedY = double.Abs(double.Abs(axis.Y) - 1d) <= DirectionTolerance+ && double.Abs(axis.X) <= DirectionTolerance && double.Abs(axis.Z) <= DirectionTolerance;+ if (!isSignedX && !isSignedY)+ {+ return Failure("Only signed-permutation transverse cone axes (+/-X, +/-Y) are admitted.", "Geometry.TransverseConePlane.UnsupportedAxis");+ }++ var zOffset = worldZ - cone.Apex.Z;+ if (double.Abs(zOffset) <= DegeneracyTolerance)+ {+ return Failure("A world-Z plane through the cone apex is a degenerate pair of lines, not a bounded hyperbola trim.", "Geometry.TransverseConePlane.ApexDegeneracy");+ }++ var tangent = double.Tan(cone.SemiAngleRadians);+ if (!double.IsFinite(tangent) || tangent <= DegeneracyTolerance)+ {+ return Failure("Cone semi-angle does not produce a finite transverse hyperbola.", "Geometry.TransverseConePlane.InvalidSemiAngle");+ }++ var planeNormal = Direction3D.Create(new Vector3D(0d, 0d, 1d));+ var center = new Point3D(cone.Apex.X, cone.Apex.Y, worldZ);+ var semiAxisA = double.Abs(zOffset) / tangent;+ var semiAxisB = double.Abs(zOffset);+ try+ {+ // The forward cone sheet v >= 0 is the positive axial branch. AxisV is+ // derived right-handed from +Z x the drilling axis, so +/-X and +/-Y keep+ // their construction-plane orientation without camera-relative aliases.+ return KernelResult<Hyperbola3Curve>.Success(new Hyperbola3Curve(+ center,+ planeNormal,+ cone.Axis,+ semiAxisA,+ semiAxisB,+ HyperbolaBranch.PositiveAxisU));+ }+ catch (ArgumentException exception)+ {+ return Failure($"Unable to construct transverse cone hyperbola: {exception.Message}", "Geometry.TransverseConePlane.FrameInvalid");+ }+ }++ private static KernelResult<Hyperbola3Curve> Failure(string message, string source)+ => KernelResult<Hyperbola3Curve>.Failure([+ new KernelDiagnostic(KernelDiagnosticCode.InvalidArgument, KernelDiagnosticSeverity.Error, message, source)]);+}diff --git a/Aetheris.Kernel.Core/Step242/Step242Exporter.cs b/Aetheris.Kernel.Core/Step242/Step242Exporter.csindex 6f751d07..621d107e 100644--- a/Aetheris.Kernel.Core/Step242/Step242Exporter.cs+++ b/Aetheris.Kernel.Core/Step242/Step242Exporter.cs@@ -64,8 +64,9 @@ public static class Step242Exportervar circleIds = new Dictionary<EdgeId, string>();var bsplineIds = new Dictionary<EdgeId, string>();var ellipseIds = new Dictionary<EdgeId, string>();+ var hyperbolaIds = new Dictionary<EdgeId, string>();- var outerClosedShellId = BuildClosedShell(writer, body, model, shellRepresentation.OuterShellId, vertexPoints, cartesianPointIds, vertexPointIds, edgeCurveIds, orientedEdgeIds, lineIds, circleIds, bsplineIds, ellipseIds, options.EmitFullCircleTrimmedCurves);+ var outerClosedShellId = BuildClosedShell(writer, body, model, shellRepresentation.OuterShellId, vertexPoints, cartesianPointIds, vertexPointIds, edgeCurveIds, orientedEdgeIds, lineIds, circleIds, bsplineIds, ellipseIds, hyperbolaIds, options.EmitFullCircleTrimmedCurves);EmitAuxiliaryVertexPointForVertexlessAnalyticBody(writer, body, model);if (outerClosedShellId is null){@@ -82,7 +83,7 @@ public static class Step242Exportervar orientedVoidShellIds = new List<string>();foreach (var innerShellId in shellRepresentation.InnerShellIds.OrderBy(id => id.Value)){- var innerClosedShellId = BuildClosedShell(writer, body, model, innerShellId, vertexPoints, cartesianPointIds, vertexPointIds, edgeCurveIds, orientedEdgeIds, lineIds, circleIds, bsplineIds, ellipseIds, options.EmitFullCircleTrimmedCurves);+ var innerClosedShellId = BuildClosedShell(writer, body, model, innerShellId, vertexPoints, cartesianPointIds, vertexPointIds, edgeCurveIds, orientedEdgeIds, lineIds, circleIds, bsplineIds, ellipseIds, hyperbolaIds, options.EmitFullCircleTrimmedCurves);if (innerClosedShellId is null){return Failure($"Shell {innerShellId.Value} could not be exported.", $"Shell:{innerShellId.Value}");@@ -159,6 +160,7 @@ public static class Step242ExporterDictionary<EdgeId, string> circleIds,Dictionary<EdgeId, string> bsplineIds,Dictionary<EdgeId, string> ellipseIds,+ Dictionary<EdgeId, string> hyperbolaIds,bool emitFullCircleTrimmedCurves){if (!model.TryGetShell(shellId, out var shell) || shell is null)@@ -204,7 +206,7 @@ public static class Step242Exporterif (!edgeCurveIds.TryGetValue(coedge.EdgeId, out var edgeCurveId)){- var edgeResult = BuildEdgeCurve(body, model, writer, coedge.EdgeId, vertexPoints, cartesianPointIds, vertexPointIds, lineIds, circleIds, bsplineIds, ellipseIds, emitFullCircleTrimmedCurves);+ var edgeResult = BuildEdgeCurve(body, model, writer, coedge.EdgeId, vertexPoints, cartesianPointIds, vertexPointIds, lineIds, circleIds, bsplineIds, ellipseIds, hyperbolaIds, emitFullCircleTrimmedCurves);if (!edgeResult.IsSuccess){return null;@@ -601,6 +603,14 @@ public static class Step242Exporterreturn KernelResult<string>.Success(writer.AddEntity("ELLIPSE", "$", Step242TextWriter.Ref(axisPlacementId), Step242TextWriter.Number(ellipse.MajorRadius), Step242TextWriter.Number(ellipse.MinorRadius)));}+ if (curve.Kind == CurveGeometryKind.Hyperbola3 && curve.Hyperbola3 is Hyperbola3Curve hyperbola)+ {+ var exportedAxisU = hyperbola.Branch == HyperbolaBranch.PositiveAxisU ? hyperbola.AxisU : Direction3D.Create(-hyperbola.AxisU.ToVector());+ var exportedNormal = hyperbola.Branch == HyperbolaBranch.PositiveAxisU ? hyperbola.PlaneNormal : Direction3D.Create(-hyperbola.PlaneNormal.ToVector());+ var axisPlacementId = BuildAxisPlacement(writer, hyperbola.Center, exportedNormal, exportedAxisU);+ return KernelResult<string>.Success(writer.AddEntity("HYPERBOLA", "$", Step242TextWriter.Ref(axisPlacementId), Step242TextWriter.Number(hyperbola.SemiAxisA), Step242TextWriter.Number(hyperbola.SemiAxisB)));+ }+return Failure($"Unsupported swept directrix curve kind '{curve.Kind}'.", source);}@@ -616,6 +626,7 @@ public static class Step242ExporterIDictionary<EdgeId, string> circleIds,IDictionary<EdgeId, string> bsplineIds,IDictionary<EdgeId, string> ellipseIds,+ IDictionary<EdgeId, string> hyperbolaIds,bool emitFullCircleTrimmedCurves){var edge = model.GetEdge(edgeId);@@ -633,7 +644,8 @@ public static class Step242Exporterif (curve.Kind != CurveGeometryKind.Line3&& curve.Kind != CurveGeometryKind.Circle3&& curve.Kind != CurveGeometryKind.BSpline3- && curve.Kind != CurveGeometryKind.Ellipse3)+ && curve.Kind != CurveGeometryKind.Ellipse3+ && curve.Kind != CurveGeometryKind.Hyperbola3){return Failure($"Unsupported curve kind '{curve.Kind}'.", $"Edge:{edgeId.Value}");}@@ -753,6 +765,29 @@ public static class Step242ExportergeometryCurveId = ellipseId;}+ else if (curve.Kind == CurveGeometryKind.Hyperbola3 && curve.Hyperbola3 is Hyperbola3Curve hyperbola)+ {+ if (!hyperbolaIds.TryGetValue(edgeId, out var hyperbolaId))+ {+ // STEP HYPERBOLA represents its one exported branch through AXIS2_PLACEMENT_3D.+ // Encode the branch in the support frame (rather than approximating it as a spline).+ var exportedAxisU = hyperbola.Branch == HyperbolaBranch.PositiveAxisU+ ? hyperbola.AxisU+ : Direction3D.Create(-hyperbola.AxisU.ToVector());+ var exportedNormal = hyperbola.Branch == HyperbolaBranch.PositiveAxisU+ ? hyperbola.PlaneNormal+ : Direction3D.Create(-hyperbola.PlaneNormal.ToVector());+ var axisPlacementId = BuildAxisPlacement(writer, hyperbola.Center, exportedNormal, exportedAxisU);+ hyperbolaId = writer.AddEntity("HYPERBOLA", "$", Step242TextWriter.Ref(axisPlacementId), Step242TextWriter.Number(hyperbola.SemiAxisA), Step242TextWriter.Number(hyperbola.SemiAxisB));+ hyperbolaIds[edgeId] = hyperbolaId;+ }++ var trim = edgeBinding.TrimInterval.Value;+ geometryCurveId = writer.AddEntity("TRIMMED_CURVE", "$", Step242TextWriter.Ref(hyperbolaId),+ Step242TextWriter.List($"PARAMETER_VALUE({Step242TextWriter.Number(trim.Start)})"),+ Step242TextWriter.List($"PARAMETER_VALUE({Step242TextWriter.Number(trim.End)})"),+ Step242TextWriter.BooleanLogical(true), Step242TextWriter.Enum("PARAMETER"));+ }else{return Failure($"Unsupported curve kind '{curve.Kind}'.", $"Edge:{edgeId.Value}");@@ -994,6 +1029,7 @@ public static class Step242ExporterCurveGeometryKind.Circle3 when curve.Circle3 is Circle3Curve circle => KernelResult<Point3D>.Success(circle.Evaluate(parameter)),CurveGeometryKind.BSpline3 when curve.BSpline3 is BSpline3Curve spline => KernelResult<Point3D>.Success(spline.Evaluate(parameter)),CurveGeometryKind.Ellipse3 when curve.Ellipse3 is Ellipse3Curve ellipse => KernelResult<Point3D>.Success(ellipse.Evaluate(parameter)),+ CurveGeometryKind.Hyperbola3 when curve.Hyperbola3 is Hyperbola3Curve hyperbola => KernelResult<Point3D>.Success(hyperbola.Evaluate(parameter)),_ => FailurePoint($"Unsupported curve kind '{curve.Kind}'.", $"Edge:{edgeId.Value}")};}diff --git a/Aetheris.Kernel.Core/Step242/Step242Importer.cs b/Aetheris.Kernel.Core/Step242/Step242Importer.csindex 246d3ef0..fce195a7 100644--- a/Aetheris.Kernel.Core/Step242/Step242Importer.cs+++ b/Aetheris.Kernel.Core/Step242/Step242Importer.cs@@ -846,6 +846,28 @@ public static class Step242ImportertrimResult.Value));}+ var hyperbolaConstructor = Step242SubsetDecoder.TryGetConstructor(curveEntity.Instance, "HYPERBOLA");+ if (hyperbolaConstructor is not null)+ {+ var hyperbolaResult = Step242SubsetDecoder.ReadHyperbolaCurve(document, WithConstructor(curveEntity, hyperbolaConstructor));+ if (!hyperbolaResult.IsSuccess)+ {+ return KernelResult<(CurveGeometry CurveGeometry, ParameterInterval TrimInterval)>.Failure(hyperbolaResult.Diagnostics);+ }++ var trimResult = explicitTrim is { } specified+ ? KernelResult<ParameterInterval>.Success(specified)+ : ComputeHyperbolaTrim(hyperbolaResult.Value, startPoint, endPoint, edgeSameSense);+ if (!trimResult.IsSuccess)+ {+ return KernelResult<(CurveGeometry CurveGeometry, ParameterInterval TrimInterval)>.Failure(trimResult.Diagnostics);+ }++ return KernelResult<(CurveGeometry CurveGeometry, ParameterInterval TrimInterval)>.Success((+ CurveGeometry.FromHyperbola(hyperbolaResult.Value),+ trimResult.Value));+ }+var splineEntity = ResolveBSplineCurveEntity(curveEntity);if (splineEntity is not null){@@ -2152,6 +2174,53 @@ public static class Step242Importerreturn loop;}+ private static KernelResult<ParameterInterval> ComputeHyperbolaTrim(Hyperbola3Curve hyperbola, Point3D startPoint, Point3D endPoint, bool edgeSameSense)+ {+ var scale = System.Math.Max(hyperbola.SemiAxisA, System.Math.Max(hyperbola.SemiAxisB, System.Math.Max((startPoint - hyperbola.Center).Length, (endPoint - hyperbola.Center).Length)));+ var tolerance = System.Math.Max(1e-7d, scale * 1e-8d);+ var startResult = ProjectPointToHyperbolaParameter(hyperbola, startPoint, tolerance);+ if (!startResult.IsSuccess) return KernelResult<ParameterInterval>.Failure(startResult.Diagnostics);+ var endResult = ProjectPointToHyperbolaParameter(hyperbola, endPoint, tolerance);+ if (!endResult.IsSuccess) return KernelResult<ParameterInterval>.Failure(endResult.Diagnostics);++ var start = startResult.Value;+ var end = endResult.Value;+ if (end < start)+ {+ if (edgeSameSense)+ {+ return FailureHyperbolaTrim("EDGE_CURVE hyperbola parameterization is opposite to vertex ordering.", "Importer.Geometry.HyperbolaTrim.Direction");+ }+ return KernelResult<ParameterInterval>.Success(new ParameterInterval(end, start));+ }+ return KernelResult<ParameterInterval>.Success(new ParameterInterval(start, end));+ }++ private static KernelResult<double> ProjectPointToHyperbolaParameter(Hyperbola3Curve hyperbola, Point3D point, double tolerance)+ {+ var delta = point - hyperbola.Center;+ var normalError = double.Abs(delta.Dot(hyperbola.PlaneNormal.ToVector()));+ if (normalError > tolerance)+ {+ return FailureHyperbolaTrimParameter($"HYPERBOLA endpoint is off its support plane by {normalError:G17}.", "Importer.Geometry.HyperbolaEndpointMismatch");+ }++ var u = delta.Dot(hyperbola.AxisU.ToVector());+ var v = delta.Dot(hyperbola.AxisV.ToVector());+ if ((u * hyperbola.BranchSign) < hyperbola.SemiAxisA - tolerance)+ {+ return FailureHyperbolaTrimParameter("HYPERBOLA endpoint lies on the opposite branch or inside the vertex line.", "Importer.Geometry.HyperbolaBranchAmbiguous");+ }++ var parameter = double.Asinh(v / hyperbola.SemiAxisB);+ var expected = hyperbola.Evaluate(parameter);+ if ((expected - point).Length > tolerance)+ {+ return FailureHyperbolaTrimParameter("HYPERBOLA endpoint does not lie on the analytic support.", "Importer.Geometry.HyperbolaEndpointMismatch");+ }+ return KernelResult<double>.Success(parameter);+ }+private static bool LoopsOverlap(PlanarLoopInfo a, PlanarLoopInfo b, double containmentTolerance){var aPoint = ChooseContainmentPoint(a.ProjectedPoints, containmentTolerance);@@ -3243,6 +3312,11 @@ public static class Step242Importervar ellipseSegmentCount = ComputeAdaptiveCircleSegmentCount(ellipseSpan);points = SampleEllipticalTrim(ellipse, ellipseTrim, ellipseSegmentCount);break;+ case CurveGeometryKind.Hyperbola3:+ var hyperbola = curve.Hyperbola3!.Value;+ var hyperbolaTrim = edgeBinding.TrimInterval ?? new ParameterInterval(-1d, 1d);+ points = SampleHyperbolicTrim(hyperbola, hyperbolaTrim, ComputeAdaptiveCircleSegmentCount(hyperbolaTrim.End - hyperbolaTrim.Start));+ break;case CurveGeometryKind.BSpline3:var spline = curve.BSpline3!.Value;var splineTrim = edgeBinding.TrimInterval ?? new ParameterInterval(spline.DomainStart, spline.DomainEnd);@@ -3294,6 +3368,14 @@ public static class Step242Importerreturn points;}+ private static List<Point3D> SampleHyperbolicTrim(Hyperbola3Curve hyperbola, ParameterInterval trim, int segmentCount)+ {+ var points = new List<Point3D>(segmentCount + 1);+ var step = (trim.End - trim.Start) / segmentCount;+ for (var i = 0; i <= segmentCount; i++) points.Add(hyperbola.Evaluate(trim.Start + (step * i)));+ return points;+ }+private static void ReportCircularSamplingDiagnostic(LoopRoleCircularSamplingDiagnostic diagnostic){var sink = CircularSamplingDiagnosticsSink.Value;@@ -3569,6 +3651,12 @@ public static class Step242Importerprivate static KernelResult<double> FailureEllipseTrimAngle(string message, string source) =>Step242ImportSharedUtilities.ValidationFailure<double>(message, source);+ private static KernelResult<ParameterInterval> FailureHyperbolaTrim(string message, string source) =>+ Step242ImportSharedUtilities.ValidationFailure<ParameterInterval>(message, source);++ private static KernelResult<double> FailureHyperbolaTrimParameter(string message, string source) =>+ Step242ImportSharedUtilities.ValidationFailure<double>(message, source);+private static KernelResult<T> OrientationFailure<T>(string message, string source) =>KernelResult<T>.Failure([new KernelDiagnostic(KernelDiagnosticCode.ValidationFailed, KernelDiagnosticSeverity.Error, message, source)]);diff --git a/Aetheris.Kernel.Core/Step242/Step242SubsetDecoder.cs b/Aetheris.Kernel.Core/Step242/Step242SubsetDecoder.csindex 60f4ae9e..6690491e 100644--- a/Aetheris.Kernel.Core/Step242/Step242SubsetDecoder.cs+++ b/Aetheris.Kernel.Core/Step242/Step242SubsetDecoder.cs@@ -320,6 +320,15 @@ internal static class Step242SubsetDecoder: KernelResult<CurveGeometry>.Success(CurveGeometry.FromEllipse(ellipseResult.Value));}+ var hyperbolaConstructor = TryGetConstructor(curveEntity.Instance, "HYPERBOLA");+ if (hyperbolaConstructor is not null)+ {+ var hyperbolaResult = ReadHyperbolaCurve(document, new Step242ParsedEntity(curveEntity.Id, new Step242SimpleEntityInstance(hyperbolaConstructor)));+ return !hyperbolaResult.IsSuccess+ ? KernelResult<CurveGeometry>.Failure(hyperbolaResult.Diagnostics)+ : KernelResult<CurveGeometry>.Success(CurveGeometry.FromHyperbola(hyperbolaResult.Value));+ }+return Failure<CurveGeometry>($"{context}: directrix curve '{curveEntity.Name}' is unsupported.", source);}@@ -498,6 +507,46 @@ internal static class Step242SubsetDecoder}}+ /// <summary>+ /// Decodes the exact STEP HYPERBOLA support. STEP stores one branch through its+ /// AXIS2_PLACEMENT_3D; the imported support is therefore canonicalized to PositiveAxisU.+ /// </summary>+ public static KernelResult<Hyperbola3Curve> ReadHyperbolaCurve(Step242ParsedDocument document, Step242ParsedEntity hyperbolaEntity)+ {+ var placementResult = ReadAxis2Placement3D(document, hyperbolaEntity, 1, "HYPERBOLA position", "Importer.Geometry.Hyperbola");+ if (!placementResult.IsSuccess)+ {+ return KernelResult<Hyperbola3Curve>.Failure(placementResult.Diagnostics);+ }++ var semiAxisResult = ReadPositiveNumber(hyperbolaEntity, 2, "HYPERBOLA semi_axis", "Importer.Geometry.Hyperbola");+ if (!semiAxisResult.IsSuccess)+ {+ return KernelResult<Hyperbola3Curve>.Failure(semiAxisResult.Diagnostics);+ }++ var semiImaginaryAxisResult = ReadPositiveNumber(hyperbolaEntity, 3, "HYPERBOLA semi_imaginary_axis", "Importer.Geometry.Hyperbola");+ if (!semiImaginaryAxisResult.IsSuccess)+ {+ return KernelResult<Hyperbola3Curve>.Failure(semiImaginaryAxisResult.Diagnostics);+ }++ try+ {+ return KernelResult<Hyperbola3Curve>.Success(new Hyperbola3Curve(+ placementResult.Value.Origin,+ placementResult.Value.Axis,+ placementResult.Value.ReferenceAxis,+ semiAxisResult.Value,+ semiImaginaryAxisResult.Value,+ HyperbolaBranch.PositiveAxisU));+ }+ catch (ArgumentException)+ {+ return FailureHyperbola("Invalid HYPERBOLA placement produced a degenerate frame.", "Importer.Geometry.HyperbolaFrameInvalid");+ }+ }+public static KernelResult<BSpline3Curve> ReadBSplineCurveWithKnots(Step242ParsedDocument document, Step242ParsedEntity splineEntity){var degreeResult = ReadIntArgument(splineEntity, 1, "B_SPLINE_CURVE_WITH_KNOTS degree", "Importer.Geometry.BSplineCurve");@@ -1357,6 +1406,8 @@ internal static class Step242SubsetDecoderprivate static KernelResult<Ellipse3Curve> FailureEllipse(string message, string source) => Failure<Ellipse3Curve>(KernelDiagnosticCode.InvalidArgument, message, source);+ private static KernelResult<Hyperbola3Curve> FailureHyperbola(string message, string source) => Failure<Hyperbola3Curve>(KernelDiagnosticCode.InvalidArgument, message, source);+private static KernelResult<BSpline3Curve> FailureBSplineCurve(string message, string source) => Failure<BSpline3Curve>(KernelDiagnosticCode.InvalidArgument, message, source);private static KernelResult<CylinderSurface> FailureCylinder(string message, string source) => Failure<CylinderSurface>(KernelDiagnosticCode.InvalidArgument, message, source);diff --git a/Aetheris.Kernel.Firmament.Tests/PrismaticSectionStackPlanMaterializationTests.cs b/Aetheris.Kernel.Firmament.Tests/PrismaticSectionStackPlanMaterializationTests.csnew file mode 100644index 00000000..daa590f8--- /dev/null+++ b/Aetheris.Kernel.Firmament.Tests/PrismaticSectionStackPlanMaterializationTests.cs@@ -0,0 +1,44 @@+using Aetheris.Kernel.Firmament.Materializer;++namespace Aetheris.Kernel.Firmament.Tests;++public sealed class PrismaticSectionStackPlanMaterializationTests+{+ [Fact]+ public void PlanFirstMaterialization_PreservesConstructionFaceMappings()+ {+ var parsed = PrismaticProfileCompositionParser.Parse(Source);+ var stack = Assert.IsType<PrismaticSectionStackConstruction>(PrismaticSectionStackCompiler.Normalize(parsed, out var diagnostics));+ Assert.Empty(diagnostics);++ var planned = PrismaticSectionStackEmitter.TryPlan(stack);+ var summary = Assert.IsType<PrismaticSectionStackBrepPlan>(planned.Plan);+ var topology = Assert.IsType<PrismaticSectionStackTopologyPlan>(summary.TopologyPlan);+ var materialized = PrismaticSectionStackBrepMaterializer.TryMaterialize(topology);++ Assert.NotNull(materialized.Body);+ Assert.Empty(materialized.Diagnostics);+ Assert.Equal(summary.Faces, materialized.Body!.Topology.Faces.Count());+ Assert.Equal(summary.Edges, materialized.Body.Topology.Edges.Count());+ Assert.NotEmpty(topology.FaceMappings);+ Assert.All(topology.FaceMappings.Where(x => x.Kind == "PrismaticSide"), mapping =>+ {+ Assert.NotNull(mapping.SlabFrom);+ Assert.NotNull(mapping.SlabTo);+ Assert.NotEmpty(mapping.SourceStableId);+ Assert.True(topology.Bindings.TryGetFaceBinding(mapping.FaceId, out _));+ });+ Assert.Contains("compose-plan-first-materialization-boundary", planned.Diagnostics);+ }++ private const string Source = """+ Concept Struct Layout On XY { Rect2 Guide { Center: [0mm, 0mm]; Size: [20mm, 12mm] } }+ Profile Stock Using Layout { Loop Outer {+ Segment South { Trace: Guide.Bottom; From: Guide.BottomLeft; To: Guide.BottomRight }+ Segment East { Trace: Guide.Right; From: Guide.BottomRight; To: Guide.TopRight }+ Segment North { Trace: Guide.Top; From: Guide.TopRight; To: Guide.TopLeft }+ Segment West { Trace: Guide.Left; From: Guide.TopLeft; To: Guide.BottomLeft }+ } }+ Struct Composition { Compose Host { Base Lower { Profile: Stock; From: 0mm; To: 5mm } Add Upper { Profile: Stock; From: 5mm; To: 10mm } } }+ """;+}diff --git a/Aetheris.Kernel.Firmament.Tests/SectionStackBlindDrillCavityPlanTests.cs b/Aetheris.Kernel.Firmament.Tests/SectionStackBlindDrillCavityPlanTests.csnew file mode 100644index 00000000..14bba146--- /dev/null+++ b/Aetheris.Kernel.Firmament.Tests/SectionStackBlindDrillCavityPlanTests.cs@@ -0,0 +1,102 @@+using Aetheris.Kernel.Core.Air;+using Aetheris.Kernel.Core.Brep.Verification;+using Aetheris.Kernel.Core.Math;+using Aetheris.Kernel.Core.Step242;+using Aetheris.Kernel.Firmament.Materializer;++namespace Aetheris.Kernel.Firmament.Tests;++public sealed class SectionStackBlindDrillCavityPlanTests+{+ [Fact]+ public void ComposeSource_ConstructionPlaneBlindDrill_UsesFullRadiusClearanceAndExportsOneBlindCavity()+ {+ var source = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "../../../../fixtures/FirmamentV2/ProfileComposition/valid/construction-plane-blind-drill-clearance.firmament"));+ var output = Path.Combine(Path.GetTempPath(), "aetheris-compose-blind-drill-" + Guid.NewGuid().ToString("N") + ".step");+ try+ {+ var exported = FirmamentBuildAndExport.Run(source, output);+ Assert.True(exported.IsSuccess, string.Join(" | ", exported.Diagnostics.Select(x => x.Message)));+ var imported = Step242Importer.ImportBody(File.ReadAllText(output));+ Assert.True(imported.IsSuccess, string.Join(" | ", imported.Diagnostics.Select(x => x.Message)));+ var mass = BrepMassProperties.Evaluate(imported.Value);+ Assert.True(mass.IsEnclosed, string.Join(" | ", mass.Diagnostics));+ Assert.True(mass.IsOrientationConsistent, string.Join(" | ", mass.Diagnostics));+ Assert.Contains(imported.Value.Geometry.Surfaces.Select(x => x.Value), x => x.Kind == Aetheris.Kernel.Core.Geometry.SurfaceGeometryKind.Cylinder);+ Assert.Contains(imported.Value.Geometry.Surfaces.Select(x => x.Value), x => x.Kind == Aetheris.Kernel.Core.Geometry.SurfaceGeometryKind.Cone);+ }+ finally+ {+ if (File.Exists(output)) File.Delete(output);+ }+ }++ [Fact]+ public void ComposeSource_MouthCrossingInternalSlabIsRejectedBeforeTopologyMaterialization()+ {+ var source = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "../../../../fixtures/FirmamentV2/ProfileComposition/invalid/construction-plane-blind-drill-mouth-crosses-slab.firmament"));++ var exported = FirmamentBuildAndExport.Run(source, Path.Combine(Path.GetTempPath(), "aetheris-unreachable.step"));++ Assert.False(exported.IsSuccess);+ Assert.Contains(exported.Diagnostics, x => x.Message == "SectionStackBlindDrillMouthCrossesHostPlanningPartition");+ }++ [Fact]+ public void ProvenPlanarMouth_ReplacesHostFaceAndIntegratesOneBlindCavityShell()+ {+ var stack = Stack(); var host = PrismaticSectionStackEmitter.TryPlan(stack).Plan!;+ var placement = new AirConstructionPlaneHolePlacement("construction:+X", "concept:+X", new Point3D(-20, 0, 2),+ Direction3D.Create(new Vector3D(0, 1, 0)), Direction3D.Create(new Vector3D(0, 0, 1)), Direction3D.Create(new Vector3D(1, 0, 0)), 0, 0, "test", "test");+ var feature = AirHoleFeature.CreateConstructionPlaneSimpleShaft("SideBlind", "Host.SideBlind", "Host", placement, new AirHoleShaft(2),+ new AirHoleEndCondition.ShaftDepth(10), new AirProvenance("test", "test", "SideBlind", "Host.SideBlind", "test", AirSelectionClass.None, AirRuleKind.None, "test", true, []), new AirHoleTermination.DrillPoint());+ var corridor = TransverseBlindDrillToolCorridor.Prove(feature, stack, placement);+ Assert.Equal(BlindDrillToolCorridorClassification.CorridorProven, corridor.Classification);+ Assert.Equal(BlindDrillClearancePolicy.FullRadiusThroughTotalDepth, corridor.ValidationPolicy);+ Assert.All(corridor.ShaftSliceProofs, proof => Assert.Equal("FullRadiusClearance", proof.ToolPart));+ Assert.Empty(corridor.ConeSliceProofs);+ var mouthFace = host.TopologyPlan!.FaceMappings.Single(mapping => mapping.Kind == "PrismaticSide" && mapping.SourceStableId.Contains("West", StringComparison.Ordinal) && mapping.SlabFrom == 0d).FaceId;++ var cavity = SectionStackBlindDrillCavityPlanner.TryPlan(new(stack, host, feature, placement, corridor, mouthFace), out var diagnostics);++ Assert.NotNull(cavity); Assert.DoesNotContain(diagnostics, x => x.StartsWith("SectionStackBlindDrillMouth", StringComparison.Ordinal) || x.EndsWith("NotProven", StringComparison.Ordinal));+ Assert.Single(cavity!.FaceReplacements);+ var finalPlan = cavity.ReplacementHostPlan.TopologyPlan!;+ var materialized = PrismaticSectionStackBrepMaterializer.TryMaterialize(finalPlan);+ Assert.NotNull(materialized.Body); Assert.Empty(materialized.Diagnostics);+ var body = materialized.Body!;+ var mass = BrepMassProperties.Evaluate(body);+ Assert.True(mass.IsEnclosed, string.Join(" | ", mass.Diagnostics));+ Assert.True(mass.IsOrientationConsistent, string.Join(" | ", mass.Diagnostics));+ var expectedVolume = stack.AnalyticVolume - (Math.PI * feature.Shaft.Radius * feature.Shaft.Radius * corridor.ShaftDepth)+ - ((Math.PI * feature.Shaft.Radius * feature.Shaft.Radius * corridor.TipLength) / 3d);+ Assert.InRange(Math.Abs(mass.AbsoluteVolume - expectedVolume), 0d, mass.ErrorBound ?? 0d);+ Assert.Single(finalPlan.Correspondence.Descendants.Where(x => x.Role == SemanticTopologyRole.HoleEntryLoop));+ Assert.Single(finalPlan.Correspondence.Descendants.Where(x => x.Role == SemanticTopologyRole.HoleTipVertex));+ Assert.Empty(finalPlan.Correspondence.Descendants.Where(x => x.Role == SemanticTopologyRole.HoleExitLoop));+ Assert.Contains("SectionStackBlindDrillNoInternalCaps", cavity.Diagnostics);+ var step = Step242Exporter.ExportBody(body, new Step242ExportOptions { BrepExportPreflightMode = BrepExportPreflightMode.Enforce });+ Assert.True(step.IsSuccess, string.Join(" | ", step.Diagnostics.Select(x => x.Message)));+ var reimported = Step242Importer.ImportBody(step.Value);+ Assert.True(reimported.IsSuccess, string.Join(" | ", reimported.Diagnostics.Select(x => x.Message)));+ var reimportedMass = BrepMassProperties.Evaluate(reimported.Value);+ Assert.True(reimportedMass.IsEnclosed);+ Assert.InRange(Math.Abs(reimportedMass.AbsoluteVolume - expectedVolume), 0d, reimportedMass.ErrorBound ?? 0d);+ }++ private static PrismaticSectionStackConstruction Stack()+ {+ const string source = """+ Concept Struct Layout On XY { Rect2 Guide { Center: [0mm, 0mm]; Size: [40mm, 20mm] } }+ Profile Stock Using Layout { Loop Outer {+ Segment South { Trace: Guide.Bottom; From: Guide.BottomLeft; To: Guide.BottomRight }+ Segment East { Trace: Guide.Right; From: Guide.BottomRight; To: Guide.TopRight }+ Segment North { Trace: Guide.Top; From: Guide.TopRight; To: Guide.TopLeft }+ Segment West { Trace: Guide.Left; From: Guide.TopLeft; To: Guide.BottomLeft }+ } }+ Struct Composition { Compose Host { Base Lower { Profile: Stock; From: 0mm; To: 5mm } Add Upper { Profile: Stock; From: 5mm; To: 10mm } } }+ """;+ var parsed = PrismaticProfileCompositionParser.Parse(source);+ return Assert.IsType<PrismaticSectionStackConstruction>(PrismaticSectionStackCompiler.Normalize(parsed, out var diagnostics));+ }+}diff --git a/Aetheris.Kernel.Firmament.Tests/TransverseBlindDrillToolCorridorTests.cs b/Aetheris.Kernel.Firmament.Tests/TransverseBlindDrillToolCorridorTests.csindex e3ddbd4e..697cd7f3 100644--- a/Aetheris.Kernel.Firmament.Tests/TransverseBlindDrillToolCorridorTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/TransverseBlindDrillToolCorridorTests.cs@@ -7,16 +7,21 @@ namespace Aetheris.Kernel.Firmament.Tests;public sealed class TransverseBlindDrillToolCorridorTests{[Fact]- public void PlusXBlindDrill_ProvesCompleteShaftAndConeAcrossTwoZSlabs()+ public void PlusXBlindDrill_ProvesFullRadiusClearanceAcrossTwoZSlabs(){var stack = Stack(40, 20); var placement = Placement(); var feature = Feature(4, 10, placement);var proof = TransverseBlindDrillToolCorridor.Prove(feature, stack, placement);Assert.True(proof.Classification == BlindDrillToolCorridorClassification.CorridorProven, string.Join(" | ", proof.Diagnostics));+ Assert.Equal(BlindDrillClearancePolicy.FullRadiusThroughTotalDepth, proof.ValidationPolicy);Assert.Equal(2, proof.ShaftSliceProofs.Count);- Assert.Equal(2, proof.ConeSliceProofs.Count);- Assert.All(proof.ShaftSliceProofs.Concat(proof.ConeSliceProofs), x => Assert.Equal(SectionRectangleCorridorClassification.FullyContained, x.Classification));+ Assert.Empty(proof.ConeSliceProofs);+ Assert.All(proof.ShaftSliceProofs, x =>+ {+ Assert.Equal("FullRadiusClearance", x.ToolPart);+ Assert.Equal(SectionRectangleCorridorClassification.FullyContained, x.Classification);+ });Assert.Equal(10d, proof.ShaftDepth);Assert.InRange(proof.TipLength, 1.2d, 1.21d);}@@ -28,8 +33,8 @@ public sealed class TransverseBlindDrillToolCorridorTestsvar proof = TransverseBlindDrillToolCorridor.Prove(feature, stack, placement);- Assert.Equal(BlindDrillToolCorridorClassification.ShaftBoundaryCrossing, proof.Classification);- Assert.Contains(proof.Diagnostics, x => x.StartsWith("ToolCorridorFailure: part=Shaft", StringComparison.Ordinal));+ Assert.Equal(BlindDrillToolCorridorClassification.FullRadiusTipClearanceFailed, proof.Classification);+ Assert.Contains(proof.Diagnostics, x => x.StartsWith("ToolCorridorFailure: part=FullRadiusClearance", StringComparison.Ordinal));}private static PrismaticSectionStackConstruction Stack(double width, double depth)diff --git a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.csindex e7c67ac4..48662137 100644--- a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs+++ b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs@@ -59,6 +59,16 @@ public static class FirmamentBuildAndExportvar emitted = PrismaticSectionStackEmitter.Emit(stack);if (emitted.Body is null)return KernelResult<FirmamentStepExportResult>.Failure(emitted.Diagnostics.Select(x => new Kernel.Core.Diagnostics.KernelDiagnostic(Kernel.Core.Diagnostics.KernelDiagnosticCode.ValidationFailed, Kernel.Core.Diagnostics.KernelDiagnosticSeverity.Error, x, "FirmamentV2.ProfileComposition")).ToArray());+ if ((stack.Feature.ConstructionPlaneBlindDrills?.Count ?? 0) > 0)+ {+ var finalPlan = SectionStackBlindDrillComposeBridge.TryApply(stack, emitted.Plan!, out var bridgeDiagnostics, out _);+ if (finalPlan?.TopologyPlan is null)+ return KernelResult<FirmamentStepExportResult>.Failure(bridgeDiagnostics.Select(x => new Kernel.Core.Diagnostics.KernelDiagnostic(Kernel.Core.Diagnostics.KernelDiagnosticCode.ValidationFailed, Kernel.Core.Diagnostics.KernelDiagnosticSeverity.Error, x, "FirmamentV2.ProfileComposition.BlindDrill")).ToArray());+ var materialized = PrismaticSectionStackBrepMaterializer.TryMaterialize(finalPlan.TopologyPlan);+ if (materialized.Body is null)+ return KernelResult<FirmamentStepExportResult>.Failure(materialized.Diagnostics.Select(x => new Kernel.Core.Diagnostics.KernelDiagnostic(Kernel.Core.Diagnostics.KernelDiagnosticCode.ValidationFailed, Kernel.Core.Diagnostics.KernelDiagnosticSeverity.Error, x, "FirmamentV2.ProfileComposition.BlindDrill")).ToArray());+ emitted = new PrismaticSectionStackEmissionResult(materialized.Body, finalPlan, emitted.Diagnostics.Concat(bridgeDiagnostics).ToArray(), finalPlan.Correspondence);+ }if (sourceText.Contains("EdgeFinish", StringComparison.Ordinal))return ExportComposedSemanticTopBoundaryChamfer(sourceText, parsed, stack, emitted);var step = Step242Exporter.ExportBody(emitted.Body);diff --git a/Aetheris.Kernel.Firmament/Materializer/PrismaticProfileComposition.cs b/Aetheris.Kernel.Firmament/Materializer/PrismaticProfileComposition.csindex e617ffe0..8654c9ba 100644--- a/Aetheris.Kernel.Firmament/Materializer/PrismaticProfileComposition.cs+++ b/Aetheris.Kernel.Firmament/Materializer/PrismaticProfileComposition.cs@@ -1,5 +1,7 @@using System.Globalization;using System.Text.RegularExpressions;+using Aetheris.Kernel.Core.Math;+using Aetheris.Kernel.Firmament.FirmamentV2;namespace Aetheris.Kernel.Firmament.Materializer;@@ -15,6 +17,13 @@ public sealed record PrismaticProfileOperation(public sealed record PrismaticShaftHoleFeature(string Name, string StableId, string ProfileReference, double CenterX, double CenterY, double Diameter,double From, double To, string SemanticRole, string SourceSpan);+/// <summary>Source-owned transverse blind drill; its cavity is planned after host construction.</summary>+public sealed record PrismaticConstructionPlaneBlindDrillFeature(+ string Name, string StableId, string ConstructionPlaneId, string SourceConceptPlaneId,+ Point3D FrameOrigin, Direction3D AxisX, Direction3D AxisY, Direction3D AxisZ,+ double LocalCenterX, double LocalCenterY, double Diameter, double DeclaredDepth,+ bool DeclaredDepthIsTotal, double PointAngleDegrees, string SemanticRole, string SourceSpan,+ string Provenance);/// <summary>Compiler-owned capsule contract; the generated Profile remains lowering detail.</summary>public sealed record PrismaticCapsuleSlotFeature(string Name, string StableId, string ProfileReference, double CenterX, double CenterY,@@ -36,7 +45,8 @@ public sealed record PrismaticProfileCompositionFeature(string Name, string Frame, string Axis, PrismaticProfilePlacement Placement, IReadOnlyList<PrismaticProfileOperation> Operations,IReadOnlyList<double> CriticalLevels, string Provenance, IReadOnlyList<PrismaticShaftHoleFeature>? ShaftHoles = null,IReadOnlyList<PrismaticCapsuleSlotFeature>? CapsuleSlots = null,- IReadOnlyList<PrismaticRoundedRectangleSlotFeature>? RoundedRectangleSlots = null)+ IReadOnlyList<PrismaticRoundedRectangleSlotFeature>? RoundedRectangleSlots = null,+ IReadOnlyList<PrismaticConstructionPlaneBlindDrillFeature>? ConstructionPlaneBlindDrills = null){public IEnumerable<(string Name, string StableId, string ProfileReference)> AllSlotProfiles =>(CapsuleSlots ?? []).Select(x => (x.Name, x.StableId, x.ProfileReference))@@ -73,8 +83,12 @@ public static class PrismaticProfileCompositionParserprivate static readonly Regex Operation = new(@"\b(?<intent>Base|Add|Remove)\s+(?<n>\w+)\s*\{\s*Profile\s*:\s*(?<profile>\w+)\s*;?\s*From\s*:\s*(?<from>[-+.\d]+)mm\s*;?\s*To\s*:\s*(?<to>[-+.\d]+)mm(?:\s*;?\s*Role\s*:\s*(?<role>\w+))?", RegexOptions.Singleline | RegexOptions.CultureInvariant);private static readonly Regex HoleHeader = new(@"\bHole\s*<\s*(?<variant>\w+)\s*>\s+(?<n>\w+)\s*\{", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);private static readonly Regex HoleCenter = new(@"\bCenter\s*:\s*\[(?<x>[-+.\d]+)mm\s*,\s*(?<y>[-+.\d]+)mm\]", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);+ private static readonly Regex HolePoint2Center = new(@"\bCenter\s*:\s*Point2\s*\(\s*(?<x>[-+.\d]+)mm\s*,\s*(?<y>[-+.\d]+)mm\s*\)", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);private static readonly Regex HoleDiameter = new(@"\bDiameter\s*:\s*(?<d>[-+.\d]+)mm", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);private static readonly Regex HoleEnd = new(@"\bEnd\s*:\s*(?<end>\w+)", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);+ private static readonly Regex HoleDepthEnd = new(@"\bEnd\s*:\s*(?<kind>ShaftDepth|TotalDepth)\s*\(\s*(?<depth>[-+.\d]+)mm\s*\)", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);+ private static readonly Regex HoleFrom = new(@"\bFrom\s*:\s*(?<plane>\w+)", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);+ private static readonly Regex HoleTermination = new(@"\bTermination\s*:\s*DrillPoint\b(?:\s*\{\s*PointAngle\s*:\s*(?<angle>[-+.\d]+)deg\s*\})?", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);private static readonly Regex HoleRole = new(@"\bRole\s*:\s*(?<role>\w+)", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);private static readonly Regex SlotHeader = new(@"\bSlot\s*<\s*(?<variant>\w+)\s*>\s+(?<n>\w+)\s*\{", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);private static readonly Regex SlotCenter = new(@"\bCenter\s*:\s*(?:Point2\s*\()?\[?(?<x>[-+.\d]+)mm\s*,\s*(?<y>[-+.\d]+)mm\]?\)?", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);@@ -177,6 +191,7 @@ public static class PrismaticProfileCompositionParser}if (operations.Count(o => o.Intent == PrismaticProfileIntent.Base) != 1) diagnostics.Add("compose-requires-exactly-one-base-operation");var shaftHoles = new List<PrismaticShaftHoleFeature>();+ var constructionPlaneBlindDrills = new List<PrismaticConstructionPlaneBlindDrillFeature>();var capsuleSlots = new List<PrismaticCapsuleSlotFeature>();var roundedRectangleSlots = new List<PrismaticRoundedRectangleSlotFeature>();var materialFrom = operations.Count == 0 ? 0d : operations.Min(x => x.From);@@ -186,7 +201,32 @@ public static class PrismaticProfileCompositionParservar name = header.Groups["n"].Value;var body = Block(composeBody, header.Index + header.Length - 1);if (body is null) { diagnostics.Add($"compose-hole-unclosed:{name}"); continue; }- var center = HoleCenter.Match(body); var diameter = HoleDiameter.Match(body); var end = HoleEnd.Match(body); var role = HoleRole.Match(body);+ var center = HoleCenter.Match(body); if (!center.Success) center = HolePoint2Center.Match(body);+ var diameter = HoleDiameter.Match(body); var end = HoleEnd.Match(body); var role = HoleRole.Match(body);+ var from = HoleFrom.Match(body); var depthEnd = HoleDepthEnd.Match(body); var termination = HoleTermination.Match(body);+ if (from.Success)+ {+ if (!string.Equals(header.Groups["variant"].Value, "Shaft", StringComparison.OrdinalIgnoreCase)+ || !depthEnd.Success || !termination.Success)+ { diagnostics.Add($"compose-construction-plane-blind-hole-invalid-contract:{name}"); continue; }+ if (!center.Success || !diameter.Success) { diagnostics.Add($"compose-construction-plane-blind-hole-missing-center-or-diameter:{name}"); continue; }+ var trace = ResolveConstructionPlaneTrace(source, from.Groups["plane"].Value);+ string? planeDiagnostic = null; string? frameDiagnostic = null;+ if (trace is null || !ConceptIrResolver.TryResolvePlane(source, trace, out var conceptPlane, out planeDiagnostic)+ || conceptPlane is null+ || !ConstructionPlane.TryTrace($"construction:{from.Groups["plane"].Value}", conceptPlane, $"offset:{header.Index}", out var plane, out frameDiagnostic))+ { diagnostics.Add(planeDiagnostic ?? frameDiagnostic ?? $"compose-construction-plane-not-found:{from.Groups["plane"].Value}"); continue; }+ var localX = N(center, "x"); var localY = N(center, "y"); var localDiameter = N(diameter, "d"); var declaredDepth = N(depthEnd, "depth");+ var angle = termination.Groups["angle"].Success ? N(termination, "angle") : 118d;+ if (!double.IsFinite(localX) || !double.IsFinite(localY) || !double.IsFinite(localDiameter) || localDiameter <= 0d || !double.IsFinite(declaredDepth) || declaredDepth < 0d || !double.IsFinite(angle) || angle <= 0d || angle >= 180d)+ { diagnostics.Add($"compose-construction-plane-blind-hole-invalid-geometry:{name}"); continue; }+ if (!names.Add(name)) { diagnostics.Add($"compose-duplicate-operation:{name}"); continue; }+ var blindStableId = $"hole:{compose.Groups["n"].Value}.{name}";+ constructionPlaneBlindDrills.Add(new(name, blindStableId, plane!.StableId, plane.SourceConceptId, plane.Origin, plane.AxisX, plane.AxisY, plane.AxisZ,+ localX, localY, localDiameter, declaredDepth, string.Equals(depthEnd.Groups["kind"].Value, "TotalDepth", StringComparison.OrdinalIgnoreCase), angle,+ role.Success ? role.Groups["role"].Value : "BlindDrillPoint", $"offset:{header.Index}", plane.Provenance));+ continue;+ }if (!string.Equals(header.Groups["variant"].Value, "Shaft", StringComparison.OrdinalIgnoreCase)|| !end.Success || !string.Equals(end.Groups["end"].Value, "ThroughAll", StringComparison.OrdinalIgnoreCase)){ diagnostics.Add($"compose-hole-unsupported-variant-or-end:{name}"); continue; }@@ -239,7 +279,7 @@ public static class PrismaticProfileCompositionParser}}var levels = operations.SelectMany(o => new[] { o.From, o.To }).Distinct().Order().ToArray();- var feature = diagnostics.Count == 0 ? new PrismaticProfileCompositionFeature(compose.Groups["n"].Value, "XY", "+Z", placement, operations, levels, "parser-backed-scaffold-profile-composition", shaftHoles, capsuleSlots, roundedRectangleSlots) : null;+ var feature = diagnostics.Count == 0 ? new PrismaticProfileCompositionFeature(compose.Groups["n"].Value, "XY", "+Z", placement, operations, levels, "parser-backed-scaffold-profile-composition", shaftHoles, capsuleSlots, roundedRectangleSlots, constructionPlaneBlindDrills) : null;return new(feature, profiles, diagnostics.Distinct().ToArray(), expansion.Evidence);}@@ -273,6 +313,11 @@ public static class PrismaticProfileCompositionParser}private static double N(Match match, string name) => double.Parse(match.Groups[name].Value, CultureInfo.InvariantCulture);+ private static string? ResolveConstructionPlaneTrace(string source, string name)+ {+ var declaration = Regex.Match(source, $@"\bConstruction\s+Plane\s+{Regex.Escape(name)}\s*\{{\s*Trace\s*:\s*(?<trace>[A-Za-z_][A-Za-z0-9_]*\.[A-Za-z_][A-Za-z0-9_]*)", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);+ return declaration.Success ? declaration.Groups["trace"].Value : null;+ }private static string? Block(string text, int open){var depth = 0;diff --git a/Aetheris.Kernel.Firmament/Materializer/PrismaticSectionStackCompiler.cs b/Aetheris.Kernel.Firmament/Materializer/PrismaticSectionStackCompiler.csindex fba33306..8a0bbc1c 100644--- a/Aetheris.Kernel.Firmament/Materializer/PrismaticSectionStackCompiler.cs+++ b/Aetheris.Kernel.Firmament/Materializer/PrismaticSectionStackCompiler.cs@@ -7,8 +7,75 @@ using Aetheris.Kernel.Core.Topology;namespace Aetheris.Kernel.Firmament.Materializer;-public sealed record PrismaticSectionStackBrepPlan(string Signature, int Vertices, int Edges, int Faces, string Policy, bool Authoritative, SemanticTopologyCorrespondence? Correspondence = null);+/// <summary>Construction-owned face identity used by feature planners; never recovered from final geometry.</summary>+public sealed record PrismaticSectionStackFacePlanMapping(+ FaceId FaceId, string Kind, string SourceStableId, string ConstructionStableId,+ double? SlabFrom, double? SlabTo, IReadOnlyList<string> Provenance);++/// <summary>+/// Immutable-by-convention entity plan for a normalized section stack. The+/// materializer may instantiate this topology but must not decide its faces,+/// senses, bindings, or provenance.+/// </summary>+public sealed record PrismaticSectionStackTopologyPlan(+ string StableId, TopologyModel Topology, BrepGeometryStore Geometry, BrepBindingModel Bindings,+ IReadOnlyDictionary<VertexId, Point3D> VertexPoints, IReadOnlyList<PrismaticSectionStackFacePlanMapping> FaceMappings,+ SemanticTopologyCorrespondence Correspondence, IReadOnlyList<string> Provenance);++public sealed record PrismaticSectionStackBrepPlan(string Signature, int Vertices, int Edges, int Faces, string Policy, bool Authoritative,+ SemanticTopologyCorrespondence? Correspondence = null, PrismaticSectionStackTopologyPlan? TopologyPlan = null);public sealed record PrismaticSectionStackEmissionResult(BrepBody? Body, PrismaticSectionStackBrepPlan? Plan, IReadOnlyList<string> Diagnostics, SemanticTopologyCorrespondence? Correspondence = null);+public sealed record PrismaticSectionStackPlanResult(PrismaticSectionStackBrepPlan? Plan, IReadOnlyList<string> Diagnostics, SemanticTopologyCorrespondence? Correspondence = null);++/// <summary>Instantiates a section-stack body from a fully-decided plan.</summary>+public static class PrismaticSectionStackBrepMaterializer+{+ public static (BrepBody? Body, IReadOnlyList<string> Diagnostics) TryMaterialize(PrismaticSectionStackTopologyPlan plan)+ {+ var diagnostics = new List<string>();+ if (plan.Topology.Bodies.Count() != 1 || plan.Topology.Shells.Count() != 1)+ diagnostics.Add("SectionStackPlanInvalidShellCardinality");+ foreach (var face in plan.Topology.Faces)+ if (!plan.Bindings.TryGetFaceBinding(face.Id, out _)) diagnostics.Add($"SectionStackPlanMissingFaceBinding:face={face.Id.Value}");+ foreach (var edge in plan.Topology.Edges)+ if (!plan.Bindings.TryGetEdgeBinding(edge.Id, out _)) diagnostics.Add($"SectionStackPlanMissingEdgeBinding:edge={edge.Id.Value}");+ if (diagnostics.Count != 0) return (null, diagnostics);+ // A body must not share the plan's mutable backing stores. Feature+ // planners can retain the immutable plan as the authority while the+ // materialized body remains an independently instantiable snapshot.+ return (new BrepBody(CloneTopology(plan.Topology), CloneGeometry(plan.Geometry), CloneBindings(plan.Bindings),+ plan.VertexPoints.ToDictionary(x => x.Key, x => x.Value)), diagnostics);+ }++ private static TopologyModel CloneTopology(TopologyModel source)+ {+ var clone = new TopologyModel();+ foreach (var vertex in source.Vertices.OrderBy(x => x.Id.Value)) clone.AddVertex(vertex);+ foreach (var edge in source.Edges.OrderBy(x => x.Id.Value)) clone.AddEdge(edge);+ foreach (var coedge in source.Coedges.OrderBy(x => x.Id.Value)) clone.AddCoedge(coedge);+ foreach (var loop in source.Loops.OrderBy(x => x.Id.Value)) clone.AddLoop(new Loop(loop.Id, loop.CoedgeIds.ToArray()));+ foreach (var face in source.Faces.OrderBy(x => x.Id.Value)) clone.AddFace(new Face(face.Id, face.LoopIds.ToArray()));+ foreach (var shell in source.Shells.OrderBy(x => x.Id.Value)) clone.AddShell(new Shell(shell.Id, shell.FaceIds.ToArray()));+ foreach (var body in source.Bodies.OrderBy(x => x.Id.Value)) clone.AddBody(new Body(body.Id, body.ShellIds.ToArray()));+ return clone;+ }++ private static BrepGeometryStore CloneGeometry(BrepGeometryStore source)+ {+ var clone = new BrepGeometryStore();+ foreach (var curve in source.Curves.OrderBy(x => x.Key.Value)) clone.AddCurve(curve.Key, curve.Value);+ foreach (var surface in source.Surfaces.OrderBy(x => x.Key.Value)) clone.AddSurface(surface.Key, surface.Value);+ return clone;+ }++ private static BrepBindingModel CloneBindings(BrepBindingModel source)+ {+ var clone = new BrepBindingModel();+ foreach (var binding in source.EdgeBindings.OrderBy(x => x.EdgeId.Value)) clone.AddEdgeBinding(binding);+ foreach (var binding in source.FaceBindings.OrderBy(x => x.FaceId.Value)) clone.AddFaceBinding(binding);+ return clone;+ }+}/// <summary>Normalizes bounded line/arc Profiles through a planar material arrangement into slabs.</summary>public static class PrismaticSectionStackCompiler@@ -76,6 +143,19 @@ public static class PrismaticSectionStackEmitter{private const double Tol = 1e-6;public static PrismaticSectionStackEmissionResult Emit(PrismaticSectionStackConstruction stack)+ {+ var planned = TryPlan(stack);+ if (planned.Plan?.TopologyPlan is null) return new(null, planned.Plan, planned.Diagnostics, planned.Correspondence);+ var materialized = PrismaticSectionStackBrepMaterializer.TryMaterialize(planned.Plan.TopologyPlan);+ return new(materialized.Body, planned.Plan, planned.Diagnostics.Concat(materialized.Diagnostics).Distinct().ToArray(), planned.Correspondence);+ }++ /// <summary>+ /// The authoritative construction phase. It makes every topology and+ /// provenance decision before the materializer is permitted to create a+ /// <see cref="BrepBody"/>.+ /// </summary>+ public static PrismaticSectionStackPlanResult TryPlan(PrismaticSectionStackConstruction stack){var d = stack.Diagnostics.ToList();var builder = new TopologyBuilder(); var points = new Dictionary<VertexId, Point3D>(); var curves = new Dictionary<EdgeId, CurveGeometry>(); var profileCurves = new Dictionary<EdgeId, LineArcProfileCurve2D>();@@ -136,7 +216,6 @@ public static class PrismaticSectionStackEmittervar a = points[edge.StartVertexId]; var b = points[edge.EndVertexId];d.Add($"compose-rejected:non-manifold-edge-use:edge={incidence.Key.Value}:uses={incidence.Count()}:curve={curves[incidence.Key].Kind}:from=({a.X:R},{a.Y:R},{a.Z:R}):to=({b.X:R},{b.Y:R},{b.Z:R})");}- var body = new BrepBody(builder.Model, geometry, bindings, points);var descendants = new List<SemanticTopologyDescendant>();var topLevels = stack.Feature.Operations.GroupBy(x => x.ProfileReference, StringComparer.Ordinal).ToDictionary(x => x.Key, x => x.Max(y => y.To), StringComparer.Ordinal);var bottomLevels = stack.Feature.Operations.GroupBy(x => x.ProfileReference, StringComparer.Ordinal).ToDictionary(x => x.Key, x => x.Min(y => y.From), StringComparer.Ordinal);@@ -223,9 +302,22 @@ public static class PrismaticSectionStackEmitterif ((stack.Feature.ShaftHoles?.Count ?? 0) > 0) provenance.Insert(0, "SemanticHoleComposeLowering");if (stack.Feature.AllSlotProfiles.Any()) provenance.Insert(0, "SemanticSlotComposeLowering");var correspondence = new SemanticTopologyCorrespondence(stack.Feature.Name, descendants.DistinctBy(x => x.StableId).ToArray(), provenance);- var plan = new PrismaticSectionStackBrepPlan($"compose:{stack.Feature.Name}:slabs={stack.Slabs.Count}:transitions={stack.Transitions.Count}", points.Count, builder.Model.Edges.Count(), faces.Count, "deterministic-slab-partitions", true, correspondence);+ var faceMappings = new List<PrismaticSectionStackFacePlanMapping>();+ foreach (var cap in capFaces)+ faceMappings.Add(new(cap.Face, "TransitionCap", $"transition:{cap.Z:R}", $"transition:{cap.Z:R}", null, null,+ ["PrismaticSectionTransition", cap.Up ? "UpwardRegion" : "DownwardRegion"]));+ for (var i = 0; i < sideFaces.Count; i++)+ {+ var side = sideFaces[i]; var face = faces[capFaces.Count + i];+ faceMappings.Add(new(face, "PrismaticSide", side.Source, side.Construction, side.From, side.To,+ ["PrismaticSectionStackConstruction", "ProfileArrangement2D", side.Source, side.Construction]));+ }+ var topologyPlan = new PrismaticSectionStackTopologyPlan($"compose-plan:{stack.Feature.Name}", builder.Model, geometry, bindings,+ points.ToDictionary(x => x.Key, x => x.Value), faceMappings, correspondence, provenance);+ var plan = new PrismaticSectionStackBrepPlan($"compose:{stack.Feature.Name}:slabs={stack.Slabs.Count}:transitions={stack.Transitions.Count}", points.Count, builder.Model.Edges.Count(), faces.Count, "deterministic-slab-partitions", true, correspondence, topologyPlan);d.Add("compose-authoritative-section-stack-brep-plan"); d.Add("compose-no-3d-boolean-used");- return new(body, plan, d.Distinct().ToArray(), correspondence);+ d.Add("compose-plan-first-materialization-boundary");+ return new(plan, d.Distinct().ToArray(), correspondence);}private static FaceId AddCap(TopologyBuilder builder, PrismaticSectionRegion region, double z, Func<LineArcProfileCurve2D, double, (EdgeId Edge, bool Reverse)> edge, IReadOnlyList<(double X, double Y)> splitPoints){diff --git a/Aetheris.Kernel.Firmament/Materializer/SectionStackBlindDrillCavityPlan.cs b/Aetheris.Kernel.Firmament/Materializer/SectionStackBlindDrillCavityPlan.csnew file mode 100644index 00000000..f4b96450--- /dev/null+++ b/Aetheris.Kernel.Firmament/Materializer/SectionStackBlindDrillCavityPlan.cs@@ -0,0 +1,216 @@+using Aetheris.Kernel.Core.Air;+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-owned input for the narrow blind-drill topology operation. The+/// mouth face is supplied by construction provenance; this planner never+/// searches a materialized body for a geometrically similar face.+/// </summary>+internal sealed record SectionStackBlindDrillCavityInput(+ PrismaticSectionStackConstruction Host,+ PrismaticSectionStackBrepPlan HostPlan,+ AirHoleFeature Hole,+ AirConstructionPlaneHolePlacement Placement,+ BlindDrillToolCorridorEvidence Corridor,+ FaceId MouthHostFaceId);++internal sealed record SectionStackHostFaceReplacement(FaceId OriginalFaceId, IReadOnlyList<FaceId> ReplacementFaceIds);++internal sealed record SectionStackBlindDrillCavityPlan(+ string StableId,+ PrismaticSectionStackBrepPlan SourceHostPlan,+ PrismaticSectionStackBrepPlan ReplacementHostPlan,+ IReadOnlyList<SectionStackHostFaceReplacement> FaceReplacements,+ IReadOnlyList<string> Diagnostics);++/// <summary>+/// Exact topology insertion for one proven blind cavity whose circular mouth is+/// wholly inside one construction-provided planar host side face. This is not+/// a Boolean: the original face is replaced in the plan and the cylinder/cone+/// walls are wired directly into the same shell.+/// </summary>+internal static class SectionStackBlindDrillCavityPlanner+{+ private const double Tol = 1e-7;++ public static SectionStackBlindDrillCavityPlan? TryPlan(SectionStackBlindDrillCavityInput input, out IReadOnlyList<string> diagnostics)+ {+ var d = new List<string>();+ if (input.Corridor.Classification != BlindDrillToolCorridorClassification.CorridorProven)+ d.Add("SectionStackBlindDrillCorridorNotProven");+ if (input.Corridor.ValidationPolicy != BlindDrillClearancePolicy.FullRadiusThroughTotalDepth)+ d.Add("SectionStackBlindDrillUnsupportedClearancePolicy");+ var point = input.Hole.Termination as AirHoleTermination.DrillPoint;+ if (point is null || input.Hole.EndCondition is AirHoleEndCondition.ThroughAll)+ d.Add("SectionStackBlindDrillRequiresBlindDrillPoint");+ var source = input.HostPlan.TopologyPlan;+ if (source is null)+ d.Add("SectionStackBlindDrillMissingAuthoritativeHostPlan");+ if (d.Count != 0) { diagnostics = d; return null; }++ var mapping = source!.FaceMappings.SingleOrDefault(x => x.FaceId == input.MouthHostFaceId && x.Kind == "PrismaticSide");+ if (mapping is null) d.Add("SectionStackBlindDrillMouthFaceProvenanceMissing");+ if (!source.Topology.TryGetFace(input.MouthHostFaceId, out var originalFace) || originalFace is null) d.Add("SectionStackBlindDrillMouthFaceMissing");+ SurfaceGeometry? originalSurface = null;+ if (!source.Bindings.TryGetFaceBinding(input.MouthHostFaceId, out var originalBinding)+ || !source.Geometry.TryGetSurface(originalBinding.SurfaceGeometryId, out originalSurface)+ || originalSurface?.Kind != SurfaceGeometryKind.Plane)+ d.Add("SectionStackBlindDrillMouthRequiresPlanarHostSideFace");+ if (d.Count != 0) { diagnostics = d; return null; }++ var axis = input.Placement.AxisZ.ToVector(); var mouth = input.Placement.WorldMouthCenter;+ var normal = originalSurface!.Plane!.Value.Normal.ToVector();+ if (Math.Abs(Math.Abs(axis.Dot(normal)) - 1d) > Tol || Math.Abs((mouth - originalSurface.Plane.Value.Origin).Dot(normal)) > Tol)+ d.Add("SectionStackBlindDrillMouthFaceDoesNotMatchConstructionPlane");+ var shaft = input.Corridor.ShaftDepth; var tipLength = input.Corridor.TipLength;+ if (shaft < -Tol || tipLength <= Tol) d.Add("SectionStackBlindDrillDepthInvalid");+ if (d.Count != 0) { diagnostics = d; return null; }++ var topology = CopyTopologyExceptShells(source.Topology, input.MouthHostFaceId);+ var geometry = CopyGeometry(source.Geometry); var bindings = CopyBindings(source.Bindings);+ var points = source.VertexPoints.ToDictionary(x => x.Key, x => x.Value);+ var nextVertex = source.Topology.Vertices.Max(x => x.Id.Value) + 1;+ var nextEdge = source.Topology.Edges.Max(x => x.Id.Value) + 1;+ var nextCoedge = source.Topology.Coedges.Max(x => x.Id.Value) + 1;+ var nextLoop = source.Topology.Loops.Max(x => x.Id.Value) + 1;+ var nextFace = source.Topology.Faces.Max(x => x.Id.Value) + 1;+ var nextCurve = source.Geometry.Curves.Max(x => x.Key.Value) + 1;+ var nextSurface = source.Geometry.Surfaces.Max(x => x.Key.Value) + 1;++ VertexId Vertex(Point3D p) { var id = new VertexId(nextVertex++); topology.AddVertex(new Vertex(id)); points[id] = p; return id; }+ EdgeId Edge(VertexId a, VertexId b, CurveGeometry curve, ParameterInterval trim, bool oriented = true)+ { var id = new EdgeId(nextEdge++); var curveId = new CurveGeometryId(nextCurve++); topology.AddEdge(new Edge(id, a, b)); geometry.AddCurve(curveId, curve); bindings.AddEdgeBinding(new EdgeGeometryBinding(id, curveId, trim, oriented)); return id; }+ LoopId Loop(params (EdgeId Edge, bool Reverse)[] uses)+ { var id = new LoopId(nextLoop++); var coedges = uses.Select(_ => new CoedgeId(nextCoedge++)).ToArray(); for (var i = 0; i < uses.Length; i++) topology.AddCoedge(new Coedge(coedges[i], uses[i].Edge, id, coedges[(i + 1) % uses.Length], coedges[(i + uses.Length - 1) % uses.Length], uses[i].Reverse)); topology.AddLoop(new Loop(id, coedges)); return id; }+ FaceId Face(IReadOnlyList<LoopId> loops, SurfaceGeometry surface, bool sameSense)+ { var id = new FaceId(nextFace++); var surfaceId = new SurfaceGeometryId(nextSurface++); topology.AddFace(new Face(id, loops)); geometry.AddSurface(surfaceId, surface); bindings.AddFaceBinding(new FaceGeometryBinding(id, surfaceId, sameSense)); return id; }++ var r = input.Hole.Shaft.Radius; var radial = input.Placement.AxisX.ToVector();+ var mouthA = Vertex(mouth + radial * r); var mouthB = Vertex(mouth - radial * r);+ var transitionCenter = mouth + axis * shaft; var transitionA = Vertex(transitionCenter + radial * r); var transitionB = Vertex(transitionCenter - radial * r);+ var tip = Vertex(transitionCenter + axis * tipLength);+ var circle = new Circle3Curve(mouth, input.Placement.AxisZ, r, input.Placement.AxisX);+ var transitionCircle = new Circle3Curve(transitionCenter, input.Placement.AxisZ, r, input.Placement.AxisX);+ var mouthArcA = Edge(mouthA, mouthB, CurveGeometry.FromCircle(circle), new(0d, Math.PI));+ var mouthArcB = Edge(mouthB, mouthA, CurveGeometry.FromCircle(circle), new(Math.PI, 2d * Math.PI));+ var transitionArcA = Edge(transitionA, transitionB, CurveGeometry.FromCircle(transitionCircle), new(0d, Math.PI));+ var transitionArcB = Edge(transitionB, transitionA, CurveGeometry.FromCircle(transitionCircle), new(Math.PI, 2d * Math.PI));+ var shaftSeam = Edge(mouthA, transitionA, CurveGeometry.FromLine(new Line3Curve(points[mouthA], Direction3D.Create(points[transitionA] - points[mouthA]))), new(0d, shaft));+ var coneSeamLength = (points[tip] - points[transitionA]).Length;+ var coneSeam = Edge(transitionA, tip, CurveGeometry.FromLine(new Line3Curve(points[transitionA], Direction3D.Create(points[tip] - points[transitionA]))), new(0d, coneSeamLength));+ var mouthLoop = Loop((mouthArcB, true), (mouthArcA, true));+ var transitionLoop = Loop((transitionArcA, false), (transitionArcB, false));+ var shaftLoop = Loop((mouthArcA, false), (mouthArcB, false), (shaftSeam, false), (transitionArcB, true), (transitionArcA, true), (shaftSeam, true));+ var coneLoop = Loop((transitionArcA, false), (transitionArcB, false), (coneSeam, false), (coneSeam, true));+ var replacementFace = Face(originalFace!.LoopIds.Concat([mouthLoop]).ToArray(), originalSurface, originalBinding.SameSense);+ var shaftFace = Face([shaftLoop], SurfaceGeometry.FromCylinder(new CylinderSurface(mouth, input.Placement.AxisZ, r, input.Placement.AxisX)), false);+ var coneFace = Face([coneLoop], SurfaceGeometry.FromCone(new ConeSurface(points[tip], Direction3D.Create(-axis), point!.PointAngleDegrees * Math.PI / 360d, input.Placement.AxisX)), false);++ var shell = source.Topology.Shells.Single(); topology.AddShell(new Shell(shell.Id, shell.FaceIds.Where(x => x != input.MouthHostFaceId).Append(replacementFace).Append(shaftFace).Append(coneFace).ToArray()));+ var body = source.Topology.Bodies.Single(); topology.AddBody(new Body(body.Id, body.ShellIds.ToArray()));+ var descendants = source.Correspondence.Descendants.Concat(new SemanticTopologyDescendant[]+ {+ new($"plan:{input.Hole.FeatureId}:mouth-loop", "Loop", SemanticTopologyRole.HoleEntryLoop, input.Hole.FeatureId, Loop: mouthLoop, ParentStableId: input.Hole.FeatureId),+ new($"plan:{input.Hole.FeatureId}:mouth-edge:a", "Edge", SemanticTopologyRole.TopBoundary, input.Hole.FeatureId, Edge: mouthArcA, ParentStableId: input.Hole.FeatureId),+ new($"plan:{input.Hole.FeatureId}:mouth-edge:b", "Edge", SemanticTopologyRole.TopBoundary, input.Hole.FeatureId, Edge: mouthArcB, ParentStableId: input.Hole.FeatureId),+ new($"plan:{input.Hole.FeatureId}:shaft", "Face", SemanticTopologyRole.HoleWallFace, input.Hole.FeatureId, Face: shaftFace, ParentStableId: input.Hole.FeatureId),+ new($"plan:{input.Hole.FeatureId}:transition-loop", "Loop", SemanticTopologyRole.HoleShaftToDrillPointLoop, input.Hole.FeatureId, Loop: transitionLoop, ParentStableId: input.Hole.FeatureId),+ new($"plan:{input.Hole.FeatureId}:point", "Face", SemanticTopologyRole.HoleDrillPointFace, input.Hole.FeatureId, Face: coneFace, ParentStableId: input.Hole.FeatureId),+ new($"plan:{input.Hole.FeatureId}:tip", "Vertex", SemanticTopologyRole.HoleTipVertex, input.Hole.FeatureId, Vertex: tip, ParentStableId: input.Hole.FeatureId)+ }).ToArray();+ var correspondence = new SemanticTopologyCorrespondence(source.Correspondence.BodyStableId, descendants, source.Correspondence.ProvenanceChain.Concat(["SectionStackBlindDrillCavityPlan", "ConstructionProvenanceMouthFace", "NoInternalCaps"]).ToArray());+ var mappings = source.FaceMappings.Where(x => x.FaceId != input.MouthHostFaceId).Append(new PrismaticSectionStackFacePlanMapping(replacementFace, "HostFaceReplacement", mapping!.SourceStableId, mapping.ConstructionStableId, mapping.SlabFrom, mapping.SlabTo, mapping.Provenance))+ .Append(new PrismaticSectionStackFacePlanMapping(shaftFace, "BlindDrillShaft", input.Hole.FeatureId, mapping.ConstructionStableId, mapping.SlabFrom, mapping.SlabTo, ["SectionStackBlindDrillCavityPlan", "NoInternalCaps"]))+ .Append(new PrismaticSectionStackFacePlanMapping(coneFace, "BlindDrillPoint", input.Hole.FeatureId, mapping.ConstructionStableId, mapping.SlabFrom, mapping.SlabTo, ["SectionStackBlindDrillCavityPlan", "NoInternalCaps"])) .ToArray();+ var topologyPlan = new PrismaticSectionStackTopologyPlan($"{source.StableId}:blind:{input.Hole.FeatureId}", topology, geometry, bindings, points, mappings, correspondence, correspondence.ProvenanceChain);+ var replacement = new PrismaticSectionStackBrepPlan($"{input.HostPlan.Signature}:blind:{input.Hole.FeatureId}", points.Count, topology.Edges.Count(), topology.Faces.Count(), input.HostPlan.Policy, true, correspondence, topologyPlan);+ d.Add("SectionStackBlindDrillCavityPlanCreated"); d.Add("SectionStackBlindDrillNoInternalCaps"); diagnostics = d;+ return new($"section-stack-blind:{input.Hole.FeatureId}", input.HostPlan, replacement, [new(input.MouthHostFaceId, [replacementFace])], d);+ }++ private static TopologyModel CopyTopologyExceptShells(TopologyModel source, FaceId excludedFace)+ { var copy = new TopologyModel(); foreach (var x in source.Vertices) copy.AddVertex(x); foreach (var x in source.Edges) copy.AddEdge(x); foreach (var x in source.Coedges) copy.AddCoedge(x); foreach (var x in source.Loops) copy.AddLoop(x); foreach (var x in source.Faces.Where(x => x.Id != excludedFace)) copy.AddFace(x); return copy; }+ private static BrepGeometryStore CopyGeometry(BrepGeometryStore source) { var copy = new BrepGeometryStore(); foreach (var x in source.Curves) copy.AddCurve(x.Key, x.Value); foreach (var x in source.Surfaces) copy.AddSurface(x.Key, x.Value); return copy; }+ private static BrepBindingModel CopyBindings(BrepBindingModel source) { var copy = new BrepBindingModel(); foreach (var x in source.EdgeBindings) copy.AddEdgeBinding(x); foreach (var x in source.FaceBindings) copy.AddFaceBinding(x); return copy; }+}++/// <summary>+/// The sole compose/V2 feature bridge for the admitted conservative blind-drill+/// lane. It consumes construction-owned section-stack plan provenance; it+/// never searches a materialized body or STEP topology for an entry face.+/// </summary>+public static class SectionStackBlindDrillComposeBridge+{+ private const double Tol = 1e-7;++ public static PrismaticSectionStackBrepPlan? TryApply(+ PrismaticSectionStackConstruction stack,+ PrismaticSectionStackBrepPlan hostPlan,+ out IReadOnlyList<string> diagnostics,+ out BlindDrillToolCorridorEvidence? evidence)+ {+ var d = new List<string>();+ var declarations = stack.Feature.ConstructionPlaneBlindDrills ?? [];+ evidence = null;+ if (declarations.Count == 0) { diagnostics = d; return hostPlan; }+ if (declarations.Count != 1) { diagnostics = ["SectionStackBlindDrillOnlyOneFeatureIsAdmitted"]; return null; }+ var declaration = declarations[0];+ var placement = new AirConstructionPlaneHolePlacement(declaration.ConstructionPlaneId, declaration.SourceConceptPlaneId,+ declaration.FrameOrigin, declaration.AxisX, declaration.AxisY, declaration.AxisZ, declaration.LocalCenterX, declaration.LocalCenterY,+ declaration.SourceSpan, declaration.Provenance);+ var end = declaration.DeclaredDepthIsTotal+ ? (AirHoleEndCondition)new AirHoleEndCondition.TotalDepth(declaration.DeclaredDepth)+ : new AirHoleEndCondition.ShaftDepth(declaration.DeclaredDepth);+ var feature = AirHoleFeature.CreateConstructionPlaneSimpleShaft(declaration.Name, declaration.StableId, stack.Feature.Name, placement,+ new AirHoleShaft(declaration.Diameter), end,+ new AirProvenance("COMPOSED-HOST-BLIND-DRILL-CLEARANCE-X1", "Profile/Compose Construction Plane Hole", declaration.Name,+ declaration.StableId, nameof(AirConstructionPlaneHolePlacement), AirSelectionClass.None, AirRuleKind.None,+ "FullRadiusThroughTotalDepth", true, ["construction-plane:" + declaration.ConstructionPlaneId, "source-concept-plane:" + declaration.SourceConceptPlaneId]),+ new AirHoleTermination.DrillPoint(declaration.PointAngleDegrees));+ var corridor = TransverseBlindDrillToolCorridor.Prove(feature, stack, placement);+ evidence = corridor;+ if (corridor.Classification != BlindDrillToolCorridorClassification.CorridorProven)+ { d.AddRange(corridor.Diagnostics); d.Add("SectionStackBlindDrillClearanceContractRejected"); diagnostics = d; return null; }++ var face = FindMouthFace(hostPlan.TopologyPlan!, placement, feature.Shaft.Radius, d);+ if (face is null) { diagnostics = d; return null; }+ var cavity = SectionStackBlindDrillCavityPlanner.TryPlan(new(stack, hostPlan, feature, placement, corridor, face.Value), out var cavityDiagnostics);+ d.AddRange(cavityDiagnostics);+ if (cavity is null) { diagnostics = d; return null; }+ d.Add("SectionStackBlindDrillComposeBridge");+ diagnostics = d;+ return cavity.ReplacementHostPlan;+ }++ private static FaceId? FindMouthFace(PrismaticSectionStackTopologyPlan plan, AirConstructionPlaneHolePlacement placement, double radius, List<string> diagnostics)+ {+ var mouth = placement.WorldMouthCenter; var axis = placement.AxisZ.ToVector();+ var compatible = plan.FaceMappings.Where(x => x.Kind == "PrismaticSide")+ .Where(x => plan.Bindings.TryGetFaceBinding(x.FaceId, out var binding)+ && plan.Geometry.TryGetSurface(binding.SurfaceGeometryId, out var surface)+ && surface.Kind == SurfaceGeometryKind.Plane+ && Math.Abs(Math.Abs(surface.Plane!.Value.Normal.ToVector().Dot(axis)) - 1d) <= Tol+ && Math.Abs((mouth - surface.Plane.Value.Origin).Dot(surface.Plane.Value.Normal.ToVector())) <= Tol)+ .ToArray();+ var candidates = compatible.Where(x => x.SlabFrom is { } from && x.SlabTo is { } to && mouth.Z - radius >= from - Tol && mouth.Z + radius <= to + Tol).ToArray();+ if (candidates.Length != 1)+ {+ diagnostics.Add(candidates.Length == 0 && compatible.Length > 0+ ? "SectionStackBlindDrillMouthCrossesHostPlanningPartition"+ : "SectionStackBlindDrillMouthProvenanceNotFound");+ return null;+ }+ var candidate = candidates[0];+ // The current exact insertion keeps the circular inner loop in one+ // planar host face. Refuse a seam-crossing mouth rather than creating+ // duplicated arcs or a false one-face ownership claim.+ return candidate.FaceId;+ }+}diff --git a/Aetheris.Kernel.Firmament/Materializer/TransverseBlindDrillToolCorridor.cs b/Aetheris.Kernel.Firmament/Materializer/TransverseBlindDrillToolCorridor.csindex 32474687..1ad0566d 100644--- a/Aetheris.Kernel.Firmament/Materializer/TransverseBlindDrillToolCorridor.cs+++ b/Aetheris.Kernel.Firmament/Materializer/TransverseBlindDrillToolCorridor.cs@@ -3,12 +3,15 @@ using Aetheris.Kernel.Core.Geometry.Curves;namespace Aetheris.Kernel.Firmament.Materializer;-/// <summary>Classification of the complete, transverse blind drilling tool volume.</summary>+/// <summary>The deliberately conservative semantic admission rule for Blind DrillPoint holes.</summary>+public enum BlindDrillClearancePolicy { FullRadiusThroughTotalDepth }++/// <summary>Classification of the full-radius transverse blind clearance corridor.</summary>public enum BlindDrillToolCorridorClassification{CorridorProven, MouthUnsupported, ShaftBoundaryCrossing, ShaftVoidIntersection,ConeBoundaryCrossing, ConeVoidIntersection, TipOutsideMaterial,- DisconnectedHostCorridor, TangentialAmbiguity, Unsupported+ FullRadiusTipClearanceFailed, InnerVoidIntersection, DisconnectedHostCorridor, TangentialAmbiguity, Unsupported}public enum SectionRectangleCorridorClassification { FullyContained, CrossesOuterBoundary, IntersectsInnerVoid, Tangential, Ambiguous, UnsupportedBoundary }@@ -23,16 +26,16 @@ public sealed record BlindDrillToolCorridorEvidence(double Radius, double ShaftDepth, double TipLength, double TotalDepth, double PointAngle,IReadOnlyList<SectionRectangleCorridorProof> ShaftSliceProofs,IReadOnlyList<SectionRectangleCorridorProof> ConeSliceProofs,+ BlindDrillClearancePolicy ValidationPolicy,double? RemainingWall, BlindDrillToolCorridorClassification Classification,IReadOnlyList<string> Diagnostics, IReadOnlyList<string> Provenance);/// <summary>/// Bounded transverse (+/-X, +/-Y) blind-drill proof. At each world-Z slab it-/// proves a tool envelope in the slab's native XY material region. The shaft-/// envelope follows the exact circular YZ/XZ chord; the cone uses the enclosing-/// analytic rectangle for that slab. This is conservative for the cone and is-/// intentionally rejected rather than approximated when its enclosure cannot-/// be proven.+/// proves the full shaft-radius cylindrical clearance envelope in the slab's+/// native XY material region. The actual B-rep remains a shaft plus conical+/// DrillPoint; this clearance cylinder is a visible, deliberate semantic+/// superset through TotalDepth./// </summary>internal static class TransverseBlindDrillToolCorridor{@@ -63,7 +66,7 @@ internal static class TransverseBlindDrillToolCorridorvar positive = axis.X > 0d || axis.Y > 0d; var xAxis = Math.Abs(axis.X) > .5d;var axialMouth = xAxis ? mouth.X : mouth.Y; var crossCenter = xAxis ? mouth.Y : mouth.X;var shaftEnd = axialMouth + (positive ? shaft : -shaft); var tipEnd = axialMouth + (positive ? total : -total);- var shaftProofs = new List<SectionRectangleCorridorProof>(); var coneProofs = new List<SectionRectangleCorridorProof>();+ var clearanceProofs = new List<SectionRectangleCorridorProof>();foreach (var slab in slabs){var z0 = Math.Max(slab.From, radialZMin); var z1 = Math.Min(slab.To, radialZMax);@@ -72,24 +75,11 @@ internal static class TransverseBlindDrillToolCorridor// closure supplies the exact circular Mouth support separately in a// host-integrated plan. No alternative mouth is searched for here.var insideMouth = axialMouth + (positive ? EntryInset : -EntryInset);- var shaftProof = QueryRectangle(slab.Region, z0, z1, insideMouth, shaftEnd,- crossCenter - maxChord, crossCenter + maxChord, xAxis, "Shaft");- shaftProofs.Add(shaftProof);-- // At fixed Z the exact cone is curved in the axial/cross plane. The- // rectangle below is its analytic enclosing envelope: s is bounded- // by L(1-|dz|/r), and the maximum cross chord occurs at s=0. A host- // containing this rectangle necessarily contains the full cone slice.- var dz = Math.Abs(NearestTo(mouth.Z, z0, z1) - mouth.Z);- var coneLength = tip * Math.Max(0d, 1d - dz / radius);- var coneEnd = shaftEnd + (positive ? coneLength : -coneLength);- var coneProof = QueryRectangle(slab.Region, z0, z1, shaftEnd, coneEnd,- crossCenter - maxChord, crossCenter + maxChord, xAxis, "DrillPoint");- coneProofs.Add(coneProof);+ clearanceProofs.Add(QueryRectangle(slab.Region, z0, z1, insideMouth, tipEnd,+ crossCenter - maxChord, crossCenter + maxChord, xAxis, "FullRadiusClearance"));}- var all = shaftProofs.Concat(coneProofs).ToArray();- var classification = Classify(all, diagnostics);+ var classification = Classify(clearanceProofs, diagnostics);double? remaining = null;// The physical RemainingWall is direction-specific distance beyond the// tip and needs host-boundary correspondence. This proof does not invent@@ -98,14 +88,15 @@ internal static class TransverseBlindDrillToolCorridordiagnostics.Add("RemainingWallRequiresHostBoundaryCorrespondence: corridor is proven but no final host boundary distance was inferred.");return new(feature.FeatureId, feature.TargetBodyId ?? stack.Feature.Name, placement.ConstructionPlaneId,[mouth.X, mouth.Y, mouth.Z], [axis.X, axis.Y, axis.Z], radius, shaft, tip, total, point.PointAngleDegrees,- shaftProofs, coneProofs, remaining, classification, diagnostics, ["PrismaticSectionStackConstruction", "ProfileArrangement2D", "TransverseYZorXZChord", "ConservativeAnalyticConeEnvelope", "NoTessellation"]);+ clearanceProofs, [], BlindDrillClearancePolicy.FullRadiusThroughTotalDepth, remaining, classification, diagnostics,+ ["PrismaticSectionStackConstruction", "ProfileArrangement2D", "TransverseYZorXZChord", "FullRadiusThroughTotalDepth", "NoConeEnvelopeAcceptance", "NoTessellation"]);BlindDrillToolCorridorEvidence Fail(string diagnostic, BlindDrillToolCorridorClassification kind){diagnostics.Add(diagnostic);return new(feature.FeatureId, feature.TargetBodyId ?? stack.Feature.Name, placement.ConstructionPlaneId,[mouth.X, mouth.Y, mouth.Z], [axis.X, axis.Y, axis.Z], feature.Shaft.Radius, 0d, 0d, 0d,- feature.Termination is AirHoleTermination.DrillPoint p ? p.PointAngleDegrees : 0d, [], [], null, kind, diagnostics,+ feature.Termination is AirHoleTermination.DrillPoint p ? p.PointAngleDegrees : 0d, [], [], BlindDrillClearancePolicy.FullRadiusThroughTotalDepth, null, kind, diagnostics,["PrismaticSectionStackConstruction", "NoBoxIntervalFallback"]);}}@@ -117,8 +108,8 @@ internal static class TransverseBlindDrillToolCorridordiagnostics.Add($"ToolCorridorFailure: part={failure.ToolPart}; z=[{failure.ZFrom:R},{failure.ZTo:R}]; axial=[{failure.AxisFrom:R},{failure.AxisTo:R}]; cross=[{failure.CrossFrom:R},{failure.CrossTo:R}]; detail={failure.Detail}.");return failure.Classification switch{- SectionRectangleCorridorClassification.IntersectsInnerVoid => failure.ToolPart == "Shaft" ? BlindDrillToolCorridorClassification.ShaftVoidIntersection : BlindDrillToolCorridorClassification.ConeVoidIntersection,- SectionRectangleCorridorClassification.CrossesOuterBoundary => failure.ToolPart == "Shaft" ? BlindDrillToolCorridorClassification.ShaftBoundaryCrossing : BlindDrillToolCorridorClassification.ConeBoundaryCrossing,+ SectionRectangleCorridorClassification.IntersectsInnerVoid => BlindDrillToolCorridorClassification.InnerVoidIntersection,+ SectionRectangleCorridorClassification.CrossesOuterBoundary => BlindDrillToolCorridorClassification.FullRadiusTipClearanceFailed,SectionRectangleCorridorClassification.Tangential => BlindDrillToolCorridorClassification.TangentialAmbiguity,_ => BlindDrillToolCorridorClassification.Unsupported};diff --git a/docs/firmament/blind-drill-clearance-contract-x1.md b/docs/firmament/blind-drill-clearance-contract-x1.mdnew file mode 100644index 00000000..beee3c50--- /dev/null+++ b/docs/firmament/blind-drill-clearance-contract-x1.md@@ -0,0 +1,53 @@+# Blind Drill clearance contract X1++Composed-host transverse `Hole<Shaft>` features with a `DrillPoint` use the+explicit `FullRadiusThroughTotalDepth` validation policy. The compiler proves+one full-radius cylindrical guard envelope from the declared Mouth through+`TotalDepth`, using the existing exact world-Z slab chord decomposition and+line/arc material-region rectangle containment query.++The guard envelope is not materialized. The authoritative cavity remains the+exact shaft cylinder, shaft-to-DrillPoint transition, conical DrillPoint wall,+and one Tip. Its analytic removed volume remains:++`pi * r^2 * ShaftDepth + (pi * r^2 * TipLength) / 3`.++Blind DrillPoint Holes require full shaft-radius clearance through TotalDepth.+The validation cylinder is a conservative guard envelope. The materialized+feature remains a cylinder plus a conical DrillPoint.++A cone-only fit is intentionally rejected by the semantic Hole generic. The+diagnostic identifies `FullRadiusTipClearanceFailed` or+`InnerVoidIntersection` and retains the slab, chord, construction-plane, and+feature provenance. If the taper itself is the intended design, author an+explicit tapered construction feature; if an exit is intended, declare a+ThroughAll Hole.++Section-stack slab changes are planning evidence, not cavity terminations. The+current narrow topology route continues to emit one unpartitioned cone face,+one Tip, no Exit, and no internal cap. Hyperbola support remains a kernel+capability, but is not part of blind-hole admission under this policy.++## Compose source bridge and inspection++The admitted source bridge is deliberately one continuation of the existing+`Profile`/`Compose` route, not a second composition language. A `Hole<Shaft>`+inside `Compose` that declares `From: <ConstructionPlane>`, `Center:+Point2(...)`, `ShaftDepth(...)` or `TotalDepth(...)`, and `Termination:+DrillPoint` is retained as a `PrismaticConstructionPlaneBlindDrillFeature`.+After the host stack has been normalized and planned it is lowered to+`AirConstructionPlaneHolePlacement`, proved by+`TransverseBlindDrillToolCorridor`, then inserted by+`SectionStackBlindDrillCavityPlanner`.++`aetheris inspect-selections <source> --json` publishes the policy, total+clearance-cylinder length, slab chord proofs, classification, semantic+descendants, and the no-cap plan provenance under `holeContract`. The emitted+cavity still contains no validation-cylinder geometry.++The current Mouth operation is intentionally narrower than the clearance+proof: the complete Mouth circle must fit in exactly one planar host-side+face partition. A Mouth which crosses an internal section-stack planning seam+is rejected as `SectionStackBlindDrillMouthCrossesHostPlanningPartition`.+This prevents an untrue single-face ownership claim while the explicit+multi-face circular-Mouth replacement operation remains future work.diff --git a/docs/kernel/hyperbola-curve-x1.md b/docs/kernel/hyperbola-curve-x1.mdnew file mode 100644index 00000000..c26b2f2b--- /dev/null+++ b/docs/kernel/hyperbola-curve-x1.md@@ -0,0 +1,48 @@+# Hyperbola curve X1++`Hyperbola3Curve` is the kernel's exact one-branch analytic hyperbola support.+It uses the right-handed frame `(AxisU, AxisV, PlaneNormal)` and the stable+parameterization:++`P(t) = Center + branchSign * A * cosh(t) * AxisU + B * sinh(t) * AxisV`.++The support is unbounded; the authoritative `EdgeGeometryBinding.TrimInterval`+owns each finite B-rep use. Edge orientation remains an `OrientedEdgeSense`+decision, so a shared bounded hyperbola edge has one support and one trim, even+when adjacent face uses traverse it oppositely.++The initial production intersection is deliberately narrow:+`TransverseConePlaneIntersection.IntersectWorldZ` accepts only a `ConeSurface`+whose axis is exactly one of `+X`, `-X`, `+Y`, or `-Y`, and a world-Z plane that+does not contain the apex. With `d = planeZ - apexZ` and cone half-angle `a`,+it produces:++- `Center = (apex.X, apex.Y, planeZ)`+- `AxisU = cone.Axis`+- `AxisV = +Z x AxisU`+- `A = abs(d) / tan(a)`+- `B = abs(d)`+- `Branch = PositiveAxisU`++This is the forward cone sheet (`v >= 0`). Apex planes and non-transverse axes+reject explicitly rather than being misclassified as hyperbolas.++`BrepDisplayTessellator` uses bounded adaptive midpoint-deviation and tangent+turn subdivision. It preserves exact endpoints, but is only a derived display+and M8 carrier: tessellation never replaces `Hyperbola3Curve` in topology.++STEP AP242 uses a real `HYPERBOLA` support plus `TRIMMED_CURVE` parameter+bounds. A negative local branch is serialized by a canonically flipped STEP+placement frame; reimport canonicalizes the physical branch to+`PositiveAxisU` in that exported frame. The geometry and trim direction are+therefore preserved without a rational B-spline fallback.++A known analytic hyperbola must remain a hyperbola through BRep, STEP, and+reimport. A section-stack partition plane may trim a transverse cone with a+hyperbola; that trim is topology, not decoration.++Current limits: parabola, arbitrary conic recovery, rational B-splines,+arbitrary cone/plane orientations, and generic surface/surface intersection+remain outside this route. The next cavity-planner step consumes these exact+supports to form shared cone partition edges; it must not synthesize caps at+section-stack planning levels.diff --git a/docs/kernel/section-stack-transverse-cavity-plan-x1.md b/docs/kernel/section-stack-transverse-cavity-plan-x1.mdnew file mode 100644index 00000000..db0d46fb--- /dev/null+++ b/docs/kernel/section-stack-transverse-cavity-plan-x1.md@@ -0,0 +1,32 @@+# SECTION-STACK-TRANSVERSE-CAVITY-PLAN-X1 — plan-first host seam++The section-stack route separates construction planning from materialization. `PrismaticSectionStackEmitter.TryPlan` produces `PrismaticSectionStackTopologyPlan`; `PrismaticSectionStackBrepMaterializer` validates bindings and instantiates an independent snapshot of the `BrepBody` without deciding topology.++The topology plan preserves every section-stack side face as a `PrismaticSectionStackFacePlanMapping`, carrying its plan `FaceId`, source arrangement provenance, construction/slab identity, and Z interval. This is the required affected-host lookup seam for a later transverse-cavity planner: it must consume corridor and construction provenance to select planned faces, not search the emitted BRep.++The next planner boundary is:++```text+PrismaticSectionStackConstruction+ -> PrismaticSectionStackTopologyPlan+ -> SectionStackBlindDrillCavityPlan (face replacements and new cavity topology)+ -> PrismaticSectionStackBrepMaterializer+```++Corridor evidence proves that the drilling tool fits. The cavity plan proves that the host topology can represent it. A section-stack planner boundary may split a cavity face. It must never create a physical cap. The cavity is integrated into the authoritative host shell; it is not emitted as a detached negative tool body.++`SectionStackBlindDrillCavityPlanner` now implements the first narrow insertion:++- Its input contains the proven corridor and a construction-provenance `MouthHostFaceId`; it never searches final BRep geometry.+- It replaces that planar host side face with the retained loops plus one exact circular Mouth inner loop.+- It adds one exact cylindrical shaft wall, one shaft-to-DrillPoint loop, one exact conical wall, and one Tip to the same authoritative shell. There is no Exit or cap at the shaft/cone seam.+- The replacement map and plan-owned semantic descendants are published before `PrismaticSectionStackBrepMaterializer` consumes the final plan.++The current admitted topology insertion deliberately requires the complete Mouth to lie in one planar side-face partition. It does not yet split a Mouth across host partitions or split a transverse cylinder/cone along world-Z host partitions. Those cases remain rejected at the planner boundary rather than being represented with false caps or detached tool bodies.++`SectionStackBlindDrillComposeBridge` is the source-facing seam used by the+compose exporter and selection inspection. It converts the source-owned+construction-plane blind declaration into AIR only after a section-stack plan+exists, proves `FullRadiusThroughTotalDepth`, obtains the Mouth face from plan+provenance and plan-bound surface identity (never an emitted BRep search), and+passes the fully decided replacement plan to the materializer.diff --git a/fixtures/FirmamentV2/ProfileComposition/invalid/construction-plane-blind-drill-mouth-crosses-slab.firmament b/fixtures/FirmamentV2/ProfileComposition/invalid/construction-plane-blind-drill-mouth-crosses-slab.firmamentnew file mode 100644index 00000000..186453d4--- /dev/null+++ b/fixtures/FirmamentV2/ProfileComposition/invalid/construction-plane-blind-drill-mouth-crosses-slab.firmament@@ -0,0 +1,24 @@+// The clearance proof spans both slabs, but the exact Mouth circle crosses the+// side-face planning seam. X1 must reject rather than manufacture split arcs.+Concept Struct SideLayout {+ PositiveXDatum: Plane { Origin: [-20mm, 0mm, 0mm]; Normal: [1, 0, 0]; Up: [0, 0, 1] }+}+Construction Plane PositiveXWorkplane { Trace: SideLayout.PositiveXDatum }+Concept Struct Layout On XY { Rect2 Guide { Center: [0mm, 0mm]; Size: [40mm, 20mm] } }+Profile Stock Using Layout { Loop Outer {+ Segment South { Trace: Guide.Bottom; From: Guide.BottomLeft; To: Guide.BottomRight }+ Segment East { Trace: Guide.Right; From: Guide.BottomRight; To: Guide.TopRight }+ Segment North { Trace: Guide.Top; From: Guide.TopRight; To: Guide.TopLeft }+ Segment West { Trace: Guide.Left; From: Guide.TopLeft; To: Guide.BottomLeft }+} }+Struct Composition { Compose SideBlindHost {+ Base Lower { Profile: Stock; From: -10mm; To: 0mm }+ Add Upper { Profile: Stock; From: 0mm; To: 10mm }+ Hole<Shaft> SideBlind {+ From: PositiveXWorkplane+ Center: Point2(0mm, 0mm)+ Diameter: 2mm+ End: ShaftDepth(10mm)+ Termination: DrillPoint+ }+} }diff --git a/fixtures/FirmamentV2/ProfileComposition/valid/construction-plane-blind-drill-clearance.firmament b/fixtures/FirmamentV2/ProfileComposition/valid/construction-plane-blind-drill-clearance.firmamentnew file mode 100644index 00000000..81d6a7d6--- /dev/null+++ b/fixtures/FirmamentV2/ProfileComposition/valid/construction-plane-blind-drill-clearance.firmament@@ -0,0 +1,26 @@+// BLIND-DRILL-CLEARANCE-CONTRACT-X1: the validation envelope is a full-radius+// cylinder through the DrillPoint Tip; the emitted cavity remains cylinder+cone.+Concept Struct SideLayout {+ PositiveXDatum: Plane { Origin: [-20mm, 0mm, 0mm]; Normal: [1, 0, 0]; Up: [0, 0, 1] }+}++Construction Plane PositiveXWorkplane { Trace: SideLayout.PositiveXDatum }++Concept Struct Layout On XY { Rect2 Guide { Center: [0mm, 0mm]; Size: [40mm, 20mm] } }+Profile Stock Using Layout { Loop Outer {+ Segment South { Trace: Guide.Bottom; From: Guide.BottomLeft; To: Guide.BottomRight }+ Segment East { Trace: Guide.Right; From: Guide.BottomRight; To: Guide.TopRight }+ Segment North { Trace: Guide.Top; From: Guide.TopRight; To: Guide.TopLeft }+ Segment West { Trace: Guide.Left; From: Guide.TopLeft; To: Guide.BottomLeft }+} }+Struct Composition { Compose SideBlindHost {+ Base StockBody { Profile: Stock; From: -10mm; To: 10mm }+ Hole<Shaft> SideBlind {+ From: PositiveXWorkplane+ Center: Point2(0mm, 0mm)+ Diameter: 2mm+ End: ShaftDepth(10mm)+ Termination: DrillPoint+ Role: SideBlindDrill+ }+} }