Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Add AP242 toroidal surface export support
Yuechen Li1b4c58d440a6
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242BSplineSurfaceWithKnotsTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242BSplineSurfaceWithKnotsTests.csindex d718fe22..84dc06aa 100644--- a/Aetheris.Kernel.Core.Tests/Step242/Step242BSplineSurfaceWithKnotsTests.cs+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242BSplineSurfaceWithKnotsTests.cs@@ -109,7 +109,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/STC/nist_stc_08_asme1_ap242-e3.stp", "exporter", "", "Unsupported surface kind 'Torus'.")]+ [InlineData("testdata/step242/nist/STC/nist_stc_08_asme1_ap242-e3.stp", "", "Audit.None", "No diagnostics.")]public void Step242_TrimmedSphereTargets_AdvancePastOldUntrimmedSphereBlocker_AndRemainDeterministic(string relativePath,string expectedLayer,diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242ConicalSurfaceRegressionTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242ConicalSurfaceRegressionTests.csindex 4f2509ff..c90d6f01 100644--- a/Aetheris.Kernel.Core.Tests/Step242/Step242ConicalSurfaceRegressionTests.cs+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242ConicalSurfaceRegressionTests.cs@@ -81,7 +81,7 @@ public sealed class Step242ConicalSurfaceRegressionTests[InlineData("testdata/step242/nist/CTC/nist_ctc_01_asme1_ap242-e1.stp", "", "Audit.None", "No diagnostics.")][InlineData("testdata/step242/nist/CTC/nist_ctc_02_asme1_ap242-e2.stp", "", "Audit.None", "No diagnostics.")][InlineData("testdata/step242/nist/CTC/nist_ctc_03_asme1_ap242-e2.stp", "", "", "")]- [InlineData("testdata/step242/nist/CTC/nist_ctc_04_asme1_ap242-e1.stp", "exporter", "", "Unsupported surface kind 'Torus'.")]+ [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", "tessellator", "", "Face 12 spherical trim loop must contain at least three coedges. Observed")][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 ")]diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242ExporterTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242ExporterTests.csindex 886ffabc..f34b9368 100644--- a/Aetheris.Kernel.Core.Tests/Step242/Step242ExporterTests.cs+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242ExporterTests.cs@@ -80,6 +80,42 @@ END-ISO-10303-21;";Assert.Contains("CYLINDRICAL_SURFACE", export.Value, StringComparison.Ordinal);}++ [Fact]+ public void ExportBody_ImportedToroidalFace_EmitsToroidalSurface()+ {+ const string toroidalFace = @"ISO-10303-21;+HEADER;+ENDSEC;+DATA;+#1=MANIFOLD_SOLID_BREP('solid',#2);+#2=CLOSED_SHELL($,(#3));+#3=ADVANCED_FACE((#4),#5,.T.);+#4=FACE_OUTER_BOUND($,#6,.T.);+#5=TOROIDAL_SURFACE($,#30,5.0,1.0);+#6=EDGE_LOOP($,(#7,#8));+#7=ORIENTED_EDGE($,$,$,#9,.T.);+#8=ORIENTED_EDGE($,$,$,#10,.F.);+#9=EDGE_CURVE($,#11,#11,#12,.T.);+#10=EDGE_CURVE($,#11,#11,#12,.T.);+#11=VERTEX_POINT($,#13);+#12=CIRCLE($,#30,4.0);+#13=CARTESIAN_POINT($,(4,0,0));+#30=AXIS2_PLACEMENT_3D($,#31,#32,#33);+#31=CARTESIAN_POINT($,(0,0,0));+#32=DIRECTION($,(0,0,1));+#33=DIRECTION($,(1,0,0));+ENDSEC;+END-ISO-10303-21;";++ var import = Step242Importer.ImportBody(toroidalFace);+ Assert.True(import.IsSuccess);++ var export = Step242Exporter.ExportBody(import.Value);+ Assert.True(export.IsSuccess);+ Assert.Contains("TOROIDAL_SURFACE", export.Value, StringComparison.Ordinal);+ }+[Fact]public void ExportBody_ImportedConicalFace_EmitsConicalSurfaceWithCanonicalRadianSemiAngle(){diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242RevolvedTopologyFamilyRegressionTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242RevolvedTopologyFamilyRegressionTests.csindex 47c0eb5b..38920a05 100644--- a/Aetheris.Kernel.Core.Tests/Step242/Step242RevolvedTopologyFamilyRegressionTests.cs+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242RevolvedTopologyFamilyRegressionTests.cs@@ -5,7 +5,7 @@ namespace Aetheris.Kernel.Core.Tests.Step242;public sealed class Step242RevolvedTopologyFamilyRegressionTests{[Theory]- [InlineData("testdata/step242/nist/CTC/nist_ctc_04_asme1_ap242-e1.stp", "Unsupported surface kind 'Torus'.")]+ [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 129 curved tessellation supports selected repeated cone/revolved boundary subfamilies; unsupported subfamily 'four-coedge mixed line/bspline revolved loop'. Observed")][InlineData("testdata/step242/nist/FTC/nist_ftc_10_asme1_ap242-e2.stp", "Face 67 curved tessellation supports selected repeated torus/revolved boundary subfamilies; unsupported subfamily 'other (coedges=5, uniqueEdges=5)'. Observed")]public void Step242_RepeatedCurvedRevolvedTargets_AdvanceWithExplicitDeterministicNextBlocker(@@ -64,7 +64,7 @@ public sealed class Step242RevolvedTopologyFamilyRegressionTests[Theory][InlineData("testdata/step242/nist/FTC/nist_ftc_06_asme1_ap242-e2.stp", "Face 12 spherical trim loop must contain at least three coedges. Observed")]- [InlineData("testdata/step242/nist/STC/nist_stc_08_asme1_ap242-e3.stp", "Unsupported surface kind 'Torus'.")]+ [InlineData("testdata/step242/nist/STC/nist_stc_08_asme1_ap242-e3.stp", "No diagnostics.")]public void Step242_RevolvedTopologyFamilyBlockers_StayDeterministic_AndRemainExplicit(string relativePath, string expectedMessagePrefix){var entry = new Step242CorpusManifestEntry(diff --git a/Aetheris.Kernel.Core/Step242/Step242Exporter.cs b/Aetheris.Kernel.Core/Step242/Step242Exporter.csindex e566fb0f..07e632cd 100644--- a/Aetheris.Kernel.Core/Step242/Step242Exporter.cs+++ b/Aetheris.Kernel.Core/Step242/Step242Exporter.cs@@ -167,6 +167,12 @@ public static class Step242Exporterreturn writer.AddEntity("SPHERICAL_SURFACE", "$", Step242TextWriter.Ref(axisPlacementId), Step242TextWriter.Number(sphere.Radius));}+ private static string BuildTorus(Step242TextWriter writer, TorusSurface torus)+ {+ var axisPlacementId = BuildAxisPlacement(writer, torus.Center, torus.Axis, torus.XAxis);+ return writer.AddEntity("TOROIDAL_SURFACE", "$", Step242TextWriter.Ref(axisPlacementId), Step242TextWriter.Number(torus.MajorRadius), Step242TextWriter.Number(torus.MinorRadius));+ }+private static string BuildBSplineSurfaceWithKnots(Step242TextWriter writer, BSplineSurfaceWithKnots surface){var controlPointRows = surface.ControlPoints@@ -214,6 +220,7 @@ public static class Step242ExporterSurfaceGeometryKind.Cylinder when surface.Cylinder is CylinderSurface cylinder => KernelResult<string>.Success(BuildCylinder(writer, cylinder)),SurfaceGeometryKind.Cone when surface.Cone is ConeSurface cone => KernelResult<string>.Success(BuildCone(writer, cone)),SurfaceGeometryKind.Sphere when surface.Sphere is SphereSurface sphere => KernelResult<string>.Success(BuildSphere(writer, sphere)),+ SurfaceGeometryKind.Torus when surface.Torus is TorusSurface torus => KernelResult<string>.Success(BuildTorus(writer, torus)),SurfaceGeometryKind.BSplineSurfaceWithKnots when surface.BSplineSurfaceWithKnots is BSplineSurfaceWithKnots bSplineSurface => KernelResult<string>.Success(BuildBSplineSurfaceWithKnots(writer, bSplineSurface)),_ => Failure($"Unsupported surface kind '{surface.Kind}'.", $"Face:{faceId.Value}")};diff --git a/testdata/step242/manifests/nist.v0.report.json b/testdata/step242/manifests/nist.v0.report.jsonindex 1498ea54..33aa343a 100644--- a/testdata/step242/manifests/nist.v0.report.json+++ b/testdata/step242/manifests/nist.v0.report.json@@ -75,14 +75,14 @@"fileId": "testdata_step242_nist_CTC_nist_ctc_04_asme1_ap242-e1","path": "testdata/step242/nist/CTC/nist_ctc_04_asme1_ap242-e1.stp","sizeBytes": 1265846,- "status": "importFail",- "firstFailureLayer": "exporter",+ "status": "success",+ "firstFailureLayer": "","firstDiagnostic": {- "code": "NotImplemented",- "source": "Face:252",- "messagePrefix": "Unsupported surface kind \u0027Torus\u0027."+ "code": "Unknown",+ "source": "Audit.None",+ "messagePrefix": "No diagnostics."},- "diagnosticCount": 1,+ "diagnosticCount": 0,"exceptionEscaped": false,"topologyCounts": {"vertices": 664,@@ -93,7 +93,7 @@"facePatches": 484,"edgePolylines": 1110},- "canonicalSha256": null+ "canonicalSha256": "3103da3bc3e8ad82026a4cd1debfea1ac2978ced50fb4a722ec82d732b1882ae"},{"fileId": "testdata_step242_nist_CTC_nist_ctc_05_asme1_ap242-e1",@@ -339,14 +339,14 @@"fileId": "testdata_step242_nist_STC_nist_stc_08_asme1_ap242-e3","path": "testdata/step242/nist/STC/nist_stc_08_asme1_ap242-e3.stp","sizeBytes": 2239112,- "status": "importFail",- "firstFailureLayer": "exporter",+ "status": "success",+ "firstFailureLayer": "","firstDiagnostic": {- "code": "NotImplemented",- "source": "Face:62",- "messagePrefix": "Unsupported surface kind \u0027Torus\u0027."+ "code": "Unknown",+ "source": "Audit.None",+ "messagePrefix": "No diagnostics."},- "diagnosticCount": 1,+ "diagnosticCount": 0,"exceptionEscaped": false,"topologyCounts": {"vertices": 446,@@ -357,7 +357,7 @@"facePatches": 271,"edgePolylines": 709},- "canonicalSha256": null+ "canonicalSha256": "df51040864fadab2d106c45a9610a20edc5944f518c90be82e0e7c734457ae35"},{"fileId": "testdata_step242_nist_STC_nist_stc_09_asme1_ap242-e3",