Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Add boolean analytic-hole classification routing
Yuechen Li38c1129d16d4
diff --git a/Aetheris.Kernel.Core.Tests/Brep/Boolean/BrepBooleanTests.cs b/Aetheris.Kernel.Core.Tests/Brep/Boolean/BrepBooleanTests.csindex 11e78278..22419599 100644--- a/Aetheris.Kernel.Core.Tests/Brep/Boolean/BrepBooleanTests.cs+++ b/Aetheris.Kernel.Core.Tests/Brep/Boolean/BrepBooleanTests.cs@@ -269,7 +269,8 @@ public sealed class BrepBooleanTestsAssert.False(result.IsSuccess);var diagnostic = Assert.Single(result.Diagnostics);Assert.Equal(KernelDiagnosticCode.NotImplemented, diagnostic.Code);- Assert.Contains("strict Z-aligned through-hole subset", diagnostic.Message, StringComparison.Ordinal);+ Assert.Equal("BrepBoolean.AnalyticHoleConstraintViolation", diagnostic.Source);+ Assert.Contains("analytic hole candidate violates M13 constraints", diagnostic.Message, StringComparison.Ordinal);Assert.Contains("cylinder axis is not aligned with the box Z axis", diagnostic.Message, StringComparison.Ordinal);}@@ -284,7 +285,8 @@ public sealed class BrepBooleanTestsAssert.False(result.IsSuccess);var diagnostic = Assert.Single(result.Diagnostics);Assert.Equal(KernelDiagnosticCode.NotImplemented, diagnostic.Code);- Assert.Contains("strict Z-aligned through-hole subset", diagnostic.Message, StringComparison.Ordinal);+ Assert.Equal("BrepBoolean.AnalyticHoleConstraintViolation", diagnostic.Source);+ Assert.Contains("analytic hole candidate violates M13 constraints", diagnostic.Message, StringComparison.Ordinal);Assert.Contains("does not fully span the box Z range", diagnostic.Message, StringComparison.Ordinal);}@@ -299,7 +301,8 @@ public sealed class BrepBooleanTestsAssert.False(result.IsSuccess);var diagnostic = Assert.Single(result.Diagnostics);Assert.Equal(KernelDiagnosticCode.NotImplemented, diagnostic.Code);- Assert.Contains("strict Z-aligned through-hole subset", diagnostic.Message, StringComparison.Ordinal);+ Assert.Equal("BrepBoolean.AnalyticHoleConstraintViolation", diagnostic.Source);+ Assert.Contains("analytic hole candidate violates M13 constraints", diagnostic.Message, StringComparison.Ordinal);Assert.Contains("strictly inside the box XY footprint", diagnostic.Message, StringComparison.Ordinal);}@@ -343,7 +346,8 @@ public sealed class BrepBooleanTestsAssert.False(result.IsSuccess);var diagnostic = Assert.Single(result.Diagnostics);Assert.Equal(KernelDiagnosticCode.NotImplemented, diagnostic.Code);- Assert.Equal("Boolean Subtract: M13 only supports recognized axis-aligned boxes from BrepPrimitives.CreateBox(...).", diagnostic.Message);+ 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);}[Fact]@@ -385,7 +389,8 @@ public sealed class BrepBooleanTestsAssert.False(result.IsSuccess);var diagnostic = Assert.Single(result.Diagnostics);Assert.Equal(KernelDiagnosticCode.NotImplemented, diagnostic.Code);- Assert.Equal("Boolean Subtract: M13 only supports recognized axis-aligned boxes from BrepPrimitives.CreateBox(...).", diagnostic.Message);+ 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);}[Fact]@@ -399,7 +404,8 @@ public sealed class BrepBooleanTestsAssert.False(result.IsSuccess);var diagnostic = Assert.Single(result.Diagnostics);Assert.Equal(KernelDiagnosticCode.NotImplemented, diagnostic.Code);- Assert.Equal("Boolean Subtract: M13 only supports recognized axis-aligned boxes from BrepPrimitives.CreateBox(...).", diagnostic.Message);+ 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);}[Fact]@@ -430,6 +436,53 @@ public sealed class BrepBooleanTestsAssert.Equal("Boolean Intersect: M13 only supports recognized axis-aligned boxes from BrepPrimitives.CreateBox(...).", diagnostic.Message);}+ [Fact]+ public void ClassifyBooleanCase_BoxBox_IsPlanarOnly()+ {+ var left = BrepBooleanBoxRecognition.CreateBoxFromExtents(new AxisAlignedBoxExtents(-2d, 2d, -2d, 2d, -2d, 2d)).Value;+ var right = BrepBooleanBoxRecognition.CreateBoxFromExtents(new AxisAlignedBoxExtents(-1d, 1d, -1d, 1d, -1d, 1d)).Value;++ var classification = BrepBoolean.ClassifyBooleanCase(left, right, BooleanOperation.Union);++ Assert.Equal(BooleanExecutionClass.PlanarOnly, classification.ExecutionClass);+ Assert.NotNull(classification.LeftBox);+ Assert.NotNull(classification.RightBox);+ Assert.Null(classification.RightAnalyticSurface);+ }++ [Fact]+ public void ClassifyBooleanCase_BoxCylinderSubtract_IsPlanarWithAnalyticHole()+ {+ 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(3d, -2d, 6d)));++ var classification = BrepBoolean.ClassifyBooleanCase(left, right, BooleanOperation.Subtract);++ Assert.Equal(BooleanExecutionClass.PlanarWithAnalyticHole, classification.ExecutionClass);+ Assert.Equal(AnalyticSurfaceKind.Cylinder, classification.RightAnalyticSurface?.Kind);+ }++ [Theory]+ [InlineData(AnalyticSurfaceKind.Cone)]+ [InlineData(AnalyticSurfaceKind.Sphere)]+ [InlineData(AnalyticSurfaceKind.Torus)]+ public void ClassifyBooleanCase_BoxAnalyticSubtract_RoutesToAnalyticHoleClass(AnalyticSurfaceKind expectedKind)+ {+ var left = BrepBooleanBoxRecognition.CreateBoxFromExtents(new AxisAlignedBoxExtents(-20d, 20d, -15d, 15d, 0d, 12d)).Value;+ var right = expectedKind switch+ {+ AnalyticSurfaceKind.Cone => CreateCone(bottomRadius: 6d, topRadius: 0d, height: 20d),+ AnalyticSurfaceKind.Sphere => TransformBody(BrepPrimitives.CreateSphere(4d).Value, Transform3D.CreateTranslation(new Vector3D(0d, 0d, 6d))),+ AnalyticSurfaceKind.Torus => TransformBody(BrepPrimitives.CreateTorus(6d, 2d).Value, Transform3D.CreateTranslation(new Vector3D(0d, 0d, 6d))),+ _ => throw new ArgumentOutOfRangeException(nameof(expectedKind)),+ };++ var classification = BrepBoolean.ClassifyBooleanCase(left, right, BooleanOperation.Subtract);++ Assert.Equal(BooleanExecutionClass.PlanarWithAnalyticHole, classification.ExecutionClass);+ Assert.Equal(expectedKind, classification.RightAnalyticSurface?.Kind);+ }+[Fact]public void Execute_NonBoxInput_ReturnsDeterministicNotImplementedWithoutThrowing(){@@ -476,7 +529,15 @@ public sealed class BrepBooleanTestsAssert.False(result.IsSuccess);var diagnostic = Assert.Single(result.Diagnostics);Assert.Equal(KernelDiagnosticCode.NotImplemented, diagnostic.Code);- Assert.Equal($"Boolean {operation}: M13 only supports recognized axis-aligned boxes from BrepPrimitives.CreateBox(...).", diagnostic.Message);+ if (operation == BooleanOperation.Subtract)+ {+ Assert.Equal("BrepBoolean.UnsupportedAnalyticSurfaceKind", diagnostic.Source);+ Assert.Equal($"Boolean {operation}: analytic hole surface kind 'Torus' is recognized but not implemented for M13 reconstruction.", diagnostic.Message);+ }+ else+ {+ Assert.Equal($"Boolean {operation}: M13 only supports recognized axis-aligned boxes from BrepPrimitives.CreateBox(...).", diagnostic.Message);+ }}private static BrepBody CreateCone(double bottomRadius, double topRadius, double height)diff --git a/Aetheris.Kernel.Core/Brep/Boolean/BrepBoolean.cs b/Aetheris.Kernel.Core/Brep/Boolean/BrepBoolean.csindex 66435508..6bc02c54 100644--- a/Aetheris.Kernel.Core/Brep/Boolean/BrepBoolean.cs+++ b/Aetheris.Kernel.Core/Brep/Boolean/BrepBoolean.cs@@ -22,9 +22,24 @@ public sealed record BooleanAnalysis(BooleanOperation Operation,bool IsSameBodyInstance,string? ShortcutReason,+ BooleanExecutionClass ExecutionClass,AxisAlignedBoxExtents? LeftBox,AxisAlignedBoxExtents? RightBox,- RecognizedCylinder? RightCylinder,+ AnalyticSurface? RightAnalyticSurface,+ string? UnsupportedReason);++public enum BooleanExecutionClass+{+ PlanarOnly,+ PlanarWithAnalyticHole,+ UnsupportedGeneralCase,+}++public sealed record BooleanCaseClassification(+ BooleanExecutionClass ExecutionClass,+ AxisAlignedBoxExtents? LeftBox,+ AxisAlignedBoxExtents? RightBox,+ AnalyticSurface? RightAnalyticSurface,string? UnsupportedReason);public sealed record BooleanIntersectionData(@@ -39,7 +54,7 @@ public sealed record BooleanClassificationData(bool IsComputed,int FragmentCount,AxisAlignedBoxExtents? SingleBoxResult,- RecognizedCylinder? ThroughHoleCylinder,+ AnalyticSurface? AnalyticHoleSurface,string? UnsupportedReason);public sealed record BooleanRebuildData(@@ -123,28 +138,52 @@ public static class BrepBoolean: null;var tolerance = request.Tolerance ?? ToleranceContext.Default;- var leftRecognized = BrepBooleanBoxRecognition.TryRecognizeAxisAlignedBox(request.Left, tolerance, out var leftBox, out _);- var rightRecognized = BrepBooleanBoxRecognition.TryRecognizeAxisAlignedBox(request.Right, tolerance, out var rightBox, out _);- var rightCylinderRecognized = BrepBooleanCylinderRecognition.TryRecognizeCylinder(request.Right, tolerance, out var rightCylinder, out _);- var supportsBoxBox = leftRecognized && rightRecognized;- var supportsThroughHoleSubtract = request.Operation == BooleanOperation.Subtract && leftRecognized && rightCylinderRecognized;- var unsupportedReason = supportsBoxBox || supportsThroughHoleSubtract- ? null- : $"Boolean {request.Operation}: M13 only supports recognized axis-aligned boxes from BrepPrimitives.CreateBox(...).";+ var classification = ClassifyBooleanCase(request.Left, request.Right, request.Operation, tolerance);return new BooleanAnalysis(request.Operation,isSameBodyInstance,shortcutReason,+ classification.ExecutionClass,+ classification.LeftBox,+ classification.RightBox,+ classification.RightAnalyticSurface,+ classification.UnsupportedReason);+ }++ public static BooleanCaseClassification ClassifyBooleanCase(BrepBody leftBody, BrepBody rightBody, BooleanOperation operation, ToleranceContext? tolerance = null)+ {+ var resolvedTolerance = tolerance ?? ToleranceContext.Default;+ var leftRecognized = BrepBooleanBoxRecognition.TryRecognizeAxisAlignedBox(leftBody, resolvedTolerance, out var leftBox, out _);+ var rightRecognized = BrepBooleanBoxRecognition.TryRecognizeAxisAlignedBox(rightBody, resolvedTolerance, out var rightBox, out _);+ var rightAnalyticRecognized = BrepBooleanAnalyticSurfaceRecognition.TryRecognizeAnalyticSurface(rightBody, resolvedTolerance, out var analyticSurface, out _);++ if (leftRecognized && rightRecognized)+ {+ return new BooleanCaseClassification(BooleanExecutionClass.PlanarOnly, leftBox, rightBox, null, null);+ }++ if (operation == BooleanOperation.Subtract && leftRecognized && rightAnalyticRecognized)+ {+ if (analyticSurface.Kind != AnalyticSurfaceKind.Cone+ || (analyticSurface.Cone is RecognizedCone cone+ && BrepBooleanCylinderRecognition.ValidateThroughHole(leftBox, cone, resolvedTolerance, out _)))+ {+ return new BooleanCaseClassification(BooleanExecutionClass.PlanarWithAnalyticHole, leftBox, null, analyticSurface, null);+ }+ }++ return new BooleanCaseClassification(+ BooleanExecutionClass.UnsupportedGeneralCase,leftRecognized ? leftBox : null,rightRecognized ? rightBox : null,- supportsThroughHoleSubtract ? rightCylinder : null,- unsupportedReason);+ rightAnalyticRecognized ? analyticSurface : null,+ $"Boolean {operation}: M13 only supports recognized axis-aligned boxes from BrepPrimitives.CreateBox(...).");}private static BooleanIntersectionData ComputeIntersections(BooleanRequest request, BooleanAnalysis analysis){- if (analysis.LeftBox is null || (analysis.RightBox is null && analysis.RightCylinder is null))+ if (analysis.LeftBox is null || (analysis.RightBox is null && analysis.RightAnalyticSurface is null)){return new BooleanIntersectionData(analysis, IsComputed: true, CandidatePairCount: 0, OverlapBox: null, IsTouchingOnly: false);}@@ -166,126 +205,153 @@ public static class BrepBooleanprivate static BooleanClassificationData ClassifyFragments(BooleanRequest request, BooleanIntersectionData intersections){- if (intersections.Analysis.UnsupportedReason is not null)+ switch (intersections.Analysis.ExecutionClass){- return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 0, SingleBoxResult: null, ThroughHoleCylinder: null, UnsupportedReason: intersections.Analysis.UnsupportedReason);+ case BooleanExecutionClass.PlanarOnly:+ return ClassifyPlanarOnly(request, intersections);+ case BooleanExecutionClass.PlanarWithAnalyticHole:+ return ClassifyPlanarWithAnalyticHole(request, intersections);+ default:+ return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 0, SingleBoxResult: null, AnalyticHoleSurface: null, UnsupportedReason: intersections.Analysis.UnsupportedReason);}+ }+ private static BooleanClassificationData ClassifyPlanarWithAnalyticHole(BooleanRequest request, BooleanIntersectionData intersections)+ {var left = intersections.Analysis.LeftBox!.Value;var tolerance = request.Tolerance ?? ToleranceContext.Default;var operation = request.Operation;- if (intersections.Analysis.RightBox is null)+ if (intersections.Analysis.RightAnalyticSurface is not AnalyticSurface analyticSurface){- var cylinder = intersections.Analysis.RightCylinder!.Value;- if (!BrepBooleanCylinderRecognition.ValidateThroughHole(left, cylinder, tolerance, out var reason))- {- return new BooleanClassificationData(- intersections,- IsComputed: true,- FragmentCount: 0,- SingleBoxResult: null,- ThroughHoleCylinder: null,- UnsupportedReason: $"Boolean {operation}: box-cylinder subtract only supports a strict Z-aligned through-hole subset ({reason}).");- }+ return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 0, SingleBoxResult: null, AnalyticHoleSurface: null, UnsupportedReason: $"Boolean {operation}: analytic-hole classification requires a recognized analytic surface.");+ }+ if (analyticSurface.Kind == AnalyticSurfaceKind.Cylinder+ && analyticSurface.Cylinder is RecognizedCylinder cylinder+ && !BrepBooleanCylinderRecognition.ValidateThroughHole(left, cylinder, tolerance, out var reason))+ {return new BooleanClassificationData(intersections,IsComputed: true,- FragmentCount: 1,+ FragmentCount: 0,SingleBoxResult: null,- ThroughHoleCylinder: cylinder,- UnsupportedReason: null);+ AnalyticHoleSurface: analyticSurface,+ UnsupportedReason: $"Boolean {operation}: analytic hole candidate violates M13 constraints ({reason}).");+ }++ return new BooleanClassificationData(+ intersections,+ IsComputed: true,+ FragmentCount: 1,+ SingleBoxResult: null,+ AnalyticHoleSurface: analyticSurface,+ UnsupportedReason: null);+ }++ private static BooleanClassificationData ClassifyPlanarOnly(BooleanRequest request, BooleanIntersectionData intersections)+ {+ if (intersections.Analysis.UnsupportedReason is not null)+ {+ return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 0, SingleBoxResult: null, AnalyticHoleSurface: null, UnsupportedReason: intersections.Analysis.UnsupportedReason);}+ var left = intersections.Analysis.LeftBox!.Value;+ var tolerance = request.Tolerance ?? ToleranceContext.Default;+ var operation = request.Operation;var right = intersections.Analysis.RightBox!.Value;if (operation == BooleanOperation.Intersect){if (intersections.IsTouchingOnly){- return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 0, SingleBoxResult: null, ThroughHoleCylinder: null, UnsupportedReason: $"Boolean {operation}: touching-only intersection is non-solid and empty results are not representable in M13.");+ return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 0, SingleBoxResult: null, AnalyticHoleSurface: null, UnsupportedReason: $"Boolean {operation}: touching-only intersection is non-solid and empty results are not representable in M13.");}if (intersections.OverlapBox is null){- return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 0, SingleBoxResult: null, ThroughHoleCylinder: null, UnsupportedReason: $"Boolean {operation}: empty intersection result is not representable in M13.");+ return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 0, SingleBoxResult: null, AnalyticHoleSurface: null, UnsupportedReason: $"Boolean {operation}: empty intersection result is not representable in M13.");}- return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 1, SingleBoxResult: intersections.OverlapBox, ThroughHoleCylinder: null, UnsupportedReason: null);+ return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 1, SingleBoxResult: intersections.OverlapBox, AnalyticHoleSurface: null, UnsupportedReason: null);}if (operation == BooleanOperation.Union){if (left.ApproximatelyEquals(right, tolerance)){- return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 1, SingleBoxResult: left, ThroughHoleCylinder: null, UnsupportedReason: null);+ return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 1, SingleBoxResult: left, AnalyticHoleSurface: null, UnsupportedReason: null);}if (left.Contains(right, tolerance)){- return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 1, SingleBoxResult: left, ThroughHoleCylinder: null, UnsupportedReason: null);+ return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 1, SingleBoxResult: left, AnalyticHoleSurface: null, UnsupportedReason: null);}if (right.Contains(left, tolerance)){- return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 1, SingleBoxResult: right, ThroughHoleCylinder: null, UnsupportedReason: null);+ return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 1, SingleBoxResult: right, AnalyticHoleSurface: null, UnsupportedReason: null);}var bounds = AxisAlignedBoxExtents.Bounding(left, right);if (AxisAlignedBoxExtents.UnionIsSingleBox(left, right, bounds, tolerance)){- return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 1, SingleBoxResult: bounds, ThroughHoleCylinder: null, UnsupportedReason: null);+ return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 1, SingleBoxResult: bounds, AnalyticHoleSurface: null, UnsupportedReason: null);}if (AxisAlignedBoxExtents.Intersection(left, right) is null){- return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 0, SingleBoxResult: null, ThroughHoleCylinder: null, UnsupportedReason: $"Boolean {operation}: disjoint box union is multi-body and not supported in M13.");+ return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 0, SingleBoxResult: null, AnalyticHoleSurface: null, UnsupportedReason: $"Boolean {operation}: disjoint box union is multi-body and not supported in M13.");}- return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 0, SingleBoxResult: null, ThroughHoleCylinder: null, UnsupportedReason: $"Boolean {operation}: box union is not a single box in M13 (for example L-shaped unions)." );+ return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 0, SingleBoxResult: null, AnalyticHoleSurface: null, UnsupportedReason: $"Boolean {operation}: box union is not a single box in M13 (for example L-shaped unions)." );}if (!left.OverlapsWithPositiveVolume(right, tolerance)){- return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 1, SingleBoxResult: left, ThroughHoleCylinder: null, UnsupportedReason: null);+ return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 1, SingleBoxResult: left, AnalyticHoleSurface: null, UnsupportedReason: null);}if (right.Contains(left, tolerance)){- return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 0, SingleBoxResult: null, ThroughHoleCylinder: null, UnsupportedReason: $"Boolean {operation}: subtraction fully removes the left box and empty results are not representable in M13.");+ return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 0, SingleBoxResult: null, AnalyticHoleSurface: null, UnsupportedReason: $"Boolean {operation}: subtraction fully removes the left box and empty results are not representable in M13.");}if (TrySubtractToSingleBox(left, right, tolerance, out var singleBox)){- return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 1, SingleBoxResult: singleBox, ThroughHoleCylinder: null, UnsupportedReason: null);+ return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 1, SingleBoxResult: singleBox, AnalyticHoleSurface: null, UnsupportedReason: null);}- return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 0, SingleBoxResult: null, ThroughHoleCylinder: null, UnsupportedReason: $"Boolean {operation}: box subtraction result is not representable as a single box in M13.");+ return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 0, SingleBoxResult: null, AnalyticHoleSurface: null, UnsupportedReason: $"Boolean {operation}: box subtraction result is not representable as a single box in M13.");}private static BooleanRebuildData RebuildResult(BooleanRequest request, BooleanClassificationData classification){var operation = request.Operation;++ if (classification.AnalyticHoleSurface is not null)+ {+ var tolerance = request.Tolerance ?? ToleranceContext.Default;+ var rebuiltThroughHole = BrepBooleanBoxCylinderHoleBuilder.BuildAnalyticHole(classification.Intersections.Analysis.LeftBox!.Value, classification.AnalyticHoleSurface.Value, tolerance);+ return rebuiltThroughHole.IsSuccess+ ? new BooleanRebuildData(classification, rebuiltThroughHole.Value, rebuiltThroughHole.Diagnostics)+ : new BooleanRebuildData(classification, RebuiltBody: null, Diagnostics: rebuiltThroughHole.Diagnostics);+ }+if (classification.UnsupportedReason is not null){+ var source = classification.UnsupportedReason.Contains("analytic hole candidate violates M13 constraints", StringComparison.Ordinal)+ ? "BrepBoolean.AnalyticHoleConstraintViolation"+ : "BrepBoolean.RebuildResult";return new BooleanRebuildData(classification,RebuiltBody: null,Diagnostics:[- CreateNotImplemented(classification.UnsupportedReason, source: "BrepBoolean.RebuildResult"),+ CreateNotImplemented(classification.UnsupportedReason, source: source),]);}- if (classification.ThroughHoleCylinder is not null)- {- var rebuiltThroughHole = BrepBooleanBoxCylinderHoleBuilder.CreateThroughHoleBody(classification.Intersections.Analysis.LeftBox!.Value, classification.ThroughHoleCylinder.Value);- return rebuiltThroughHole.IsSuccess- ? new BooleanRebuildData(classification, rebuiltThroughHole.Value, rebuiltThroughHole.Diagnostics)- : new BooleanRebuildData(classification, RebuiltBody: null, Diagnostics: rebuiltThroughHole.Diagnostics);- }-if (classification.SingleBoxResult is null){return new BooleanRebuildData(diff --git a/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanAnalyticSurfaceRecognition.cs b/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanAnalyticSurfaceRecognition.csnew file mode 100644index 00000000..8e5d3076--- /dev/null+++ b/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanAnalyticSurfaceRecognition.cs@@ -0,0 +1,210 @@+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.Numerics;++namespace Aetheris.Kernel.Core.Brep.Boolean;++public enum AnalyticSurfaceKind+{+ Cylinder,+ Cone,+ Sphere,+ Torus,+}++public readonly record struct RecognizedCone(+ Point3D AxisOrigin,+ Direction3D Axis,+ double MinAxisParameter,+ double MaxAxisParameter,+ double RadiusAtMinAxisParameter,+ double RadiusAtMaxAxisParameter)+{+ public Point3D MinCenter => AxisOrigin + (Axis.ToVector() * MinAxisParameter);++ public Point3D MaxCenter => AxisOrigin + (Axis.ToVector() * MaxAxisParameter);++ public double MaxRadius => System.Math.Max(RadiusAtMinAxisParameter, RadiusAtMaxAxisParameter);+}++public readonly record struct RecognizedSphere(Point3D Center, double Radius);++public readonly record struct RecognizedTorus(Point3D Center, Direction3D Axis, double MajorRadius, double MinorRadius);++public readonly record struct AnalyticSurface(+ AnalyticSurfaceKind Kind,+ RecognizedCylinder? Cylinder = null,+ RecognizedCone? Cone = null,+ RecognizedSphere? Sphere = null,+ RecognizedTorus? Torus = null);++public static class BrepBooleanAnalyticSurfaceRecognition+{+ public static bool TryRecognizeCylinder(BrepBody body, ToleranceContext tolerance, out AnalyticSurface surface, out string reason)+ {+ var recognized = BrepBooleanCylinderRecognition.TryRecognizeCylinder(body, tolerance, out var cylinder, out reason);+ surface = recognized+ ? new AnalyticSurface(AnalyticSurfaceKind.Cylinder, Cylinder: cylinder)+ : default;+ return recognized;+ }++ public static bool TryRecognizeCone(BrepBody body, ToleranceContext tolerance, out AnalyticSurface surface, out string reason)+ {+ surface = default;+ reason = string.Empty;++ var faceBindings = body.Bindings.FaceBindings.ToArray();+ if (faceBindings.Length < 2 || faceBindings.Length > 3)+ {+ reason = "cone recognition requires one conical face plus one or two planar cap faces.";+ return false;+ }++ if (body.Bindings.EdgeBindings.Count() < 2 || body.Bindings.EdgeBindings.Count() > 3)+ {+ reason = "cone recognition requires one seam edge plus one or two circular cap edges.";+ return false;+ }++ var coneBindings = new List<FaceGeometryBinding>(1);+ var planeBindings = new List<(FaceGeometryBinding Binding, PlaneSurface Plane)>(2);++ foreach (var binding in faceBindings)+ {+ var currentSurface = body.Geometry.GetSurface(binding.SurfaceGeometryId);+ switch (currentSurface.Kind)+ {+ case SurfaceGeometryKind.Cone when currentSurface.Cone is ConeSurface:+ coneBindings.Add(binding);+ break;+ case SurfaceGeometryKind.Plane when currentSurface.Plane is PlaneSurface plane:+ planeBindings.Add((binding, plane));+ break;+ default:+ reason = "cone recognition requires one conical face plus one or two planar cap faces.";+ return false;+ }+ }++ if (coneBindings.Count != 1 || planeBindings.Count is < 1 or > 2)+ {+ reason = "cone recognition requires one conical face plus one or two planar cap faces.";+ return false;+ }++ var coneSurface = body.Geometry.GetSurface(coneBindings[0].SurfaceGeometryId).Cone!.Value;+ var axis = coneSurface.Axis;+ var axisVector = axis.ToVector();++ foreach (var edgeBinding in body.Bindings.EdgeBindings)+ {+ var edgeCurve = body.Geometry.GetCurve(edgeBinding.CurveGeometryId);+ if (edgeCurve.Kind != CurveGeometryKind.Line3 && edgeCurve.Kind != CurveGeometryKind.Circle3)+ {+ reason = "cone recognition requires one line seam and circular cap edges only.";+ return false;+ }+ }++ var samples = new List<(double AxisParameter, double Radius)>(2);+ foreach (var (_, plane) in planeBindings)+ {+ var normal = plane.Normal.ToVector();+ var dot = normal.Dot(axisVector);+ if (!ToleranceMath.AlmostEqual(double.Abs(dot), 1d, tolerance))+ {+ reason = "cone recognition requires cap plane normals parallel to the cone axis.";+ return false;+ }++ var centerOffset = plane.Origin - coneSurface.Apex;+ var axisParameter = centerOffset.Dot(axisVector);+ var radialOffset = centerOffset - (axisVector * axisParameter);+ if (radialOffset.Length > tolerance.Linear)+ {+ reason = "cone recognition requires cap centers to stay on the cone axis.";+ return false;+ }++ samples.Add((axisParameter, System.Math.Abs(axisParameter) * System.Math.Tan(coneSurface.SemiAngleRadians)));+ }++ if (planeBindings.Count == 1)+ {+ samples.Add((0d, 0d));+ }++ samples.Sort((a, b) => a.AxisParameter.CompareTo(b.AxisParameter));+ if ((samples[1].AxisParameter - samples[0].AxisParameter) <= tolerance.Linear)+ {+ reason = "recognized cone height must be positive.";+ return false;+ }++ surface = new AnalyticSurface(+ AnalyticSurfaceKind.Cone,+ Cone: new RecognizedCone(+ coneSurface.Apex,+ axis,+ samples[0].AxisParameter,+ samples[1].AxisParameter,+ samples[0].Radius,+ samples[1].Radius));+ return true;+ }++ public static bool TryRecognizeSphere(BrepBody body, ToleranceContext _, out AnalyticSurface surface, out string reason)+ {+ surface = default;+ reason = string.Empty;++ var faceBindings = body.Bindings.FaceBindings.ToArray();+ if (faceBindings.Length != 1)+ {+ reason = "sphere recognition requires exactly one spherical face.";+ return false;+ }++ var recognizedSurface = body.Geometry.GetSurface(faceBindings[0].SurfaceGeometryId);+ if (recognizedSurface.Kind != SurfaceGeometryKind.Sphere || recognizedSurface.Sphere is not SphereSurface sphere)+ {+ reason = "sphere recognition requires a spherical face binding.";+ return false;+ }++ surface = new AnalyticSurface(AnalyticSurfaceKind.Sphere, Sphere: new RecognizedSphere(sphere.Center, sphere.Radius));+ return true;+ }++ public static bool TryRecognizeTorus(BrepBody body, ToleranceContext _, out AnalyticSurface surface, out string reason)+ {+ surface = default;+ reason = string.Empty;++ var faceBindings = body.Bindings.FaceBindings.ToArray();+ if (faceBindings.Length != 1)+ {+ reason = "torus recognition requires exactly one toroidal face.";+ return false;+ }++ var recognizedSurface = body.Geometry.GetSurface(faceBindings[0].SurfaceGeometryId);+ if (recognizedSurface.Kind != SurfaceGeometryKind.Torus || recognizedSurface.Torus is not TorusSurface torus)+ {+ reason = "torus recognition requires a toroidal face binding.";+ return false;+ }++ surface = new AnalyticSurface(AnalyticSurfaceKind.Torus, Torus: new RecognizedTorus(torus.Center, torus.Axis, torus.MajorRadius, torus.MinorRadius));+ return true;+ }++ public static bool TryRecognizeAnalyticSurface(BrepBody body, ToleranceContext tolerance, out AnalyticSurface surface, out string reason)+ => TryRecognizeCylinder(body, tolerance, out surface, out reason)+ || TryRecognizeCone(body, tolerance, out surface, out reason)+ || TryRecognizeSphere(body, tolerance, out surface, out reason)+ || TryRecognizeTorus(body, tolerance, out surface, out reason);+}diff --git a/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanBoxCylinderHoleBuilder.cs b/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanBoxCylinderHoleBuilder.csindex 565cc6a7..bd74e251 100644--- a/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanBoxCylinderHoleBuilder.cs+++ b/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanBoxCylinderHoleBuilder.cs@@ -3,6 +3,7 @@ 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.Numerics;using Aetheris.Kernel.Core.Results;using Aetheris.Kernel.Core.Topology;@@ -10,7 +11,33 @@ namespace Aetheris.Kernel.Core.Brep.Boolean;public static class BrepBooleanBoxCylinderHoleBuilder{- public static KernelResult<BrepBody> CreateThroughHoleBody(AxisAlignedBoxExtents box, in RecognizedCylinder cylinder)+ public static KernelResult<BrepBody> BuildAnalyticHole(AxisAlignedBoxExtents outer, AnalyticSurface surface, ToleranceContext tolerance)+ {+ switch (surface.Kind)+ {+ case AnalyticSurfaceKind.Cylinder when surface.Cylinder is RecognizedCylinder cylinder:+ if (!BrepBooleanCylinderRecognition.ValidateThroughHole(outer, cylinder, tolerance, out var reason))+ {+ return KernelResult<BrepBody>.Failure([+ BrepBooleanCylinderRecognition.CreateConstraintViolationDiagnostic(BooleanOperation.Subtract.ToString(), reason),+ ]);+ }++ return CreateThroughHoleBody(outer, cylinder);+ case AnalyticSurfaceKind.Cone:+ case AnalyticSurfaceKind.Sphere:+ case AnalyticSurfaceKind.Torus:+ return KernelResult<BrepBody>.Failure([+ CreateUnsupportedAnalyticSurfaceKindDiagnostic(BooleanOperation.Subtract.ToString(), surface.Kind),+ ]);+ default:+ return KernelResult<BrepBody>.Failure([+ CreateUnsupportedAnalyticSurfaceKindDiagnostic(BooleanOperation.Subtract.ToString(), surface.Kind),+ ]);+ }+ }++ private static KernelResult<BrepBody> CreateThroughHoleBody(AxisAlignedBoxExtents box, in RecognizedCylinder cylinder){var builder = new TopologyBuilder();@@ -160,6 +187,13 @@ public static class BrepBooleanBoxCylinderHoleBuilder: KernelResult<BrepBody>.Failure(validation.Diagnostics);}+ private static KernelDiagnostic CreateUnsupportedAnalyticSurfaceKindDiagnostic(string operation, AnalyticSurfaceKind kind)+ => new(+ KernelDiagnosticCode.NotImplemented,+ KernelDiagnosticSeverity.Error,+ $"Boolean {operation}: analytic hole surface kind '{kind}' is recognized but not implemented for M13 reconstruction.",+ Source: "BrepBoolean.UnsupportedAnalyticSurfaceKind");+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 299530e0..1c60a1c5 100644--- a/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanCylinderRecognition.cs+++ b/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanCylinderRecognition.cs@@ -193,6 +193,58 @@ public static class BrepBooleanCylinderRecognitionreturn true;}+ public static bool ValidateThroughHole(AxisAlignedBoxExtents box, in RecognizedCone cone, ToleranceContext tolerance, out string reason)+ {+ reason = string.Empty;++ 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.";+ return false;+ }++ var minCenter = cone.MinCenter;+ var 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.";+ 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;++ if (minZ > (box.MinZ + tolerance.Linear) || maxZ < (box.MaxZ - tolerance.Linear))+ {+ 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))+ {+ reason = "cone radial footprint must stay strictly inside the box XY footprint.";+ return false;+ }++ return true;+ }++ public static KernelDiagnostic CreateConstraintViolationDiagnostic(string operation, string message)+ => new(+ KernelDiagnosticCode.NotImplemented,+ KernelDiagnosticSeverity.Error,+ $"Boolean {operation}: analytic hole candidate violates M13 constraints ({message}).",+ Source: "BrepBoolean.AnalyticHoleConstraintViolation");+public static KernelDiagnostic CreateUnsupportedThroughHoleDiagnostic(string operation, string reason)=> new(KernelDiagnosticCode.NotImplemented,diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentBooleanCanonicalSuccessTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentBooleanCanonicalSuccessTests.csindex c28b3844..fbd24fe8 100644--- a/Aetheris.Kernel.Firmament.Tests/FirmamentBooleanCanonicalSuccessTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentBooleanCanonicalSuccessTests.cs@@ -108,8 +108,7 @@ public sealed class FirmamentBooleanCanonicalSuccessTests&& diagnostic.Message.Contains($"Requested boolean feature '{expectedFeatureId}' ({expectedKind}) could not be executed.", StringComparison.Ordinal));Assert.Contains(result.Compilation.Diagnostics, diagnostic =>diagnostic.Code == KernelDiagnosticCode.NotImplemented- && (diagnostic.Message.Contains("M13 only supports recognized axis-aligned boxes from BrepPrimitives.CreateBox(...).", StringComparison.Ordinal)- || diagnostic.Message.Contains("strict Z-aligned through-hole subset", StringComparison.Ordinal)));+ && HasExpectedMixedPrimitiveFailure(diagnostic.Message));}@@ -127,7 +126,7 @@ public sealed class FirmamentBooleanCanonicalSuccessTests&& diagnostic.Message.Contains($"Requested boolean feature '{expectedFeatureId}' (subtract) could not be executed.", StringComparison.Ordinal));Assert.Contains(result.Compilation.Diagnostics, diagnostic =>diagnostic.Code == KernelDiagnosticCode.NotImplemented- && diagnostic.Message.Contains("M13 only supports recognized axis-aligned boxes from BrepPrimitives.CreateBox(...).", StringComparison.Ordinal));+ && HasExpectedMixedPrimitiveFailure(diagnostic.Message));}public static TheoryData<string, string, string> UnsupportedBoxTorusVariantSources =>@@ -160,9 +159,14 @@ public sealed class FirmamentBooleanCanonicalSuccessTests&& diagnostic.Message.Contains($"Requested boolean feature '{expectedFeatureId}' ({expectedKind}) could not be executed.", StringComparison.Ordinal));Assert.Contains(result.Compilation.Diagnostics, diagnostic =>diagnostic.Code == KernelDiagnosticCode.NotImplemented- && diagnostic.Message.Contains("M13 only supports recognized axis-aligned boxes from BrepPrimitives.CreateBox(...).", StringComparison.Ordinal));+ && HasExpectedMixedPrimitiveFailure(diagnostic.Message));}+ private 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 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) =>$"""firmament:diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentBooleanRequiredFieldValidationTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentBooleanRequiredFieldValidationTests.csindex 6b5851ab..43dadb10 100644--- a/Aetheris.Kernel.Firmament.Tests/FirmamentBooleanRequiredFieldValidationTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentBooleanRequiredFieldValidationTests.cs@@ -146,7 +146,8 @@ public sealed class FirmamentBooleanRequiredFieldValidationTestsAssert.DoesNotContain(result.Compilation.Diagnostics, diagnostic => diagnostic.Message.Contains("[FIRM-STRUCT-", StringComparison.Ordinal));Assert.Contains(result.Compilation.Diagnostics, diagnostic =>diagnostic.Code == Aetheris.Kernel.Core.Diagnostics.KernelDiagnosticCode.NotImplemented- && diagnostic.Message.Contains("M13 only supports recognized axis-aligned boxes from BrepPrimitives.CreateBox(...).", StringComparison.Ordinal));+ && (diagnostic.Message.Contains("M13 only supports recognized axis-aligned boxes from BrepPrimitives.CreateBox(...).", StringComparison.Ordinal)+ || diagnostic.Message.Contains("analytic hole surface kind", StringComparison.Ordinal)));}[Fact]diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentBuildAndExportTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentBuildAndExportTests.csindex d244dfc6..2a2331ed 100644--- a/Aetheris.Kernel.Firmament.Tests/FirmamentBuildAndExportTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentBuildAndExportTests.cs@@ -198,6 +198,11 @@ public sealed class FirmamentBuildAndExportTestsAssert.False(result.IsSuccess);Assert.False(File.Exists(expectedOutputPath));Assert.Contains(result.Diagnostics, diagnostic => diagnostic.Message.Contains($"Requested boolean feature '{expectedFeatureId}' ({expectedKind}) could not be executed.", StringComparison.Ordinal));- Assert.Contains(result.Diagnostics, diagnostic => diagnostic.Message.Contains("M13 only supports recognized axis-aligned boxes from BrepPrimitives.CreateBox(...).", StringComparison.Ordinal) || diagnostic.Message.Contains("strict Z-aligned through-hole subset", StringComparison.Ordinal));+ Assert.Contains(result.Diagnostics, diagnostic => HasExpectedMixedPrimitiveFailure(diagnostic.Message));}++ private 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 surface kind", StringComparison.Ordinal);}diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentPrimitiveExecutionTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentPrimitiveExecutionTests.csindex f742ef77..09968574 100644--- a/Aetheris.Kernel.Firmament.Tests/FirmamentPrimitiveExecutionTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentPrimitiveExecutionTests.cs@@ -276,7 +276,8 @@ public sealed class FirmamentPrimitiveExecutionTests&& diagnostic.Message.Contains($"Requested boolean feature '{expectedFeatureId}' ({expectedKind}) could not be executed.", StringComparison.Ordinal));Assert.Contains(result.Compilation.Diagnostics, diagnostic =>diagnostic.Code == Aetheris.Kernel.Core.Diagnostics.KernelDiagnosticCode.NotImplemented- && diagnostic.Message.Contains("M13 only supports recognized axis-aligned boxes from BrepPrimitives.CreateBox(...).", StringComparison.Ordinal));+ && (diagnostic.Message.Contains("M13 only supports recognized axis-aligned boxes from BrepPrimitives.CreateBox(...).", StringComparison.Ordinal)+ || diagnostic.Message.Contains("analytic hole surface kind", StringComparison.Ordinal)));}[Fact]diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentStepExporterTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentStepExporterTests.csindex 2baeea4e..b4f0e99c 100644--- a/Aetheris.Kernel.Firmament.Tests/FirmamentStepExporterTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentStepExporterTests.cs@@ -93,7 +93,7 @@ public sealed class FirmamentStepExporterTestsAssert.False(second.IsSuccess);Assert.Equal(first.Diagnostics, second.Diagnostics);Assert.Contains(first.Diagnostics, diagnostic => diagnostic.Message.Contains("Requested boolean feature 'hole' (subtract) could not be executed.", StringComparison.Ordinal));- Assert.Contains(first.Diagnostics, diagnostic => diagnostic.Message.Contains("strict Z-aligned through-hole subset", StringComparison.Ordinal));+ Assert.Contains(first.Diagnostics, diagnostic => diagnostic.Message.Contains("analytic hole candidate violates M13 constraints", StringComparison.Ordinal));Assert.DoesNotContain(first.Diagnostics, diagnostic => diagnostic.Message.Contains("requires at least one executed primitive or boolean body", StringComparison.Ordinal));}@@ -119,7 +119,7 @@ public sealed class FirmamentStepExporterTestsAssert.False(second.IsSuccess);Assert.Equal(first.Diagnostics, second.Diagnostics);Assert.Contains(first.Diagnostics, diagnostic => diagnostic.Message.Contains($"Requested boolean feature '{expectedFeatureId}'", StringComparison.Ordinal));- Assert.Contains(first.Diagnostics, diagnostic => diagnostic.Message.Contains("M13 only supports recognized axis-aligned boxes from BrepPrimitives.CreateBox(...).", StringComparison.Ordinal));+ Assert.Contains(first.Diagnostics, diagnostic => HasExpectedMixedPrimitiveFailure(diagnostic.Message));Assert.DoesNotContain(first.Diagnostics, diagnostic => diagnostic.Message.Contains("requires at least one executed primitive or boolean body", StringComparison.Ordinal));}@@ -151,10 +151,15 @@ public sealed class FirmamentStepExporterTestsAssert.False(second.IsSuccess);Assert.Equal(first.Diagnostics, second.Diagnostics);Assert.Contains(first.Diagnostics, diagnostic => diagnostic.Message.Contains($"Requested boolean feature '{expectedFeatureId}'", StringComparison.Ordinal));- Assert.Contains(first.Diagnostics, diagnostic => diagnostic.Message.Contains("M13 only supports recognized axis-aligned boxes from BrepPrimitives.CreateBox(...).", StringComparison.Ordinal));+ Assert.Contains(first.Diagnostics, diagnostic => HasExpectedMixedPrimitiveFailure(diagnostic.Message));Assert.DoesNotContain(first.Diagnostics, diagnostic => diagnostic.Message.Contains("requires at least one executed primitive or boolean body", StringComparison.Ordinal));}+ private 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 surface kind", StringComparison.Ordinal);+[Fact]public void Export_SchemaPresent_Model_Still_Exports_With_Stable_Metadata_And_Deterministic_Text(){