Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Handle EDGE_CURVE same_sense false orientation in importer

Yuechen Lif4f995b70a6a
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242EdgeCurveSenseRegressionTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242EdgeCurveSenseRegressionTests.cs
new file mode 100644
index 00000000..946c8b88
--- /dev/null
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242EdgeCurveSenseRegressionTests.cs
@@ -0,0 +1,36 @@
+using Aetheris.Kernel.Core.Step242;
+
+namespace Aetheris.Kernel.Core.Tests.Step242;
+
+public sealed class Step242EdgeCurveSenseRegressionTests
+{
+ [Theory]
+ [InlineData("testdata/step242/nist/FTC/nist_ftc_08_asme1_ap242-e2.stp", "Importer.LoopRole.CylinderMappingFailed", "Cylinder multi-loop hole classification is not yet safely supported.")]
+ [InlineData("testdata/step242/nist/FTC/nist_ftc_11_asme1_ap242-e2.stp", "Importer.LoopRole.InnerDisjointAfterNormalization", "Inner loop could not be normalized")]
+ public void Step242_NistEdgeCurveSenseTargets_AdvanceToNextBlocker_Deterministically(
+ string relativePath,
+ string expectedSource,
+ string expectedMessagePrefix)
+ {
+ var entry = new Step242CorpusManifestEntry(
+ Id: Path.GetFileNameWithoutExtension(relativePath),
+ Path: relativePath,
+ Group: "nist-edge-orientation-regression",
+ Notes: "regression",
+ ExpectedFirstDiagnostic: null,
+ ExpectHashStableAfterCanonicalization: null,
+ ExpectTopologyCounts: null,
+ ExpectGeometryKinds: null);
+
+ var first = Step242CorpusManifestRunner.RunOne(entry);
+ var second = Step242CorpusManifestRunner.RunOne(entry);
+
+ Assert.NotEqual("Importer.Orientation.EdgeCurveSense", first.FirstDiagnostic.Source);
+ Assert.Equal(expectedSource, first.FirstDiagnostic.Source);
+ Assert.StartsWith(expectedMessagePrefix, first.FirstDiagnostic.MessagePrefix, StringComparison.Ordinal);
+
+ Assert.Equal(first.FirstFailureLayer, second.FirstFailureLayer);
+ Assert.Equal(first.FirstDiagnostic.Source, second.FirstDiagnostic.Source);
+ Assert.Equal(first.FirstDiagnostic.MessagePrefix, second.FirstDiagnostic.MessagePrefix);
+ }
+}
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242OrientationSemanticsTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242OrientationSemanticsTests.cs
index 76b9d70b..cecc8957 100644
--- a/Aetheris.Kernel.Core.Tests/Step242/Step242OrientationSemanticsTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242OrientationSemanticsTests.cs
@@ -52,6 +52,26 @@ public sealed class Step242OrientationSemanticsTests
Assert.Equal(-1d, reversedSurface!.Plane!.Value.Normal.Z);
}
+ [Fact]
+ public void ImportBody_EdgeCurveSameSenseFalse_WithOppositeLineDirection_ImportsSuccessfully()
+ {
+ var result = Step242Importer.ImportBody(BuildSingleEdgeStep(edgeCurveSameSense: false, orientedEdgeOrientation: true, lineDirectionX: -1d));
+
+ Assert.True(result.IsSuccess, string.Join(" | ", result.Diagnostics.Select(d => $"{d.Source}:{d.Message}")));
+ Assert.Empty(result.Diagnostics);
+ }
+
+ [Fact]
+ public void ImportBody_EdgeCurveSameSenseTrue_WithOppositeLineDirection_ReturnsGeometryDiagnostic()
+ {
+ var result = Step242Importer.ImportBody(BuildSingleEdgeStep(edgeCurveSameSense: true, orientedEdgeOrientation: true, lineDirectionX: -1d));
+
+ Assert.False(result.IsSuccess);
+ var first = Assert.Single(result.Diagnostics);
+ Assert.Equal("Importer.Geometry.EdgeCurveParameters", first.Source);
+ Assert.Contains("opposite to vertex ordering", first.Message, StringComparison.Ordinal);
+ }
+
[Fact]
public void ImportBody_OrientationTypeMismatch_ReturnsDiagnosticsWithoutThrowing()
{
@@ -67,10 +87,17 @@ public sealed class Step242OrientationSemanticsTests
private static string BuildSingleTriangleStep(bool edgeCurveSameSense, bool faceBoundOrientation, bool advancedFaceSameSense)
{
- var edgeSense = edgeCurveSameSense ? ".T." : ".F.";
var boundOrientation = faceBoundOrientation ? ".T." : ".F.";
var faceSense = advancedFaceSameSense ? ".T." : ".F.";
+ return BuildSingleEdgeStep(edgeCurveSameSense, orientedEdgeOrientation: true, lineDirectionX: 1d, boundOrientation, faceSense);
+ }
- return $"ISO-10303-21;\nHEADER;\nENDSEC;\nDATA;\n#1=MANIFOLD_SOLID_BREP('solid',#2);\n#2=CLOSED_SHELL($,(#3));\n#3=ADVANCED_FACE((#4),#5,{faceSense});\n#4=FACE_OUTER_BOUND($,#6,{boundOrientation});\n#5=PLANE($,#20);\n#6=EDGE_LOOP($,(#7));\n#7=ORIENTED_EDGE($,$,$,#8,.T.);\n#8=EDGE_CURVE($,#9,#10,#11,{edgeSense});\n#9=VERTEX_POINT($,#12);\n#10=VERTEX_POINT($,#13);\n#11=LINE($,#12,#14);\n#12=CARTESIAN_POINT($,(0,0,0));\n#13=CARTESIAN_POINT($,(1,0,0));\n#14=VECTOR($,#15,1.0);\n#15=DIRECTION($,(1,0,0));\n#20=AXIS2_PLACEMENT_3D($,#12,#21,#22);\n#21=DIRECTION($,(0,0,1));\n#22=DIRECTION($,(1,0,0));\nENDSEC;\nEND-ISO-10303-21;";
+ private static string BuildSingleEdgeStep(bool edgeCurveSameSense, bool orientedEdgeOrientation, double lineDirectionX, string boundOrientation = ".T.", string faceSense = ".T.")
+ {
+ var edgeSense = edgeCurveSameSense ? ".T." : ".F.";
+ var orientedSense = orientedEdgeOrientation ? ".T." : ".F.";
+
+ return $"ISO-10303-21;\nHEADER;\nENDSEC;\nDATA;\n#1=MANIFOLD_SOLID_BREP('solid',#2);\n#2=CLOSED_SHELL($,(#3));\n#3=ADVANCED_FACE((#4),#5,{faceSense});\n#4=FACE_OUTER_BOUND($,#6,{boundOrientation});\n#5=PLANE($,#20);\n#6=EDGE_LOOP($,(#7));\n#7=ORIENTED_EDGE($,$,$,#8,{orientedSense});\n#8=EDGE_CURVE($,#9,#10,#11,{edgeSense});\n#9=VERTEX_POINT($,#12);\n#10=VERTEX_POINT($,#13);\n#11=LINE($,#12,#14);\n#12=CARTESIAN_POINT($,(0,0,0));\n#13=CARTESIAN_POINT($,(1,0,0));\n#14=VECTOR($,#15,1.0);\n#15=DIRECTION($,({lineDirectionX},0,0));\n#20=AXIS2_PLACEMENT_3D($,#12,#21,#22);\n#21=DIRECTION($,(0,0,1));\n#22=DIRECTION($,(1,0,0));\nENDSEC;\nEND-ISO-10303-21;";
}
+
}
diff --git a/Aetheris.Kernel.Core/Step242/Step242Importer.cs b/Aetheris.Kernel.Core/Step242/Step242Importer.cs
index 295a5b08..41142bad 100644
--- a/Aetheris.Kernel.Core/Step242/Step242Importer.cs
+++ b/Aetheris.Kernel.Core/Step242/Step242Importer.cs
@@ -483,14 +483,14 @@ public static class Step242Importer
if (endParameter < startParameter)
{
- if (!edgeSameSense)
+ if (edgeSameSense)
{
- return OrientationFailure<(CurveGeometry CurveGeometry, ParameterInterval TrimInterval)>(
- "EDGE_CURVE same_sense semantics unsupported for this edge",
- SourceFor(edgeCurveEntityId, "Importer.Orientation.EdgeCurveSense"));
+ return FailureCurveBinding("EDGE_CURVE line parameterization is opposite to vertex ordering.", SourceFor(edgeCurveEntityId, "Importer.Geometry.EdgeCurveParameters"));
}
- return FailureCurveBinding("EDGE_CURVE line parameterization is opposite to vertex ordering.", SourceFor(edgeCurveEntityId, "Importer.Geometry.EdgeCurveParameters"));
+ return KernelResult<(CurveGeometry CurveGeometry, ParameterInterval TrimInterval)>.Success((
+ CurveGeometry.FromLine(lineResult.Value),
+ new ParameterInterval(endParameter, startParameter)));
}
return KernelResult<(CurveGeometry CurveGeometry, ParameterInterval TrimInterval)>.Success((
diff --git a/testdata/step242/manifests/nist.v0.report.json b/testdata/step242/manifests/nist.v0.report.json
index e9b7b283..7fd1800c 100644
--- a/testdata/step242/manifests/nist.v0.report.json
+++ b/testdata/step242/manifests/nist.v0.report.json
@@ -199,8 +199,8 @@
"firstFailureLayer": "importer-topology",
"firstDiagnostic": {
"code": "ValidationFailed",
- "source": "Importer.Orientation.EdgeCurveSense",
- "messagePrefix": "EDGE_CURVE same_sense semantics unsupported for this edge"
+ "source": "Importer.LoopRole.CylinderMappingFailed",
+ "messagePrefix": "Cylinder multi-loop hole classification is not yet safely supported."
},
"diagnosticCount": 1,
"exceptionEscaped": false,
@@ -271,8 +271,8 @@
"firstFailureLayer": "importer-topology",
"firstDiagnostic": {
"code": "ValidationFailed",
- "source": "Importer.Orientation.EdgeCurveSense",
- "messagePrefix": "EDGE_CURVE same_sense semantics unsupported for this edge"
+ "source": "Importer.LoopRole.InnerDisjointAfterNormalization",
+ "messagePrefix": "Inner loop could not be normalized"
},
"diagnosticCount": 1,
"exceptionEscaped": false,