Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Validate BSpline3 progression with runtime-backed blocker expectations

Yuechen Li675d1cb5f22d
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242BSplineSurfaceWithKnotsTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242BSplineSurfaceWithKnotsTests.cs
index c16bc66f..56fdf5e2 100644
--- a/Aetheris.Kernel.Core.Tests/Step242/Step242BSplineSurfaceWithKnotsTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242BSplineSurfaceWithKnotsTests.cs
@@ -67,7 +67,7 @@ public sealed class Step242BSplineSurfaceWithKnotsTests
}
[Theory]
- [InlineData("testdata/step242/nist/CTC/nist_ctc_02_asme1_ap242-e2.stp", "exporter", "Edge:5", "Unsupported curve kind 'BSpline3'.")]
+ [InlineData("testdata/step242/nist/CTC/nist_ctc_02_asme1_ap242-e2.stp", "exporter", "Face:47", "Unsupported surface kind 'Sphere'.")]
[InlineData("testdata/step242/nist/FTC/nist_ftc_07_asme1_ap242-e2.stp", "tessellator", "", "Face 20 curved tessellation supports repeated torus/revolved families with mixed line/circle loops; this topology family is still unsupported. Observed")]
[InlineData("testdata/step242/nist/STC/nist_stc_08_asme1_ap242-e3.stp", "tessellator", "", "Face 62 curved tessellation does not support this torus/revolved boundary topology yet. Observed")]
public void Step242_TrimmedSphereTargets_AdvancePastOldUntrimmedSphereBlocker_AndRemainDeterministic(
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242ConicalSurfaceRegressionTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242ConicalSurfaceRegressionTests.cs
index 4cc8edc0..a0c564fe 100644
--- a/Aetheris.Kernel.Core.Tests/Step242/Step242ConicalSurfaceRegressionTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242ConicalSurfaceRegressionTests.cs
@@ -31,8 +31,8 @@ public sealed class Step242ConicalSurfaceRegressionTests
}
[Theory]
- [InlineData("testdata/step242/nist/CTC/nist_ctc_01_asme1_ap242-e1.stp", "exporter", "Edge:87", "Unsupported curve kind 'BSpline3'.")]
- [InlineData("testdata/step242/nist/CTC/nist_ctc_02_asme1_ap242-e2.stp", "exporter", "Edge:5", "Unsupported curve kind 'BSpline3'.")]
+ [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", "exporter", "Face:47", "Unsupported surface kind 'Sphere'.")]
[InlineData("testdata/step242/nist/CTC/nist_ctc_03_asme1_ap242-e2.stp", "", "", "")]
[InlineData("testdata/step242/nist/CTC/nist_ctc_04_asme1_ap242-e1.stp", "tessellator", "", "Face 1 curved tessellation supports repeated cone/revolved families with mixed line/circle loops; this topology family is still unsupported. Observed")]
[InlineData("testdata/step242/nist/FTC/nist_ftc_06_asme1_ap242-e2.stp", "tessellator", "", "Face 2 curved tessellation does not support this torus/revolved boundary topology yet. Observed")]
@@ -64,6 +64,7 @@ public sealed class Step242ConicalSurfaceRegressionTests
Assert.DoesNotContain("Unsupported surface kind 'Cylinder'", first.FirstDiagnostic.MessagePrefix, StringComparison.Ordinal);
Assert.DoesNotContain("Unsupported surface kind 'Cone'", first.FirstDiagnostic.MessagePrefix, StringComparison.Ordinal);
Assert.DoesNotContain("Unsupported curve kind 'Circle3'", first.FirstDiagnostic.MessagePrefix, StringComparison.Ordinal);
+ Assert.DoesNotContain("Unsupported curve kind 'BSpline3'", first.FirstDiagnostic.MessagePrefix, StringComparison.Ordinal);
if (!string.IsNullOrEmpty(expectedLayer))
{
Assert.Equal(expectedLayer, first.FirstFailureLayer);
@@ -94,8 +95,8 @@ public sealed class Step242ConicalSurfaceRegressionTests
[InlineData(
"testdata/step242/nist/CTC/nist_ctc_02_asme1_ap242-e2.stp",
"exporter",
- "Edge:5",
- "Unsupported curve kind 'BSpline3'.")]
+ "Face:47",
+ "Unsupported surface kind 'Sphere'.")]
[InlineData(
"testdata/step242/nist/STC/nist_stc_10_asme1_ap242-e2.stp",
"importer-topology",
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242EllipseEdgeRegressionTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242EllipseEdgeRegressionTests.cs
index 8197344b..d4097f39 100644
--- a/Aetheris.Kernel.Core.Tests/Step242/Step242EllipseEdgeRegressionTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242EllipseEdgeRegressionTests.cs
@@ -5,7 +5,7 @@ namespace Aetheris.Kernel.Core.Tests.Step242;
public sealed class Step242EllipseEdgeRegressionTests
{
[Theory]
- [InlineData("testdata/step242/nist/CTC/nist_ctc_02_asme1_ap242-e2.stp", "exporter", "Edge:5", "Unsupported curve kind 'BSpline3'.")]
+ [InlineData("testdata/step242/nist/CTC/nist_ctc_02_asme1_ap242-e2.stp", "exporter", "Face:47", "Unsupported surface kind 'Sphere'.")]
[InlineData("testdata/step242/nist/STC/nist_stc_06_asme1_ap242-e3.stp", "importer-topology", "Importer.LoopRole.CylinderNonNormalizableDegenerateProjection", "Cylinder loop normalization failed")]
public void Step242_NistEllipseTargets_AdvancePastUnsupportedEllipse_AndRemainDeterministic(string relativePath, string expectedLayer, string expectedSource, string expectedMessagePrefix)
{
diff --git a/Aetheris.Kernel.Core/Step242/Step242Exporter.cs b/Aetheris.Kernel.Core/Step242/Step242Exporter.cs
index 5b248829..40c6997e 100644
--- a/Aetheris.Kernel.Core/Step242/Step242Exporter.cs
+++ b/Aetheris.Kernel.Core/Step242/Step242Exporter.cs
@@ -39,6 +39,7 @@ public static class Step242Exporter
var orientedEdgeIds = new Dictionary<CoedgeId, string>();
var lineIds = new Dictionary<EdgeId, string>();
var circleIds = new Dictionary<EdgeId, string>();
+ var bsplineIds = new Dictionary<EdgeId, string>();
var faceIds = new List<string>();
@@ -77,7 +78,7 @@ public static class Step242Exporter
if (!edgeCurveIds.TryGetValue(coedge.EdgeId, out var edgeCurveId))
{
- var edgeResult = BuildEdgeCurve(body, model, writer, coedge.EdgeId, vertexPoints, cartesianPointIds, vertexPointIds, lineIds, circleIds);
+ var edgeResult = BuildEdgeCurve(body, model, writer, coedge.EdgeId, vertexPoints, cartesianPointIds, vertexPointIds, lineIds, circleIds, bsplineIds);
if (!edgeResult.IsSuccess)
{
return KernelResult<string>.Failure(edgeResult.Diagnostics);
@@ -193,7 +194,8 @@ public static class Step242Exporter
IDictionary<VertexId, string> cartesianPointIds,
IDictionary<VertexId, string> vertexPointIds,
IDictionary<EdgeId, string> lineIds,
- IDictionary<EdgeId, string> circleIds)
+ IDictionary<EdgeId, string> circleIds,
+ IDictionary<EdgeId, string> bsplineIds)
{
var edge = model.GetEdge(edgeId);
@@ -207,7 +209,9 @@ public static class Step242Exporter
return Failure("Edge curve geometry was not found.", $"Curve:{edgeBinding.CurveGeometryId.Value}");
}
- if (curve.Kind != CurveGeometryKind.Line3 && curve.Kind != CurveGeometryKind.Circle3)
+ if (curve.Kind != CurveGeometryKind.Line3
+ && curve.Kind != CurveGeometryKind.Circle3
+ && curve.Kind != CurveGeometryKind.BSpline3)
{
return Failure($"Unsupported curve kind '{curve.Kind}'.", $"Edge:{edgeId.Value}");
}
@@ -277,6 +281,35 @@ public static class Step242Exporter
geometryCurveId = circleId;
}
+ else if (curve.Kind == CurveGeometryKind.BSpline3 && curve.BSpline3 is BSpline3Curve spline)
+ {
+ if (!bsplineIds.TryGetValue(edgeId, out var bsplineId))
+ {
+ var controlPointIds = spline.ControlPoints
+ .Select(point => writer.AddEntity("CARTESIAN_POINT", "$", PointList(point)))
+ .Select(Step242TextWriter.Ref)
+ .ToArray();
+
+ var multiplicities = spline.KnotMultiplicities.Select(multiplicity => multiplicity.ToString(System.Globalization.CultureInfo.InvariantCulture)).ToArray();
+ var knotValues = spline.KnotValues.Select(Step242TextWriter.Number).ToArray();
+
+ bsplineId = writer.AddEntity(
+ "B_SPLINE_CURVE_WITH_KNOTS",
+ "$",
+ spline.Degree.ToString(System.Globalization.CultureInfo.InvariantCulture),
+ Step242TextWriter.List(controlPointIds),
+ Step242TextWriter.Enum(spline.CurveForm),
+ Step242TextWriter.BooleanLogical(spline.ClosedCurve),
+ Step242TextWriter.BooleanLogical(spline.SelfIntersect),
+ Step242TextWriter.List(multiplicities),
+ Step242TextWriter.List(knotValues),
+ Step242TextWriter.Enum(spline.KnotSpec));
+
+ bsplineIds[edgeId] = bsplineId;
+ }
+
+ geometryCurveId = bsplineId;
+ }
else
{
return Failure($"Unsupported curve kind '{curve.Kind}'.", $"Edge:{edgeId.Value}");
@@ -467,6 +500,7 @@ public static class Step242Exporter
{
CurveGeometryKind.Line3 when curve.Line3 is Line3Curve line => KernelResult<Point3D>.Success(line.Evaluate(parameter)),
CurveGeometryKind.Circle3 when curve.Circle3 is Circle3Curve circle => KernelResult<Point3D>.Success(circle.Evaluate(parameter)),
+ CurveGeometryKind.BSpline3 when curve.BSpline3 is BSpline3Curve spline => KernelResult<Point3D>.Success(spline.Evaluate(parameter)),
_ => FailurePoint($"Unsupported curve kind '{curve.Kind}'.", $"Edge:{edgeId.Value}")
};
}