Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

CIR-RECOVERY-V16 add bottom-entry chamfered-entry support

Yuechen Lif59a852c82a5
diff --git a/Aetheris.Kernel.Firmament.Tests/ChamferedEntryHoleVariantAndExecutorTests.cs b/Aetheris.Kernel.Firmament.Tests/ChamferedEntryHoleVariantAndExecutorTests.cs
index c43fe480..d0c2f601 100644
--- a/Aetheris.Kernel.Firmament.Tests/ChamferedEntryHoleVariantAndExecutorTests.cs
+++ b/Aetheris.Kernel.Firmament.Tests/ChamferedEntryHoleVariantAndExecutorTests.cs
@@ -18,6 +18,17 @@ public sealed class ChamferedEntryHoleVariantAndExecutorTests
Assert.Equal(HoleProfileSegmentKind.Cylindrical, plan.ProfileStack[1].SegmentKind);
Assert.Contains(plan.ExpectedSurfacePatches, p => p.Role == HoleSurfacePatchRole.ChamferedEntryWall);
}
+
+ [Fact]
+ public void ChamferedEntry_BottomEntry_AdmitsPlan()
+ {
+ var eval = new HoleRecoveryPolicy().Evaluate(new FrepMaterializerContext(BuildChamferedBottom()));
+ Assert.Contains("selected-variant:ChamferedEntryHoleVariant", eval.Evidence);
+ var plan = Assert.IsType<HoleRecoveryPlan>(eval.Plan);
+ Assert.Equal(HoleKind.ChamferedEntry, plan.HoleKind);
+ Assert.Equal(HoleEntryFeatureKind.Chamfer, plan.EntryFeature);
+ Assert.Contains(eval.EvaluationsFor(nameof(ChamferedEntryHoleVariant)), d => d.Contains("bottom(-Z)", StringComparison.OrdinalIgnoreCase));
+ }
[Fact]
public void ChamferedEntryVariant_RejectsCountersinkSizedCone()
@@ -54,6 +65,18 @@ public sealed class ChamferedEntryHoleVariantAndExecutorTests
Assert.Contains(result.Diagnostics, d => d.Contains("cylinder subtract invoked", StringComparison.OrdinalIgnoreCase));
Assert.Contains(result.Diagnostics, d => d.Contains("chamfer cone subtract invoked", StringComparison.OrdinalIgnoreCase));
}
+
+ [Fact]
+ public void ChamferedEntry_BottomEntry_ProducesBrepBody()
+ {
+ var plan = Assert.IsType<HoleRecoveryPlan>(new HoleRecoveryPolicy().Evaluate(new FrepMaterializerContext(BuildChamferedBottom())).Plan);
+ var result = HoleRecoveryExecutor.Execute(plan);
+ Assert.Equal(HoleRecoveryExecutionStatus.Succeeded, result.Status);
+ Assert.NotNull(result.Body);
+ Assert.Contains(result.Diagnostics, d => d.Contains("cylinder subtract invoked", StringComparison.OrdinalIgnoreCase));
+ Assert.Contains(result.Diagnostics, d => d.Contains("chamfer cone subtract invoked", StringComparison.OrdinalIgnoreCase));
+ Assert.Contains(result.Diagnostics, d => d.Contains("bottom(-Z)", StringComparison.OrdinalIgnoreCase));
+ }
[Fact]
public void ChamferedEntryStepSmoke_CanonicalChamferedEntry_ExportsStep()
@@ -69,6 +92,47 @@ public sealed class ChamferedEntryHoleVariantAndExecutorTests
Assert.Contains("CYLINDRICAL_SURFACE", step.Value);
Assert.DoesNotContain("BREP_WITH_VOIDS", step.Value);
}
+
+ [Fact]
+ public void ChamferedEntry_BottomEntry_ExportsStep()
+ {
+ var plan = Assert.IsType<HoleRecoveryPlan>(new HoleRecoveryPolicy().Evaluate(new FrepMaterializerContext(BuildChamferedBottom())).Plan);
+ var exec = HoleRecoveryExecutor.Execute(plan);
+ var step = Step242Exporter.ExportBody(exec.Body!);
+ Assert.True(step.IsSuccess);
+ Assert.Contains("ISO-10303-21", step.Value);
+ Assert.Contains("MANIFOLD_SOLID_BREP", step.Value);
+ Assert.Contains("ADVANCED_FACE", step.Value);
+ Assert.Contains("CONICAL_SURFACE", step.Value);
+ Assert.Contains("CYLINDRICAL_SURFACE", step.Value);
+ Assert.DoesNotContain("BREP_WITH_VOIDS", step.Value);
+ }
+
+ [Fact]
+ public void ChamferedEntry_BottomEntry_DoesNotStealCountersink()
+ {
+ var eval = new HoleRecoveryPolicy().Evaluate(new FrepMaterializerContext(BuildCountersinkBottom()));
+ Assert.Contains("selected-variant:CountersinkVariant", eval.Evidence);
+ Assert.Contains(eval.Diagnostics, d => d.Contains("Variant rejected: ChamferedEntryHoleVariant", StringComparison.Ordinal));
+ }
+
+ [Fact]
+ public void Countersink_DoesNotStealBottomChamfer()
+ {
+ var eval = new HoleRecoveryPolicy().Evaluate(new FrepMaterializerContext(BuildChamferedBottom()));
+ Assert.Contains("selected-variant:ChamferedEntryHoleVariant", eval.Evidence);
+ Assert.Contains(eval.Diagnostics, d => d.Contains("Variant rejected: CountersinkVariant", StringComparison.Ordinal));
+ }
+
+ [Fact]
+ public void ChamferedEntry_RejectsInvalidBottomConeOrientation()
+ {
+ var cone = new CirTransformNode(new CirConeNode(2d, 2.8d, 1d), Transform3D.CreateTranslation(new Vector3D(0d, 0d, -4.5d)));
+ var root = new CirSubtractNode(new CirSubtractNode(new CirBoxNode(20d, 20d, 10d), new CirCylinderNode(2d, 20d)), cone);
+ var eval = new HoleRecoveryPolicy().Evaluate(new FrepMaterializerContext(root));
+ Assert.Contains(eval.EvaluationsFor(nameof(ChamferedEntryHoleVariant)), d => d.Contains("radius ordering invalid", StringComparison.OrdinalIgnoreCase));
+ Assert.DoesNotContain("selected-variant:ChamferedEntryHoleVariant", eval.Evidence);
+ }
[Fact]
public void ChamferedEntry_Unsupported_DoesNotFalseSucceed()
@@ -83,4 +147,8 @@ public sealed class ChamferedEntryHoleVariantAndExecutorTests
=> new CirSubtractNode(new CirSubtractNode(new CirBoxNode(20d,20d,10d), new CirCylinderNode(2d,20d)), new CirTransformNode(new CirConeNode(2d, 2.8d, 1d), Transform3D.CreateTranslation(new Vector3D(0d, 0d, 4.5d))));
private static CirNode BuildCountersink()
=> new CirSubtractNode(new CirSubtractNode(new CirBoxNode(20d,20d,10d), new CirCylinderNode(2d,20d)), new CirTransformNode(new CirConeNode(2d, 4d, 4d), Transform3D.CreateTranslation(new Vector3D(0d, 0d, 3d))));
+ private static CirNode BuildChamferedBottom()
+ => new CirSubtractNode(new CirSubtractNode(new CirBoxNode(20d,20d,10d), new CirCylinderNode(2d,20d)), new CirTransformNode(new CirConeNode(2.8d, 2d, 1d), Transform3D.CreateTranslation(new Vector3D(0d, 0d, -4.5d))));
+ private static CirNode BuildCountersinkBottom()
+ => new CirSubtractNode(new CirSubtractNode(new CirBoxNode(20d,20d,10d), new CirCylinderNode(2d,20d)), new CirTransformNode(new CirConeNode(4d, 2d, 4d), Transform3D.CreateTranslation(new Vector3D(0d, 0d, -3d))));
}
diff --git a/Aetheris.Kernel.Firmament.Tests/HoleRecoveryPolicyCoverageMatrixTests.cs b/Aetheris.Kernel.Firmament.Tests/HoleRecoveryPolicyCoverageMatrixTests.cs
index 23e90cb5..75d9ca7c 100644
--- a/Aetheris.Kernel.Firmament.Tests/HoleRecoveryPolicyCoverageMatrixTests.cs
+++ b/Aetheris.Kernel.Firmament.Tests/HoleRecoveryPolicyCoverageMatrixTests.cs
@@ -18,6 +18,7 @@ public sealed class HoleRecoveryPolicyCoverageMatrixTests
{ "BlindHoleBottom", BuildBlindHoleBottom(), nameof(BlindHoleVariant), HoleKind.Blind, HoleDepthKind.Blind, FrepMaterializerCapability.ExactBRep },
{ "Countersink", BuildCountersink(), nameof(CountersinkVariant), HoleKind.Countersink, HoleDepthKind.ThroughWithEntryRelief, FrepMaterializerCapability.ExactBRep },
{ "ChamferedEntry", BuildChamferedEntry(), nameof(ChamferedEntryHoleVariant), HoleKind.ChamferedEntry, HoleDepthKind.ThroughWithEntryRelief, FrepMaterializerCapability.ExactBRep },
+ { "ChamferedEntryBottom", BuildChamferedEntryBottom(), nameof(ChamferedEntryHoleVariant), HoleKind.ChamferedEntry, HoleDepthKind.ThroughWithEntryRelief, FrepMaterializerCapability.ExactBRep },
{ "SteppedHole", BuildSteppedHole(), nameof(SteppedHoleVariant), HoleKind.Stepped, HoleDepthKind.ThroughWithEntryRelief, FrepMaterializerCapability.ExactBRep }
};
@@ -152,5 +153,6 @@ public sealed class HoleRecoveryPolicyCoverageMatrixTests
private static CirNode BuildCounterbore() => new CirSubtractNode(new CirSubtractNode(new CirBoxNode(20, 20, 10), new CirCylinderNode(2, 20)), new CirTransformNode(new CirCylinderNode(4, 4), Transform3D.CreateTranslation(new Vector3D(0, 0, -3))));
private static CirNode BuildCountersink() => new CirSubtractNode(new CirSubtractNode(new CirBoxNode(20, 20, 10), new CirCylinderNode(2, 20)), new CirTransformNode(new CirConeNode(2, 4, 4), Transform3D.CreateTranslation(new Vector3D(0, 0, 3))));
private static CirNode BuildChamferedEntry() => new CirSubtractNode(new CirSubtractNode(new CirBoxNode(20, 20, 10), new CirCylinderNode(2, 20)), new CirTransformNode(new CirConeNode(2, 2.8, 1), Transform3D.CreateTranslation(new Vector3D(0, 0, 4.5))));
+ private static CirNode BuildChamferedEntryBottom() => new CirSubtractNode(new CirSubtractNode(new CirBoxNode(20, 20, 10), new CirCylinderNode(2, 20)), new CirTransformNode(new CirConeNode(2.8, 2, 1), Transform3D.CreateTranslation(new Vector3D(0, 0, -4.5))));
private static CirNode BuildSteppedHole() => new CirSubtractNode(new CirSubtractNode(new CirSubtractNode(new CirBoxNode(20,20,10), new CirCylinderNode(2,20)), new CirTransformNode(new CirCylinderNode(3,6), Transform3D.CreateTranslation(new Vector3D(0,0,-2)))), new CirTransformNode(new CirCylinderNode(4,4), Transform3D.CreateTranslation(new Vector3D(0,0,-3))));
}
diff --git a/Aetheris.Kernel.Firmament/Materializer/HoleRecoveryExecutor.cs b/Aetheris.Kernel.Firmament/Materializer/HoleRecoveryExecutor.cs
index 53c94252..029cfaef 100644
--- a/Aetheris.Kernel.Firmament/Materializer/HoleRecoveryExecutor.cs
+++ b/Aetheris.Kernel.Firmament/Materializer/HoleRecoveryExecutor.cs
@@ -427,8 +427,11 @@ public static class HoleRecoveryExecutor
}
var entryTopZ = plan.HostTranslation.Z + (plan.HostSizeZ * 0.5d);
- var coneCenterZ = entryTopZ - (coneHeight * 0.5d);
+ var entryBottomZ = plan.HostTranslation.Z - (plan.HostSizeZ * 0.5d);
+ var touchesTop = Math.Abs((plan.ToolTranslation.Z + (coneHeight * 0.5d)) - entryTopZ) <= Aetheris.Kernel.Core.Numerics.ToleranceContext.Default.Linear;
+ var coneCenterZ = touchesTop ? entryTopZ - (coneHeight * 0.5d) : entryBottomZ + (coneHeight * 0.5d);
var coneBody = TranslateBody(coneResult.Value, new Vector3D(plan.ToolTranslation.X, plan.ToolTranslation.Y, coneCenterZ));
+ diagnostics.Add($"entry side resolved for {coneLabel}: {(touchesTop ? "top(+Z)" : "bottom(-Z)") }.");
diagnostics.Add($"{coneLabel} subtract invoked.");
var secondSub = BrepBoolean.Subtract(firstSub.Value, coneBody);
if (!secondSub.IsSuccess || secondSub.Value is null)
diff --git a/Aetheris.Kernel.Firmament/Materializer/HoleRecoveryPolicy.cs b/Aetheris.Kernel.Firmament/Materializer/HoleRecoveryPolicy.cs
index 423b3f98..1d8828ed 100644
--- a/Aetheris.Kernel.Firmament/Materializer/HoleRecoveryPolicy.cs
+++ b/Aetheris.Kernel.Firmament/Materializer/HoleRecoveryPolicy.cs
@@ -224,17 +224,25 @@ internal sealed class ChamferedEntryHoleVariant : IHoleRecoveryVariant
var coneMinZ = coneTranslation.Z - (cone.Height * 0.5d);
var coneMaxZ = coneTranslation.Z + (cone.Height * 0.5d);
var touchesTop = Math.Abs(coneMaxZ - boxMaxZ) <= tol;
- if (!touchesTop)
+ var touchesBottom = Math.Abs(coneMinZ - boxMinZ) <= tol;
+ if (!touchesTop && !touchesBottom)
+ {
+ diagnostics.Add("cone does not touch entry face.");
+ return new(Name, false, 0d, null, ["chamfered-entry", "rectangular-box-host"], ["UnsupportedConeMissingEntryFace"], diagnostics);
+ }
+
+ if (touchesTop && touchesBottom)
{
- diagnostics.Add("entry side unsupported: bounded v15 supports top-entry chamfer only.");
- return new(Name, false, 0d, null, ["chamfered-entry", "rectangular-box-host"], ["UnsupportedEntrySide"], diagnostics);
+ diagnostics.Add("cone through full depth unsupported.");
+ return new(Name, false, 0d, null, ["chamfered-entry", "rectangular-box-host"], ["UnsupportedConeThroughFullDepth"], diagnostics);
}
- var entryRadius = cone.TopRadius;
- var transitionRadius = cone.BottomRadius;
+ var entryFromTop = touchesTop;
+ var entryRadius = entryFromTop ? cone.TopRadius : cone.BottomRadius;
+ var transitionRadius = entryFromTop ? cone.BottomRadius : cone.TopRadius;
if (entryRadius <= transitionRadius + tol)
{
- diagnostics.Add("cone radius ordering invalid for entry side.");
+ diagnostics.Add($"cone radius ordering invalid for {(entryFromTop ? "top(+Z)" : "bottom(-Z)")} entry side.");
return new(Name, false, 0d, null, ["chamfered-entry", "rectangular-box-host"], ["UnsupportedConeRadiusOrderingInvalid"], diagnostics);
}
@@ -267,8 +275,8 @@ internal sealed class ChamferedEntryHoleVariant : IHoleRecoveryVariant
var depthKind = host.ThroughLength >= host.BoxDepth - tol ? HoleDepthKind.ThroughWithEntryRelief : HoleDepthKind.BlindWithEntryRelief;
var exitKind = depthKind == HoleDepthKind.ThroughWithEntryRelief ? HoleExitFeatureKind.Plain : HoleExitFeatureKind.ClosedBottom;
- diagnostics.Add("entry side detected: top(+Z).");
- diagnostics.Add("cone radius/order validated.");
+ diagnostics.Add($"entry side detected: {(entryFromTop ? "top(+Z)" : "bottom(-Z)")}.");
+ diagnostics.Add($"cone radius/order validated for {(entryFromTop ? "top(+Z)" : "bottom(-Z)")} entry.");
diagnostics.Add("transition radius compatible.");
diagnostics.Add("Chamfered-entry plan produced.");
var plan = new HoleRecoveryPlan(HoleHostKind.RectangularBox, HoleAxisKind.Z, HoleKind.ChamferedEntry, depthKind, HoleEntryFeatureKind.Chamfer, exitKind,
diff --git a/docs/cir-recovery-v15-chamfered-entry-hole-variant.md b/docs/cir-recovery-v15-chamfered-entry-hole-variant.md
index 1ac6fc86..79e79099 100644
--- a/docs/cir-recovery-v15-chamfered-entry-hole-variant.md
+++ b/docs/cir-recovery-v15-chamfered-entry-hole-variant.md
@@ -1,4 +1,4 @@
-# CIR-RECOVERY-V15 — bounded ChamferedEntryHoleVariant recognition + execution + STEP smoke
+# CIR-RECOVERY-V15 — bounded ChamferedEntryHoleVariant recognition + execution + STEP smoke (top-entry baseline; extended by V16 for bottom-entry)
## Supported bounded CIR shape
diff --git a/docs/cir-recovery-v16-bottom-entry-chamfered-hole.md b/docs/cir-recovery-v16-bottom-entry-chamfered-hole.md
new file mode 100644
index 00000000..4bb6e8f8
--- /dev/null
+++ b/docs/cir-recovery-v16-bottom-entry-chamfered-hole.md
@@ -0,0 +1,86 @@
+# CIR-RECOVERY-V16 — bottom-entry support for bounded `ChamferedEntryHoleVariant`
+
+## Scope
+
+V16 extends the existing bounded chamfered-entry lane from V15 to include mirrored **bottom-entry (-Z)** conical entry relief, while preserving all existing policy architecture and exporter behavior.
+
+Included:
+- `HoleRecoveryPolicy -> ChamferedEntryHoleVariant` now recognizes top and bottom entry chamfer cones for canonical bounded nested subtract shape.
+- `HoleRecoveryExecutor` chamfer/countersink-like execution now resolves cone placement for top or bottom entry from plan/host z extents.
+- Focused tests for plan admission, execution, STEP smoke, anti-steal behavior, and invalid bottom-cone orientation rejection.
+
+Not included:
+- new policy families
+- generic chamfer recovery
+- STEP exporter changes
+- topology naming expansion (SEM-A0 preserved)
+
+## Supported CIR shape (bounded)
+
+```text
+Subtract(
+ Subtract(Box, HoleCylinder),
+ ChamferCone
+)
+```
+
+Where:
+- `Box` is rectangular host.
+- `HoleCylinder` is coaxial Z-axis cylindrical base hole.
+- `ChamferCone` is `CirConeNode`.
+- direct or identity/pure-translation wrappers are allowed.
+- no rotation/non-translation transforms.
+
+## Entry-side and cone radius convention
+
+Entry-side detection:
+- top-entry if `coneMaxZ == boxMaxZ` within tolerance
+- bottom-entry if `coneMinZ == boxMinZ` within tolerance
+- touching neither or both entry faces is rejected.
+
+Radius interpretation is entry-relative:
+- top-entry: `entryRadius = cone.TopRadius`, `transitionRadius = cone.BottomRadius`
+- bottom-entry: `entryRadius = cone.BottomRadius`, `transitionRadius = cone.TopRadius`
+
+Admissibility requires:
+- strict decreasing radius from entry to transition,
+- transition radius matches cylinder radius within tolerance,
+- chamfer thresholds (depth/radius-delta) pass,
+- strict host XY clearance at max radius.
+
+## Plan / execution semantics
+
+`ChamferedEntryHoleVariant` emits `HoleRecoveryPlan` with:
+- `HoleKind.ChamferedEntry`
+- `HoleEntryFeatureKind.Chamfer`
+- conical segment then cylindrical segment profile stack.
+
+`HoleRecoveryExecutor` uses existing bounded route:
+1. build host box
+2. subtract through cylinder
+3. build cone tool
+4. resolve cone center from detected entry side (top or bottom)
+5. subtract cone
+
+Result remains manifold `BrepBody` route suitable for STEP242 export.
+
+## Countersink/chamfer anti-steal behavior
+
+Preserved for both top and bottom entry:
+- countersink rejects chamfer-sized cones (`RejectedChamferSizedEntryRelief`)
+- chamfer rejects countersink-like cones (`RejectedCountersinkLikeCone`)
+
+## STEP smoke expectations
+
+Bottom-entry chamfer execution exports through existing `Step242Exporter.ExportBody(...)` with expected markers:
+- `ISO-10303-21`
+- `MANIFOLD_SOLID_BREP`
+- `ADVANCED_FACE`
+- `CONICAL_SURFACE`
+- `CYLINDRICAL_SURFACE`
+
+And no `BREP_WITH_VOIDS`.
+
+## SEM-A0 status
+
+No generated topology naming/provenance expansion introduced. V16 is bounded to entry-side hardening inside existing hole-family variant architecture.