Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Add STEP242 swept surface support

Yuechen Li8cad5b801e1b
diff --git a/Aetheris.CLI/StepAnalyzer.cs b/Aetheris.CLI/StepAnalyzer.cs
index a4a037b8..3a4a0426 100644
--- a/Aetheris.CLI/StepAnalyzer.cs
+++ b/Aetheris.CLI/StepAnalyzer.cs
@@ -943,6 +943,8 @@ public sealed record VolumeAnalysisResult(
case SurfaceGeometryKind.Cone: surfaceFamilies["cone"]++; break;
case SurfaceGeometryKind.Sphere: surfaceFamilies["sphere"]++; break;
case SurfaceGeometryKind.Torus: surfaceFamilies["torus"]++; break;
+ case SurfaceGeometryKind.LinearExtrusion: surfaceFamilies["linear-extrusion"]++; break;
+ case SurfaceGeometryKind.SurfaceOfRevolution: surfaceFamilies["surface-of-revolution"]++; break;
case SurfaceGeometryKind.BSplineSurfaceWithKnots: surfaceFamilies["bspline"]++; break;
default: surfaceFamilies["other"]++; break;
}
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242RuledSurfaceSkeletonTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242RuledSurfaceSkeletonTests.cs
new file mode 100644
index 00000000..4858986e
--- /dev/null
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242RuledSurfaceSkeletonTests.cs
@@ -0,0 +1,97 @@
+using System.Text;
+using Aetheris.Kernel.Core.Geometry;
+using Aetheris.Kernel.Core.Geometry.Curves;
+using Aetheris.Kernel.Core.Geometry.Surfaces;
+using Aetheris.Kernel.Core.Step242;
+
+namespace Aetheris.Kernel.Core.Tests.Step242;
+
+public sealed class Step242RuledSurfaceSkeletonTests
+{
+ [Fact]
+ public void LinearExtrusionLineProbe_ImportsExportsAndReimportsAsLinearExtrusion()
+ {
+ var text = LoadProbe("surface-of-linear-extrusion-line.step");
+
+ var import = Step242Importer.ImportBody(text);
+ Assert.True(import.IsSuccess);
+
+ var surface = Assert.Single(import.Value.Geometry.Surfaces).Value;
+ Assert.Equal(SurfaceGeometryKind.LinearExtrusion, surface.Kind);
+ Assert.True(surface.LinearExtrusion.HasValue);
+ var linearExtrusion = surface.LinearExtrusion.Value;
+ Assert.Equal(CurveGeometryKind.Line3, linearExtrusion.Directrix.Kind);
+
+ var export = Step242Exporter.ExportBody(import.Value);
+ Assert.True(export.IsSuccess);
+ Assert.Contains("SURFACE_OF_LINEAR_EXTRUSION", export.Value, StringComparison.Ordinal);
+
+ var roundTrip = Step242Importer.ImportBody(export.Value);
+ Assert.True(roundTrip.IsSuccess);
+ Assert.Equal(SurfaceGeometryKind.LinearExtrusion, Assert.Single(roundTrip.Value.Geometry.Surfaces).Value.Kind);
+ }
+
+ [Fact]
+ public void SurfaceOfRevolutionLineProbe_ImportsExportsAndReimportsAsSurfaceOfRevolution()
+ {
+ var text = LoadProbe("surface-of-revolution-line.step");
+
+ var import = Step242Importer.ImportBody(text);
+ Assert.True(import.IsSuccess);
+
+ var surface = Assert.Single(import.Value.Geometry.Surfaces).Value;
+ Assert.Equal(SurfaceGeometryKind.SurfaceOfRevolution, surface.Kind);
+ Assert.True(surface.SurfaceOfRevolution.HasValue);
+ var revolution = surface.SurfaceOfRevolution.Value;
+ Assert.Equal(CurveGeometryKind.Line3, revolution.Directrix.Kind);
+
+ var export = Step242Exporter.ExportBody(import.Value);
+ Assert.True(export.IsSuccess);
+ Assert.Contains("SURFACE_OF_REVOLUTION", export.Value, StringComparison.Ordinal);
+
+ var roundTrip = Step242Importer.ImportBody(export.Value);
+ Assert.True(roundTrip.IsSuccess);
+ Assert.Equal(SurfaceGeometryKind.SurfaceOfRevolution, Assert.Single(roundTrip.Value.Geometry.Surfaces).Value.Kind);
+ }
+
+ [Fact]
+ public void Degree11BilinearProbe_IsClassifiedAsExactRuledAndRoundTripsAsBspline()
+ {
+ var text = LoadProbe("bspline-degree-1-1-bilinear.step");
+
+ var import = Step242Importer.ImportBody(text);
+ Assert.True(import.IsSuccess);
+
+ var surface = Assert.Single(import.Value.Geometry.Surfaces).Value;
+ Assert.Equal(SurfaceGeometryKind.BSplineSurfaceWithKnots, surface.Kind);
+
+ var bspline = Assert.IsType<BSplineSurfaceWithKnots>(surface.BSplineSurfaceWithKnots);
+ Assert.Equal(1, bspline.DegreeU);
+ Assert.Equal(1, bspline.DegreeV);
+
+ var classification = Step242BsplineRuledClassifier.Classify(bspline);
+ Assert.True(classification.IsRuledCandidate);
+ Assert.True(classification.IsBilinearPatch);
+ Assert.Equal(Step242BsplineRuledDirection.Both, classification.RulingDirection);
+ Assert.Equal(Step242BsplineRuledExactness.ExactRuled, classification.Exactness);
+ Assert.DoesNotContain(import.Diagnostics, diagnostic => diagnostic.Message.Contains("approximation", StringComparison.OrdinalIgnoreCase));
+
+ var export = Step242Exporter.ExportBody(import.Value);
+ Assert.True(export.IsSuccess);
+ Assert.Contains("B_SPLINE_SURFACE_WITH_KNOTS", export.Value, StringComparison.Ordinal);
+
+ var roundTrip = Step242Importer.ImportBody(export.Value);
+ Assert.True(roundTrip.IsSuccess);
+
+ var roundTripSurface = Assert.Single(roundTrip.Value.Geometry.Surfaces).Value;
+ var roundTripSpline = Assert.IsType<BSplineSurfaceWithKnots>(roundTripSurface.BSplineSurfaceWithKnots);
+ Assert.Equal(1, roundTripSpline.DegreeU);
+ Assert.Equal(1, roundTripSpline.DegreeV);
+ }
+
+ private static string LoadProbe(string fileName)
+ {
+ var path = Path.Combine(Step242CorpusManifestRunner.RepoRoot(), "testdata", "step242", "probes", fileName);
+ return File.ReadAllText(path, Encoding.UTF8);
+ }
+}
diff --git a/Aetheris.Kernel.Core/Geometry/SurfaceGeometry.cs b/Aetheris.Kernel.Core/Geometry/SurfaceGeometry.cs
index 1059857d..185134bc 100644
--- a/Aetheris.Kernel.Core/Geometry/SurfaceGeometry.cs
+++ b/Aetheris.Kernel.Core/Geometry/SurfaceGeometry.cs
@@ -9,6 +9,8 @@ public enum SurfaceGeometryKind
Cone,
Sphere,
Torus,
+ LinearExtrusion,
+ SurfaceOfRevolution,
BSplineSurfaceWithKnots,
}
@@ -24,6 +26,8 @@ public sealed record SurfaceGeometry
ConeSurface? cone,
SphereSurface? sphere,
TorusSurface? torus,
+ LinearExtrusionSurface? linearExtrusion,
+ SurfaceOfRevolutionSurface? surfaceOfRevolution,
BSplineSurfaceWithKnots? bSplineSurfaceWithKnots)
{
Kind = kind;
@@ -32,6 +36,8 @@ public sealed record SurfaceGeometry
Cone = cone;
Sphere = sphere;
Torus = torus;
+ LinearExtrusion = linearExtrusion;
+ SurfaceOfRevolution = surfaceOfRevolution;
BSplineSurfaceWithKnots = bSplineSurfaceWithKnots;
}
@@ -47,17 +53,25 @@ public sealed record SurfaceGeometry
public TorusSurface? Torus { get; }
+ public LinearExtrusionSurface? LinearExtrusion { get; }
+
+ public SurfaceOfRevolutionSurface? SurfaceOfRevolution { get; }
+
public BSplineSurfaceWithKnots? BSplineSurfaceWithKnots { get; }
- public static SurfaceGeometry FromPlane(PlaneSurface plane) => new(SurfaceGeometryKind.Plane, plane, null, null, null, null, null);
+ public static SurfaceGeometry FromPlane(PlaneSurface plane) => new(SurfaceGeometryKind.Plane, plane, null, null, null, null, null, null, null);
+
+ public static SurfaceGeometry FromCylinder(CylinderSurface cylinder) => new(SurfaceGeometryKind.Cylinder, null, cylinder, null, null, null, null, null, null);
+
+ public static SurfaceGeometry FromCone(ConeSurface cone) => new(SurfaceGeometryKind.Cone, null, null, cone, null, null, null, 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, null, null, 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, null, null, null);
- public static SurfaceGeometry FromSphere(SphereSurface sphere) => new(SurfaceGeometryKind.Sphere, null, null, null, sphere, null, null);
+ public static SurfaceGeometry FromLinearExtrusion(LinearExtrusionSurface surface) => new(SurfaceGeometryKind.LinearExtrusion, null, null, null, null, null, surface, null, null);
- public static SurfaceGeometry FromTorus(TorusSurface torus) => new(SurfaceGeometryKind.Torus, null, null, null, null, torus, null);
+ public static SurfaceGeometry FromSurfaceOfRevolution(SurfaceOfRevolutionSurface surface) => new(SurfaceGeometryKind.SurfaceOfRevolution, null, null, null, null, null, null, surface, null);
- public static SurfaceGeometry FromBSplineSurfaceWithKnots(BSplineSurfaceWithKnots surface) => new(SurfaceGeometryKind.BSplineSurfaceWithKnots, null, null, null, null, null, surface);
+ public static SurfaceGeometry FromBSplineSurfaceWithKnots(BSplineSurfaceWithKnots surface) => new(SurfaceGeometryKind.BSplineSurfaceWithKnots, null, null, null, null, null, null, null, surface);
}
diff --git a/Aetheris.Kernel.Core/Geometry/Surfaces/LinearExtrusionSurface.cs b/Aetheris.Kernel.Core/Geometry/Surfaces/LinearExtrusionSurface.cs
new file mode 100644
index 00000000..720491dd
--- /dev/null
+++ b/Aetheris.Kernel.Core/Geometry/Surfaces/LinearExtrusionSurface.cs
@@ -0,0 +1,30 @@
+using Aetheris.Kernel.Core.Geometry.Curves;
+using Aetheris.Kernel.Core.Math;
+
+namespace Aetheris.Kernel.Core.Geometry.Surfaces;
+
+public readonly record struct LinearExtrusionSurface
+{
+ public LinearExtrusionSurface(CurveGeometry directrix, Vector3D extrusionVector)
+ {
+ if (directrix is null)
+ {
+ throw new ArgumentNullException(nameof(directrix));
+ }
+
+ if (!double.IsFinite(extrusionVector.X)
+ || !double.IsFinite(extrusionVector.Y)
+ || !double.IsFinite(extrusionVector.Z)
+ || extrusionVector.LengthSquared <= 1e-24d)
+ {
+ throw new ArgumentOutOfRangeException(nameof(extrusionVector), "Extrusion vector must be finite and non-zero.");
+ }
+
+ Directrix = directrix;
+ ExtrusionVector = extrusionVector;
+ }
+
+ public CurveGeometry Directrix { get; }
+
+ public Vector3D ExtrusionVector { get; }
+}
diff --git a/Aetheris.Kernel.Core/Geometry/Surfaces/SurfaceOfRevolutionSurface.cs b/Aetheris.Kernel.Core/Geometry/Surfaces/SurfaceOfRevolutionSurface.cs
new file mode 100644
index 00000000..4b508a9e
--- /dev/null
+++ b/Aetheris.Kernel.Core/Geometry/Surfaces/SurfaceOfRevolutionSurface.cs
@@ -0,0 +1,20 @@
+using Aetheris.Kernel.Core.Geometry.Curves;
+using Aetheris.Kernel.Core.Math;
+
+namespace Aetheris.Kernel.Core.Geometry.Surfaces;
+
+public readonly record struct SurfaceOfRevolutionSurface
+{
+ public SurfaceOfRevolutionSurface(CurveGeometry directrix, Point3D axisOrigin, Direction3D axisDirection)
+ {
+ Directrix = directrix ?? throw new ArgumentNullException(nameof(directrix));
+ AxisOrigin = axisOrigin;
+ AxisDirection = axisDirection;
+ }
+
+ public CurveGeometry Directrix { get; }
+
+ public Point3D AxisOrigin { get; }
+
+ public Direction3D AxisDirection { get; }
+}
diff --git a/Aetheris.Kernel.Core/Step242/Step242BsplineRuledClassification.cs b/Aetheris.Kernel.Core/Step242/Step242BsplineRuledClassification.cs
new file mode 100644
index 00000000..7535a748
--- /dev/null
+++ b/Aetheris.Kernel.Core/Step242/Step242BsplineRuledClassification.cs
@@ -0,0 +1,61 @@
+using Aetheris.Kernel.Core.Geometry.Surfaces;
+
+namespace Aetheris.Kernel.Core.Step242;
+
+internal enum Step242BsplineRuledDirection
+{
+ None,
+ U,
+ V,
+ Both,
+}
+
+internal enum Step242BsplineRuledExactness
+{
+ None,
+ ExactRuled,
+}
+
+internal readonly record struct Step242BsplineRuledClassification(
+ bool IsRuledCandidate,
+ Step242BsplineRuledDirection RulingDirection,
+ bool IsBilinearPatch,
+ Step242BsplineRuledExactness Exactness,
+ string Reason);
+
+internal static class Step242BsplineRuledClassifier
+{
+ public static Step242BsplineRuledClassification Classify(BSplineSurfaceWithKnots surface)
+ {
+ var ruledInU = surface.DegreeU == 1;
+ var ruledInV = surface.DegreeV == 1;
+ var direction = (ruledInU, ruledInV) switch
+ {
+ (true, true) => Step242BsplineRuledDirection.Both,
+ (true, false) => Step242BsplineRuledDirection.U,
+ (false, true) => Step242BsplineRuledDirection.V,
+ _ => Step242BsplineRuledDirection.None
+ };
+
+ var isRuledCandidate = direction != Step242BsplineRuledDirection.None;
+ var isBilinearPatch = ruledInU && ruledInV;
+ var exactness = isRuledCandidate
+ ? Step242BsplineRuledExactness.ExactRuled
+ : Step242BsplineRuledExactness.None;
+
+ var reason = direction switch
+ {
+ Step242BsplineRuledDirection.Both => "Degrees (1,1) form an exact bilinear ruled patch.",
+ Step242BsplineRuledDirection.U => "Degree 1 in U marks an exact ruled candidate in the U direction.",
+ Step242BsplineRuledDirection.V => "Degree 1 in V marks an exact ruled candidate in the V direction.",
+ _ => "Both spline degrees exceed 1, so ruled exactness cannot be concluded from degree alone."
+ };
+
+ return new Step242BsplineRuledClassification(
+ isRuledCandidate,
+ direction,
+ isBilinearPatch,
+ exactness,
+ reason);
+ }
+}
diff --git a/Aetheris.Kernel.Core/Step242/Step242Exporter.cs b/Aetheris.Kernel.Core/Step242/Step242Exporter.cs
index c86201f2..d93e1464 100644
--- a/Aetheris.Kernel.Core/Step242/Step242Exporter.cs
+++ b/Aetheris.Kernel.Core/Step242/Step242Exporter.cs
@@ -396,6 +396,43 @@ public static class Step242Exporter
return writer.AddEntity("TOROIDAL_SURFACE", "$", Step242TextWriter.Ref(axisPlacementId), Step242TextWriter.Number(torus.MajorRadius), Step242TextWriter.Number(torus.MinorRadius));
}
+ private static KernelResult<string> BuildLinearExtrusionSurface(Step242TextWriter writer, LinearExtrusionSurface surface)
+ {
+ var directrixIdResult = BuildSurfaceCurve(writer, surface.Directrix, "Surface.Directrix.LinearExtrusion");
+ if (!directrixIdResult.IsSuccess)
+ {
+ return directrixIdResult;
+ }
+
+ var extrusionAxisResult = BuildVector(writer, surface.ExtrusionVector, "Surface.ExtrusionVector");
+ if (!extrusionAxisResult.IsSuccess)
+ {
+ return extrusionAxisResult;
+ }
+
+ return KernelResult<string>.Success(writer.AddEntity(
+ "SURFACE_OF_LINEAR_EXTRUSION",
+ "$",
+ Step242TextWriter.Ref(directrixIdResult.Value),
+ Step242TextWriter.Ref(extrusionAxisResult.Value)));
+ }
+
+ private static KernelResult<string> BuildSurfaceOfRevolutionSurface(Step242TextWriter writer, SurfaceOfRevolutionSurface surface)
+ {
+ var directrixIdResult = BuildSurfaceCurve(writer, surface.Directrix, "Surface.Directrix.SurfaceOfRevolution");
+ if (!directrixIdResult.IsSuccess)
+ {
+ return directrixIdResult;
+ }
+
+ var axisPlacementId = BuildAxis1Placement(writer, surface.AxisOrigin, surface.AxisDirection);
+ return KernelResult<string>.Success(writer.AddEntity(
+ "SURFACE_OF_REVOLUTION",
+ "$",
+ Step242TextWriter.Ref(directrixIdResult.Value),
+ Step242TextWriter.Ref(axisPlacementId)));
+ }
+
private static string BuildBSplineSurfaceWithKnots(Step242TextWriter writer, BSplineSurfaceWithKnots surface)
{
var controlPointRows = surface.ControlPoints
@@ -444,6 +481,8 @@ public static class Step242Exporter
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.LinearExtrusion when surface.LinearExtrusion is LinearExtrusionSurface linearExtrusion => BuildLinearExtrusionSurface(writer, linearExtrusion),
+ SurfaceGeometryKind.SurfaceOfRevolution when surface.SurfaceOfRevolution is SurfaceOfRevolutionSurface surfaceOfRevolution => BuildSurfaceOfRevolutionSurface(writer, surfaceOfRevolution),
SurfaceGeometryKind.BSplineSurfaceWithKnots when surface.BSplineSurfaceWithKnots is BSplineSurfaceWithKnots bSplineSurface => KernelResult<string>.Success(BuildBSplineSurfaceWithKnots(writer, bSplineSurface)),
_ => Failure($"Unsupported surface kind '{surface.Kind}'.", $"Face:{faceId.Value}")
};
@@ -463,6 +502,59 @@ public static class Step242Exporter
return writer.AddEntity("AXIS2_PLACEMENT_3D", "$", Step242TextWriter.Ref(originId), Step242TextWriter.Ref(axisId), Step242TextWriter.Ref(referenceId));
}
+ private static string BuildAxis1Placement(Step242TextWriter writer, Point3D origin, Direction3D axis)
+ {
+ var originId = writer.AddEntity("CARTESIAN_POINT", "$", PointList(origin));
+ var axisVector = axis.ToVector();
+ var axisId = writer.AddEntity("DIRECTION", "$", Step242TextWriter.List(
+ Step242TextWriter.Number(axisVector.X),
+ Step242TextWriter.Number(axisVector.Y),
+ Step242TextWriter.Number(axisVector.Z)));
+ return writer.AddEntity("AXIS1_PLACEMENT", "$", Step242TextWriter.Ref(originId), Step242TextWriter.Ref(axisId));
+ }
+
+ private static KernelResult<string> BuildVector(Step242TextWriter writer, Vector3D vector, string source)
+ {
+ if (!vector.TryNormalize(out var direction))
+ {
+ return Failure("Vector must be non-zero.", source);
+ }
+
+ var magnitude = vector.Length;
+ if (!double.IsFinite(magnitude) || magnitude <= 0d)
+ {
+ return Failure("Vector magnitude must be finite and greater than zero.", source);
+ }
+
+ var directionId = writer.AddEntity("DIRECTION", "$", Step242TextWriter.List(
+ Step242TextWriter.Number(direction.X),
+ Step242TextWriter.Number(direction.Y),
+ Step242TextWriter.Number(direction.Z)));
+ return KernelResult<string>.Success(writer.AddEntity("VECTOR", "$", Step242TextWriter.Ref(directionId), Step242TextWriter.Number(magnitude)));
+ }
+
+ private static KernelResult<string> BuildSurfaceCurve(Step242TextWriter writer, CurveGeometry curve, string source)
+ {
+ if (curve.Kind == CurveGeometryKind.Line3 && curve.Line3 is Line3Curve line)
+ {
+ var originId = writer.AddEntity("CARTESIAN_POINT", "$", PointList(line.Origin));
+ var directionId = writer.AddEntity("DIRECTION", "$", Step242TextWriter.List(
+ Step242TextWriter.Number(line.Direction.X),
+ Step242TextWriter.Number(line.Direction.Y),
+ Step242TextWriter.Number(line.Direction.Z)));
+ var vectorId = writer.AddEntity("VECTOR", "$", Step242TextWriter.Ref(directionId), Step242TextWriter.Number(1d));
+ return KernelResult<string>.Success(writer.AddEntity("LINE", "$", Step242TextWriter.Ref(originId), Step242TextWriter.Ref(vectorId)));
+ }
+
+ if (curve.Kind == CurveGeometryKind.Circle3 && curve.Circle3 is Circle3Curve circle)
+ {
+ var axisPlacementId = BuildAxisPlacement(writer, circle.Center, circle.Normal, circle.XAxis);
+ return KernelResult<string>.Success(writer.AddEntity("CIRCLE", "$", Step242TextWriter.Ref(axisPlacementId), Step242TextWriter.Number(circle.Radius)));
+ }
+
+ return Failure($"Unsupported swept directrix curve kind '{curve.Kind}'.", source);
+ }
+
private static KernelResult<string> BuildEdgeCurve(
BrepBody body,
TopologyModel model,
diff --git a/Aetheris.Kernel.Core/Step242/Step242Importer.cs b/Aetheris.Kernel.Core/Step242/Step242Importer.cs
index 485c1928..6a10eb89 100644
--- a/Aetheris.Kernel.Core/Step242/Step242Importer.cs
+++ b/Aetheris.Kernel.Core/Step242/Step242Importer.cs
@@ -1008,6 +1008,32 @@ public static class Step242Importer
return KernelResult<(SurfaceGeometryId SurfaceGeometryId, SurfaceGeometry SurfaceGeometry)>.Success((geometryId, SurfaceGeometry.FromTorus(torusResult.Value)));
}
+ if (string.Equals(normalizedName, "SURFACE_OF_LINEAR_EXTRUSION", StringComparison.Ordinal))
+ {
+ var linearExtrusionResult = Step242SubsetDecoder.ReadLinearExtrusionSurface(document, surfaceToDecode);
+ if (!linearExtrusionResult.IsSuccess)
+ {
+ return KernelResult<(SurfaceGeometryId SurfaceGeometryId, SurfaceGeometry SurfaceGeometry)>.Failure(linearExtrusionResult.Diagnostics);
+ }
+
+ return KernelResult<(SurfaceGeometryId SurfaceGeometryId, SurfaceGeometry SurfaceGeometry)>.Success((
+ geometryId,
+ SurfaceGeometry.FromLinearExtrusion(linearExtrusionResult.Value)));
+ }
+
+ if (string.Equals(normalizedName, "SURFACE_OF_REVOLUTION", StringComparison.Ordinal))
+ {
+ var surfaceOfRevolutionResult = Step242SubsetDecoder.ReadSurfaceOfRevolution(document, surfaceToDecode);
+ if (!surfaceOfRevolutionResult.IsSuccess)
+ {
+ return KernelResult<(SurfaceGeometryId SurfaceGeometryId, SurfaceGeometry SurfaceGeometry)>.Failure(surfaceOfRevolutionResult.Diagnostics);
+ }
+
+ return KernelResult<(SurfaceGeometryId SurfaceGeometryId, SurfaceGeometry SurfaceGeometry)>.Success((
+ geometryId,
+ SurfaceGeometry.FromSurfaceOfRevolution(surfaceOfRevolutionResult.Value)));
+ }
+
var bSplineSurfaceEntity = ResolveBSplineSurfaceEntity(surfaceToDecode);
if (bSplineSurfaceEntity is not null)
{
@@ -1084,7 +1110,9 @@ public static class Step242Importer
&& !string.Equals(surfaceName, "CYLINDRICAL_SURFACE", StringComparison.Ordinal)
&& !string.Equals(surfaceName, "CONICAL_SURFACE", StringComparison.Ordinal)
&& !string.Equals(surfaceName, "SPHERICAL_SURFACE", StringComparison.Ordinal)
- && !string.Equals(surfaceName, "TOROIDAL_SURFACE", StringComparison.Ordinal))
+ && !string.Equals(surfaceName, "TOROIDAL_SURFACE", StringComparison.Ordinal)
+ && !string.Equals(surfaceName, "SURFACE_OF_LINEAR_EXTRUSION", StringComparison.Ordinal)
+ && !string.Equals(surfaceName, "SURFACE_OF_REVOLUTION", StringComparison.Ordinal))
{
return FailureInlineSurface<Step242ParsedEntity>($"ADVANCED_FACE surface: inline constructor '{surfaceName}' is not supported in this subset.", SourceFor(faceEntityId, "Importer.StepSyntax.InlineEntity"));
}
@@ -1258,6 +1286,68 @@ public static class Step242Importer
return FailureInlineSurface<IReadOnlyList<Step242Value>>("Inline ADVANCED_FACE.surface constructor 'TOROIDAL_SURFACE' has unsupported argument shape.", SourceFor(faceEntityId, "Importer.StepSyntax.InlineEntity"));
}
+ if (string.Equals(surfaceName, "SURFACE_OF_LINEAR_EXTRUSION", StringComparison.Ordinal))
+ {
+ if (inlineArguments.Count == 2)
+ {
+ if (inlineArguments[0] is not Step242EntityReference || inlineArguments[1] is not Step242EntityReference)
+ {
+ return FailureInlineSurface<IReadOnlyList<Step242Value>>("Inline ADVANCED_FACE.surface constructor 'SURFACE_OF_LINEAR_EXTRUSION' 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 Step242EntityReference)
+ {
+ return FailureInlineSurface<IReadOnlyList<Step242Value>>("Inline ADVANCED_FACE.surface constructor 'SURFACE_OF_LINEAR_EXTRUSION' has unsupported argument shape.", SourceFor(faceEntityId, "Importer.StepSyntax.InlineEntity"));
+ }
+
+ return KernelResult<IReadOnlyList<Step242Value>>.Success(inlineArguments);
+ }
+
+ return FailureInlineSurface<IReadOnlyList<Step242Value>>("Inline ADVANCED_FACE.surface constructor 'SURFACE_OF_LINEAR_EXTRUSION' has unsupported argument shape.", SourceFor(faceEntityId, "Importer.StepSyntax.InlineEntity"));
+ }
+
+ if (string.Equals(surfaceName, "SURFACE_OF_REVOLUTION", StringComparison.Ordinal))
+ {
+ if (inlineArguments.Count == 2)
+ {
+ if (inlineArguments[0] is not Step242EntityReference || inlineArguments[1] is not Step242EntityReference)
+ {
+ return FailureInlineSurface<IReadOnlyList<Step242Value>>("Inline ADVANCED_FACE.surface constructor 'SURFACE_OF_REVOLUTION' 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 Step242EntityReference)
+ {
+ return FailureInlineSurface<IReadOnlyList<Step242Value>>("Inline ADVANCED_FACE.surface constructor 'SURFACE_OF_REVOLUTION' has unsupported argument shape.", SourceFor(faceEntityId, "Importer.StepSyntax.InlineEntity"));
+ }
+
+ return KernelResult<IReadOnlyList<Step242Value>>.Success(inlineArguments);
+ }
+
+ return FailureInlineSurface<IReadOnlyList<Step242Value>>("Inline ADVANCED_FACE.surface constructor 'SURFACE_OF_REVOLUTION' has unsupported argument shape.", SourceFor(faceEntityId, "Importer.StepSyntax.InlineEntity"));
+ }
+
return KernelResult<IReadOnlyList<Step242Value>>.Success(inlineArguments);
}
diff --git a/Aetheris.Kernel.Core/Step242/Step242SubsetDecoder.cs b/Aetheris.Kernel.Core/Step242/Step242SubsetDecoder.cs
index 10137c84..d348d8e3 100644
--- a/Aetheris.Kernel.Core/Step242/Step242SubsetDecoder.cs
+++ b/Aetheris.Kernel.Core/Step242/Step242SubsetDecoder.cs
@@ -1,4 +1,5 @@
using Aetheris.Kernel.Core.Diagnostics;
+using Aetheris.Kernel.Core.Geometry;
using Aetheris.Kernel.Core.Geometry.Curves;
using Aetheris.Kernel.Core.Geometry.Surfaces;
using Aetheris.Kernel.Core.Math;
@@ -243,6 +244,140 @@ internal static class Step242SubsetDecoder
return KernelResult<Line3Curve>.Success(new Line3Curve(originResult.Value, directionResult.Value));
}
+ public static KernelResult<Vector3D> ReadVector(Step242ParsedDocument document, int vectorEntityId, string context, string source)
+ {
+ var vectorEntityResult = document.TryGetEntity(vectorEntityId, "VECTOR");
+ if (!vectorEntityResult.IsSuccess)
+ {
+ return KernelResult<Vector3D>.Failure(vectorEntityResult.Diagnostics);
+ }
+
+ return ReadVector(document, vectorEntityResult.Value, context, source);
+ }
+
+ public static KernelResult<Vector3D> ReadVector(Step242ParsedDocument document, Step242ParsedEntity vectorEntity, string context, string source)
+ {
+ var directionRefResult = ReadReference(vectorEntity, 1, $"{context} direction");
+ if (!directionRefResult.IsSuccess)
+ {
+ return KernelResult<Vector3D>.Failure(directionRefResult.Diagnostics);
+ }
+
+ var directionEntityResult = document.TryGetEntity(directionRefResult.Value.TargetId, "DIRECTION");
+ if (!directionEntityResult.IsSuccess)
+ {
+ return KernelResult<Vector3D>.Failure(directionEntityResult.Diagnostics);
+ }
+
+ var directionResult = ReadDirection(directionEntityResult.Value, $"{context} direction");
+ if (!directionResult.IsSuccess)
+ {
+ return KernelResult<Vector3D>.Failure(directionResult.Diagnostics);
+ }
+
+ var magnitudeResult = ReadPositiveNumber(vectorEntity, 2, $"{context} magnitude", source);
+ if (!magnitudeResult.IsSuccess)
+ {
+ return KernelResult<Vector3D>.Failure(magnitudeResult.Diagnostics);
+ }
+
+ return KernelResult<Vector3D>.Success(directionResult.Value.ToVector() * magnitudeResult.Value);
+ }
+
+ public static KernelResult<CurveGeometry> ReadCurveGeometry(Step242ParsedDocument document, int curveEntityId, string context, string source)
+ {
+ var curveEntityResult = document.TryGetEntity(curveEntityId);
+ if (!curveEntityResult.IsSuccess)
+ {
+ return KernelResult<CurveGeometry>.Failure(curveEntityResult.Diagnostics);
+ }
+
+ var curveEntity = curveEntityResult.Value;
+ var lineConstructor = TryGetConstructor(curveEntity.Instance, "LINE");
+ if (lineConstructor is not null)
+ {
+ var lineResult = ReadLineCurve(document, new Step242ParsedEntity(curveEntity.Id, new Step242SimpleEntityInstance(lineConstructor)));
+ return !lineResult.IsSuccess
+ ? KernelResult<CurveGeometry>.Failure(lineResult.Diagnostics)
+ : KernelResult<CurveGeometry>.Success(CurveGeometry.FromLine(lineResult.Value));
+ }
+
+ var circleConstructor = TryGetConstructor(curveEntity.Instance, "CIRCLE");
+ if (circleConstructor is not null)
+ {
+ var circleResult = ReadCircleCurve(document, new Step242ParsedEntity(curveEntity.Id, new Step242SimpleEntityInstance(circleConstructor)));
+ return !circleResult.IsSuccess
+ ? KernelResult<CurveGeometry>.Failure(circleResult.Diagnostics)
+ : KernelResult<CurveGeometry>.Success(CurveGeometry.FromCircle(circleResult.Value));
+ }
+
+ return Failure<CurveGeometry>($"{context}: directrix curve '{curveEntity.Name}' is unsupported.", source);
+ }
+
+ public static KernelResult<LinearExtrusionSurface> ReadLinearExtrusionSurface(Step242ParsedDocument document, Step242ParsedEntity surfaceEntity)
+ {
+ const string source = "Importer.Geometry.LinearExtrusion";
+ var directrixRefResult = ReadReference(surfaceEntity, 1, "SURFACE_OF_LINEAR_EXTRUSION swept_curve");
+ if (!directrixRefResult.IsSuccess)
+ {
+ return KernelResult<LinearExtrusionSurface>.Failure(directrixRefResult.Diagnostics);
+ }
+
+ var directrixResult = ReadCurveGeometry(document, directrixRefResult.Value.TargetId, "SURFACE_OF_LINEAR_EXTRUSION swept_curve", source);
+ if (!directrixResult.IsSuccess)
+ {
+ return KernelResult<LinearExtrusionSurface>.Failure(directrixResult.Diagnostics);
+ }
+
+ var vectorRefResult = ReadReference(surfaceEntity, 2, "SURFACE_OF_LINEAR_EXTRUSION extrusion_axis");
+ if (!vectorRefResult.IsSuccess)
+ {
+ return KernelResult<LinearExtrusionSurface>.Failure(vectorRefResult.Diagnostics);
+ }
+
+ var vectorResult = ReadVector(document, vectorRefResult.Value.TargetId, "SURFACE_OF_LINEAR_EXTRUSION extrusion_axis", source);
+ if (!vectorResult.IsSuccess)
+ {
+ return KernelResult<LinearExtrusionSurface>.Failure(vectorResult.Diagnostics);
+ }
+
+ try
+ {
+ return KernelResult<LinearExtrusionSurface>.Success(new LinearExtrusionSurface(directrixResult.Value, vectorResult.Value));
+ }
+ catch (ArgumentException ex)
+ {
+ return Failure<LinearExtrusionSurface>(KernelDiagnosticCode.InvalidArgument, ex.Message, source);
+ }
+ }
+
+ public static KernelResult<SurfaceOfRevolutionSurface> ReadSurfaceOfRevolution(Step242ParsedDocument document, Step242ParsedEntity surfaceEntity)
+ {
+ const string source = "Importer.Geometry.SurfaceOfRevolution";
+ var directrixRefResult = ReadReference(surfaceEntity, 1, "SURFACE_OF_REVOLUTION swept_curve");
+ if (!directrixRefResult.IsSuccess)
+ {
+ return KernelResult<SurfaceOfRevolutionSurface>.Failure(directrixRefResult.Diagnostics);
+ }
+
+ var directrixResult = ReadCurveGeometry(document, directrixRefResult.Value.TargetId, "SURFACE_OF_REVOLUTION swept_curve", source);
+ if (!directrixResult.IsSuccess)
+ {
+ return KernelResult<SurfaceOfRevolutionSurface>.Failure(directrixResult.Diagnostics);
+ }
+
+ var axisPlacementResult = ReadAxis1Placement(document, surfaceEntity, 2, "SURFACE_OF_REVOLUTION axis_position", source);
+ if (!axisPlacementResult.IsSuccess)
+ {
+ return KernelResult<SurfaceOfRevolutionSurface>.Failure(axisPlacementResult.Diagnostics);
+ }
+
+ return KernelResult<SurfaceOfRevolutionSurface>.Success(new SurfaceOfRevolutionSurface(
+ directrixResult.Value,
+ axisPlacementResult.Value.Origin,
+ axisPlacementResult.Value.Axis));
+ }
+
public static KernelResult<PlaneSurface> ReadPlaneSurface(Step242ParsedDocument document, Step242ParsedEntity planeEntity)
{
var placementResult = ReadAxis2Placement3D(document, planeEntity, 1, "PLANE position", SourceFor(planeEntity.Id, "Importer.Geometry.Plane"));
@@ -698,6 +833,58 @@ internal static class Step242SubsetDecoder
return KernelResult<(Point3D, Direction3D, Direction3D)>.Success((originResult.Value, axis, referenceAxis));
}
+ private static KernelResult<(Point3D Origin, Direction3D Axis)> ReadAxis1Placement(
+ Step242ParsedDocument document,
+ Step242ParsedEntity ownerEntity,
+ int argumentIndex,
+ string context,
+ string geometrySource)
+ {
+ var placementRefResult = ReadReference(ownerEntity, argumentIndex, context);
+ if (!placementRefResult.IsSuccess)
+ {
+ return KernelResult<(Point3D Origin, Direction3D Axis)>.Failure(placementRefResult.Diagnostics);
+ }
+
+ var placementEntityResult = document.TryGetEntity(placementRefResult.Value.TargetId, "AXIS1_PLACEMENT");
+ if (!placementEntityResult.IsSuccess)
+ {
+ return KernelResult<(Point3D Origin, Direction3D Axis)>.Failure(placementEntityResult.Diagnostics);
+ }
+
+ var placementEntity = placementEntityResult.Value;
+ var originRefResult = ReadReference(placementEntity, 1, "AXIS1_PLACEMENT origin");
+ if (!originRefResult.IsSuccess)
+ {
+ return KernelResult<(Point3D Origin, Direction3D Axis)>.Failure(originRefResult.Diagnostics);
+ }
+
+ var originEntityResult = document.TryGetEntity(originRefResult.Value.TargetId, "CARTESIAN_POINT");
+ if (!originEntityResult.IsSuccess)
+ {
+ return KernelResult<(Point3D Origin, Direction3D Axis)>.Failure(originEntityResult.Diagnostics);
+ }
+
+ var originResult = ReadCartesianPoint(originEntityResult.Value, "AXIS1_PLACEMENT origin");
+ if (!originResult.IsSuccess)
+ {
+ return KernelResult<(Point3D Origin, Direction3D Axis)>.Failure(originResult.Diagnostics);
+ }
+
+ var axisResult = ReadPlacementDirection(document, placementEntity, 2, "AXIS1_PLACEMENT axis", new Vector3D(0d, 0d, 1d));
+ if (!axisResult.IsSuccess)
+ {
+ return KernelResult<(Point3D Origin, Direction3D Axis)>.Failure(axisResult.Diagnostics);
+ }
+
+ if (!double.IsFinite(originResult.Value.X) || !double.IsFinite(originResult.Value.Y) || !double.IsFinite(originResult.Value.Z))
+ {
+ return Failure<(Point3D Origin, Direction3D Axis)>(KernelDiagnosticCode.InvalidArgument, "AXIS1_PLACEMENT origin must be finite.", geometrySource);
+ }
+
+ return KernelResult<(Point3D Origin, Direction3D Axis)>.Success((originResult.Value, axisResult.Value.Direction));
+ }
+
private static KernelResult<PlacementDirectionReadResult> ReadPlacementDirection(Step242ParsedDocument document, Step242ParsedEntity placementEntity, int argumentIndex, string context, Vector3D defaultDirection)
{
if (argumentIndex < 0 || argumentIndex >= placementEntity.Arguments.Count)
diff --git a/docs/audits/ruled-a0-ap242-ruled-swept-surface-audit.md b/docs/audits/ruled-a0-ap242-ruled-swept-surface-audit.md
index 0da956ec..affc43f7 100644
--- a/docs/audits/ruled-a0-ap242-ruled-swept-surface-audit.md
+++ b/docs/audits/ruled-a0-ap242-ruled-swept-surface-audit.md
@@ -1,5 +1,7 @@
# RULED-A0 AP242 exact ruled/swept surface audit
+Status note, 2026-06-22: RULED-A1 has now landed the minimal exact swept-surface skeleton for `SURFACE_OF_LINEAR_EXTRUSION` and `SURFACE_OF_REVOLUTION`, plus degree-1 ruled B-spline classification. See `docs/implementation/ruled-a1-exact-swept-surface-skeleton.md`.
+
## 1. Summary verdict
Aetheris currently has a solid elementary-surface AP242 lane for `PLANE`, `CYLINDRICAL_SURFACE`, `CONICAL_SURFACE`, `SPHERICAL_SURFACE`, and `TOROIDAL_SURFACE`, plus a generic `B_SPLINE_SURFACE_WITH_KNOTS` preservation lane. It does **not** currently parse or export `SURFACE_OF_LINEAR_EXTRUSION`, `SURFACE_OF_REVOLUTION`, or `RULED_SURFACE` in the STEP surface binding path.
diff --git a/docs/implementation/ruled-a1-exact-swept-surface-skeleton.md b/docs/implementation/ruled-a1-exact-swept-surface-skeleton.md
new file mode 100644
index 00000000..ab3bcfb5
--- /dev/null
+++ b/docs/implementation/ruled-a1-exact-swept-surface-skeleton.md
@@ -0,0 +1,132 @@
+# RULED-A1 exact swept surface skeleton
+
+## Scope delivered
+
+RULED-A1 adds a narrow AP242 exact-surface lane for:
+
+- `SURFACE_OF_LINEAR_EXTRUSION`
+- `SURFACE_OF_REVOLUTION`
+- degree-1 `B_SPLINE_SURFACE_WITH_KNOTS` ruled classification
+
+This milestone does not add Firmament ruled syntax, AIR ruled-transition primitives, general lofting, general NURBS conversion, full ruled-face construction, or `RULED_SURFACE`.
+
+## Internal surface kinds added
+
+`Aetheris.Kernel.Core/Geometry/SurfaceGeometry.cs` now includes:
+
+- `SurfaceGeometryKind.LinearExtrusion`
+- `SurfaceGeometryKind.SurfaceOfRevolution`
+
+Backed by:
+
+- `LinearExtrusionSurface`
+ - `CurveGeometry Directrix`
+ - `Vector3D ExtrusionVector`
+- `SurfaceOfRevolutionSurface`
+ - `CurveGeometry Directrix`
+ - `Point3D AxisOrigin`
+ - `Direction3D AxisDirection`
+
+The directrix is stored through the existing reusable `CurveGeometry` model instead of a one-off surface-only line record.
+
+## STEP entities imported/exported
+
+Importer support was added in `Step242Importer` and `Step242SubsetDecoder` for:
+
+- `SURFACE_OF_LINEAR_EXTRUSION`
+- `SURFACE_OF_REVOLUTION`
+- `AXIS1_PLACEMENT`
+- `VECTOR` decoding for swept-surface axes
+
+Exporter support was added in `Step242Exporter` for:
+
+- `SURFACE_OF_LINEAR_EXTRUSION`
+- `SURFACE_OF_REVOLUTION`
+- `AXIS1_PLACEMENT`
+- free directrix `LINE` / `CIRCLE`
+- free `VECTOR`
+
+The importer/exporter preserve these as exact swept surfaces and do not collapse them to B-spline fallback.
+
+## Directrix subset supported
+
+Imported/exported directrix subset:
+
+- `LINE`
+- `CIRCLE`
+
+RULED-A1 only requires line directrix coverage in tests. Circle directrix support was cheap because the STEP subset decoder and curve model already handled circles cleanly.
+
+Unsupported swept directrix curves still fail deterministically through the importer/exporter unsupported-surface path. They are not silently degraded to B-spline.
+
+## Degree-1 B-spline ruled classification
+
+`Step242BsplineRuledClassifier` adds an exactness report without overwriting the original B-spline surface data.
+
+Classification rules:
+
+- `degreeU == 1 || degreeV == 1` -> exact ruled candidate
+- `degreeU == 1 && degreeV == 1` -> exact bilinear ruled patch
+- `degreeU > 1 && degreeV > 1` -> not ruled by degree alone
+
+Reported fields:
+
+- `IsRuledCandidate`
+- `RulingDirection`
+ - `U`
+ - `V`
+ - `Both`
+ - `None`
+- `IsBilinearPatch`
+- `Exactness`
+ - `ExactRuled`
+ - `None`
+- `Reason`
+
+This classification is intentionally separate from analytic recovery. The existing bounded cylinder recovery lane still runs for its rational `(1,3)` / `(3,1)` cases, but degree-1 B-splines are no longer conceptually “approximation garbage” by default.
+
+## Fixtures
+
+Probe fixtures added under `testdata/step242/probes/`:
+
+- `surface-of-linear-extrusion-line.step`
+- `surface-of-revolution-line.step`
+- `bspline-degree-1-1-bilinear.step`
+
+These are small importable AP242 probes for exact surface import/export/reimport testing.
+
+## Validation commands
+
+Primary validation commands used for RULED-A1:
+
+```powershell
+dotnet restore Aetheris.slnx
+dotnet build Aetheris.slnx -f net10.0 --no-restore /m:1
+dotnet test Aetheris.Kernel.Core.Tests\Aetheris.Kernel.Core.Tests.csproj -f net10.0 --no-build --filter "FullyQualifiedName~Step242RuledSurfaceSkeletonTests|FullyQualifiedName~Step242BSplineSurfaceWithKnotsTests|FullyQualifiedName~Step242OcctCylinderRecoveryTests|FullyQualifiedName~Step242ConicalSurfaceRegressionTests|FullyQualifiedName~Step242InlineSurfaceConstructorTests|FullyQualifiedName~Step242ExporterTests|FullyQualifiedName~Step242ImporterTests"
+dotnet test Aetheris.Kernel.Firmament.Tests\Aetheris.Kernel.Firmament.Tests.csproj -f net10.0 --no-build --filter "InlineStep"
+dotnet run --project Aetheris.CLI -- --help
+```
+
+Broader `Step242|Surface|Bspline|Ruled|Extrusion|Revolution` filtering also reaches NIST audit snapshot tests. Those snapshots change because canonical export now preserves additional exact swept-surface semantics. That broad command is still informative, but it is not the best focused gate for the bounded RULED-A1 lane.
+
+## External validation
+
+FreeCAD validation command:
+
+```powershell
+.\tools\Validate-Step-FreeCAD.ps1 .\testdata\step242\probes\surface-of-linear-extrusion-line.step
+.\tools\Validate-Step-FreeCAD.ps1 .\testdata\step242\probes\surface-of-revolution-line.step
+.\tools\Validate-Step-FreeCAD.ps1 .\testdata\step242\probes\bspline-degree-1-1-bilinear.step
+```
+
+If `FreeCADCmd` is not on `PATH`, the script skips cleanly and reports the skip.
+
+## Known limitations
+
+- `RULED_SURFACE` is still not implemented.
+- No Firmament ruled syntax was added.
+- No AIR ruled-transition primitive was added.
+- No general loft or general NURBS conversion was added.
+- No automatic simplification from swept surfaces to elementary surfaces was added here.
+- Multi-loop hole classification for the new swept surface kinds is still not a dedicated path; RULED-A1 stays on the minimal exact import/export skeleton.
+- The broad NIST audit snapshot suite needs explicit snapshot refresh if the project wants canonical hashes to encode the new preserved surface semantics.
diff --git a/testdata/step242/probes/bspline-degree-1-1-bilinear.step b/testdata/step242/probes/bspline-degree-1-1-bilinear.step
new file mode 100644
index 00000000..08ed99f4
--- /dev/null
+++ b/testdata/step242/probes/bspline-degree-1-1-bilinear.step
@@ -0,0 +1,44 @@
+ISO-10303-21;
+HEADER;
+ENDSEC;
+DATA;
+#1=MANIFOLD_SOLID_BREP('bspline_bilinear_probe',#2);
+#2=CLOSED_SHELL($,(#3));
+#3=ADVANCED_FACE((#4),#5,.T.);
+#4=FACE_OUTER_BOUND($,#6,.T.);
+#5=B_SPLINE_SURFACE_WITH_KNOTS('',1,1,((#100,#101),(#102,#103)),.UNSPECIFIED.,.F.,.F.,.F.,(2,2),(2,2),(0.,1.),(0.,1.),.UNSPECIFIED.);
+#6=EDGE_LOOP($,(#10,#11,#12,#13));
+#10=ORIENTED_EDGE($,$,$,#20,.T.);
+#11=ORIENTED_EDGE($,$,$,#21,.T.);
+#12=ORIENTED_EDGE($,$,$,#22,.T.);
+#13=ORIENTED_EDGE($,$,$,#23,.T.);
+#20=EDGE_CURVE($,#30,#31,#60,.T.);
+#21=EDGE_CURVE($,#31,#32,#61,.T.);
+#22=EDGE_CURVE($,#32,#33,#62,.T.);
+#23=EDGE_CURVE($,#33,#30,#63,.T.);
+#30=VERTEX_POINT($,#50);
+#31=VERTEX_POINT($,#51);
+#32=VERTEX_POINT($,#52);
+#33=VERTEX_POINT($,#53);
+#50=CARTESIAN_POINT($,(0.,0.,0.));
+#51=CARTESIAN_POINT($,(1.,0.,0.));
+#52=CARTESIAN_POINT($,(1.,1.,1.));
+#53=CARTESIAN_POINT($,(0.,1.,0.));
+#60=LINE($,#50,#70);
+#61=LINE($,#51,#71);
+#62=LINE($,#52,#72);
+#63=LINE($,#53,#73);
+#70=VECTOR($,#90,1.);
+#71=VECTOR($,#91,1.);
+#72=VECTOR($,#92,1.);
+#73=VECTOR($,#93,1.);
+#90=DIRECTION($,(1.,0.,0.));
+#91=DIRECTION($,(0.,1.,1.));
+#92=DIRECTION($,(-1.,0.,-1.));
+#93=DIRECTION($,(0.,-1.,0.));
+#100=CARTESIAN_POINT($,(0.,0.,0.));
+#101=CARTESIAN_POINT($,(0.,1.,0.));
+#102=CARTESIAN_POINT($,(1.,0.,0.));
+#103=CARTESIAN_POINT($,(1.,1.,1.));
+ENDSEC;
+END-ISO-10303-21;
diff --git a/testdata/step242/probes/surface-of-linear-extrusion-line.step b/testdata/step242/probes/surface-of-linear-extrusion-line.step
new file mode 100644
index 00000000..169a3ea6
--- /dev/null
+++ b/testdata/step242/probes/surface-of-linear-extrusion-line.step
@@ -0,0 +1,43 @@
+ISO-10303-21;
+HEADER;
+ENDSEC;
+DATA;
+#1=MANIFOLD_SOLID_BREP('linear_extrusion_probe',#2);
+#2=CLOSED_SHELL($,(#3));
+#3=ADVANCED_FACE((#4),#5,.T.);
+#4=FACE_OUTER_BOUND($,#6,.T.);
+#5=SURFACE_OF_LINEAR_EXTRUSION($,#40,#80);
+#6=EDGE_LOOP($,(#10,#11,#12,#13));
+#10=ORIENTED_EDGE($,$,$,#20,.T.);
+#11=ORIENTED_EDGE($,$,$,#21,.T.);
+#12=ORIENTED_EDGE($,$,$,#22,.T.);
+#13=ORIENTED_EDGE($,$,$,#23,.T.);
+#20=EDGE_CURVE($,#30,#31,#60,.T.);
+#21=EDGE_CURVE($,#31,#32,#61,.T.);
+#22=EDGE_CURVE($,#32,#33,#62,.T.);
+#23=EDGE_CURVE($,#33,#30,#63,.T.);
+#30=VERTEX_POINT($,#50);
+#31=VERTEX_POINT($,#51);
+#32=VERTEX_POINT($,#52);
+#33=VERTEX_POINT($,#53);
+#40=LINE($,#50,#70);
+#50=CARTESIAN_POINT($,(0.,0.,0.));
+#51=CARTESIAN_POINT($,(1.,0.,0.));
+#52=CARTESIAN_POINT($,(1.,0.,1.));
+#53=CARTESIAN_POINT($,(0.,0.,1.));
+#60=LINE($,#50,#70);
+#61=LINE($,#51,#71);
+#62=LINE($,#52,#72);
+#63=LINE($,#53,#73);
+#70=VECTOR($,#90,1.);
+#71=VECTOR($,#91,1.);
+#72=VECTOR($,#92,1.);
+#73=VECTOR($,#93,1.);
+#80=VECTOR($,#94,1.);
+#90=DIRECTION($,(1.,0.,0.));
+#91=DIRECTION($,(0.,0.,1.));
+#92=DIRECTION($,(-1.,0.,0.));
+#93=DIRECTION($,(0.,0.,-1.));
+#94=DIRECTION($,(0.,0.,1.));
+ENDSEC;
+END-ISO-10303-21;
diff --git a/testdata/step242/probes/surface-of-revolution-line.step b/testdata/step242/probes/surface-of-revolution-line.step
new file mode 100644
index 00000000..a4088cc6
--- /dev/null
+++ b/testdata/step242/probes/surface-of-revolution-line.step
@@ -0,0 +1,41 @@
+ISO-10303-21;
+HEADER;
+ENDSEC;
+DATA;
+#1=MANIFOLD_SOLID_BREP('surface_of_revolution_probe',#2);
+#2=CLOSED_SHELL($,(#3));
+#3=ADVANCED_FACE((#4),#5,.T.);
+#4=FACE_OUTER_BOUND($,#6,.T.);
+#5=SURFACE_OF_REVOLUTION($,#40,#30);
+#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($,#32,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=AXIS1_PLACEMENT($,#27,#28);
+#31=AXIS2_PLACEMENT_3D($,#29,#28,#33);
+#32=AXIS2_PLACEMENT_3D($,#27,#28,#33);
+#27=CARTESIAN_POINT($,(0.,0.,0.));
+#28=DIRECTION($,(0.,0.,1.));
+#29=CARTESIAN_POINT($,(0.,0.,1.));
+#33=DIRECTION($,(1.,0.,0.));
+#40=LINE($,#21,#41);
+#41=VECTOR($,#28,1.0);
+ENDSEC;
+END-ISO-10303-21;
diff --git a/tools/Validate-Step-FreeCAD.ps1 b/tools/Validate-Step-FreeCAD.ps1
index 1ddb52a7..4c629b8a 100644
--- a/tools/Validate-Step-FreeCAD.ps1
+++ b/tools/Validate-Step-FreeCAD.ps1
@@ -17,17 +17,20 @@ if (-not $freeCadCmd) {
}
$tempScript = [System.IO.Path]::GetTempFileName() + '.py'
+$resolvedStepFile = (Resolve-Path -LiteralPath $StepFile).Path
@'
import sys
import FreeCAD
import Import
-step_file = sys.argv[1]
+step_file = r'__STEP_FILE__'
doc = FreeCAD.newDocument('StepImportValidation')
try:
- Import.open(step_file)
- doc = FreeCAD.ActiveDocument or doc
+ Import.insert(step_file, doc.Name)
objects = list(doc.Objects)
+ if not objects:
+ raise RuntimeError('STEP import produced zero document objects')
+
valid = True
invalid = []
for obj in objects:
@@ -51,10 +54,10 @@ finally:
FreeCAD.closeDocument(doc.Name)
except Exception:
pass
-'@ | Set-Content -LiteralPath $tempScript -Encoding UTF8
+'@.Replace('__STEP_FILE__', $resolvedStepFile) | Set-Content -LiteralPath $tempScript -Encoding UTF8
try {
- & $freeCadCmd.Source $tempScript (Resolve-Path -LiteralPath $StepFile).Path
+ & $freeCadCmd.Source $tempScript
exit $LASTEXITCODE
}
finally {