Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

fillet: classify chained cylindrical-termination context and reject explicitly

Yuechen Lid6659aa10426
diff --git a/Aetheris.Kernel.Core.Tests/Brep/EdgeFinishing/BrepBoundedFilletTests.cs b/Aetheris.Kernel.Core.Tests/Brep/EdgeFinishing/BrepBoundedFilletTests.cs
index 6903b0e9..be50e93f 100644
--- a/Aetheris.Kernel.Core.Tests/Brep/EdgeFinishing/BrepBoundedFilletTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Brep/EdgeFinishing/BrepBoundedFilletTests.cs
@@ -46,7 +46,7 @@ public sealed class BrepBoundedFilletTests
var result = BrepBoundedFillet.FilletTrustedPolyhedralSingleInternalConcaveEdge(source, preflight.Value, 1.5d);
Assert.False(result.IsSuccess);
- Assert.Contains(result.Diagnostics, d => d.Message.Contains("No bounded single-edge/chained fillet candidate", StringComparison.Ordinal));
+ Assert.Contains(result.Diagnostics, d => d.Message.Contains("No bounded single-edge/chained fillet candidate was admissible", StringComparison.Ordinal));
}
[Fact]
@@ -65,6 +65,28 @@ public sealed class BrepBoundedFilletTests
Assert.True(result.Value.Bindings.FaceBindings.Count(binding => result.Value.Geometry.GetSurface(binding.SurfaceGeometryId).Kind == SurfaceGeometryKind.Cylinder) >= 2);
}
+ [Fact]
+ public void FilletTrustedPolyhedralSingleInternalConcaveEdge_Rejects_ChainedCylindricalTerminationContext_Explicitly()
+ {
+ var source = CreatePlanarSourceWithNotchComposition();
+ var preflight = BrepBoundedManufacturingFilletPreflight.ResolveInternalConcaveVerticalEdges(
+ source.SafeBooleanComposition!,
+ [BrepBoundedManufacturingFilletEdge.InnerXMaxYMin, BrepBoundedManufacturingFilletEdge.InnerXMaxYMax],
+ radius: 1d);
+ Assert.True(preflight.IsSuccess);
+
+ var firstPass = BrepBoundedFillet.FilletTrustedPolyhedralSingleInternalConcaveEdge(source, preflight.Value, 1d);
+ Assert.True(firstPass.IsSuccess, string.Join(Environment.NewLine, firstPass.Diagnostics.Select(d => d.Message)));
+
+ var secondPass = BrepBoundedFillet.FilletTrustedPolyhedralSingleInternalConcaveEdge(firstPass.Value, preflight.Value, 1d);
+
+ Assert.False(secondPass.IsSuccess);
+ Assert.Contains(
+ secondPass.Diagnostics,
+ d => d.Message.Contains("chained_same_radius_fillet_with_cylindrical_termination", StringComparison.Ordinal)
+ && d.Message.Contains("supported=False", StringComparison.Ordinal));
+ }
+
private static BrepBody CreatePlanarSourceWithLRootComposition()
{
var box = BrepPrimitives.CreateBox(30d, 20d, 10d);
diff --git a/Aetheris.Kernel.Core/Brep/EdgeFinishing/BrepBoundedFillet.cs b/Aetheris.Kernel.Core/Brep/EdgeFinishing/BrepBoundedFillet.cs
index 46cf3fba..f8afa870 100644
--- a/Aetheris.Kernel.Core/Brep/EdgeFinishing/BrepBoundedFillet.cs
+++ b/Aetheris.Kernel.Core/Brep/EdgeFinishing/BrepBoundedFillet.cs
@@ -17,6 +17,7 @@ public static class BrepBoundedFillet
{
private const string SingleEdgeCylindricalFilletCandidate = "single_edge_cylindrical_fillet";
private const string ChainedSameRadiusCylindricalFilletCandidate = "chained_same_radius_cylindrical_fillets";
+ private const string ChainedSameRadiusCylindricalTerminationCandidate = "chained_same_radius_fillet_with_cylindrical_termination";
private const string RejectCandidate = "reject";
public static KernelResult<BrepBody> FilletTrustedPolyhedralSingleInternalConcaveEdge(
@@ -36,7 +37,7 @@ public static class BrepBoundedFillet
if (!judgment.IsSuccess || !judgment.Selection.HasValue || judgment.Selection.Value.Candidate.Name == RejectCandidate)
{
var reason = judgment.Rejections.Count == 0
- ? "No bounded single-edge/chained fillet candidate was admissible."
+ ? BuildRejectReason(context)
: string.Join(" ", judgment.Rejections.Select(rejection => $"{rejection.CandidateName}: {rejection.Reason}."));
return KernelResult<BrepBody>.Failure([Failure($"Bounded fillet edge resolution rejected: {reason}", "firmament.fillet-bounded")]);
}
@@ -45,6 +46,9 @@ public static class BrepBoundedFillet
{
SingleEdgeCylindricalFilletCandidate => BuildConcaveFilletBody(sourceBody, context),
ChainedSameRadiusCylindricalFilletCandidate => BuildConcaveFilletBody(sourceBody, context),
+ ChainedSameRadiusCylindricalTerminationCandidate => KernelResult<BrepBody>.Failure([Failure(
+ "Bounded chained same-radius fillet with cylindrical-context termination is recognized but not yet supported; the current local extrusion rewrite cannot preserve neighboring cylindrical context while terminating the chain.",
+ "firmament.fillet-bounded")]),
_ => KernelResult<BrepBody>.Failure([Failure($"Bounded fillet selected unsupported candidate '{judgment.Selection.Value.Candidate.Name}'.", "firmament.fillet-bounded")])
};
}
@@ -75,14 +79,37 @@ public static class BrepBoundedFillet
Score: context => context.HasLocalChainedInteraction ? 150d : 0d,
RejectionReason: context => $"requires trusted two-edge same-radius chained internal concave planar-planar bounded-radius context (trusted={context.IsTrustedSource}, count={context.SelectionCount}, planar={context.IsPlanarPlanar}, concave={context.IsInternalConcave}, bounded={context.IsBoundedRadius}, interacting={context.HasLocalChainedInteraction})",
TieBreakerPriority: 1),
+ new JudgmentCandidate<BrepBoundedFilletContext>(
+ Name: ChainedSameRadiusCylindricalTerminationCandidate,
+ IsAdmissible: When.All<BrepBoundedFilletContext>(
+ context => context.IsTrustedSource,
+ context => context.SelectionCount == 2,
+ context => context.IsInternalConcave,
+ context => context.IsBoundedRadius,
+ context => context.HasLocalChainedInteraction,
+ context => context.HasCylindricalSourceFaces,
+ context => context.IsCylindricalTerminationSupported),
+ Score: context => context.HasCylindricalSourceFaces ? 175d : 0d,
+ RejectionReason: context => $"requires supported chained same-radius cylindrical-context termination context (trusted={context.IsTrustedSource}, count={context.SelectionCount}, concave={context.IsInternalConcave}, bounded={context.IsBoundedRadius}, interacting={context.HasLocalChainedInteraction}, hasCylindricalSourceFaces={context.HasCylindricalSourceFaces}, supported={context.IsCylindricalTerminationSupported})",
+ TieBreakerPriority: 2),
new JudgmentCandidate<BrepBoundedFilletContext>(
Name: RejectCandidate,
IsAdmissible: _ => true,
Score: _ => -1d,
RejectionReason: _ => "bounded single-edge cylindrical fillet candidate is not admissible",
- TieBreakerPriority: 2)
+ TieBreakerPriority: 3)
];
+ private static string BuildRejectReason(BrepBoundedFilletContext context)
+ {
+ if (context.SelectionCount == 2 && context.HasLocalChainedInteraction && context.HasCylindricalSourceFaces)
+ {
+ return "chained_same_radius_fillet_with_cylindrical_termination: requires supported chained same-radius cylindrical-context termination context (supported=False).";
+ }
+
+ return "No bounded single-edge/chained fillet candidate was admissible.";
+ }
+
private static KernelResult<BrepBody> BuildConcaveFilletBody(BrepBody sourceBody, BrepBoundedFilletContext context)
{
if (!TryBuildOrthogonalFootprintLoop(context.OccupiedCells, out var loop, out var loopFailure))
@@ -99,14 +126,20 @@ public static class BrepBoundedFillet
"firmament.fillet-bounded")]);
}
- return BuildExtrudedBodyWithArcs(filletedLoop, context.Selection.MinZ, context.Selection.MaxZ, context.Radius);
+ return BuildExtrudedBodyWithArcs(
+ filletedLoop,
+ context.Selection.MinZ,
+ context.Selection.MaxZ,
+ context.Radius,
+ sourceBody.SafeBooleanComposition);
}
private static KernelResult<BrepBody> BuildExtrudedBodyWithArcs(
IReadOnlyList<LoopSegment2D> segments,
double minZ,
double maxZ,
- double radius)
+ double radius,
+ SafeBooleanComposition? safeBooleanComposition)
{
var height = maxZ - minZ;
if (height <= 0d)
@@ -244,7 +277,7 @@ public static class BrepBoundedFillet
geometry.AddSurface(new SurfaceGeometryId(surfaceId), SurfaceGeometry.FromPlane(new PlaneSurface(new Point3D(0d, 0d, maxZ), zAxis, xAxis)));
bindings.AddFaceBinding(new FaceGeometryBinding(topFace, new SurfaceGeometryId(surfaceId)));
- var body = new BrepBody(builder.Model, geometry, bindings);
+ var body = new BrepBody(builder.Model, geometry, bindings, vertexPoints: null, safeBooleanComposition: safeBooleanComposition);
var validation = BrepBindingValidator.Validate(body, requireAllEdgeAndFaceBindings: true);
return validation.IsSuccess
? KernelResult<BrepBody>.Success(body, validation.Diagnostics)
@@ -626,6 +659,8 @@ internal readonly record struct BrepBoundedFilletContext(
int SelectionCount,
bool HasLocalChainedInteraction,
bool IsPlanarPlanar,
+ bool HasCylindricalSourceFaces,
+ bool IsCylindricalTerminationSupported,
bool IsInternalConcave,
bool IsBoundedRadius,
BoundedManufacturingFilletSelection Selection,
@@ -649,12 +684,15 @@ internal readonly record struct BrepBoundedFilletContext(
}
var planar = sourceBody.Bindings.FaceBindings.All(binding => sourceBody.Geometry.GetSurface(binding.SurfaceGeometryId).Kind == SurfaceGeometryKind.Plane);
+ var hasCylindricalFaces = sourceBody.Bindings.FaceBindings.Any(binding => sourceBody.Geometry.GetSurface(binding.SurfaceGeometryId).Kind == SurfaceGeometryKind.Cylinder);
var bounded = radius < selection.MaxAllowedRadius;
return KernelResult<BrepBoundedFilletContext>.Success(new BrepBoundedFilletContext(
IsTrustedSource: true,
SelectionCount: selection.Corners.Count,
HasLocalChainedInteraction: selection.HasLocalInteraction,
IsPlanarPlanar: planar,
+ HasCylindricalSourceFaces: hasCylindricalFaces,
+ IsCylindricalTerminationSupported: false,
IsInternalConcave: true,
IsBoundedRadius: bounded,
Selection: selection,
diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentPrimitiveExecutionTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentPrimitiveExecutionTests.cs
index ace8aed0..214096eb 100644
--- a/Aetheris.Kernel.Firmament.Tests/FirmamentPrimitiveExecutionTests.cs
+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentPrimitiveExecutionTests.cs
@@ -513,6 +513,18 @@ public sealed class FirmamentPrimitiveExecutionTests
&& diagnostic.Message.Contains("one- or two-item string array", StringComparison.Ordinal));
}
+ [Fact]
+ public void Compile_Rejects_BoundedFillet_ChainedCylindricalTermination_Attempt()
+ {
+ var result = CompileFixture("testdata/firmament/fixtures/m5b-invalid-fillet-chained-cylindrical-termination.firmament");
+
+ Assert.False(result.Compilation.IsSuccess);
+ Assert.Contains(result.Compilation.Diagnostics, diagnostic =>
+ diagnostic.Source == "firmament.fillet-bounded"
+ && diagnostic.Message.Contains("chained_same_radius_fillet_with_cylindrical_termination", StringComparison.Ordinal)
+ && diagnostic.Message.Contains("supported=False", StringComparison.Ordinal));
+ }
+
[Fact]
public void Compile_Mixed_Document_With_Unsupported_Boolean_Fails_Before_Publishing_Success_Artifact()
{
diff --git a/Aetheris.Kernel.Firmament/Execution/FirmamentPrimitiveExecutor.cs b/Aetheris.Kernel.Firmament/Execution/FirmamentPrimitiveExecutor.cs
index 28867e6e..2e87fd93 100644
--- a/Aetheris.Kernel.Firmament/Execution/FirmamentPrimitiveExecutor.cs
+++ b/Aetheris.Kernel.Firmament/Execution/FirmamentPrimitiveExecutor.cs
@@ -832,6 +832,27 @@ internal static class FirmamentPrimitiveExecutor
|| sourceState is not (FirmamentSafeSubtractFeatureGraphState.BoundedOrthogonalAdditiveSafeRoot
or FirmamentSafeSubtractFeatureGraphState.BoundedOrthogonalAdditiveOutsideSafeRoot
or FirmamentSafeSubtractFeatureGraphState.SafeSubtractComposition))
+ {
+ if (baseBody.SafeBooleanComposition is not null)
+ {
+ sourceState = FirmamentSafeSubtractFeatureGraphState.SafeSubtractComposition;
+ }
+ else
+ {
+ return KernelResult<BrepBody>.Failure(
+ [
+ new KernelDiagnostic(
+ KernelDiagnosticCode.ValidationFailed,
+ KernelDiagnosticSeverity.Error,
+ $"Bounded M5b fillet requires a recognized orthogonal additive or safe subtract root input; '{boolean.PrimaryReferenceFeatureId}' is not eligible.",
+ Source: "firmament.fillet-bounded")
+ ]);
+ }
+ }
+
+ if (sourceState is not (FirmamentSafeSubtractFeatureGraphState.BoundedOrthogonalAdditiveSafeRoot
+ or FirmamentSafeSubtractFeatureGraphState.BoundedOrthogonalAdditiveOutsideSafeRoot
+ or FirmamentSafeSubtractFeatureGraphState.SafeSubtractComposition))
{
return KernelResult<BrepBody>.Failure(
[
diff --git a/testdata/firmament/fixtures/m5b-invalid-fillet-chained-cylindrical-termination.firmament b/testdata/firmament/fixtures/m5b-invalid-fillet-chained-cylindrical-termination.firmament
new file mode 100644
index 00000000..cdcc505d
--- /dev/null
+++ b/testdata/firmament/fixtures/m5b-invalid-fillet-chained-cylindrical-termination.firmament
@@ -0,0 +1,63 @@
+firmament:
+ version: 1
+
+model:
+ name: m5b_invalid_fillet_chained_cylindrical_termination
+ units: mm
+
+ops[5]:
+ -
+ op: box
+ id: base
+ size[3]:
+ 12
+ 4
+ 10
+ -
+ op: add
+ id: mid
+ to: base
+ with:
+ op: box
+ size[3]:
+ 6
+ 2
+ 10
+ place:
+ on: origin
+ offset[3]:
+ 0
+ 2
+ 0
+ -
+ op: add
+ id: croot
+ to: mid
+ with:
+ op: box
+ size[3]:
+ 12
+ 2
+ 10
+ place:
+ on: origin
+ offset[3]:
+ 0
+ 4
+ 0
+ -
+ op: fillet
+ id: chained_inner_fillet
+ from: croot
+ edges[2]:
+ inner_x_min_y_min
+ inner_x_min_y_max
+ radius: 0.4
+ -
+ op: fillet
+ id: chained_termination_attempt
+ from: chained_inner_fillet
+ edges[2]:
+ inner_x_min_y_min
+ inner_x_min_y_max
+ radius: 0.4