Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Add narrow support for four-coedge circle-only non-seam torus loops
Yuechen Li3a04455d75ea
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242BSplineSurfaceWithKnotsTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242BSplineSurfaceWithKnotsTests.csindex 1c04df85..d718fe22 100644--- a/Aetheris.Kernel.Core.Tests/Step242/Step242BSplineSurfaceWithKnotsTests.cs+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242BSplineSurfaceWithKnotsTests.cs@@ -109,7 +109,7 @@ public sealed class Step242BSplineSurfaceWithKnotsTests[Theory][InlineData("testdata/step242/nist/CTC/nist_ctc_02_asme1_ap242-e2.stp", "", "Audit.None", "No diagnostics.")][InlineData("testdata/step242/nist/FTC/nist_ftc_07_asme1_ap242-e2.stp", "tessellator", "", "Face ")]- [InlineData("testdata/step242/nist/STC/nist_stc_08_asme1_ap242-e3.stp", "tessellator", "", "Face 62 curved tessellation supports selected repeated torus/revolved boundary subfamilies; unsupported subfamily 'circle-only non-seam loop'. Observed")]+ [InlineData("testdata/step242/nist/STC/nist_stc_08_asme1_ap242-e3.stp", "exporter", "", "Unsupported surface kind 'Torus'.")]public void Step242_TrimmedSphereTargets_AdvancePastOldUntrimmedSphereBlocker_AndRemainDeterministic(string relativePath,string expectedLayer,diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242ConicalSurfaceRegressionTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242ConicalSurfaceRegressionTests.csindex 3ecfe223..4f2509ff 100644--- a/Aetheris.Kernel.Core.Tests/Step242/Step242ConicalSurfaceRegressionTests.cs+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242ConicalSurfaceRegressionTests.cs@@ -81,7 +81,7 @@ public sealed class Step242ConicalSurfaceRegressionTests[InlineData("testdata/step242/nist/CTC/nist_ctc_01_asme1_ap242-e1.stp", "", "Audit.None", "No diagnostics.")][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", "tessellator", "", "Face 327 curved tessellation supports selected repeated torus/revolved boundary subfamilies; unsupported subfamily 'circle-only non-seam loop'. Observed")]+ [InlineData("testdata/step242/nist/CTC/nist_ctc_04_asme1_ap242-e1.stp", "exporter", "", "Unsupported surface kind 'Torus'.")][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_09_asme1_ap242-e1.stp", "", "Audit.None", "No diagnostics.")][InlineData("testdata/step242/nist/FTC/nist_ftc_10_asme1_ap242-e2.stp", "tessellator", "", "Face ")]diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242RevolvedTopologyFamilyRegressionTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242RevolvedTopologyFamilyRegressionTests.csindex 1ac56103..47c0eb5b 100644--- a/Aetheris.Kernel.Core.Tests/Step242/Step242RevolvedTopologyFamilyRegressionTests.cs+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242RevolvedTopologyFamilyRegressionTests.cs@@ -5,7 +5,7 @@ namespace Aetheris.Kernel.Core.Tests.Step242;public sealed class Step242RevolvedTopologyFamilyRegressionTests{[Theory]- [InlineData("testdata/step242/nist/CTC/nist_ctc_04_asme1_ap242-e1.stp", "Face 327 curved tessellation supports selected repeated torus/revolved boundary subfamilies; unsupported subfamily 'circle-only non-seam loop'. Observed")]+ [InlineData("testdata/step242/nist/CTC/nist_ctc_04_asme1_ap242-e1.stp", "Unsupported surface kind 'Torus'.")][InlineData("testdata/step242/nist/FTC/nist_ftc_07_asme1_ap242-e2.stp", "Face 129 curved tessellation supports selected repeated cone/revolved boundary subfamilies; unsupported subfamily 'four-coedge mixed line/bspline revolved loop'. Observed")][InlineData("testdata/step242/nist/FTC/nist_ftc_10_asme1_ap242-e2.stp", "Face 67 curved tessellation supports selected repeated torus/revolved boundary subfamilies; unsupported subfamily 'other (coedges=5, uniqueEdges=5)'. Observed")]public void Step242_RepeatedCurvedRevolvedTargets_AdvanceWithExplicitDeterministicNextBlocker(@@ -33,6 +33,7 @@ public sealed class Step242RevolvedTopologyFamilyRegressionTestsAssert.DoesNotContain("supports repeated cone/revolved families with mixed line/circle loops; this topology family is still unsupported", first.FirstDiagnostic.MessagePrefix, StringComparison.Ordinal);Assert.DoesNotContain("unsupported subfamily 'other (coedges=3, uniqueEdges=3)'", first.FirstDiagnostic.MessagePrefix, StringComparison.Ordinal);Assert.DoesNotContain("unsupported subfamily 'four-coedge bspline-only revolved loop'", first.FirstDiagnostic.MessagePrefix, StringComparison.Ordinal);+ Assert.DoesNotContain("unsupported subfamily 'circle-only non-seam loop'", first.FirstDiagnostic.MessagePrefix, StringComparison.Ordinal);Assert.StartsWith(expectedMessagePrefix, first.FirstDiagnostic.MessagePrefix, StringComparison.Ordinal);}@@ -63,7 +64,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/STC/nist_stc_08_asme1_ap242-e3.stp", "Face 62 curved tessellation supports selected repeated torus/revolved boundary subfamilies; unsupported subfamily 'circle-only non-seam loop'. Observed")]+ [InlineData("testdata/step242/nist/STC/nist_stc_08_asme1_ap242-e3.stp", "Unsupported surface kind 'Torus'.")]public void Step242_RevolvedTopologyFamilyBlockers_StayDeterministic_AndRemainExplicit(string relativePath, string expectedMessagePrefix){var entry = new Step242CorpusManifestEntry(@@ -79,12 +80,14 @@ public sealed class Step242RevolvedTopologyFamilyRegressionTestsvar first = Step242CorpusManifestRunner.RunOne(entry);var second = Step242CorpusManifestRunner.RunOne(entry);- Assert.Equal("tessellator", first.FirstFailureLayer);Assert.Equal(first.FirstFailureLayer, second.FirstFailureLayer);Assert.Equal(first.FirstDiagnostic.Source, second.FirstDiagnostic.Source);Assert.Equal(first.FirstDiagnostic.MessagePrefix, second.FirstDiagnostic.MessagePrefix);- Assert.Contains("Observed", first.FirstDiagnostic.MessagePrefix, StringComparison.Ordinal);+ if (expectedMessagePrefix.Contains("Observed", StringComparison.Ordinal))+ {+ Assert.Contains("Observed", first.FirstDiagnostic.MessagePrefix, StringComparison.Ordinal);+ }Assert.False(string.IsNullOrWhiteSpace(first.FirstDiagnostic.MessagePrefix));Assert.StartsWith(expectedMessagePrefix, first.FirstDiagnostic.MessagePrefix, StringComparison.Ordinal);}diff --git a/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.cs b/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.csindex 6a91015c..e0c0db5a 100644--- a/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.cs+++ b/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.cs@@ -687,6 +687,13 @@ public static class BrepDisplayTessellatorreturn KernelResult<(double, double, int, int)>.Success((coneRevolvedParameters.VStart, coneRevolvedParameters.VEnd, angularSegments, axialSegments), coneRevolvedDiagnostics);}+ if (TryResolveFourUseCircleOnlyNonSeamRevolvedLoop(body, coedges, lineCoedges, circleCoedges, axialParameterFromPoint, faceId, out var fourUseCircleOnlyNonSeamParameters, out var fourUseCircleOnlyNonSeamDiagnostics))+ {+ var angularSegments = CalculateSegmentCount(2d * double.Pi, System.Math.Max(1e-6d, radiusHint), options);+ var axialSegments = CalculateAxialSegments(fourUseCircleOnlyNonSeamParameters.VStart, fourUseCircleOnlyNonSeamParameters.VEnd, options);+ return KernelResult<(double, double, int, int)>.Success((fourUseCircleOnlyNonSeamParameters.VStart, fourUseCircleOnlyNonSeamParameters.VEnd, angularSegments, axialSegments), fourUseCircleOnlyNonSeamDiagnostics);+ }+var uniqueEdgeIds = coedges.Select(c => c.EdgeId).Distinct()@@ -737,6 +744,59 @@ public static class BrepDisplayTessellatorreturn true;}+ private static bool TryResolveFourUseCircleOnlyNonSeamRevolvedLoop(+ BrepBody body,+ IReadOnlyList<Coedge> coedges,+ IReadOnlyList<Coedge> lineCoedges,+ IReadOnlyList<Coedge> circleCoedges,+ Func<Point3D, double>? axialParameterFromPoint,+ FaceId faceId,+ out (double VStart, double VEnd) parameters,+ out IReadOnlyList<KernelDiagnostic> diagnostics)+ {+ parameters = default;+ diagnostics = [];+ if (axialParameterFromPoint is null || coedges.Count != 4 || lineCoedges.Count != 0 || circleCoedges.Count != 4)+ {+ return false;+ }++ var uniqueEdgeIds = coedges.Select(c => c.EdgeId).Distinct().ToArray();+ if (uniqueEdgeIds.Length != 4)+ {+ return false;+ }++ var seamUses = coedges.Count(c =>+ {+ var edge = body.Topology.GetEdge(c.EdgeId);+ return edge.StartVertexId == edge.EndVertexId;+ });+ if (seamUses != 0)+ {+ return false;+ }++ var allEdgeCurvesAreCircles = uniqueEdgeIds+ .Select(id => body.GetEdgeCurve(id).Kind)+ .All(kind => kind == CurveGeometryKind.Circle3);+ if (!allEdgeCurvesAreCircles)+ {+ return false;+ }++ var result = TryResolveAxialBoundsFromProjectedLoopVertices(body, coedges, axialParameterFromPoint, faceId);+ if (!result.IsSuccess)+ {+ diagnostics = result.Diagnostics;+ return false;+ }++ parameters = result.Value;+ diagnostics = result.Diagnostics;+ return true;+ }+private static bool TryResolveRepeatedMixedRevolvedLoop(BrepBody body,IReadOnlyList<Coedge> coedges,@@ -1268,6 +1328,11 @@ public static class BrepDisplayTessellatorif (lineCoedges.Count == 0 && circleCoedges.Count == coedges.Count){+ if (coedges.Count == 4 && uniqueEdgeIds.Length == 4 && seamUses == 0)+ {+ return "four-coedge circle-only non-seam revolved loop";+ }+return seamUses > 0 ? "circle-only seam reused loop" : "circle-only non-seam loop";}diff --git a/testdata/step242/manifests/nist.v0.report.json b/testdata/step242/manifests/nist.v0.report.jsonindex 2e121012..1498ea54 100644--- a/testdata/step242/manifests/nist.v0.report.json+++ b/testdata/step242/manifests/nist.v0.report.json@@ -76,11 +76,11 @@"path": "testdata/step242/nist/CTC/nist_ctc_04_asme1_ap242-e1.stp","sizeBytes": 1265846,"status": "importFail",- "firstFailureLayer": "tessellator",+ "firstFailureLayer": "exporter","firstDiagnostic": {"code": "NotImplemented",- "source": "",- "messagePrefix": "Face 327 curved tessellation supports selected repeated torus/revolved boundary subfamilies; unsupported subfamily \u0027circle-only non-seam loop\u0027. Observed"+ "source": "Face:252",+ "messagePrefix": "Unsupported surface kind \u0027Torus\u0027."},"diagnosticCount": 1,"exceptionEscaped": false,@@ -90,8 +90,8 @@"faces": 484},"tessellationCounts": {- "facePatches": 0,- "edgePolylines": 0+ "facePatches": 484,+ "edgePolylines": 1110},"canonicalSha256": null},@@ -340,11 +340,11 @@"path": "testdata/step242/nist/STC/nist_stc_08_asme1_ap242-e3.stp","sizeBytes": 2239112,"status": "importFail",- "firstFailureLayer": "tessellator",+ "firstFailureLayer": "exporter","firstDiagnostic": {"code": "NotImplemented",- "source": "",- "messagePrefix": "Face 62 curved tessellation supports selected repeated torus/revolved boundary subfamilies; unsupported subfamily \u0027circle-only non-seam loop\u0027. Observed"+ "source": "Face:62",+ "messagePrefix": "Unsupported surface kind \u0027Torus\u0027."},"diagnosticCount": 1,"exceptionEscaped": false,@@ -354,8 +354,8 @@"faces": 271},"tessellationCounts": {- "facePatches": 0,- "edgePolylines": 0+ "facePatches": 271,+ "edgePolylines": 709},"canonicalSha256": null},