Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
M47b: allow inline CYLINDRICAL_SURFACE in ADVANCED_FACE.surface with deterministic guards
Yuechen Lieec7bf7851c1
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242ImporterTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242ImporterTests.csindex 8b2ae01d..fec8fa61 100644--- a/Aetheris.Kernel.Core.Tests/Step242/Step242ImporterTests.cs+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242ImporterTests.cs@@ -2,6 +2,7 @@ using System.Text;using Aetheris.Kernel.Core.Brep;using Aetheris.Kernel.Core.Brep.Tessellation;using Aetheris.Kernel.Core.Diagnostics;+using Aetheris.Kernel.Core.Geometry;using Aetheris.Kernel.Core.Step242;namespace Aetheris.Kernel.Core.Tests.Step242;@@ -145,9 +146,31 @@ public sealed class Step242ImporterTests}[Fact]- public void Step242_AdvancedFace_Surface_RejectsInlineNonPlaneSurface()+ public void Step242_AdvancedFace_Surface_AllowsInlineCylindricalSurfaceConstructor(){- var text = LoadFixture("testdata/step242/syntax-robustness/advanced-face-inline-non-plane.step");+ var text = LoadFixture("testdata/step242/syntax-robustness/advanced-face-inline-cylinder.step");++ var parseResult = Step242SubsetParser.Parse(text);+ Assert.True(parseResult.IsSuccess);++ var import = Step242Importer.ImportBody(text);++ Assert.DoesNotContain(import.Diagnostics, d => d.Source is not null && d.Source.StartsWith("Parser", StringComparison.Ordinal));+ Assert.DoesNotContain(import.Diagnostics, d => string.Equals(d.Source, "Importer.StepSyntax.InlineEntity", StringComparison.Ordinal));++ if (!import.IsSuccess)+ {+ Assert.NotEmpty(import.Diagnostics);+ return;+ }++ Assert.Contains(import.Value.Geometry.Surfaces, s => s.Value.Kind == SurfaceGeometryKind.Cylinder);+ }++ [Fact]+ public void Step242_AdvancedFace_Surface_RejectsInlineCylinderMalformedArgs()+ {+ var text = LoadFixture("testdata/step242/syntax-robustness/advanced-face-inline-cylinder-malformed.step");var parseResult = Step242SubsetParser.Parse(text);Assert.True(parseResult.IsSuccess);@@ -158,7 +181,7 @@ public sealed class Step242ImporterTestsvar diagnostic = Assert.Single(import.Diagnostics);Assert.Equal(KernelDiagnosticCode.NotImplemented, diagnostic.Code);Assert.Equal("Importer.StepSyntax.InlineEntity", diagnostic.Source);- Assert.Equal("ADVANCED_FACE surface: inline constructor 'CYLINDRICAL_SURFACE' is unsupported in M47a (only PLANE is allowed).", diagnostic.Message);+ Assert.StartsWith("Inline ADVANCED_FACE.surface constructor 'CYLINDRICAL_SURFACE' has unsupported argument shape.", diagnostic.Message, StringComparison.Ordinal);}private static string LoadFixture(string relativePath)diff --git a/Aetheris.Kernel.Core/Step242/Step242Importer.cs b/Aetheris.Kernel.Core/Step242/Step242Importer.csindex 3e831cb8..49adad10 100644--- a/Aetheris.Kernel.Core/Step242/Step242Importer.cs+++ b/Aetheris.Kernel.Core/Step242/Step242Importer.cs@@ -584,9 +584,10 @@ public static class Step242Importerreturn FailureInlineSurface<Step242ParsedEntity>("ADVANCED_FACE surface: inline constructor arguments are required.", SourceFor(faceEntityId, "Importer.StepSyntax.InlineEntity"));}- if (!string.Equals(surfaceName, "PLANE", StringComparison.Ordinal))+ if (!string.Equals(surfaceName, "PLANE", StringComparison.Ordinal)+ && !string.Equals(surfaceName, "CYLINDRICAL_SURFACE", StringComparison.Ordinal)){- return FailureInlineSurface<Step242ParsedEntity>($"ADVANCED_FACE surface: inline constructor '{surfaceName}' is unsupported in M47a (only PLANE is allowed).", SourceFor(faceEntityId, "Importer.StepSyntax.InlineEntity"));+ return FailureInlineSurface<Step242ParsedEntity>($"ADVANCED_FACE surface: inline constructor '{surfaceName}' is not supported in this subset.", SourceFor(faceEntityId, "Importer.StepSyntax.InlineEntity"));}var normalizedArgumentsResult = NormalizeInlineSurfaceArguments(surfaceName, inlineArguments, faceEntityId);@@ -630,6 +631,35 @@ public static class Step242Importerreturn FailureInlineSurface<IReadOnlyList<Step242Value>>("ADVANCED_FACE surface: inline PLANE constructor expects PLANE(#axis2_placement_3d).", SourceFor(faceEntityId, "Importer.StepSyntax.InlineEntity"));}+ if (string.Equals(surfaceName, "CYLINDRICAL_SURFACE", StringComparison.Ordinal))+ {+ if (inlineArguments.Count == 2)+ {+ if (inlineArguments[0] is not Step242EntityReference || inlineArguments[1] is not Step242NumberValue)+ {+ return FailureInlineSurface<IReadOnlyList<Step242Value>>("Inline ADVANCED_FACE.surface constructor 'CYLINDRICAL_SURFACE' has unsupported argument shape.", SourceFor(faceEntityId, "Importer.StepSyntax.InlineEntity"));+ }++ return KernelResult<IReadOnlyList<Step242Value>>.Success([+ Step242OmittedValue.Instance,+ inlineArguments[0],+ inlineArguments[1]+ ]);+ }++ if (inlineArguments.Count == 3)+ {+ if (inlineArguments[0] is not Step242OmittedValue || inlineArguments[1] is not Step242EntityReference || inlineArguments[2] is not Step242NumberValue)+ {+ return FailureInlineSurface<IReadOnlyList<Step242Value>>("Inline ADVANCED_FACE.surface constructor 'CYLINDRICAL_SURFACE' has unsupported argument shape.", SourceFor(faceEntityId, "Importer.StepSyntax.InlineEntity"));+ }++ return KernelResult<IReadOnlyList<Step242Value>>.Success(inlineArguments);+ }++ return FailureInlineSurface<IReadOnlyList<Step242Value>>("Inline ADVANCED_FACE.surface constructor 'CYLINDRICAL_SURFACE' has unsupported argument shape.", SourceFor(faceEntityId, "Importer.StepSyntax.InlineEntity"));+ }+return KernelResult<IReadOnlyList<Step242Value>>.Success(inlineArguments);}diff --git a/docs/support-matrix-step242-v0.md b/docs/support-matrix-step242-v0.mdindex 7b68dc95..2c8b6edd 100644--- a/docs/support-matrix-step242-v0.md+++ b/docs/support-matrix-step242-v0.md@@ -10,7 +10,7 @@ Aetheris STEP242 v0 is intentionally narrow and deterministic.- Exporter line-edge consistency: for exported `EDGE_CURVE` instances backed by `LINE`, both referenced vertex points are guaranteed to lie on the exported line geometry within export tolerance.- STEP Part 21 complex entity-instance assignments are accepted for parser/decoder context use (for example `#5=(GEOMETRIC_REPRESENTATION_CONTEXT(...)...REPRESENTATION_CONTEXT(...));`).- STEP Part 21 typed parameter values are supported in value position with deterministic normalization (`IDENT(...)` parsed as uppercase identifier + argument list), including common nested wrappers such as `LENGTH_MEASURE(...)` and `LENGTH_MEASURE_WITH_UNIT(LENGTH_MEASURE(...),#...)`.-- `ADVANCED_FACE.surface` accepts either a `#entity` reference or a limited inline surface constructor (`PLANE(...)` only in M47a).+- `ADVANCED_FACE.surface` accepts either a `#entity` reference or a limited inline surface constructor (`PLANE(...)` and `CYLINDRICAL_SURFACE(...)` in M47b).## Supported entity families (Tier1)@@ -33,7 +33,7 @@ Aetheris STEP242 v0 is intentionally narrow and deterministic.- Toroidal and other exotic analytic surface support.- Any modeling/editor feature expansion in the Viewer tab.- Typed wrapper decoding is intentionally limited in v0: primitive readers currently unwrap single-argument typed values; wrappers with unexpected arity fail deterministically via `Importer.StepSyntax.TypedValue`.-- Inline surface constructors are intentionally limited in v0: only `ADVANCED_FACE.surface = PLANE(...)` is accepted in M47a; other inline surface constructors fail deterministically via `Importer.StepSyntax.InlineEntity`.+- Inline surface constructors are intentionally limited in v0: `ADVANCED_FACE.surface = PLANE(...)` and `ADVANCED_FACE.surface = CYLINDRICAL_SURFACE(...)` are accepted in M47b; other inline surface constructors fail deterministically via `Importer.StepSyntax.InlineEntity`.## Corpus and CI gatediff --git a/testdata/step242/syntax-robustness/advanced-face-inline-cylinder-malformed.step b/testdata/step242/syntax-robustness/advanced-face-inline-cylinder-malformed.stepnew file mode 100644index 00000000..5d5fdac8--- /dev/null+++ b/testdata/step242/syntax-robustness/advanced-face-inline-cylinder-malformed.step@@ -0,0 +1,21 @@+ISO-10303-21;+HEADER;+ENDSEC;+DATA;+#1=MANIFOLD_SOLID_BREP('solid',#2);+#2=CLOSED_SHELL($,(#3));+#3=ADVANCED_FACE((#4),CYLINDRICAL_SURFACE(#30),.T.);+#4=FACE_OUTER_BOUND($,#6,.T.);+#6=EDGE_LOOP($,(#7));+#7=ORIENTED_EDGE($,$,$,#8,.T.);+#8=EDGE_CURVE($,#9,#9,#11,.T.);+#9=VERTEX_POINT($,#12);+#11=CIRCLE($,#31,1.0);+#12=CARTESIAN_POINT($,(1,0,0));+#30=AXIS2_PLACEMENT_3D($,#14,#15,#16);+#31=AXIS2_PLACEMENT_3D($,#14,#15,#16);+#14=CARTESIAN_POINT($,(0,0,0));+#15=DIRECTION($,(0,0,1));+#16=DIRECTION($,(1,0,0));+ENDSEC;+END-ISO-10303-21;diff --git a/testdata/step242/syntax-robustness/advanced-face-inline-cylinder.step b/testdata/step242/syntax-robustness/advanced-face-inline-cylinder.stepnew file mode 100644index 00000000..afa6930f--- /dev/null+++ b/testdata/step242/syntax-robustness/advanced-face-inline-cylinder.step@@ -0,0 +1,37 @@+ISO-10303-21;+HEADER;+ENDSEC;+DATA;+#1=MANIFOLD_SOLID_BREP('solid',#2);+#2=CLOSED_SHELL($,(#3));+#3=ADVANCED_FACE((#4),CYLINDRICAL_SURFACE($,#30,1.0),.T.);+#4=FACE_OUTER_BOUND($,#6,.T.);+#6=EDGE_LOOP($,(#7,#8,#9,#10));+#7=ORIENTED_EDGE($,$,$,#11,.T.);+#8=ORIENTED_EDGE($,$,$,#12,.T.);+#9=ORIENTED_EDGE($,$,$,#13,.T.);+#10=ORIENTED_EDGE($,$,$,#14,.T.);+#11=EDGE_CURVE($,#15,#16,#17,.T.);+#12=EDGE_CURVE($,#16,#16,#18,.T.);+#13=EDGE_CURVE($,#16,#15,#19,.T.);+#14=EDGE_CURVE($,#15,#15,#20,.T.);+#15=VERTEX_POINT($,#21);+#16=VERTEX_POINT($,#22);+#17=LINE($,#21,#23);+#18=CIRCLE($,#31,1.0);+#19=LINE($,#22,#24);+#20=CIRCLE($,#30,1.0);+#21=CARTESIAN_POINT($,(1,0,0));+#22=CARTESIAN_POINT($,(1,0,1));+#23=VECTOR($,#25,1.0);+#24=VECTOR($,#26,1.0);+#25=DIRECTION($,(0,0,1));+#26=DIRECTION($,(0,0,-1));+#30=AXIS2_PLACEMENT_3D($,#27,#28,#29);+#31=AXIS2_PLACEMENT_3D($,#32,#28,#29);+#32=CARTESIAN_POINT($,(0,0,1));+#27=CARTESIAN_POINT($,(0,0,0));+#28=DIRECTION($,(0,0,1));+#29=DIRECTION($,(1,0,0));+ENDSEC;+END-ISO-10303-21;