Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Preserve periodic degenerate loop uses for cone/torus normalization

Yuechen Li2ef9ab43b228
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242EdgeCurveSenseRegressionTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242EdgeCurveSenseRegressionTests.cs
index dfd43d7f..8321d58c 100644
--- a/Aetheris.Kernel.Core.Tests/Step242/Step242EdgeCurveSenseRegressionTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242EdgeCurveSenseRegressionTests.cs
@@ -33,7 +33,7 @@ public sealed class Step242EdgeCurveSenseRegressionTests
{
Assert.Equal("tessellator", first.FirstFailureLayer);
Assert.Equal(string.Empty, first.FirstDiagnostic.Source);
- Assert.StartsWith("Face 33 spherical trim loop must contain at least three coedges.", first.FirstDiagnostic.MessagePrefix, StringComparison.Ordinal);
+ Assert.StartsWith("Face 30 curved tessellation requires exactly one loop.", first.FirstDiagnostic.MessagePrefix, StringComparison.Ordinal);
}
Assert.Equal(first.FirstFailureLayer, second.FirstFailureLayer);
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242LoopRoleNormalizationRegressionTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242LoopRoleNormalizationRegressionTests.cs
index badad2c4..4c001e45 100644
--- a/Aetheris.Kernel.Core.Tests/Step242/Step242LoopRoleNormalizationRegressionTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242LoopRoleNormalizationRegressionTests.cs
@@ -1,3 +1,4 @@
+using Aetheris.Kernel.Core.Brep;
using Aetheris.Kernel.Core.Step242;
namespace Aetheris.Kernel.Core.Tests.Step242;
@@ -110,6 +111,21 @@ public sealed class Step242LoopRoleNormalizationRegressionTests
Assert.DoesNotContain("TorusDegenerateMinorSpan", first.FirstDiagnostic.MessagePrefix, StringComparison.Ordinal);
}
+ [Theory]
+ [InlineData("testdata/step242/nist/CTC/nist_ctc_05_asme1_ap242-e1.stp")]
+ [InlineData("testdata/step242/nist/FTC/nist_ftc_11_asme1_ap242-e2.stp")]
+ public void Step242_PeriodicDegenerateNormalization_PreservesSharedClosedEdgeFaceUses_Deterministically(string relativePath)
+ {
+ var first = ImportFromCorpus(relativePath);
+ var second = ImportFromCorpus(relativePath);
+
+ var firstSignature = BuildSharedClosedEdgeUseSignature(first);
+ var secondSignature = BuildSharedClosedEdgeUseSignature(second);
+
+ Assert.NotEmpty(firstSignature);
+ Assert.Equal(firstSignature, secondSignature);
+ }
+
[Theory]
[InlineData("testdata/step242/nist/CTC/nist_ctc_04_asme1_ap242-e1.stp")]
[InlineData("testdata/step242/nist/FTC/nist_ftc_07_asme1_ap242-e2.stp")]
@@ -179,6 +195,45 @@ public sealed class Step242LoopRoleNormalizationRegressionTests
return diagnostics;
}
+ private static global::Aetheris.Kernel.Core.Brep.BrepBody ImportFromCorpus(string relativePath)
+ {
+ var absolutePath = Path.Combine(Step242CorpusManifestRunner.RepoRoot(), relativePath.Replace('/', Path.DirectorySeparatorChar));
+ var text = File.ReadAllText(absolutePath);
+ var import = Step242Importer.ImportBody(text);
+ Assert.True(import.IsSuccess);
+ return import.Value;
+ }
+
+ private static IReadOnlyList<string> BuildSharedClosedEdgeUseSignature(global::Aetheris.Kernel.Core.Brep.BrepBody body)
+ {
+ var faceUsesByEdge = new Dictionary<int, HashSet<int>>();
+ foreach (var face in body.Topology.Faces)
+ {
+ foreach (var loopId in face.LoopIds)
+ {
+ foreach (var coedgeId in body.GetCoedgeIds(loopId))
+ {
+ var coedge = body.Topology.GetCoedge(coedgeId);
+ if (!faceUsesByEdge.TryGetValue(coedge.EdgeId.Value, out var faceUses))
+ {
+ faceUses = [];
+ faceUsesByEdge.Add(coedge.EdgeId.Value, faceUses);
+ }
+
+ faceUses.Add(face.Id.Value);
+ }
+ }
+ }
+
+ return faceUsesByEdge
+ .Where(kvp => kvp.Value.Count == 2)
+ .Select(kvp => (Edge: body.Topology.GetEdge(new global::Aetheris.Kernel.Core.Topology.EdgeId(kvp.Key)), Faces: kvp.Value.OrderBy(v => v).ToArray()))
+ .Where(item => item.Edge.StartVertexId == item.Edge.EndVertexId)
+ .Select(item => $"edge:{item.Edge.Id.Value}:faces:{item.Faces[0]}-{item.Faces[1]}")
+ .OrderBy(v => v, StringComparer.Ordinal)
+ .ToArray();
+ }
+
private static IReadOnlyList<Step242Importer.LoopRoleCircularSamplingDiagnostic> CaptureCircularSampling(string relativePath)
{
var absolutePath = Path.Combine(Step242CorpusManifestRunner.RepoRoot(), relativePath.Replace('/', Path.DirectorySeparatorChar));
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242RevolvedTopologyFamilyRegressionTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242RevolvedTopologyFamilyRegressionTests.cs
index e3964265..78035b8e 100644
--- a/Aetheris.Kernel.Core.Tests/Step242/Step242RevolvedTopologyFamilyRegressionTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242RevolvedTopologyFamilyRegressionTests.cs
@@ -85,7 +85,7 @@ public sealed class Step242RevolvedTopologyFamilyRegressionTests
Assert.Equal(first.FirstDiagnostic.MessagePrefix, second.FirstDiagnostic.MessagePrefix);
Assert.DoesNotContain("unsupported subfamily 'circle-only seam reused loop'", first.FirstDiagnostic.MessagePrefix, StringComparison.Ordinal);
- Assert.StartsWith("Face 38 cylindrical trim loop 73 has 1 coedges, angular span", first.FirstDiagnostic.MessagePrefix, StringComparison.Ordinal);
+ Assert.StartsWith("Face 91 curved tessellation requires exactly one loop.", first.FirstDiagnostic.MessagePrefix, StringComparison.Ordinal);
}
[Theory]
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242UnsupportedSurfaceForHolesRegressionTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242UnsupportedSurfaceForHolesRegressionTests.cs
index 7b3725fa..ab7824a5 100644
--- a/Aetheris.Kernel.Core.Tests/Step242/Step242UnsupportedSurfaceForHolesRegressionTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242UnsupportedSurfaceForHolesRegressionTests.cs
@@ -9,8 +9,8 @@ public sealed class Step242UnsupportedSurfaceForHolesRegressionTests
"testdata/step242/nist/CTC/nist_ctc_05_asme1_ap242-e1.stp",
"tessellator",
"Importer.LoopRole.UnsupportedSurfaceForHoles",
- "Viewer.Tessellation.CylinderTrimAxialSpanDegenerate.SingleCoedgeNearFullWrap",
- "Face 38 cylindrical trim loop 73 has 1 coedges, angular span")]
+ "",
+ "Face 91 curved tessellation requires exactly one loop.")]
[InlineData(
"testdata/step242/nist/FTC/nist_ftc_08_asme1_ap242-e2.stp",
"tessellator",
@@ -21,14 +21,14 @@ public sealed class Step242UnsupportedSurfaceForHolesRegressionTests
"testdata/step242/nist/FTC/nist_ftc_11_asme1_ap242-e2.stp",
"tessellator",
"Topology.GraphValidator",
- "Viewer.Tessellation.CylinderTrimAxialSpanDegenerate.SingleCoedgeNearFullWrap",
- "Face 3 cylindrical trim loop 7 has 1 coedges, angular span")]
+ "",
+ "Face 4 curved tessellation requires exactly one loop.")]
[InlineData(
"testdata/step242/nist/STC/nist_stc_06_asme1_ap242-e3.stp",
"tessellator",
"Importer.LoopRole.UnsupportedSurfaceForHoles",
"",
- "Face 33 spherical trim loop must contain at least three coedges. Observed 1.")]
+ "Face 30 curved tessellation requires exactly one loop.")]
public void Step242_NistTargets_AdvancePastGenericUnsupportedSurfaceForHoles_Deterministically(
string relativePath,
string expectedLayer,
diff --git a/Aetheris.Kernel.Core/Step242/Step242Importer.cs b/Aetheris.Kernel.Core/Step242/Step242Importer.cs
index cd2b6d33..7a477eb0 100644
--- a/Aetheris.Kernel.Core/Step242/Step242Importer.cs
+++ b/Aetheris.Kernel.Core/Step242/Step242Importer.cs
@@ -1577,12 +1577,12 @@ public static class Step242Importer
if (degenerate.All(d => d.Analysis.Degeneracy == ConeProjectionDegeneracy.FullRevolutionConstantAxial))
{
- var canonical = degenerate
+ var preservedUses = degenerate
.OrderByDescending(d => d.Analysis.AxialMean)
.ThenBy(d => d.Loop.LoopId.Value)
.Select(d => d.Loop)
- .First();
- return KernelResult<IReadOnlyList<LoopBuildData>>.Success([canonical]);
+ .ToArray();
+ return KernelResult<IReadOnlyList<LoopBuildData>>.Success(preservedUses);
}
var primary = degenerate
@@ -1680,11 +1680,11 @@ public static class Step242Importer
{
if (degenerateAnalyses.Count > 0 && degenerateAnalyses.All(d => IsToroidalFullMajorRevolutionConstantMinor(d.Analysis)))
{
- var canonical = degenerateAnalyses
+ var preservedUses = degenerateAnalyses
.OrderBy(d => d.Loop.LoopId.Value)
.Select(d => d.Loop)
- .First();
- return KernelResult<IReadOnlyList<LoopBuildData>>.Success([canonical]);
+ .ToArray();
+ return KernelResult<IReadOnlyList<LoopBuildData>>.Success(preservedUses);
}
var primary = degenerateAnalyses
diff --git a/testdata/step242/manifests/nist.v0.report.json b/testdata/step242/manifests/nist.v0.report.json
index 11667bb1..0fb44b17 100644
--- a/testdata/step242/manifests/nist.v0.report.json
+++ b/testdata/step242/manifests/nist.v0.report.json
@@ -102,9 +102,9 @@
"status": "importFail",
"firstFailureLayer": "tessellator",
"firstDiagnostic": {
- "code": "InvalidArgument",
- "source": "Viewer.Tessellation.CylinderTrimAxialSpanDegenerate.SingleCoedgeNearFullWrap",
- "messagePrefix": "Face 38 cylindrical trim loop 73 has 1 coedges, angular span 6.1086523819801535, axial span 0, loop count 1; classified "
+ "code": "NotImplemented",
+ "source": "",
+ "messagePrefix": "Face 91 curved tessellation requires exactly one loop."
},
"diagnosticCount": 1,
"exceptionEscaped": false,
@@ -270,9 +270,9 @@
"status": "importFail",
"firstFailureLayer": "tessellator",
"firstDiagnostic": {
- "code": "InvalidArgument",
- "source": "Viewer.Tessellation.CylinderTrimAxialSpanDegenerate.SingleCoedgeNearFullWrap",
- "messagePrefix": "Face 3 cylindrical trim loop 7 has 1 coedges, angular span 6.1086523819801535, axial span 0, loop count 1; classified as"
+ "code": "NotImplemented",
+ "source": "",
+ "messagePrefix": "Face 4 curved tessellation requires exactly one loop."
},
"diagnosticCount": 1,
"exceptionEscaped": false,
@@ -296,7 +296,7 @@
"firstDiagnostic": {
"code": "NotImplemented",
"source": "",
- "messagePrefix": "Face 33 spherical trim loop must contain at least three coedges. Observed 1."
+ "messagePrefix": "Face 30 curved tessellation requires exactly one loop."
},
"diagnosticCount": 1,
"exceptionEscaped": false,