Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Fix VERTEX_LOOP vertex decode call and validate with .NET 8 tests

Yuechen Li1672df68ee91
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242ImporterTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242ImporterTests.cs
index 58f56c75..4d012570 100644
--- a/Aetheris.Kernel.Core.Tests/Step242/Step242ImporterTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242ImporterTests.cs
@@ -382,6 +382,36 @@ public sealed class Step242ImporterTests
Assert.NotEmpty(tessellation.Value.FacePatches);
}
+
+ [Fact]
+ public void Step242_HandcraftedSphereFixture_AcceptsVertexLoopFaceBound_AndImports()
+ {
+ var text = LoadFixture("testdata/step242/handcrafted/baseline/sphere.step");
+
+ var import = Step242Importer.ImportBody(text);
+
+ Assert.True(import.IsSuccess);
+ Assert.Single(import.Value.Topology.Faces);
+ var face = Assert.Single(import.Value.Topology.Faces);
+ Assert.Empty(import.Value.GetLoopIds(face.Id));
+ }
+
+ [Fact]
+ public void Step242_HandcraftedSphereFixture_AdvancesPastVertexLoopBlocker_AndTessellates()
+ {
+ var text = LoadFixture("testdata/step242/handcrafted/baseline/sphere.step");
+
+ var import = Step242Importer.ImportBody(text);
+ Assert.True(import.IsSuccess);
+
+ var tessellation = BrepDisplayTessellator.Tessellate(import.Value);
+
+ Assert.True(tessellation.IsSuccess);
+ Assert.DoesNotContain(tessellation.Diagnostics,
+ d => d.Message.Contains("expected 'EDGE_LOOP' but found 'VERTEX_LOOP'", StringComparison.Ordinal));
+ Assert.NotEmpty(tessellation.Value.FacePatches);
+ }
+
[Fact]
public void Step242_HandcraftedToroidFixture_UsesCircularSeamTopology_AndTessellates()
{
diff --git a/Aetheris.Kernel.Core/Step242/Step242Importer.cs b/Aetheris.Kernel.Core/Step242/Step242Importer.cs
index 80c2058e..a95f1aef 100644
--- a/Aetheris.Kernel.Core/Step242/Step242Importer.cs
+++ b/Aetheris.Kernel.Core/Step242/Step242Importer.cs
@@ -185,12 +185,41 @@ public static class Step242Importer
var boundOrientation = boundOrientationResult.Value;
- var loopEntityResult = document.TryGetEntity(loopRefResult.Value.TargetId, "EDGE_LOOP");
+ var loopEntityResult = document.TryGetEntity(loopRefResult.Value.TargetId);
if (!loopEntityResult.IsSuccess)
{
return KernelResult<BrepBody>.Failure(loopEntityResult.Diagnostics);
}
+ if (string.Equals(loopEntityResult.Value.Name, "VERTEX_LOOP", StringComparison.OrdinalIgnoreCase))
+ {
+ if (!isSphericalFace)
+ {
+ return Failure("FACE_BOUND loop type 'VERTEX_LOOP' is unsupported for non-spherical faces in M23 import subset.", $"Entity:{loopEntityResult.Value.Id}");
+ }
+
+ var vertexLoopRefResult = Step242SubsetDecoder.ReadReference(loopEntityResult.Value, 1, "VERTEX_LOOP vertex");
+ if (!vertexLoopRefResult.IsSuccess)
+ {
+ return KernelResult<BrepBody>.Failure(vertexLoopRefResult.Diagnostics);
+ }
+
+ var vertexPointResult = Step242SubsetDecoder.ReadVertexPoint(document, vertexLoopRefResult.Value.TargetId);
+ if (!vertexPointResult.IsSuccess)
+ {
+ return KernelResult<BrepBody>.Failure(vertexPointResult.Diagnostics);
+ }
+
+ // Singular spherical bounds can be represented with VERTEX_LOOP. They do not map
+ // to edge/coedge topology in the current subset, so they are treated as degenerate trims.
+ continue;
+ }
+
+ if (!string.Equals(loopEntityResult.Value.Name, "EDGE_LOOP", StringComparison.OrdinalIgnoreCase))
+ {
+ return Failure($"FACE_BOUND loop type '{loopEntityResult.Value.Name}' is unsupported in M23 import subset.", $"Entity:{loopEntityResult.Value.Id}");
+ }
+
var orientedEdgeRefsResult = Step242SubsetDecoder.ReadReferenceList(loopEntityResult.Value, 1, "EDGE_LOOP coedges");
if (!orientedEdgeRefsResult.IsSuccess)
{