Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Implement narrow box-cone through-hole support
Yuechen Li49ae73d3957a
diff --git a/Aetheris.Kernel.Core.Tests/Brep/Boolean/BrepBooleanTests.cs b/Aetheris.Kernel.Core.Tests/Brep/Boolean/BrepBooleanTests.csindex 8be13653..413c01fc 100644--- a/Aetheris.Kernel.Core.Tests/Brep/Boolean/BrepBooleanTests.cs+++ b/Aetheris.Kernel.Core.Tests/Brep/Boolean/BrepBooleanTests.cs@@ -319,54 +319,139 @@ public sealed class BrepBooleanTests}[Fact]- public void Add_BoxCylinder_StillReturnsDeterministicNotImplemented()+ public void Subtract_BoxFrustumConeThroughHole_Returns_ManifoldBodyWithConicalHole(){var left = BrepBooleanBoxRecognition.CreateBoxFromExtents(new AxisAlignedBoxExtents(-20d, 20d, -15d, 15d, 0d, 12d)).Value;- var right = TransformBody(BrepPrimitives.CreateCylinder(4d, 20d).Value, Transform3D.CreateTranslation(new Vector3D(0d, 0d, 6d)));+ var right = CreateCone(bottomRadius: 4d, topRadius: 8d, height: 20d);- var result = BrepBoolean.Union(left, right);+ var result = BrepBoolean.Subtract(left, right);++ Assert.True(result.IsSuccess);+ var body = result.Value;+ Assert.Single(body.Topology.Bodies);+ Assert.Single(body.Topology.Shells);+ Assert.Equal(7, body.Topology.Faces.Count());+ Assert.Equal(15, body.Topology.Edges.Count());+ Assert.Equal(12, body.Topology.Vertices.Count());+ Assert.True(BrepBindingValidator.Validate(body, true).IsSuccess);++ var conicalFace = Assert.Single(body.Topology.Faces, face =>+ body.TryGetFaceSurfaceGeometry(face.Id, out var surface)+ && surface?.Kind == SurfaceGeometryKind.Cone);+ Assert.Single(body.GetLoopIds(conicalFace.Id));++ var topFace = Assert.Single(body.Topology.Faces, face =>+ body.TryGetFaceSurfaceGeometry(face.Id, out var surface)+ && surface?.Kind == SurfaceGeometryKind.Plane+ && surface.Plane!.Value.Normal.Z > 0.5d);+ Assert.Equal(2, body.GetLoopIds(topFace.Id).Count);++ var bottomFace = Assert.Single(body.Topology.Faces, face =>+ body.TryGetFaceSurfaceGeometry(face.Id, out var surface)+ && surface?.Kind == SurfaceGeometryKind.Plane+ && surface.Plane!.Value.Normal.Z < -0.5d);+ Assert.Equal(2, body.GetLoopIds(bottomFace.Id).Count);+ }++ [Fact]+ public void Subtract_BoxPointedConeThroughHole_Exports_And_RoundTrips_Deterministically()+ {+ var left = BrepBooleanBoxRecognition.CreateBoxFromExtents(new AxisAlignedBoxExtents(-20d, 20d, -15d, 15d, 0d, 12d)).Value;+ var right = CreateCone(bottomRadius: 6d, topRadius: 0d, height: 20d);++ var first = BrepBoolean.Subtract(left, right);+ var second = BrepBoolean.Subtract(left, right);++ Assert.True(first.IsSuccess);+ Assert.True(second.IsSuccess);+ Assert.Equal(7, first.Value.Topology.Faces.Count());+ Assert.Contains(first.Value.Topology.Faces, face =>+ first.Value.TryGetFaceSurfaceGeometry(face.Id, out var surface)+ && surface?.Kind == SurfaceGeometryKind.Cone);++ var firstExport = Step242Exporter.ExportBody(first.Value);+ var secondExport = Step242Exporter.ExportBody(second.Value);+ Assert.True(firstExport.IsSuccess);+ Assert.True(secondExport.IsSuccess);+ Assert.Equal(firstExport.Value, secondExport.Value);+ Assert.Contains("MANIFOLD_SOLID_BREP", firstExport.Value, StringComparison.Ordinal);+ Assert.Contains("CONICAL_SURFACE", firstExport.Value, StringComparison.Ordinal);+ Assert.Contains("FACE_BOUND('',", firstExport.Value, StringComparison.Ordinal);+ Assert.Contains("FACE_OUTER_BOUND('',", firstExport.Value, StringComparison.Ordinal);++ var import = Step242Importer.ImportBody(firstExport.Value);+ Assert.True(import.IsSuccess);+ Assert.True(BrepBindingValidator.Validate(import.Value, true).IsSuccess);+ Assert.Contains(import.Value.Topology.Faces, face =>+ import.Value.TryGetFaceSurfaceGeometry(face.Id, out var surface)+ && surface?.Kind == SurfaceGeometryKind.Cone);+ }++ [Fact]+ public void Subtract_BoxConeRotatedAxis_ReturnsAxisNotAlignedDiagnostic()+ {+ var left = BrepBooleanBoxRecognition.CreateBoxFromExtents(new AxisAlignedBoxExtents(-20d, 20d, -15d, 15d, 0d, 12d)).Value;+ var rotated = TransformBody(CreateCone(bottomRadius: 4d, topRadius: 8d, height: 20d), Transform3D.CreateRotationX(System.Math.PI / 2d));++ var result = BrepBoolean.Subtract(left, rotated);Assert.False(result.IsSuccess);var diagnostic = Assert.Single(result.Diagnostics);Assert.Equal(KernelDiagnosticCode.NotImplemented, diagnostic.Code);- Assert.Equal("Boolean Union: M13 only supports recognized axis-aligned boxes from BrepPrimitives.CreateBox(...).", diagnostic.Message);+ Assert.Equal("BrepBoolean.AnalyticHole.AxisNotAligned", diagnostic.Source);+ Assert.Equal("Boolean Subtract: analytic hole candidate failed diagnostic AxisNotAligned (cone axis is not aligned with the box Z axis.).", diagnostic.Message);}[Fact]- public void Intersect_BoxCylinder_StillReturnsDeterministicNotImplemented()+ public void Subtract_BoxConePartialHeight_ReturnsNotFullySpanningDiagnostic(){var left = BrepBooleanBoxRecognition.CreateBoxFromExtents(new AxisAlignedBoxExtents(-20d, 20d, -15d, 15d, 0d, 12d)).Value;- var right = TransformBody(BrepPrimitives.CreateCylinder(4d, 20d).Value, Transform3D.CreateTranslation(new Vector3D(0d, 0d, 6d)));+ var partial = CreateCone(bottomRadius: 4d, topRadius: 2d, height: 8d);- var result = BrepBoolean.Intersect(left, right);+ var result = BrepBoolean.Subtract(left, partial);Assert.False(result.IsSuccess);var diagnostic = Assert.Single(result.Diagnostics);Assert.Equal(KernelDiagnosticCode.NotImplemented, diagnostic.Code);- Assert.Equal("Boolean Intersect: M13 only supports recognized axis-aligned boxes from BrepPrimitives.CreateBox(...).", diagnostic.Message);+ Assert.Equal("BrepBoolean.AnalyticHole.NotFullySpanning", diagnostic.Source);+ Assert.Equal("Boolean Subtract: analytic hole candidate failed diagnostic NotFullySpanning (cone does not fully span the box Z range.).", diagnostic.Message);}+ [Fact]+ public void Subtract_BoxConeOutsideFootprint_ReturnsRadiusExceedsBoundaryDiagnostic()+ {+ var left = BrepBooleanBoxRecognition.CreateBoxFromExtents(new AxisAlignedBoxExtents(-20d, 20d, -15d, 15d, 0d, 12d)).Value;+ var outside = TransformBody(CreateCone(bottomRadius: 4d, topRadius: 8d, height: 20d), Transform3D.CreateTranslation(new Vector3D(13.7d, 0d, 0d)));++ var result = BrepBoolean.Subtract(left, outside);++ Assert.False(result.IsSuccess);+ var diagnostic = Assert.Single(result.Diagnostics);+ Assert.Equal(KernelDiagnosticCode.NotImplemented, diagnostic.Code);+ Assert.Equal("BrepBoolean.AnalyticHole.RadiusExceedsBoundary", diagnostic.Source);+ Assert.Equal("Boolean Subtract: analytic hole candidate failed diagnostic RadiusExceedsBoundary (cone top-plane cross-section exceeds the box XY boundary.).", diagnostic.Message);+ }[Fact]- public void Subtract_BoxSphereFullyContained_StillReturnsDeterministicNotImplemented()+ public void Subtract_BoxConeTangentToBoundary_ReturnsTangentContactDiagnostic(){- var left = BrepBooleanBoxRecognition.CreateBoxFromExtents(new AxisAlignedBoxExtents(-20d, 20d, -15d, 15d, -6d, 6d)).Value;- var right = BrepPrimitives.CreateSphere(4d).Value;+ var left = BrepBooleanBoxRecognition.CreateBoxFromExtents(new AxisAlignedBoxExtents(-20d, 20d, -15d, 15d, 0d, 12d)).Value;+ var tangent = TransformBody(CreateCone(bottomRadius: 4d, topRadius: 8d, height: 20d), Transform3D.CreateTranslation(new Vector3D(13.6d, 0d, 0d)));- var result = BrepBoolean.Subtract(left, right);+ var result = BrepBoolean.Subtract(left, tangent);Assert.False(result.IsSuccess);var diagnostic = Assert.Single(result.Diagnostics);Assert.Equal(KernelDiagnosticCode.NotImplemented, diagnostic.Code);- Assert.Equal("BrepBoolean.UnsupportedAnalyticSurfaceKind", diagnostic.Source);- Assert.Equal("Boolean Subtract: analytic hole surface kind 'Sphere' is recognized but not implemented for M13 reconstruction.", diagnostic.Message);+ Assert.Equal("BrepBoolean.AnalyticHole.TangentContact", diagnostic.Source);+ Assert.Equal("Boolean Subtract: analytic hole candidate failed diagnostic TangentContact (cone top-plane cross-section is tangent to the box XY boundary.).", diagnostic.Message);}[Fact]- public void Union_BoxSphereOverlap_StillReturnsDeterministicNotImplemented()+ public void Add_BoxCylinder_StillReturnsDeterministicNotImplemented(){- var left = BrepBooleanBoxRecognition.CreateBoxFromExtents(new AxisAlignedBoxExtents(-20d, 20d, -15d, 15d, -6d, 6d)).Value;- var right = BrepPrimitives.CreateSphere(4d).Value;+ var left = BrepBooleanBoxRecognition.CreateBoxFromExtents(new AxisAlignedBoxExtents(-20d, 20d, -15d, 15d, 0d, 12d)).Value;+ var right = TransformBody(BrepPrimitives.CreateCylinder(4d, 20d).Value, Transform3D.CreateTranslation(new Vector3D(0d, 0d, 6d)));var result = BrepBoolean.Union(left, right);@@ -377,10 +462,10 @@ public sealed class BrepBooleanTests}[Fact]- public void Intersect_BoxSphereOverlap_StillReturnsDeterministicNotImplemented()+ public void Intersect_BoxCylinder_StillReturnsDeterministicNotImplemented(){- var left = BrepBooleanBoxRecognition.CreateBoxFromExtents(new AxisAlignedBoxExtents(-20d, 20d, -15d, 15d, -6d, 6d)).Value;- var right = BrepPrimitives.CreateSphere(4d).Value;+ var left = BrepBooleanBoxRecognition.CreateBoxFromExtents(new AxisAlignedBoxExtents(-20d, 20d, -15d, 15d, 0d, 12d)).Value;+ var right = TransformBody(BrepPrimitives.CreateCylinder(4d, 20d).Value, Transform3D.CreateTranslation(new Vector3D(0d, 0d, 6d)));var result = BrepBoolean.Intersect(left, right);@@ -390,11 +475,12 @@ public sealed class BrepBooleanTestsAssert.Equal("Boolean Intersect: M13 only supports recognized axis-aligned boxes from BrepPrimitives.CreateBox(...).", diagnostic.Message);}+[Fact]- public void Subtract_BoxPointedCone_StillReturnsDeterministicNotImplemented()+ public void Subtract_BoxSphereFullyContained_StillReturnsDeterministicNotImplemented(){- var left = BrepBooleanBoxRecognition.CreateBoxFromExtents(new AxisAlignedBoxExtents(-20d, 20d, -15d, 15d, 0d, 12d)).Value;- var right = CreateCone(bottomRadius: 6d, topRadius: 0d, height: 20d);+ var left = BrepBooleanBoxRecognition.CreateBoxFromExtents(new AxisAlignedBoxExtents(-20d, 20d, -15d, 15d, -6d, 6d)).Value;+ var right = BrepPrimitives.CreateSphere(4d).Value;var result = BrepBoolean.Subtract(left, right);@@ -402,22 +488,35 @@ public sealed class BrepBooleanTestsvar diagnostic = Assert.Single(result.Diagnostics);Assert.Equal(KernelDiagnosticCode.NotImplemented, diagnostic.Code);Assert.Equal("BrepBoolean.UnsupportedAnalyticSurfaceKind", diagnostic.Source);- Assert.Equal("Boolean Subtract: analytic hole surface kind 'Cone' is recognized but not implemented for M13 reconstruction.", diagnostic.Message);+ Assert.Equal("Boolean Subtract: analytic hole surface kind 'Sphere' is recognized but not implemented for M13 reconstruction.", diagnostic.Message);}[Fact]- public void Subtract_BoxFrustumCone_StillReturnsDeterministicNotImplemented()+ public void Union_BoxSphereOverlap_StillReturnsDeterministicNotImplemented(){- var left = BrepBooleanBoxRecognition.CreateBoxFromExtents(new AxisAlignedBoxExtents(-20d, 20d, -15d, 15d, 0d, 12d)).Value;- var right = CreateCone(bottomRadius: 6d, topRadius: 2d, height: 20d);+ var left = BrepBooleanBoxRecognition.CreateBoxFromExtents(new AxisAlignedBoxExtents(-20d, 20d, -15d, 15d, -6d, 6d)).Value;+ var right = BrepPrimitives.CreateSphere(4d).Value;- var result = BrepBoolean.Subtract(left, right);+ var result = BrepBoolean.Union(left, right);Assert.False(result.IsSuccess);var diagnostic = Assert.Single(result.Diagnostics);Assert.Equal(KernelDiagnosticCode.NotImplemented, diagnostic.Code);- Assert.Equal("BrepBoolean.UnsupportedAnalyticSurfaceKind", diagnostic.Source);- Assert.Equal("Boolean Subtract: analytic hole surface kind 'Cone' is recognized but not implemented for M13 reconstruction.", diagnostic.Message);+ Assert.Equal("Boolean Union: M13 only supports recognized axis-aligned boxes from BrepPrimitives.CreateBox(...).", diagnostic.Message);+ }++ [Fact]+ public void Intersect_BoxSphereOverlap_StillReturnsDeterministicNotImplemented()+ {+ var left = BrepBooleanBoxRecognition.CreateBoxFromExtents(new AxisAlignedBoxExtents(-20d, 20d, -15d, 15d, -6d, 6d)).Value;+ var right = BrepPrimitives.CreateSphere(4d).Value;++ var result = BrepBoolean.Intersect(left, right);++ Assert.False(result.IsSuccess);+ var diagnostic = Assert.Single(result.Diagnostics);+ Assert.Equal(KernelDiagnosticCode.NotImplemented, diagnostic.Code);+ Assert.Equal("Boolean Intersect: M13 only supports recognized axis-aligned boxes from BrepPrimitives.CreateBox(...).", diagnostic.Message);}[Fact]diff --git a/Aetheris.Kernel.Core/Brep/Boolean/BrepBoolean.cs b/Aetheris.Kernel.Core/Brep/Boolean/BrepBoolean.csindex 8e18e25d..0a425177 100644--- a/Aetheris.Kernel.Core/Brep/Boolean/BrepBoolean.cs+++ b/Aetheris.Kernel.Core/Brep/Boolean/BrepBoolean.cs@@ -238,7 +238,21 @@ public static class BrepBooleanDiagnostic: diagnostic);}- if (analyticSurface.Kind is AnalyticSurfaceKind.Cone or AnalyticSurfaceKind.Sphere or AnalyticSurfaceKind.Torus)+ if (analyticSurface.Kind == AnalyticSurfaceKind.Cone+ && analyticSurface.Cone is RecognizedCone cone+ && !BrepBooleanCylinderRecognition.ValidateThroughHole(left, cone, tolerance, out var coneDiagnostic))+ {+ return new BooleanClassificationData(+ intersections,+ IsComputed: true,+ FragmentCount: 0,+ SingleBoxResult: null,+ AnalyticHoleSurface: analyticSurface,+ UnsupportedReason: null,+ Diagnostic: coneDiagnostic);+ }++ if (analyticSurface.Kind is AnalyticSurfaceKind.Sphere or AnalyticSurfaceKind.Torus){return new BooleanClassificationData(intersections,diff --git a/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanAnalyticSurfaceRecognition.cs b/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanAnalyticSurfaceRecognition.csindex 8e5d3076..11730a65 100644--- a/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanAnalyticSurfaceRecognition.cs+++ b/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanAnalyticSurfaceRecognition.cs@@ -19,6 +19,7 @@ public readonly record struct RecognizedCone(Direction3D Axis,double MinAxisParameter,double MaxAxisParameter,+ double SemiAngleRadians,double RadiusAtMinAxisParameter,double RadiusAtMaxAxisParameter){@@ -27,6 +28,12 @@ public readonly record struct RecognizedCone(public Point3D MaxCenter => AxisOrigin + (Axis.ToVector() * MaxAxisParameter);public double MaxRadius => System.Math.Max(RadiusAtMinAxisParameter, RadiusAtMaxAxisParameter);++ public double RadiusScale => double.Tan(SemiAngleRadians);++ public Point3D PointAtAxisParameter(double axisParameter) => AxisOrigin + (Axis.ToVector() * axisParameter);++ public double RadiusAtAxisParameter(double axisParameter) => axisParameter * RadiusScale;}public readonly record struct RecognizedSphere(Point3D Center, double Radius);@@ -151,6 +158,7 @@ public static class BrepBooleanAnalyticSurfaceRecognitionaxis,samples[0].AxisParameter,samples[1].AxisParameter,+ coneSurface.SemiAngleRadians,samples[0].Radius,samples[1].Radius));return true;diff --git a/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanBoxCylinderHoleBuilder.cs b/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanBoxCylinderHoleBuilder.csindex 05beef78..f5ca5b2a 100644--- a/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanBoxCylinderHoleBuilder.cs+++ b/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanBoxCylinderHoleBuilder.cs@@ -24,7 +24,15 @@ public static class BrepBooleanBoxCylinderHoleBuilder}return CreateThroughHoleBody(outer, cylinder);- case AnalyticSurfaceKind.Cone:+ case AnalyticSurfaceKind.Cone when surface.Cone is RecognizedCone cone:+ if (!BrepBooleanCylinderRecognition.ValidateThroughHole(outer, cone, tolerance, out var coneDiagnostic))+ {+ return KernelResult<BrepBody>.Failure([+ coneDiagnostic!.ToKernelDiagnostic(),+ ]);+ }++ return CreateThroughHoleBody(outer, cone);case AnalyticSurfaceKind.Sphere:case AnalyticSurfaceKind.Torus:return KernelResult<BrepBody>.Failure([@@ -187,6 +195,169 @@ public static class BrepBooleanBoxCylinderHoleBuilder: KernelResult<BrepBody>.Failure(validation.Diagnostics);}+ private static KernelResult<BrepBody> CreateThroughHoleBody(AxisAlignedBoxExtents box, in RecognizedCone cone)+ {+ var builder = new TopologyBuilder();++ var v1 = builder.AddVertex();+ var v2 = builder.AddVertex();+ var v3 = builder.AddVertex();+ var v4 = builder.AddVertex();+ var v5 = builder.AddVertex();+ var v6 = builder.AddVertex();+ var v7 = builder.AddVertex();+ var v8 = builder.AddVertex();+ var topHoleVertex = builder.AddVertex();+ var bottomHoleVertex = builder.AddVertex();+ var seamTopVertex = builder.AddVertex();+ var seamBottomVertex = builder.AddVertex();++ var e1 = builder.AddEdge(v1, v2);+ var e2 = builder.AddEdge(v2, v3);+ var e3 = builder.AddEdge(v3, v4);+ var e4 = builder.AddEdge(v4, v1);+ var e5 = builder.AddEdge(v5, v6);+ var e6 = builder.AddEdge(v6, v7);+ var e7 = builder.AddEdge(v7, v8);+ var e8 = builder.AddEdge(v8, v5);+ var e9 = builder.AddEdge(v1, v5);+ var e10 = builder.AddEdge(v2, v6);+ var e11 = builder.AddEdge(v3, v7);+ var e12 = builder.AddEdge(v4, v8);+ var topCircle = builder.AddEdge(topHoleVertex, topHoleVertex);+ var bottomCircle = builder.AddEdge(bottomHoleVertex, bottomHoleVertex);+ var seam = builder.AddEdge(seamTopVertex, seamBottomVertex);++ var bottomOuterLoop = AddLoop(builder, [Forward(e1), Forward(e2), Forward(e3), Forward(e4)]);+ var topOuterLoop = AddLoop(builder, [Forward(e5), Forward(e6), Forward(e7), Forward(e8)]);+ var topInnerLoop = AddLoop(builder, [Forward(topCircle)]);+ var bottomInnerLoop = AddLoop(builder, [Reversed(bottomCircle)]);+ var bottomFace = builder.AddFace([bottomOuterLoop, bottomInnerLoop]);+ var topFace = builder.AddFace([topOuterLoop, topInnerLoop]);++ var xMinFace = builder.AddFace([AddLoop(builder, [Forward(e1), Forward(e10), Reversed(e5), Reversed(e9)])]);+ var xMaxFace = builder.AddFace([AddLoop(builder, [Forward(e2), Forward(e11), Reversed(e6), Reversed(e10)])]);+ var yMaxFace = builder.AddFace([AddLoop(builder, [Forward(e3), Forward(e12), Reversed(e7), Reversed(e11)])]);+ var yMinFace = builder.AddFace([AddLoop(builder, [Forward(e4), Forward(e9), Reversed(e8), Reversed(e12)])]);+ var holeFace = builder.AddFace([AddLoop(builder, [Forward(seam), Reversed(topCircle), Reversed(seam), Forward(bottomCircle)])]);++ var shell = builder.AddShell([bottomFace, topFace, xMinFace, xMaxFace, yMaxFace, yMinFace, holeFace]);+ builder.AddBody([shell]);++ var geometry = new BrepGeometryStore();+ var width = box.MaxX - box.MinX;+ var depth = box.MaxY - box.MinY;+ var height = box.MaxZ - box.MinZ;++ var p1 = new Point3D(box.MinX, box.MinY, box.MinZ);+ var p2 = new Point3D(box.MaxX, box.MinY, box.MinZ);+ var p3 = new Point3D(box.MaxX, box.MaxY, box.MinZ);+ var p4 = new Point3D(box.MinX, box.MaxY, box.MinZ);+ var p5 = new Point3D(box.MinX, box.MinY, box.MaxZ);+ var p6 = new Point3D(box.MaxX, box.MinY, box.MaxZ);+ var p7 = new Point3D(box.MaxX, box.MaxY, box.MaxZ);+ var p8 = new Point3D(box.MinX, box.MaxY, box.MaxZ);++ var zAxis = Direction3D.Create(new Vector3D(0d, 0d, 1d));+ var xAxis = Direction3D.Create(new Vector3D(1d, 0d, 0d));+ var yAxis = Direction3D.Create(new Vector3D(0d, 1d, 0d));++ var bottomAxisParameter = AxisParameterAtZ(cone, box.MinZ);+ var topAxisParameter = AxisParameterAtZ(cone, box.MaxZ);+ var bottomCenter = cone.PointAtAxisParameter(bottomAxisParameter);+ var topCenter = cone.PointAtAxisParameter(topAxisParameter);+ var bottomRadius = cone.RadiusAtAxisParameter(bottomAxisParameter);+ var topRadius = cone.RadiusAtAxisParameter(topAxisParameter);+ var seamBottomPoint = new Point3D(bottomCenter.X + bottomRadius, bottomCenter.Y, bottomCenter.Z);+ var seamTopPoint = new Point3D(topCenter.X + topRadius, topCenter.Y, topCenter.Z);++ var lineCurves = new[]+ {+ (p1, new Vector3D(width, 0d, 0d)),+ (p2, new Vector3D(0d, depth, 0d)),+ (p3, new Vector3D(-width, 0d, 0d)),+ (p4, new Vector3D(0d, -depth, 0d)),+ (p5, new Vector3D(width, 0d, 0d)),+ (p6, new Vector3D(0d, depth, 0d)),+ (p7, new Vector3D(-width, 0d, 0d)),+ (p8, new Vector3D(0d, -depth, 0d)),+ (p1, new Vector3D(0d, 0d, height)),+ (p2, new Vector3D(0d, 0d, height)),+ (p3, new Vector3D(0d, 0d, height)),+ (p4, new Vector3D(0d, 0d, height)),+ (topCenter, zAxis.ToVector()),+ (bottomCenter, zAxis.ToVector()),+ (seamTopPoint, seamBottomPoint - seamTopPoint),+ };++ for (var i = 0; i < 12; i++)+ {+ geometry.AddCurve(new CurveGeometryId(i + 1), CurveGeometry.FromLine(new Line3Curve(lineCurves[i].Item1, Direction3D.Create(lineCurves[i].Item2))));+ }++ geometry.AddCurve(new CurveGeometryId(13), CurveGeometry.FromCircle(new Circle3Curve(topCenter, zAxis, topRadius, xAxis)));+ geometry.AddCurve(new CurveGeometryId(14), CurveGeometry.FromCircle(new Circle3Curve(bottomCenter, zAxis, bottomRadius, xAxis)));+ geometry.AddCurve(new CurveGeometryId(15), CurveGeometry.FromLine(new Line3Curve(seamTopPoint, Direction3D.Create(lineCurves[14].Item2))));++ geometry.AddSurface(new SurfaceGeometryId(1), SurfaceGeometry.FromPlane(new PlaneSurface(new Point3D(0d, 0d, box.MinZ), Direction3D.Create(new Vector3D(0d, 0d, -1d)), xAxis)));+ geometry.AddSurface(new SurfaceGeometryId(2), SurfaceGeometry.FromPlane(new PlaneSurface(new Point3D(0d, 0d, box.MaxZ), zAxis, xAxis)));+ geometry.AddSurface(new SurfaceGeometryId(3), SurfaceGeometry.FromPlane(new PlaneSurface(new Point3D(0d, box.MinY, 0d), Direction3D.Create(new Vector3D(0d, -1d, 0d)), xAxis)));+ geometry.AddSurface(new SurfaceGeometryId(4), SurfaceGeometry.FromPlane(new PlaneSurface(new Point3D(box.MaxX, 0d, 0d), Direction3D.Create(new Vector3D(1d, 0d, 0d)), yAxis)));+ geometry.AddSurface(new SurfaceGeometryId(5), SurfaceGeometry.FromPlane(new PlaneSurface(new Point3D(0d, box.MaxY, 0d), Direction3D.Create(new Vector3D(0d, 1d, 0d)), Direction3D.Create(new Vector3D(-1d, 0d, 0d)))));+ geometry.AddSurface(new SurfaceGeometryId(6), SurfaceGeometry.FromPlane(new PlaneSurface(new Point3D(box.MinX, 0d, 0d), Direction3D.Create(new Vector3D(-1d, 0d, 0d)), yAxis)));++ var innerMinAxisParameter = System.Math.Min(bottomAxisParameter, topAxisParameter);+ var innerMinCenter = cone.PointAtAxisParameter(innerMinAxisParameter);+ var innerMinRadius = cone.RadiusAtAxisParameter(innerMinAxisParameter);+ geometry.AddSurface(new SurfaceGeometryId(7), SurfaceGeometry.FromCone(new ConeSurface(innerMinCenter, cone.Axis, innerMinRadius, cone.SemiAngleRadians, xAxis)));++ var bindings = new BrepBindingModel();+ for (var i = 0; i < 12; i++)+ {+ bindings.AddEdgeBinding(new EdgeGeometryBinding(new EdgeId(i + 1), new CurveGeometryId(i + 1), new ParameterInterval(0d, 1d)));+ }++ bindings.AddEdgeBinding(new EdgeGeometryBinding(topCircle, new CurveGeometryId(13), new ParameterInterval(0d, 2d * double.Pi)));+ bindings.AddEdgeBinding(new EdgeGeometryBinding(bottomCircle, new CurveGeometryId(14), new ParameterInterval(0d, 2d * double.Pi)));+ bindings.AddEdgeBinding(new EdgeGeometryBinding(seam, new CurveGeometryId(15), new ParameterInterval(0d, (seamBottomPoint - seamTopPoint).Length)));++ bindings.AddFaceBinding(new FaceGeometryBinding(bottomFace, new SurfaceGeometryId(1)));+ bindings.AddFaceBinding(new FaceGeometryBinding(topFace, new SurfaceGeometryId(2)));+ bindings.AddFaceBinding(new FaceGeometryBinding(xMinFace, new SurfaceGeometryId(3)));+ bindings.AddFaceBinding(new FaceGeometryBinding(xMaxFace, new SurfaceGeometryId(4)));+ bindings.AddFaceBinding(new FaceGeometryBinding(yMaxFace, new SurfaceGeometryId(5)));+ bindings.AddFaceBinding(new FaceGeometryBinding(yMinFace, new SurfaceGeometryId(6)));+ bindings.AddFaceBinding(new FaceGeometryBinding(holeFace, new SurfaceGeometryId(7)));++ var vertexPoints = new Dictionary<VertexId, Point3D>+ {+ [v1] = p1,+ [v2] = p2,+ [v3] = p3,+ [v4] = p4,+ [v5] = p5,+ [v6] = p6,+ [v7] = p7,+ [v8] = p8,+ [topHoleVertex] = seamTopPoint,+ [bottomHoleVertex] = seamBottomPoint,+ [seamTopVertex] = seamTopPoint,+ [seamBottomVertex] = seamBottomPoint,+ };++ var body = new BrepBody(builder.Model, geometry, bindings, vertexPoints);+ var validation = BrepBindingValidator.Validate(body, requireAllEdgeAndFaceBindings: true);+ return validation.IsSuccess+ ? KernelResult<BrepBody>.Success(body, validation.Diagnostics)+ : KernelResult<BrepBody>.Failure(validation.Diagnostics);+ }++ private static double AxisParameterAtZ(in RecognizedCone cone, double z)+ {+ var axisZ = cone.Axis.ToVector().Z;+ return (z - cone.AxisOrigin.Z) / axisZ;+ }+private static LoopId AddLoop(TopologyBuilder builder, IReadOnlyList<EdgeUse> edgeUses){var loopId = builder.AllocateLoopId();diff --git a/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanCylinderRecognition.cs b/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanCylinderRecognition.csindex 396e8218..ab5169b5 100644--- a/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanCylinderRecognition.cs+++ b/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanCylinderRecognition.cs@@ -209,16 +209,16 @@ public static class BrepBooleanCylinderRecognitionreturn true;}- public static bool ValidateThroughHole(AxisAlignedBoxExtents box, in RecognizedCone cone, ToleranceContext tolerance, out string reason)+ public static bool ValidateThroughHole(AxisAlignedBoxExtents box, in RecognizedCone cone, ToleranceContext tolerance, out BooleanDiagnostic? diagnostic){- reason = string.Empty;+ diagnostic = null;var axis = cone.Axis.ToVector();if (!ToleranceMath.AlmostZero(axis.X, tolerance)|| !ToleranceMath.AlmostZero(axis.Y, tolerance)|| !ToleranceMath.AlmostEqual(double.Abs(axis.Z), 1d, tolerance)){- reason = "cone axis is not aligned with the box Z axis.";+ diagnostic = CreateAxisNotAlignedDiagnostic(BooleanOperation.Subtract.ToString(), "cone axis is not aligned with the box Z axis.");return false;}@@ -226,28 +226,92 @@ public static class BrepBooleanCylinderRecognitionvar maxCenter = cone.MaxCenter;if (!ToleranceMath.AlmostEqual(minCenter.X, maxCenter.X, tolerance) || !ToleranceMath.AlmostEqual(minCenter.Y, maxCenter.Y, tolerance)){- reason = "cone cap centers are not vertically aligned in XY.";+ diagnostic = CreateAxisNotAlignedDiagnostic(BooleanOperation.Subtract.ToString(), "cone cap centers are not vertically aligned in XY.");return false;}- var centerX = minCenter.X;- var centerY = minCenter.Y;- var minZ = System.Math.Min(minCenter.Z, maxCenter.Z);- var maxZ = System.Math.Max(minCenter.Z, maxCenter.Z);- var maxRadius = cone.MaxRadius;+ var bottomAxisParameter = AxisParameterAtZ(cone, box.MinZ, tolerance);+ var topAxisParameter = AxisParameterAtZ(cone, box.MaxZ, tolerance);- if (minZ > (box.MinZ + tolerance.Linear) || maxZ < (box.MaxZ - tolerance.Linear))+ if (bottomAxisParameter < (cone.MinAxisParameter - tolerance.Linear)+ || bottomAxisParameter > (cone.MaxAxisParameter + tolerance.Linear)+ || topAxisParameter < (cone.MinAxisParameter - tolerance.Linear)+ || topAxisParameter > (cone.MaxAxisParameter + tolerance.Linear))+ {+ diagnostic = CreateNotFullySpanningDiagnostic(BooleanOperation.Subtract.ToString(), "cone does not fully span the box Z range.");+ return false;+ }++ if (bottomAxisParameter <= tolerance.Linear || topAxisParameter <= tolerance.Linear)+ {+ diagnostic = CreateNotFullySpanningDiagnostic(BooleanOperation.Subtract.ToString(), "cone apex or termination prevents circular through-hole sections at both box Z boundary planes.");+ return false;+ }++ var centerX = cone.AxisOrigin.X;+ var centerY = cone.AxisOrigin.Y;+ var bottomRadius = cone.RadiusAtAxisParameter(bottomAxisParameter);+ var topRadius = cone.RadiusAtAxisParameter(topAxisParameter);++ if (bottomRadius <= tolerance.Linear || topRadius <= tolerance.Linear)+ {+ diagnostic = CreateNotFullySpanningDiagnostic(BooleanOperation.Subtract.ToString(), "cone cross-sections at the box Z boundary planes must be non-degenerate circles.");+ return false;+ }++ if (!ValidateCircleInsideBoxFootprint(box, centerX, centerY, bottomRadius, tolerance, out diagnostic, "cone bottom-plane cross-section")+ || !ValidateCircleInsideBoxFootprint(box, centerX, centerY, topRadius, tolerance, out diagnostic, "cone top-plane cross-section")){- reason = "cone does not fully span the box Z range.";return false;}- if ((centerX - maxRadius) <= (box.MinX + tolerance.Linear)- || (centerX + maxRadius) >= (box.MaxX - tolerance.Linear)- || (centerY - maxRadius) <= (box.MinY + tolerance.Linear)- || (centerY + maxRadius) >= (box.MaxY - tolerance.Linear))+ return true;+ }++ private static double AxisParameterAtZ(in RecognizedCone cone, double z, ToleranceContext tolerance)+ {+ var axisZ = cone.Axis.ToVector().Z;+ if (ToleranceMath.AlmostZero(axisZ, tolerance))+ {+ throw new InvalidOperationException("AxisParameterAtZ requires a cone axis aligned with Z.");+ }++ return (z - cone.AxisOrigin.Z) / axisZ;+ }++ private static bool ValidateCircleInsideBoxFootprint(+ AxisAlignedBoxExtents box,+ double centerX,+ double centerY,+ double radius,+ ToleranceContext tolerance,+ out BooleanDiagnostic? diagnostic,+ string circleLabel)+ {+ diagnostic = null;++ var minFootprintX = centerX - radius;+ var maxFootprintX = centerX + radius;+ var minFootprintY = centerY - radius;+ var maxFootprintY = centerY + radius;++ var tangentContact =+ ToleranceMath.AlmostEqual(minFootprintX, box.MinX, tolerance)+ || ToleranceMath.AlmostEqual(maxFootprintX, box.MaxX, tolerance)+ || ToleranceMath.AlmostEqual(minFootprintY, box.MinY, tolerance)+ || ToleranceMath.AlmostEqual(maxFootprintY, box.MaxY, tolerance);+ if (tangentContact)+ {+ diagnostic = CreateTangentContactDiagnostic(BooleanOperation.Subtract.ToString(), $"{circleLabel} is tangent to the box XY boundary.");+ return false;+ }++ if (minFootprintX < (box.MinX - tolerance.Linear)+ || maxFootprintX > (box.MaxX + tolerance.Linear)+ || minFootprintY < (box.MinY - tolerance.Linear)+ || maxFootprintY > (box.MaxY + tolerance.Linear)){- reason = "cone radial footprint must stay strictly inside the box XY footprint.";+ diagnostic = CreateRadiusExceedsBoundaryDiagnostic(BooleanOperation.Subtract.ToString(), $"{circleLabel} exceeds the box XY boundary.");return false;}diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentBooleanCanonicalSuccessTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentBooleanCanonicalSuccessTests.csindex fbd24fe8..d1182422 100644--- a/Aetheris.Kernel.Firmament.Tests/FirmamentBooleanCanonicalSuccessTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentBooleanCanonicalSuccessTests.cs@@ -11,7 +11,8 @@ public sealed class FirmamentBooleanCanonicalSuccessTests{ "testdata/firmament/examples/boolean_add_basic.firmament", "joined", FirmamentLoweredBooleanKind.Add },{ "testdata/firmament/examples/boolean_subtract_basic.firmament", "carved", FirmamentLoweredBooleanKind.Subtract },{ "testdata/firmament/examples/boolean_intersect_basic.firmament", "overlap", FirmamentLoweredBooleanKind.Intersect },- { "testdata/firmament/examples/boolean_box_cylinder_hole.firmament", "hole", FirmamentLoweredBooleanKind.Subtract }+ { "testdata/firmament/examples/boolean_box_cylinder_hole.firmament", "hole", FirmamentLoweredBooleanKind.Subtract },+ { "testdata/firmament/examples/boolean_box_cone_throughhole_basic.firmament", "cut", FirmamentLoweredBooleanKind.Subtract }};[Theory]@@ -36,6 +37,7 @@ public sealed class FirmamentBooleanCanonicalSuccessTests[InlineData("testdata/firmament/examples/boolean_subtract_basic.firmament", "carved", 2, "subtract")][InlineData("testdata/firmament/examples/boolean_intersect_basic.firmament", "overlap", 2, "intersect")][InlineData("testdata/firmament/examples/boolean_box_cylinder_hole.firmament", "hole", 1, "subtract")]+ [InlineData("testdata/firmament/examples/boolean_box_cone_throughhole_basic.firmament", "cut", 1, "subtract")]public void CanonicalBooleanExamples_Export_Deterministically_WithExpectedMarkers(string fixturePath, string expectedFeatureId, int expectedOpIndex, string expectedKind){var first = ExportFixture(fixturePath);@@ -60,7 +62,9 @@ public sealed class FirmamentBooleanCanonicalSuccessTestsvar unsupportedSingleBoxSubtract = FirmamentCorpusHarness.Compile(FirmamentCorpusHarness.ReadFixtureText("testdata/firmament/fixtures/m3d-valid-subtract-exec.firmament"));var supportedCylinderHoleExport = ExportFixture("testdata/firmament/examples/boolean_box_cylinder_hole.firmament");+ var supportedConeHoleExport = ExportFixture("testdata/firmament/examples/boolean_box_cone_throughhole_basic.firmament");var unsupportedCylinderHoleExport = ExportFixture("testdata/firmament/fixtures/m10h1-unsupported-box-with-cylinder-hole.firmament");+ var unsupportedConeHoleExport = ExportFixture("testdata/firmament/fixtures/m10m-unsupported-box-subtract-cone.firmament");Assert.False(unsupportedSingleBoxSubtract.Compilation.IsSuccess);Assert.Contains(unsupportedSingleBoxSubtract.Compilation.Diagnostics, diagnostic =>@@ -70,12 +74,22 @@ public sealed class FirmamentBooleanCanonicalSuccessTestsAssert.True(supportedCylinderHoleExport.IsSuccess);Assert.Contains("CYLINDRICAL_SURFACE", supportedCylinderHoleExport.Value.StepText, StringComparison.Ordinal);+ Assert.True(supportedConeHoleExport.IsSuccess);+ Assert.Contains("CONICAL_SURFACE", supportedConeHoleExport.Value.StepText, StringComparison.Ordinal);+Assert.False(unsupportedCylinderHoleExport.IsSuccess);Assert.Contains(unsupportedCylinderHoleExport.Diagnostics, diagnostic =>diagnostic.Code == KernelDiagnosticCode.NotImplemented&& diagnostic.Message.Contains("Requested boolean feature 'hole' (subtract) could not be executed.", StringComparison.Ordinal));Assert.DoesNotContain(unsupportedCylinderHoleExport.Diagnostics, diagnostic =>diagnostic.Message.Contains("requires at least one executed primitive or boolean body", StringComparison.Ordinal));++ Assert.False(unsupportedConeHoleExport.IsSuccess);+ Assert.Contains(unsupportedConeHoleExport.Diagnostics, diagnostic =>+ diagnostic.Code == KernelDiagnosticCode.NotImplemented+ && diagnostic.Message.Contains("Requested boolean feature 'tapered_cut' (subtract) could not be executed.", StringComparison.Ordinal));+ Assert.DoesNotContain(unsupportedConeHoleExport.Diagnostics, diagnostic =>+ diagnostic.Message.Contains("requires at least one executed primitive or boolean body", StringComparison.Ordinal));}public static TheoryData<string, string, string> UnsupportedMixedPrimitiveBooleanFixtures =>@@ -164,7 +178,7 @@ public sealed class FirmamentBooleanCanonicalSuccessTestsprivate static bool HasExpectedMixedPrimitiveFailure(string message)=> message.Contains("M13 only supports recognized axis-aligned boxes from BrepPrimitives.CreateBox(...).", StringComparison.Ordinal)- || message.Contains("analytic hole candidate violates M13 constraints", StringComparison.Ordinal)+ || message.Contains("analytic hole candidate failed diagnostic", StringComparison.Ordinal)|| message.Contains("analytic hole surface kind", StringComparison.Ordinal);private static string CreateBoxTorusSource(string op, string featureId, string targetField, string nameSuffix, double offsetX, double offsetY, double offsetZ, double majorRadius = 6d, double minorRadius = 2d) =>diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentBuildAndExportTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentBuildAndExportTests.csindex 20ead6f5..2e8177f5 100644--- a/Aetheris.Kernel.Firmament.Tests/FirmamentBuildAndExportTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentBuildAndExportTests.cs@@ -137,6 +137,18 @@ public sealed class FirmamentBuildAndExportTests"subtract");}+ [Fact]+ public void Run_BooleanBoxConeThroughHoleExample_Writes_Default_Export_Artifact()+ {+ AssertExampleBuildAndExport(+ "testdata/firmament/examples/boolean_box_cone_throughhole_basic.firmament",+ "boolean_box_cone_throughhole_basic.step",+ "cut",+ 1,+ "boolean",+ "subtract");+ }+[Fact]public void Run_UnsupportedBoxWithCylinderHoleFixture_Fails_And_Does_Not_Write_Fallback_Export(){@@ -153,6 +165,9 @@ public sealed class FirmamentBuildAndExportTests[InlineData("testdata/firmament/fixtures/m10l-unsupported-box-subtract-sphere-contained.firmament", "m10l-unsupported-box-subtract-sphere-contained.step", "cavity", "subtract")][InlineData("testdata/firmament/fixtures/m10l-unsupported-box-add-sphere.firmament", "m10l-unsupported-box-add-sphere.step", "joined", "add")][InlineData("testdata/firmament/fixtures/m10l-unsupported-box-intersect-sphere.firmament", "m10l-unsupported-box-intersect-sphere.step", "overlap", "intersect")]+ [InlineData("testdata/firmament/fixtures/m10m-unsupported-box-subtract-cone.firmament", "m10m-unsupported-box-subtract-cone.step", "tapered_cut", "subtract")]+ [InlineData("testdata/firmament/fixtures/m10m-unsupported-box-add-cone.firmament", "m10m-unsupported-box-add-cone.step", "joined", "add")]+ [InlineData("testdata/firmament/fixtures/m10m-unsupported-box-intersect-cone.firmament", "m10m-unsupported-box-intersect-cone.step", "overlap", "intersect")]public void Run_Unsupported_MixedPrimitive_Fixtures_Fail_And_Do_Not_Write_Fallback_Export(string sourcePath,string expectedFileName,diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentStepExporterTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentStepExporterTests.csindex 5ffe93b6..20b9767a 100644--- a/Aetheris.Kernel.Firmament.Tests/FirmamentStepExporterTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentStepExporterTests.cs@@ -83,6 +83,27 @@ public sealed class FirmamentStepExporterTestsAssert.Contains("MANIFOLD_SOLID_BREP", first.Value.StepText, StringComparison.Ordinal);}+ [Fact]+ public void Export_SupportedBoxConeThroughHole_Exports_Deterministically_With_ConicalSurface_And_Persisted_Artifact()+ {+ var first = ExportFixture("testdata/firmament/examples/boolean_box_cone_throughhole_basic.firmament");+ var second = ExportFixture("testdata/firmament/examples/boolean_box_cone_throughhole_basic.firmament");++ Assert.True(first.IsSuccess);+ Assert.True(second.IsSuccess);+ Assert.Equal(first.Value.StepText, second.Value.StepText);+ Assert.Equal("cut", first.Value.ExportedFeatureId);+ Assert.Equal(1, first.Value.ExportedOpIndex);+ Assert.Equal("boolean", first.Value.ExportedBodyCategory);+ Assert.Equal("subtract", first.Value.ExportedFeatureKind);+ Assert.Contains("CONICAL_SURFACE", first.Value.StepText, StringComparison.Ordinal);+ Assert.Contains("MANIFOLD_SOLID_BREP", first.Value.StepText, StringComparison.Ordinal);++ var artifactPath = WriteExportArtifact("boolean_box_cone_throughhole_basic.step", first.Value.StepText);+ Assert.True(File.Exists(artifactPath));+ Assert.Equal(first.Value.StepText, File.ReadAllText(artifactPath));+ }+[Fact]public void Export_UnsupportedBoxWithCylinderHole_Fails_Instead_Of_Falling_Back_To_Base_Primitive(){diff --git a/Aetheris.Kernel.Firmament/Execution/FirmamentPrimitiveExecutor.cs b/Aetheris.Kernel.Firmament/Execution/FirmamentPrimitiveExecutor.csindex 036227c2..b70abcf2 100644--- a/Aetheris.Kernel.Firmament/Execution/FirmamentPrimitiveExecutor.cs+++ b/Aetheris.Kernel.Firmament/Execution/FirmamentPrimitiveExecutor.cs@@ -108,6 +108,7 @@ internal static class FirmamentPrimitiveExecutor{FirmamentLoweredPrimitiveKind.Box => TranslateBody(body, new Vector3D(0d, 0d, ((FirmamentLoweredBoxParameters)primitive.Parameters).SizeZ * 0.5d)),FirmamentLoweredPrimitiveKind.Cylinder => TranslateBody(body, new Vector3D(0d, 0d, ((FirmamentLoweredCylinderParameters)primitive.Parameters).Height * 0.5d)),+ FirmamentLoweredPrimitiveKind.Cone => TranslateBody(body, new Vector3D(0d, 0d, ((FirmamentLoweredConeParameters)primitive.Parameters).Height * 0.5d)),_ => body};}@@ -133,13 +134,20 @@ internal static class FirmamentPrimitiveExecutoruAxis: Direction3D.Create(new Vector3D(1d, 0d, 0d)));var axis = new RevolveAxis3D(Point3D.Origin, new Vector3D(0d, 0d, 1d));- return BrepRevolve.Create(+ var coneResult = BrepRevolve.Create([new ProfilePoint2D(parameters.BottomRadius, 0d),new ProfilePoint2D(parameters.TopRadius, parameters.Height)],frame,axis);++ if (!coneResult.IsSuccess)+ {+ return coneResult;+ }++ return KernelResult<BrepBody>.Success(TranslateBody(coneResult.Value, new Vector3D(0d, 0d, -parameters.Height * 0.5d)));}private static KernelResult<BrepBody> ExecuteTool(FirmamentLoweredToolOp tool)diff --git a/testdata/firmament/examples/README.md b/testdata/firmament/examples/README.mdindex 16764d98..13e20758 100644--- a/testdata/firmament/examples/README.md+++ b/testdata/firmament/examples/README.md@@ -16,7 +16,8 @@ Other combinations may fail and are intentionally not supported yet.- `boolean_subtract_basic.firmament` — canonical proven boolean subtract example for the current box/box single-box subset; helper export path: `testdata/firmament/exports/boolean_subtract_basic.step`.- `boolean_intersect_basic.firmament` — canonical proven boolean intersect example for the current box/box single-box subset; helper export path: `testdata/firmament/exports/boolean_intersect_basic.step`.- `boolean_box_cylinder_hole.firmament` — the only supported box+cylinder boolean case: subtracting a Z-aligned cylinder that cleanly spans the full box height to form a single box-with-through-hole solid; helper export path: `testdata/firmament/exports/boolean_box_cylinder_hole.step`.+- `boolean_box_cone_throughhole_basic.firmament` — the narrow supported box+cone boolean case: subtracting a Z-aligned cone that cleanly spans the full box height, keeps both boundary circles strictly inside the box footprint, and reconstructs as one box-with-conical-through-hole solid; helper export path: `testdata/firmament/exports/boolean_box_cone_throughhole_basic.step`.- `placed_primitive.firmament` — selector-based placement using `place.on` and `offset[3]`; helper export path: `testdata/firmament/exports/placed_primitive.step`.- `schema_box_basic.firmament` — minimal schema-present export example showing schema presence without changing export body semantics; helper export path: `testdata/firmament/exports/schema_box_basic.step`.-Unsupported boolean requests are tracked as fixtures/tests, not presented in this working example pack. The only supported box+cylinder case is `subtract(box, cylinder)` where the cylinder stays axis-aligned with +Z/-Z, fully spans the box from bottom face to top face, and remains strictly inside the box footprint so the result is one connected box-with-through-hole solid. Box+cylinder `add`, box+cylinder `intersect`, rotated cylinders, partial-depth cuts, tangent/grazing cases, and outside-footprint cuts remain unsupported. Box+sphere booleans are currently unsupported in all audited forms, including `subtract(box, sphere)` with a fully contained sphere, boundary-touching sphere, or partially outside sphere, plus all current box+sphere `add` and `intersect` requests. Box+cone booleans are also currently unsupported in all audited forms, including `subtract(box, cone)` with both pointed-cone and frustum-cone tools, plus all current box+cone `add` and `intersect` requests. Box+torus booleans are currently unsupported in every audited form: `subtract(box, torus)`, `add(box, torus)`, and `intersect(box, torus)` all fail the real kernel boundary for centered, offset, fully contained, face-intersecting, and outside-footprint torus placements, so no box+torus example is included here. These files are intended to stay minimal, readable, and aligned with the implemented language surface. Export artifacts are kept separately under `testdata/firmament/exports/` so examples remain source-only and demo outputs stay easy to find.+Unsupported boolean requests are tracked as fixtures/tests, not presented in this working example pack. The supported box+cylinder subset remains only `subtract(box, cylinder)` where the cylinder stays axis-aligned with +Z/-Z, fully spans the box from bottom face to top face, and remains strictly inside the box footprint so the result is one connected box-with-through-hole solid. The supported box+cone subset is similarly narrow: only `subtract(box, cone)` where the cone stays axis-aligned with +Z/-Z, spans the full box Z range, produces non-degenerate circular sections at both box boundary planes, and keeps both boundary circles strictly inside the box footprint so the result remains one connected box-with-conical-through-hole solid. Box+cylinder `add`, box+cylinder `intersect`, rotated cylinders, partial-depth cuts, tangent/grazing cases, and outside-footprint cuts remain unsupported. Box+cone `add`, box+cone `intersect`, tilted cones, partial-depth cone cuts, tangent/grazing cone cuts, apex-inside cases, and outside-footprint cone cuts remain unsupported. Box+sphere booleans are currently unsupported in all audited forms, including `subtract(box, sphere)` with a fully contained sphere, boundary-touching sphere, or partially outside sphere, plus all current box+sphere `add` and `intersect` requests. Box+torus booleans are currently unsupported in every audited form: `subtract(box, torus)`, `add(box, torus)`, and `intersect(box, torus)` all fail the real kernel boundary for centered, offset, fully contained, face-intersecting, and outside-footprint torus placements, so no box+torus example is included here. These files are intended to stay minimal, readable, and aligned with the implemented language surface. Export artifacts are kept separately under `testdata/firmament/exports/` so examples remain source-only and demo outputs stay easy to find.diff --git a/testdata/firmament/examples/boolean_box_cone_throughhole_basic.firmament b/testdata/firmament/examples/boolean_box_cone_throughhole_basic.firmamentnew file mode 100644index 00000000..815a3da8--- /dev/null+++ b/testdata/firmament/examples/boolean_box_cone_throughhole_basic.firmament@@ -0,0 +1,31 @@+firmament:+ version: 1++model:+ name: boolean_box_cone_throughhole_basic+ units: mm++ops[2]:+ -+ op: box+ id: base+ size[3]:+ 20+ 20+ 10++ -+ op: subtract+ id: cut+ from: base+ with:+ op: cone+ bottom_radius: 4+ top_radius: 2+ height: 10+ place:+ on: origin+ offset[3]:+ 0+ 0+ -5diff --git a/testdata/firmament/exports/boolean_box_cone_throughhole_basic.step b/testdata/firmament/exports/boolean_box_cone_throughhole_basic.stepnew file mode 100644index 00000000..5f17aebd--- /dev/null+++ b/testdata/firmament/exports/boolean_box_cone_throughhole_basic.step@@ -0,0 +1,215 @@+ISO-10303-21;+HEADER;+FILE_DESCRIPTION(('Aetheris AP242 subset export'),'2;1');+FILE_NAME('aetheris_export.step','1970-01-01T00:00:00',('Aetheris'),('Aetheris'),'Aetheris.Kernel','Aetheris.Kernel','');+FILE_SCHEMA(('AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF'));+ENDSEC;+DATA;+#1=CARTESIAN_POINT($,(0,0,-10));+#2=DIRECTION($,(0,0,-1));+#3=DIRECTION($,(1,0,0));+#4=AXIS2_PLACEMENT_3D($,#1,#2,#3);+#5=PLANE($,#4);+#6=CARTESIAN_POINT($,(-10,-10,-10));+#7=VERTEX_POINT($,#6);+#8=CARTESIAN_POINT($,(10,-10,-10));+#9=VERTEX_POINT($,#8);+#10=CARTESIAN_POINT($,(-10,-10,-10));+#11=DIRECTION($,(1,0,0));+#12=VECTOR($,#11,1);+#13=LINE($,#10,#12);+#14=EDGE_CURVE($,#7,#9,#13,.T.);+#15=ORIENTED_EDGE($,$,$,#14,.T.);+#16=CARTESIAN_POINT($,(10,10,-10));+#17=VERTEX_POINT($,#16);+#18=CARTESIAN_POINT($,(10,-10,-10));+#19=DIRECTION($,(0,1,0));+#20=VECTOR($,#19,1);+#21=LINE($,#18,#20);+#22=EDGE_CURVE($,#9,#17,#21,.T.);+#23=ORIENTED_EDGE($,$,$,#22,.T.);+#24=CARTESIAN_POINT($,(-10,10,-10));+#25=VERTEX_POINT($,#24);+#26=CARTESIAN_POINT($,(10,10,-10));+#27=DIRECTION($,(-1,0,0));+#28=VECTOR($,#27,1);+#29=LINE($,#26,#28);+#30=EDGE_CURVE($,#17,#25,#29,.T.);+#31=ORIENTED_EDGE($,$,$,#30,.T.);+#32=CARTESIAN_POINT($,(-10,10,-10));+#33=DIRECTION($,(0,-1,0));+#34=VECTOR($,#33,1);+#35=LINE($,#32,#34);+#36=EDGE_CURVE($,#25,#7,#35,.T.);+#37=ORIENTED_EDGE($,$,$,#36,.T.);+#38=EDGE_LOOP($,(#15,#23,#31,#37));+#39=FACE_OUTER_BOUND('',#38,.T.);+#40=CARTESIAN_POINT($,(4,0,-10));+#41=VERTEX_POINT($,#40);+#42=CARTESIAN_POINT($,(0,0,-10));+#43=DIRECTION($,(0,0,1));+#44=DIRECTION($,(1,0,0));+#45=AXIS2_PLACEMENT_3D($,#42,#43,#44);+#46=CIRCLE($,#45,4);+#47=EDGE_CURVE($,#41,#41,#46,.T.);+#48=ORIENTED_EDGE($,$,$,#47,.F.);+#49=EDGE_LOOP($,(#48));+#50=FACE_BOUND('',#49,.T.);+#51=ADVANCED_FACE('',(#39,#50),#5,.T.);+#52=CARTESIAN_POINT($,(0,0,0));+#53=DIRECTION($,(0,0,1));+#54=DIRECTION($,(1,0,0));+#55=AXIS2_PLACEMENT_3D($,#52,#53,#54);+#56=PLANE($,#55);+#57=CARTESIAN_POINT($,(-10,-10,0));+#58=VERTEX_POINT($,#57);+#59=CARTESIAN_POINT($,(10,-10,0));+#60=VERTEX_POINT($,#59);+#61=CARTESIAN_POINT($,(-10,-10,0));+#62=DIRECTION($,(1,0,0));+#63=VECTOR($,#62,1);+#64=LINE($,#61,#63);+#65=EDGE_CURVE($,#58,#60,#64,.T.);+#66=ORIENTED_EDGE($,$,$,#65,.T.);+#67=CARTESIAN_POINT($,(10,10,0));+#68=VERTEX_POINT($,#67);+#69=CARTESIAN_POINT($,(10,-10,0));+#70=DIRECTION($,(0,1,0));+#71=VECTOR($,#70,1);+#72=LINE($,#69,#71);+#73=EDGE_CURVE($,#60,#68,#72,.T.);+#74=ORIENTED_EDGE($,$,$,#73,.T.);+#75=CARTESIAN_POINT($,(-10,10,0));+#76=VERTEX_POINT($,#75);+#77=CARTESIAN_POINT($,(10,10,0));+#78=DIRECTION($,(-1,0,0));+#79=VECTOR($,#78,1);+#80=LINE($,#77,#79);+#81=EDGE_CURVE($,#68,#76,#80,.T.);+#82=ORIENTED_EDGE($,$,$,#81,.T.);+#83=CARTESIAN_POINT($,(-10,10,0));+#84=DIRECTION($,(0,-1,0));+#85=VECTOR($,#84,1);+#86=LINE($,#83,#85);+#87=EDGE_CURVE($,#76,#58,#86,.T.);+#88=ORIENTED_EDGE($,$,$,#87,.T.);+#89=EDGE_LOOP($,(#66,#74,#82,#88));+#90=FACE_OUTER_BOUND('',#89,.T.);+#91=CARTESIAN_POINT($,(2,0,0));+#92=VERTEX_POINT($,#91);+#93=CARTESIAN_POINT($,(0,0,0));+#94=DIRECTION($,(0,0,1));+#95=DIRECTION($,(1,0,0));+#96=AXIS2_PLACEMENT_3D($,#93,#94,#95);+#97=CIRCLE($,#96,2);+#98=EDGE_CURVE($,#92,#92,#97,.T.);+#99=ORIENTED_EDGE($,$,$,#98,.T.);+#100=EDGE_LOOP($,(#99));+#101=FACE_BOUND('',#100,.T.);+#102=ADVANCED_FACE('',(#90,#101),#56,.T.);+#103=CARTESIAN_POINT($,(0,-10,-5));+#104=DIRECTION($,(0,-1,0));+#105=DIRECTION($,(1,0,0));+#106=AXIS2_PLACEMENT_3D($,#103,#104,#105);+#107=PLANE($,#106);+#108=ORIENTED_EDGE($,$,$,#14,.T.);+#109=CARTESIAN_POINT($,(10,-10,-10));+#110=DIRECTION($,(0,0,1));+#111=VECTOR($,#110,1);+#112=LINE($,#109,#111);+#113=EDGE_CURVE($,#9,#60,#112,.T.);+#114=ORIENTED_EDGE($,$,$,#113,.T.);+#115=ORIENTED_EDGE($,$,$,#65,.F.);+#116=CARTESIAN_POINT($,(-10,-10,-10));+#117=DIRECTION($,(0,0,1));+#118=VECTOR($,#117,1);+#119=LINE($,#116,#118);+#120=EDGE_CURVE($,#7,#58,#119,.T.);+#121=ORIENTED_EDGE($,$,$,#120,.F.);+#122=EDGE_LOOP($,(#108,#114,#115,#121));+#123=FACE_OUTER_BOUND('',#122,.T.);+#124=ADVANCED_FACE('',(#123),#107,.T.);+#125=CARTESIAN_POINT($,(10,0,-5));+#126=DIRECTION($,(1,0,0));+#127=DIRECTION($,(0,1,0));+#128=AXIS2_PLACEMENT_3D($,#125,#126,#127);+#129=PLANE($,#128);+#130=ORIENTED_EDGE($,$,$,#22,.T.);+#131=CARTESIAN_POINT($,(10,10,-10));+#132=DIRECTION($,(0,0,1));+#133=VECTOR($,#132,1);+#134=LINE($,#131,#133);+#135=EDGE_CURVE($,#17,#68,#134,.T.);+#136=ORIENTED_EDGE($,$,$,#135,.T.);+#137=ORIENTED_EDGE($,$,$,#73,.F.);+#138=ORIENTED_EDGE($,$,$,#113,.F.);+#139=EDGE_LOOP($,(#130,#136,#137,#138));+#140=FACE_OUTER_BOUND('',#139,.T.);+#141=ADVANCED_FACE('',(#140),#129,.T.);+#142=CARTESIAN_POINT($,(0,10,-5));+#143=DIRECTION($,(0,1,0));+#144=DIRECTION($,(-1,0,0));+#145=AXIS2_PLACEMENT_3D($,#142,#143,#144);+#146=PLANE($,#145);+#147=ORIENTED_EDGE($,$,$,#30,.T.);+#148=CARTESIAN_POINT($,(-10,10,-10));+#149=DIRECTION($,(0,0,1));+#150=VECTOR($,#149,1);+#151=LINE($,#148,#150);+#152=EDGE_CURVE($,#25,#76,#151,.T.);+#153=ORIENTED_EDGE($,$,$,#152,.T.);+#154=ORIENTED_EDGE($,$,$,#81,.F.);+#155=ORIENTED_EDGE($,$,$,#135,.F.);+#156=EDGE_LOOP($,(#147,#153,#154,#155));+#157=FACE_OUTER_BOUND('',#156,.T.);+#158=ADVANCED_FACE('',(#157),#146,.T.);+#159=CARTESIAN_POINT($,(-10,0,-5));+#160=DIRECTION($,(-1,0,0));+#161=DIRECTION($,(0,1,0));+#162=AXIS2_PLACEMENT_3D($,#159,#160,#161);+#163=PLANE($,#162);+#164=ORIENTED_EDGE($,$,$,#36,.T.);+#165=ORIENTED_EDGE($,$,$,#120,.T.);+#166=ORIENTED_EDGE($,$,$,#87,.F.);+#167=ORIENTED_EDGE($,$,$,#152,.F.);+#168=EDGE_LOOP($,(#164,#165,#166,#167));+#169=FACE_OUTER_BOUND('',#168,.T.);+#170=ADVANCED_FACE('',(#169),#163,.T.);+#171=CARTESIAN_POINT($,(0,0,0));+#172=DIRECTION($,(-0,-0,-1));+#173=DIRECTION($,(1,0,0));+#174=AXIS2_PLACEMENT_3D($,#171,#172,#173);+#175=CONICAL_SURFACE($,#174,2,0.197395559849881);+#176=CARTESIAN_POINT($,(2,0,0));+#177=VERTEX_POINT($,#176);+#178=CARTESIAN_POINT($,(4,0,-10));+#179=VERTEX_POINT($,#178);+#180=CARTESIAN_POINT($,(2,0,0));+#181=DIRECTION($,(0.196116135138184,0,-0.98058067569092));+#182=VECTOR($,#181,1);+#183=LINE($,#180,#182);+#184=EDGE_CURVE($,#177,#179,#183,.T.);+#185=ORIENTED_EDGE($,$,$,#184,.T.);+#186=ORIENTED_EDGE($,$,$,#98,.F.);+#187=ORIENTED_EDGE($,$,$,#184,.F.);+#188=ORIENTED_EDGE($,$,$,#47,.T.);+#189=EDGE_LOOP($,(#185,#186,#187,#188));+#190=FACE_OUTER_BOUND('',#189,.T.);+#191=ADVANCED_FACE('',(#190),#175,.T.);+#192=CLOSED_SHELL($,(#51,#102,#124,#141,#158,#170,#191));+#193=MANIFOLD_SOLID_BREP('AetherisBody',#192);+#194=APPLICATION_CONTEXT('mechanical design');+#195=PRODUCT_CONTEXT('',#194,'mechanical');+#196=PRODUCT('AETHERIS','AetherisBody','',(#195));+#197=PRODUCT_DEFINITION_FORMATION('','',#196);+#198=PRODUCT_DEFINITION_CONTEXT('design',#194,'design');+#199=PRODUCT_DEFINITION('','',#197,#198);+#200=PRODUCT_DEFINITION_SHAPE('','',#199);+#201=(LENGTH_UNIT()NAMED_UNIT(*)SI_UNIT(.MILLI.,.METRE.));+#202=(NAMED_UNIT(*)PLANE_ANGLE_UNIT()SI_UNIT($,.RADIAN.));+#203=(NAMED_UNIT(*)SI_UNIT($,.STERADIAN.)SOLID_ANGLE_UNIT());+#204=(GEOMETRIC_REPRESENTATION_CONTEXT(3)GLOBAL_UNIT_ASSIGNED_CONTEXT((#201,#202,#203))REPRESENTATION_CONTEXT('3','3D'));+#205=SHAPE_REPRESENTATION('AetherisBody',(#193),#204);+#206=SHAPE_DEFINITION_REPRESENTATION(#200,#205);+ENDSEC;+END-ISO-10303-21;diff --git a/testdata/firmament/fixtures/m10m-unsupported-box-subtract-cone.firmament b/testdata/firmament/fixtures/m10m-unsupported-box-subtract-cone.firmamentindex 7d1a1c71..87399abe 100644--- a/testdata/firmament/fixtures/m10m-unsupported-box-subtract-cone.firmament+++ b/testdata/firmament/fixtures/m10m-unsupported-box-subtract-cone.firmament@@ -10,9 +10,9 @@ ops[2]:op: boxid: basesize[3]:- 40- 30- 12+ 20+ 20+ 10-op: subtract@@ -20,6 +20,6 @@ ops[2]:from: basewith:op: cone- bottom_radius: 6- top_radius: 0- height: 20+ bottom_radius: 4+ top_radius: 2+ height: 6