Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Add Revolve inspection, validation, and STEP export support

Yuechen Lifab18ee60b36
diff --git a/Aetheris.CLI.Tests/RevolveCliTests.cs b/Aetheris.CLI.Tests/RevolveCliTests.cs
new file mode 100644
index 00000000..ea282d9b
--- /dev/null
+++ b/Aetheris.CLI.Tests/RevolveCliTests.cs
@@ -0,0 +1,44 @@
+using System.Text.Json;
+
+namespace Aetheris.CLI.Tests;
+
+public sealed class RevolveCliTests
+{
+ private static readonly string Repo = FindRepo();
+
+ [Fact]
+ public void InspectReportsBoundedAngleAxisAndFrame()
+ {
+ var output = new StringWriter(); var error = new StringWriter();
+ var exit = CliRunner.Run(["inspect", Fixture("Canonical/Revolve/partial-quarter.firmament"), "--json"], output, error);
+ Assert.Equal(0, exit); Assert.Empty(error.ToString());
+ using var json = JsonDocument.Parse(output.ToString()); var root = json.RootElement;
+ Assert.Equal("Revolve", root.GetProperty("domain").GetString());
+ var revolve = root.GetProperty("revolve");
+ Assert.Equal(90d, revolve.GetProperty("sweepDegrees").GetDouble());
+ Assert.Equal("quarter", revolve.GetProperty("alias").GetString());
+ Assert.Equal("Partial", revolve.GetProperty("classification").GetString());
+ Assert.Equal("MainAxis", revolve.GetProperty("axis").GetString());
+ Assert.Equal("XY", revolve.GetProperty("profileFrame").GetString());
+ }
+
+ [Fact]
+ public void ValidateRejectsZeroAngleAsFatalSemanticDiagnostic()
+ {
+ var output = new StringWriter(); var error = new StringWriter();
+ var exit = CliRunner.Run(["validate", Fixture("Invalid/Revolve/zero-angle.firmament"), "--json"], output, error);
+ Assert.Equal(1, exit); Assert.Empty(error.ToString());
+ using var json = JsonDocument.Parse(output.ToString());
+ var validation = json.RootElement.GetProperty("firmamentV2Validation");
+ Assert.Equal("invalid", validation.GetProperty("status").GetString());
+ Assert.Contains(validation.GetProperty("diagnostics").EnumerateArray(), item => item.GetString() == "firmament-revolve-zero-angle:Bad");
+ }
+
+ private static string Fixture(string relative) => Path.Combine(Repo, "fixtures", relative.Replace('/', Path.DirectorySeparatorChar));
+ private static string FindRepo()
+ {
+ var directory = new DirectoryInfo(AppContext.BaseDirectory);
+ while (directory is not null && !File.Exists(Path.Combine(directory.FullName, "Aetheris.slnx"))) directory = directory.Parent;
+ return directory?.FullName ?? throw new DirectoryNotFoundException();
+ }
+}
diff --git a/Aetheris.CLI/CliRunner.cs b/Aetheris.CLI/CliRunner.cs
index 050b455a..95f4d741 100644
--- a/Aetheris.CLI/CliRunner.cs
+++ b/Aetheris.CLI/CliRunner.cs
@@ -1414,6 +1414,29 @@ Model CanonicalPanel {
var library = FirmamentStandardLibraryResolver.Resolve(source, out var libraryDiagnostics);
var inspectionSource = library?.Source ?? source;
var sweepSource = ExpandSweepInspectionSource(source, out var sweepExpansionDiagnostics);
+ if (RevolveAuthoringParser.IsRevolveSource(inspectionSource))
+ {
+ var revolve = RevolveAuthoringParser.Parse(inspectionSource, out var revolveDiagnostics);
+ var revolveSuccess = revolve is not null && revolveDiagnostics.Count == 0;
+ if (json) stdout.WriteLine(JsonSerializer.Serialize(new
+ {
+ command = "inspect", success = revolveSuccess, input = fullPath, domain = "Revolve",
+ revolve = revolve is null ? null : new
+ {
+ revolve.Name, profile = revolve.Profile.Name, axis = revolve.AxisName,
+ axisOrigin = new[] { revolve.Axis.Origin.X, revolve.Axis.Origin.Y, revolve.Axis.Origin.Z },
+ axisDirection = new[] { revolve.Axis.Direction.X, revolve.Axis.Direction.Y, revolve.Axis.Direction.Z },
+ sweepRadians = revolve.SweepRadians, sweepDegrees = revolve.SweepRadians * 180d / Math.PI,
+ alias = revolve.AuthoredAlias, direction = revolve.SweepRadians < 0d ? "Negative" : "Positive",
+ classification = Math.Abs(Math.Abs(revolve.SweepRadians) - 2d * Math.PI) <= 1e-9 ? "Full" : "Partial",
+ profileFrame = revolve.Profile.PlaneFrame
+ },
+ diagnostics = revolveDiagnostics
+ }, JsonOptions));
+ else if (revolveSuccess) stdout.WriteLine($"Revolve {revolve!.Name}: {revolve.Profile.Name} about {revolve.AxisName}, {revolve.SweepRadians * 180d / Math.PI:R}deg ({(Math.Abs(Math.Abs(revolve.SweepRadians) - 2d * Math.PI) <= 1e-9 ? "Full" : "Partial")})");
+ else foreach (var diagnostic in revolveDiagnostics) stderr.WriteLine("error: " + diagnostic);
+ return revolveSuccess ? 0 : 1;
+ }
if (WireFormAuthoring.IsWireFormSource(source))
{
var authored = sweepSource is null ? null : WireFormAuthoring.Parse(sweepSource);
@@ -2218,6 +2241,18 @@ Model CanonicalPanel {
else stdout.WriteLine($"Firmament V2 SectionChain validation: {payload.status} ({payload.summary.fatalDiagnosticCount} fatal, 0 warning)");
return section.IsSuccess ? 0 : 1;
}
+ if (RevolveAuthoringParser.IsRevolveSource(validationSource))
+ {
+ var revolve = RevolveAuthoringParser.Parse(validationSource, out var bindDiagnostics);
+ var materializationDiagnostics = revolve is null ? [] : ResolvedProfileRevolveEmitter.TryEmit(revolve).Diagnostics;
+ var diagnostics = bindDiagnostics.Concat(materializationDiagnostics.Where(message => message.StartsWith(RevolveAuthoringParser.Prefix, StringComparison.Ordinal))).Distinct(StringComparer.Ordinal).ToArray();
+ var valid = revolve is not null && diagnostics.Length == 0;
+ var payload = new { source = sourcePath, status = valid ? "valid" : "invalid", domain = "Revolve",
+ summary = new { fatalDiagnosticCount = diagnostics.Length, warningDiagnosticCount = 0 }, diagnostics };
+ if (json) stdout.WriteLine(JsonSerializer.Serialize(new { firmamentV2Validation = payload }, JsonOptions));
+ else stdout.WriteLine($"Firmament V2 Revolve validation: {payload.status} ({payload.summary.fatalDiagnosticCount} fatal, 0 warning)");
+ return valid ? 0 : 1;
+ }
if (WireFormAuthoring.IsWireFormSource(validationSource))
{
var wireSource = ExpandSweepInspectionSource(validationSource, out var expansionDiagnostics);
diff --git a/Aetheris.Kernel.Firmament.Tests/GeomRevolveX1Tests.cs b/Aetheris.Kernel.Firmament.Tests/GeomRevolveX1Tests.cs
new file mode 100644
index 00000000..a96079e7
--- /dev/null
+++ b/Aetheris.Kernel.Firmament.Tests/GeomRevolveX1Tests.cs
@@ -0,0 +1,136 @@
+using Aetheris.Kernel.Core.Geometry;
+using Aetheris.Kernel.Core.Brep;
+using Aetheris.Kernel.Core.Step242;
+using Aetheris.Kernel.Firmament.FirmamentV2;
+using Aetheris.Kernel.Firmament.Materializer;
+
+namespace Aetheris.Kernel.Firmament.Tests;
+
+public sealed class GeomRevolveX1Tests
+{
+ [Theory]
+ [InlineData("quarter", 90d)]
+ [InlineData("90deg", 90d)]
+ [InlineData("1.5707963267948966", 90d)]
+ [InlineData("half", 180d)]
+ [InlineData("full", 360d)]
+ [InlineData("-90deg", -90d)]
+ public void AngleFormsBindAndMaterializeThroughOneBoundedPlan(string angle, double expectedDegrees)
+ {
+ var result = FirmamentBuildAndExport.CompileSource(Rectangle(angle));
+ Assert.True(result.IsSuccess, string.Join(Environment.NewLine, result.Diagnostics.Select(d => d.Message)));
+ Assert.Equal(expectedDegrees, result.Value.Revolve!.SweepDegrees, 9);
+ Assert.Equal(Math.Abs(expectedDegrees) == 360d ? "Full" : "Partial", result.Value.Revolve.Classification);
+ Assert.True(result.Value.Revolve.StepReimportedManifold);
+ Assert.Equal(result.Value.Revolve.Classification == "Full" ? 2 : 4, result.Value.Revolve.Planes);
+ }
+
+ [Fact]
+ public void FullRectanglePreservesAnalyticCylinderAndPlaneCarriersDeterministically()
+ {
+ var first = FirmamentBuildAndExport.CompileSource(Rectangle("full"));
+ var second = FirmamentBuildAndExport.CompileSource(Rectangle("360deg"));
+ Assert.True(first.IsSuccess, string.Join(Environment.NewLine, first.Diagnostics.Select(d => d.Message)));
+ Assert.True(second.IsSuccess, string.Join(Environment.NewLine, second.Diagnostics.Select(d => d.Message)));
+ Assert.Equal(first.Value.StepText, second.Value.StepText);
+ Assert.Equal(2, first.Value.Revolve!.Cylinders);
+ Assert.Equal(2, first.Value.Revolve.Planes);
+ Assert.DoesNotContain("B_SPLINE_SURFACE", first.Value.StepText, StringComparison.Ordinal);
+ }
+
+ [Fact]
+ public void SemicircleAboutDiameterProducesExactSphereCarrierAndReimports()
+ {
+ var result = FirmamentBuildAndExport.CompileSource(Sphere);
+ Assert.True(result.IsSuccess, string.Join(Environment.NewLine, result.Diagnostics.Select(d => d.Message)));
+ Assert.Equal(1, result.Value.Revolve!.Spheres);
+ Assert.Contains("SPHERICAL_SURFACE", result.Value.StepText, StringComparison.Ordinal);
+ var imported = Step242Importer.ImportBody(result.Value.StepText);
+ Assert.True(imported.IsSuccess, string.Join(Environment.NewLine, imported.Diagnostics.Select(d => d.Message)));
+ Assert.Contains(imported.Value.Topology.Faces, face => imported.Value.GetFaceSurface(face.Id).Kind == SurfaceGeometryKind.Sphere);
+ }
+
+ [Fact]
+ public void ConceptCircle2IsAReusableCurveWithoutClosedBoundaryBoilerplate()
+ {
+ var diagnostics = new List<string>();
+ var expanded = ClosedBoundary2Authoring.Expand(Sphere, diagnostics);
+ Assert.NotNull(expanded);
+ Assert.Empty(diagnostics);
+ Assert.DoesNotContain(expanded.Boundaries, boundary => boundary.Name == "Meridian");
+
+ var profile = ProfileAuthoringParser.ResolveNamedProfile(expanded.Source, "SphereSection", out var profileDiagnostics);
+ Assert.NotNull(profile);
+ Assert.Empty(profileDiagnostics);
+ Assert.IsType<LineArcCircularArc2D>(profile.Loops[0].Segments[0].Geometry);
+ }
+
+ [Fact]
+ public void NonPrincipalCoplanarAxisIsAdmitted()
+ {
+ var result = FirmamentBuildAndExport.CompileSource(ArbitraryAxis);
+ Assert.True(result.IsSuccess, string.Join(Environment.NewLine, result.Diagnostics.Select(d => d.Message)));
+ Assert.True(result.Value.Revolve!.StepReimportedManifold);
+ }
+
+ [Theory]
+ [InlineData("0deg", "firmament-revolve-zero-angle:Ring")]
+ [InlineData("361deg", "firmament-revolve-angle-out-of-range:Ring")]
+ public void InvalidAnglesAreRejectedBeforeMaterialization(string angle, string diagnostic)
+ {
+ var result = FirmamentBuildAndExport.CompileSource(Rectangle(angle));
+ Assert.False(result.IsSuccess); Assert.Contains(result.Diagnostics, d => d.Message == diagnostic);
+ }
+
+ [Fact]
+ public void ZeroSkewAndCrossingAxisCasesHaveTypedDiagnostics()
+ {
+ var zero = FirmamentBuildAndExport.CompileSource(Rectangle("full").Replace("Direction: [0, 1, 0]", "Direction: [0, 0, 0]", StringComparison.Ordinal));
+ var skew = FirmamentBuildAndExport.CompileSource(Rectangle("full").Replace("Direction: [0, 1, 0]", "Direction: [0, 1, 1]", StringComparison.Ordinal));
+ var crossing = FirmamentBuildAndExport.CompileSource(Rectangle("full").Replace("Center: [15mm, 0mm]", "Center: [0mm, 0mm]", StringComparison.Ordinal));
+ Assert.Contains(zero.Diagnostics, d => d.Message == "firmament-revolve-axis-zero-direction:Ring");
+ Assert.Contains(skew.Diagnostics, d => d.Message == "firmament-revolve-axis-not-in-profile-plane:Ring");
+ Assert.Contains(crossing.Diagnostics, d => d.Message == "firmament-revolve-profile-crosses-axis:Ring");
+ }
+
+ private static string Rectangle(string angle) => $$"""
+ Model TurnedRing {
+ Units: mm
+ Axis MainAxis { Origin: [0mm, 0mm, 0mm]; Direction: [0, 1, 0] }
+ Concept Struct Layout On XY { Rect2 Section { Center: [15mm, 0mm]; Size: [10mm, 20mm] } }
+ Profile RingSection Using Layout { Loop Outer { Section.Bottom |> Section.Right |> Section.Top |> Section.Left |> Close } }
+ Revolve Ring { Profile: RingSection; About: MainAxis; Angle: {{angle}} }
+ }
+ """;
+
+ private const string Sphere = """
+ Model RevolvedSphere {
+ Units: mm
+ Axis MainAxis { Origin: [0mm, 0mm, 0mm]; Direction: [0, 1, 0] }
+ Concept Struct Layout On XY {
+ Point2 South { Position: [0mm, -20mm] }
+ Point2 North { Position: [0mm, 20mm] }
+ Point2 Center { Position: [0mm, 0mm] }
+ Concept Circle2 Meridian { Center: Center; Radius: 20mm }
+ Line2 Diameter { From: North; To: South }
+ }
+ Profile SphereSection Using Layout { Loop Outer {
+ Segment Arc { Trace: Meridian; From: South; To: North; Sweep: CounterClockwise }
+ Segment AxisClosure { Trace: Diameter; From: North; To: South }
+ } }
+ Revolve Ball { Profile: SphereSection; About: MainAxis; Angle: full }
+ }
+ """;
+
+ private const string ArbitraryAxis = """
+ Model ArbitraryAxisTurn {
+ Units: mm
+ Axis Tilted { Origin: [3mm, 4mm, 5mm]; Direction: [1, 1, 0] }
+ Concept Struct Supports { Datum: Plane { Origin: [3mm,4mm,5mm]; Normal: [1,-1,0]; Up: [0,0,1] } }
+ Construction Plane SectionFrame { Trace: Supports.Datum }
+ Concept Struct Layout On SectionFrame { Rect2 Section { Center: [0mm, 15mm]; Size: [20mm, 10mm] } }
+ Profile SectionProfile Using SectionFrame { Loop Outer { Section.Bottom |> Section.Right |> Section.Top |> Section.Left |> Close } }
+ Revolve TiltedRing { Profile: SectionProfile; About: Tilted; Angle: quarter }
+ }
+ """;
+}
diff --git a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs
index 5142823b..bf8e849c 100644
--- a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs
@@ -326,6 +326,39 @@ public static class FirmamentBuildAndExport
canonicalParseWatch.Stop();
var canonicalAdvanced = FirmamentV2Parser.TryGetCanonicalAdvancedBody(materializerInput, out var canonicalBody);
var materializerSource = canonicalAdvanced ? canonicalBody : materializerInput;
+ if (RevolveAuthoringParser.IsRevolveSource(materializerSource))
+ {
+ var authored = RevolveAuthoringParser.Parse(materializerSource, out var revolveDiagnostics);
+ if (authored is null)
+ return KernelResult<FirmamentStepExportResult>.Failure(revolveDiagnostics.Select(message => new Kernel.Core.Diagnostics.KernelDiagnostic(
+ Kernel.Core.Diagnostics.KernelDiagnosticCode.ValidationFailed, Kernel.Core.Diagnostics.KernelDiagnosticSeverity.Error, message, "FirmamentV2.Revolve")).ToArray());
+ var built = ResolvedProfileRevolveEmitter.TryEmit(authored);
+ if (!built.Succeeded || built.Body is null || built.Plan is null)
+ return KernelResult<FirmamentStepExportResult>.Failure(built.Diagnostics.Select(message => new Kernel.Core.Diagnostics.KernelDiagnostic(
+ Kernel.Core.Diagnostics.KernelDiagnosticCode.ValidationFailed, Kernel.Core.Diagnostics.KernelDiagnosticSeverity.Error, message, "FirmamentV2.Revolve")).ToArray());
+ var step = Step242Exporter.ExportBody(built.Body, new Step242ExportOptions { ProductName = authored.Name });
+ if (!step.IsSuccess) return KernelResult<FirmamentStepExportResult>.Failure(step.Diagnostics);
+ var reimport = Step242Importer.ImportBody(step.Value);
+ if (!reimport.IsSuccess || reimport.Value is null) return KernelResult<FirmamentStepExportResult>.Failure(reimport.Diagnostics);
+ var reimportedManifold = reimport.Value.Topology.Edges.All(edge => reimport.Value.Topology.Coedges.Count(use => use.EdgeId == edge.Id) == 2);
+ if (!reimportedManifold)
+ return KernelResult<FirmamentStepExportResult>.Failure([new Kernel.Core.Diagnostics.KernelDiagnostic(
+ Kernel.Core.Diagnostics.KernelDiagnosticCode.ValidationFailed, Kernel.Core.Diagnostics.KernelDiagnosticSeverity.Error,
+ $"firmament-revolve-step-reimport-not-manifold:{authored.Name}", "FirmamentV2.Revolve")]);
+ var surfaces = built.Body.Topology.Faces.Select(face => built.Body.GetFaceSurface(face.Id).Kind).ToArray();
+ var hash = Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(step.Value))).ToLowerInvariant();
+ var report = new FirmamentRevolveReport(authored.Profile.Name, authored.AxisName, authored.SweepRadians,
+ authored.SweepRadians * 180d / Math.PI, authored.AuthoredAlias, authored.SweepRadians < 0d ? "Negative" : "Positive",
+ built.Plan.IsFull ? "Full" : "Partial", built.Plan.DeterministicSignature, built.Plan.SurfaceRoles,
+ built.Body.Topology.Vertices.Count(), built.Body.Topology.Edges.Count(), built.Body.Topology.Faces.Count(),
+ surfaces.Count(kind => kind == SurfaceGeometryKind.Plane), surfaces.Count(kind => kind == SurfaceGeometryKind.Cylinder),
+ surfaces.Count(kind => kind == SurfaceGeometryKind.Cone), surfaces.Count(kind => kind == SurfaceGeometryKind.Sphere),
+ surfaces.Count(kind => kind == SurfaceGeometryKind.Torus), surfaces.Count(kind => kind == SurfaceGeometryKind.SurfaceOfRevolution),
+ reimportedManifold, hash);
+ return KernelResult<FirmamentStepExportResult>.Success(new(step.Value, authored.Name, 0, "bounded-revolve", "revolve", Revolve: report,
+ EngineeringFeatures: [new(authored.Name, "Revolve", authored.StableId, authored.Name, authored.Axis.StableId, authored.Profile.Name,
+ authored.SweepRadians, "SweepRadians", "Base", PolicySource: "ResolvedProfileRevolveEmitter", MaterializationRoute: "RevolveBRepPlan")]));
+ }
if (explicitSchema == FirmamentFrontendSchema.WireForm || WireFormAuthoring.IsWireFormSource(materializerSource))
{
var authored = WireFormAuthoring.Parse(materializerSource);
diff --git a/Aetheris.Kernel.Firmament/FirmamentStepExportResult.cs b/Aetheris.Kernel.Firmament/FirmamentStepExportResult.cs
index bbd502da..2a637807 100644
--- a/Aetheris.Kernel.Firmament/FirmamentStepExportResult.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentStepExportResult.cs
@@ -26,7 +26,14 @@ public sealed record FirmamentStepExportResult(
FirmamentSweepReport? Sweep = null,
IReadOnlyList<FirmamentSemanticPatternReport>? Patterns = null,
Aetheris.Kernel.Firmament.Structural.StructuralReport? Structural = null,
- Aetheris.Kernel.Firmament.Piping.PipingReport? Piping = null);
+ Aetheris.Kernel.Firmament.Piping.PipingReport? Piping = null,
+ FirmamentRevolveReport? Revolve = null);
+
+public sealed record FirmamentRevolveReport(
+ string Profile, string Axis, double SweepRadians, double SweepDegrees, string? Alias,
+ string Direction, string Classification, string DeterministicSignature, IReadOnlyList<string> SurfaceRoles,
+ int Vertices, int Edges, int Faces, int Planes, int Cylinders, int Cones, int Spheres, int Tori,
+ int SurfacesOfRevolution, bool StepReimportedManifold, string StepSha256);
public sealed record FirmamentWireStateReport(
IReadOnlyList<double> Position, IReadOnlyList<double> Tangent, IReadOnlyList<double> Up,
diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/ClosedBoundary2Authoring.cs b/Aetheris.Kernel.Firmament/FirmamentV2/ClosedBoundary2Authoring.cs
index 110cebd4..6c92ee83 100644
--- a/Aetheris.Kernel.Firmament/FirmamentV2/ClosedBoundary2Authoring.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentV2/ClosedBoundary2Authoring.cs
@@ -36,6 +36,11 @@ internal static class ClosedBoundary2Authoring
var shapes = new List<Shape>(); var names = new HashSet<string>(StringComparer.Ordinal);
foreach (Match header in Header.Matches(source))
{
+ // `Concept Circle2 Name { ... }` is a concise reusable curve concept, not a
+ // closed material boundary declaration. Its Circle2 payload is consumed by
+ // the ordinary profile-guide binder and must not be rewritten here.
+ var prefix = source[..header.Index].TrimEnd();
+ if (prefix.EndsWith("Concept", StringComparison.Ordinal) && (prefix.Length == 7 || !char.IsLetterOrDigit(prefix[^8]) && prefix[^8] != '_')) continue;
if (InTemplate(header.Index)) continue;
var open = source.IndexOf('{', header.Index); var close = Matching(source, open); var name = header.Groups["name"].Value;
if (close < 0) { diagnostics.Add(Prefix + "malformed:" + name); continue; }
@@ -126,7 +131,7 @@ internal static class ClosedBoundary2Authoring
if (!inline && (centerRef is null || !ResolvePoint(source, centerRef, out c))) return null; // legacy/template Circle2 remains on its existing binder path
var hasRadius = Length(body, "Radius", out var radius); var hasDiameter = Length(body, "Diameter", out var diameter);
if (hasRadius == hasDiameter || (radius = hasRadius ? radius : diameter / 2) <= 0) return Invalid(name, "invalid-dimensions", diagnostics);
- var lowered = inline || hasDiameter ? $"Point2 {name}_Center {{ Position: [{N(c.X)}, {N(c.Y)}] }}\nCircle2Guide {name}_Curve {{ Center: {name}_Center; Radius: {N(radius)} }}" : null;
+ var lowered = inline || hasDiameter ? $"Point2 {name}_Center {{ Position: [{N(c.X)}, {N(c.Y)}] }}\nConcept Circle2 {name}_Curve {{ Center: {name}_Center; Radius: {N(radius)} }}" : null;
var guide = lowered is null ? name : name + "_Curve"; var map = new Dictionary<string, string>(StringComparer.Ordinal) { ["Center"] = inline || hasDiameter ? name + "_Center" : centerRef! };
return Make(name, "Circle2", null, c, rotation, new Dictionary<string, double> { ["Radius"] = radius, ["Diameter"] = 2 * radius }, ["Center"], ["Boundary"], "Circle", span, lowered, map, guide + " |> TraceLoop", Math.PI * radius * radius, 2 * Math.PI * radius);
}
@@ -148,7 +153,7 @@ internal static class ClosedBoundary2Authoring
var straight = length - width; var r = width / 2; var start = Rotate((c.X - straight / 2, c.Y - r), c, rotation);
if (straight <= Tol)
{
- var lowerCircle = $"Point2 {name}_Center {{ Position: [{N(c.X)}, {N(c.Y)}] }}\nCircle2Guide {name}_Curve {{ Center: {name}_Center; Radius: {N(r)} }}";
+ var lowerCircle = $"Point2 {name}_Center {{ Position: [{N(c.X)}, {N(c.Y)}] }}\nConcept Circle2 {name}_Curve {{ Center: {name}_Center; Radius: {N(r)} }}";
return Make(name, "Slot2", null, c, rotation, new Dictionary<string, double> { ["OverallLength"] = length, ["Width"] = width }, ["Center"], ["Boundary"], "Circle", span, lowerCircle,
new Dictionary<string, string> { ["Center"] = name + "_Center", ["Boundary"] = name + "_Curve" }, name + "_Curve |> TraceLoop", Math.PI * r * r, 2 * Math.PI * r);
}
diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs
index b364bd6c..0338178a 100644
--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs
@@ -970,7 +970,7 @@ public static class FirmamentV2Parser
var known = new HashSet<string>(StringComparer.Ordinal)
{
- "Box", "Cylinder", "Cone", "Sphere", "Torus", "RoundedBox", "Frustum", "StandardPart", "ExactCoaxialPart", "Point2", "Line2", "Rect2", "Circle2", "Circle2Guide", "Ellipse2Guide", "Concept", "Struct", "Construction", "Profile", "Span", "Compose", "Boss", "Pocket", "EdgeFinish",
+ "Box", "Cylinder", "Cone", "Sphere", "Torus", "RoundedBox", "Frustum", "StandardPart", "ExactCoaxialPart", "Point2", "Line2", "Rect2", "Circle2", "Ellipse2Guide", "Concept", "Struct", "Construction", "Profile", "Span", "Compose", "Boss", "Pocket", "EdgeFinish",
"Record", "Static", "Template", "template", "ProfileDelta", "Selection", "InlineStep", "Recognize", "Replace", "Pmi", "Modify", "Match", "Require", "Assert"
};
var compatibilityOnly = new HashSet<string>(StringComparer.Ordinal)
@@ -2042,7 +2042,7 @@ public static class FirmamentV2Parser
|| code.StartsWith(ConceptIrResolver.PointProjectionUnsupported, StringComparison.Ordinal)
|| code.StartsWith("firmament-static-", StringComparison.Ordinal);
- public static bool IsFatalDiagnosticCode(string code) => code.StartsWith(FirmamentV2FeatureExpansion.Prefix, StringComparison.Ordinal) || code.StartsWith("firmament-pipeline-", StringComparison.Ordinal) || code.StartsWith("firmament-profile-pipeline-", StringComparison.Ordinal) || code.StartsWith("firmament-profile-traceloop-", StringComparison.Ordinal) || code.StartsWith("firmament-boss-", StringComparison.Ordinal) || code.StartsWith("firmament-pocket-", StringComparison.Ordinal) || code.StartsWith("feature-support-", StringComparison.Ordinal) || code.StartsWith("compose-role-cardinality:", StringComparison.Ordinal) || code.StartsWith(ModifyTargetNotBoundToActiveCompose, StringComparison.Ordinal) || code.StartsWith("firmament-v2-assert-volume-", StringComparison.Ordinal) || code.StartsWith(SemanticConstraintMalformed, StringComparison.Ordinal) || code.StartsWith(SemanticConstraintUnsupported, StringComparison.Ordinal) || code.StartsWith(SemanticConstraintDimensionMismatch, StringComparison.Ordinal) || code.StartsWith(SemanticConstraintValidationFailed, StringComparison.Ordinal) || code.StartsWith(PmiProjectionUnknownRequire, StringComparison.Ordinal) || code.StartsWith(PmiProjectionUnsupportedKind, StringComparison.Ordinal) || code.StartsWith(PmiProjectedFieldMustNotOverrideSourceConstraint, StringComparison.Ordinal) || code.StartsWith(AssertVolumeKindUnsupported, StringComparison.Ordinal) || code.StartsWith(CanonicalDeclarationUnknown + ":", StringComparison.Ordinal) || code.StartsWith(CanonicalConstructNotYetSupported + ":", StringComparison.Ordinal) || code.StartsWith(EdgeFinishProfileComposeBoundaryUnsupported, StringComparison.Ordinal) || IsConceptFatalDiagnostic(code) || code is UnknownConstructionPolicy or PrimitiveDoesNotSatisfyHollowConstructible or WallThicknessRequired or WallThicknessMustBePositive or UnsupportedOpening or MultipleOpeningsNotSupported or Phase3EdgeFinishSyntaxInvalid or 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 or PmiKindUnknown or PmiTargetMissing or PmiTargetUnresolved or PmiDiameterInvalid or PmiDuplicateName or InlineStepUnknownBody or InlineStepUnknownFace or PmiImportedTargetNotFace or PmiImportedTargetRequiresCanonicalStep or PmiInvalidImportedTarget or InlineStepPathMissing or InlineStepPathInvalid or InlineStepFileMissing or InlineStepRequiresCanonical or UnknownRecognitionBody or UnknownRecognitionFace or DuplicateRegion or UnknownRecognitionRegion or InvalidRecognitionKind or InvalidRecognitionConfidence or PmiRecognizedRegionKindMismatch or UnknownReplacementBody or UnknownReplacementRegion or ReplacementKindMismatch or ReplacementFaceUnresolved or ReplacementUnsupportedKind or ReplacementVerificationFailed or ReplacementRadiusInvalid or ReplacementEndUnsupported or LetDuplicateName or LetUnknownType or LetMismatch or LetInvalidLiteral or LetUnitMismatch or LetLiteralOnly or LetRecordDuplicateName or LetRecordDuplicateField or LetReferenceUnknownRecord or LetReferenceUnknownField or LetReferenceNonRecord or LetReferenceRecordUsedAsValue or ExpressionUnknownSymbol or ExpressionUnknownRecord or ExpressionUnknownField or ExpressionRecordUsedAsValue or ExpressionScalarUsedAsRecord or ExpressionTypeMismatch or ExpressionInvalidOperator or ExpressionDivisionByZero or ExpressionCycle or ExpressionUnsupported or ToleranceInvalidType or ToleranceUnitMismatch or ToleranceInvalidLiteral or ToleranceNegativeBilateral or ToleranceMissingMinus or ToleranceMissingPlus or ToleranceUnsupported or RecognitionEvidenceRadiusInvalid or RecognitionEvidenceSurfaceFamilyUnknown or RecognitionEvidenceAxisInvalid or SemanticProposalKindMismatch or SemanticProposalRadiusInvalid or SemanticProposalTargetUnresolved or SemanticProposalEndUnsupported or ConceptUnknownFamily or ConceptUnknownConcept or ConceptMissingRequiredField or ConceptUnknownField or ConceptDuplicateField or ConceptFieldTypeMismatch or ConceptInvalidTarget or ConceptDescriptorUnavailable or PmiDuplicateBlock or PmiDuplicateRecord or PmiDuplicateDatum or PmiUnknownRecordKind or PmiMissingRequiredField or PmiUnknownField or PmiDuplicateField or PmiInvalidTarget or PmiUnknownDatum or PmiDimensionTypeMismatch or PmiDimensionMissingTolerance or PmiToleranceTypeMismatch or StandaloneFillRegionRequired or UnsupportedStandaloneFillPattern or InvalidCellCount or CellSizeMustBePositive or StrutRadiusMustBePositive or NodeRadiusMustBePositive or MaterialBoundsMismatch or StandaloneFillMultipleUnsupported;
+ public static bool IsFatalDiagnosticCode(string code) => code.StartsWith(RevolveAuthoringParser.Prefix, StringComparison.Ordinal) || code.StartsWith(FirmamentV2FeatureExpansion.Prefix, StringComparison.Ordinal) || code.StartsWith("firmament-pipeline-", StringComparison.Ordinal) || code.StartsWith("firmament-profile-pipeline-", StringComparison.Ordinal) || code.StartsWith("firmament-profile-traceloop-", StringComparison.Ordinal) || code.StartsWith("firmament-boss-", StringComparison.Ordinal) || code.StartsWith("firmament-pocket-", StringComparison.Ordinal) || code.StartsWith("feature-support-", StringComparison.Ordinal) || code.StartsWith("compose-role-cardinality:", StringComparison.Ordinal) || code.StartsWith(ModifyTargetNotBoundToActiveCompose, StringComparison.Ordinal) || code.StartsWith("firmament-v2-assert-volume-", StringComparison.Ordinal) || code.StartsWith(SemanticConstraintMalformed, StringComparison.Ordinal) || code.StartsWith(SemanticConstraintUnsupported, StringComparison.Ordinal) || code.StartsWith(SemanticConstraintDimensionMismatch, StringComparison.Ordinal) || code.StartsWith(SemanticConstraintValidationFailed, StringComparison.Ordinal) || code.StartsWith(PmiProjectionUnknownRequire, StringComparison.Ordinal) || code.StartsWith(PmiProjectionUnsupportedKind, StringComparison.Ordinal) || code.StartsWith(PmiProjectedFieldMustNotOverrideSourceConstraint, StringComparison.Ordinal) || code.StartsWith(AssertVolumeKindUnsupported, StringComparison.Ordinal) || code.StartsWith(CanonicalDeclarationUnknown + ":", StringComparison.Ordinal) || code.StartsWith(CanonicalConstructNotYetSupported + ":", StringComparison.Ordinal) || code.StartsWith(EdgeFinishProfileComposeBoundaryUnsupported, StringComparison.Ordinal) || IsConceptFatalDiagnostic(code) || code is UnknownConstructionPolicy or PrimitiveDoesNotSatisfyHollowConstructible or WallThicknessRequired or WallThicknessMustBePositive or UnsupportedOpening or MultipleOpeningsNotSupported or Phase3EdgeFinishSyntaxInvalid or 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 or PmiKindUnknown or PmiTargetMissing or PmiTargetUnresolved or PmiDiameterInvalid or PmiDuplicateName or InlineStepUnknownBody or InlineStepUnknownFace or PmiImportedTargetNotFace or PmiImportedTargetRequiresCanonicalStep or PmiInvalidImportedTarget or InlineStepPathMissing or InlineStepPathInvalid or InlineStepFileMissing or InlineStepRequiresCanonical or UnknownRecognitionBody or UnknownRecognitionFace or DuplicateRegion or UnknownRecognitionRegion or InvalidRecognitionKind or InvalidRecognitionConfidence or PmiRecognizedRegionKindMismatch or UnknownReplacementBody or UnknownReplacementRegion or ReplacementKindMismatch or ReplacementFaceUnresolved or ReplacementUnsupportedKind or ReplacementVerificationFailed or ReplacementRadiusInvalid or ReplacementEndUnsupported or LetDuplicateName or LetUnknownType or LetMismatch or LetInvalidLiteral or LetUnitMismatch or LetLiteralOnly or LetRecordDuplicateName or LetRecordDuplicateField or LetReferenceUnknownRecord or LetReferenceUnknownField or LetReferenceNonRecord or LetReferenceRecordUsedAsValue or ExpressionUnknownSymbol or ExpressionUnknownRecord or ExpressionUnknownField or ExpressionRecordUsedAsValue or ExpressionScalarUsedAsRecord or ExpressionTypeMismatch or ExpressionInvalidOperator or ExpressionDivisionByZero or ExpressionCycle or ExpressionUnsupported or ToleranceInvalidType or ToleranceUnitMismatch or ToleranceInvalidLiteral or ToleranceNegativeBilateral or ToleranceMissingMinus or ToleranceMissingPlus or ToleranceUnsupported or RecognitionEvidenceRadiusInvalid or RecognitionEvidenceSurfaceFamilyUnknown or RecognitionEvidenceAxisInvalid or SemanticProposalKindMismatch or SemanticProposalRadiusInvalid or SemanticProposalTargetUnresolved or SemanticProposalEndUnsupported or ConceptUnknownFamily or ConceptUnknownConcept or ConceptMissingRequiredField or ConceptUnknownField or ConceptDuplicateField or ConceptFieldTypeMismatch or ConceptInvalidTarget or ConceptDescriptorUnavailable or PmiDuplicateBlock or PmiDuplicateRecord or PmiDuplicateDatum or PmiUnknownRecordKind or PmiMissingRequiredField or PmiUnknownField or PmiDuplicateField or PmiInvalidTarget or PmiUnknownDatum or PmiDimensionTypeMismatch or PmiDimensionMissingTolerance or PmiToleranceTypeMismatch or StandaloneFillRegionRequired or UnsupportedStandaloneFillPattern or InvalidCellCount or CellSizeMustBePositive or StrutRadiusMustBePositive or NodeRadiusMustBePositive or MaterialBoundsMismatch or StandaloneFillMultipleUnsupported;
private static IReadOnlyList<FirmamentV2Exposure> ParseExposures(string body, List<string> diagnostics)
{
diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringParser.cs b/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringParser.cs
index a22651b3..5db70ce5 100644
--- a/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringParser.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringParser.cs
@@ -15,8 +15,7 @@ public static class ProfileAuthoringParser
private const double Tolerance = 1e-9;
private static readonly Regex Point = new(@"\bPoint2\s+(?<n>[A-Za-z_]\w*)\s*\{\s*Position\s*:\s*(?:\[|Point2\s*\()\s*(?<x>[-+.\deE]+)mm\s*,\s*(?<y>[-+.\deE]+)mm\s*(?:\]|\))", RegexOptions.Singleline | RegexOptions.CultureInvariant);
private static readonly Regex Line = new(@"\bLine2\s+(?<n>[A-Za-z_]\w*)\s*\{\s*From\s*:\s*(?<a>[\w.]+)\s*;?\s*To\s*:\s*(?<b>[\w.]+)", RegexOptions.Singleline | RegexOptions.CultureInvariant);
- private static readonly Regex Circle = new(@"\bCircle2\s+(?<n>[A-Za-z_]\w*)\s*\{\s*Center\s*:\s*(?<c>[\w.]+)\s*;?\s*Radius\s*:\s*(?<r>[-+.\deE]+)mm", RegexOptions.Singleline | RegexOptions.CultureInvariant);
- private static readonly Regex CircleGuide = new(@"\bCircle2Guide\s+(?<n>[A-Za-z_]\w*)\s*\{\s*Center\s*:\s*(?<c>[\w.]+)\s*;?\s*Radius\s*:\s*(?<r>[-+.\deE]+)mm", RegexOptions.Singleline | RegexOptions.CultureInvariant);
+ private static readonly Regex Circle = new(@"(?:\bConcept\s+)?\bCircle2\s+(?<n>[A-Za-z_]\w*)\s*\{\s*Center\s*:\s*(?<c>[\w.]+)\s*;?\s*Radius\s*:\s*(?<r>[-+.\deE]+)mm", RegexOptions.Singleline | RegexOptions.CultureInvariant);
private static readonly Regex EllipseGuide = new(@"\bEllipse2Guide\s+(?<n>[A-Za-z_]\w*)\s*\{\s*Center\s*:\s*(?<c>[\w.]+)\s*;?\s*SemiAxes\s*:\s*\[\s*(?<a>[-+.\deE]+)mm\s*,\s*(?<b>[-+.\deE]+)mm\s*\]\s*;?\s*Rotation\s*:\s*(?<r>[-+.\deE]+)deg", RegexOptions.Singleline | RegexOptions.CultureInvariant);
private static readonly Regex Rect = new(@"\bRect2\s+(?<n>[A-Za-z_]\w*)\s*\{\s*Center\s*:\s*(?:\[|Point2\s*\()\s*(?<x>[-+.\deE]+)mm\s*,\s*(?<y>[-+.\deE]+)mm\s*(?:\]|\))\s*;?\s*Size\s*:\s*\[(?<w>[-+.\deE]+)mm\s*,\s*(?<h>[-+.\deE]+)mm\]", RegexOptions.Singleline | RegexOptions.CultureInvariant);
private static readonly Regex ConstructionPlaneDeclaration = new(@"\bConstruction\s+Plane\s+(?<name>\w+)\s*\{\s*Trace\s*:\s*(?<trace>[\w.]+)\s*;?\s*\}", RegexOptions.Singleline | RegexOptions.CultureInvariant);
@@ -243,7 +242,7 @@ public static class ProfileAuthoringParser
guides[$"{name}.Top"] = new LineArcLineSegment2D(tr, tl); guides[$"{name}.Left"] = new LineArcLineSegment2D(tl, bl);
}
}
- foreach (Match match in Circle.Matches(source).Cast<Match>().Concat(CircleGuide.Matches(source).Cast<Match>()))
+ foreach (Match match in Circle.Matches(source))
{
if (!points.TryGetValue(match.Groups["c"].Value, out var center) || !TryNumber(match.Groups["r"].Value, out var radius) || radius <= 0) { diagnostics.Add($"profile-layout-unresolved-circle:{match.Groups["n"].Value}"); continue; }
// A circle remains a guide; segments choose its directed arc below.
diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/RevolveAuthoringParser.cs b/Aetheris.Kernel.Firmament/FirmamentV2/RevolveAuthoringParser.cs
new file mode 100644
index 00000000..d77405ce
--- /dev/null
+++ b/Aetheris.Kernel.Firmament/FirmamentV2/RevolveAuthoringParser.cs
@@ -0,0 +1,162 @@
+using System.Globalization;
+using System.Text.RegularExpressions;
+using Aetheris.Kernel.Core.Math;
+using Aetheris.Kernel.Firmament.Materializer;
+
+namespace Aetheris.Kernel.Firmament.FirmamentV2;
+
+public sealed record ResolvedRevolve(
+ string Name,
+ ResolvedProfile2D Profile,
+ string AxisName,
+ ConceptIrAxisValue Axis,
+ double SweepRadians,
+ string? AuthoredAlias,
+ string StableId);
+
+/// <summary>Finite semantic binder for Profile + explicit Axis + bounded Angle.</summary>
+public static class RevolveAuthoringParser
+{
+ public const string Prefix = "firmament-revolve-";
+ private const double Tol = 1e-9;
+ private static readonly Regex Revolve = new(@"\bRevolve\s+(?<name>[A-Za-z_]\w*)\s*\{(?<body>[\s\S]*?)\}", RegexOptions.CultureInvariant);
+ private static readonly Regex Axis = new(@"\bAxis\s+(?<name>[A-Za-z_]\w*)\s*\{\s*Origin\s*:\s*\[\s*(?<x>[-+.\deE]+)mm\s*,\s*(?<y>[-+.\deE]+)mm\s*,\s*(?<z>[-+.\deE]+)mm\s*\]\s*;?\s*Direction\s*:\s*\[\s*(?<dx>[-+.\deE]+)\s*,\s*(?<dy>[-+.\deE]+)\s*,\s*(?<dz>[-+.\deE]+)\s*\]", RegexOptions.CultureInvariant);
+
+ public static bool IsRevolveSource(string source) => Revolve.IsMatch(source);
+
+ public static ResolvedRevolve? Parse(string source, out IReadOnlyList<string> reportedDiagnostics)
+ {
+ ArgumentNullException.ThrowIfNull(source);
+ var diagnostics = new List<string>();
+ var feature = Revolve.Match(source);
+ if (!feature.Success) { reportedDiagnostics = [Prefix + "missing"]; return null; }
+ var name = feature.Groups["name"].Value;
+ var body = feature.Groups["body"].Value;
+ var profileName = Field(body, "Profile");
+ var axisName = Field(body, "About");
+ var angleText = Field(body, "Angle");
+ if (profileName is null) diagnostics.Add(Prefix + "profile-not-found:" + name);
+ if (axisName is null) diagnostics.Add(Prefix + "axis-not-found:" + name);
+ if (angleText is null) diagnostics.Add(Prefix + "angle-missing:" + name);
+
+ IReadOnlyList<string> profileDiagnostics = [];
+ var profile = profileName is null ? null : ProfileAuthoringParser.ResolveNamedProfile(source, profileName, out profileDiagnostics);
+ if (profileName is not null)
+ {
+ diagnostics.AddRange(profileDiagnostics);
+ if (profile is null)
+ {
+ if (profileDiagnostics.Any(message => message.Contains("nonzero area", StringComparison.Ordinal))) diagnostics.Add(Prefix + "profile-zero-area:" + name);
+ else if (profileDiagnostics.Any(message => message.Contains("self-intersection", StringComparison.Ordinal))) diagnostics.Add(Prefix + "self-intersection:" + name);
+ else if (profileDiagnostics.Any(message => message.StartsWith("profile-source-missing-profile:", StringComparison.Ordinal))) diagnostics.Add(Prefix + "profile-not-found:" + name);
+ }
+ }
+
+ ConceptIrAxisValue? axis = null;
+ if (axisName is not null)
+ {
+ var axisMatch = Axis.Matches(source).Cast<Match>().FirstOrDefault(match => match.Groups["name"].Value == axisName);
+ if (axisMatch is null) diagnostics.Add(Prefix + "axis-not-found:" + name);
+ else if (!Numbers(axisMatch, ["x", "y", "z", "dx", "dy", "dz"], out var values)) diagnostics.Add(Prefix + "axis-invalid:" + name);
+ else
+ {
+ var direction = new Vector3D(values[3], values[4], values[5]);
+ if (!direction.TryNormalize(out _)) diagnostics.Add(Prefix + "axis-zero-direction:" + name);
+ else axis = new("axis:" + axisName,
+ new(values[0], values[1], values[2]),
+ new(direction.X, direction.Y, direction.Z),
+ "Axis:" + axisName);
+ }
+ }
+
+ var sweep = 0d;
+ string? alias = null;
+ if (angleText is not null && !TryAngle(angleText, out sweep, out alias)) diagnostics.Add(Prefix + "angle-invalid:" + name);
+ else if (angleText is not null && Math.Abs(sweep) <= Tol) diagnostics.Add(Prefix + "zero-angle:" + name);
+ else if (angleText is not null && Math.Abs(sweep) > 2d * Math.PI + Tol) diagnostics.Add(Prefix + "angle-out-of-range:" + name);
+
+ if (profile is not null && axis is not null)
+ {
+ var frame = profile.EffectiveConstructionPlane;
+ var origin = new Point3D(axis.Origin.X, axis.Origin.Y, axis.Origin.Z);
+ var direction = new Vector3D(axis.Direction.X, axis.Direction.Y, axis.Direction.Z);
+ var localOrigin = frame.ToLocal(origin);
+ var normalComponent = direction.Dot(frame.AxisZ.ToVector());
+ if (Math.Abs(localOrigin.Z) > 1e-7 || Math.Abs(normalComponent) > 1e-7)
+ diagnostics.Add(Prefix + "axis-not-in-profile-plane:" + name);
+ else if (CrossesAxis(profile, localOrigin, direction, frame))
+ diagnostics.Add(Prefix + "profile-crosses-axis:" + name);
+ }
+
+ reportedDiagnostics = diagnostics.Distinct(StringComparer.Ordinal).ToArray();
+ return reportedDiagnostics.Count == 0 && profile is not null && axis is not null
+ ? new(name, profile, axisName!, axis, sweep, alias, "revolve:" + name)
+ : null;
+ }
+
+ private static string? Field(string body, string name)
+ {
+ var match = Regex.Match(body, $@"\b{Regex.Escape(name)}\s*:\s*(?<value>[^;\r\n}}]+)", RegexOptions.CultureInvariant);
+ return match.Success ? match.Groups["value"].Value.Trim() : null;
+ }
+
+ private static bool Numbers(Match match, IReadOnlyList<string> groups, out double[] values)
+ {
+ values = new double[groups.Count];
+ for (var i = 0; i < groups.Count; i++)
+ if (!double.TryParse(match.Groups[groups[i]].Value, NumberStyles.Float, CultureInfo.InvariantCulture, out values[i]) || !double.IsFinite(values[i])) return false;
+ return true;
+ }
+
+ private static bool TryAngle(string text, out double radians, out string? alias)
+ {
+ radians = 0d; alias = null;
+ var normalized = text.Trim().ToLowerInvariant();
+ var sign = 1d;
+ if (normalized.StartsWith('+')) normalized = normalized[1..].Trim();
+ else if (normalized.StartsWith('-')) { sign = -1d; normalized = normalized[1..].Trim(); }
+ var factor = normalized switch { "quarter" => Math.PI / 2d, "half" => Math.PI, "full" => 2d * Math.PI, _ => double.NaN };
+ if (double.IsFinite(factor)) { radians = sign * factor; alias = normalized; return true; }
+ if (normalized.EndsWith("deg", StringComparison.Ordinal))
+ {
+ if (!double.TryParse(normalized[..^3], NumberStyles.Float, CultureInfo.InvariantCulture, out var degrees) || !double.IsFinite(degrees)) return false;
+ radians = sign * degrees * Math.PI / 180d; return true;
+ }
+ if (!double.TryParse(normalized, NumberStyles.Float, CultureInfo.InvariantCulture, out var numeric) || !double.IsFinite(numeric)) return false;
+ radians = sign * numeric; return true;
+ }
+
+ private static bool CrossesAxis(ResolvedProfile2D profile, (double X, double Y, double Z) axisOrigin, Vector3D worldDirection, ConstructionPlane frame)
+ {
+ var dx = worldDirection.Dot(frame.AxisX.ToVector());
+ var dy = worldDirection.Dot(frame.AxisY.ToVector());
+ var length = Math.Sqrt(dx * dx + dy * dy);
+ dx /= length; dy /= length;
+ var signs = new HashSet<int>();
+ foreach (var loop in profile.Loops)
+ foreach (var segment in loop.Segments)
+ foreach (var point in Samples(segment.Geometry))
+ {
+ var signed = dx * (point.Y - axisOrigin.Y) - dy * (point.X - axisOrigin.X);
+ if (Math.Abs(signed) > 1e-7) signs.Add(Math.Sign(signed));
+ }
+ return signs.Count > 1;
+ }
+
+ private static IEnumerable<(double X, double Y)> Samples(LineArcProfileCurve2D curve)
+ {
+ switch (curve)
+ {
+ case LineArcLineSegment2D line: yield return line.Start; yield return line.End; break;
+ case LineArcCircularArc2D arc:
+ for (var i = 0; i <= 32; i++) { var a = arc.StartAngleRadians + arc.SweepAngleRadians * i / 32d; yield return (arc.Center.X + arc.Radius * Math.Cos(a), arc.Center.Y + arc.Radius * Math.Sin(a)); }
+ break;
+ case LineArcFullCircle2D circle:
+ for (var i = 0; i < 64; i++) { var a = 2d * Math.PI * i / 64d; yield return (circle.Center.X + circle.Radius * Math.Cos(a), circle.Center.Y + circle.Radius * Math.Sin(a)); }
+ break;
+ case LineArcFullEllipse2D ellipse:
+ for (var i = 0; i < 64; i++) { var a = 2d * Math.PI * i / 64d; var x = ellipse.MajorRadius * Math.Cos(a); var y = ellipse.MinorRadius * Math.Sin(a); var c = Math.Cos(ellipse.RotationRadians); var s = Math.Sin(ellipse.RotationRadians); yield return (ellipse.Center.X + c * x - s * y, ellipse.Center.Y + s * x + c * y); }
+ break;
+ }
+ }
+}
diff --git a/Aetheris.Kernel.Firmament/Materializer/ResolvedProfile2D.cs b/Aetheris.Kernel.Firmament/Materializer/ResolvedProfile2D.cs
index e32ecf6b..83c8f136 100644
--- a/Aetheris.Kernel.Firmament/Materializer/ResolvedProfile2D.cs
+++ b/Aetheris.Kernel.Firmament/Materializer/ResolvedProfile2D.cs
@@ -31,7 +31,7 @@ public static class ResolvedProfile2DValidator
var names = new HashSet<string>(StringComparer.Ordinal);
foreach (var loop in profile.Loops)
{
- if (loop.Segments.Count == 0 || (loop.Segments.Count < 3 && !(loop.Segments.Count == 1 && loop.Segments[0].Geometry is LineArcFullCircle2D or LineArcFullEllipse2D))) d.Add($"profile:{profile.Name}: loop '{loop.Name}' requires a closed boundary");
+ if (loop.Segments.Count == 0 || (loop.Segments.Count < 2 && !(loop.Segments.Count == 1 && loop.Segments[0].Geometry is LineArcFullCircle2D or LineArcFullEllipse2D))) d.Add($"profile:{profile.Name}: loop '{loop.Name}' requires a closed boundary");
for (var i=0;i<loop.Segments.Count;i++)
{
var s=loop.Segments[i]; if(!names.Add(s.Name))d.Add($"profile:{profile.Name}: duplicate segment '{s.Name}'");
@@ -49,7 +49,7 @@ public static class ResolvedProfile2DValidator
}
var area=outer.Segments.Count == 1 && outer.Segments[0].Geometry is LineArcFullCircle2D circle ? Math.PI * circle.Radius * circle.Radius
: outer.Segments.Count == 1 && outer.Segments[0].Geometry is LineArcFullEllipse2D ellipse ? Math.PI * ellipse.MajorRadius * ellipse.MinorRadius
- : outer.Segments.Sum(s=>Endpoints(s.Geometry,out var a,out var b)?a.X*b.Y-b.X*a.Y:0)/2d;
+ : outer.Segments.Sum(s=>SignedAreaContribution(s.Geometry));
if(area<=Tol)d.Add($"profile:{profile.Name}: outer winding must be CounterClockwise with nonzero area");
return new(d.Count==0,area,d);
}
@@ -60,6 +60,16 @@ public static class ResolvedProfile2DValidator
}
private static bool Endpoints(LineArcProfileCurve2D c,out (double X,double Y) a,out (double X,double Y) b){switch(c){case LineArcLineSegment2D l:a=l.Start;b=l.End;return true;case LineArcCircularArc2D x:a=(x.Center.X+x.Radius*Math.Cos(x.StartAngleRadians),x.Center.Y+x.Radius*Math.Sin(x.StartAngleRadians));b=(x.Center.X+x.Radius*Math.Cos(x.StartAngleRadians+x.SweepAngleRadians),x.Center.Y+x.Radius*Math.Sin(x.StartAngleRadians+x.SweepAngleRadians));return true;default:a=default;b=default;return false;}}
private static double Distance((double X,double Y)a,(double X,double Y)b)=>Math.Sqrt((a.X-b.X)*(a.X-b.X)+(a.Y-b.Y)*(a.Y-b.Y));
+ private static double SignedAreaContribution(LineArcProfileCurve2D curve)
+ {
+ if (curve is LineArcCircularArc2D arc)
+ {
+ var a=(X:arc.Center.X+arc.Radius*Math.Cos(arc.StartAngleRadians),Y:arc.Center.Y+arc.Radius*Math.Sin(arc.StartAngleRadians));
+ var b=(X:arc.Center.X+arc.Radius*Math.Cos(arc.StartAngleRadians+arc.SweepAngleRadians),Y:arc.Center.Y+arc.Radius*Math.Sin(arc.StartAngleRadians+arc.SweepAngleRadians));
+ return 0.5d*(arc.Center.X*(b.Y-a.Y)-arc.Center.Y*(b.X-a.X)+arc.Radius*arc.Radius*arc.SweepAngleRadians);
+ }
+ return Endpoints(curve,out var start,out var end)?0.5d*(start.X*end.Y-end.X*start.Y):0d;
+ }
private static bool Adjacent(int i,int j,int count)=>j==i+1 || (i==0 && j==count-1);
private static bool SameLine(LineArcProfileCurve2D a,LineArcProfileCurve2D b)=>a is LineArcLineSegment2D x&&b is LineArcLineSegment2D y&&((Distance(x.Start,y.Start)<=Tol&&Distance(x.End,y.End)<=Tol)||(Distance(x.Start,y.End)<=Tol&&Distance(x.End,y.Start)<=Tol));
private static bool ProperIntersection((double X,double Y)a,(double X,double Y)b,(double X,double Y)c,(double X,double Y)d)
diff --git a/Aetheris.Kernel.Firmament/Materializer/ResolvedProfileRevolveEmitter.cs b/Aetheris.Kernel.Firmament/Materializer/ResolvedProfileRevolveEmitter.cs
new file mode 100644
index 00000000..97807f72
--- /dev/null
+++ b/Aetheris.Kernel.Firmament/Materializer/ResolvedProfileRevolveEmitter.cs
@@ -0,0 +1,307 @@
+using System.Security.Cryptography;
+using System.Text;
+using Aetheris.Kernel.Core.Brep;
+using Aetheris.Kernel.Core.Geometry;
+using Aetheris.Kernel.Core.Geometry.Curves;
+using Aetheris.Kernel.Core.Geometry.Surfaces;
+using Aetheris.Kernel.Core.Math;
+using Aetheris.Kernel.Core.Topology;
+using Aetheris.Kernel.Firmament.FirmamentV2;
+
+namespace Aetheris.Kernel.Firmament.Materializer;
+
+public sealed record RevolveBRepPlan(
+ string StableId, string ProfileStableId, string AxisStableId, ConstructionPlane Frame,
+ Point3D AxisOrigin, Direction3D AxisDirection, Direction3D RadialDirection,
+ double SweepRadians, bool IsFull, string DeterministicSignature,
+ IReadOnlyList<string> SurfaceRoles, IReadOnlyList<string> Diagnostics);
+
+public sealed record ResolvedProfileRevolveResult(
+ BrepBody? Body, RevolveBRepPlan? Plan, IReadOnlyList<string> Diagnostics,
+ IReadOnlyDictionary<string, FaceId>? SemanticFaces = null)
+{
+ public bool Succeeded => Body is not null && Plan is not null;
+}
+
+/// <summary>
+/// Authoritative bounded revolution plan/materializer. The source Profile remains the only
+/// boundary authority; periodic seams are representational and partial caps are semantic.
+/// </summary>
+public static class ResolvedProfileRevolveEmitter
+{
+ private const double Tol = 1e-7;
+
+ public static ResolvedProfileRevolveResult TryEmit(ResolvedRevolve revolve)
+ {
+ var diagnostics = new List<string>();
+ var validation = ResolvedProfile2DValidator.Validate(revolve.Profile);
+ if (!validation.IsValid) diagnostics.AddRange(validation.Diagnostics);
+ if (revolve.Profile.Loops.Count != 1) diagnostics.Add($"firmament-revolve-inner-loops-not-supported:{revolve.Name}");
+ var sourceOrigin = new Point3D(revolve.Axis.Origin.X, revolve.Axis.Origin.Y, revolve.Axis.Origin.Z);
+ var sourceDirection = new Vector3D(revolve.Axis.Direction.X, revolve.Axis.Direction.Y, revolve.Axis.Direction.Z);
+ if (!Direction3D.TryCreate(sourceDirection, out var sourceAxis)) diagnostics.Add($"firmament-revolve-axis-zero-direction:{revolve.Name}");
+ var sweepMagnitude = Math.Abs(revolve.SweepRadians);
+ if (!double.IsFinite(sweepMagnitude) || sweepMagnitude <= Tol) diagnostics.Add($"firmament-revolve-zero-angle:{revolve.Name}");
+ if (sweepMagnitude > 2d * Math.PI + Tol) diagnostics.Add($"firmament-revolve-angle-out-of-range:{revolve.Name}");
+ if (diagnostics.Count != 0) return new(null, null, diagnostics.Distinct(StringComparer.Ordinal).ToArray());
+
+ var frame = revolve.Profile.EffectiveConstructionPlane;
+ var localAxisOrigin = frame.ToLocal(sourceOrigin);
+ var localDx = sourceAxis.ToVector().Dot(frame.AxisX.ToVector());
+ var localDy = sourceAxis.ToVector().Dot(frame.AxisY.ToVector());
+ var localLength = Math.Sqrt(localDx * localDx + localDy * localDy);
+ if (Math.Abs(localAxisOrigin.Z) > Tol || localLength <= Tol || Math.Abs(sourceAxis.ToVector().Dot(frame.AxisZ.ToVector())) > Tol)
+ return new(null, null, [$"firmament-revolve-axis-not-in-profile-plane:{revolve.Name}"]);
+ localDx /= localLength; localDy /= localLength;
+
+ var firstNonAxis = revolve.Profile.Loops[0].Segments
+ .SelectMany(segment => Endpoints(segment.Geometry))
+ .FirstOrDefault(point => Math.Abs(Radius(point)) > Tol);
+ var sideSign = Math.Sign(Radius(firstNonAxis));
+ if (sideSign == 0) sideSign = 1;
+ var radialVector = frame.ToWorldVector((-localDy * sideSign, localDx * sideSign));
+ var radialDirection = Direction3D.Create(radialVector);
+ var axisDirection = sourceAxis;
+ var isFull = Math.Abs(sweepMagnitude - 2d * Math.PI) <= Tol;
+ var roles = revolve.Profile.Loops[0].Segments.Select(segment => "RevolvedSpan:" + segment.Name)
+ .Concat(isFull ? [] : ["Start", "End"]).ToArray();
+ var signatureText = string.Join("|", revolve.StableId, revolve.Profile.Name, revolve.Axis.StableId,
+ revolve.SweepRadians.ToString("R", System.Globalization.CultureInfo.InvariantCulture),
+ string.Join(";", revolve.Profile.Loops[0].Segments.Select(s => s.Name + ":" + s.Geometry)));
+ var signature = Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(signatureText)));
+ var plan = new RevolveBRepPlan(revolve.StableId, "profile:" + revolve.Profile.Name, revolve.Axis.StableId, frame,
+ sourceOrigin, axisDirection, radialDirection, revolve.SweepRadians, isFull, signature, roles,
+ ["revolve-profile-authoritative", "revolve-axis-explicit", isFull ? "revolve-periodic-seam" : "revolve-semantic-radial-caps"]);
+
+ if (isFull && TryEmitSphere(revolve, plan, localAxisOrigin, localDx, localDy, out var sphere)) return sphere;
+ return EmitGeneral(revolve, plan, localAxisOrigin, localDx, localDy, sideSign, sweepMagnitude);
+
+ double Radius((double X, double Y) point) => localDx * (point.Y - localAxisOrigin.Y) - localDy * (point.X - localAxisOrigin.X);
+ }
+
+ private static ResolvedProfileRevolveResult EmitGeneral(ResolvedRevolve revolve, RevolveBRepPlan plan,
+ (double X, double Y, double Z) localAxisOrigin, double localDx, double localDy, int sideSign, double sweep)
+ {
+ var segments = revolve.Profile.Loops[0].Segments;
+ var rotationAxis = revolve.SweepRadians < 0d ? Direction3D.Create(-plan.AxisDirection.ToVector()) : plan.AxisDirection;
+ if (segments.Any(segment => segment.Geometry is LineArcFullCircle2D or LineArcFullEllipse2D))
+ return new(null, plan, [$"firmament-revolve-full-closed-curve-materialization-not-supported:{revolve.Name}"]);
+ var starts = segments.Select(segment => Endpoints(segment.Geometry)[0]).ToArray();
+ var radii = starts.Select(Radius).ToArray();
+ if (radii.Any(radius => radius <= Tol))
+ return new(null, plan, [$"firmament-revolve-axis-touch-materialization-not-supported:{revolve.Name}"]);
+
+ var builder = new TopologyBuilder();
+ var geometry = new BrepGeometryStore();
+ var bindings = new BrepBindingModel();
+ var semanticFaces = new Dictionary<string, FaceId>(StringComparer.Ordinal);
+ var startVertices = starts.Select(_ => builder.AddVertex()).ToArray();
+ var endVertices = plan.IsFull ? startVertices : starts.Select(_ => builder.AddVertex()).ToArray();
+ var startEdges = new EdgeId?[segments.Count];
+ var endEdges = new EdgeId?[segments.Count];
+ var angularEdges = new EdgeId[segments.Count];
+ var vertexPoints = new Dictionary<VertexId, Point3D>();
+ var curveId = 1;
+ var surfaceId = 1;
+
+ for (var i = 0; i < starts.Length; i++)
+ {
+ var start = World(starts[i], 0d);
+ var end = World(starts[i], sweep);
+ vertexPoints[startVertices[i]] = start;
+ vertexPoints[endVertices[i]] = end;
+ angularEdges[i] = builder.AddEdge(startVertices[i], endVertices[i]);
+ var center = plan.AxisOrigin + plan.AxisDirection.ToVector() * Axial(starts[i]);
+ var circle = new Circle3Curve(center, rotationAxis, radii[i], Direction3D.Create(start - center));
+ var id = new CurveGeometryId(curveId++);
+ geometry.AddCurve(id, CurveGeometry.FromCircle(circle));
+ bindings.AddEdgeBinding(new EdgeGeometryBinding(angularEdges[i], id, new ParameterInterval(0d, plan.IsFull ? 2d * Math.PI : sweep)));
+ }
+
+ for (var i = 0; i < segments.Count; i++)
+ {
+ var next = (i + 1) % segments.Count;
+ var periodicPlanarAnnulus = plan.IsFull && segments[i].Geometry is LineArcLineSegment2D radial
+ && Math.Abs(Axial(radial.Start) - Axial(radial.End)) <= Tol;
+ if (!periodicPlanarAnnulus)
+ {
+ startEdges[i] = builder.AddEdge(startVertices[i], startVertices[next]);
+ BindProfileCurve(startEdges[i]!.Value, segments[i].Geometry, 0d);
+ }
+ if (!plan.IsFull)
+ {
+ endEdges[i] = builder.AddEdge(endVertices[i], endVertices[next]);
+ BindProfileCurve(endEdges[i]!.Value, segments[i].Geometry, sweep);
+ }
+ else endEdges[i] = startEdges[i];
+ }
+
+ var sideFaces = new List<FaceId>();
+ for (var i = 0; i < segments.Count; i++)
+ {
+ var next = (i + 1) % segments.Count;
+ var face = startEdges[i].HasValue
+ ? AddFace(builder,
+ [
+ Use.Forward(startEdges[i]!.Value), Use.Forward(angularEdges[next]),
+ Use.Reversed(endEdges[i]!.Value), Use.Reversed(angularEdges[i])
+ ])
+ : AddFaceWithLoops(builder,
+ [
+ [Use.Forward(angularEdges[next])],
+ [Use.Reversed(angularEdges[i])]
+ ]);
+ sideFaces.Add(face);
+ semanticFaces["RevolvedSpan:" + segments[i].Name] = face;
+ var sid = new SurfaceGeometryId(surfaceId++);
+ var surface = SideSurface(segments[i].Geometry);
+ geometry.AddSurface(sid, surface);
+ bindings.AddFaceBinding(new FaceGeometryBinding(face, sid, SideSameSense(segments[i].Geometry, surface)));
+ }
+
+ var faces = new List<FaceId>(sideFaces);
+ if (!plan.IsFull)
+ {
+ var startFace = AddFace(builder, startEdges.Reverse().Select(edge => Use.Reversed(edge!.Value)).ToArray());
+ var endFace = AddFace(builder, endEdges.Select(edge => Use.Forward(edge!.Value)).ToArray());
+ faces.Add(startFace); faces.Add(endFace);
+ semanticFaces["Start"] = startFace; semanticFaces["End"] = endFace;
+ var startNormal = Direction3D.Create(-rotationAxis.ToVector().Cross(plan.RadialDirection.ToVector()));
+ var endRadial = Direction3D.Create(Rotate(plan.RadialDirection.ToVector(), rotationAxis, sweep));
+ var endNormal = Direction3D.Create(rotationAxis.ToVector().Cross(endRadial.ToVector()));
+ var s0 = new SurfaceGeometryId(surfaceId++); geometry.AddSurface(s0, SurfaceGeometry.FromPlane(new PlaneSurface(plan.AxisOrigin, startNormal, plan.AxisDirection))); bindings.AddFaceBinding(new(startFace, s0));
+ var s1 = new SurfaceGeometryId(surfaceId); geometry.AddSurface(s1, SurfaceGeometry.FromPlane(new PlaneSurface(plan.AxisOrigin, endNormal, plan.AxisDirection))); bindings.AddFaceBinding(new(endFace, s1));
+ }
+ var shell = builder.AddShell(faces); builder.AddBody([shell]);
+ var body = new BrepBody(builder.Model, geometry, bindings, vertexPoints);
+ var validation = BrepBindingValidator.Validate(body, requireAllEdgeAndFaceBindings: true);
+ return validation.IsSuccess
+ ? new(body, plan, plan.Diagnostics.Concat(["revolve-brep-plan-consumed"]).ToArray(), semanticFaces)
+ : new(null, plan, validation.Diagnostics.Select(d => d.Message).ToArray());
+
+ double Radius((double X, double Y) point) => sideSign * (localDx * (point.Y - localAxisOrigin.Y) - localDy * (point.X - localAxisOrigin.X));
+ double Axial((double X, double Y) point) => localDx * (point.X - localAxisOrigin.X) + localDy * (point.Y - localAxisOrigin.Y);
+ Point3D World((double X, double Y) point, double angle) => plan.AxisOrigin + plan.AxisDirection.ToVector() * Axial(point) + Rotate(plan.RadialDirection.ToVector() * Radius(point), rotationAxis, angle);
+ void BindProfileCurve(EdgeId edge, LineArcProfileCurve2D curve, double angle)
+ {
+ var (worldCurve, interval) = WorldCurve(curve, angle, World);
+ var id = new CurveGeometryId(curveId++); geometry.AddCurve(id, worldCurve); bindings.AddEdgeBinding(new(edge, id, interval));
+ }
+ SurfaceGeometry SideSurface(LineArcProfileCurve2D curve)
+ {
+ if (curve is LineArcLineSegment2D line)
+ {
+ var r0 = Radius(line.Start); var r1 = Radius(line.End); var a0 = Axial(line.Start); var a1 = Axial(line.End);
+ var center0 = plan.AxisOrigin + plan.AxisDirection.ToVector() * a0;
+ if (Math.Abs(r0 - r1) <= Tol) return SurfaceGeometry.FromCylinder(new CylinderSurface(center0, plan.AxisDirection, r0, plan.RadialDirection));
+ if (Math.Abs(a0 - a1) <= Tol) return SurfaceGeometry.FromPlane(new PlaneSurface(center0, plan.AxisDirection, plan.RadialDirection));
+ var slope = (r1 - r0) / (a1 - a0); var apex = plan.AxisOrigin + plan.AxisDirection.ToVector() * (a0 - r0 / slope);
+ var coneAxis = slope > 0d ? plan.AxisDirection : Direction3D.Create(-plan.AxisDirection.ToVector());
+ return SurfaceGeometry.FromCone(new ConeSurface(apex, coneAxis, Math.Atan(Math.Abs(slope)), plan.RadialDirection));
+ }
+ var (directrix, _) = WorldCurve(curve, 0d, World);
+ if (curve is LineArcCircularArc2D arc)
+ {
+ var centerRadius = Radius(arc.Center); var centerWorld = World(arc.Center, 0d);
+ if (Math.Abs(centerRadius) <= Tol) return SurfaceGeometry.FromSphere(new SphereSurface(centerWorld, plan.AxisDirection, arc.Radius, plan.RadialDirection));
+ var torusCenter = plan.AxisOrigin + plan.AxisDirection.ToVector() * Axial(arc.Center);
+ return SurfaceGeometry.FromTorus(new TorusSurface(torusCenter, plan.AxisDirection, Math.Abs(centerRadius), arc.Radius, plan.RadialDirection));
+ }
+ return SurfaceGeometry.FromSurfaceOfRevolution(new SurfaceOfRevolutionSurface(directrix, plan.AxisOrigin, plan.AxisDirection));
+ }
+ bool SideSameSense(LineArcProfileCurve2D curve, SurfaceGeometry surface)
+ {
+ if (curve is not LineArcLineSegment2D line) return true;
+ var dr = Radius(line.End) - Radius(line.Start); var da = Axial(line.End) - Axial(line.Start);
+ var desired = plan.RadialDirection.ToVector() * da - plan.AxisDirection.ToVector() * dr;
+ var carrier = surface.Kind switch
+ {
+ SurfaceGeometryKind.Cylinder => plan.RadialDirection.ToVector(),
+ SurfaceGeometryKind.Plane => surface.Plane!.Value.Normal.ToVector(),
+ SurfaceGeometryKind.Cone => surface.Cone!.Value.Normal(0d).ToVector(),
+ _ => desired
+ };
+ return desired.Dot(carrier) >= 0d;
+ }
+ }
+
+ private static bool TryEmitSphere(ResolvedRevolve revolve, RevolveBRepPlan plan,
+ (double X, double Y, double Z) localAxisOrigin, double localDx, double localDy,
+ out ResolvedProfileRevolveResult result)
+ {
+ result = default!;
+ var segments = revolve.Profile.Loops[0].Segments;
+ var arcSegments = segments.Where(segment => segment.Geometry is LineArcCircularArc2D).ToArray();
+ if (segments.Count != 2 || arcSegments.Length != 1 || arcSegments[0].Geometry is not LineArcCircularArc2D arc || Math.Abs(Math.Abs(arc.SweepAngleRadians) - Math.PI) > Tol) return false;
+ var arcSegment = arcSegments[0];
+ var line = segments.Single(segment => segment != arcSegment).Geometry as LineArcLineSegment2D;
+ if (line is null) return false;
+ double Radius((double X, double Y) p) => localDx * (p.Y - localAxisOrigin.Y) - localDy * (p.X - localAxisOrigin.X);
+ if (Math.Abs(Radius(arc.Center)) > Tol || Math.Abs(Radius(line.Start)) > Tol || Math.Abs(Radius(line.End)) > Tol) return false;
+ var center = revolve.Profile.EffectiveConstructionPlane.ToWorld(arc.Center);
+ var builder = new TopologyBuilder(); var face = builder.AddFace([]); var shell = builder.AddShell([face]); builder.AddBody([shell]);
+ var geometry = new BrepGeometryStore(); geometry.AddSurface(new(1), SurfaceGeometry.FromSphere(new SphereSurface(center, plan.AxisDirection, arc.Radius, plan.RadialDirection)));
+ var bindings = new BrepBindingModel(); bindings.AddFaceBinding(new(face, new(1)));
+ var body = new BrepBody(builder.Model, geometry, bindings);
+ result = new(body, plan, plan.Diagnostics.Concat(["revolve-sphere-analytic-carrier"]).ToArray(), new Dictionary<string, FaceId> { ["RevolvedSpan:" + arcSegment.Name] = face });
+ return true;
+ }
+
+ private static ((double X, double Y)[] Points, bool Closed) CurveEndpoints(LineArcProfileCurve2D curve) => curve switch
+ {
+ LineArcLineSegment2D line => ([line.Start, line.End], false),
+ LineArcCircularArc2D arc => ([(arc.Center.X + arc.Radius * Math.Cos(arc.StartAngleRadians), arc.Center.Y + arc.Radius * Math.Sin(arc.StartAngleRadians)), (arc.Center.X + arc.Radius * Math.Cos(arc.StartAngleRadians + arc.SweepAngleRadians), arc.Center.Y + arc.Radius * Math.Sin(arc.StartAngleRadians + arc.SweepAngleRadians))], false),
+ _ => ([], true)
+ };
+ private static (double X, double Y)[] Endpoints(LineArcProfileCurve2D curve) => CurveEndpoints(curve).Points;
+
+ private static (CurveGeometry Curve, ParameterInterval Interval) WorldCurve(LineArcProfileCurve2D curve, double rotation,
+ Func<(double X, double Y), double, Point3D> world) => curve switch
+ {
+ LineArcLineSegment2D line => Line(world(line.Start, rotation), world(line.End, rotation)),
+ LineArcCircularArc2D arc => Arc(arc, rotation, world),
+ _ => throw new NotSupportedException("The bounded revolve curve family is line/arc in X1.")
+ };
+
+ private static (CurveGeometry, ParameterInterval) Line(Point3D start, Point3D end)
+ {
+ var delta = end - start; return (CurveGeometry.FromLine(new Line3Curve(start, Direction3D.Create(delta))), new(0d, delta.Length));
+ }
+ private static (CurveGeometry, ParameterInterval) Arc(LineArcCircularArc2D arc, double rotation, Func<(double X, double Y), double, Point3D> world)
+ {
+ var start2 = (arc.Center.X + arc.Radius * Math.Cos(arc.StartAngleRadians), arc.Center.Y + arc.Radius * Math.Sin(arc.StartAngleRadians));
+ var mid2 = (arc.Center.X + arc.Radius * Math.Cos(arc.StartAngleRadians + Math.Sign(arc.SweepAngleRadians) * Math.PI / 2d), arc.Center.Y + arc.Radius * Math.Sin(arc.StartAngleRadians + Math.Sign(arc.SweepAngleRadians) * Math.PI / 2d));
+ var center = world(arc.Center, rotation); var start = world(start2, rotation); var mid = world(mid2, rotation);
+ var normal = Direction3D.Create((start - center).Cross(mid - center) * Math.Sign(arc.SweepAngleRadians));
+ var circle = new Circle3Curve(center, normal, arc.Radius, Direction3D.Create(start - center));
+ return (CurveGeometry.FromCircle(circle), new(0d, Math.Abs(arc.SweepAngleRadians)));
+ }
+
+ private static Vector3D Rotate(Vector3D vector, Direction3D axis, double angle)
+ {
+ var k = axis.ToVector(); return vector * Math.Cos(angle) + k.Cross(vector) * Math.Sin(angle) + k * k.Dot(vector) * (1d - Math.Cos(angle));
+ }
+
+ private static FaceId AddFace(TopologyBuilder builder, IReadOnlyList<Use> uses)
+ {
+ var loop = builder.AllocateLoopId(); var coedges = uses.Select(_ => builder.AllocateCoedgeId()).ToArray();
+ for (var i = 0; i < uses.Count; i++) builder.AddCoedge(new(coedges[i], uses[i].Edge, loop, coedges[(i + 1) % uses.Count], coedges[(i + uses.Count - 1) % uses.Count], uses[i].IsReversed));
+ builder.AddLoop(new Loop(loop, coedges)); return builder.AddFace([loop]);
+ }
+ private static FaceId AddFaceWithLoops(TopologyBuilder builder, IReadOnlyList<IReadOnlyList<Use>> boundaries)
+ {
+ var loops = new List<LoopId>();
+ foreach (var uses in boundaries)
+ {
+ var loop = builder.AllocateLoopId(); var coedges = uses.Select(_ => builder.AllocateCoedgeId()).ToArray();
+ for (var i = 0; i < uses.Count; i++) builder.AddCoedge(new(coedges[i], uses[i].Edge, loop, coedges[(i + 1) % uses.Count], coedges[(i + uses.Count - 1) % uses.Count], uses[i].IsReversed));
+ builder.AddLoop(new Loop(loop, coedges)); loops.Add(loop);
+ }
+ return builder.AddFace(loops);
+ }
+ private readonly record struct Use(EdgeId Edge, bool IsReversed)
+ {
+ public static Use Forward(EdgeId edge) => new(edge, false);
+ public static Use Reversed(EdgeId edge) => new(edge, true);
+ }
+}
diff --git a/docs/public/README.md b/docs/public/README.md
index 65f59bdb..1a0ef8a3 100644
--- a/docs/public/README.md
+++ b/docs/public/README.md
@@ -4,7 +4,7 @@ This directory is the only authoritative in-repository guide to behavior shipped
Start with [Getting Started](getting-started.md), then use these guides:
-- Firmament: [overview](firmament/overview.md), [language style](firmament/language-style.md), [syntax](firmament/syntax.md), [geometry](firmament/geometry.md), [closed 2D boundaries](firmament/boundaries.md), [bounded mathematical sculpting](firmament/sculpting.md), [Section chains](firmament/section-chains.md), [PlasticShell](firmament/plastic-shell.md), [Circular Sweep](firmament/sweep.md), [Formed Wire](firmament/wire-form.md), [Structural members and weldments](firmament/structural.md), [Semantic piping and local autorouting](firmament/piping.md), [Paperclip Template](firmament/paperclip.md), [Templates](firmament/templates.md), [materials](firmament/materials.md), [PMI](firmament/pmi.md), [Sheet Metal](firmament/sheet-metal.md), [FEA](firmament/fea.md), and [STEP import](firmament/step-import.md)
+- Firmament: [overview](firmament/overview.md), [language style](firmament/language-style.md), [syntax](firmament/syntax.md), [geometry](firmament/geometry.md), [closed 2D boundaries](firmament/boundaries.md), [Revolve](firmament/revolve.md), [bounded mathematical sculpting](firmament/sculpting.md), [Section chains](firmament/section-chains.md), [PlasticShell](firmament/plastic-shell.md), [Circular Sweep](firmament/sweep.md), [Formed Wire](firmament/wire-form.md), [Structural members and weldments](firmament/structural.md), [Semantic piping and local autorouting](firmament/piping.md), [Paperclip Template](firmament/paperclip.md), [Templates](firmament/templates.md), [materials](firmament/materials.md), [PMI](firmament/pmi.md), [Sheet Metal](firmament/sheet-metal.md), [FEA](firmament/fea.md), and [STEP import](firmament/step-import.md)
- Non-manufacturing work: [Virtual Sculpture and Sol 1](virtual-sculpture.md)
- Standard Library: [product-family index, invocation, authoring, and compatibility](standard-library/README.md)
- Interoperability: [Forge Host Protocol v1](forge/interop.md)
diff --git a/docs/public/firmament/geometry.md b/docs/public/firmament/geometry.md
index 27597437..51a062fe 100644
--- a/docs/public/firmament/geometry.md
+++ b/docs/public/firmament/geometry.md
@@ -1,6 +1,6 @@
# Geometry and semantic features
-Preview 3 plus X0 supports bounded production routes, not an unrestricted general-purpose CAD kernel. Public native examples cover Box, Cylinder, Frustum, RoundedBox, line/arc profile extrusion and composition, bounded [circular Sweep](sweep.md), ordered [Formed Wire](wire-form.md), semantic shaft/counterbore/countersink holes, slots, patterns, selected chamfer/fillet routes, hollow bodies, and a bounded cubic lattice. Consult the [support matrix](../reference/supported-features.md) before relying on a combination.
+Preview 3 plus bounded X0/X1 additions support production routes, not an unrestricted general-purpose CAD kernel. Public native examples cover Box, Cylinder, Frustum, RoundedBox, line/arc profile extrusion and composition, bounded [Revolve](revolve.md), bounded [circular Sweep](sweep.md), ordered [Formed Wire](wire-form.md), semantic shaft/counterbore/countersink holes, slots, patterns, selected chamfer/fillet routes, hollow bodies, and a bounded cubic lattice. Consult the [support matrix](../reference/supported-features.md) before relying on a combination.
Analytic single solids use the same direct named declaration family: `Sphere Body { Radius: 7.5mm }`, `Cone Body { ... }`, and `Torus Body { ... }`. `Cone` includes a pointed zero-radius end. These forms round-trip as analytic AP242 surfaces, but they do not imply arbitrary Boolean or profile-composition support. The older `solid Body: Sphere { radius: ... }` spelling remains a compatibility input, not canonical authoring. Use the qualified [sphere](../../../fixtures/Canonical/Primitives/sphere.firmament), [pointed cone](../../../fixtures/Canonical/Primitives/pointed-cone.firmament), and [torus](../../../fixtures/Canonical/Primitives/torus.firmament) sources as the boundary examples.
diff --git a/docs/public/firmament/revolve.md b/docs/public/firmament/revolve.md
new file mode 100644
index 00000000..04ef7167
--- /dev/null
+++ b/docs/public/firmament/revolve.md
@@ -0,0 +1,44 @@
+# Revolve
+
+`Revolve` sweeps one bounded 2D `Profile` around an explicit semantic `Axis` through a bounded angle. Use it when the engineering intent is “take this section and turn it around this axis.” It is a base construction, not public Boolean authoring.
+
+```firmament
+Axis MainAxis {
+ Origin: [0mm, 0mm, 0mm]
+ Direction: [0, 1, 0]
+}
+
+Rect2 Section { Center: [15mm, 0mm]; Size: [10mm, 20mm] }
+Profile RingSection { Loop Outer { Section |> TraceLoop } }
+
+Revolve Ring {
+ Profile: RingSection
+ About: MainAxis
+ Angle: full
+}
+```
+
+The axis must preexist, have a finite nonzero direction, and lie in the Profile construction plane. The Profile frame fixes the zero-angle radial direction; partial revolutions do not use a hidden world-axis orientation. Arbitrary 3D axes are supported when they are coplanar with the Profile.
+
+## Angles
+
+Radians are dimensionless numeric values. Degree literals use `deg`. The lowercase semantic aliases `quarter`, `half`, and `full` mean π/2, π, and 2π. All forms lower through one angle path.
+
+```firmament
+Angle: 1.5707963267948966
+Angle: 90deg
+Angle: quarter
+Angle: half
+Angle: full
+Angle: -90deg
+```
+
+The safe domain is `0 < |Angle| <= full`. A negative angle reverses direction. Zero and multiple turns are compile-time errors.
+
+## X1 support boundary
+
+X1 materializes a standalone base solid from one validated outer line/arc loop. A one-sided line/arc Profile may produce exact plane, cylinder, cone, sphere, or torus carriers. Full revolutions use periodic seams; partial revolutions have stable `Start` and `End` closure faces. Segment descendants use `RevolvedSpan:<segment>` identity in the construction plan.
+
+Profiles that cross the axis are rejected. A semicircle closed by its diameter is the admitted axis-touching sphere case. Other axis-touching loops and Profile inner loops are explicitly deferred rather than sent to degenerate topology. Add/Remove composition, multi-turn revolve, skew-axis projection, sheet/surface revolve, Thread, helix, and arbitrary Boolean operations are not X1 capabilities.
+
+Use `aetheris inspect part.firmament --json` to read `sweepRadians`, `sweepDegrees`, authored alias, direction, full/partial classification, axis, and Profile frame.
diff --git a/docs/public/firmament/syntax.md b/docs/public/firmament/syntax.md
index ab545c11..1d8df618 100644
--- a/docs/public/firmament/syntax.md
+++ b/docs/public/firmament/syntax.md
@@ -9,6 +9,7 @@
| `Mechanical` | Ordinary V2 mechanical parts and features. |
| `WireForm` | Formed wire, bends, coils, and knots. |
| `Sweep` | Circular-section Concept Path sweeps. |
+| `Revolve` | Bounded Profile revolution about an explicit coplanar Axis. |
| `SectionChain` | Standalone ruled/G1 section-chain bodies. |
For example, begin a formed-wire program with `schema WireForm`. An explicit schema is authoritative: if its frontend rejects the program, Firmament does not retry another frontend. Historical V1 `schema:` mappings remain compatibility metadata; they are distinct from this `schema <Name>` header.
diff --git a/docs/public/reference/supported-features.md b/docs/public/reference/supported-features.md
index 2f5a92d7..9d922269 100644
--- a/docs/public/reference/supported-features.md
+++ b/docs/public/reference/supported-features.md
@@ -10,6 +10,7 @@
| Virtual Sculpture | Bounded (ART-X0) | The explicit `Mode: Virtual` Sol 1 flagship: deterministic golden-angle/Fibonacci 3D lattice, analytic toroidal frame and eye, exact closed-body AP242 assembly, evidence/preview output, and zero rational product surfaces. This is not manufacturing geometry and does not extend Firmament engineering domains. See [Virtual Sculpture](../virtual-sculpture.md). |
| Firmament V2 analytic primitives | Bounded | Direct named Sphere, Cone (including zero-radius pointed end), and Torus routes round-trip through AP242; legacy `solid` declarations remain compatibility inputs, not canonical authoring |
| Circular Sweep | Bounded (X0) | Open planar XY Concept Path, tangent line/arc segments, constant circular diameter, analytic cylinder/torus faces, capped solid; no general 3D/variable/rail/twist sweep |
+| Revolve | Bounded (X1) | One bounded outer line/arc Profile, explicit coplanar Axis, `0 < \|Angle\| <= full`, signed direction, safe Base construction; no multi-turn, axis-crossing, general axis-touching, inner loops, Add/Remove, or skew projection |
| Profile/Path `|>` composition | Supported (LANG-PIPELINE-X1) | finite qualified span chains, automatic continuity orientation, `Reverse`, `As`, validating `Close`, real-loop-only `TraceLoop`, inherited identity/provenance; no general function pipe or control flow |
| Wire coils | Bounded (WIRE-X1) | Semantic AxisCoil plus Cylinder/Frustum/Sphere SurfaceCoil, explicit handedness/clearance, constant circular wire, evaluable winding authority, deterministic cubic non-rational STEP tube; no variable pitch/section, arbitrary support, intentional contact, dynamics, or knots |
| Formed Wire | Bounded (WIRE-X0) | One open, continuous, unbranched constant circular wire; explicit 3D StartFrame; ordered Straight and signed planar Bend operations through ±180° in current local Up/Right planes; exact line/arc centerline, ideal cut length/volume/mass, analytic cylinders/tori/caps, terminals, and fail-closed no-contact validation. No coils, knots, branches, variable section, springback, or intentional contact. See [guide](../firmament/wire-form.md). |
diff --git a/docs/release/GEOM-REVOLVE-X1.md b/docs/release/GEOM-REVOLVE-X1.md
new file mode 100644
index 00000000..fae64d84
--- /dev/null
+++ b/docs/release/GEOM-REVOLVE-X1.md
@@ -0,0 +1,37 @@
+# GEOM-REVOLVE-X1 — axis-defined bounded revolution
+
+## Executive verdict
+
+**Accepted for the documented bounded X1 Base lane.** Firmament can now express a standalone turned/revolved solid directly as `Profile + Axis + Angle`, without arbitrary Boolean authoring. Unsupported topology is rejected explicitly; it is not generalized by implication.
+
+## Architecture audit
+
+Aetheris already had one rotational geometry backend: `BrepRevolve`, analytic cylinder/cone/sphere/torus carriers, generic `SurfaceOfRevolutionSurface`, STEP `SURFACE_OF_REVOLUTION` import/export, and seam-aware display/import support. The authoritative public axis value remains `ConceptIrAxisValue`/exact Axis binding. Full periodic faces use representational seam topology; partial trims use bounded circular edges and real radial cap faces. Cylinder, cone/frustum, sphere, and torus are analytic special cases of revolution.
+
+X1 adds a finite semantic binder and `RevolveBRepPlan`; it does not add a parser callback into BRep or a second sketch/Boolean engine. The Profile's `ConstructionPlane` and explicit Axis determine world placement and the zero-angle radial direction.
+
+## Angle model and rejection
+
+- dimensionless numeric values are radians;
+- `90deg` is the canonical degree literal;
+- `quarter`, `half`, and `full` are lowercase semantic aliases;
+- signed angles select direction;
+- zero and magnitudes greater than a full turn are fatal before materialization.
+
+Typed diagnostics cover missing/zero/skew axes, zero/out-of-range angles, invalid/zero-area Profiles, and Profiles crossing the Axis. The nearby Profile validator now integrates circular-arc signed area exactly, closing the false zero-area gap exposed by a semicircle.
+
+## Artifact evidence
+
+Canonical witnesses live under `fixtures/Canonical/Revolve/`: sphere, stepped shaft, partial quarter, non-principal-axis ring, and knob. Invalid witnesses live under `fixtures/Invalid/Revolve/`.
+
+- sphere: bounds `[-20,20]` on X/Y/Z, one exact `SPHERICAL_SURFACE`, enclosed STEP reimport;
+- stepped shaft: bounds `[-20,20] x [-30,30] x [-20,20]`, four cylinders plus four planar shoulders, enclosed STEP reimport;
+- partial quarter: bounds `[0,20] x [-10,10] x [-20,0]`, two cylinders, four planes including `Start`/`End`, enclosed STEP reimport;
+- arbitrary axis: one body, six faces, exact plane/cylinder inventory, enclosed STEP reimport;
+- knob: piecewise-linear stem/head section with analytic cylinders/cones/planes and no faceted fallback.
+
+Equivalent `full` and `360deg` inputs produce byte-identical STEP in focused tests. `inspect --json` reports radians, degrees, alias, direction, full/partial classification, Axis, and Profile frame.
+
+## Explicit boundary
+
+The admitted X1 body has one outer line/arc loop. Semicircle-about-diameter is the proven axis-touching sphere lane; other axis-touching topology and inner loops are deferred. X1 exposes Base only. Add/Remove composition, sheet revolve, multi-turn, Thread/helix, skew projection, and arbitrary Boolean operations remain unsupported. Cylinder/Sphere/Cone syntax remains preferred when that primitive is the engineering intent.
diff --git a/fixtures/Canonical/Revolve/arbitrary-axis.firmament b/fixtures/Canonical/Revolve/arbitrary-axis.firmament
new file mode 100644
index 00000000..5bd38f77
--- /dev/null
+++ b/fixtures/Canonical/Revolve/arbitrary-axis.firmament
@@ -0,0 +1,11 @@
+schema Mechanical
+
+Model ArbitraryAxisTurn {
+ Units: mm
+ Axis Tilted { Origin: [3mm, 4mm, 5mm]; Direction: [1, 1, 0] }
+ Concept Struct Supports { Datum: Plane { Origin: [3mm,4mm,5mm]; Normal: [1,-1,0]; Up: [0,0,1] } }
+ Construction Plane SectionFrame { Trace: Supports.Datum }
+ Rect2 Section { Center: [0mm, 15mm]; Size: [20mm, 10mm] }
+ Profile SectionProfile Using SectionFrame { Loop Outer { Section |> TraceLoop } }
+ Revolve TiltedRing { Profile: SectionProfile; About: Tilted; Angle: half }
+}
diff --git a/fixtures/Canonical/Revolve/knob.firmament b/fixtures/Canonical/Revolve/knob.firmament
new file mode 100644
index 00000000..23c93d0e
--- /dev/null
+++ b/fixtures/Canonical/Revolve/knob.firmament
@@ -0,0 +1,19 @@
+schema Mechanical
+
+Model TurnedKnob {
+ Units: mm
+ Axis MainAxis { Origin: [0mm, 0mm, 0mm]; Direction: [0, 1, 0] }
+ Static KnobPoints: Set<Point2> {
+ StemBottomInner => Point2(5mm, -18mm)
+ StemBottomOuter => Point2(15mm, -18mm)
+ StemShoulder => Point2(15mm, -8mm)
+ HeadLower => Point2(24mm, -2mm)
+ HeadUpper => Point2(24mm, 8mm)
+ CrownOuter => Point2(18mm, 16mm)
+ CrownInner => Point2(6mm, 16mm)
+ StemTopInner => Point2(5mm, 10mm)
+ }
+ Polygon2<Explicit> KnobBoundary { Vertices: KnobPoints }
+ Profile KnobSection { Loop Outer { KnobBoundary |> TraceLoop } }
+ Revolve Knob { Profile: KnobSection; About: MainAxis; Angle: full }
+}
diff --git a/fixtures/Canonical/Revolve/partial-quarter.firmament b/fixtures/Canonical/Revolve/partial-quarter.firmament
new file mode 100644
index 00000000..017ae5e9
--- /dev/null
+++ b/fixtures/Canonical/Revolve/partial-quarter.firmament
@@ -0,0 +1,9 @@
+schema Mechanical
+
+Model QuarterSector {
+ Units: mm
+ Axis MainAxis { Origin: [0mm, 0mm, 0mm]; Direction: [0, 1, 0] }
+ Rect2 Section { Center: [15mm, 0mm]; Size: [10mm, 20mm] }
+ Profile RingSection { Loop Outer { Section |> TraceLoop } }
+ Revolve Sector { Profile: RingSection; About: MainAxis; Angle: quarter }
+}
diff --git a/fixtures/Canonical/Revolve/sphere.firmament b/fixtures/Canonical/Revolve/sphere.firmament
new file mode 100644
index 00000000..bbaf7a0b
--- /dev/null
+++ b/fixtures/Canonical/Revolve/sphere.firmament
@@ -0,0 +1,16 @@
+schema Mechanical
+
+Model RevolvedSphere {
+ Units: mm
+ Axis MainAxis { Origin: [0mm, 0mm, 0mm]; Direction: [0, 1, 0] }
+ Point2 South { Position: [0mm, -20mm] }
+ Point2 North { Position: [0mm, 20mm] }
+ Point2 Center { Position: [0mm, 0mm] }
+ Concept Circle2 Meridian { Center: Center; Radius: 20mm }
+ Line2 Diameter { From: North; To: South }
+ Profile SphereSection { Loop Outer {
+ Segment Arc { Trace: Meridian; From: South; To: North; Sweep: CounterClockwise }
+ Segment AxisClosure { Trace: Diameter; From: North; To: South }
+ } }
+ Revolve Ball { Profile: SphereSection; About: MainAxis; Angle: full }
+}
diff --git a/fixtures/Canonical/Revolve/stepped-shaft.firmament b/fixtures/Canonical/Revolve/stepped-shaft.firmament
new file mode 100644
index 00000000..ccf83d64
--- /dev/null
+++ b/fixtures/Canonical/Revolve/stepped-shaft.firmament
@@ -0,0 +1,19 @@
+schema Mechanical
+
+Model SteppedShaft {
+ Units: mm
+ Axis MainAxis { Origin: [0mm, 0mm, 0mm]; Direction: [0, 1, 0] }
+ Static SectionPoints: Set<Point2> {
+ InnerBottom => Point2(5mm, -30mm)
+ OuterBottom => Point2(15mm, -30mm)
+ LowerShoulder => Point2(15mm, -10mm)
+ WideLower => Point2(20mm, -10mm)
+ WideUpper => Point2(20mm, 10mm)
+ UpperShoulder => Point2(12mm, 10mm)
+ OuterTop => Point2(12mm, 30mm)
+ InnerTop => Point2(5mm, 30mm)
+ }
+ Polygon2<Explicit> ShaftBoundary { Vertices: SectionPoints }
+ Profile ShaftSection { Loop Outer { ShaftBoundary |> TraceLoop } }
+ Revolve Shaft { Profile: ShaftSection; About: MainAxis; Angle: full }
+}
diff --git a/fixtures/Canonical/qualification.json b/fixtures/Canonical/qualification.json
index 66c5e512..374869f5 100644
--- a/fixtures/Canonical/qualification.json
+++ b/fixtures/Canonical/qualification.json
@@ -32,6 +32,7 @@
{ "path": "Set", "operation": "build-step" },
{ "path": "Span", "operation": "build-step" },
{ "path": "Boundary2", "operation": "build-step" },
+ { "path": "Revolve", "operation": "build-step" },
{ "path": "PMI", "operation": "build-step" },
{ "path": "Templates", "operation": "build-step" },
{ "path": "Integration", "operation": "build-step" }
diff --git a/fixtures/Invalid/Revolve/angle-over-full.firmament b/fixtures/Invalid/Revolve/angle-over-full.firmament
new file mode 100644
index 00000000..9d49b388
--- /dev/null
+++ b/fixtures/Invalid/Revolve/angle-over-full.firmament
@@ -0,0 +1,4 @@
+Axis MainAxis { Origin: [0mm,0mm,0mm]; Direction: [0,1,0] }
+Rect2 Section { Center: [15mm,0mm]; Size: [10mm,20mm] }
+Profile P { Loop Outer { Section |> TraceLoop } }
+Revolve Bad { Profile: P; About: MainAxis; Angle: 361deg }
diff --git a/fixtures/Invalid/Revolve/axis-not-in-plane.firmament b/fixtures/Invalid/Revolve/axis-not-in-plane.firmament
new file mode 100644
index 00000000..26b856e8
--- /dev/null
+++ b/fixtures/Invalid/Revolve/axis-not-in-plane.firmament
@@ -0,0 +1,4 @@
+Axis MainAxis { Origin: [0mm,0mm,1mm]; Direction: [0,1,0] }
+Rect2 Section { Center: [15mm,0mm]; Size: [10mm,20mm] }
+Profile P { Loop Outer { Section |> TraceLoop } }
+Revolve Bad { Profile: P; About: MainAxis; Angle: full }
diff --git a/fixtures/Invalid/Revolve/profile-crosses-axis.firmament b/fixtures/Invalid/Revolve/profile-crosses-axis.firmament
new file mode 100644
index 00000000..d3d6cfeb
--- /dev/null
+++ b/fixtures/Invalid/Revolve/profile-crosses-axis.firmament
@@ -0,0 +1,4 @@
+Axis MainAxis { Origin: [0mm,0mm,0mm]; Direction: [0,1,0] }
+Rect2 Section { Center: [0mm,0mm]; Size: [10mm,20mm] }
+Profile P { Loop Outer { Section |> TraceLoop } }
+Revolve Bad { Profile: P; About: MainAxis; Angle: full }
diff --git a/fixtures/Invalid/Revolve/zero-angle.firmament b/fixtures/Invalid/Revolve/zero-angle.firmament
new file mode 100644
index 00000000..f36e95a2
--- /dev/null
+++ b/fixtures/Invalid/Revolve/zero-angle.firmament
@@ -0,0 +1,4 @@
+Axis MainAxis { Origin: [0mm,0mm,0mm]; Direction: [0,1,0] }
+Rect2 Section { Center: [15mm,0mm]; Size: [10mm,20mm] }
+Profile P { Loop Outer { Section |> TraceLoop } }
+Revolve Bad { Profile: P; About: MainAxis; Angle: 0deg }
diff --git a/fixtures/Invalid/Revolve/zero-area-profile.firmament b/fixtures/Invalid/Revolve/zero-area-profile.firmament
new file mode 100644
index 00000000..b50cbdc6
--- /dev/null
+++ b/fixtures/Invalid/Revolve/zero-area-profile.firmament
@@ -0,0 +1,7 @@
+Axis MainAxis { Origin: [0mm,0mm,0mm]; Direction: [0,1,0] }
+Point2 A { Position: [10mm,0mm] }
+Point2 B { Position: [10mm,10mm] }
+Line2 AB { From: A; To: B }
+Line2 BA { From: B; To: A }
+Profile P { Loop Outer { Segment Up { Trace: AB; From: A; To: B } Segment Down { Trace: BA; From: B; To: A } } }
+Revolve Bad { Profile: P; About: MainAxis; Angle: full }
diff --git a/fixtures/Invalid/Revolve/zero-axis.firmament b/fixtures/Invalid/Revolve/zero-axis.firmament
new file mode 100644
index 00000000..e597ca3a
--- /dev/null
+++ b/fixtures/Invalid/Revolve/zero-axis.firmament
@@ -0,0 +1,4 @@
+Axis MainAxis { Origin: [0mm,0mm,0mm]; Direction: [0,0,0] }
+Rect2 Section { Center: [15mm,0mm]; Size: [10mm,20mm] }
+Profile P { Loop Outer { Section |> TraceLoop } }
+Revolve Bad { Profile: P; About: MainAxis; Angle: full }