Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Implement safe sequential boolean hole composition

Yuechen Libd3a0dae25b1
diff --git a/Aetheris.Kernel.Core.Tests/Brep/Boolean/BrepBooleanTests.cs b/Aetheris.Kernel.Core.Tests/Brep/Boolean/BrepBooleanTests.cs
index 413c01fc..1de9b991 100644
--- a/Aetheris.Kernel.Core.Tests/Brep/Boolean/BrepBooleanTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Brep/Boolean/BrepBooleanTests.cs
@@ -447,6 +447,111 @@ public sealed class BrepBooleanTests
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 Subtract_ComposedTwoCylinderThroughHoles_RemainsTruthful_And_Deterministic()
+ {
+ var baseBox = BrepBooleanBoxRecognition.CreateBoxFromExtents(new AxisAlignedBoxExtents(-20d, 20d, -15d, 15d, 0d, 12d)).Value;
+ var firstHole = TransformBody(BrepPrimitives.CreateCylinder(4d, 20d).Value, Transform3D.CreateTranslation(new Vector3D(-7d, 0d, 6d)));
+ var secondHole = TransformBody(BrepPrimitives.CreateCylinder(3d, 20d).Value, Transform3D.CreateTranslation(new Vector3D(8d, 2d, 6d)));
+
+ var first = BrepBoolean.Subtract(baseBox, firstHole);
+ Assert.True(first.IsSuccess);
+
+ var second = BrepBoolean.Subtract(first.Value, secondHole);
+ var repeated = BrepBoolean.Subtract(first.Value, secondHole);
+
+ Assert.True(second.IsSuccess);
+ Assert.True(repeated.IsSuccess);
+ Assert.Equal(8, second.Value.Topology.Faces.Count());
+ Assert.Equal(18, second.Value.Topology.Edges.Count());
+ Assert.Equal(16, second.Value.Topology.Vertices.Count());
+ Assert.Equal(second.Value.SafeBooleanComposition?.Holes.Count, repeated.Value.SafeBooleanComposition?.Holes.Count);
+ Assert.Equal(2, second.Value.SafeBooleanComposition?.Holes.Count);
+ Assert.True(BrepBindingValidator.Validate(second.Value, true).IsSuccess);
+
+ var export = Step242Exporter.ExportBody(second.Value);
+ var repeatedExport = Step242Exporter.ExportBody(repeated.Value);
+ Assert.True(export.IsSuccess);
+ Assert.True(repeatedExport.IsSuccess);
+ Assert.Equal(export.Value, repeatedExport.Value);
+ Assert.Contains("CYLINDRICAL_SURFACE", export.Value, StringComparison.Ordinal);
+ Assert.Contains("MANIFOLD_SOLID_BREP", export.Value, StringComparison.Ordinal);
+ }
+
+ [Fact]
+ public void Subtract_ComposedCylinderThenConeThroughHole_RemainsTruthful_And_Deterministic()
+ {
+ var baseBox = BrepBooleanBoxRecognition.CreateBoxFromExtents(new AxisAlignedBoxExtents(-20d, 20d, -15d, 15d, 0d, 12d)).Value;
+ var cylinderHole = TransformBody(BrepPrimitives.CreateCylinder(4d, 20d).Value, Transform3D.CreateTranslation(new Vector3D(-7d, -2d, 6d)));
+ var coneHole = TransformBody(CreateCone(bottomRadius: 3d, topRadius: 5d, height: 20d), Transform3D.CreateTranslation(new Vector3D(8d, 0d, 0d)));
+
+ var first = BrepBoolean.Subtract(baseBox, cylinderHole);
+ Assert.True(first.IsSuccess);
+
+ var second = BrepBoolean.Subtract(first.Value, coneHole);
+ var repeated = BrepBoolean.Subtract(first.Value, coneHole);
+
+ Assert.True(second.IsSuccess);
+ Assert.True(repeated.IsSuccess);
+ Assert.Equal(8, second.Value.Topology.Faces.Count());
+ Assert.Equal(18, second.Value.Topology.Edges.Count());
+ Assert.Equal(16, second.Value.Topology.Vertices.Count());
+ Assert.Equal(2, second.Value.SafeBooleanComposition?.Holes.Count);
+ Assert.True(BrepBindingValidator.Validate(second.Value, true).IsSuccess);
+ Assert.Contains(second.Value.Topology.Faces, face =>
+ second.Value.TryGetFaceSurfaceGeometry(face.Id, out var surface)
+ && surface?.Kind == SurfaceGeometryKind.Cylinder);
+ Assert.Contains(second.Value.Topology.Faces, face =>
+ second.Value.TryGetFaceSurfaceGeometry(face.Id, out var surface)
+ && surface?.Kind == SurfaceGeometryKind.Cone);
+
+ var export = Step242Exporter.ExportBody(second.Value);
+ var repeatedExport = Step242Exporter.ExportBody(repeated.Value);
+ Assert.True(export.IsSuccess);
+ Assert.True(repeatedExport.IsSuccess);
+ Assert.Equal(export.Value, repeatedExport.Value);
+ Assert.Contains("CYLINDRICAL_SURFACE", export.Value, StringComparison.Ordinal);
+ Assert.Contains("CONICAL_SURFACE", export.Value, StringComparison.Ordinal);
+ }
+
+ [Fact]
+ public void Subtract_ComposedOverlappingHoles_FailsWithDeterministicInterferenceDiagnostic()
+ {
+ var baseBox = BrepBooleanBoxRecognition.CreateBoxFromExtents(new AxisAlignedBoxExtents(-20d, 20d, -15d, 15d, 0d, 12d)).Value;
+ var firstHole = TransformBody(BrepPrimitives.CreateCylinder(4d, 20d).Value, Transform3D.CreateTranslation(new Vector3D(0d, 0d, 6d)));
+ var secondHole = TransformBody(BrepPrimitives.CreateCylinder(4d, 20d).Value, Transform3D.CreateTranslation(new Vector3D(6d, 0d, 6d)));
+
+ var first = BrepBoolean.Subtract(baseBox, firstHole);
+ Assert.True(first.IsSuccess);
+
+ var second = BrepBoolean.Subtract(first.Value, secondHole);
+
+ Assert.False(second.IsSuccess);
+ var diagnostic = Assert.Single(second.Diagnostics);
+ Assert.Equal(KernelDiagnosticCode.NotImplemented, diagnostic.Code);
+ Assert.Equal("BrepBoolean.AnalyticHole.HoleInterference", diagnostic.Source);
+ Assert.Equal("Boolean Subtract: analytic hole candidate failed diagnostic HoleInterference (analytic hole footprint overlaps an existing composed hole).", diagnostic.Message);
+ }
+
+ [Fact]
+ public void Subtract_ComposedTangentHoles_FailsWithDeterministicTangentDiagnostic()
+ {
+ var baseBox = BrepBooleanBoxRecognition.CreateBoxFromExtents(new AxisAlignedBoxExtents(-20d, 20d, -15d, 15d, 0d, 12d)).Value;
+ var firstHole = TransformBody(BrepPrimitives.CreateCylinder(4d, 20d).Value, Transform3D.CreateTranslation(new Vector3D(-4d, 0d, 6d)));
+ var secondHole = TransformBody(BrepPrimitives.CreateCylinder(4d, 20d).Value, Transform3D.CreateTranslation(new Vector3D(4d, 0d, 6d)));
+
+ var first = BrepBoolean.Subtract(baseBox, firstHole);
+ Assert.True(first.IsSuccess);
+
+ var second = BrepBoolean.Subtract(first.Value, secondHole);
+
+ Assert.False(second.IsSuccess);
+ var diagnostic = Assert.Single(second.Diagnostics);
+ Assert.Equal(KernelDiagnosticCode.NotImplemented, diagnostic.Code);
+ Assert.Equal("BrepBoolean.AnalyticHole.TangentContact", diagnostic.Source);
+ Assert.Equal("Boolean Subtract: analytic hole candidate failed diagnostic TangentContact (analytic hole footprint is tangent to an existing composed hole.).", diagnostic.Message);
+ }
+
[Fact]
public void Add_BoxCylinder_StillReturnsDeterministicNotImplemented()
{
@@ -733,7 +838,7 @@ public sealed class BrepBooleanTests
}
}
- return new BrepBody(body.Topology, geometry, body.Bindings, vertexPoints);
+ return new BrepBody(body.Topology, geometry, body.Bindings, vertexPoints, body.SafeBooleanComposition);
}
}
diff --git a/Aetheris.Kernel.Core/Brep/Boolean/BooleanDiagnostic.cs b/Aetheris.Kernel.Core/Brep/Boolean/BooleanDiagnostic.cs
index 24adc92b..0f1c8f4a 100644
--- a/Aetheris.Kernel.Core/Brep/Boolean/BooleanDiagnostic.cs
+++ b/Aetheris.Kernel.Core/Brep/Boolean/BooleanDiagnostic.cs
@@ -9,6 +9,7 @@ public enum BooleanDiagnosticCode
RadiusExceedsBoundary,
TangentContact,
MultiBodyResult,
+ HoleInterference,
UnsupportedAnalyticSurfaceKind
}
diff --git a/Aetheris.Kernel.Core/Brep/Boolean/BrepBoolean.cs b/Aetheris.Kernel.Core/Brep/Boolean/BrepBoolean.cs
index 0a425177..4f724fd5 100644
--- a/Aetheris.Kernel.Core/Brep/Boolean/BrepBoolean.cs
+++ b/Aetheris.Kernel.Core/Brep/Boolean/BrepBoolean.cs
@@ -23,6 +23,7 @@ public sealed record BooleanAnalysis(
bool IsSameBodyInstance,
string? ShortcutReason,
BooleanExecutionClass ExecutionClass,
+ SafeBooleanComposition? LeftSafeComposition,
AxisAlignedBoxExtents? LeftBox,
AxisAlignedBoxExtents? RightBox,
AnalyticSurface? RightAnalyticSurface,
@@ -37,6 +38,7 @@ public enum BooleanExecutionClass
public sealed record BooleanCaseClassification(
BooleanExecutionClass ExecutionClass,
+ SafeBooleanComposition? LeftSafeComposition,
AxisAlignedBoxExtents? LeftBox,
AxisAlignedBoxExtents? RightBox,
AnalyticSurface? RightAnalyticSurface,
@@ -55,7 +57,7 @@ public sealed record BooleanClassificationData(
bool IsComputed,
int FragmentCount,
AxisAlignedBoxExtents? SingleBoxResult,
- AnalyticSurface? AnalyticHoleSurface,
+ SafeBooleanComposition? SafeCompositionResult,
string? UnsupportedReason,
BooleanDiagnostic? Diagnostic = null);
@@ -147,6 +149,7 @@ public static class BrepBoolean
isSameBodyInstance,
shortcutReason,
classification.ExecutionClass,
+ classification.LeftSafeComposition,
classification.LeftBox,
classification.RightBox,
classification.RightAnalyticSurface,
@@ -156,22 +159,44 @@ public static class BrepBoolean
public static BooleanCaseClassification ClassifyBooleanCase(BrepBody leftBody, BrepBody rightBody, BooleanOperation operation, ToleranceContext? tolerance = null)
{
var resolvedTolerance = tolerance ?? ToleranceContext.Default;
+ var leftSafeCompositionRecognized = leftBody.SafeBooleanComposition is not null;
+ var leftSafeComposition = leftSafeCompositionRecognized
+ ? leftBody.SafeBooleanComposition!
+ : null;
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);
+ return new BooleanCaseClassification(BooleanExecutionClass.PlanarOnly, leftSafeComposition, leftBox, rightBox, null, null);
+ }
+
+ if (operation == BooleanOperation.Subtract && (leftRecognized || leftSafeCompositionRecognized) && rightAnalyticRecognized)
+ {
+ return new BooleanCaseClassification(
+ BooleanExecutionClass.PlanarWithAnalyticHole,
+ leftSafeCompositionRecognized ? leftSafeComposition : new SafeBooleanComposition(leftBox, []),
+ leftRecognized ? leftBox : leftSafeComposition!.OuterBox,
+ null,
+ analyticSurface,
+ null);
}
- if (operation == BooleanOperation.Subtract && leftRecognized && rightAnalyticRecognized)
+ if (leftSafeCompositionRecognized)
{
- return new BooleanCaseClassification(BooleanExecutionClass.PlanarWithAnalyticHole, leftBox, null, analyticSurface, null);
+ return new BooleanCaseClassification(
+ BooleanExecutionClass.UnsupportedGeneralCase,
+ leftSafeComposition,
+ leftRecognized ? leftBox : leftSafeComposition!.OuterBox,
+ rightRecognized ? rightBox : null,
+ rightAnalyticRecognized ? analyticSurface : null,
+ $"Boolean {operation}: sequential safe composition only supports subtracting supported cylinder/cone through-holes from the current composed box shell.");
}
return new BooleanCaseClassification(
BooleanExecutionClass.UnsupportedGeneralCase,
+ null,
leftRecognized ? leftBox : null,
rightRecognized ? rightBox : null,
rightAnalyticRecognized ? analyticSurface : null,
@@ -209,67 +234,41 @@ public static class BrepBoolean
case BooleanExecutionClass.PlanarWithAnalyticHole:
return ClassifyPlanarWithAnalyticHole(request, intersections);
default:
- return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 0, SingleBoxResult: null, AnalyticHoleSurface: null, UnsupportedReason: intersections.Analysis.UnsupportedReason);
+ return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 0, SingleBoxResult: null, SafeCompositionResult: null, UnsupportedReason: intersections.Analysis.UnsupportedReason);
}
}
private static BooleanClassificationData ClassifyPlanarWithAnalyticHole(BooleanRequest request, BooleanIntersectionData intersections)
{
- var left = intersections.Analysis.LeftBox!.Value;
+ var leftComposition = intersections.Analysis.LeftSafeComposition
+ ?? new SafeBooleanComposition(intersections.Analysis.LeftBox!.Value, []);
+ var left = leftComposition.OuterBox;
var tolerance = request.Tolerance ?? ToleranceContext.Default;
var operation = request.Operation;
if (intersections.Analysis.RightAnalyticSurface is not AnalyticSurface analyticSurface)
{
- return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 0, SingleBoxResult: null, AnalyticHoleSurface: null, UnsupportedReason: $"Boolean {operation}: analytic-hole classification requires a recognized analytic surface.");
+ return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 0, SingleBoxResult: null, SafeCompositionResult: 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 diagnostic))
+ if (!BrepBooleanSafeComposition.TryAppend(leftComposition, analyticSurface, tolerance, out var updatedComposition, out var diagnostic))
{
return new BooleanClassificationData(
intersections,
IsComputed: true,
FragmentCount: 0,
SingleBoxResult: null,
- AnalyticHoleSurface: analyticSurface,
+ SafeCompositionResult: null,
UnsupportedReason: null,
Diagnostic: diagnostic);
}
- 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,
- IsComputed: true,
- FragmentCount: 0,
- SingleBoxResult: null,
- AnalyticHoleSurface: analyticSurface,
- UnsupportedReason: null,
- Diagnostic: BrepBooleanCylinderRecognition.CreateUnsupportedAnalyticSurfaceKindDiagnostic(operation.ToString(), analyticSurface.Kind));
- }
-
return new BooleanClassificationData(
intersections,
IsComputed: true,
FragmentCount: 1,
SingleBoxResult: null,
- AnalyticHoleSurface: analyticSurface,
+ SafeCompositionResult: updatedComposition,
UnsupportedReason: null);
}
@@ -277,7 +276,7 @@ public static class BrepBoolean
{
if (intersections.Analysis.UnsupportedReason is not null)
{
- return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 0, SingleBoxResult: null, AnalyticHoleSurface: null, UnsupportedReason: intersections.Analysis.UnsupportedReason);
+ return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 0, SingleBoxResult: null, SafeCompositionResult: null, UnsupportedReason: intersections.Analysis.UnsupportedReason);
}
var left = intersections.Analysis.LeftBox!.Value;
@@ -289,64 +288,64 @@ public static class BrepBoolean
{
if (intersections.IsTouchingOnly)
{
- 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.");
+ return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 0, SingleBoxResult: null, SafeCompositionResult: 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, AnalyticHoleSurface: null, UnsupportedReason: $"Boolean {operation}: empty intersection result is not representable in M13.");
+ return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 0, SingleBoxResult: null, SafeCompositionResult: null, UnsupportedReason: $"Boolean {operation}: empty intersection result is not representable in M13.");
}
- return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 1, SingleBoxResult: intersections.OverlapBox, AnalyticHoleSurface: null, UnsupportedReason: null);
+ return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 1, SingleBoxResult: intersections.OverlapBox, SafeCompositionResult: null, UnsupportedReason: null);
}
if (operation == BooleanOperation.Union)
{
if (left.ApproximatelyEquals(right, tolerance))
{
- return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 1, SingleBoxResult: left, AnalyticHoleSurface: null, UnsupportedReason: null);
+ return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 1, SingleBoxResult: left, SafeCompositionResult: null, UnsupportedReason: null);
}
if (left.Contains(right, tolerance))
{
- return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 1, SingleBoxResult: left, AnalyticHoleSurface: null, UnsupportedReason: null);
+ return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 1, SingleBoxResult: left, SafeCompositionResult: null, UnsupportedReason: null);
}
if (right.Contains(left, tolerance))
{
- return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 1, SingleBoxResult: right, AnalyticHoleSurface: null, UnsupportedReason: null);
+ return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 1, SingleBoxResult: right, SafeCompositionResult: 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, AnalyticHoleSurface: null, UnsupportedReason: null);
+ return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 1, SingleBoxResult: bounds, SafeCompositionResult: null, UnsupportedReason: null);
}
if (AxisAlignedBoxExtents.Intersection(left, right) is null)
{
- 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, SafeCompositionResult: 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}: box union is not a single box in M13 (for example L-shaped unions)." );
+ return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 0, SingleBoxResult: null, SafeCompositionResult: 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, AnalyticHoleSurface: null, UnsupportedReason: null);
+ return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 1, SingleBoxResult: left, SafeCompositionResult: null, UnsupportedReason: null);
}
if (right.Contains(left, tolerance))
{
- 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.");
+ return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 0, SingleBoxResult: null, SafeCompositionResult: 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, AnalyticHoleSurface: null, UnsupportedReason: null);
+ return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 1, SingleBoxResult: singleBox, SafeCompositionResult: null, UnsupportedReason: null);
}
- 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.");
+ return new BooleanClassificationData(intersections, IsComputed: true, FragmentCount: 0, SingleBoxResult: null, SafeCompositionResult: null, UnsupportedReason: $"Boolean {operation}: box subtraction result is not representable as a single box in M13.");
}
private static BooleanRebuildData RebuildResult(BooleanRequest request, BooleanClassificationData classification)
@@ -364,10 +363,10 @@ public static class BrepBoolean
]);
}
- if (classification.AnalyticHoleSurface is not null)
+ if (classification.SafeCompositionResult is not null)
{
var tolerance = request.Tolerance ?? ToleranceContext.Default;
- var rebuiltThroughHole = BrepBooleanBoxCylinderHoleBuilder.BuildAnalyticHole(classification.Intersections.Analysis.LeftBox!.Value, classification.AnalyticHoleSurface.Value, tolerance);
+ var rebuiltThroughHole = BrepBooleanBoxCylinderHoleBuilder.BuildComposition(classification.SafeCompositionResult, tolerance);
return rebuiltThroughHole.IsSuccess
? new BooleanRebuildData(classification, rebuiltThroughHole.Value, rebuiltThroughHole.Diagnostics)
: new BooleanRebuildData(classification, RebuiltBody: null, Diagnostics: rebuiltThroughHole.Diagnostics);
diff --git a/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanBoxCylinderHoleBuilder.cs b/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanBoxCylinderHoleBuilder.cs
index f5ca5b2a..1d37ffb9 100644
--- a/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanBoxCylinderHoleBuilder.cs
+++ b/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanBoxCylinderHoleBuilder.cs
@@ -1,4 +1,3 @@
-using Aetheris.Kernel.Core.Diagnostics;
using Aetheris.Kernel.Core.Geometry;
using Aetheris.Kernel.Core.Geometry.Curves;
using Aetheris.Kernel.Core.Geometry.Surfaces;
@@ -13,40 +12,27 @@ public static class BrepBooleanBoxCylinderHoleBuilder
{
public static KernelResult<BrepBody> BuildAnalyticHole(AxisAlignedBoxExtents outer, AnalyticSurface surface, ToleranceContext tolerance)
{
- switch (surface.Kind)
+ var composition = new SafeBooleanComposition(outer, []);
+ if (!BrepBooleanSafeComposition.TryAppend(composition, surface, tolerance, out var updatedComposition, out var diagnostic))
{
- case AnalyticSurfaceKind.Cylinder when surface.Cylinder is RecognizedCylinder cylinder:
- if (!BrepBooleanCylinderRecognition.ValidateThroughHole(outer, cylinder, tolerance, out var diagnostic))
- {
- return KernelResult<BrepBody>.Failure([
- diagnostic!.ToKernelDiagnostic(),
- ]);
- }
-
- return CreateThroughHoleBody(outer, cylinder);
- 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([
- BrepBooleanCylinderRecognition.CreateUnsupportedAnalyticSurfaceKindDiagnostic(BooleanOperation.Subtract.ToString(), surface.Kind).ToKernelDiagnostic(),
- ]);
- default:
- return KernelResult<BrepBody>.Failure([
- BrepBooleanCylinderRecognition.CreateUnsupportedAnalyticSurfaceKindDiagnostic(BooleanOperation.Subtract.ToString(), surface.Kind).ToKernelDiagnostic(),
- ]);
+ return KernelResult<BrepBody>.Failure([diagnostic!.ToKernelDiagnostic()]);
}
+
+ return BuildComposition(updatedComposition, tolerance);
}
- private static KernelResult<BrepBody> CreateThroughHoleBody(AxisAlignedBoxExtents box, in RecognizedCylinder cylinder)
+ public static KernelResult<BrepBody> BuildComposition(SafeBooleanComposition composition, ToleranceContext tolerance)
{
+ ArgumentNullException.ThrowIfNull(composition);
+ _ = tolerance;
+ return CreateComposedThroughHoleBody(composition);
+ }
+
+ private static KernelResult<BrepBody> CreateComposedThroughHoleBody(SafeBooleanComposition composition)
+ {
+ var box = composition.OuterBox;
+ var holes = composition.Holes;
+
var builder = new TopologyBuilder();
var v1 = builder.AddVertex();
@@ -57,10 +43,6 @@ public static class BrepBooleanBoxCylinderHoleBuilder
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);
@@ -74,24 +56,59 @@ public static class BrepBooleanBoxCylinderHoleBuilder
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 holeTopology = new List<HoleTopology>(holes.Count);
+ foreach (var hole in holes)
+ {
+ var topHoleVertex = builder.AddVertex();
+ var bottomHoleVertex = builder.AddVertex();
+ var seamTopVertex = builder.AddVertex();
+ var seamBottomVertex = builder.AddVertex();
+
+ var topCircle = builder.AddEdge(topHoleVertex, topHoleVertex);
+ var bottomCircle = builder.AddEdge(bottomHoleVertex, bottomHoleVertex);
+ var seam = builder.AddEdge(seamTopVertex, seamBottomVertex);
+
+ holeTopology.Add(new HoleTopology(hole, topHoleVertex, bottomHoleVertex, seamTopVertex, seamBottomVertex, topCircle, bottomCircle, seam));
+ }
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 yMinFace = builder.AddFace([bottomOuterLoop, bottomInnerLoop]);
- var yMaxFace = builder.AddFace([topOuterLoop, topInnerLoop]);
+ var bottomLoops = new List<LoopId>(holes.Count + 1) { bottomOuterLoop };
+ var topLoops = new List<LoopId>(holes.Count + 1) { topOuterLoop };
+ foreach (var hole in holeTopology)
+ {
+ topLoops.Add(AddLoop(builder, [Forward(hole.TopCircle)]));
+ bottomLoops.Add(AddLoop(builder, [Reversed(hole.BottomCircle)]));
+ }
+ var bottomFace = builder.AddFace(bottomLoops);
+ var topFace = builder.AddFace(topLoops);
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 yFarFace = builder.AddFace([AddLoop(builder, [Forward(e3), Forward(e12), Reversed(e7), Reversed(e11)])]);
- var yNearFace = 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 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 holeFaces = new List<FaceId>(holes.Count);
+ foreach (var hole in holeTopology)
+ {
+ holeFaces.Add(builder.AddFace([
+ AddLoop(builder, [Forward(hole.Seam), Reversed(hole.TopCircle), Reversed(hole.Seam), Forward(hole.BottomCircle)])
+ ]));
+ }
+
+ var shellFaces = new List<FaceId>(6 + holeFaces.Count)
+ {
+ bottomFace,
+ topFace,
+ xMinFace,
+ xMaxFace,
+ yMaxFace,
+ yMinFace,
+ };
+ shellFaces.AddRange(holeFaces);
- var shell = builder.AddShell([yMinFace, yMaxFace, xMinFace, xMaxFace, yFarFace, yNearFace, holeFace]);
+ var shell = builder.AddShell(shellFaces);
builder.AddBody([shell]);
var geometry = new BrepGeometryStore();
@@ -108,15 +125,9 @@ public static class BrepBooleanBoxCylinderHoleBuilder
var p7 = new Point3D(box.MaxX, box.MaxY, box.MaxZ);
var p8 = new Point3D(box.MinX, box.MaxY, box.MaxZ);
- var axis = Direction3D.Create(new Vector3D(0d, 0d, 1d));
+ 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 centerX = cylinder.MinCenter.X;
- var centerY = cylinder.MinCenter.Y;
- var bottomCenter = new Point3D(centerX, centerY, box.MinZ);
- var topCenter = new Point3D(centerX, centerY, box.MaxZ);
- var seamBottomPoint = new Point3D(centerX + cylinder.Radius, centerY, box.MinZ);
- var seamTopPoint = new Point3D(centerX + cylinder.Radius, centerY, box.MaxZ);
var lineCurves = new[]
{
@@ -132,27 +143,19 @@ public static class BrepBooleanBoxCylinderHoleBuilder
(p2, new Vector3D(0d, 0d, height)),
(p3, new Vector3D(0d, 0d, height)),
(p4, new Vector3D(0d, 0d, height)),
- (topCenter, axis.ToVector()),
- (bottomCenter, axis.ToVector()),
- (seamTopPoint, new Vector3D(0d, 0d, box.MinZ - box.MaxZ)),
};
- for (var i = 0; i < 12; i++)
+ for (var i = 0; i < lineCurves.Length; 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, axis, cylinder.Radius, xAxis)));
- geometry.AddCurve(new CurveGeometryId(14), CurveGeometry.FromCircle(new Circle3Curve(bottomCenter, axis, cylinder.Radius, 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), axis, 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)));
- geometry.AddSurface(new SurfaceGeometryId(7), SurfaceGeometry.FromCylinder(new CylinderSurface(bottomCenter, axis, cylinder.Radius, xAxis)));
var bindings = new BrepBindingModel();
for (var i = 0; i < 12; i++)
@@ -160,17 +163,12 @@ public static class BrepBooleanBoxCylinderHoleBuilder
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, height)));
-
- bindings.AddFaceBinding(new FaceGeometryBinding(yMinFace, new SurfaceGeometryId(1)));
- bindings.AddFaceBinding(new FaceGeometryBinding(yMaxFace, new SurfaceGeometryId(2)));
+ 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(yFarFace, new SurfaceGeometryId(5)));
- bindings.AddFaceBinding(new FaceGeometryBinding(yNearFace, new SurfaceGeometryId(6)));
- bindings.AddFaceBinding(new FaceGeometryBinding(holeFace, new SurfaceGeometryId(7)));
+ bindings.AddFaceBinding(new FaceGeometryBinding(yMaxFace, new SurfaceGeometryId(5)));
+ bindings.AddFaceBinding(new FaceGeometryBinding(yMinFace, new SurfaceGeometryId(6)));
var vertexPoints = new Dictionary<VertexId, Point3D>
{
@@ -182,86 +180,73 @@ public static class BrepBooleanBoxCylinderHoleBuilder
[v6] = p6,
[v7] = p7,
[v8] = p8,
- [topHoleVertex] = seamTopPoint,
- [bottomHoleVertex] = seamBottomPoint,
- [seamTopVertex] = seamTopPoint,
- [seamBottomVertex] = seamBottomPoint,
};
- var body = new BrepBody(builder.Model, geometry, bindings, vertexPoints);
+ var nextCurveId = 13;
+ var nextSurfaceId = 7;
+ for (var i = 0; i < holeTopology.Count; i++)
+ {
+ var topology = holeTopology[i];
+ var geometryData = CreateHoleGeometry(topology.Hole, box, zAxis, xAxis);
+ var topCurveId = new CurveGeometryId(nextCurveId++);
+ var bottomCurveId = new CurveGeometryId(nextCurveId++);
+ var seamCurveId = new CurveGeometryId(nextCurveId++);
+ var surfaceId = new SurfaceGeometryId(nextSurfaceId++);
+
+ geometry.AddCurve(topCurveId, geometryData.TopCircle);
+ geometry.AddCurve(bottomCurveId, geometryData.BottomCircle);
+ geometry.AddCurve(seamCurveId, geometryData.Seam);
+ geometry.AddSurface(surfaceId, geometryData.Surface);
+
+ bindings.AddEdgeBinding(new EdgeGeometryBinding(topology.TopCircle, topCurveId, new ParameterInterval(0d, 2d * double.Pi)));
+ bindings.AddEdgeBinding(new EdgeGeometryBinding(topology.BottomCircle, bottomCurveId, new ParameterInterval(0d, 2d * double.Pi)));
+ bindings.AddEdgeBinding(new EdgeGeometryBinding(topology.Seam, seamCurveId, new ParameterInterval(0d, geometryData.SeamLength)));
+ bindings.AddFaceBinding(new FaceGeometryBinding(holeFaces[i], surfaceId));
+
+ vertexPoints[topology.TopHoleVertex] = geometryData.SeamTopPoint;
+ vertexPoints[topology.BottomHoleVertex] = geometryData.SeamBottomPoint;
+ vertexPoints[topology.SeamTopVertex] = geometryData.SeamTopPoint;
+ vertexPoints[topology.SeamBottomVertex] = geometryData.SeamBottomPoint;
+ }
+
+ var body = new BrepBody(builder.Model, geometry, bindings, vertexPoints, composition);
var validation = BrepBindingValidator.Validate(body, requireAllEdgeAndFaceBindings: true);
return validation.IsSuccess
? KernelResult<BrepBody>.Success(body, validation.Diagnostics)
: KernelResult<BrepBody>.Failure(validation.Diagnostics);
}
- private static KernelResult<BrepBody> CreateThroughHoleBody(AxisAlignedBoxExtents box, in RecognizedCone cone)
+ private static HoleGeometryData CreateHoleGeometry(SupportedBooleanHole hole, AxisAlignedBoxExtents box, Direction3D zAxis, Direction3D xAxis)
{
- 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;
+ return hole.Surface.Kind switch
+ {
+ AnalyticSurfaceKind.Cylinder when hole.Surface.Cylinder is RecognizedCylinder cylinder => CreateCylinderHoleGeometry(box, xAxis, zAxis, cylinder),
+ AnalyticSurfaceKind.Cone when hole.Surface.Cone is RecognizedCone cone => CreateConeHoleGeometry(box, xAxis, zAxis, cone),
+ _ => throw new InvalidOperationException($"Unsupported hole surface kind '{hole.Surface.Kind}'."),
+ };
+ }
- 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);
+ private static HoleGeometryData CreateCylinderHoleGeometry(AxisAlignedBoxExtents box, Direction3D xAxis, Direction3D zAxis, in RecognizedCylinder cylinder)
+ {
+ var centerX = cylinder.MinCenter.X;
+ var centerY = cylinder.MinCenter.Y;
+ var bottomCenter = new Point3D(centerX, centerY, box.MinZ);
+ var topCenter = new Point3D(centerX, centerY, box.MaxZ);
+ var seamBottomPoint = new Point3D(centerX + cylinder.Radius, centerY, box.MinZ);
+ var seamTopPoint = new Point3D(centerX + cylinder.Radius, centerY, 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));
+ return new HoleGeometryData(
+ CurveGeometry.FromCircle(new Circle3Curve(topCenter, zAxis, cylinder.Radius, xAxis)),
+ CurveGeometry.FromCircle(new Circle3Curve(bottomCenter, zAxis, cylinder.Radius, xAxis)),
+ CurveGeometry.FromLine(new Line3Curve(seamTopPoint, Direction3D.Create(seamBottomPoint - seamTopPoint))),
+ SurfaceGeometry.FromCylinder(new CylinderSurface(bottomCenter, zAxis, cylinder.Radius, xAxis)),
+ seamTopPoint,
+ seamBottomPoint,
+ (seamBottomPoint - seamTopPoint).Length);
+ }
+ private static HoleGeometryData CreateConeHoleGeometry(AxisAlignedBoxExtents box, Direction3D xAxis, Direction3D zAxis, in RecognizedCone cone)
+ {
var bottomAxisParameter = AxisParameterAtZ(cone, box.MinZ);
var topAxisParameter = AxisParameterAtZ(cone, box.MaxZ);
var bottomCenter = cone.PointAtAxisParameter(bottomAxisParameter);
@@ -270,86 +255,18 @@ public static class BrepBooleanBoxCylinderHoleBuilder
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);
+ return new HoleGeometryData(
+ CurveGeometry.FromCircle(new Circle3Curve(topCenter, zAxis, topRadius, xAxis)),
+ CurveGeometry.FromCircle(new Circle3Curve(bottomCenter, zAxis, bottomRadius, xAxis)),
+ CurveGeometry.FromLine(new Line3Curve(seamTopPoint, Direction3D.Create(seamBottomPoint - seamTopPoint))),
+ SurfaceGeometry.FromCone(new ConeSurface(innerMinCenter, cone.Axis, innerMinRadius, cone.SemiAngleRadians, xAxis)),
+ seamTopPoint,
+ seamBottomPoint,
+ (seamBottomPoint - seamTopPoint).Length);
}
private static double AxisParameterAtZ(in RecognizedCone cone, double z)
@@ -379,6 +296,25 @@ public static class BrepBooleanBoxCylinderHoleBuilder
return loopId;
}
+ private readonly record struct HoleTopology(
+ SupportedBooleanHole Hole,
+ VertexId TopHoleVertex,
+ VertexId BottomHoleVertex,
+ VertexId SeamTopVertex,
+ VertexId SeamBottomVertex,
+ EdgeId TopCircle,
+ EdgeId BottomCircle,
+ EdgeId Seam);
+
+ private readonly record struct HoleGeometryData(
+ CurveGeometry TopCircle,
+ CurveGeometry BottomCircle,
+ CurveGeometry Seam,
+ SurfaceGeometry Surface,
+ Point3D SeamTopPoint,
+ Point3D SeamBottomPoint,
+ double SeamLength);
+
private readonly record struct EdgeUse(EdgeId EdgeId, bool IsReversed);
private static EdgeUse Forward(EdgeId edgeId) => new(edgeId, IsReversed: false);
diff --git a/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanSafeComposition.cs b/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanSafeComposition.cs
new file mode 100644
index 00000000..8601287f
--- /dev/null
+++ b/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanSafeComposition.cs
@@ -0,0 +1,202 @@
+using Aetheris.Kernel.Core.Math;
+using Aetheris.Kernel.Core.Numerics;
+
+namespace Aetheris.Kernel.Core.Brep.Boolean;
+
+public sealed record SafeBooleanComposition(
+ AxisAlignedBoxExtents OuterBox,
+ IReadOnlyList<SupportedBooleanHole> Holes)
+{
+ public SafeBooleanComposition Translate(Vector3D translation)
+ {
+ var translatedOuter = new AxisAlignedBoxExtents(
+ OuterBox.MinX + translation.X,
+ OuterBox.MaxX + translation.X,
+ OuterBox.MinY + translation.Y,
+ OuterBox.MaxY + translation.Y,
+ OuterBox.MinZ + translation.Z,
+ OuterBox.MaxZ + translation.Z);
+
+ return new SafeBooleanComposition(
+ translatedOuter,
+ Holes.Select(hole => hole.Translate(translation)).ToArray());
+ }
+}
+
+public readonly record struct SupportedBooleanHole(
+ AnalyticSurface Surface,
+ double CenterX,
+ double CenterY,
+ double BottomRadius,
+ double TopRadius)
+{
+ public double MaxBoundaryRadius => System.Math.Max(BottomRadius, TopRadius);
+
+ public SupportedBooleanHole Translate(Vector3D translation)
+ => this with
+ {
+ Surface = Surface.Translate(translation),
+ CenterX = CenterX + translation.X,
+ CenterY = CenterY + translation.Y,
+ };
+}
+
+public static class BrepBooleanSafeComposition
+{
+ public static bool TryRecognize(BrepBody body, ToleranceContext tolerance, out SafeBooleanComposition composition, out string reason)
+ {
+ if (body.SafeBooleanComposition is not null)
+ {
+ composition = body.SafeBooleanComposition;
+ reason = string.Empty;
+ return true;
+ }
+
+ if (BrepBooleanBoxRecognition.TryRecognizeAxisAlignedBox(body, tolerance, out var box, out reason))
+ {
+ composition = new SafeBooleanComposition(box, []);
+ return true;
+ }
+
+ composition = default!;
+ return false;
+ }
+
+ public static bool TryAppend(
+ SafeBooleanComposition composition,
+ AnalyticSurface surface,
+ ToleranceContext tolerance,
+ out SafeBooleanComposition updatedComposition,
+ out BooleanDiagnostic? diagnostic)
+ {
+ updatedComposition = composition;
+ diagnostic = null;
+
+ if (!TryCreateSupportedHole(composition.OuterBox, surface, tolerance, out var nextHole, out diagnostic))
+ {
+ return false;
+ }
+
+ foreach (var existingHole in composition.Holes)
+ {
+ var deltaX = existingHole.CenterX - nextHole.CenterX;
+ var deltaY = existingHole.CenterY - nextHole.CenterY;
+ var centerDistance = System.Math.Sqrt((deltaX * deltaX) + (deltaY * deltaY));
+ var requiredDistance = existingHole.MaxBoundaryRadius + nextHole.MaxBoundaryRadius;
+
+ if (ToleranceMath.AlmostEqual(centerDistance, requiredDistance, tolerance))
+ {
+ diagnostic = BrepBooleanCylinderRecognition.CreateTangentContactDiagnostic(
+ BooleanOperation.Subtract.ToString(),
+ "analytic hole footprint is tangent to an existing composed hole.");
+ return false;
+ }
+
+ if (centerDistance < (requiredDistance - tolerance.Linear))
+ {
+ diagnostic = new BooleanDiagnostic(
+ BooleanDiagnosticCode.HoleInterference,
+ "Boolean Subtract: analytic hole candidate failed diagnostic HoleInterference (analytic hole footprint overlaps an existing composed hole).",
+ "BrepBoolean.AnalyticHole.HoleInterference");
+ return false;
+ }
+ }
+
+ updatedComposition = composition with
+ {
+ Holes = [.. composition.Holes, nextHole],
+ };
+ return true;
+ }
+
+ private static bool TryCreateSupportedHole(
+ AxisAlignedBoxExtents outerBox,
+ AnalyticSurface surface,
+ ToleranceContext tolerance,
+ out SupportedBooleanHole hole,
+ out BooleanDiagnostic? diagnostic)
+ {
+ switch (surface.Kind)
+ {
+ case AnalyticSurfaceKind.Cylinder when surface.Cylinder is RecognizedCylinder cylinder:
+ if (!BrepBooleanCylinderRecognition.ValidateThroughHole(outerBox, cylinder, tolerance, out diagnostic))
+ {
+ hole = default;
+ return false;
+ }
+
+ hole = new SupportedBooleanHole(
+ surface,
+ cylinder.MinCenter.X,
+ cylinder.MinCenter.Y,
+ cylinder.Radius,
+ cylinder.Radius);
+ return true;
+
+ case AnalyticSurfaceKind.Cone when surface.Cone is RecognizedCone cone:
+ if (!BrepBooleanCylinderRecognition.ValidateThroughHole(outerBox, cone, tolerance, out diagnostic))
+ {
+ hole = default;
+ return false;
+ }
+
+ var bottomAxisParameter = AxisParameterAtZ(cone, outerBox.MinZ, tolerance);
+ var topAxisParameter = AxisParameterAtZ(cone, outerBox.MaxZ, tolerance);
+ var boundaryBottomCenter = cone.PointAtAxisParameter(bottomAxisParameter);
+ hole = new SupportedBooleanHole(
+ surface,
+ boundaryBottomCenter.X,
+ boundaryBottomCenter.Y,
+ cone.RadiusAtAxisParameter(bottomAxisParameter),
+ cone.RadiusAtAxisParameter(topAxisParameter));
+ return true;
+
+ case AnalyticSurfaceKind.Sphere:
+ case AnalyticSurfaceKind.Torus:
+ default:
+ diagnostic = BrepBooleanCylinderRecognition.CreateUnsupportedAnalyticSurfaceKindDiagnostic(
+ BooleanOperation.Subtract.ToString(),
+ surface.Kind);
+ hole = default;
+ return false;
+ }
+ }
+
+ private static double AxisParameterAtZ(in RecognizedCone cone, double z, ToleranceContext tolerance)
+ {
+ var axisZ = cone.Axis.ToVector().Z;
+ if (ToleranceMath.AlmostEqual(axisZ, 0d, tolerance))
+ {
+ throw new InvalidOperationException("AxisParameterAtZ requires a cone axis aligned with Z.");
+ }
+
+ return (z - cone.AxisOrigin.Z) / axisZ;
+ }
+}
+
+internal static class AnalyticSurfaceCompositionExtensions
+{
+ public static AnalyticSurface Translate(this AnalyticSurface surface, Vector3D translation)
+ => surface.Kind switch
+ {
+ AnalyticSurfaceKind.Cylinder when surface.Cylinder is RecognizedCylinder cylinder
+ => new AnalyticSurface(
+ surface.Kind,
+ Cylinder: cylinder with
+ {
+ AxisOrigin = cylinder.AxisOrigin + translation,
+ }),
+ AnalyticSurfaceKind.Cone when surface.Cone is RecognizedCone cone
+ => new AnalyticSurface(
+ surface.Kind,
+ Cone: cone with
+ {
+ AxisOrigin = cone.AxisOrigin + translation,
+ }),
+ AnalyticSurfaceKind.Sphere when surface.Sphere is RecognizedSphere sphere
+ => new AnalyticSurface(surface.Kind, Sphere: sphere with { Center = sphere.Center + translation }),
+ AnalyticSurfaceKind.Torus when surface.Torus is RecognizedTorus torus
+ => new AnalyticSurface(surface.Kind, Torus: torus with { Center = torus.Center + translation }),
+ _ => surface,
+ };
+}
diff --git a/Aetheris.Kernel.Core/Brep/BrepBody.cs b/Aetheris.Kernel.Core/Brep/BrepBody.cs
index 47776459..56f58de3 100644
--- a/Aetheris.Kernel.Core/Brep/BrepBody.cs
+++ b/Aetheris.Kernel.Core/Brep/BrepBody.cs
@@ -1,6 +1,7 @@
using Aetheris.Kernel.Core.Geometry;
using Aetheris.Kernel.Core.Math;
using Aetheris.Kernel.Core.Topology;
+using Aetheris.Kernel.Core.Brep.Boolean;
namespace Aetheris.Kernel.Core.Brep;
@@ -20,12 +21,14 @@ public sealed class BrepBody
TopologyModel topology,
BrepGeometryStore geometry,
BrepBindingModel bindings,
- IReadOnlyDictionary<VertexId, Point3D>? vertexPoints)
+ IReadOnlyDictionary<VertexId, Point3D>? vertexPoints,
+ SafeBooleanComposition? safeBooleanComposition = null)
{
Topology = topology;
Geometry = geometry;
Bindings = bindings;
_vertexPoints = vertexPoints ?? new Dictionary<VertexId, Point3D>();
+ SafeBooleanComposition = safeBooleanComposition;
}
public TopologyModel Topology { get; }
@@ -34,6 +37,8 @@ public sealed class BrepBody
public BrepBindingModel Bindings { get; }
+ public SafeBooleanComposition? SafeBooleanComposition { get; }
+
public bool TryGetVertexPoint(VertexId vertexId, out Point3D point) => _vertexPoints.TryGetValue(vertexId, out point);
public bool TryGetEdgeCurveGeometry(EdgeId edgeId, out CurveGeometry? curve)
diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentBooleanCanonicalSuccessTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentBooleanCanonicalSuccessTests.cs
index d1182422..35493c67 100644
--- a/Aetheris.Kernel.Firmament.Tests/FirmamentBooleanCanonicalSuccessTests.cs
+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentBooleanCanonicalSuccessTests.cs
@@ -12,7 +12,9 @@ public sealed class FirmamentBooleanCanonicalSuccessTests
{ "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_cone_throughhole_basic.firmament", "cut", FirmamentLoweredBooleanKind.Subtract }
+ { "testdata/firmament/examples/boolean_box_cone_throughhole_basic.firmament", "cut", FirmamentLoweredBooleanKind.Subtract },
+ { "testdata/firmament/examples/boolean_two_cylinder_holes_basic.firmament", "hole_b", FirmamentLoweredBooleanKind.Subtract },
+ { "testdata/firmament/examples/boolean_cylinder_cone_holes_basic.firmament", "cut_b", FirmamentLoweredBooleanKind.Subtract }
};
[Theory]
@@ -38,6 +40,8 @@ public sealed class FirmamentBooleanCanonicalSuccessTests
[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")]
+ [InlineData("testdata/firmament/examples/boolean_two_cylinder_holes_basic.firmament", "hole_b", 2, "subtract")]
+ [InlineData("testdata/firmament/examples/boolean_cylinder_cone_holes_basic.firmament", "cut_b", 2, "subtract")]
public void CanonicalBooleanExamples_Export_Deterministically_WithExpectedMarkers(string fixturePath, string expectedFeatureId, int expectedOpIndex, string expectedKind)
{
var first = ExportFixture(fixturePath);
@@ -56,6 +60,21 @@ public sealed class FirmamentBooleanCanonicalSuccessTests
Assert.Contains("PLANE", first.Value.StepText, StringComparison.Ordinal);
}
+ [Fact]
+ public void SequentialSafeCompositionExamples_ExportExpectedAnalyticMarkers()
+ {
+ var twoCylinder = ExportFixture("testdata/firmament/examples/boolean_two_cylinder_holes_basic.firmament");
+ var cylinderCone = ExportFixture("testdata/firmament/examples/boolean_cylinder_cone_holes_basic.firmament");
+
+ Assert.True(twoCylinder.IsSuccess);
+ Assert.Contains("CYLINDRICAL_SURFACE", twoCylinder.Value.StepText, StringComparison.Ordinal);
+ Assert.Equal(2, CountOccurrences(twoCylinder.Value.StepText, "CYLINDRICAL_SURFACE"));
+
+ Assert.True(cylinderCone.IsSuccess);
+ Assert.Contains("CYLINDRICAL_SURFACE", cylinderCone.Value.StepText, StringComparison.Ordinal);
+ Assert.Contains("CONICAL_SURFACE", cylinderCone.Value.StepText, StringComparison.Ordinal);
+ }
+
[Fact]
public void OutsideCanonicalSubset_RemainsRejected_WithoutSilentFallback()
{
@@ -143,6 +162,31 @@ public sealed class FirmamentBooleanCanonicalSuccessTests
&& HasExpectedMixedPrimitiveFailure(diagnostic.Message));
}
+ [Theory]
+ [InlineData("testdata/firmament/fixtures/m13a-unsupported-overlapping-composed-holes.firmament", "hole_b", "HoleInterference")]
+ [InlineData("testdata/firmament/fixtures/m13a-unsupported-tangent-composed-holes.firmament", "hole_b", "TangentContact")]
+ [InlineData("testdata/firmament/fixtures/m13a-unsupported-composed-add-ordering.firmament", "joined", "sequential safe composition only supports subtracting supported cylinder/cone through-holes")]
+ [InlineData("testdata/firmament/fixtures/m13a-unsupported-composed-subtract-sphere.firmament", "cavity", "analytic hole surface kind 'Sphere'")]
+ [InlineData("testdata/firmament/fixtures/m13a-unsupported-composed-subtract-box.firmament", "notch", "sequential safe composition only supports subtracting supported cylinder/cone through-holes")]
+ public void SequentialCompositionOutsideSafeSubset_RemainsRejectedWithoutFallback(string fixturePath, string expectedFeatureId, string expectedMessageFragment)
+ {
+ var result = FirmamentCorpusHarness.Compile(FirmamentCorpusHarness.ReadFixtureText(fixturePath));
+ var export = ExportFixture(fixturePath);
+
+ Assert.False(result.Compilation.IsSuccess);
+ Assert.Contains(result.Compilation.Diagnostics, diagnostic =>
+ diagnostic.Code == KernelDiagnosticCode.NotImplemented
+ && diagnostic.Message.Contains($"Requested boolean feature '{expectedFeatureId}'", StringComparison.Ordinal));
+ Assert.Contains(result.Compilation.Diagnostics, diagnostic => diagnostic.Message.Contains(expectedMessageFragment, StringComparison.Ordinal));
+
+ Assert.False(export.IsSuccess);
+ Assert.Contains(export.Diagnostics, diagnostic =>
+ diagnostic.Code == KernelDiagnosticCode.NotImplemented
+ && diagnostic.Message.Contains($"Requested boolean feature '{expectedFeatureId}'", StringComparison.Ordinal));
+ Assert.DoesNotContain(export.Diagnostics, diagnostic =>
+ diagnostic.Message.Contains("requires at least one executed primitive or boolean body", StringComparison.Ordinal));
+ }
+
public static TheoryData<string, string, string> UnsupportedBoxTorusVariantSources =>
new()
{
@@ -178,9 +222,23 @@ public sealed class FirmamentBooleanCanonicalSuccessTests
private static bool HasExpectedMixedPrimitiveFailure(string message)
=> message.Contains("M13 only supports recognized axis-aligned boxes from BrepPrimitives.CreateBox(...).", StringComparison.Ordinal)
+ || message.Contains("sequential safe composition only supports subtracting supported cylinder/cone through-holes", StringComparison.Ordinal)
|| message.Contains("analytic hole candidate failed diagnostic", StringComparison.Ordinal)
|| message.Contains("analytic hole surface kind", StringComparison.Ordinal);
+ private static int CountOccurrences(string text, string token)
+ {
+ var count = 0;
+ var index = 0;
+ while ((index = text.IndexOf(token, index, StringComparison.Ordinal)) >= 0)
+ {
+ count++;
+ index += token.Length;
+ }
+
+ return count;
+ }
+
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/FirmamentBuildAndExportTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentBuildAndExportTests.cs
index 2e8177f5..fcbf8f7c 100644
--- a/Aetheris.Kernel.Firmament.Tests/FirmamentBuildAndExportTests.cs
+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentBuildAndExportTests.cs
@@ -149,6 +149,30 @@ public sealed class FirmamentBuildAndExportTests
"subtract");
}
+ [Fact]
+ public void Run_BooleanTwoCylinderHolesExample_Writes_Default_Export_Artifact()
+ {
+ AssertExampleBuildAndExport(
+ "testdata/firmament/examples/boolean_two_cylinder_holes_basic.firmament",
+ "boolean_two_cylinder_holes_basic.step",
+ "hole_b",
+ 2,
+ "boolean",
+ "subtract");
+ }
+
+ [Fact]
+ public void Run_BooleanCylinderConeHolesExample_Writes_Default_Export_Artifact()
+ {
+ AssertExampleBuildAndExport(
+ "testdata/firmament/examples/boolean_cylinder_cone_holes_basic.firmament",
+ "boolean_cylinder_cone_holes_basic.step",
+ "cut_b",
+ 2,
+ "boolean",
+ "subtract");
+ }
+
[Fact]
public void Run_UnsupportedBoxWithCylinderHoleFixture_Fails_And_Does_Not_Write_Fallback_Export()
{
@@ -168,6 +192,11 @@ public sealed class FirmamentBuildAndExportTests
[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")]
+ [InlineData("testdata/firmament/fixtures/m13a-unsupported-overlapping-composed-holes.firmament", "m13a-unsupported-overlapping-composed-holes.step", "hole_b", "subtract")]
+ [InlineData("testdata/firmament/fixtures/m13a-unsupported-tangent-composed-holes.firmament", "m13a-unsupported-tangent-composed-holes.step", "hole_b", "subtract")]
+ [InlineData("testdata/firmament/fixtures/m13a-unsupported-composed-add-ordering.firmament", "m13a-unsupported-composed-add-ordering.step", "joined", "add")]
+ [InlineData("testdata/firmament/fixtures/m13a-unsupported-composed-subtract-sphere.firmament", "m13a-unsupported-composed-subtract-sphere.step", "cavity", "subtract")]
+ [InlineData("testdata/firmament/fixtures/m13a-unsupported-composed-subtract-box.firmament", "m13a-unsupported-composed-subtract-box.step", "notch", "subtract")]
public void Run_Unsupported_MixedPrimitive_Fixtures_Fail_And_Do_Not_Write_Fallback_Export(
string sourcePath,
string expectedFileName,
@@ -218,6 +247,7 @@ public sealed class FirmamentBuildAndExportTests
private static bool HasExpectedMixedPrimitiveFailure(string message)
=> message.Contains("M13 only supports recognized axis-aligned boxes from BrepPrimitives.CreateBox(...).", StringComparison.Ordinal)
+ || message.Contains("sequential safe composition only supports subtracting supported cylinder/cone through-holes", StringComparison.Ordinal)
|| message.Contains("analytic hole candidate failed diagnostic", StringComparison.Ordinal)
|| message.Contains("analytic hole surface kind", StringComparison.Ordinal);
}
diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentExamplePackSmokeTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentExamplePackSmokeTests.cs
index 371f4b85..8080c6ec 100644
--- a/Aetheris.Kernel.Firmament.Tests/FirmamentExamplePackSmokeTests.cs
+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentExamplePackSmokeTests.cs
@@ -16,6 +16,8 @@ public sealed class FirmamentExamplePackSmokeTests
"testdata/firmament/examples/boolean_add_basic.firmament",
"testdata/firmament/examples/boolean_subtract_basic.firmament",
"testdata/firmament/examples/boolean_intersect_basic.firmament",
+ "testdata/firmament/examples/boolean_two_cylinder_holes_basic.firmament",
+ "testdata/firmament/examples/boolean_cylinder_cone_holes_basic.firmament",
"testdata/firmament/examples/placed_primitive.firmament",
"testdata/firmament/examples/schema_box_basic.firmament"
];
@@ -45,6 +47,8 @@ public sealed class FirmamentExamplePackSmokeTests
[InlineData("testdata/firmament/examples/boolean_add_basic.firmament", "joined", 2, "boolean", "add")]
[InlineData("testdata/firmament/examples/boolean_subtract_basic.firmament", "carved", 2, "boolean", "subtract")]
[InlineData("testdata/firmament/examples/boolean_intersect_basic.firmament", "overlap", 2, "boolean", "intersect")]
+ [InlineData("testdata/firmament/examples/boolean_two_cylinder_holes_basic.firmament", "hole_b", 2, "boolean", "subtract")]
+ [InlineData("testdata/firmament/examples/boolean_cylinder_cone_holes_basic.firmament", "cut_b", 2, "boolean", "subtract")]
[InlineData("testdata/firmament/examples/placed_primitive.firmament", "post", 1, "primitive", "cylinder")]
[InlineData("testdata/firmament/examples/schema_box_basic.firmament", "schema_box", 0, "primitive", "box")]
public void ExamplePack_GoldenPath_Examples_Export(string fixturePath, string expectedFeatureId, int expectedOpIndex, string expectedBodyCategory, string expectedFeatureKind)
diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentStepExporterTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentStepExporterTests.cs
index 20b9767a..9912d9ed 100644
--- a/Aetheris.Kernel.Firmament.Tests/FirmamentStepExporterTests.cs
+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentStepExporterTests.cs
@@ -104,6 +104,49 @@ public sealed class FirmamentStepExporterTests
Assert.Equal(first.Value.StepText, File.ReadAllText(artifactPath));
}
+ [Fact]
+ public void Export_SupportedTwoCylinderComposition_Exports_Deterministically_With_Persisted_Artifact()
+ {
+ var first = ExportFixture("testdata/firmament/examples/boolean_two_cylinder_holes_basic.firmament");
+ var second = ExportFixture("testdata/firmament/examples/boolean_two_cylinder_holes_basic.firmament");
+
+ Assert.True(first.IsSuccess);
+ Assert.True(second.IsSuccess);
+ Assert.Equal(first.Value.StepText, second.Value.StepText);
+ Assert.Equal("hole_b", first.Value.ExportedFeatureId);
+ Assert.Equal(2, first.Value.ExportedOpIndex);
+ Assert.Equal("boolean", first.Value.ExportedBodyCategory);
+ Assert.Equal("subtract", first.Value.ExportedFeatureKind);
+ Assert.Equal(2, CountOccurrences(first.Value.StepText, "CYLINDRICAL_SURFACE"));
+ Assert.Contains("MANIFOLD_SOLID_BREP", first.Value.StepText, StringComparison.Ordinal);
+
+ var artifactPath = WriteExportArtifact("boolean_two_cylinder_holes_basic.step", first.Value.StepText);
+ Assert.True(File.Exists(artifactPath));
+ Assert.Equal(first.Value.StepText, File.ReadAllText(artifactPath));
+ }
+
+ [Fact]
+ public void Export_SupportedCylinderConeComposition_Exports_Deterministically_With_Persisted_Artifact()
+ {
+ var first = ExportFixture("testdata/firmament/examples/boolean_cylinder_cone_holes_basic.firmament");
+ var second = ExportFixture("testdata/firmament/examples/boolean_cylinder_cone_holes_basic.firmament");
+
+ Assert.True(first.IsSuccess);
+ Assert.True(second.IsSuccess);
+ Assert.Equal(first.Value.StepText, second.Value.StepText);
+ Assert.Equal("cut_b", first.Value.ExportedFeatureId);
+ Assert.Equal(2, first.Value.ExportedOpIndex);
+ Assert.Equal("boolean", first.Value.ExportedBodyCategory);
+ Assert.Equal("subtract", first.Value.ExportedFeatureKind);
+ Assert.Contains("CYLINDRICAL_SURFACE", first.Value.StepText, StringComparison.Ordinal);
+ Assert.Contains("CONICAL_SURFACE", first.Value.StepText, StringComparison.Ordinal);
+ Assert.Contains("MANIFOLD_SOLID_BREP", first.Value.StepText, StringComparison.Ordinal);
+
+ var artifactPath = WriteExportArtifact("boolean_cylinder_cone_holes_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()
{
@@ -132,6 +175,11 @@ public sealed class FirmamentStepExporterTests
[InlineData("testdata/firmament/fixtures/m10n-unsupported-box-subtract-torus.firmament", "ring_cut")]
[InlineData("testdata/firmament/fixtures/m10n-unsupported-box-add-torus.firmament", "joined")]
[InlineData("testdata/firmament/fixtures/m10n-unsupported-box-intersect-torus.firmament", "overlap")]
+ [InlineData("testdata/firmament/fixtures/m13a-unsupported-overlapping-composed-holes.firmament", "hole_b")]
+ [InlineData("testdata/firmament/fixtures/m13a-unsupported-tangent-composed-holes.firmament", "hole_b")]
+ [InlineData("testdata/firmament/fixtures/m13a-unsupported-composed-add-ordering.firmament", "joined")]
+ [InlineData("testdata/firmament/fixtures/m13a-unsupported-composed-subtract-sphere.firmament", "cavity")]
+ [InlineData("testdata/firmament/fixtures/m13a-unsupported-composed-subtract-box.firmament", "notch")]
public void Export_UnsupportedMixedPrimitiveBooleanFixtures_Fail_Loudly_Without_Fallback(string fixturePath, string expectedFeatureId)
{
var first = ExportFixture(fixturePath);
@@ -179,9 +227,23 @@ public sealed class FirmamentStepExporterTests
private static bool HasExpectedMixedPrimitiveFailure(string message)
=> message.Contains("M13 only supports recognized axis-aligned boxes from BrepPrimitives.CreateBox(...).", StringComparison.Ordinal)
+ || message.Contains("sequential safe composition only supports subtracting supported cylinder/cone through-holes", StringComparison.Ordinal)
|| message.Contains("analytic hole candidate failed diagnostic", StringComparison.Ordinal)
|| message.Contains("analytic hole surface kind", StringComparison.Ordinal);
+ private static int CountOccurrences(string text, string token)
+ {
+ var count = 0;
+ var index = 0;
+ while ((index = text.IndexOf(token, index, StringComparison.Ordinal)) >= 0)
+ {
+ count++;
+ index += token.Length;
+ }
+
+ return count;
+ }
+
[Fact]
public void Export_SchemaPresent_Model_Still_Exports_With_Stable_Metadata_And_Deterministic_Text()
{
diff --git a/Aetheris.Kernel.Firmament/Execution/FirmamentPrimitiveExecutor.cs b/Aetheris.Kernel.Firmament/Execution/FirmamentPrimitiveExecutor.cs
index b70abcf2..b06ca3a6 100644
--- a/Aetheris.Kernel.Firmament/Execution/FirmamentPrimitiveExecutor.cs
+++ b/Aetheris.Kernel.Firmament/Execution/FirmamentPrimitiveExecutor.cs
@@ -261,7 +261,7 @@ internal static class FirmamentPrimitiveExecutor
}
}
- return new BrepBody(body.Topology, translatedGeometry, body.Bindings, vertexPoints);
+ return new BrepBody(body.Topology, translatedGeometry, body.Bindings, vertexPoints, body.SafeBooleanComposition?.Translate(translation));
}
}
diff --git a/testdata/firmament/examples/README.md b/testdata/firmament/examples/README.md
index 13e20758..a64e7100 100644
--- a/testdata/firmament/examples/README.md
+++ b/testdata/firmament/examples/README.md
@@ -17,7 +17,9 @@ Other combinations may fail and are intentionally not supported yet.
- `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`.
+- `boolean_two_cylinder_holes_basic.firmament` — canonical sequential safe composition case for `box → subtract cylinder → subtract cylinder`; helper export path: `testdata/firmament/exports/boolean_two_cylinder_holes_basic.step`.
+- `boolean_cylinder_cone_holes_basic.firmament` — canonical sequential safe composition case for `box → subtract cylinder → subtract cone`; helper export path: `testdata/firmament/exports/boolean_cylinder_cone_holes_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 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.
+Unsupported boolean requests are tracked as fixtures/tests, not presented in this working example pack. The supported safe subtract family remains narrow and explicit: `subtract(box, cylinder)` and `subtract(box, cone)` still require a Z-aligned tool, full span through the current box shell, non-degenerate boundary circles for cones, and strict in-bounds clearance with no tangent/grazing contact. Sequential composition is limited to repeated document-order subtracts from that same safe family only: `box → subtract cylinder/cone → subtract cylinder/cone`, while the intermediate result must stay representable as one outer box shell plus non-interfering analytic through-holes. This is not general multi-feature boolean support. Box+cylinder `add`, box+cylinder `intersect`, rotated cylinders, partial-depth cuts, tangent/grazing cases, outside-footprint cuts, interfering multi-hole layouts, and unsupported subtract orderings remain unsupported. Box+cone `add`, box+cone `intersect`, tilted cones, partial-depth cone cuts, tangent/grazing cone cuts, apex-inside cases, outside-footprint cone cuts, and unsupported mixed-ordering requests 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_cylinder_cone_holes_basic.firmament b/testdata/firmament/examples/boolean_cylinder_cone_holes_basic.firmament
new file mode 100644
index 00000000..bad1f0d5
--- /dev/null
+++ b/testdata/firmament/examples/boolean_cylinder_cone_holes_basic.firmament
@@ -0,0 +1,40 @@
+firmament:
+ version: 1
+
+model:
+ name: boolean_cylinder_cone_holes_basic
+ units: mm
+
+ops[3]:
+ -
+ op: box
+ id: base
+ size[3]:
+ 40
+ 30
+ 12
+
+ -
+ op: subtract
+ id: hole_a
+ from: base
+ with:
+ op: cylinder
+ radius: 4
+ height: 20
+ place:
+ on: origin
+ offset[3]:
+ -15
+ 0
+ 0
+
+ -
+ op: subtract
+ id: cut_b
+ from: hole_a
+ with:
+ op: cone
+ bottom_radius: 3
+ top_radius: 5
+ height: 20
diff --git a/testdata/firmament/examples/boolean_two_cylinder_holes_basic.firmament b/testdata/firmament/examples/boolean_two_cylinder_holes_basic.firmament
new file mode 100644
index 00000000..e933dca2
--- /dev/null
+++ b/testdata/firmament/examples/boolean_two_cylinder_holes_basic.firmament
@@ -0,0 +1,39 @@
+firmament:
+ version: 1
+
+model:
+ name: boolean_two_cylinder_holes_basic
+ units: mm
+
+ops[3]:
+ -
+ op: box
+ id: base
+ size[3]:
+ 40
+ 30
+ 12
+
+ -
+ op: subtract
+ id: hole_a
+ from: base
+ with:
+ op: cylinder
+ radius: 4
+ height: 20
+ place:
+ on: origin
+ offset[3]:
+ -15
+ 0
+ 0
+
+ -
+ op: subtract
+ id: hole_b
+ from: hole_a
+ with:
+ op: cylinder
+ radius: 3
+ height: 20
diff --git a/testdata/firmament/exports/boolean_cylinder_cone_holes_basic.step b/testdata/firmament/exports/boolean_cylinder_cone_holes_basic.step
new file mode 100644
index 00000000..08ab1959
--- /dev/null
+++ b/testdata/firmament/exports/boolean_cylinder_cone_holes_basic.step
@@ -0,0 +1,258 @@
+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,-6));
+#2=DIRECTION($,(0,0,-1));
+#3=DIRECTION($,(1,0,0));
+#4=AXIS2_PLACEMENT_3D($,#1,#2,#3);
+#5=PLANE($,#4);
+#6=CARTESIAN_POINT($,(-35,-15,-6));
+#7=VERTEX_POINT($,#6);
+#8=CARTESIAN_POINT($,(5,-15,-6));
+#9=VERTEX_POINT($,#8);
+#10=CARTESIAN_POINT($,(-35,-15,-6));
+#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($,(5,15,-6));
+#17=VERTEX_POINT($,#16);
+#18=CARTESIAN_POINT($,(5,-15,-6));
+#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($,(-35,15,-6));
+#25=VERTEX_POINT($,#24);
+#26=CARTESIAN_POINT($,(5,15,-6));
+#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($,(-35,15,-6));
+#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($,(-11,0,-6));
+#41=VERTEX_POINT($,#40);
+#42=CARTESIAN_POINT($,(-15,0,-6));
+#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=CARTESIAN_POINT($,(3.4,0,-6));
+#52=VERTEX_POINT($,#51);
+#53=CARTESIAN_POINT($,(0,0,-6));
+#54=DIRECTION($,(0,0,1));
+#55=DIRECTION($,(1,0,0));
+#56=AXIS2_PLACEMENT_3D($,#53,#54,#55);
+#57=CIRCLE($,#56,3.4);
+#58=EDGE_CURVE($,#52,#52,#57,.T.);
+#59=ORIENTED_EDGE($,$,$,#58,.F.);
+#60=EDGE_LOOP($,(#59));
+#61=FACE_BOUND('',#60,.T.);
+#62=ADVANCED_FACE('',(#39,#50,#61),#5,.T.);
+#63=CARTESIAN_POINT($,(0,0,6));
+#64=DIRECTION($,(0,0,1));
+#65=DIRECTION($,(1,0,0));
+#66=AXIS2_PLACEMENT_3D($,#63,#64,#65);
+#67=PLANE($,#66);
+#68=CARTESIAN_POINT($,(-35,-15,6));
+#69=VERTEX_POINT($,#68);
+#70=CARTESIAN_POINT($,(5,-15,6));
+#71=VERTEX_POINT($,#70);
+#72=CARTESIAN_POINT($,(-35,-15,6));
+#73=DIRECTION($,(1,0,0));
+#74=VECTOR($,#73,1);
+#75=LINE($,#72,#74);
+#76=EDGE_CURVE($,#69,#71,#75,.T.);
+#77=ORIENTED_EDGE($,$,$,#76,.T.);
+#78=CARTESIAN_POINT($,(5,15,6));
+#79=VERTEX_POINT($,#78);
+#80=CARTESIAN_POINT($,(5,-15,6));
+#81=DIRECTION($,(0,1,0));
+#82=VECTOR($,#81,1);
+#83=LINE($,#80,#82);
+#84=EDGE_CURVE($,#71,#79,#83,.T.);
+#85=ORIENTED_EDGE($,$,$,#84,.T.);
+#86=CARTESIAN_POINT($,(-35,15,6));
+#87=VERTEX_POINT($,#86);
+#88=CARTESIAN_POINT($,(5,15,6));
+#89=DIRECTION($,(-1,0,0));
+#90=VECTOR($,#89,1);
+#91=LINE($,#88,#90);
+#92=EDGE_CURVE($,#79,#87,#91,.T.);
+#93=ORIENTED_EDGE($,$,$,#92,.T.);
+#94=CARTESIAN_POINT($,(-35,15,6));
+#95=DIRECTION($,(0,-1,0));
+#96=VECTOR($,#95,1);
+#97=LINE($,#94,#96);
+#98=EDGE_CURVE($,#87,#69,#97,.T.);
+#99=ORIENTED_EDGE($,$,$,#98,.T.);
+#100=EDGE_LOOP($,(#77,#85,#93,#99));
+#101=FACE_OUTER_BOUND('',#100,.T.);
+#102=CARTESIAN_POINT($,(-11,0,6));
+#103=VERTEX_POINT($,#102);
+#104=CARTESIAN_POINT($,(-15,0,6));
+#105=DIRECTION($,(0,0,1));
+#106=DIRECTION($,(1,0,0));
+#107=AXIS2_PLACEMENT_3D($,#104,#105,#106);
+#108=CIRCLE($,#107,4);
+#109=EDGE_CURVE($,#103,#103,#108,.T.);
+#110=ORIENTED_EDGE($,$,$,#109,.T.);
+#111=EDGE_LOOP($,(#110));
+#112=FACE_BOUND('',#111,.T.);
+#113=CARTESIAN_POINT($,(4.6,0,6));
+#114=VERTEX_POINT($,#113);
+#115=CARTESIAN_POINT($,(0,0,6));
+#116=DIRECTION($,(0,0,1));
+#117=DIRECTION($,(1,0,0));
+#118=AXIS2_PLACEMENT_3D($,#115,#116,#117);
+#119=CIRCLE($,#118,4.6);
+#120=EDGE_CURVE($,#114,#114,#119,.T.);
+#121=ORIENTED_EDGE($,$,$,#120,.T.);
+#122=EDGE_LOOP($,(#121));
+#123=FACE_BOUND('',#122,.T.);
+#124=ADVANCED_FACE('',(#101,#112,#123),#67,.T.);
+#125=CARTESIAN_POINT($,(0,-15,0));
+#126=DIRECTION($,(0,-1,0));
+#127=DIRECTION($,(1,0,0));
+#128=AXIS2_PLACEMENT_3D($,#125,#126,#127);
+#129=PLANE($,#128);
+#130=ORIENTED_EDGE($,$,$,#14,.T.);
+#131=CARTESIAN_POINT($,(5,-15,-6));
+#132=DIRECTION($,(0,0,1));
+#133=VECTOR($,#132,1);
+#134=LINE($,#131,#133);
+#135=EDGE_CURVE($,#9,#71,#134,.T.);
+#136=ORIENTED_EDGE($,$,$,#135,.T.);
+#137=ORIENTED_EDGE($,$,$,#76,.F.);
+#138=CARTESIAN_POINT($,(-35,-15,-6));
+#139=DIRECTION($,(0,0,1));
+#140=VECTOR($,#139,1);
+#141=LINE($,#138,#140);
+#142=EDGE_CURVE($,#7,#69,#141,.T.);
+#143=ORIENTED_EDGE($,$,$,#142,.F.);
+#144=EDGE_LOOP($,(#130,#136,#137,#143));
+#145=FACE_OUTER_BOUND('',#144,.T.);
+#146=ADVANCED_FACE('',(#145),#129,.T.);
+#147=CARTESIAN_POINT($,(5,0,0));
+#148=DIRECTION($,(1,0,0));
+#149=DIRECTION($,(0,1,0));
+#150=AXIS2_PLACEMENT_3D($,#147,#148,#149);
+#151=PLANE($,#150);
+#152=ORIENTED_EDGE($,$,$,#22,.T.);
+#153=CARTESIAN_POINT($,(5,15,-6));
+#154=DIRECTION($,(0,0,1));
+#155=VECTOR($,#154,1);
+#156=LINE($,#153,#155);
+#157=EDGE_CURVE($,#17,#79,#156,.T.);
+#158=ORIENTED_EDGE($,$,$,#157,.T.);
+#159=ORIENTED_EDGE($,$,$,#84,.F.);
+#160=ORIENTED_EDGE($,$,$,#135,.F.);
+#161=EDGE_LOOP($,(#152,#158,#159,#160));
+#162=FACE_OUTER_BOUND('',#161,.T.);
+#163=ADVANCED_FACE('',(#162),#151,.T.);
+#164=CARTESIAN_POINT($,(0,15,0));
+#165=DIRECTION($,(0,1,0));
+#166=DIRECTION($,(-1,0,0));
+#167=AXIS2_PLACEMENT_3D($,#164,#165,#166);
+#168=PLANE($,#167);
+#169=ORIENTED_EDGE($,$,$,#30,.T.);
+#170=CARTESIAN_POINT($,(-35,15,-6));
+#171=DIRECTION($,(0,0,1));
+#172=VECTOR($,#171,1);
+#173=LINE($,#170,#172);
+#174=EDGE_CURVE($,#25,#87,#173,.T.);
+#175=ORIENTED_EDGE($,$,$,#174,.T.);
+#176=ORIENTED_EDGE($,$,$,#92,.F.);
+#177=ORIENTED_EDGE($,$,$,#157,.F.);
+#178=EDGE_LOOP($,(#169,#175,#176,#177));
+#179=FACE_OUTER_BOUND('',#178,.T.);
+#180=ADVANCED_FACE('',(#179),#168,.T.);
+#181=CARTESIAN_POINT($,(-35,0,0));
+#182=DIRECTION($,(-1,0,0));
+#183=DIRECTION($,(0,1,0));
+#184=AXIS2_PLACEMENT_3D($,#181,#182,#183);
+#185=PLANE($,#184);
+#186=ORIENTED_EDGE($,$,$,#36,.T.);
+#187=ORIENTED_EDGE($,$,$,#142,.T.);
+#188=ORIENTED_EDGE($,$,$,#98,.F.);
+#189=ORIENTED_EDGE($,$,$,#174,.F.);
+#190=EDGE_LOOP($,(#186,#187,#188,#189));
+#191=FACE_OUTER_BOUND('',#190,.T.);
+#192=ADVANCED_FACE('',(#191),#185,.T.);
+#193=CARTESIAN_POINT($,(-15,0,-6));
+#194=DIRECTION($,(0,0,1));
+#195=DIRECTION($,(1,0,0));
+#196=AXIS2_PLACEMENT_3D($,#193,#194,#195);
+#197=CYLINDRICAL_SURFACE($,#196,4);
+#198=CARTESIAN_POINT($,(-11,0,6));
+#199=VERTEX_POINT($,#198);
+#200=CARTESIAN_POINT($,(-11,0,-6));
+#201=VERTEX_POINT($,#200);
+#202=CARTESIAN_POINT($,(-11,0,6));
+#203=DIRECTION($,(0,0,-1));
+#204=VECTOR($,#203,1);
+#205=LINE($,#202,#204);
+#206=EDGE_CURVE($,#199,#201,#205,.T.);
+#207=ORIENTED_EDGE($,$,$,#206,.T.);
+#208=ORIENTED_EDGE($,$,$,#109,.F.);
+#209=ORIENTED_EDGE($,$,$,#206,.F.);
+#210=ORIENTED_EDGE($,$,$,#47,.T.);
+#211=EDGE_LOOP($,(#207,#208,#209,#210));
+#212=FACE_OUTER_BOUND('',#211,.T.);
+#213=ADVANCED_FACE('',(#212),#197,.T.);
+#214=CARTESIAN_POINT($,(0,0,-6));
+#215=DIRECTION($,(0,0,1));
+#216=DIRECTION($,(1,0,0));
+#217=AXIS2_PLACEMENT_3D($,#214,#215,#216);
+#218=CONICAL_SURFACE($,#217,3.4,0.099668652491162);
+#219=CARTESIAN_POINT($,(4.6,0,6));
+#220=VERTEX_POINT($,#219);
+#221=CARTESIAN_POINT($,(3.4,0,-6));
+#222=VERTEX_POINT($,#221);
+#223=CARTESIAN_POINT($,(4.6,0,6));
+#224=DIRECTION($,(-0.099503719020999,0,-0.995037190209989));
+#225=VECTOR($,#224,1);
+#226=LINE($,#223,#225);
+#227=EDGE_CURVE($,#220,#222,#226,.T.);
+#228=ORIENTED_EDGE($,$,$,#227,.T.);
+#229=ORIENTED_EDGE($,$,$,#120,.F.);
+#230=ORIENTED_EDGE($,$,$,#227,.F.);
+#231=ORIENTED_EDGE($,$,$,#58,.T.);
+#232=EDGE_LOOP($,(#228,#229,#230,#231));
+#233=FACE_OUTER_BOUND('',#232,.T.);
+#234=ADVANCED_FACE('',(#233),#218,.T.);
+#235=CLOSED_SHELL($,(#62,#124,#146,#163,#180,#192,#213,#234));
+#236=MANIFOLD_SOLID_BREP('AetherisBody',#235);
+#237=APPLICATION_CONTEXT('mechanical design');
+#238=PRODUCT_CONTEXT('',#237,'mechanical');
+#239=PRODUCT('AETHERIS','AetherisBody','',(#238));
+#240=PRODUCT_DEFINITION_FORMATION('','',#239);
+#241=PRODUCT_DEFINITION_CONTEXT('design',#237,'design');
+#242=PRODUCT_DEFINITION('','',#240,#241);
+#243=PRODUCT_DEFINITION_SHAPE('','',#242);
+#244=(LENGTH_UNIT()NAMED_UNIT(*)SI_UNIT(.MILLI.,.METRE.));
+#245=(NAMED_UNIT(*)PLANE_ANGLE_UNIT()SI_UNIT($,.RADIAN.));
+#246=(NAMED_UNIT(*)SI_UNIT($,.STERADIAN.)SOLID_ANGLE_UNIT());
+#247=(GEOMETRIC_REPRESENTATION_CONTEXT(3)GLOBAL_UNIT_ASSIGNED_CONTEXT((#244,#245,#246))REPRESENTATION_CONTEXT('3','3D'));
+#248=SHAPE_REPRESENTATION('AetherisBody',(#236),#247);
+#249=SHAPE_DEFINITION_REPRESENTATION(#243,#248);
+ENDSEC;
+END-ISO-10303-21;
diff --git a/testdata/firmament/exports/boolean_two_cylinder_holes_basic.step b/testdata/firmament/exports/boolean_two_cylinder_holes_basic.step
new file mode 100644
index 00000000..1c5e6769
--- /dev/null
+++ b/testdata/firmament/exports/boolean_two_cylinder_holes_basic.step
@@ -0,0 +1,258 @@
+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,-6));
+#2=DIRECTION($,(0,0,-1));
+#3=DIRECTION($,(1,0,0));
+#4=AXIS2_PLACEMENT_3D($,#1,#2,#3);
+#5=PLANE($,#4);
+#6=CARTESIAN_POINT($,(-35,-15,-6));
+#7=VERTEX_POINT($,#6);
+#8=CARTESIAN_POINT($,(5,-15,-6));
+#9=VERTEX_POINT($,#8);
+#10=CARTESIAN_POINT($,(-35,-15,-6));
+#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($,(5,15,-6));
+#17=VERTEX_POINT($,#16);
+#18=CARTESIAN_POINT($,(5,-15,-6));
+#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($,(-35,15,-6));
+#25=VERTEX_POINT($,#24);
+#26=CARTESIAN_POINT($,(5,15,-6));
+#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($,(-35,15,-6));
+#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($,(-11,0,-6));
+#41=VERTEX_POINT($,#40);
+#42=CARTESIAN_POINT($,(-15,0,-6));
+#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=CARTESIAN_POINT($,(3,0,-6));
+#52=VERTEX_POINT($,#51);
+#53=CARTESIAN_POINT($,(0,0,-6));
+#54=DIRECTION($,(0,0,1));
+#55=DIRECTION($,(1,0,0));
+#56=AXIS2_PLACEMENT_3D($,#53,#54,#55);
+#57=CIRCLE($,#56,3);
+#58=EDGE_CURVE($,#52,#52,#57,.T.);
+#59=ORIENTED_EDGE($,$,$,#58,.F.);
+#60=EDGE_LOOP($,(#59));
+#61=FACE_BOUND('',#60,.T.);
+#62=ADVANCED_FACE('',(#39,#50,#61),#5,.T.);
+#63=CARTESIAN_POINT($,(0,0,6));
+#64=DIRECTION($,(0,0,1));
+#65=DIRECTION($,(1,0,0));
+#66=AXIS2_PLACEMENT_3D($,#63,#64,#65);
+#67=PLANE($,#66);
+#68=CARTESIAN_POINT($,(-35,-15,6));
+#69=VERTEX_POINT($,#68);
+#70=CARTESIAN_POINT($,(5,-15,6));
+#71=VERTEX_POINT($,#70);
+#72=CARTESIAN_POINT($,(-35,-15,6));
+#73=DIRECTION($,(1,0,0));
+#74=VECTOR($,#73,1);
+#75=LINE($,#72,#74);
+#76=EDGE_CURVE($,#69,#71,#75,.T.);
+#77=ORIENTED_EDGE($,$,$,#76,.T.);
+#78=CARTESIAN_POINT($,(5,15,6));
+#79=VERTEX_POINT($,#78);
+#80=CARTESIAN_POINT($,(5,-15,6));
+#81=DIRECTION($,(0,1,0));
+#82=VECTOR($,#81,1);
+#83=LINE($,#80,#82);
+#84=EDGE_CURVE($,#71,#79,#83,.T.);
+#85=ORIENTED_EDGE($,$,$,#84,.T.);
+#86=CARTESIAN_POINT($,(-35,15,6));
+#87=VERTEX_POINT($,#86);
+#88=CARTESIAN_POINT($,(5,15,6));
+#89=DIRECTION($,(-1,0,0));
+#90=VECTOR($,#89,1);
+#91=LINE($,#88,#90);
+#92=EDGE_CURVE($,#79,#87,#91,.T.);
+#93=ORIENTED_EDGE($,$,$,#92,.T.);
+#94=CARTESIAN_POINT($,(-35,15,6));
+#95=DIRECTION($,(0,-1,0));
+#96=VECTOR($,#95,1);
+#97=LINE($,#94,#96);
+#98=EDGE_CURVE($,#87,#69,#97,.T.);
+#99=ORIENTED_EDGE($,$,$,#98,.T.);
+#100=EDGE_LOOP($,(#77,#85,#93,#99));
+#101=FACE_OUTER_BOUND('',#100,.T.);
+#102=CARTESIAN_POINT($,(-11,0,6));
+#103=VERTEX_POINT($,#102);
+#104=CARTESIAN_POINT($,(-15,0,6));
+#105=DIRECTION($,(0,0,1));
+#106=DIRECTION($,(1,0,0));
+#107=AXIS2_PLACEMENT_3D($,#104,#105,#106);
+#108=CIRCLE($,#107,4);
+#109=EDGE_CURVE($,#103,#103,#108,.T.);
+#110=ORIENTED_EDGE($,$,$,#109,.T.);
+#111=EDGE_LOOP($,(#110));
+#112=FACE_BOUND('',#111,.T.);
+#113=CARTESIAN_POINT($,(3,0,6));
+#114=VERTEX_POINT($,#113);
+#115=CARTESIAN_POINT($,(0,0,6));
+#116=DIRECTION($,(0,0,1));
+#117=DIRECTION($,(1,0,0));
+#118=AXIS2_PLACEMENT_3D($,#115,#116,#117);
+#119=CIRCLE($,#118,3);
+#120=EDGE_CURVE($,#114,#114,#119,.T.);
+#121=ORIENTED_EDGE($,$,$,#120,.T.);
+#122=EDGE_LOOP($,(#121));
+#123=FACE_BOUND('',#122,.T.);
+#124=ADVANCED_FACE('',(#101,#112,#123),#67,.T.);
+#125=CARTESIAN_POINT($,(0,-15,0));
+#126=DIRECTION($,(0,-1,0));
+#127=DIRECTION($,(1,0,0));
+#128=AXIS2_PLACEMENT_3D($,#125,#126,#127);
+#129=PLANE($,#128);
+#130=ORIENTED_EDGE($,$,$,#14,.T.);
+#131=CARTESIAN_POINT($,(5,-15,-6));
+#132=DIRECTION($,(0,0,1));
+#133=VECTOR($,#132,1);
+#134=LINE($,#131,#133);
+#135=EDGE_CURVE($,#9,#71,#134,.T.);
+#136=ORIENTED_EDGE($,$,$,#135,.T.);
+#137=ORIENTED_EDGE($,$,$,#76,.F.);
+#138=CARTESIAN_POINT($,(-35,-15,-6));
+#139=DIRECTION($,(0,0,1));
+#140=VECTOR($,#139,1);
+#141=LINE($,#138,#140);
+#142=EDGE_CURVE($,#7,#69,#141,.T.);
+#143=ORIENTED_EDGE($,$,$,#142,.F.);
+#144=EDGE_LOOP($,(#130,#136,#137,#143));
+#145=FACE_OUTER_BOUND('',#144,.T.);
+#146=ADVANCED_FACE('',(#145),#129,.T.);
+#147=CARTESIAN_POINT($,(5,0,0));
+#148=DIRECTION($,(1,0,0));
+#149=DIRECTION($,(0,1,0));
+#150=AXIS2_PLACEMENT_3D($,#147,#148,#149);
+#151=PLANE($,#150);
+#152=ORIENTED_EDGE($,$,$,#22,.T.);
+#153=CARTESIAN_POINT($,(5,15,-6));
+#154=DIRECTION($,(0,0,1));
+#155=VECTOR($,#154,1);
+#156=LINE($,#153,#155);
+#157=EDGE_CURVE($,#17,#79,#156,.T.);
+#158=ORIENTED_EDGE($,$,$,#157,.T.);
+#159=ORIENTED_EDGE($,$,$,#84,.F.);
+#160=ORIENTED_EDGE($,$,$,#135,.F.);
+#161=EDGE_LOOP($,(#152,#158,#159,#160));
+#162=FACE_OUTER_BOUND('',#161,.T.);
+#163=ADVANCED_FACE('',(#162),#151,.T.);
+#164=CARTESIAN_POINT($,(0,15,0));
+#165=DIRECTION($,(0,1,0));
+#166=DIRECTION($,(-1,0,0));
+#167=AXIS2_PLACEMENT_3D($,#164,#165,#166);
+#168=PLANE($,#167);
+#169=ORIENTED_EDGE($,$,$,#30,.T.);
+#170=CARTESIAN_POINT($,(-35,15,-6));
+#171=DIRECTION($,(0,0,1));
+#172=VECTOR($,#171,1);
+#173=LINE($,#170,#172);
+#174=EDGE_CURVE($,#25,#87,#173,.T.);
+#175=ORIENTED_EDGE($,$,$,#174,.T.);
+#176=ORIENTED_EDGE($,$,$,#92,.F.);
+#177=ORIENTED_EDGE($,$,$,#157,.F.);
+#178=EDGE_LOOP($,(#169,#175,#176,#177));
+#179=FACE_OUTER_BOUND('',#178,.T.);
+#180=ADVANCED_FACE('',(#179),#168,.T.);
+#181=CARTESIAN_POINT($,(-35,0,0));
+#182=DIRECTION($,(-1,0,0));
+#183=DIRECTION($,(0,1,0));
+#184=AXIS2_PLACEMENT_3D($,#181,#182,#183);
+#185=PLANE($,#184);
+#186=ORIENTED_EDGE($,$,$,#36,.T.);
+#187=ORIENTED_EDGE($,$,$,#142,.T.);
+#188=ORIENTED_EDGE($,$,$,#98,.F.);
+#189=ORIENTED_EDGE($,$,$,#174,.F.);
+#190=EDGE_LOOP($,(#186,#187,#188,#189));
+#191=FACE_OUTER_BOUND('',#190,.T.);
+#192=ADVANCED_FACE('',(#191),#185,.T.);
+#193=CARTESIAN_POINT($,(-15,0,-6));
+#194=DIRECTION($,(0,0,1));
+#195=DIRECTION($,(1,0,0));
+#196=AXIS2_PLACEMENT_3D($,#193,#194,#195);
+#197=CYLINDRICAL_SURFACE($,#196,4);
+#198=CARTESIAN_POINT($,(-11,0,6));
+#199=VERTEX_POINT($,#198);
+#200=CARTESIAN_POINT($,(-11,0,-6));
+#201=VERTEX_POINT($,#200);
+#202=CARTESIAN_POINT($,(-11,0,6));
+#203=DIRECTION($,(0,0,-1));
+#204=VECTOR($,#203,1);
+#205=LINE($,#202,#204);
+#206=EDGE_CURVE($,#199,#201,#205,.T.);
+#207=ORIENTED_EDGE($,$,$,#206,.T.);
+#208=ORIENTED_EDGE($,$,$,#109,.F.);
+#209=ORIENTED_EDGE($,$,$,#206,.F.);
+#210=ORIENTED_EDGE($,$,$,#47,.T.);
+#211=EDGE_LOOP($,(#207,#208,#209,#210));
+#212=FACE_OUTER_BOUND('',#211,.T.);
+#213=ADVANCED_FACE('',(#212),#197,.T.);
+#214=CARTESIAN_POINT($,(0,0,-6));
+#215=DIRECTION($,(0,0,1));
+#216=DIRECTION($,(1,0,0));
+#217=AXIS2_PLACEMENT_3D($,#214,#215,#216);
+#218=CYLINDRICAL_SURFACE($,#217,3);
+#219=CARTESIAN_POINT($,(3,0,6));
+#220=VERTEX_POINT($,#219);
+#221=CARTESIAN_POINT($,(3,0,-6));
+#222=VERTEX_POINT($,#221);
+#223=CARTESIAN_POINT($,(3,0,6));
+#224=DIRECTION($,(0,0,-1));
+#225=VECTOR($,#224,1);
+#226=LINE($,#223,#225);
+#227=EDGE_CURVE($,#220,#222,#226,.T.);
+#228=ORIENTED_EDGE($,$,$,#227,.T.);
+#229=ORIENTED_EDGE($,$,$,#120,.F.);
+#230=ORIENTED_EDGE($,$,$,#227,.F.);
+#231=ORIENTED_EDGE($,$,$,#58,.T.);
+#232=EDGE_LOOP($,(#228,#229,#230,#231));
+#233=FACE_OUTER_BOUND('',#232,.T.);
+#234=ADVANCED_FACE('',(#233),#218,.T.);
+#235=CLOSED_SHELL($,(#62,#124,#146,#163,#180,#192,#213,#234));
+#236=MANIFOLD_SOLID_BREP('AetherisBody',#235);
+#237=APPLICATION_CONTEXT('mechanical design');
+#238=PRODUCT_CONTEXT('',#237,'mechanical');
+#239=PRODUCT('AETHERIS','AetherisBody','',(#238));
+#240=PRODUCT_DEFINITION_FORMATION('','',#239);
+#241=PRODUCT_DEFINITION_CONTEXT('design',#237,'design');
+#242=PRODUCT_DEFINITION('','',#240,#241);
+#243=PRODUCT_DEFINITION_SHAPE('','',#242);
+#244=(LENGTH_UNIT()NAMED_UNIT(*)SI_UNIT(.MILLI.,.METRE.));
+#245=(NAMED_UNIT(*)PLANE_ANGLE_UNIT()SI_UNIT($,.RADIAN.));
+#246=(NAMED_UNIT(*)SI_UNIT($,.STERADIAN.)SOLID_ANGLE_UNIT());
+#247=(GEOMETRIC_REPRESENTATION_CONTEXT(3)GLOBAL_UNIT_ASSIGNED_CONTEXT((#244,#245,#246))REPRESENTATION_CONTEXT('3','3D'));
+#248=SHAPE_REPRESENTATION('AetherisBody',(#236),#247);
+#249=SHAPE_DEFINITION_REPRESENTATION(#243,#248);
+ENDSEC;
+END-ISO-10303-21;
diff --git a/testdata/firmament/fixtures/m13a-unsupported-composed-add-ordering.firmament b/testdata/firmament/fixtures/m13a-unsupported-composed-add-ordering.firmament
new file mode 100644
index 00000000..4e2722a5
--- /dev/null
+++ b/testdata/firmament/fixtures/m13a-unsupported-composed-add-ordering.firmament
@@ -0,0 +1,39 @@
+firmament:
+ version: 1
+
+model:
+ name: m13a_unsupported_composed_add_ordering
+ units: mm
+
+ops[3]:
+ -
+ op: box
+ id: base
+ size[3]:
+ 40
+ 30
+ 12
+
+ -
+ op: subtract
+ id: hole_a
+ from: base
+ with:
+ op: cylinder
+ radius: 4
+ height: 20
+
+ -
+ op: add
+ id: joined
+ to: hole_a
+ with:
+ op: cylinder
+ radius: 3
+ height: 20
+ place:
+ on: origin
+ offset[3]:
+ 8
+ 0
+ 0
diff --git a/testdata/firmament/fixtures/m13a-unsupported-composed-subtract-box.firmament b/testdata/firmament/fixtures/m13a-unsupported-composed-subtract-box.firmament
new file mode 100644
index 00000000..6c3d4b84
--- /dev/null
+++ b/testdata/firmament/fixtures/m13a-unsupported-composed-subtract-box.firmament
@@ -0,0 +1,35 @@
+firmament:
+ version: 1
+
+model:
+ name: m13a_unsupported_composed_subtract_box
+ units: mm
+
+ops[3]:
+ -
+ op: box
+ id: base
+ size[3]:
+ 40
+ 30
+ 12
+
+ -
+ op: subtract
+ id: hole_a
+ from: base
+ with:
+ op: cylinder
+ radius: 4
+ height: 20
+
+ -
+ op: subtract
+ id: notch
+ from: hole_a
+ with:
+ op: box
+ size[3]:
+ 6
+ 6
+ 20
diff --git a/testdata/firmament/fixtures/m13a-unsupported-composed-subtract-sphere.firmament b/testdata/firmament/fixtures/m13a-unsupported-composed-subtract-sphere.firmament
new file mode 100644
index 00000000..dc864376
--- /dev/null
+++ b/testdata/firmament/fixtures/m13a-unsupported-composed-subtract-sphere.firmament
@@ -0,0 +1,32 @@
+firmament:
+ version: 1
+
+model:
+ name: m13a_unsupported_composed_subtract_sphere
+ units: mm
+
+ops[3]:
+ -
+ op: box
+ id: base
+ size[3]:
+ 40
+ 30
+ 12
+
+ -
+ op: subtract
+ id: hole_a
+ from: base
+ with:
+ op: cylinder
+ radius: 4
+ height: 20
+
+ -
+ op: subtract
+ id: cavity
+ from: hole_a
+ with:
+ op: sphere
+ radius: 3
diff --git a/testdata/firmament/fixtures/m13a-unsupported-overlapping-composed-holes.firmament b/testdata/firmament/fixtures/m13a-unsupported-overlapping-composed-holes.firmament
new file mode 100644
index 00000000..f31151ce
--- /dev/null
+++ b/testdata/firmament/fixtures/m13a-unsupported-overlapping-composed-holes.firmament
@@ -0,0 +1,39 @@
+firmament:
+ version: 1
+
+model:
+ name: m13a_unsupported_overlapping_composed_holes
+ units: mm
+
+ops[3]:
+ -
+ op: box
+ id: base
+ size[3]:
+ 40
+ 30
+ 12
+
+ -
+ op: subtract
+ id: hole_a
+ from: base
+ with:
+ op: cylinder
+ radius: 4
+ height: 20
+ place:
+ on: origin
+ offset[3]:
+ -6
+ 0
+ 0
+
+ -
+ op: subtract
+ id: hole_b
+ from: hole_a
+ with:
+ op: cylinder
+ radius: 4
+ height: 20
diff --git a/testdata/firmament/fixtures/m13a-unsupported-tangent-composed-holes.firmament b/testdata/firmament/fixtures/m13a-unsupported-tangent-composed-holes.firmament
new file mode 100644
index 00000000..10d889b8
--- /dev/null
+++ b/testdata/firmament/fixtures/m13a-unsupported-tangent-composed-holes.firmament
@@ -0,0 +1,39 @@
+firmament:
+ version: 1
+
+model:
+ name: m13a_unsupported_tangent_composed_holes
+ units: mm
+
+ops[3]:
+ -
+ op: box
+ id: base
+ size[3]:
+ 40
+ 30
+ 12
+
+ -
+ op: subtract
+ id: hole_a
+ from: base
+ with:
+ op: cylinder
+ radius: 4
+ height: 20
+ place:
+ on: origin
+ offset[3]:
+ -8
+ 0
+ 0
+
+ -
+ op: subtract
+ id: hole_b
+ from: hole_a
+ with:
+ op: cylinder
+ radius: 4
+ height: 20