Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Install .NET 8 and tighten axial-span degeneracy classification
Yuechen Li5e75d085b39a
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242HoleSemanticsTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242HoleSemanticsTests.csindex b8208ee6..271c649a 100644--- a/Aetheris.Kernel.Core.Tests/Step242/Step242HoleSemanticsTests.cs+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242HoleSemanticsTests.cs@@ -80,7 +80,7 @@ public sealed class Step242HoleSemanticsTests}[Fact]- public void ImportBody_MultiLoopCylindricalFace_Imports_ThenFailsDeterministicallyAtCylinderTrimDegenerateTessellation()+ public void ImportBody_MultiLoopCylindricalFace_Imports_ThenFailsDeterministicallyAtCylinderTrimAxialSpanDegenerateTessellation(){var import = Step242Importer.ImportBody(Step242FixtureCorpus.CylindricalFaceWithTwoLoops);@@ -95,7 +95,7 @@ public sealed class Step242HoleSemanticsTestsAssert.False(tessellation.IsSuccess);var diagnostic = Assert.Single(tessellation.Diagnostics);Assert.Equal(KernelDiagnosticCode.InvalidArgument, diagnostic.Code);- Assert.Equal("Viewer.Tessellation.CylinderTrimDegenerate", diagnostic.Source);- Assert.StartsWith("Cylindrical face tessellation derived a degenerate trim patch.", diagnostic.Message, StringComparison.Ordinal);+ Assert.Equal("Viewer.Tessellation.CylinderTrimAxialSpanDegenerate", diagnostic.Source);+ Assert.Contains("collapsed axial span", diagnostic.Message, StringComparison.Ordinal);}}diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242UnsupportedSurfaceForHolesRegressionTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242UnsupportedSurfaceForHolesRegressionTests.csindex 17471f7f..66576f08 100644--- a/Aetheris.Kernel.Core.Tests/Step242/Step242UnsupportedSurfaceForHolesRegressionTests.cs+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242UnsupportedSurfaceForHolesRegressionTests.cs@@ -15,8 +15,8 @@ public sealed class Step242UnsupportedSurfaceForHolesRegressionTests"testdata/step242/nist/FTC/nist_ftc_11_asme1_ap242-e2.stp","tessellator","Topology.GraphValidator",- "Viewer.Tessellation.CylinderTrimDegenerate",- "Cylindrical face tessellation derived a degenerate trim patch.")]+ "Viewer.Tessellation.CylinderTrimAxialSpanDegenerate",+ "Face 3 cylindrical trim loop 7 has 1 coedges, angular span")][InlineData("testdata/step242/nist/STC/nist_stc_06_asme1_ap242-e3.stp","importer-topology",diff --git a/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.cs b/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.csindex 78e0997e..ebca2d5d 100644--- a/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.cs+++ b/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.cs@@ -17,6 +17,7 @@ public static class BrepDisplayTessellatorprivate const string CircleTrimAmbiguousUsedShorterArcSource = "Viewer.Tessellation.CircleTrimAmbiguousUsedShorterArc";private const string CylinderTrimUnsupportedSource = "Viewer.Tessellation.CylinderTrimUnsupported";private const string CylinderTrimDegenerateSource = "Viewer.Tessellation.CylinderTrimDegenerate";+ private const string CylinderTrimAxialSpanDegenerateSource = "Viewer.Tessellation.CylinderTrimAxialSpanDegenerate";private const string CylinderTrimAmbiguousUsedShorterSpanSource = "Viewer.Tessellation.CylinderTrimAmbiguousUsedShorterSpan";private const string CurvedTopologyUnsupportedSource = "Viewer.Tessellation.CurvedTopologyUnsupported";private const string BSplineSurfaceTrimUnsupportedSource = "Viewer.Tessellation.BSplineSurfaceTrimUnsupported";@@ -982,6 +983,7 @@ public static class BrepDisplayTessellatorCylinderSurface cylinder){const double minSpan = 1e-8d;+ const double nearFullWrapThreshold = 2d * double.Pi * 0.95d;var loopIds = body.GetLoopIds(faceId);if (loopIds.Count == 0){@@ -994,14 +996,11 @@ public static class BrepDisplayTessellatorvar yAxis = cylinder.YAxis.ToVector();(double UStart, double USpan, double VStart, double VEnd, bool UsedAmbiguousShorterSpanResolution)? best = null;+ (LoopId LoopId, int CoedgeCount, double AngularSpan, double AxialSpan, bool IsNearFullWrap, bool AngularResolved)? bestAxialSpanDegenerate = null;foreach (var loopId in loopIds){var coedges = body.GetCoedgeIds(loopId).Select(id => body.Topology.GetCoedge(id)).ToArray();- if (coedges.Length < 3)- {- continue;- }var vertexPointsResult = BuildLoopVertexPointLookup(body, coedges, faceId);if (!vertexPointsResult.IsSuccess)@@ -1051,12 +1050,30 @@ public static class BrepDisplayTessellatorvar vStart = allAxials.Min();var vEnd = allAxials.Max();- if ((vEnd - vStart) <= minSpan)+ var axialSpan = vEnd - vStart;+ var angularBounds = ResolveAngularBounds(allAngles);+ var angularSpan = (angularBounds.IsSuccess && angularBounds.Value.Span > minSpan) ? angularBounds.Value.Span : 0d;++ if (axialSpan <= minSpan){+ var degenerateCandidate = (+ LoopId: loopId,+ CoedgeCount: coedges.Length,+ AngularSpan: angularSpan,+ AxialSpan: axialSpan,+ IsNearFullWrap: angularBounds.IsSuccess && angularBounds.Value.Span >= nearFullWrapThreshold,+ AngularResolved: angularBounds.IsSuccess && angularBounds.Value.Span > minSpan);+ if (!bestAxialSpanDegenerate.HasValue ||+ degenerateCandidate.AngularSpan > bestAxialSpanDegenerate.Value.AngularSpan ||+ (System.Math.Abs(degenerateCandidate.AngularSpan - bestAxialSpanDegenerate.Value.AngularSpan) <= minSpan &&+ degenerateCandidate.CoedgeCount > bestAxialSpanDegenerate.Value.CoedgeCount))+ {+ bestAxialSpanDegenerate = degenerateCandidate;+ }+continue;}- var angularBounds = ResolveAngularBounds(allAngles);if (!angularBounds.IsSuccess || angularBounds.Value.Span <= minSpan){continue;@@ -1073,6 +1090,19 @@ public static class BrepDisplayTessellatorif (!best.HasValue){+ if (bestAxialSpanDegenerate.HasValue && loopIds.Count == 1)+ {+ var classification = bestAxialSpanDegenerate.Value.IsNearFullWrap+ ? "full-wrap ring-like boundary with collapsed axial span"+ : bestAxialSpanDegenerate.Value.AngularResolved+ ? "trimmed cylindrical loop with collapsed axial span"+ : "axial-span-collapsed loop without resolvable angular extent";+ return KernelResult<(double, double, double, double)>.Failure([+ CreateInvalidArgument(+ $"Face {faceId.Value} cylindrical trim loop {bestAxialSpanDegenerate.Value.LoopId.Value} has {bestAxialSpanDegenerate.Value.CoedgeCount} coedges, angular span {bestAxialSpanDegenerate.Value.AngularSpan:R}, axial span {bestAxialSpanDegenerate.Value.AxialSpan:R}, loop count {loopIds.Count}; classified as {classification} and treated as degenerate.",+ CylinderTrimAxialSpanDegenerateSource)]);+ }+return KernelResult<(double, double, double, double)>.Failure([CreateInvalidArgument("Cylindrical face tessellation derived a degenerate trim patch.", CylinderTrimDegenerateSource)]);}diff --git a/testdata/step242/manifests/nist.v0.report.json b/testdata/step242/manifests/nist.v0.report.jsonindex e9fd5504..11e08140 100644--- a/testdata/step242/manifests/nist.v0.report.json+++ b/testdata/step242/manifests/nist.v0.report.json@@ -271,8 +271,8 @@"firstFailureLayer": "tessellator","firstDiagnostic": {"code": "InvalidArgument",- "source": "Viewer.Tessellation.CylinderTrimDegenerate",- "messagePrefix": "Cylindrical face tessellation derived a degenerate trim patch."+ "source": "Viewer.Tessellation.CylinderTrimAxialSpanDegenerate",+ "messagePrefix": "Face 3 cylindrical trim loop 7 has 1 coedges, angular span 6.2831853071795862, axial span 0, loop count 1; classified as full-wrap ring-like boundary with collapsed axial span and treated as degenerate."},"diagnosticCount": 1,"exceptionEscaped": false,