Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Add bounded mixed blind-pocket metadata and gating

Yuechen Li93b3162aaf87
diff --git a/Aetheris.Kernel.Core.Tests/Brep/Boolean/BrepBooleanTests.cs b/Aetheris.Kernel.Core.Tests/Brep/Boolean/BrepBooleanTests.cs
index e7eb92bc..37fea505 100644
--- a/Aetheris.Kernel.Core.Tests/Brep/Boolean/BrepBooleanTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Brep/Boolean/BrepBooleanTests.cs
@@ -1890,7 +1890,7 @@ public sealed class BrepBooleanTests
Assert.False(result.IsSuccess);
var diagnostic = Assert.Single(result.Diagnostics);
- Assert.Contains("blind-pocket continuation", diagnostic.Message, StringComparison.Ordinal);
+ Assert.Contains("bounded orthogonal pocket family", diagnostic.Message, StringComparison.Ordinal);
}
[Fact]
diff --git a/Aetheris.Kernel.Core/Brep/Boolean/BrepBoolean.cs b/Aetheris.Kernel.Core/Brep/Boolean/BrepBoolean.cs
index cedc887e..4e0547a3 100644
--- a/Aetheris.Kernel.Core/Brep/Boolean/BrepBoolean.cs
+++ b/Aetheris.Kernel.Core/Brep/Boolean/BrepBoolean.cs
@@ -770,6 +770,40 @@ public static class BrepBoolean
&& intersections.Analysis.RightPrismaticTool is { } prismaticTool
&& TryClassifyBoundedPrismaticThroughCutSubtract(leftCompositionForPrismatic, prismaticTool, tolerance, out _))
{
+ var isThroughCut = prismaticTool.Bounds.MinZ <= (leftCompositionForPrismatic.RootDescriptor.Box.MinZ + tolerance.Linear)
+ && prismaticTool.Bounds.MaxZ >= (leftCompositionForPrismatic.RootDescriptor.Box.MaxZ - tolerance.Linear);
+ if (!isThroughCut)
+ {
+ if (!TryClassifyBoundedOrthogonalPocketSubtract(
+ leftCompositionForPrismatic.RootDescriptor.Box,
+ prismaticTool.Bounds,
+ tolerance,
+ out var mixedPocketCells,
+ out var mixedBlindUnsupported))
+ {
+ return new BooleanClassificationData(
+ intersections,
+ IsComputed: true,
+ FragmentCount: 0,
+ SingleBoxResult: null,
+ SafeCompositionResult: null,
+ UnsupportedReason: mixedBlindUnsupported);
+ }
+
+ return new BooleanClassificationData(
+ intersections,
+ IsComputed: true,
+ FragmentCount: 1,
+ SingleBoxResult: null,
+ SafeCompositionResult: leftCompositionForPrismatic with
+ {
+ OccupiedCells = mixedPocketCells,
+ BlindPrismaticPocket = new SupportedBlindPrismaticPocket(prismaticTool.Bounds, prismaticTool.Footprint),
+ },
+ UnsupportedReason: null,
+ OrthogonalUnionCells: mixedPocketCells);
+ }
+
var throughVoids = BuildThroughVoidSetForPrismaticContinuation(leftCompositionForPrismatic, prismaticTool);
return new BooleanClassificationData(
intersections,
@@ -1833,6 +1867,11 @@ public static class BrepBoolean
unsupportedReason = "Boolean Subtract: bounded prismatic subtract continuation does not yet support prior prismatic/open-slot through-void history.";
return false;
}
+ if (leftComposition.BlindPrismaticPocket is not null)
+ {
+ unsupportedReason = "Boolean Subtract: bounded mixed blind-pocket continuation supports exactly one blind prismatic pocket.";
+ return false;
+ }
var root = leftComposition.RootDescriptor.Box;
var isThroughCut = prismTool.Bounds.MinZ <= (root.MinZ + tolerance.Linear)
@@ -1841,8 +1880,19 @@ public static class BrepBoolean
var hasPriorSubtractHistory = leftComposition.Holes.Count > 0 || (leftComposition.OpenSlots?.Count ?? 0) > 0;
if (hasPriorSubtractHistory && !isThroughCut)
{
- unsupportedReason = "Boolean Subtract: bounded prismatic blind-pocket continuation on safe compositions is deferred pending a bounded analytic-plus-orthogonal reconstruction path.";
- return false;
+ if (leftComposition.RootDescriptor.Kind != SafeBooleanRootKind.Box)
+ {
+ unsupportedReason = "Boolean Subtract: bounded mixed blind-pocket continuation currently supports only recognized safe box roots.";
+ return false;
+ }
+
+ if (!SupportsStrictNonOverlapMixedBlindPocketContinuation(leftComposition, prismTool, tolerance, out unsupportedReason))
+ {
+ return false;
+ }
+
+ unsupportedReason = string.Empty;
+ return true;
}
if (hasPriorSubtractHistory)
@@ -1993,6 +2043,56 @@ public static class BrepBoolean
return true;
}
+ private static bool SupportsStrictNonOverlapMixedBlindPocketContinuation(
+ SafeBooleanComposition composition,
+ SupportedPrismaticSubtractTool prismaticTool,
+ ToleranceContext tolerance,
+ out string unsupportedReason)
+ {
+ unsupportedReason = "Boolean Subtract: bounded mixed blind-pocket continuation requires supported analytic cylinder/cone history.";
+ if (composition.OpenSlots is { Count: > 0 })
+ {
+ return false;
+ }
+
+ foreach (var hole in composition.Holes)
+ {
+ if (hole.Surface.Kind is not (AnalyticSurfaceKind.Cylinder or AnalyticSurfaceKind.Cone))
+ {
+ return false;
+ }
+
+ if (hole.SpanKind is not (SupportedBooleanHoleSpanKind.Through or SupportedBooleanHoleSpanKind.BlindFromTop or SupportedBooleanHoleSpanKind.BlindFromBottom))
+ {
+ return false;
+ }
+
+ if (!PositiveOverlap(hole.StartZ, hole.EndZ, prismaticTool.Bounds.MinZ, prismaticTool.Bounds.MaxZ, tolerance)
+ && !PositiveOverlap(hole.EndZ, hole.StartZ, prismaticTool.Bounds.MinZ, prismaticTool.Bounds.MaxZ, tolerance))
+ {
+ continue;
+ }
+
+ if (!BrepBooleanPrismaticFootprintContainment.TryComputeContainmentMargin((hole.CenterX, hole.CenterY), prismaticTool.Footprint, tolerance, out var edgeDistance))
+ {
+ unsupportedReason = "Boolean Subtract: bounded mixed blind-pocket continuation rejected due to ambiguous analytic-pocket clearance classification.";
+ return false;
+ }
+
+ var signedClearance = edgeDistance - hole.MaxBoundaryRadius;
+ if (signedClearance <= tolerance.Linear)
+ {
+ unsupportedReason = signedClearance < -tolerance.Linear
+ ? "Boolean Subtract: bounded mixed blind-pocket continuation requires strict non-overlap between analytic holes and pocket volume."
+ : "Boolean Subtract: bounded mixed blind-pocket continuation rejected: tangent/edge-grazing analytic-pocket boundary contact.";
+ return false;
+ }
+ }
+
+ unsupportedReason = string.Empty;
+ return true;
+ }
+
private static KernelResult<BrepBody> ValidateOutput(BrepBody body, IReadOnlyList<KernelDiagnostic> diagnostics)
{
var validation = BrepBindingValidator.Validate(body, requireAllEdgeAndFaceBindings: true);
diff --git a/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanSafeComposition.cs b/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanSafeComposition.cs
index ca7c9b49..61d243f1 100644
--- a/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanSafeComposition.cs
+++ b/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanSafeComposition.cs
@@ -10,7 +10,8 @@ public sealed record SafeBooleanComposition(
SafeBooleanRootDescriptor? Root = null,
IReadOnlyList<AxisAlignedBoxExtents>? OccupiedCells = null,
IReadOnlyList<SupportedCylinderOpenSlot>? OpenSlots = null,
- SupportedThroughVoidSet? ThroughVoids = null)
+ SupportedThroughVoidSet? ThroughVoids = null,
+ SupportedBlindPrismaticPocket? BlindPrismaticPocket = null)
{
public SafeBooleanRootDescriptor RootDescriptor => Root ?? SafeBooleanRootDescriptor.FromBox(OuterBox);
@@ -36,7 +37,8 @@ public sealed record SafeBooleanComposition(
cell.MinZ + translation.Z,
cell.MaxZ + translation.Z)).ToArray(),
OpenSlots?.Select(slot => slot.Translate(translation)).ToArray(),
- ThroughVoids?.Translate(translation));
+ ThroughVoids?.Translate(translation),
+ BlindPrismaticPocket?.Translate(translation));
}
}
@@ -66,6 +68,22 @@ public readonly record struct SupportedPrismaticThroughVoid(
Footprint.Select(point => (point.X + translation.X, point.Y + translation.Y)).ToArray());
}
+public readonly record struct SupportedBlindPrismaticPocket(
+ AxisAlignedBoxExtents Bounds,
+ IReadOnlyList<(double X, double Y)> Footprint)
+{
+ public SupportedBlindPrismaticPocket Translate(Vector3D translation)
+ => new(
+ new AxisAlignedBoxExtents(
+ Bounds.MinX + translation.X,
+ Bounds.MaxX + translation.X,
+ Bounds.MinY + translation.Y,
+ Bounds.MaxY + translation.Y,
+ Bounds.MinZ + translation.Z,
+ Bounds.MaxZ + translation.Z),
+ Footprint.Select(point => (point.X + translation.X, point.Y + translation.Y)).ToArray());
+}
+
public enum SafeBooleanRootKind
{
Box,