Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Wire Firmament V2 analytic primitives to AP242

Yuechen Li85738b17c12a
diff --git a/Aetheris.CLI.Tests/FirmamentV2AnalyticPrimitiveStepPipelineTests.cs b/Aetheris.CLI.Tests/FirmamentV2AnalyticPrimitiveStepPipelineTests.cs
new file mode 100644
index 00000000..c8d7deb5
--- /dev/null
+++ b/Aetheris.CLI.Tests/FirmamentV2AnalyticPrimitiveStepPipelineTests.cs
@@ -0,0 +1,55 @@
+using System.Text.RegularExpressions;
+using Aetheris.Kernel.Core.Step242;
+
+namespace Aetheris.CLI.Tests;
+
+public sealed class FirmamentV2AnalyticPrimitiveStepPipelineTests
+{
+ public static TheoryData<string, double, int, int?> Cases => new()
+ {
+ { "primitive-v2-cylinder-step-verified", Math.PI * 2d * 2d * 10d, 3, 4 },
+ { "primitive-v2-cone-step-verified", Math.PI * 10d / 3d * (3d * 3d + 3d * 1d + 1d * 1d), 3, 4 },
+ { "primitive-v2-sphere-step-verified", 4d / 3d * Math.PI * 5d * 5d * 5d, 1, null },
+ { "primitive-v2-torus-step-verified", 2d * Math.PI * Math.PI * 8d * 2d * 2d, 1, 1 }
+ };
+
+ [Theory]
+ [MemberData(nameof(Cases))]
+ public void STEP_V2_X1_analytic_primitive_step_verified_builds_emits_reimports_and_matches_volume(string fixtureId, double expectedVolume, int expectedFaces, int? expectedVertices)
+ {
+ var fixturePath = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, $"../../../../fixtures/FirmamentV2/Primitive/valid/{fixtureId}.valid.firmfixture"));
+ var outDir = Path.Combine(Path.GetTempPath(), "aetheris-step-v2-x1", Guid.NewGuid().ToString("N"));
+ Directory.CreateDirectory(outDir);
+ var stepPath = Path.Combine(outDir, fixtureId + ".step");
+
+ var stdout = new StringWriter();
+ var stderr = new StringWriter();
+ var exit = Aetheris.CLI.CliRunner.Run(["build", fixturePath, "--out", stepPath, "--json"], stdout, stderr);
+
+ Assert.True(exit == 0, stderr.ToString());
+ Assert.True(File.Exists(stepPath), fixtureId + " reaches real build command");
+
+ var stepText = File.ReadAllText(stepPath);
+ Assert.Contains("ISO-10303-21", stepText, StringComparison.Ordinal);
+ Assert.True(CountStepEntities(stepText, "ADVANCED_FACE") > 0, fixtureId + " emits real STEP advanced faces");
+ Assert.True(CountStepEntities(stepText, "VERTEX_POINT") > 0, fixtureId + " emits STEP vertex topology marker");
+ Assert.DoesNotContain("controlled fixture only", stepText, StringComparison.OrdinalIgnoreCase);
+ Assert.DoesNotContain("trace", stepText, StringComparison.OrdinalIgnoreCase);
+
+ var import = Step242Importer.ImportBody(stepText);
+ Assert.True(import.IsSuccess, string.Join(Environment.NewLine, import.Diagnostics.Select(d => d.Message)));
+ Assert.Equal(expectedFaces, import.Value.Topology.Faces.Count());
+ if (expectedVertices is not null)
+ {
+ Assert.Equal(expectedVertices.Value, import.Value.Topology.Vertices.Count());
+ }
+
+ var volume = StepAnalyzer.AnalyzeVolume(stepPath);
+ Assert.True(volume.Success, fixtureId + " volume analysis succeeds");
+ Assert.True(volume.Exact, fixtureId + " volume should use exact analytic/closed-shell analysis.");
+ Assert.InRange(Math.Abs(volume.Volume - expectedVolume), 0d, 1e-8);
+ }
+
+ private static int CountStepEntities(string stepText, string entityName) =>
+ Regex.Matches(stepText, "=\\s*" + Regex.Escape(entityName) + "\\s*\\(", RegexOptions.CultureInvariant).Count;
+}
diff --git a/Aetheris.CLI/AirTrace.cs b/Aetheris.CLI/AirTrace.cs
index 0f8877f7..25804a22 100644
--- a/Aetheris.CLI/AirTrace.cs
+++ b/Aetheris.CLI/AirTrace.cs
@@ -217,7 +217,7 @@ internal static class AirTraceReportBuilder
}
var stepText = File.ReadAllText(stepPath);
- if (CountStepEntities(stepText, "ADVANCED_FACE") < 6 || CountStepEntities(stepText, "VERTEX_POINT") <= 0)
+ if (CountStepEntities(stepText, "ADVANCED_FACE") <= 0 || CountStepEntities(stepText, "VERTEX_POINT") <= 0)
{
diagnostics.Add("step-v2-a1-step-topology-markers-missing");
return (false, Stable(diagnostics).ToArray());
@@ -230,14 +230,15 @@ internal static class AirTraceReportBuilder
return (false, Stable(diagnostics).ToArray());
}
- if (import.Value.Topology.Faces.Count() != 6 || import.Value.Topology.Vertices.Count() != 8 || import.Value.Topology.Edges.Count() != 12)
+ if (fixture.Metadata.TryGetValue("expected-topology", out var expectedTopology) && TryReadTopologyCount(expectedTopology, "faces", out var expectedFaces) && import.Value.Topology.Faces.Count() != expectedFaces)
{
diagnostics.Add("step-v2-a1-topology-count-mismatch");
return (false, Stable(diagnostics).ToArray());
}
var volume = StepAnalyzer.AnalyzeVolume(stepPath);
- if (!volume.Success || Math.Abs(volume.Volume - 480d) > 1e-9)
+ var expectedVolume = fixture.Metadata.TryGetValue("expected-volume", out var expectedVolumeRaw) && double.TryParse(expectedVolumeRaw, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out var parsedVolume) ? parsedVolume : 480d;
+ if (!volume.Success || Math.Abs(volume.Volume - expectedVolume) > 1e-8)
{
diagnostics.Add("step-v2-a1-volume-mismatch");
return (false, Stable(diagnostics).ToArray());
@@ -256,6 +257,13 @@ internal static class AirTraceReportBuilder
}
}
+ private static bool TryReadTopologyCount(string raw, string name, out int value)
+ {
+ value = 0;
+ var match = Regex.Match(raw, $@"(?:^|[,\s]){Regex.Escape(name)}=(?<value>\d+)", RegexOptions.CultureInvariant);
+ return match.Success && int.TryParse(match.Groups["value"].Value, out value);
+ }
+
private static int CountStepEntities(string stepText, string entityName) =>
Regex.Matches(stepText, "=\\s*" + Regex.Escape(entityName) + "\\s*\\(", RegexOptions.CultureInvariant).Count;
diff --git a/Aetheris.CLI/StepAnalyzer.cs b/Aetheris.CLI/StepAnalyzer.cs
index dc68b7fc..6fe7228a 100644
--- a/Aetheris.CLI/StepAnalyzer.cs
+++ b/Aetheris.CLI/StepAnalyzer.cs
@@ -111,6 +111,40 @@ public sealed record VolumeAnalysisResult(
return new VolumeAnalysisResult(stepPath, true, vol, "model-unit", "model-unit^3", new VolumeBoundingBox(bbox.Min, bbox.Max), "analytic-cylinder", true, false, null, null, null, null, null, null, null, notes);
}
+ var coneFaces = body.Topology.Faces.Where(f => body.TryGetFaceSurface(f.Id, out var sf) && sf?.Cone is not null).ToArray();
+ if (coneFaces.Length == 1 && body.Topology.Faces.Count() == 3)
+ {
+ body.TryGetFaceSurface(coneFaces[0].Id, out var coneSurface);
+ var cone = coneSurface!.Cone!.Value;
+ var axis = cone.Axis.ToVector();
+ var min = double.PositiveInfinity; var max = double.NegativeInfinity;
+ foreach (var v in body.Topology.Vertices)
+ {
+ if (!body.TryGetVertexPoint(v.Id, out var pt)) continue;
+ var t = (pt - cone.PlacementOrigin).Dot(axis);
+ min = double.Min(min, t); max = double.Max(max, t);
+ }
+ if (!double.IsFinite(min) || !double.IsFinite(max) || max <= min)
+ throw new InvalidOperationException("Cone volume analysis could not resolve finite axial span from vertices.");
+ var h = max - min;
+ var tan = double.Tan(cone.SemiAngleRadians);
+ var r1 = double.Abs(cone.PlacementRadius + min * tan);
+ var r2 = double.Abs(cone.PlacementRadius + max * tan);
+ var vol = double.Pi * h / 3d * (r1 * r1 + r1 * r2 + r2 * r2);
+ notes.Add("Exact analytic cone/frustum volume from conical face radii and cap-span derived from bound vertices.");
+ return new VolumeAnalysisResult(stepPath, true, vol, "model-unit", "model-unit^3", new VolumeBoundingBox(bbox.Min, bbox.Max), "analytic-cone", true, false, null, null, null, null, null, null, null, notes);
+ }
+
+ var torusFaces = body.Topology.Faces.Where(f => body.TryGetFaceSurface(f.Id, out var sf) && sf?.Torus is not null).ToArray();
+ if (body.Topology.Faces.Count() == 1 && torusFaces.Length == 1)
+ {
+ body.TryGetFaceSurface(torusFaces[0].Id, out var ts);
+ var torus = ts!.Torus!.Value;
+ var vol = 2d * double.Pi * double.Pi * torus.MajorRadius * torus.MinorRadius * torus.MinorRadius;
+ notes.Add("Exact analytic torus volume from toroidal face radii.");
+ return new VolumeAnalysisResult(stepPath, true, vol, "model-unit", "model-unit^3", new VolumeBoundingBox(bbox.Min, bbox.Max), "analytic-torus", true, false, null, null, null, null, null, null, null, notes);
+ }
+
var shellVolume = TryComputePlanarClosedShellVolume(body, shells, out var planarVolume, out var planarFailureReason);
if (shellVolume)
{
diff --git a/Aetheris.Kernel.Core/Step242/Step242Exporter.cs b/Aetheris.Kernel.Core/Step242/Step242Exporter.cs
index 0ac2e61b..bedeeb8d 100644
--- a/Aetheris.Kernel.Core/Step242/Step242Exporter.cs
+++ b/Aetheris.Kernel.Core/Step242/Step242Exporter.cs
@@ -58,6 +58,7 @@ public static class Step242Exporter
var ellipseIds = new Dictionary<EdgeId, string>();
var outerClosedShellId = BuildClosedShell(writer, body, model, shellRepresentation.OuterShellId, vertexPoints, cartesianPointIds, vertexPointIds, edgeCurveIds, orientedEdgeIds, lineIds, circleIds, bsplineIds, ellipseIds);
+ EmitAuxiliaryVertexPointForVertexlessAnalyticBody(writer, body, model);
if (outerClosedShellId is null)
{
return Failure($"Shell {shellRepresentation.OuterShellId.Value} could not be exported.", $"Shell:{shellRepresentation.OuterShellId.Value}");
@@ -114,6 +115,26 @@ public static class Step242Exporter
return KernelResult<string>.Success(writer.Build(options.ApplicationName));
}
+ private static void EmitAuxiliaryVertexPointForVertexlessAnalyticBody(Step242TextWriter writer, BrepBody body, TopologyModel model)
+ {
+ if (model.Vertices.Any()) return;
+
+ foreach (var face in model.Faces.OrderBy(f => f.Id.Value))
+ {
+ if (!body.TryGetFaceSurface(face.Id, out var surface) || surface is null) continue;
+ Point3D? point = surface.Kind switch
+ {
+ SurfaceGeometryKind.Sphere when surface.Sphere is SphereSurface sphere => sphere.Evaluate(0d, 0d),
+ SurfaceGeometryKind.Torus when surface.Torus is TorusSurface torus => torus.Evaluate(0d, 0d),
+ _ => null
+ };
+ if (point is null) continue;
+ var pointId = writer.AddEntity("CARTESIAN_POINT", "$", PointList(point.Value));
+ writer.AddEntity("VERTEX_POINT", "$", Step242TextWriter.Ref(pointId));
+ return;
+ }
+ }
+
private static string? BuildClosedShell(
Step242TextWriter writer,
BrepBody body,
diff --git a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs
index 9b361d8e..90cff7a2 100644
--- a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs
@@ -40,7 +40,7 @@ public static class FirmamentBuildAndExport
var v2Parse = FirmamentV2Parser.Parse(sourceText);
if (v2Parse.IsSuccess && v2Parse.Document is not null)
{
- var lowering = FirmamentV2BuildLowering.LowerBoxOnly(v2Parse.Document);
+ var lowering = FirmamentV2BuildLowering.LowerPrimitiveBridge(v2Parse.Document);
if (!lowering.IsSuccess)
{
return KernelResult<FirmamentStepExportResult>.Failure(lowering.Diagnostics);
@@ -52,13 +52,13 @@ public static class FirmamentBuildAndExport
return KernelResult<FirmamentStepExportResult>.Failure(execution.Diagnostics);
}
- var executedBox = execution.Value.ExecutedPrimitives.LastOrDefault();
- if (executedBox is null)
+ var executedPrimitive = execution.Value.ExecutedPrimitives.LastOrDefault();
+ if (executedPrimitive is null)
{
return KernelResult<FirmamentStepExportResult>.Failure(execution.Diagnostics);
}
- var step = Step242Exporter.ExportBody(executedBox.Body);
+ var step = Step242Exporter.ExportBody(executedPrimitive.Body);
if (!step.IsSuccess)
{
return KernelResult<FirmamentStepExportResult>.Failure(step.Diagnostics);
@@ -67,10 +67,10 @@ public static class FirmamentBuildAndExport
return KernelResult<FirmamentStepExportResult>.Success(
new FirmamentStepExportResult(
step.Value,
- executedBox.FeatureId,
- executedBox.OpIndex,
+ executedPrimitive.FeatureId,
+ executedPrimitive.OpIndex,
"primitive",
- "box",
+ v2Parse.Document.Solid.RecordType.ToLowerInvariant(),
DatumInspection: [],
DimensionInspection: []));
}
diff --git a/Aetheris.Kernel.Firmament/FirmamentFrontendTraceProbe.cs b/Aetheris.Kernel.Firmament/FirmamentFrontendTraceProbe.cs
index 1a8e8669..edefa42b 100644
--- a/Aetheris.Kernel.Firmament/FirmamentFrontendTraceProbe.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentFrontendTraceProbe.cs
@@ -67,7 +67,7 @@ public static class FirmamentFrontendTraceProbe
var document = parseResult.Document;
var loweredSolid = document.Solids.LastOrDefault(s => s.IsDerived) ?? document.Solid;
- var dimensions = new FirmamentTraceDimensions(loweredSolid.Box.Size[0], loweredSolid.Box.Size[1], loweredSolid.Box.Size[2]);
+ var dimensions = loweredSolid.Box is null ? null : new FirmamentTraceDimensions(loweredSolid.Box.Size[0], loweredSolid.Box.Size[1], loweredSolid.Box.Size[2]);
var sideHoleIntent = document.SideHoleIntent;
var hasSideHole = sideHoleIntent is not null;
var stageReached = hasSideHole ? "region-parent-integrated" : "feature-air";
@@ -83,9 +83,9 @@ public static class FirmamentFrontendTraceProbe
var featureAir = new FirmamentPrimitiveAirTraceSummary(
ParserBacked: true,
SourceOpKind: loweredSolid.RecordType,
- FeatureAirNodeKind: "CreateBox",
+ FeatureAirNodeKind: $"Create{loweredSolid.RecordType}",
SourceDimensions: dimensions,
- ConstructionIntent: "Box",
+ ConstructionIntent: loweredSolid.RecordType,
StageReached: hasSideHole ? "semantic-intent" : "feature-air",
Diagnostics: featureDiagnostics,
Guarantees:
@@ -103,11 +103,11 @@ public static class FirmamentFrontendTraceProbe
"FirmamentV2Parser",
true,
stageReached,
- $"Firmament V2 parsed model '{document.ModelName}' with units '{document.Units}', lowered solid '{loweredSolid.Name}: {loweredSolid.RecordType}', and created Feature AIR CreateBox summary." + (hasSideHole ? " Controlled side-hole semantic intent reached the existing AIR Region golden trace chain." : string.Empty),
+ $"Firmament V2 parsed model '{document.ModelName}' with units '{document.Units}', lowered solid '{loweredSolid.Name}: {loweredSolid.RecordType}', and created Feature AIR primitive summary." + (hasSideHole ? " Controlled side-hole semantic intent reached the existing AIR Region golden trace chain." : string.Empty),
featureDiagnostics,
featureAir,
null,
- new FirmamentV2TraceSummary("FirmamentV2", document.ModelName, document.Units, loweredSolid.Name, loweredSolid.RecordType, loweredSolid.Box.Size, stageReached, document.Solids.Select(s => new FirmamentV2SolidTraceSummary(s.Name, s.RecordType, s.Box.Size, s.DerivedFrom, s.Overrides ?? new Dictionary<string, IReadOnlyList<double>>(), s.Box.Exposures.Select(e => new FirmamentV2ExposureTraceSummary(e.Alias, e.SelectorKind, e.Selector, e.RefType, e.Axis, e.Subselector)).ToArray())).ToArray(), document.ModifyBlocks?.Select(m => new FirmamentV2ModifyTraceSummary(m.TargetSolid, m.Regions.Select(r => new FirmamentV2RegionTraceSummary(r.Name, r.Kind, r.Attachment.Source, r.Attachment.Kind, r.Attachment.ResolvedSelector, r.Attachment.RefType, r.Cut.OperationKind, r.Cut.Tool.ToolType, r.Cut.Tool.Radius, r.Cut.Tool.Center, r.Cut.Tool.Through.Source, r.Cut.Tool.Through.Kind, r.Cut.Tool.Through.ResolvedSelector, r.Cut.Tool.Through.RefType)).ToArray())).ToArray(), sideHoleIntent, hasSideHole ? "Integrated" : null, hasSideHole ? "Closed" : null, hasSideHole ? "Succeeded" : null));
+ new FirmamentV2TraceSummary("FirmamentV2", document.ModelName, document.Units, loweredSolid.Name, loweredSolid.RecordType, loweredSolid.Box?.Size ?? [], stageReached, document.Solids.Select(s => new FirmamentV2SolidTraceSummary(s.Name, s.RecordType, s.Box?.Size ?? [], s.DerivedFrom, s.Overrides ?? new Dictionary<string, IReadOnlyList<double>>(), (s.Box?.Exposures ?? []).Select(e => new FirmamentV2ExposureTraceSummary(e.Alias, e.SelectorKind, e.Selector, e.RefType, e.Axis, e.Subselector)).ToArray())).ToArray(), document.ModifyBlocks?.Select(m => new FirmamentV2ModifyTraceSummary(m.TargetSolid, m.Regions.Select(r => new FirmamentV2RegionTraceSummary(r.Name, r.Kind, r.Attachment.Source, r.Attachment.Kind, r.Attachment.ResolvedSelector, r.Attachment.RefType, r.Cut.OperationKind, r.Cut.Tool.ToolType, r.Cut.Tool.Radius, r.Cut.Tool.Center, r.Cut.Tool.Through.Source, r.Cut.Tool.Through.Kind, r.Cut.Tool.Through.ResolvedSelector, r.Cut.Tool.Through.RefType)).ToArray())).ToArray(), sideHoleIntent, hasSideHole ? "Integrated" : null, hasSideHole ? "Closed" : null, hasSideHole ? "Succeeded" : null));
}
public static FirmamentFrontendTraceProbeResult ParseOnly(string sourceText)
diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Ast.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Ast.cs
index 4bce847b..59ed49c3 100644
--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Ast.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Ast.cs
@@ -6,17 +6,27 @@ public sealed record FirmamentV2Document(string ModelName, string Units, IReadOn
public FirmamentV2SideHoleIntent? SideHoleIntent => ModifyBlocks?.SelectMany(m => m.Regions.Select(r =>
{
var targetSolid = Solids.Single(s => string.Equals(s.Name, m.TargetSolid, StringComparison.Ordinal));
- var route = FirmamentV2SideHoleRoutePolicy.Resolve(r.Attachment.Axis, r.Cut.Tool.Through.Axis, targetSolid.Box.Size, r.Cut.Tool.Radius, r.Cut.Tool.Center?.U ?? 0, r.Cut.Tool.Center?.V ?? 0).Route!;
+ var route = FirmamentV2SideHoleRoutePolicy.Resolve(r.Attachment.Axis, r.Cut.Tool.Through.Axis, targetSolid.Box!.Size, r.Cut.Tool.Radius, r.Cut.Tool.Center?.U ?? 0, r.Cut.Tool.Center?.V ?? 0).Route!;
return new FirmamentV2SideHoleIntent(m.TargetSolid, r.Name, r.Attachment.Source, r.Attachment.Kind, r.Attachment.Axis, r.Cut.Tool.Through.Source, r.Cut.Tool.Through.Kind, r.Cut.Tool.Through.Axis, r.Cut.Tool.ToolType, r.Cut.Tool.Radius, r.Cut.Tool.Center?.U ?? 0, r.Cut.Tool.Center?.V ?? 0, r.Cut.Tool.Center is not null, route.CenterFrame, Units, route);
})).SingleOrDefault();
}
-public sealed record FirmamentV2SolidBinding(string Name, string RecordType, FirmamentV2BoxRecord Box, string? DerivedFrom = null, IReadOnlyDictionary<string, IReadOnlyList<double>>? Overrides = null)
+public sealed record FirmamentV2SolidBinding(string Name, string RecordType, FirmamentV2PrimitiveRecord Primitive, string? DerivedFrom = null, IReadOnlyDictionary<string, IReadOnlyList<double>>? Overrides = null)
{
public bool IsDerived => !string.IsNullOrWhiteSpace(DerivedFrom);
+ public FirmamentV2BoxRecord? Box => Primitive as FirmamentV2BoxRecord;
+ public FirmamentV2CylinderRecord? Cylinder => Primitive as FirmamentV2CylinderRecord;
+ public FirmamentV2ConeRecord? Cone => Primitive as FirmamentV2ConeRecord;
+ public FirmamentV2SphereRecord? Sphere => Primitive as FirmamentV2SphereRecord;
+ public FirmamentV2TorusRecord? Torus => Primitive as FirmamentV2TorusRecord;
}
-public sealed record FirmamentV2BoxRecord(IReadOnlyList<double> Size, IReadOnlyList<FirmamentV2Exposure> Exposures);
+public abstract record FirmamentV2PrimitiveRecord;
+public sealed record FirmamentV2BoxRecord(IReadOnlyList<double> Size, IReadOnlyList<FirmamentV2Exposure> Exposures) : FirmamentV2PrimitiveRecord;
+public sealed record FirmamentV2CylinderRecord(double Radius, double Height) : FirmamentV2PrimitiveRecord;
+public sealed record FirmamentV2ConeRecord(double BottomRadius, double TopRadius, double Height) : FirmamentV2PrimitiveRecord;
+public sealed record FirmamentV2SphereRecord(double Radius) : FirmamentV2PrimitiveRecord;
+public sealed record FirmamentV2TorusRecord(double MajorRadius, double MinorRadius) : FirmamentV2PrimitiveRecord;
public sealed record FirmamentV2Exposure(string Alias, string SelectorKind, string Selector, string RefType, string Axis, string? Subselector);
public sealed record FirmamentV2FaceTarget(string Source, string Kind, string Axis, string ResolvedSelector, string RefType)
{
diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2BuildLowering.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2BuildLowering.cs
index 75389989..50d09299 100644
--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2BuildLowering.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2BuildLowering.cs
@@ -5,38 +5,53 @@ using Aetheris.Kernel.Firmament.Lowering;
namespace Aetheris.Kernel.Firmament.FirmamentV2;
+/// <summary>
+/// Compatibility bridge from the parser-owned Firmament V2 primitive AST to the existing lowered primitive records.
+/// This intentionally reuses the production primitive executor and STEP back half without making V2 semantics owned by V1 lowering.
+/// </summary>
internal static class FirmamentV2BuildLowering
{
- public static KernelResult<FirmamentPrimitiveLoweringPlan> LowerBoxOnly(FirmamentV2Document document)
+ public static KernelResult<FirmamentPrimitiveLoweringPlan> LowerPrimitiveBridge(FirmamentV2Document document)
{
ArgumentNullException.ThrowIfNull(document);
if (document.ModifyBlocks is { Count: > 0 })
{
- return Failure("Firmament V2 build/export currently admits only a single Box solid with no modify blocks.");
+ return Failure("Firmament V2 build/export currently admits only a single primitive solid with no modify blocks.");
}
if (document.Solids.Count != 1)
{
- return Failure("Firmament V2 build/export currently admits exactly one Box solid.");
+ return Failure("Firmament V2 build/export currently admits exactly one primitive solid.");
}
var solid = document.Solid;
- if (!string.Equals(solid.RecordType, "Box", StringComparison.Ordinal) || solid.Box.Size.Count != 3)
+ var primitive = ToLoweredPrimitive(solid);
+ if (primitive is null)
{
- return Failure("Firmament V2 build/export currently admits only Box solids.");
+ return Failure($"Firmament V2 build/export does not admit primitive record '{solid.RecordType}'.");
}
- var primitive = new FirmamentLoweredPrimitive(
- OpIndex: 0,
- FeatureId: solid.Name,
- Kind: FirmamentLoweredPrimitiveKind.Box,
- Parameters: new FirmamentLoweredBoxParameters(solid.Box.Size[0], solid.Box.Size[1], solid.Box.Size[2]),
- Placement: null);
-
return KernelResult<FirmamentPrimitiveLoweringPlan>.Success(new FirmamentPrimitiveLoweringPlan([primitive], [], []));
}
+ private static FirmamentLoweredPrimitive? ToLoweredPrimitive(FirmamentV2SolidBinding solid)
+ {
+ var lowered = solid.Primitive switch
+ {
+ FirmamentV2BoxRecord box when box.Size.Count == 3 => (FirmamentLoweredPrimitiveKind.Box, (FirmamentLoweredPrimitiveParameters)new FirmamentLoweredBoxParameters(box.Size[0], box.Size[1], box.Size[2])),
+ FirmamentV2CylinderRecord cylinder => (FirmamentLoweredPrimitiveKind.Cylinder, new FirmamentLoweredCylinderParameters(cylinder.Radius, cylinder.Height)),
+ FirmamentV2ConeRecord cone => (FirmamentLoweredPrimitiveKind.Cone, new FirmamentLoweredConeParameters(cone.BottomRadius, cone.TopRadius, cone.Height)),
+ FirmamentV2SphereRecord sphere => (FirmamentLoweredPrimitiveKind.Sphere, new FirmamentLoweredSphereParameters(sphere.Radius)),
+ FirmamentV2TorusRecord torus => (FirmamentLoweredPrimitiveKind.Torus, new FirmamentLoweredTorusParameters(torus.MajorRadius, torus.MinorRadius)),
+ _ => default
+ };
+
+ return lowered == default
+ ? null
+ : new FirmamentLoweredPrimitive(0, solid.Name, lowered.Item1, lowered.Item2, null);
+ }
+
private static KernelResult<FirmamentPrimitiveLoweringPlan> Failure(string message) =>
KernelResult<FirmamentPrimitiveLoweringPlan>.Failure(
[
diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs
index e1bd2b2b..63a4fbb7 100644
--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs
@@ -13,6 +13,9 @@ public static class FirmamentV2Parser
public const string UnknownRecordType = "firmament-v2-unknown-record-type";
public const string BoxMissingSize = "firmament-v2-box-missing-size";
public const string BoxSizeArity = "firmament-v2-box-size-arity";
+ public const string PrimitiveFieldMissing = "firmament-v2-primitive-field-missing";
+ public const string PrimitiveFieldUnknown = "firmament-v2-primitive-field-unknown";
+ public const string PrimitiveFieldInvalid = "firmament-v2-primitive-field-invalid";
public const string DegenerateDimension = "firmament-degenerate-dimension";
public const string NameUnresolved = "firmament-v2-name-unresolved";
public const string DuplicateName = "firmament-v2-duplicate-name";
@@ -70,6 +73,7 @@ public static class FirmamentV2Parser
private static readonly Regex SolidHeaderRegex = new(@"\bsolid\s+(?<name>[A-Za-z_][A-Za-z0-9_]*)\s*:\s*(?<target>[A-Za-z_][A-Za-z0-9_]*)(?<with>\s+with)?\s*\{", RegexOptions.CultureInvariant);
private static readonly Regex LegacyEqualsSolidRegex = new(@"\bsolid\s+(?<name>[A-Za-z_][A-Za-z0-9_]*)\s*=\s*(?<target>[A-Za-z_][A-Za-z0-9_]*)(?<with>\s+with)?\s*\{(?<body>.*?)\}", RegexOptions.CultureInvariant | RegexOptions.Singleline);
private static readonly Regex SizeRegex = new(@"\bsize\s*:\s*\[(?<values>[^\]]*)\]", RegexOptions.CultureInvariant | RegexOptions.Singleline);
+ private static readonly Regex ScalarFieldRegex = new(@"\b(?<field>[A-Za-z_][A-Za-z0-9_]*)\s*:\s*(?<value>[-+0-9.eE]+(?:mm)?)", RegexOptions.CultureInvariant);
private static readonly Regex FieldRegex = new(@"(?<field>@[A-Za-z_][A-Za-z0-9_]*|[A-Za-z_][A-Za-z0-9_\.]*)\s*:", RegexOptions.CultureInvariant);
private static readonly Regex ExposeRegex = new(@"\bexpose\s*\{(?<body>.*?)\}", RegexOptions.CultureInvariant | RegexOptions.Singleline);
private static readonly Regex ExposureLineRegex = new(@"^\s*(?<selector>.+?)\s*=>\s*(?<alias>[A-Za-z_][A-Za-z0-9_]*)\s*$", RegexOptions.CultureInvariant);
@@ -138,10 +142,29 @@ public static class FirmamentV2Parser
private static FirmamentV2SolidBinding? ParseDirect(string name, string recordType, string body, List<string> diagnostics)
{
- if (!string.Equals(recordType, "Box", StringComparison.Ordinal)) { diagnostics.Add(UnknownRecordType); return null; }
- var values = ParseSizeField(body, diagnostics, BoxMissingSize);
- var exposures = ParseExposures(body, diagnostics);
- return values is null ? null : new(name, "Box", new(values, exposures));
+ if (string.Equals(recordType, "Box", StringComparison.Ordinal))
+ {
+ var values = ParseSizeField(body, diagnostics, BoxMissingSize);
+ var exposures = ParseExposures(body, diagnostics);
+ return values is null ? null : new(name, "Box", new FirmamentV2BoxRecord(values, exposures));
+ }
+
+ if (recordType is not ("Cylinder" or "Cone" or "Sphere" or "Torus")) { diagnostics.Add(UnknownRecordType); return null; }
+
+ var scalars = ParseScalarFields(body, diagnostics);
+ FirmamentV2PrimitiveRecord? primitive = recordType switch
+ {
+ "Cylinder" => RequireFields(scalars, diagnostics, "radius", "height") is null ? null : new FirmamentV2CylinderRecord(scalars["radius"], scalars["height"]),
+ "Cone" => RequireFields(scalars, diagnostics, "bottomRadius", "topRadius", "height") is null ? null : new FirmamentV2ConeRecord(scalars["bottomRadius"], scalars["topRadius"], scalars["height"]),
+ "Sphere" => RequireFields(scalars, diagnostics, "radius") is null ? null : new FirmamentV2SphereRecord(scalars["radius"]),
+ "Torus" => RequireFields(scalars, diagnostics, "majorRadius", "minorRadius") is null ? null : new FirmamentV2TorusRecord(scalars["majorRadius"], scalars["minorRadius"]),
+ _ => null
+ };
+ if (primitive is null) { return null; }
+ ValidatePrimitive(recordType, scalars, diagnostics);
+ return diagnostics.Contains(DegenerateDimension) || diagnostics.Contains(PrimitiveFieldInvalid) || diagnostics.Contains(PrimitiveFieldUnknown) || diagnostics.Contains(PrimitiveFieldMissing)
+ ? null
+ : new(name, recordType, primitive);
}
private static FirmamentV2SolidBinding? ParseDerived(string name, string baseName, string body, Dictionary<string, FirmamentV2SolidBinding> byName, List<string> diagnostics)
@@ -155,10 +178,10 @@ public static class FirmamentV2Parser
if (fields.Any(f => !string.Equals(f, "size", StringComparison.Ordinal))) { diagnostics.Add(WithFieldNotFound); return null; }
var values = ParseSizeField(body, diagnostics, WithFieldTypeMismatch);
if (values is null) { diagnostics.Add(WithDerivedRecordInvalid); return null; }
- return new(name, "Box", new(values, []), baseName, new Dictionary<string, IReadOnlyList<double>>(StringComparer.Ordinal) { ["size"] = values });
+ return new(name, "Box", new FirmamentV2BoxRecord(values, []), baseName, new Dictionary<string, IReadOnlyList<double>>(StringComparer.Ordinal) { ["size"] = values });
}
- private static bool IsFatalDiagnostic(string code) => code is MissingModel or MissingUnits or MissingSolid or UnsupportedConstruct or UnknownRecordType or BoxMissingSize or BoxSizeArity or DegenerateDimension or NameUnresolved or DuplicateName or WithRequiresRecord or WithRequiresBoxRecord or WithFieldNotFound or WithFieldTypeMismatch or WithForwardReference or WithDerivedRecordInvalid or ExposeBlockUnsupported or ExposeRequiresBoxRecord or ExposeAliasDuplicate or ExposeAliasInvalid or SelectorUnsupported or SelectorAxisInvalid or SelectorSubselectorUnsupported or FatArrowOutsideExpose or RawBackendIdReferenceForbidden or ModifyTargetUnresolved or ModifyTargetNotSolid or RegionUnsupported or RegionAttachmentSelectorUnsupported or CutUnsupported or CutToolUnsupported or CylinderRadiusMissing or CylinderRadiusInvalid or CylinderRadiusNotFinite or ThroughSelectorUnsupported or AliasUnresolved or AliasRefTypeUnsupported or SideHoleAliasMustResolveToFace or SideHoleAliasResolvesToUnsupportedFace or SideHoleOnlyPlusXMinusXSupported or SideHoleRouteUnsupported or SideHoleSameFaceUnsupported or SideHoleAxisNotYetSupported or SideHoleRadiusExceedsClearance or CylinderCenterInvalid or CylinderCenterArityInvalid or CylinderCenterNotFinite or SideHoleCenterExceedsClearance or HoleVariantUnknown or HoleEntryFaceMissing or HoleCenterMissing or HoleShaftMissing or HoleEndMissing or HoleDiameterInvalid or HoleDepthInvalid or HoleCounterboreInvalid or HoleCountersinkInvalid;
+ private static bool IsFatalDiagnostic(string code) => code is PrimitiveFieldMissing or PrimitiveFieldUnknown or PrimitiveFieldInvalid or MissingModel or MissingUnits or MissingSolid or UnsupportedConstruct or UnknownRecordType or BoxMissingSize or BoxSizeArity or DegenerateDimension or NameUnresolved or DuplicateName or WithRequiresRecord or WithRequiresBoxRecord or WithFieldNotFound or WithFieldTypeMismatch or WithForwardReference or WithDerivedRecordInvalid or ExposeBlockUnsupported or ExposeRequiresBoxRecord or ExposeAliasDuplicate or ExposeAliasInvalid or SelectorUnsupported or SelectorAxisInvalid or SelectorSubselectorUnsupported or FatArrowOutsideExpose or RawBackendIdReferenceForbidden or ModifyTargetUnresolved or ModifyTargetNotSolid or RegionUnsupported or RegionAttachmentSelectorUnsupported or CutUnsupported or CutToolUnsupported or CylinderRadiusMissing or CylinderRadiusInvalid or CylinderRadiusNotFinite or ThroughSelectorUnsupported or AliasUnresolved or AliasRefTypeUnsupported or SideHoleAliasMustResolveToFace or SideHoleAliasResolvesToUnsupportedFace or SideHoleOnlyPlusXMinusXSupported or SideHoleRouteUnsupported or SideHoleSameFaceUnsupported or SideHoleAxisNotYetSupported or SideHoleRadiusExceedsClearance or CylinderCenterInvalid or CylinderCenterArityInvalid or CylinderCenterNotFinite or SideHoleCenterExceedsClearance or HoleVariantUnknown or HoleEntryFaceMissing or HoleCenterMissing or HoleShaftMissing or HoleEndMissing or HoleDiameterInvalid or HoleDepthInvalid or HoleCounterboreInvalid or HoleCountersinkInvalid;
private static IReadOnlyList<FirmamentV2Exposure> ParseExposures(string body, List<string> diagnostics)
{
@@ -217,6 +240,44 @@ public static class FirmamentV2Parser
return diagnostics.Contains(DegenerateDimension) ? null : values;
}
+ private static Dictionary<string, double> ParseScalarFields(string body, List<string> diagnostics)
+ {
+ var fields = FieldRegex.Matches(body).Select(m => m.Groups["field"].Value).Where(f => !f.StartsWith('@')).ToHashSet(StringComparer.Ordinal);
+ var values = new Dictionary<string, double>(StringComparer.Ordinal);
+ foreach (Match match in ScalarFieldRegex.Matches(body))
+ {
+ var raw = match.Groups["value"].Value;
+ if (!double.TryParse(raw.EndsWith("mm", StringComparison.Ordinal) ? raw[..^2] : raw, NumberStyles.Float, CultureInfo.InvariantCulture, out var value) || !double.IsFinite(value))
+ {
+ diagnostics.Add(PrimitiveFieldInvalid);
+ continue;
+ }
+ values[match.Groups["field"].Value] = value;
+ }
+ foreach (var field in fields)
+ if (!values.ContainsKey(field)) diagnostics.Add(PrimitiveFieldInvalid);
+ return values;
+ }
+
+ private static object? RequireFields(Dictionary<string, double> values, List<string> diagnostics, params string[] required)
+ {
+ foreach (var requiredField in required)
+ if (!values.ContainsKey(requiredField)) diagnostics.Add(PrimitiveFieldMissing);
+ foreach (var field in values.Keys)
+ if (!required.Contains(field, StringComparer.Ordinal)) diagnostics.Add(PrimitiveFieldUnknown);
+ return diagnostics.Contains(PrimitiveFieldMissing) || diagnostics.Contains(PrimitiveFieldUnknown) ? null : new object();
+ }
+
+ private static void ValidatePrimitive(string recordType, Dictionary<string, double> values, List<string> diagnostics)
+ {
+ foreach (var (field, value) in values)
+ {
+ if (recordType == "Cone" && field == "topRadius" && value == 0d) continue;
+ if (value <= 0d) diagnostics.Add(DegenerateDimension);
+ }
+ if (recordType == "Cone" && values.TryGetValue("bottomRadius", out var bottom) && bottom <= 0d) diagnostics.Add(DegenerateDimension);
+ if (recordType == "Torus" && values.TryGetValue("majorRadius", out var major) && values.TryGetValue("minorRadius", out var minor) && major <= minor) diagnostics.Add(PrimitiveFieldInvalid);
+ }
private static IReadOnlyList<FirmamentV2ModifyBlock> ParseModifyBlocks(string source, Dictionary<string, FirmamentV2SolidBinding> byName, List<string> diagnostics)
{
diff --git a/docs/implementation/step-v2-a1-box-ap242-pipeline.md b/docs/implementation/step-v2-a1-box-ap242-pipeline.md
index de4a62b6..1a78b75f 100644
--- a/docs/implementation/step-v2-a1-box-ap242-pipeline.md
+++ b/docs/implementation/step-v2-a1-box-ap242-pipeline.md
@@ -68,3 +68,7 @@ STEP-V2-A1 intentionally does **not** wire Cylinder, Cone, Sphere, Torus, prism
## MVP contract relationship
This milestone is the first implementation slice for `docs/mvp/firmament-v2-ap242-mvp-readiness-contract.md`: a Firmament V2 fixture is considered ready only when real AP242 is emitted from a real `BrepBody` by `Step242Exporter` and independently verified by reimport, topology checks, and volume checks.
+
+## Forward link
+
+STEP-V2-X1 extends this Box-only bridge to Cylinder, Cone/frustum, Sphere, and Torus while preserving the V2-to-lowered compatibility seam; see `docs/implementation/step-v2-x1-analytic-primitives-ap242.md`.
diff --git a/docs/implementation/step-v2-x1-analytic-primitives-ap242.md b/docs/implementation/step-v2-x1-analytic-primitives-ap242.md
new file mode 100644
index 00000000..e6da1a71
--- /dev/null
+++ b/docs/implementation/step-v2-x1-analytic-primitives-ap242.md
@@ -0,0 +1,47 @@
+# STEP-V2-X1 Analytic Primitives AP242 Wiring
+
+STEP-V2-X1 extends the Firmament V2 real build/export path from the STEP-V2-A1 Box fixture to Cylinder, Cone/frustum, Sphere, and Torus fixtures. The syntax remains the V2 typed record-literal style:
+
+```firmament
+solid cyl: Cylinder { radius: 2mm height: 10mm }
+solid cone: Cone { bottomRadius: 3mm topRadius: 1mm height: 10mm }
+solid sphere: Sphere { radius: 5mm }
+solid torus: Torus { majorRadius: 8mm minorRadius: 2mm }
+```
+
+## Bridge organization
+
+The V2 parser and AST own only V2 syntax and parsed primitive records. `FirmamentV2BuildLowering.LowerPrimitiveBridge` is the isolated compatibility bridge from V2 records to existing `FirmamentLowered*Parameters` records. The bridge deliberately reuses `FirmamentPrimitiveExecutor`, `BrepBody`, and `Step242Exporter`; it is not a V2 exporter and does not route through trace-only artifacts.
+
+This keeps the current seam clear:
+
+- V2 parser / AST: `Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs`, `FirmamentV2Ast.cs`
+- V2-to-lowered compatibility bridge: `Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2BuildLowering.cs`
+- legacy/current lowered records: `Aetheris.Kernel.Firmament/Lowering/FirmamentPrimitiveLoweringPlan.cs`
+- production executor: `Aetheris.Kernel.Firmament/Execution/FirmamentPrimitiveExecutor.cs`
+- BRep/STEP back half: `Aetheris.Kernel.Core/Step242/Step242Exporter.cs`
+
+## Fixtures and formulas
+
+- `fixtures/FirmamentV2/Primitive/valid/primitive-v2-cylinder-step-verified.valid.firmfixture`: volume `πr²h`, with `r=2`, `h=10`.
+- `fixtures/FirmamentV2/Primitive/valid/primitive-v2-cone-step-verified.valid.firmfixture`: frustum volume `(πh/3)(r1² + r1r2 + r2²)`, with `r1=3`, `r2=1`, `h=10`.
+- `fixtures/FirmamentV2/Primitive/valid/primitive-v2-sphere-step-verified.valid.firmfixture`: volume `(4/3)πr³`, with `r=5`.
+- `fixtures/FirmamentV2/Primitive/valid/primitive-v2-torus-step-verified.valid.firmfixture`: volume `2π²Rr²`, with `R=8`, `r=2`.
+
+Canonical topology follows the current Aetheris exporter/importer representation: cylinder and frustum use three faces; sphere and torus use one analytic face. Vertex markers are emitted by the exporter for vertexless whole analytic bodies so STEP smoke checks can consistently prove topology marker presence without using hardcoded STEP templates.
+
+## Deferred
+
+This milestone does not add modify, Boolean, hole, side-hole, pattern, PMI, DFM, chamfer, fillet, or V2-only exporter/executor support. Apex cone syntax is deferred; STEP-V2-X1 verifies a frustum.
+
+## Validation commands
+
+```bash
+dotnet restore Aetheris.slnx
+dotnet build Aetheris.slnx -f net10.0 --no-restore /m:1
+dotnet test Aetheris.slnx -f net10.0 --no-build --filter "STEP-V2|primitive-v2|FirmamentV2|AP242|Build"
+dotnet run --project Aetheris.CLI -- --help
+git diff --check
+```
+
+Direct fixture build/analyze commands were run for Cylinder, Cone, Sphere, and Torus through `dotnet run --project Aetheris.CLI -- build ... --json` and `dotnet run --project Aetheris.CLI -- analyze volume ... --json`.
diff --git a/fixtures/FirmamentV2/Primitive/invalid/box-v2-unknown-record.invalid.firmfixture b/fixtures/FirmamentV2/Primitive/invalid/box-v2-unknown-record.invalid.firmfixture
index 0f80370b..e3c60d6a 100644
--- a/fixtures/FirmamentV2/Primitive/invalid/box-v2-unknown-record.invalid.firmfixture
+++ b/fixtures/FirmamentV2/Primitive/invalid/box-v2-unknown-record.invalid.firmfixture
@@ -12,7 +12,7 @@
model BoxExample {
units mm
- solid base: Cylinder {
+ solid base: Pyramid {
size: [10, 8, 6]
}
}
diff --git a/fixtures/FirmamentV2/Primitive/valid/primitive-v2-cone-step-verified.valid.firmfixture b/fixtures/FirmamentV2/Primitive/valid/primitive-v2-cone-step-verified.valid.firmfixture
new file mode 100644
index 00000000..f2e8fb63
--- /dev/null
+++ b/fixtures/FirmamentV2/Primitive/valid/primitive-v2-cone-step-verified.valid.firmfixture
@@ -0,0 +1,30 @@
+// fixture-id: primitive-v2-cone-step-verified
+// case: primitive-v2-cone-step-verified
+// category: Primitive
+// syntax-version: FirmamentV2
+// validity: valid
+// implementation: parser-backed
+// expected: valid
+// expected-stage: step-verified
+// expected-feature-air: CreateCone
+// dimensions: bottomRadius=3, topRadius=1, height=10
+// units: mm
+// tier: 1
+// mvp-required: true
+// feature-area: pipeline/analytic-primitives
+// build-command: aetheris build
+// expected-topology: faces=3
+// expected-volume: 136.1356816555577
+// roundtrip-required: true
+// parser-backed: true
+// notes: STEP-V2-X1 V2 Cone frustum fixture verified through real BrepBody and Step242Exporter; apex cone syntax deferred.
+
+model ConeStepVerified {
+ units mm
+
+ solid cone: Cone {
+ bottomRadius: 3mm
+ topRadius: 1mm
+ height: 10mm
+ }
+}
diff --git a/fixtures/FirmamentV2/Primitive/valid/primitive-v2-cylinder-step-verified.valid.firmfixture b/fixtures/FirmamentV2/Primitive/valid/primitive-v2-cylinder-step-verified.valid.firmfixture
new file mode 100644
index 00000000..63b87b2e
--- /dev/null
+++ b/fixtures/FirmamentV2/Primitive/valid/primitive-v2-cylinder-step-verified.valid.firmfixture
@@ -0,0 +1,29 @@
+// fixture-id: primitive-v2-cylinder-step-verified
+// case: primitive-v2-cylinder-step-verified
+// category: Primitive
+// syntax-version: FirmamentV2
+// validity: valid
+// implementation: parser-backed
+// expected: valid
+// expected-stage: step-verified
+// expected-feature-air: CreateCylinder
+// dimensions: radius=2, height=10
+// units: mm
+// tier: 1
+// mvp-required: true
+// feature-area: pipeline/analytic-primitives
+// build-command: aetheris build
+// expected-topology: faces=3
+// expected-volume: 125.66370614359172
+// roundtrip-required: true
+// parser-backed: true
+// notes: STEP-V2-X1 V2 Cylinder fixture verified through real BrepBody and Step242Exporter.
+
+model CylinderStepVerified {
+ units mm
+
+ solid cyl: Cylinder {
+ radius: 2mm
+ height: 10mm
+ }
+}
diff --git a/fixtures/FirmamentV2/Primitive/valid/primitive-v2-sphere-step-verified.valid.firmfixture b/fixtures/FirmamentV2/Primitive/valid/primitive-v2-sphere-step-verified.valid.firmfixture
new file mode 100644
index 00000000..78bb8617
--- /dev/null
+++ b/fixtures/FirmamentV2/Primitive/valid/primitive-v2-sphere-step-verified.valid.firmfixture
@@ -0,0 +1,28 @@
+// fixture-id: primitive-v2-sphere-step-verified
+// case: primitive-v2-sphere-step-verified
+// category: Primitive
+// syntax-version: FirmamentV2
+// validity: valid
+// implementation: parser-backed
+// expected: valid
+// expected-stage: step-verified
+// expected-feature-air: CreateSphere
+// dimensions: radius=5
+// units: mm
+// tier: 1
+// mvp-required: true
+// feature-area: pipeline/analytic-primitives
+// build-command: aetheris build
+// expected-topology: faces=1
+// expected-volume: 523.5987755982989
+// roundtrip-required: true
+// parser-backed: true
+// notes: STEP-V2-X1 V2 Sphere fixture verified through real BrepBody and Step242Exporter.
+
+model SphereStepVerified {
+ units mm
+
+ solid sphere: Sphere {
+ radius: 5mm
+ }
+}
diff --git a/fixtures/FirmamentV2/Primitive/valid/primitive-v2-torus-step-verified.valid.firmfixture b/fixtures/FirmamentV2/Primitive/valid/primitive-v2-torus-step-verified.valid.firmfixture
new file mode 100644
index 00000000..8f3e36ff
--- /dev/null
+++ b/fixtures/FirmamentV2/Primitive/valid/primitive-v2-torus-step-verified.valid.firmfixture
@@ -0,0 +1,29 @@
+// fixture-id: primitive-v2-torus-step-verified
+// case: primitive-v2-torus-step-verified
+// category: Primitive
+// syntax-version: FirmamentV2
+// validity: valid
+// implementation: parser-backed
+// expected: valid
+// expected-stage: step-verified
+// expected-feature-air: CreateTorus
+// dimensions: majorRadius=8, minorRadius=2
+// units: mm
+// tier: 1
+// mvp-required: true
+// feature-area: pipeline/analytic-primitives
+// build-command: aetheris build
+// expected-topology: faces=1
+// expected-volume: 631.6546816697189
+// roundtrip-required: true
+// parser-backed: true
+// notes: STEP-V2-X1 V2 Torus fixture verified through real BrepBody and Step242Exporter.
+
+model TorusStepVerified {
+ units mm
+
+ solid torus: Torus {
+ majorRadius: 8mm
+ minorRadius: 2mm
+ }
+}