Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

G7 bound blind-hole continuation on recognized additive roots

Yuechen Li50f28ab631ac
diff --git a/Aetheris.Kernel.Core.Tests/Brep/Boolean/BrepBooleanTests.cs b/Aetheris.Kernel.Core.Tests/Brep/Boolean/BrepBooleanTests.cs
index 61f26366..e294093b 100644
--- a/Aetheris.Kernel.Core.Tests/Brep/Boolean/BrepBooleanTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Brep/Boolean/BrepBooleanTests.cs
@@ -825,7 +825,7 @@ public sealed class BrepBooleanTests
}
[Fact]
- public void Subtract_ComposedThroughThenBlindCylinder_ReturnsUnsupportedBlindHoleCompositionDiagnostic()
+ public void Subtract_ComposedThroughThenBlindCylinder_OnPrimitiveRoot_ReturnsBoundedBlindContinuationDiagnostic()
{
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)));
@@ -837,7 +837,60 @@ public sealed class BrepBooleanTests
var result = BrepBoolean.Subtract(first.Value, blind);
Assert.False(result.IsSuccess);
var diagnostic = Assert.Single(result.Diagnostics);
- Assert.Equal("BrepBoolean.AnalyticHole.UnsupportedBlindHoleComposition", diagnostic.Source);
+ Assert.Equal("BrepBoolean.AnalyticHole.BlindContinuationOutsideBoundedFamily", diagnostic.Source);
+ }
+
+ [Fact]
+ public void Subtract_RecognizedOrthogonalAdditiveRoot_ComposedThroughThenBlindCylinder_PassesValidatorBoundedFamily()
+ {
+ var composition = new SafeBooleanComposition(
+ new AxisAlignedBoxExtents(-30d, 30d, -15d, 15d, -4d, 44d),
+ [
+ new SupportedBooleanHole(
+ "base_hole",
+ new AnalyticSurface(
+ AnalyticSurfaceKind.Cylinder,
+ Cylinder: new RecognizedCylinder(
+ new Point3D(-15d, 0d, -30d),
+ Direction3D.Create(new Vector3D(0d, 0d, 1d)),
+ 0d,
+ 80d,
+ 3.5d)),
+ -15d,
+ 0d,
+ new Point3D(-15d, 0d, -4d),
+ new Point3D(-15d, 0d, 44d),
+ Direction3D.Create(new Vector3D(0d, 0d, 1d)),
+ Direction3D.Create(new Vector3D(1d, 0d, 0d)),
+ 3.5d,
+ 3.5d,
+ SupportedBooleanHoleSpanKind.Through,
+ -4d,
+ 44d),
+ ],
+ SafeBooleanRootDescriptor.FromBox(new AxisAlignedBoxExtents(-30d, 30d, -15d, 15d, -4d, 44d)),
+ [new AxisAlignedBoxExtents(-30d, 30d, -15d, 15d, -4d, 4d), new AxisAlignedBoxExtents(22d, 30d, -15d, 15d, 4d, 44d)]);
+ var blind = new AnalyticSurface(
+ AnalyticSurfaceKind.Cylinder,
+ Cylinder: new RecognizedCylinder(
+ new Point3D(26d, 0d, 8d),
+ Direction3D.Create(new Vector3D(0d, 0d, 1d)),
+ 0d,
+ 20d,
+ 3.5d));
+
+ var accepted = BrepBooleanSafeCompositionGraphValidator.TryValidateNextSubtract(
+ composition,
+ blind,
+ ToleranceContext.Default,
+ out var updated,
+ out var diagnostic,
+ "upright_hole");
+
+ Assert.True(accepted);
+ Assert.Null(diagnostic);
+ Assert.Equal(2, updated.Holes.Count);
+ Assert.Equal("upright_hole", updated.Holes[1].FeatureId);
}
[Fact]
diff --git a/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanBoxCylinderHoleBuilder.cs b/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanBoxCylinderHoleBuilder.cs
index 414289d7..1c785fcd 100644
--- a/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanBoxCylinderHoleBuilder.cs
+++ b/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanBoxCylinderHoleBuilder.cs
@@ -78,7 +78,7 @@ public static class BrepBooleanBoxCylinderHoleBuilder
}
}
- return CreateComposedThroughHoleBody(composition);
+ return CreateComposedThroughHoleBody(composition, tolerance);
}
private static KernelResult<BrepBody> CreateBoundedCylinderRootHoleChainBody(SafeBooleanComposition composition, ToleranceContext tolerance)
@@ -396,11 +396,13 @@ public static class BrepBooleanBoxCylinderHoleBuilder
: KernelResult<BrepBody>.Failure(validation.Diagnostics);
}
- private static KernelResult<BrepBody> CreateComposedThroughHoleBody(SafeBooleanComposition composition)
+ private static KernelResult<BrepBody> CreateComposedThroughHoleBody(SafeBooleanComposition composition, ToleranceContext tolerance)
{
var box = composition.OuterBox;
var holes = composition.Holes;
- if (holes.Count > 1 && holes.Any(h => h.IsBlind))
+ if (holes.Count > 1
+ && holes.Any(h => h.IsBlind)
+ && !SupportsBoundedBlindContinuationOnRecognizedOrthogonalAdditiveRoot(composition, tolerance))
{
return KernelResult<BrepBody>.Failure([
new BooleanDiagnostic(
@@ -408,8 +410,8 @@ public static class BrepBooleanBoxCylinderHoleBuilder
BrepBooleanCylinderRecognition.CreateBooleanMessage(
BooleanOperation.Subtract.ToString(),
null,
- "cannot rebuild a composition with more than one blind analytic hole in B1; blind-hole support is limited to single-feature subtracts."),
- "BrepBoolean.AnalyticHole.UnsupportedBlindHoleComposition").ToKernelDiagnostic(),
+ "blind-hole continuation exceeds bounded rebuild support; only recognized orthogonal additive roots with world-Z cylinder/cone hole chains are rebuildable in this milestone."),
+ "BrepBoolean.AnalyticHole.BlindContinuationOutsideBoundedFamily").ToKernelDiagnostic(),
]);
}
@@ -1068,6 +1070,35 @@ public static class BrepBooleanBoxCylinderHoleBuilder
return loopId;
}
+ private static bool SupportsBoundedBlindContinuationOnRecognizedOrthogonalAdditiveRoot(
+ SafeBooleanComposition composition,
+ ToleranceContext tolerance)
+ {
+ if (composition.OccupiedCells is null || composition.OccupiedCells.Count < 2)
+ {
+ return false;
+ }
+
+ foreach (var hole in composition.Holes.Where(h => h.IsBlind))
+ {
+ if (hole.Surface.Kind is not (AnalyticSurfaceKind.Cylinder or AnalyticSurfaceKind.Cone)
+ || !IsAxisAlignedWithWorldZ(hole.Axis, tolerance))
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private static bool IsAxisAlignedWithWorldZ(Direction3D axis, ToleranceContext tolerance)
+ {
+ var v = axis.ToVector();
+ return ToleranceMath.AlmostZero(v.X, tolerance)
+ && ToleranceMath.AlmostZero(v.Y, tolerance)
+ && ToleranceMath.AlmostEqual(System.Math.Abs(v.Z), 1d, tolerance);
+ }
+
private readonly record struct HoleTopology(
SupportedBooleanHole Hole,
VertexId TopHoleVertex,
diff --git a/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanSafeCompositionGraphValidator.cs b/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanSafeCompositionGraphValidator.cs
index 8f377e33..38cfe99a 100644
--- a/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanSafeCompositionGraphValidator.cs
+++ b/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanSafeCompositionGraphValidator.cs
@@ -35,15 +35,16 @@ public static class BrepBooleanSafeCompositionGraphValidator
return false;
}
- if (composition.Holes.Count > 0 && nextHole.IsBlind)
+ var supportsContinuedAdditiveBlindComposition = SupportsBoundedBlindContinuationOnRecognizedOrthogonalAdditiveRoot(composition, nextHole, tolerance);
+ if (composition.Holes.Count > 0 && nextHole.IsBlind && !supportsContinuedAdditiveBlindComposition)
{
diagnostic = new BooleanDiagnostic(
BooleanDiagnosticCode.UnsupportedBlindHoleComposition,
BrepBooleanCylinderRecognition.CreateBooleanMessage(
BooleanOperation.Subtract.ToString(),
nextFeatureId,
- "cannot append a blind analytic hole to an existing safe subtract composition in B1; blind-hole support is currently limited to single-feature subtracts."),
- "BrepBoolean.AnalyticHole.UnsupportedBlindHoleComposition");
+ "blind-hole continuation exceeds the bounded family; only recognized orthogonal additive roots with world-Z analytic-hole chains are supported for continued blind-hole composition."),
+ "BrepBoolean.AnalyticHole.BlindContinuationOutsideBoundedFamily");
return false;
}
@@ -488,6 +489,29 @@ public static class BrepBooleanSafeCompositionGraphValidator
&& ToleranceMath.AlmostEqual(System.Math.Abs(v.Z), 1d, tolerance);
}
+ private static bool SupportsBoundedBlindContinuationOnRecognizedOrthogonalAdditiveRoot(
+ SafeBooleanComposition composition,
+ in SupportedBooleanHole nextHole,
+ ToleranceContext tolerance)
+ {
+ if (composition.OccupiedCells is null || composition.OccupiedCells.Count < 2)
+ {
+ return false;
+ }
+
+ if (!IsAxisAlignedWithWorldZ(nextHole.Axis, tolerance))
+ {
+ return false;
+ }
+
+ if (composition.Holes.Any(existingHole => !IsAxisAlignedWithWorldZ(existingHole.Axis, tolerance)))
+ {
+ return false;
+ }
+
+ return nextHole.Surface.Kind is AnalyticSurfaceKind.Cylinder or AnalyticSurfaceKind.Cone;
+ }
+
private static bool ValidateContainedSphereCavity(
AxisAlignedBoxExtents outerBox,
in RecognizedSphere sphere,
diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentBuildAndExportTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentBuildAndExportTests.cs
index 870a42cd..b7e1b198 100644
--- a/Aetheris.Kernel.Firmament.Tests/FirmamentBuildAndExportTests.cs
+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentBuildAndExportTests.cs
@@ -366,7 +366,7 @@ public sealed class FirmamentBuildAndExportTests
}
[Fact]
- public void Run_FrictionLabMountingBracketBasic_ProgressesPastUnrecognizedAdditiveRoot_ToBlindHoleCompositionBlocker()
+ public void Run_FrictionLabMountingBracketBasic_ProgressesToCoaxialStackConstraint()
{
var fullSourcePath = Path.Combine(FirmamentCorpusHarness.RepoRoot(), "Aetheris.Firmament.FrictionLab/Cases/mounting-bracket-basic/part.firmament");
var result = FirmamentBuildAndExport.Run(fullSourcePath);
@@ -375,9 +375,9 @@ public sealed class FirmamentBuildAndExportTests
Assert.Contains(result.Diagnostics, diagnostic =>
diagnostic.Message.Contains("Requested boolean feature 'upright_hole' (subtract) could not be executed.", StringComparison.Ordinal));
Assert.Contains(result.Diagnostics, diagnostic =>
- diagnostic.Message.Contains("cannot append a blind analytic hole to an existing safe subtract composition", StringComparison.Ordinal));
+ diagnostic.Message.Contains("requires coaxial cylinders with matching XY axis centers", StringComparison.Ordinal));
Assert.DoesNotContain(result.Diagnostics, diagnostic =>
- string.Equals(diagnostic.Source, "firmament.feature-graph.unrecognized-additive-root", StringComparison.Ordinal));
+ diagnostic.Message.Contains("cannot append a blind analytic hole to an existing safe subtract composition", StringComparison.Ordinal));
}
[Fact]