Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Update STEP242 regressions after ftc_07/ftc_10 progression

Yuechen Li50460182ab23
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242BSplineSurfaceWithKnotsTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242BSplineSurfaceWithKnotsTests.cs
index 84dc06aa..1df3e341 100644
--- a/Aetheris.Kernel.Core.Tests/Step242/Step242BSplineSurfaceWithKnotsTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242BSplineSurfaceWithKnotsTests.cs
@@ -108,7 +108,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/FTC/nist_ftc_07_asme1_ap242-e2.stp", "", "Audit.None", "No diagnostics.")]
[InlineData("testdata/step242/nist/STC/nist_stc_08_asme1_ap242-e3.stp", "", "Audit.None", "No diagnostics.")]
public void Step242_TrimmedSphereTargets_AdvancePastOldUntrimmedSphereBlocker_AndRemainDeterministic(
string relativePath,
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242ConicalSurfaceRegressionTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242ConicalSurfaceRegressionTests.cs
index 615677a1..874f8594 100644
--- a/Aetheris.Kernel.Core.Tests/Step242/Step242ConicalSurfaceRegressionTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242ConicalSurfaceRegressionTests.cs
@@ -84,7 +84,7 @@ public sealed class Step242ConicalSurfaceRegressionTests
[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", "", "Audit.None", "No diagnostics.")]
[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/FTC/nist_ftc_10_asme1_ap242-e2.stp", "", "Audit.None", "No diagnostics.")]
[InlineData("testdata/step242/nist/STC/nist_stc_09_asme1_ap242-e3.stp", "", "", "")]
public void Step242_NistCurvedRevolvedTargets_AdvancePastOldTopologyFamily_AndReportDeterministicNextBlocker(
string relativePath,
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242RevolvedTopologyFamilyRegressionTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242RevolvedTopologyFamilyRegressionTests.cs
index 87d56df7..28bdc528 100644
--- a/Aetheris.Kernel.Core.Tests/Step242/Step242RevolvedTopologyFamilyRegressionTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242RevolvedTopologyFamilyRegressionTests.cs
@@ -6,8 +6,8 @@ public sealed class Step242RevolvedTopologyFamilyRegressionTests
{
[Theory]
[InlineData("testdata/step242/nist/CTC/nist_ctc_04_asme1_ap242-e1.stp", "No diagnostics.")]
- [InlineData("testdata/step242/nist/FTC/nist_ftc_07_asme1_ap242-e2.stp", "Face 183 planar loop triangulation failed.")]
- [InlineData("testdata/step242/nist/FTC/nist_ftc_10_asme1_ap242-e2.stp", "Face 214 planar loop triangulation failed because the polygon is not simple.")]
+ [InlineData("testdata/step242/nist/FTC/nist_ftc_07_asme1_ap242-e2.stp", "No diagnostics.")]
+ [InlineData("testdata/step242/nist/FTC/nist_ftc_10_asme1_ap242-e2.stp", "No diagnostics.")]
public void Step242_RepeatedCurvedRevolvedTargets_AdvanceWithExplicitDeterministicNextBlocker(
string relativePath,
string expectedMessagePrefix)
@@ -38,7 +38,7 @@ public sealed class Step242RevolvedTopologyFamilyRegressionTests
}
[Fact]
- public void Step242_Ftc07_SixCoedgeBsplineOnlyRevolvedLoop_AdvancesDeterministically_ToPlanarTriangulationBlocker()
+ public void Step242_Ftc07_SixCoedgeBsplineOnlyRevolvedLoop_AdvancesDeterministically_ToSuccess()
{
const string relativePath = "testdata/step242/nist/FTC/nist_ftc_07_asme1_ap242-e2.stp";
var entry = new Step242CorpusManifestEntry(
@@ -59,7 +59,7 @@ public sealed class Step242RevolvedTopologyFamilyRegressionTests
Assert.Equal(first.FirstDiagnostic.MessagePrefix, second.FirstDiagnostic.MessagePrefix);
Assert.DoesNotContain("unsupported subfamily 'six-coedge bspline-only revolved loop'", first.FirstDiagnostic.MessagePrefix, StringComparison.Ordinal);
- Assert.StartsWith("Face 183 planar loop triangulation failed.", first.FirstDiagnostic.MessagePrefix, StringComparison.Ordinal);
+ Assert.Equal("No diagnostics.", first.FirstDiagnostic.MessagePrefix);
}
diff --git a/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.cs b/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.cs
index 44b2a2a4..30e14aae 100644
--- a/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.cs
+++ b/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.cs
@@ -150,10 +150,31 @@ public static class BrepDisplayTessellator
return loopIds[0];
}
- var bestLoop = loopIds[0];
+ var lineOnlyLoopCandidates = loopIds.Where(loopId => IsAllLine3Loop(body, loopId)).ToArray();
+ if (TrySelectLargestViablePlanarLoop(body, faceId, plane, lineOnlyLoopCandidates, out var selectedLineLoop))
+ {
+ return selectedLineLoop;
+ }
+
+ if (TrySelectLargestViablePlanarLoop(body, faceId, plane, loopIds, out var selectedMixedLoop))
+ {
+ return selectedMixedLoop;
+ }
+
+ return loopIds[0];
+ }
+
+ private static bool TrySelectLargestViablePlanarLoop(
+ BrepBody body,
+ FaceId faceId,
+ PlaneSurface plane,
+ IReadOnlyList<LoopId> candidateLoopIds,
+ out LoopId bestLoop)
+ {
+ bestLoop = default;
var bestArea = double.NegativeInfinity;
- foreach (var loopId in loopIds)
+ foreach (var loopId in candidateLoopIds)
{
var coedges = body.GetCoedgeIds(loopId)
.Select(id => body.Topology.GetCoedge(id))
@@ -165,15 +186,41 @@ public static class BrepDisplayTessellator
continue;
}
- var area = double.Abs(ComputeSignedPlanarArea(pointsResult.Value, plane));
- if (area > bestArea)
+ var polygonPoints = pointsResult.Value;
+ if (polygonPoints.Count < 3)
+ {
+ continue;
+ }
+
+ if (!PlanarPolygonTriangulator.TryTriangulate(polygonPoints, plane.Normal.ToVector(), out _, out _))
+ {
+ continue;
+ }
+
+ var area = double.Abs(ComputeSignedPlanarArea(polygonPoints, plane));
+ if (area > bestArea || (System.Math.Abs(area - bestArea) <= 1e-12d && loopId.Value < bestLoop.Value))
{
bestArea = area;
bestLoop = loopId;
}
}
- return bestLoop;
+ return bestArea > double.NegativeInfinity;
+ }
+
+ private static bool IsAllLine3Loop(BrepBody body, LoopId loopId)
+ {
+ var coedgeIds = body.GetCoedgeIds(loopId);
+ for (var i = 0; i < coedgeIds.Count; i++)
+ {
+ var edgeId = body.Topology.GetCoedge(coedgeIds[i]).EdgeId;
+ if (body.GetEdgeCurve(edgeId).Kind != CurveGeometryKind.Line3)
+ {
+ return false;
+ }
+ }
+
+ return true;
}
private static double ComputeSignedPlanarArea(IReadOnlyList<Point3D> polygonPoints, PlaneSurface plane)
diff --git a/testdata/step242/manifests/nist.v0.report.json b/testdata/step242/manifests/nist.v0.report.json
index bbcff274..ad0e49da 100644
--- a/testdata/step242/manifests/nist.v0.report.json
+++ b/testdata/step242/manifests/nist.v0.report.json
@@ -147,14 +147,14 @@
"fileId": "testdata_step242_nist_FTC_nist_ftc_07_asme1_ap242-e2",
"path": "testdata/step242/nist/FTC/nist_ftc_07_asme1_ap242-e2.stp",
"sizeBytes": 1459346,
- "status": "importFail",
- "firstFailureLayer": "tessellator",
+ "status": "success",
+ "firstFailureLayer": "",
"firstDiagnostic": {
- "code": "NotImplemented",
- "source": "Viewer.Tessellation.PlanarNonConvexTriangulationFailed",
- "messagePrefix": "Face 183 planar loop triangulation failed."
+ "code": "Unknown",
+ "source": "Audit.None",
+ "messagePrefix": "No diagnostics."
},
- "diagnosticCount": 1,
+ "diagnosticCount": 0,
"exceptionEscaped": false,
"topologyCounts": {
"vertices": 588,
@@ -162,10 +162,10 @@
"faces": 306
},
"tessellationCounts": {
- "facePatches": 0,
- "edgePolylines": 0
+ "facePatches": 306,
+ "edgePolylines": 871
},
- "canonicalSha256": null
+ "canonicalSha256": "e88e432d9cae16a3b457d1ba3ce3ccddcb2a64e3f740d543c3d5cd570026fa0a"
},
{
"fileId": "testdata_step242_nist_FTC_nist_ftc_08_asme1_ap242-e1-tg",
@@ -243,14 +243,14 @@
"fileId": "testdata_step242_nist_FTC_nist_ftc_10_asme1_ap242-e2",
"path": "testdata/step242/nist/FTC/nist_ftc_10_asme1_ap242-e2.stp",
"sizeBytes": 1855829,
- "status": "importFail",
- "firstFailureLayer": "tessellator",
+ "status": "success",
+ "firstFailureLayer": "",
"firstDiagnostic": {
- "code": "NotImplemented",
- "source": "Viewer.Tessellation.PlanarNonConvexTriangulationFailed",
- "messagePrefix": "Face 214 planar loop triangulation failed because the polygon is not simple."
+ "code": "Unknown",
+ "source": "Audit.None",
+ "messagePrefix": "No diagnostics."
},
- "diagnosticCount": 1,
+ "diagnosticCount": 0,
"exceptionEscaped": false,
"topologyCounts": {
"vertices": 572,
@@ -258,10 +258,10 @@
"faces": 268
},
"tessellationCounts": {
- "facePatches": 0,
- "edgePolylines": 0
+ "facePatches": 268,
+ "edgePolylines": 813
},
- "canonicalSha256": null
+ "canonicalSha256": "72852a798345f6815b5d56397e942efe70ca47e8c7c216770170fe06fa2ced11"
},
{
"fileId": "testdata_step242_nist_FTC_nist_ftc_11_asme1_ap242-e2",