Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Support spherical two-coedge bi-arc trim classification

Yuechen Lie1e421dea2bf
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242ConicalSurfaceRegressionTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242ConicalSurfaceRegressionTests.cs
index c90d6f01..a29c00e3 100644
--- a/Aetheris.Kernel.Core.Tests/Step242/Step242ConicalSurfaceRegressionTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242ConicalSurfaceRegressionTests.cs
@@ -82,7 +82,7 @@ public sealed class Step242ConicalSurfaceRegressionTests
[InlineData("testdata/step242/nist/CTC/nist_ctc_02_asme1_ap242-e2.stp", "", "Audit.None", "No diagnostics.")]
[InlineData("testdata/step242/nist/CTC/nist_ctc_03_asme1_ap242-e2.stp", "", "", "")]
[InlineData("testdata/step242/nist/CTC/nist_ctc_04_asme1_ap242-e1.stp", "", "Audit.None", "No diagnostics.")]
- [InlineData("testdata/step242/nist/FTC/nist_ftc_06_asme1_ap242-e2.stp", "tessellator", "", "Face 12 spherical trim loop must contain at least three coedges. Observed")]
+ [InlineData("testdata/step242/nist/FTC/nist_ftc_06_asme1_ap242-e2.stp", "tessellator", "", "Face 12 spherical two-coedge trim classified as unsupported subfamily (requires bi-arc circles; observed edge kinds 'BSp")]
[InlineData("testdata/step242/nist/FTC/nist_ftc_09_asme1_ap242-e1.stp", "", "Audit.None", "No diagnostics.")]
[InlineData("testdata/step242/nist/FTC/nist_ftc_10_asme1_ap242-e2.stp", "tessellator", "", "Face ")]
[InlineData("testdata/step242/nist/STC/nist_stc_09_asme1_ap242-e3.stp", "", "", "")]
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242RevolvedTopologyFamilyRegressionTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242RevolvedTopologyFamilyRegressionTests.cs
index 7301ec1f..244c8db3 100644
--- a/Aetheris.Kernel.Core.Tests/Step242/Step242RevolvedTopologyFamilyRegressionTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242RevolvedTopologyFamilyRegressionTests.cs
@@ -90,7 +90,7 @@ public sealed class Step242RevolvedTopologyFamilyRegressionTests
}
[Theory]
- [InlineData("testdata/step242/nist/FTC/nist_ftc_06_asme1_ap242-e2.stp", "Face 12 spherical trim loop must contain at least three coedges. Observed")]
+ [InlineData("testdata/step242/nist/FTC/nist_ftc_06_asme1_ap242-e2.stp", "Face 12 spherical two-coedge trim classified as unsupported subfamily (requires bi-arc circles; observed edge kinds 'BSp")]
[InlineData("testdata/step242/nist/STC/nist_stc_08_asme1_ap242-e3.stp", "No diagnostics.")]
public void Step242_RevolvedTopologyFamilyBlockers_StayDeterministic_AndRemainExplicit(string relativePath, string expectedMessagePrefix)
{
diff --git a/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.cs b/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.cs
index 0031d382..07863ac1 100644
--- a/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.cs
+++ b/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.cs
@@ -27,6 +27,8 @@ public static class BrepDisplayTessellator
private const string BSplineSurfaceTrimUnsupportedSource = "Viewer.Tessellation.BSplineSurfaceTrimUnsupported";
private const string SphereTrimSingleCoedgeLatitudeCapSource = "Viewer.Tessellation.SphereTrim.SingleCoedgeLatitudeCap";
private const string SphereTrimSingleCoedgeUnsupportedSource = "Viewer.Tessellation.SphereTrim.SingleCoedgeUnsupported";
+ private const string SphereTrimTwoCoedgeBiArcLuneSource = "Viewer.Tessellation.SphereTrim.TwoCoedgeBiArcLune";
+ private const string SphereTrimTwoCoedgeUnsupportedSource = "Viewer.Tessellation.SphereTrim.TwoCoedgeUnsupported";
public static KernelResult<DisplayTessellationResult> Tessellate(BrepBody body, DisplayTessellationOptions? options = null)
{
@@ -1720,9 +1722,6 @@ public static class BrepDisplayTessellator
FaceId faceId,
SphereSurface sphere)
{
- const double minAngularSpan = 1e-6d;
- const double minElevationSpan = 1e-6d;
-
var loopIds = body.GetLoopIds(faceId);
if (loopIds.Count == 0)
{
@@ -1747,12 +1746,88 @@ public static class BrepDisplayTessellator
return KernelResult<(double, double, double, double)>.Failure(singleCoedgeResolution.Diagnostics);
}
+ if (coedges.Length == 2)
+ {
+ var twoCoedgeResolution = TryResolveTwoCoedgeSphereTrimPatch(body, faceId, sphere, coedges);
+ if (twoCoedgeResolution.IsSuccess)
+ {
+ return twoCoedgeResolution;
+ }
+
+ return KernelResult<(double, double, double, double)>.Failure(twoCoedgeResolution.Diagnostics);
+ }
+
if (coedges.Length < 3)
{
return KernelResult<(double, double, double, double)>.Failure([
CreateNotImplemented($"Face {faceId.Value} spherical trim loop must contain at least three coedges. Observed {coedges.Length}.")]);
}
+ return TryResolveGeneralSphereTrimPatch(body, faceId, sphere, coedges);
+ }
+
+ private static KernelResult<(double UStart, double USpan, double VStart, double VEnd)> TryResolveTwoCoedgeSphereTrimPatch(
+ BrepBody body,
+ FaceId faceId,
+ SphereSurface sphere,
+ IReadOnlyList<Coedge> coedges)
+ {
+ if (coedges.Count != 2)
+ {
+ return KernelResult<(double, double, double, double)>.Failure([
+ CreateNotImplemented($"Face {faceId.Value} spherical two-coedge trim resolver expected exactly two coedges. Observed {coedges.Count}.", SphereTrimTwoCoedgeUnsupportedSource)]);
+ }
+
+ var firstCurve = body.GetEdgeCurve(coedges[0].EdgeId);
+ var secondCurve = body.GetEdgeCurve(coedges[1].EdgeId);
+ if (firstCurve.Kind != CurveGeometryKind.Circle3 || secondCurve.Kind != CurveGeometryKind.Circle3)
+ {
+ return KernelResult<(double, double, double, double)>.Failure([
+ CreateNotImplemented(
+ $"Face {faceId.Value} spherical two-coedge trim classified as unsupported subfamily (requires bi-arc circles; observed edge kinds '{firstCurve.UnsupportedKind ?? firstCurve.Kind.ToString()}' and '{secondCurve.UnsupportedKind ?? secondCurve.Kind.ToString()}').",
+ SphereTrimTwoCoedgeUnsupportedSource)]);
+ }
+
+ if (!body.TryGetEdgeVertices(coedges[0].EdgeId, out var firstStartVertexId, out var firstEndVertexId)
+ || !body.TryGetEdgeVertices(coedges[1].EdgeId, out var secondStartVertexId, out var secondEndVertexId))
+ {
+ return KernelResult<(double, double, double, double)>.Failure([
+ CreateNotImplemented(
+ $"Face {faceId.Value} spherical two-coedge trim classified as unsupported subfamily (missing edge vertex topology).",
+ SphereTrimTwoCoedgeUnsupportedSource)]);
+ }
+
+ var uniqueVertexIds = new HashSet<VertexId> { firstStartVertexId, firstEndVertexId, secondStartVertexId, secondEndVertexId };
+ if (uniqueVertexIds.Count != 2)
+ {
+ return KernelResult<(double, double, double, double)>.Failure([
+ CreateNotImplemented(
+ $"Face {faceId.Value} spherical two-coedge trim classified as unsupported subfamily (expected two shared vertices; observed {uniqueVertexIds.Count}).",
+ SphereTrimTwoCoedgeUnsupportedSource)]);
+ }
+
+ var generalResolution = TryResolveGeneralSphereTrimPatch(body, faceId, sphere, coedges);
+ if (!generalResolution.IsSuccess)
+ {
+ return generalResolution;
+ }
+
+ return KernelResult<(double, double, double, double)>.Success(
+ generalResolution.Value,
+ [CreateValidationWarning(
+ $"Face {faceId.Value} spherical two-coedge trim classified as bi-arc circle lune with two shared vertices (edges {coedges[0].EdgeId.Value}/{coedges[1].EdgeId.Value}).",
+ SphereTrimTwoCoedgeBiArcLuneSource)]);
+ }
+
+ private static KernelResult<(double UStart, double USpan, double VStart, double VEnd)> TryResolveGeneralSphereTrimPatch(
+ BrepBody body,
+ FaceId faceId,
+ SphereSurface sphere,
+ IReadOnlyList<Coedge> coedges)
+ {
+ const double minAngularSpan = 1e-6d;
+ const double minElevationSpan = 1e-6d;
+
var vertexPointsResult = BuildLoopVertexPointLookup(body, coedges, faceId);
if (!vertexPointsResult.IsSuccess)
{
diff --git a/testdata/step242/manifests/nist.v0.report.json b/testdata/step242/manifests/nist.v0.report.json
index 044a83bd..515a5bb0 100644
--- a/testdata/step242/manifests/nist.v0.report.json
+++ b/testdata/step242/manifests/nist.v0.report.json
@@ -127,8 +127,8 @@
"firstFailureLayer": "tessellator",
"firstDiagnostic": {
"code": "NotImplemented",
- "source": "",
- "messagePrefix": "Face 12 spherical trim loop must contain at least three coedges. Observed 2."
+ "source": "Viewer.Tessellation.SphereTrim.TwoCoedgeUnsupported",
+ "messagePrefix": "Face 12 spherical two-coedge trim classified as unsupported subfamily (requires bi-arc circles; observed edge kinds \u0027BSp"
},
"diagnosticCount": 1,
"exceptionEscaped": false,