Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

F6 narrow cylinder-root hole-chain progression for flange bolt-circle

Yuechen Li8afc3902fd00
diff --git a/Aetheris.Kernel.Core.Tests/Brep/Boolean/BrepBooleanTests.cs b/Aetheris.Kernel.Core.Tests/Brep/Boolean/BrepBooleanTests.cs
index 7fd0114b..4e3ec9c2 100644
--- a/Aetheris.Kernel.Core.Tests/Brep/Boolean/BrepBooleanTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Brep/Boolean/BrepBooleanTests.cs
@@ -617,6 +617,24 @@ public sealed class BrepBooleanTests
Assert.Contains("tangent to previously accepted hole", diagnostic.Message, StringComparison.Ordinal);
}
+ [Fact]
+ public void Subtract_CylinderRootDuplicateBoltHole_IsAcceptedAsNoOp()
+ {
+ var root = BrepPrimitives.CreateCylinder(40d, 12d).Value;
+ var centerBore = BrepPrimitives.CreateCylinder(12d, 24d).Value;
+ var holeA = TransformBody(BrepPrimitives.CreateCylinder(4d, 24d).Value, Transform3D.CreateTranslation(new Vector3D(25d, 0d, 0d)));
+
+ var withCenterBore = BrepBoolean.Subtract(root, centerBore);
+ Assert.True(withCenterBore.IsSuccess);
+ var withHoleA = BrepBoolean.Subtract(withCenterBore.Value, holeA);
+ Assert.True(withHoleA.IsSuccess);
+ var withDuplicateHole = BrepBoolean.Subtract(withHoleA.Value, holeA);
+
+ Assert.True(withDuplicateHole.IsSuccess);
+ Assert.True(BrepBindingValidator.Validate(withDuplicateHole.Value, true).IsSuccess);
+ Assert.Equal(2, withDuplicateHole.Value.ShellRepresentation!.InnerShellIds.Count);
+ }
+
[Fact]
public void Subtract_BoxCylinderRotatedAxis_SucceedsWithinBoundedSubset()
{
diff --git a/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanSafeCompositionGraphValidator.cs b/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanSafeCompositionGraphValidator.cs
index ae2f35fc..40355928 100644
--- a/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanSafeCompositionGraphValidator.cs
+++ b/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanSafeCompositionGraphValidator.cs
@@ -240,6 +240,12 @@ public static class BrepBooleanSafeCompositionGraphValidator
var centerDistance = System.Math.Sqrt((existingDeltaX * existingDeltaX) + (existingDeltaY * existingDeltaY));
var requiredDistance = existingHole.MaxBoundaryRadius + nextHole.MaxBoundaryRadius;
+ if (AreEquivalentCylinderRootThroughHoles(existingHole, nextHole, tolerance))
+ {
+ updatedComposition = composition;
+ return true;
+ }
+
if (ToleranceMath.AlmostEqual(centerDistance, requiredDistance, tolerance))
{
diagnostic = BrepBooleanCylinderRecognition.CreateTangentContactDiagnostic(
@@ -270,6 +276,27 @@ public static class BrepBooleanSafeCompositionGraphValidator
return true;
}
+ private static bool AreEquivalentCylinderRootThroughHoles(
+ in SupportedBooleanHole existingHole,
+ in SupportedBooleanHole nextHole,
+ ToleranceContext tolerance)
+ {
+ if (existingHole.Surface.Kind != AnalyticSurfaceKind.Cylinder
+ || nextHole.Surface.Kind != AnalyticSurfaceKind.Cylinder
+ || existingHole.SpanKind != SupportedBooleanHoleSpanKind.Through
+ || nextHole.SpanKind != SupportedBooleanHoleSpanKind.Through)
+ {
+ return false;
+ }
+
+ return ToleranceMath.AlmostEqual(existingHole.CenterX, nextHole.CenterX, tolerance)
+ && ToleranceMath.AlmostEqual(existingHole.CenterY, nextHole.CenterY, tolerance)
+ && ToleranceMath.AlmostEqual(existingHole.BottomRadius, nextHole.BottomRadius, tolerance)
+ && ToleranceMath.AlmostEqual(existingHole.TopRadius, nextHole.TopRadius, tolerance)
+ && ToleranceMath.AlmostEqual(existingHole.StartZ, nextHole.StartZ, tolerance)
+ && ToleranceMath.AlmostEqual(existingHole.EndZ, nextHole.EndZ, tolerance);
+ }
+
private static bool TryCreateSupportedHole(
SafeBooleanComposition composition,
AnalyticSurface surface,
diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentBuildAndExportTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentBuildAndExportTests.cs
index d53ee611..4ebdff30 100644
--- a/Aetheris.Kernel.Firmament.Tests/FirmamentBuildAndExportTests.cs
+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentBuildAndExportTests.cs
@@ -565,6 +565,21 @@ public sealed class FirmamentBuildAndExportTests
Assert.True(CountOccurrences(stepText, "ADVANCED_FACE") > 6);
}
+ [Fact]
+ public void Run_FrictionLabFlangeBoltCircle_RemovesOverlapBlocker_AndFailsAtSchemaVoidGate()
+ {
+ var fullSourcePath = Path.Combine(FirmamentCorpusHarness.RepoRoot(), "Aetheris.Firmament.FrictionLab/Cases/flange-bolt-circle/part.firmament");
+ var result = FirmamentBuildAndExport.Run(fullSourcePath);
+
+ Assert.False(result.IsSuccess);
+ Assert.DoesNotContain(result.Diagnostics, diagnostic =>
+ diagnostic.Message.Contains("overlapping cylinder-root hole chains are not supported", StringComparison.Ordinal));
+ Assert.Contains(result.Diagnostics, diagnostic =>
+ diagnostic.Message.Contains("[FIRM-SCHEMA-0006]", StringComparison.Ordinal)
+ && diagnostic.Message.Contains("contains 5 fully enclosed internal void", StringComparison.Ordinal)
+ && diagnostic.Message.Contains("bolt_0__cir4", StringComparison.Ordinal));
+ }
+
[Fact]
public void Run_BoundedPocketFixture_WithSealedCavity_RemainsExplicitlyRejected()
{
diff --git a/Aetheris.Kernel.Firmament/Execution/FirmamentPrimitiveExecutor.cs b/Aetheris.Kernel.Firmament/Execution/FirmamentPrimitiveExecutor.cs
index 302a0159..1d2bed4a 100644
--- a/Aetheris.Kernel.Firmament/Execution/FirmamentPrimitiveExecutor.cs
+++ b/Aetheris.Kernel.Firmament/Execution/FirmamentPrimitiveExecutor.cs
@@ -105,10 +105,17 @@ internal static class FirmamentPrimitiveExecutor
continue;
}
+ var toolResult = FirmamentBooleanToolBodyFactory.CreateBody(boolean.Tool);
+ if (!toolResult.IsSuccess)
+ {
+ return KernelResult<FirmamentPrimitiveExecutionResult>.Failure(toolResult.Diagnostics);
+ }
+
var featureGraphValidation = FirmamentSafeSubtractFeatureGraphValidator.ValidateNextBoolean(
boolean,
featureGraphStates,
- booleanExecutionBodiesByFeatureId);
+ booleanExecutionBodiesByFeatureId,
+ resolvedToolBody: ResolveValidationToolBody(boolean, baseBody, toolResult.Value, publishedBodiesByFeatureId));
if (!featureGraphValidation.IsSuccess)
{
return KernelResult<FirmamentPrimitiveExecutionResult>.Failure(
@@ -118,12 +125,6 @@ internal static class FirmamentPrimitiveExecutor
]);
}
- var toolResult = FirmamentBooleanToolBodyFactory.CreateBody(boolean.Tool);
- if (!toolResult.IsSuccess)
- {
- return KernelResult<FirmamentPrimitiveExecutionResult>.Failure(toolResult.Diagnostics);
- }
-
var canUsePublishedFrameAdditiveExecution = boolean.Kind == FirmamentLoweredBooleanKind.Add
&& boolean.Placement is not null;
var usedPublishedFrameAdditiveExecution = false;
@@ -164,7 +165,7 @@ internal static class FirmamentPrimitiveExecutor
return KernelResult<FirmamentPrimitiveExecutionResult>.Failure(placementResult.Diagnostics);
}
- var translatedToolBody = TranslateBody(ApplyDefaultToolLocalFrame(boolean.Tool, toolResult.Value), placementResult.Value);
+ var translatedToolBody = PlaceSemanticToolBody(boolean, toolResult.Value, placementResult.Value);
booleanResult = ExecuteBoolean(boolean.Kind, baseBody, translatedToolBody);
}
else
@@ -403,6 +404,35 @@ internal static class FirmamentPrimitiveExecutor
return !coversMin && !coversMax;
}
+ private static BrepBody? ResolveValidationToolBody(
+ FirmamentLoweredBoolean boolean,
+ BrepBody baseBody,
+ BrepBody toolBody,
+ IReadOnlyDictionary<string, BrepBody> publishedBodiesByFeatureId)
+ {
+ if (!ShouldUseSemanticToolPlacement(boolean, baseBody, toolBody))
+ {
+ return null;
+ }
+
+ var placementResult = FirmamentPlacementResolver.ResolvePlacementTranslation(boolean, publishedBodiesByFeatureId);
+ if (!placementResult.IsSuccess)
+ {
+ return null;
+ }
+
+ return PlaceSemanticToolBody(boolean, toolBody, placementResult.Value);
+ }
+
+ private static BrepBody PlaceSemanticToolBody(FirmamentLoweredBoolean boolean, BrepBody toolBody, Vector3D placementTranslation)
+ {
+ var shouldApplyDefaultToolFrame = string.IsNullOrWhiteSpace(boolean.Placement?.AroundAxis);
+ var localFrameBody = shouldApplyDefaultToolFrame
+ ? ApplyDefaultToolLocalFrame(boolean.Tool, toolBody)
+ : toolBody;
+ return TranslateBody(localFrameBody, placementTranslation);
+ }
+
private static BrepBody TranslateBody(BrepBody body, Vector3D translation)
{
if (translation == Vector3D.Zero) return body;