Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
M47d: allow inline SPHERICAL_SURFACE in ADVANCED_FACE.surface
Yuechen Lif3ce94280c35
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242InlineSurfaceConstructorTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242InlineSurfaceConstructorTests.csnew file mode 100644index 00000000..1e1035e8--- /dev/null+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242InlineSurfaceConstructorTests.cs@@ -0,0 +1,54 @@+using System.Text;+using Aetheris.Kernel.Core.Diagnostics;+using Aetheris.Kernel.Core.Geometry;+using Aetheris.Kernel.Core.Step242;++namespace Aetheris.Kernel.Core.Tests.Step242;++public sealed class Step242InlineSurfaceConstructorTests+{+ [Fact]+ public void Step242_AdvancedFace_Surface_AllowsInlineSphericalSurfaceConstructor()+ {+ var text = LoadFixture("testdata/step242/syntax-robustness/advanced-face-inline-sphere-valid.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.Sphere);+ }++ [Fact]+ public void Step242_AdvancedFace_Surface_RejectsMalformedInlineSphericalSurfaceConstructor()+ {+ var text = LoadFixture("testdata/step242/syntax-robustness/advanced-face-inline-sphere-malformed.step");++ var parseResult = Step242SubsetParser.Parse(text);+ Assert.True(parseResult.IsSuccess);++ var import = Step242Importer.ImportBody(text);++ Assert.False(import.IsSuccess);+ var diagnostic = Assert.Single(import.Diagnostics);+ Assert.Equal(KernelDiagnosticCode.NotImplemented, diagnostic.Code);+ Assert.Equal("Importer.StepSyntax.InlineEntity", diagnostic.Source);+ Assert.Equal("Inline ADVANCED_FACE.surface constructor 'SPHERICAL_SURFACE' has unsupported argument shape.", diagnostic.Message);+ }++ private static string LoadFixture(string relativePath)+ {+ var path = Path.Combine(Step242CorpusManifestRunner.RepoRoot(), relativePath.Replace('/', Path.DirectorySeparatorChar));+ return File.ReadAllText(path, Encoding.UTF8);+ }+}diff --git a/Aetheris.Kernel.Core/Step242/Step242Importer.cs b/Aetheris.Kernel.Core/Step242/Step242Importer.csindex 48c11740..ae571244 100644--- a/Aetheris.Kernel.Core/Step242/Step242Importer.cs+++ b/Aetheris.Kernel.Core/Step242/Step242Importer.cs@@ -586,7 +586,8 @@ public static class Step242Importerif (!string.Equals(surfaceName, "PLANE", StringComparison.Ordinal)&& !string.Equals(surfaceName, "CYLINDRICAL_SURFACE", StringComparison.Ordinal)- && !string.Equals(surfaceName, "CONICAL_SURFACE", StringComparison.Ordinal))+ && !string.Equals(surfaceName, "CONICAL_SURFACE", StringComparison.Ordinal)+ && !string.Equals(surfaceName, "SPHERICAL_SURFACE", StringComparison.Ordinal)){return FailureInlineSurface<Step242ParsedEntity>($"ADVANCED_FACE surface: inline constructor '{surfaceName}' is not supported in this subset.", SourceFor(faceEntityId, "Importer.StepSyntax.InlineEntity"));}@@ -696,6 +697,35 @@ public static class Step242Importerreturn FailureInlineSurface<IReadOnlyList<Step242Value>>("Inline ADVANCED_FACE.surface constructor 'CONICAL_SURFACE' has unsupported argument shape.", SourceFor(faceEntityId, "Importer.StepSyntax.InlineEntity"));}+ if (string.Equals(surfaceName, "SPHERICAL_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 'SPHERICAL_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 'SPHERICAL_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 'SPHERICAL_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 10b86a46..c8ea70ff 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(...)`, `CYLINDRICAL_SURFACE(...)`, and `CONICAL_SURFACE(...)` in M47c).+- `ADVANCED_FACE.surface` accepts either a `#entity` reference or a limited inline surface constructor (`PLANE(...)`, `CYLINDRICAL_SURFACE(...)`, `CONICAL_SURFACE(...)`, and `SPHERICAL_SURFACE(...)` in M47d).## 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: `ADVANCED_FACE.surface = PLANE(...)`, `CYLINDRICAL_SURFACE(...)`, and `CONICAL_SURFACE(...)` are accepted in M47c; other inline surface constructors fail deterministically via `Importer.StepSyntax.InlineEntity`.+- Inline surface constructors are intentionally limited in v0: `ADVANCED_FACE.surface = PLANE(...)`, `CYLINDRICAL_SURFACE(...)`, `CONICAL_SURFACE(...)`, and `SPHERICAL_SURFACE(...)` are accepted in M47d; all other inline surface constructors fail deterministically via `Importer.StepSyntax.InlineEntity`.## Corpus and CI gatediff --git a/testdata/step242/syntax-robustness/advanced-face-inline-sphere-malformed.step b/testdata/step242/syntax-robustness/advanced-face-inline-sphere-malformed.stepnew file mode 100644index 00000000..9d31ed5c--- /dev/null+++ b/testdata/step242/syntax-robustness/advanced-face-inline-sphere-malformed.step@@ -0,0 +1,13 @@+ISO-10303-21;+HEADER;+ENDSEC;+DATA;+#1=MANIFOLD_SOLID_BREP('solid',#2);+#2=CLOSED_SHELL($,(#3));+#3=ADVANCED_FACE((),SPHERICAL_SURFACE(#10),.T.);+#10=AXIS2_PLACEMENT_3D($,#11,#12,#13);+#11=CARTESIAN_POINT($,(0,0,0));+#12=DIRECTION($,(0,0,1));+#13=DIRECTION($,(1,0,0));+ENDSEC;+END-ISO-10303-21;diff --git a/testdata/step242/syntax-robustness/advanced-face-inline-sphere-valid.step b/testdata/step242/syntax-robustness/advanced-face-inline-sphere-valid.stepnew file mode 100644index 00000000..5dce5bb6--- /dev/null+++ b/testdata/step242/syntax-robustness/advanced-face-inline-sphere-valid.step@@ -0,0 +1,13 @@+ISO-10303-21;+HEADER;+ENDSEC;+DATA;+#1=MANIFOLD_SOLID_BREP('solid',#2);+#2=CLOSED_SHELL($,(#3));+#3=ADVANCED_FACE((),SPHERICAL_SURFACE(#10,1.0),.T.);+#10=AXIS2_PLACEMENT_3D($,#11,#12,#13);+#11=CARTESIAN_POINT($,(0,0,0));+#12=DIRECTION($,(0,0,1));+#13=DIRECTION($,(1,0,0));+ENDSEC;+END-ISO-10303-21;