Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Use trimmed-circle sampling for planar tessellation arcs
Yuechen Li2e1094aadfb7
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242CylinderTrimDualSingleCoedgeClosedCircleRegressionTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242CylinderTrimDualSingleCoedgeClosedCircleRegressionTests.csindex 4b149c91..82b263b0 100644--- a/Aetheris.Kernel.Core.Tests/Step242/Step242CylinderTrimDualSingleCoedgeClosedCircleRegressionTests.cs+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242CylinderTrimDualSingleCoedgeClosedCircleRegressionTests.cs@@ -50,9 +50,10 @@ public sealed class Step242CylinderTrimDualSingleCoedgeClosedCircleRegressionTesvar first = Step242CorpusManifestRunner.RunOne(new Step242CorpusManifestEntry("ftc11", relativePath, "nist-regression", null, null, null, null, null));var second = Step242CorpusManifestRunner.RunOne(new Step242CorpusManifestEntry("ftc11", relativePath, "nist-regression", null, null, null, null, null));- Assert.Equal("tessellator", first.FirstFailureLayer);+ Assert.Equal("exporter", first.FirstFailureLayer);Assert.NotEqual("Viewer.Tessellation.CylinderTrimDegenerate", first.FirstDiagnostic.Source);- Assert.Equal("Viewer.Tessellation.PlanarNonConvexTriangulationFailed", first.FirstDiagnostic.Source);+ Assert.Equal("Edge:29", first.FirstDiagnostic.Source);+ Assert.StartsWith("Edge endpoints resolve to a degenerate line direction.", first.FirstDiagnostic.MessagePrefix, StringComparison.Ordinal);Assert.Equal(first.FirstFailureLayer, second.FirstFailureLayer);Assert.Equal(first.FirstDiagnostic.Source, second.FirstDiagnostic.Source);diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242UnsupportedSurfaceForHolesRegressionTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242UnsupportedSurfaceForHolesRegressionTests.csindex 841ad8d7..f2dadae7 100644--- a/Aetheris.Kernel.Core.Tests/Step242/Step242UnsupportedSurfaceForHolesRegressionTests.cs+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242UnsupportedSurfaceForHolesRegressionTests.cs@@ -13,10 +13,10 @@ public sealed class Step242UnsupportedSurfaceForHolesRegressionTests"Face 4 planar loop triangulation failed because the polygon is not simple.")][InlineData("testdata/step242/nist/FTC/nist_ftc_11_asme1_ap242-e2.stp",- "tessellator",+ "exporter","Topology.GraphValidator",- "Viewer.Tessellation.PlanarNonConvexTriangulationFailed",- null)]+ "Edge:29",+ "Edge endpoints resolve to a degenerate line direction.")]public void Step242_NistTargets_AdvancePastGenericUnsupportedSurfaceForHoles_Deterministically(string relativePath,diff --git a/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.cs b/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.csindex 935d5734..d662f12c 100644--- a/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.cs+++ b/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.cs@@ -2522,6 +2522,37 @@ public static class BrepDisplayTessellatorPlaneSurface plane,FaceId faceId){+ if (body.Bindings.TryGetEdgeBinding(coedge.EdgeId, out var binding)+ && CurveSampler.TrySampleTrimmedCircleArc(+ circle,+ start,+ end,+ coedge.IsReversed ? !binding.OrientedEdgeSense : binding.OrientedEdgeSense,+ out var sampledPoints,+ out var isClosed,+ out var usedShorterArcFallback))+ {+ var points = new List<Point3D>(sampledPoints.Count - 1);+ for (var i = 1; i < sampledPoints.Count; i++)+ {+ points.Add(sampledPoints[i]);+ }++ if (!isClosed)+ {+ points[^1] = end;+ }++ if (usedShorterArcFallback)+ {+ return KernelResult<IReadOnlyList<Point3D>>.Success(+ points,+ [CreateValidationWarning($"Face {faceId.Value} edge {coedge.EdgeId.Value} circular planar trim was ambiguous; using shorter arc.", CircleTrimAmbiguousUsedShorterArcSource)]);+ }++ return KernelResult<IReadOnlyList<Point3D>>.Success(points);+ }+var deltaResult = ResolveArcDelta(body, coedge, circle, start, end, plane, faceId);if (!deltaResult.IsSuccess){@@ -2530,13 +2561,13 @@ public static class BrepDisplayTessellatorvar (startAngle, delta) = deltaResult.Value;var samples = CurveSampler.SampleCircleArc(circle, startAngle, delta);- var points = new List<Point3D>(samples.Count - 1);+ var pointsFallback = new List<Point3D>(samples.Count - 1);for (var i = 1; i < samples.Count; i++){- points.Add(samples[i]);+ pointsFallback.Add(samples[i]);}- return KernelResult<IReadOnlyList<Point3D>>.Success(points);+ return KernelResult<IReadOnlyList<Point3D>>.Success(pointsFallback);}private static KernelResult<IReadOnlyList<Point3D>> SamplePlanarBSpline(diff --git a/testdata/step242/manifests/nist.v0.report.json b/testdata/step242/manifests/nist.v0.report.jsonindex 3fbc57a5..107ab0a2 100644--- a/testdata/step242/manifests/nist.v0.report.json+++ b/testdata/step242/manifests/nist.v0.report.json@@ -268,11 +268,11 @@"path": "testdata/step242/nist/FTC/nist_ftc_11_asme1_ap242-e2.stp","sizeBytes": 1920822,"status": "importFail",- "firstFailureLayer": "tessellator",+ "firstFailureLayer": "exporter","firstDiagnostic": {"code": "NotImplemented",- "source": "Viewer.Tessellation.PlanarNonConvexTriangulationFailed",- "messagePrefix": "Face 21 planar loop triangulation failed because the polygon is not simple."+ "source": "Edge:29",+ "messagePrefix": "Edge endpoints resolve to a degenerate line direction."},"diagnosticCount": 1,"exceptionEscaped": false,@@ -282,8 +282,8 @@"faces": 42},"tessellationCounts": {- "facePatches": 0,- "edgePolylines": 0+ "facePatches": 42,+ "edgePolylines": 104},"canonicalSha256": null},