Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Run STEP242 B-spline runtime tests and refresh NIST snapshot

Yuechen Lif544b36a3a9d
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242BSplineSurfaceWithKnotsTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242BSplineSurfaceWithKnotsTests.cs
new file mode 100644
index 00000000..3e9bd2db
--- /dev/null
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242BSplineSurfaceWithKnotsTests.cs
@@ -0,0 +1,64 @@
+using Aetheris.Kernel.Core.Geometry;
+using Aetheris.Kernel.Core.Step242;
+
+namespace Aetheris.Kernel.Core.Tests.Step242;
+
+public sealed class Step242BSplineSurfaceWithKnotsTests
+{
+ [Fact]
+ public void ImportBody_BSplineSurfaceWithKnotsFace_DecodesSurfaceGeometry()
+ {
+ const string text = "ISO-10303-21;\nHEADER;\nENDSEC;\nDATA;\n#1=MANIFOLD_SOLID_BREP('s',#2);\n#2=CLOSED_SHELL($,(#3));\n#3=ADVANCED_FACE((#4),#5,.T.);\n#4=FACE_OUTER_BOUND($,#6,.T.);\n#5=B_SPLINE_SURFACE_WITH_KNOTS('',3,3,((#100,#101,#102,#103),(#104,#105,#106,#107),(#108,#109,#110,#111),(#112,#113,#114,#115)),.UNSPECIFIED.,.F.,.F.,.F.,(4,4),(4,4),(0.,1.),(0.,1.),.UNSPECIFIED.);\n#6=EDGE_LOOP($,(#10,#11,#12,#13));\n#10=ORIENTED_EDGE($,$,$,#20,.T.);\n#11=ORIENTED_EDGE($,$,$,#21,.T.);\n#12=ORIENTED_EDGE($,$,$,#22,.T.);\n#13=ORIENTED_EDGE($,$,$,#23,.T.);\n#20=EDGE_CURVE($,#30,#31,#40,.T.);\n#21=EDGE_CURVE($,#31,#32,#41,.T.);\n#22=EDGE_CURVE($,#32,#33,#42,.T.);\n#23=EDGE_CURVE($,#33,#30,#43,.T.);\n#30=VERTEX_POINT($,#50);\n#31=VERTEX_POINT($,#51);\n#32=VERTEX_POINT($,#52);\n#33=VERTEX_POINT($,#53);\n#40=LINE($,#50,#80);\n#41=LINE($,#51,#81);\n#42=LINE($,#52,#82);\n#43=LINE($,#53,#83);\n#50=CARTESIAN_POINT($,(0,0,0));\n#51=CARTESIAN_POINT($,(1,0,0));\n#52=CARTESIAN_POINT($,(1,1,0));\n#53=CARTESIAN_POINT($,(0,1,0));\n#80=VECTOR($,#84,1.0);\n#81=VECTOR($,#85,1.0);\n#82=VECTOR($,#86,1.0);\n#83=VECTOR($,#87,1.0);\n#84=DIRECTION($,(1,0,0));\n#85=DIRECTION($,(0,1,0));\n#86=DIRECTION($,(-1,0,0));\n#87=DIRECTION($,(0,-1,0));\n#100=CARTESIAN_POINT($,(0,0,0));\n#101=CARTESIAN_POINT($,(0,0.33,0));\n#102=CARTESIAN_POINT($,(0,0.66,0));\n#103=CARTESIAN_POINT($,(0,1,0));\n#104=CARTESIAN_POINT($,(0.33,0,0));\n#105=CARTESIAN_POINT($,(0.33,0.33,0));\n#106=CARTESIAN_POINT($,(0.33,0.66,0));\n#107=CARTESIAN_POINT($,(0.33,1,0));\n#108=CARTESIAN_POINT($,(0.66,0,0));\n#109=CARTESIAN_POINT($,(0.66,0.33,0));\n#110=CARTESIAN_POINT($,(0.66,0.66,0));\n#111=CARTESIAN_POINT($,(0.66,1,0));\n#112=CARTESIAN_POINT($,(1,0,0));\n#113=CARTESIAN_POINT($,(1,0.33,0));\n#114=CARTESIAN_POINT($,(1,0.66,0));\n#115=CARTESIAN_POINT($,(1,1,0));\nENDSEC;\nEND-ISO-10303-21;";
+
+ var import = Step242Importer.ImportBody(text);
+
+ Assert.True(import.IsSuccess);
+ Assert.Contains(import.Value.Geometry.Surfaces, s => s.Value.Kind == SurfaceGeometryKind.BSplineSurfaceWithKnots);
+ }
+
+ [Theory]
+ [InlineData("testdata/step242/nist/CTC/nist_ctc_02_asme1_ap242-e2.stp")]
+ [InlineData("testdata/step242/nist/FTC/nist_ftc_07_asme1_ap242-e2.stp")]
+ [InlineData("testdata/step242/nist/FTC/nist_ftc_10_asme1_ap242-e2.stp")]
+ public void Step242_NistTargets_DoNotFirstFailOnUnsupportedBSplineSurfaceWithKnots(string relativePath)
+ {
+ var entry = new Step242CorpusManifestEntry(
+ Id: Path.GetFileNameWithoutExtension(relativePath),
+ Path: relativePath,
+ Group: "nist-bspline-surface-regression",
+ Notes: "regression",
+ ExpectedFirstDiagnostic: null,
+ ExpectHashStableAfterCanonicalization: null,
+ ExpectTopologyCounts: null,
+ ExpectGeometryKinds: null);
+
+ var first = Step242CorpusManifestRunner.RunOne(entry);
+ var second = Step242CorpusManifestRunner.RunOne(entry);
+
+ Assert.DoesNotContain("ADVANCED_FACE surface 'B_SPLINE_SURFACE_WITH_KNOTS' is unsupported.", 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);
+ }
+
+ [Theory]
+ [InlineData("testdata/step242/nist/CTC/nist_ctc_02_asme1_ap242-e2.stp", "Importer.EntityFamily")]
+ [InlineData("testdata/step242/nist/FTC/nist_ftc_07_asme1_ap242-e2.stp", "")]
+ [InlineData("testdata/step242/nist/FTC/nist_ftc_10_asme1_ap242-e2.stp", "")]
+ public void Step242_NistTargets_FirstBlockerIsExplicitAfterBSplineSurfaceProgression(string relativePath, string expectedSource)
+ {
+ var entry = new Step242CorpusManifestEntry(
+ Id: Path.GetFileNameWithoutExtension(relativePath),
+ Path: relativePath,
+ Group: "nist-bspline-surface-regression",
+ Notes: "regression",
+ ExpectedFirstDiagnostic: null,
+ ExpectHashStableAfterCanonicalization: null,
+ ExpectTopologyCounts: null,
+ ExpectGeometryKinds: null);
+
+ var run = Step242CorpusManifestRunner.RunOne(entry);
+ Assert.Equal(expectedSource, run.FirstDiagnostic.Source);
+ Assert.False(string.IsNullOrWhiteSpace(run.FirstDiagnostic.MessagePrefix));
+ }
+}
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242LoopRoleNormalizationRegressionTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242LoopRoleNormalizationRegressionTests.cs
index 2259f54c..ecd6520b 100644
--- a/Aetheris.Kernel.Core.Tests/Step242/Step242LoopRoleNormalizationRegressionTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242LoopRoleNormalizationRegressionTests.cs
@@ -7,8 +7,8 @@ public sealed class Step242LoopRoleNormalizationRegressionTests
[Theory]
[InlineData("testdata/step242/nist/CTC/nist_ctc_04_asme1_ap242-e1.stp", null, null)]
[InlineData("testdata/step242/nist/CTC/nist_ctc_05_asme1_ap242-e1.stp", "Entity:1234", "FACE_BOUND loop type 'VERTEX_LOOP' is unsupported")]
- [InlineData("testdata/step242/nist/FTC/nist_ftc_07_asme1_ap242-e2.stp", "Importer.EntityFamily", null)]
- [InlineData("testdata/step242/nist/FTC/nist_ftc_10_asme1_ap242-e2.stp", "Importer.EntityFamily", null)]
+ [InlineData("testdata/step242/nist/FTC/nist_ftc_07_asme1_ap242-e2.stp", null, null)]
+ [InlineData("testdata/step242/nist/FTC/nist_ftc_10_asme1_ap242-e2.stp", null, null)]
[InlineData("testdata/step242/nist/FTC/nist_ftc_11_asme1_ap242-e2.stp", "Importer.LoopRole.CylinderNonNormalizableDegenerateProjection", "Cylinder loop normalization failed")]
[InlineData("testdata/step242/nist/STC/nist_stc_06_asme1_ap242-e3.stp", null, null)]
[InlineData("testdata/step242/nist/STC/nist_stc_09_asme1_ap242-e3.stp", null, null)]
diff --git a/Aetheris.Kernel.Core/Geometry/SurfaceGeometry.cs b/Aetheris.Kernel.Core/Geometry/SurfaceGeometry.cs
index 0ae442a8..1059857d 100644
--- a/Aetheris.Kernel.Core/Geometry/SurfaceGeometry.cs
+++ b/Aetheris.Kernel.Core/Geometry/SurfaceGeometry.cs
@@ -9,6 +9,7 @@ public enum SurfaceGeometryKind
Cone,
Sphere,
Torus,
+ BSplineSurfaceWithKnots,
}
/// <summary>
@@ -22,7 +23,8 @@ public sealed record SurfaceGeometry
CylinderSurface? cylinder,
ConeSurface? cone,
SphereSurface? sphere,
- TorusSurface? torus)
+ TorusSurface? torus,
+ BSplineSurfaceWithKnots? bSplineSurfaceWithKnots)
{
Kind = kind;
Plane = plane;
@@ -30,6 +32,7 @@ public sealed record SurfaceGeometry
Cone = cone;
Sphere = sphere;
Torus = torus;
+ BSplineSurfaceWithKnots = bSplineSurfaceWithKnots;
}
public SurfaceGeometryKind Kind { get; }
@@ -44,13 +47,17 @@ public sealed record SurfaceGeometry
public TorusSurface? Torus { get; }
- public static SurfaceGeometry FromPlane(PlaneSurface plane) => new(SurfaceGeometryKind.Plane, plane, null, null, null, null);
+ public BSplineSurfaceWithKnots? BSplineSurfaceWithKnots { get; }
- public static SurfaceGeometry FromCylinder(CylinderSurface cylinder) => new(SurfaceGeometryKind.Cylinder, null, cylinder, null, null, null);
+ public static SurfaceGeometry FromPlane(PlaneSurface plane) => new(SurfaceGeometryKind.Plane, plane, null, null, null, null, null);
- public static SurfaceGeometry FromCone(ConeSurface cone) => new(SurfaceGeometryKind.Cone, null, null, cone, null, null);
+ public static SurfaceGeometry FromCylinder(CylinderSurface cylinder) => new(SurfaceGeometryKind.Cylinder, null, cylinder, null, null, null, null);
- public static SurfaceGeometry FromSphere(SphereSurface sphere) => new(SurfaceGeometryKind.Sphere, null, null, null, sphere, null);
+ public static SurfaceGeometry FromCone(ConeSurface cone) => new(SurfaceGeometryKind.Cone, null, null, cone, null, null, null);
- public static SurfaceGeometry FromTorus(TorusSurface torus) => new(SurfaceGeometryKind.Torus, null, null, null, null, torus);
+ public static SurfaceGeometry FromSphere(SphereSurface sphere) => new(SurfaceGeometryKind.Sphere, null, null, null, sphere, null, null);
+
+ public static SurfaceGeometry FromTorus(TorusSurface torus) => new(SurfaceGeometryKind.Torus, null, null, null, null, torus, null);
+
+ public static SurfaceGeometry FromBSplineSurfaceWithKnots(BSplineSurfaceWithKnots surface) => new(SurfaceGeometryKind.BSplineSurfaceWithKnots, null, null, null, null, null, surface);
}
diff --git a/Aetheris.Kernel.Core/Geometry/Surfaces/BSplineSurfaceWithKnots.cs b/Aetheris.Kernel.Core/Geometry/Surfaces/BSplineSurfaceWithKnots.cs
new file mode 100644
index 00000000..cd9b1ab9
--- /dev/null
+++ b/Aetheris.Kernel.Core/Geometry/Surfaces/BSplineSurfaceWithKnots.cs
@@ -0,0 +1,128 @@
+using Aetheris.Kernel.Core.Math;
+
+namespace Aetheris.Kernel.Core.Geometry.Surfaces;
+
+public sealed record BSplineSurfaceWithKnots
+{
+ public BSplineSurfaceWithKnots(
+ int degreeU,
+ int degreeV,
+ IReadOnlyList<IReadOnlyList<Point3D>> controlPoints,
+ string surfaceForm,
+ bool uClosed,
+ bool vClosed,
+ bool selfIntersect,
+ IReadOnlyList<int> knotMultiplicitiesU,
+ IReadOnlyList<int> knotMultiplicitiesV,
+ IReadOnlyList<double> knotValuesU,
+ IReadOnlyList<double> knotValuesV,
+ string knotSpec)
+ {
+ if (degreeU < 1 || degreeV < 1)
+ {
+ throw new ArgumentOutOfRangeException(nameof(degreeU), "Surface degrees must be greater than or equal to one.");
+ }
+
+ if (controlPoints is null || controlPoints.Count < degreeU + 1)
+ {
+ throw new ArgumentException("Control net U count must be at least degree_u + 1.", nameof(controlPoints));
+ }
+
+ var controlCountV = controlPoints[0]?.Count ?? 0;
+ if (controlCountV < degreeV + 1)
+ {
+ throw new ArgumentException("Control net V count must be at least degree_v + 1.", nameof(controlPoints));
+ }
+
+ for (var i = 0; i < controlPoints.Count; i++)
+ {
+ if (controlPoints[i] is null || controlPoints[i].Count != controlCountV)
+ {
+ throw new ArgumentException("All control net rows must be non-null and have identical V cardinality.", nameof(controlPoints));
+ }
+ }
+
+ var fullKnotsU = ExpandKnots(knotMultiplicitiesU, knotValuesU);
+ var fullKnotsV = ExpandKnots(knotMultiplicitiesV, knotValuesV);
+
+ var expectedKnotCountU = controlPoints.Count + degreeU + 1;
+ var expectedKnotCountV = controlCountV + degreeV + 1;
+ if (fullKnotsU.Count != expectedKnotCountU)
+ {
+ throw new ArgumentException($"Expanded U knot count must be {expectedKnotCountU} for degree_u {degreeU} and {controlPoints.Count} control rows.");
+ }
+
+ if (fullKnotsV.Count != expectedKnotCountV)
+ {
+ throw new ArgumentException($"Expanded V knot count must be {expectedKnotCountV} for degree_v {degreeV} and {controlCountV} control columns.");
+ }
+
+ EnsureNonDecreasing(fullKnotsU, "U");
+ EnsureNonDecreasing(fullKnotsV, "V");
+
+ DegreeU = degreeU;
+ DegreeV = degreeV;
+ ControlPoints = controlPoints.Select(row => row.ToArray()).ToArray();
+ SurfaceForm = surfaceForm;
+ UClosed = uClosed;
+ VClosed = vClosed;
+ SelfIntersect = selfIntersect;
+ KnotMultiplicitiesU = knotMultiplicitiesU.ToArray();
+ KnotMultiplicitiesV = knotMultiplicitiesV.ToArray();
+ KnotValuesU = knotValuesU.ToArray();
+ KnotValuesV = knotValuesV.ToArray();
+ FullKnotsU = fullKnotsU;
+ FullKnotsV = fullKnotsV;
+ KnotSpec = knotSpec;
+ }
+
+ public int DegreeU { get; }
+ public int DegreeV { get; }
+ public IReadOnlyList<IReadOnlyList<Point3D>> ControlPoints { get; }
+ public string SurfaceForm { get; }
+ public bool UClosed { get; }
+ public bool VClosed { get; }
+ public bool SelfIntersect { get; }
+ public IReadOnlyList<int> KnotMultiplicitiesU { get; }
+ public IReadOnlyList<int> KnotMultiplicitiesV { get; }
+ public IReadOnlyList<double> KnotValuesU { get; }
+ public IReadOnlyList<double> KnotValuesV { get; }
+ public IReadOnlyList<double> FullKnotsU { get; }
+ public IReadOnlyList<double> FullKnotsV { get; }
+ public string KnotSpec { get; }
+
+ private static IReadOnlyList<double> ExpandKnots(IReadOnlyList<int> multiplicities, IReadOnlyList<double> values)
+ {
+ if (multiplicities is null || values is null || multiplicities.Count == 0 || multiplicities.Count != values.Count)
+ {
+ throw new ArgumentException("Knot multiplicities and values must be non-empty and have matching counts.");
+ }
+
+ var knots = new List<double>();
+ for (var i = 0; i < multiplicities.Count; i++)
+ {
+ if (multiplicities[i] <= 0 || !double.IsFinite(values[i]))
+ {
+ throw new ArgumentException("Knot multiplicities must be positive and knot values must be finite.");
+ }
+
+ for (var j = 0; j < multiplicities[i]; j++)
+ {
+ knots.Add(values[i]);
+ }
+ }
+
+ return knots;
+ }
+
+ private static void EnsureNonDecreasing(IReadOnlyList<double> knots, string dimension)
+ {
+ for (var i = 1; i < knots.Count; i++)
+ {
+ if (knots[i] < knots[i - 1])
+ {
+ throw new ArgumentException($"Expanded {dimension} knot vector must be non-decreasing.");
+ }
+ }
+ }
+}
diff --git a/Aetheris.Kernel.Core/Step242/Step242Importer.cs b/Aetheris.Kernel.Core/Step242/Step242Importer.cs
index 8194d2a6..955649f4 100644
--- a/Aetheris.Kernel.Core/Step242/Step242Importer.cs
+++ b/Aetheris.Kernel.Core/Step242/Step242Importer.cs
@@ -727,9 +727,62 @@ public static class Step242Importer
return KernelResult<(SurfaceGeometryId SurfaceGeometryId, SurfaceGeometry SurfaceGeometry)>.Success((geometryId, SurfaceGeometry.FromTorus(torusResult.Value)));
}
+ var bSplineSurfaceEntity = ResolveBSplineSurfaceEntity(surfaceToDecode);
+ if (bSplineSurfaceEntity is not null)
+ {
+ var surfaceResult = Step242SubsetDecoder.ReadBSplineSurfaceWithKnots(document, bSplineSurfaceEntity);
+ if (!surfaceResult.IsSuccess)
+ {
+ return KernelResult<(SurfaceGeometryId SurfaceGeometryId, SurfaceGeometry SurfaceGeometry)>.Failure(surfaceResult.Diagnostics);
+ }
+
+ return KernelResult<(SurfaceGeometryId SurfaceGeometryId, SurfaceGeometry SurfaceGeometry)>.Success((
+ geometryId,
+ SurfaceGeometry.FromBSplineSurfaceWithKnots(surfaceResult.Value)));
+ }
+
return FailureSurfaceBinding($"ADVANCED_FACE surface '{surfaceName}' is unsupported.", SourceFor(surfaceToDecode.Id, "Importer.EntityFamily"));
}
+ private static Step242ParsedEntity? ResolveBSplineSurfaceEntity(Step242ParsedEntity surfaceEntity)
+ {
+ var splineWithKnots = Step242SubsetDecoder.TryGetConstructor(surfaceEntity.Instance, "B_SPLINE_SURFACE_WITH_KNOTS");
+ if (splineWithKnots is null)
+ {
+ return null;
+ }
+
+ if (splineWithKnots.Arguments.Count >= 13)
+ {
+ return WithConstructor(surfaceEntity, splineWithKnots);
+ }
+
+ var splineSurface = Step242SubsetDecoder.TryGetConstructor(surfaceEntity.Instance, "B_SPLINE_SURFACE");
+ if (splineSurface is null || splineSurface.Arguments.Count < 7 || splineWithKnots.Arguments.Count < 5)
+ {
+ return null;
+ }
+
+ var normalized = new List<Step242Value>(13)
+ {
+ Step242OmittedValue.Instance,
+ splineSurface.Arguments[0],
+ splineSurface.Arguments[1],
+ splineSurface.Arguments[2],
+ splineSurface.Arguments[3],
+ splineSurface.Arguments[4],
+ splineSurface.Arguments[5],
+ splineSurface.Arguments[6],
+ splineWithKnots.Arguments[0],
+ splineWithKnots.Arguments[1],
+ splineWithKnots.Arguments[2],
+ splineWithKnots.Arguments[3],
+ splineWithKnots.Arguments[4]
+ };
+
+ return WithConstructor(surfaceEntity, new Step242EntityConstructor("B_SPLINE_SURFACE_WITH_KNOTS", normalized));
+ }
+
private static KernelResult<Step242ParsedEntity> BuildInlineSurfaceEntity(int faceEntityId, string surfaceName, IReadOnlyList<Step242Value>? inlineArguments)
{
if (inlineArguments is null)
diff --git a/Aetheris.Kernel.Core/Step242/Step242SubsetDecoder.cs b/Aetheris.Kernel.Core/Step242/Step242SubsetDecoder.cs
index ae793425..6416c9df 100644
--- a/Aetheris.Kernel.Core/Step242/Step242SubsetDecoder.cs
+++ b/Aetheris.Kernel.Core/Step242/Step242SubsetDecoder.cs
@@ -445,6 +445,107 @@ internal static class Step242SubsetDecoder
}
}
+ public static KernelResult<BSplineSurfaceWithKnots> ReadBSplineSurfaceWithKnots(Step242ParsedDocument document, Step242ParsedEntity splineEntity)
+ {
+ var degreeUResult = ReadIntArgument(splineEntity, 1, "B_SPLINE_SURFACE_WITH_KNOTS degree_u", "Importer.Geometry.BSplineSurface");
+ if (!degreeUResult.IsSuccess)
+ {
+ return KernelResult<BSplineSurfaceWithKnots>.Failure(degreeUResult.Diagnostics);
+ }
+
+ var degreeVResult = ReadIntArgument(splineEntity, 2, "B_SPLINE_SURFACE_WITH_KNOTS degree_v", "Importer.Geometry.BSplineSurface");
+ if (!degreeVResult.IsSuccess)
+ {
+ return KernelResult<BSplineSurfaceWithKnots>.Failure(degreeVResult.Diagnostics);
+ }
+
+ var controlPointsResult = ReadCartesianPointReferenceNet(
+ document,
+ splineEntity,
+ 3,
+ "B_SPLINE_SURFACE_WITH_KNOTS control_points_list",
+ "Importer.Geometry.BSplineSurface");
+ if (!controlPointsResult.IsSuccess)
+ {
+ return KernelResult<BSplineSurfaceWithKnots>.Failure(controlPointsResult.Diagnostics);
+ }
+
+ var surfaceFormResult = ReadEnumArgument(splineEntity, 4, "B_SPLINE_SURFACE_WITH_KNOTS surface_form", "Importer.Geometry.BSplineSurface");
+ if (!surfaceFormResult.IsSuccess)
+ {
+ return KernelResult<BSplineSurfaceWithKnots>.Failure(surfaceFormResult.Diagnostics);
+ }
+
+ var uClosedResult = ReadLogical(splineEntity, 5, "B_SPLINE_SURFACE_WITH_KNOTS u_closed");
+ if (!uClosedResult.IsSuccess)
+ {
+ return KernelResult<BSplineSurfaceWithKnots>.Failure(uClosedResult.Diagnostics);
+ }
+
+ var vClosedResult = ReadLogical(splineEntity, 6, "B_SPLINE_SURFACE_WITH_KNOTS v_closed");
+ if (!vClosedResult.IsSuccess)
+ {
+ return KernelResult<BSplineSurfaceWithKnots>.Failure(vClosedResult.Diagnostics);
+ }
+
+ var selfIntersectResult = ReadLogical(splineEntity, 7, "B_SPLINE_SURFACE_WITH_KNOTS self_intersect");
+ if (!selfIntersectResult.IsSuccess)
+ {
+ return KernelResult<BSplineSurfaceWithKnots>.Failure(selfIntersectResult.Diagnostics);
+ }
+
+ var multiplicitiesUResult = ReadIntegerListArgument(splineEntity, 8, "B_SPLINE_SURFACE_WITH_KNOTS u_multiplicities", "Importer.Geometry.BSplineSurface");
+ if (!multiplicitiesUResult.IsSuccess)
+ {
+ return KernelResult<BSplineSurfaceWithKnots>.Failure(multiplicitiesUResult.Diagnostics);
+ }
+
+ var multiplicitiesVResult = ReadIntegerListArgument(splineEntity, 9, "B_SPLINE_SURFACE_WITH_KNOTS v_multiplicities", "Importer.Geometry.BSplineSurface");
+ if (!multiplicitiesVResult.IsSuccess)
+ {
+ return KernelResult<BSplineSurfaceWithKnots>.Failure(multiplicitiesVResult.Diagnostics);
+ }
+
+ var knotsUResult = ReadNumberListArgument(splineEntity, 10, "B_SPLINE_SURFACE_WITH_KNOTS u_knots", "Importer.Geometry.BSplineSurface");
+ if (!knotsUResult.IsSuccess)
+ {
+ return KernelResult<BSplineSurfaceWithKnots>.Failure(knotsUResult.Diagnostics);
+ }
+
+ var knotsVResult = ReadNumberListArgument(splineEntity, 11, "B_SPLINE_SURFACE_WITH_KNOTS v_knots", "Importer.Geometry.BSplineSurface");
+ if (!knotsVResult.IsSuccess)
+ {
+ return KernelResult<BSplineSurfaceWithKnots>.Failure(knotsVResult.Diagnostics);
+ }
+
+ var knotSpecResult = ReadEnumArgument(splineEntity, 12, "B_SPLINE_SURFACE_WITH_KNOTS knot_spec", "Importer.Geometry.BSplineSurface");
+ if (!knotSpecResult.IsSuccess)
+ {
+ return KernelResult<BSplineSurfaceWithKnots>.Failure(knotSpecResult.Diagnostics);
+ }
+
+ try
+ {
+ return KernelResult<BSplineSurfaceWithKnots>.Success(new BSplineSurfaceWithKnots(
+ degreeUResult.Value,
+ degreeVResult.Value,
+ controlPointsResult.Value,
+ surfaceFormResult.Value,
+ uClosedResult.Value ?? false,
+ vClosedResult.Value ?? false,
+ selfIntersectResult.Value ?? false,
+ multiplicitiesUResult.Value,
+ multiplicitiesVResult.Value,
+ knotsUResult.Value,
+ knotsVResult.Value,
+ knotSpecResult.Value));
+ }
+ catch (ArgumentException ex)
+ {
+ return Failure<BSplineSurfaceWithKnots>(KernelDiagnosticCode.InvalidArgument, ex.Message, "Importer.Geometry.BSplineSurface");
+ }
+ }
+
public static KernelResult<CylinderSurface> ReadCylindricalSurface(Step242ParsedDocument document, Step242ParsedEntity cylinderEntity)
{
var placementResult = ReadAxis2Placement3D(document, cylinderEntity, 1, "CYLINDRICAL_SURFACE position", "Importer.Geometry.Cylinder");
@@ -816,6 +917,60 @@ internal static class Step242SubsetDecoder
return KernelResult<IReadOnlyList<Point3D>>.Success(points);
}
+ private static KernelResult<IReadOnlyList<IReadOnlyList<Point3D>>> ReadCartesianPointReferenceNet(
+ Step242ParsedDocument document,
+ Step242ParsedEntity ownerEntity,
+ int argumentIndex,
+ string context,
+ string source)
+ {
+ if (argumentIndex < 0 || argumentIndex >= ownerEntity.Arguments.Count)
+ {
+ return Failure<IReadOnlyList<IReadOnlyList<Point3D>>>(KernelDiagnosticCode.InvalidArgument, $"{context}: missing argument at index {argumentIndex}.", source);
+ }
+
+ if (ownerEntity.Arguments[argumentIndex] is not Step242ListValue rows)
+ {
+ return Failure<IReadOnlyList<IReadOnlyList<Point3D>>>(KernelDiagnosticCode.InvalidArgument, $"{context}: expected aggregate list of control-point rows.", source);
+ }
+
+ var net = new List<IReadOnlyList<Point3D>>(rows.Items.Count);
+ for (var rowIndex = 0; rowIndex < rows.Items.Count; rowIndex++)
+ {
+ if (rows.Items[rowIndex] is not Step242ListValue row)
+ {
+ return Failure<IReadOnlyList<IReadOnlyList<Point3D>>>(KernelDiagnosticCode.InvalidArgument, $"{context}: row {rowIndex} must be a list of CARTESIAN_POINT references.", source);
+ }
+
+ var points = new List<Point3D>(row.Items.Count);
+ for (var colIndex = 0; colIndex < row.Items.Count; colIndex++)
+ {
+ if (row.Items[colIndex] is not Step242EntityReference pointReference)
+ {
+ return Failure<IReadOnlyList<IReadOnlyList<Point3D>>>(KernelDiagnosticCode.InvalidArgument, $"{context}: row {rowIndex}, column {colIndex} must be an entity reference (#id).", source);
+ }
+
+ var pointEntityResult = document.TryGetEntity(pointReference.TargetId, "CARTESIAN_POINT");
+ if (!pointEntityResult.IsSuccess)
+ {
+ return KernelResult<IReadOnlyList<IReadOnlyList<Point3D>>>.Failure(pointEntityResult.Diagnostics);
+ }
+
+ var pointResult = ReadCartesianPoint(pointEntityResult.Value, context);
+ if (!pointResult.IsSuccess)
+ {
+ return KernelResult<IReadOnlyList<IReadOnlyList<Point3D>>>.Failure(pointResult.Diagnostics);
+ }
+
+ points.Add(pointResult.Value);
+ }
+
+ net.Add(points);
+ }
+
+ return KernelResult<IReadOnlyList<IReadOnlyList<Point3D>>>.Success(net);
+ }
+
private static KernelResult<IReadOnlyList<int>> ReadIntegerListArgument(
Step242ParsedEntity entity,
int argumentIndex,
diff --git a/testdata/step242/manifests/nist.v0.report.json b/testdata/step242/manifests/nist.v0.report.json
index 4990ebba..8afbec32 100644
--- a/testdata/step242/manifests/nist.v0.report.json
+++ b/testdata/step242/manifests/nist.v0.report.json
@@ -32,7 +32,7 @@
"firstDiagnostic": {
"code": "NotImplemented",
"source": "Importer.EntityFamily",
- "messagePrefix": "ADVANCED_FACE surface \u0027B_SPLINE_SURFACE_WITH_KNOTS\u0027 is unsupported."
+ "messagePrefix": "EDGE_CURVE geometry \u0027ELLIPSE\u0027 is unsupported."
},
"diagnosticCount": 1,
"exceptionEscaped": false,
@@ -148,18 +148,18 @@
"path": "testdata/step242/nist/FTC/nist_ftc_07_asme1_ap242-e2.stp",
"sizeBytes": 1459346,
"status": "importFail",
- "firstFailureLayer": "importer-topology",
+ "firstFailureLayer": "tessellator",
"firstDiagnostic": {
"code": "NotImplemented",
- "source": "Importer.EntityFamily",
- "messagePrefix": "ADVANCED_FACE surface \u0027B_SPLINE_SURFACE_WITH_KNOTS\u0027 is unsupported."
+ "source": "",
+ "messagePrefix": "Face 14 sphere tessellation supports only untrimmed sphere faces with zero loops."
},
"diagnosticCount": 1,
"exceptionEscaped": false,
"topologyCounts": {
- "vertices": 0,
- "edges": 0,
- "faces": 0
+ "vertices": 582,
+ "edges": 865,
+ "faces": 304
},
"tessellationCounts": {
"facePatches": 0,
@@ -244,18 +244,18 @@
"path": "testdata/step242/nist/FTC/nist_ftc_10_asme1_ap242-e2.stp",
"sizeBytes": 1855829,
"status": "importFail",
- "firstFailureLayer": "importer-topology",
+ "firstFailureLayer": "tessellator",
"firstDiagnostic": {
"code": "NotImplemented",
- "source": "Importer.EntityFamily",
- "messagePrefix": "ADVANCED_FACE surface \u0027B_SPLINE_SURFACE_WITH_KNOTS\u0027 is unsupported."
+ "source": "",
+ "messagePrefix": "Face 14 curved tessellation supports four-coedge torus/revolved loop layouts. Observed"
},
"diagnosticCount": 1,
"exceptionEscaped": false,
"topologyCounts": {
- "vertices": 0,
- "edges": 0,
- "faces": 0
+ "vertices": 560,
+ "edges": 799,
+ "faces": 264
},
"tessellationCounts": {
"facePatches": 0,