Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Add ellipsoid support to B-rep tessellation
Yuechen Lib1a9ebd5893f
diff --git a/Aetheris.CLI.Tests/ConvexStockCliTests.cs b/Aetheris.CLI.Tests/ConvexStockCliTests.csnew file mode 100644index 00000000..cbc8f5bc--- /dev/null+++ b/Aetheris.CLI.Tests/ConvexStockCliTests.cs@@ -0,0 +1,91 @@+using System.Text.Json;+using Aetheris.Kernel.Core.Step242;++namespace Aetheris.CLI.Tests;++public sealed class ConvexStockCliTests+{+ public static TheoryData<string, int> Accepted => new()+ {+ { "box-rounded", 26 }, { "ellipsoid", 8 },+ { "polyhedron-4", 4 }, { "polyhedron-6", 6 }, { "polyhedron-8", 8 }, { "polyhedron-12", 12 }, { "polyhedron-20", 20 },+ { "polyhedron-4-rounded", 14 }, { "polyhedron-6-rounded", 26 }, { "polyhedron-8-rounded", 26 },+ { "polyhedron-12-rounded", 62 }, { "polyhedron-20-rounded", 62 }+ };++ [Theory]+ [MemberData(nameof(Accepted))]+ public void ValidateBuildAndMeshUseTheActualStock(string fixture, int faces)+ {+ WithSource(Fixture(fixture), (path, output) =>+ {+ foreach (var command in new[] { "validate", "build" })+ {+ var stdout = new StringWriter(); var stderr = new StringWriter();+ var args = command == "validate" ? new[] { command, path, "--json" } : new[] { command, path, "--out", output, "--json" };+ Assert.True(CliRunner.Run(args, stdout, stderr) == 0, stdout + stderr.ToString());+ }+ var imported = Step242Importer.ImportBody(File.ReadAllText(output));+ Assert.True(imported.IsSuccess, string.Join("\n", imported.Diagnostics));+ Assert.Equal(faces, imported.Value.Topology.Faces.Count());+ var mesh = new StringWriter(); var error = new StringWriter();+ Assert.True(CliRunner.Run(["mesh", output, "--format", "obj", "--output", output + ".obj", "--json"], mesh, error) == 0, mesh + error.ToString());+ using var json = JsonDocument.Parse(mesh.ToString()); var report = json.RootElement;+ Assert.True(report.GetProperty("watertight").GetBoolean(), mesh.ToString());+ Assert.True(report.GetProperty("connected").GetBoolean(), mesh.ToString());+ Assert.True(report.GetProperty("outwardOriented").GetBoolean(), mesh.ToString());+ });+ }++ [Theory]+ [InlineData("Ellipsoid stock { radii: [18mm, 12mm, 25mm]; heigth: 4mm }", "", "field-unknown")]+ [InlineData("Polyhedron<10> stock { edgeLength: 20mm }", "", "polyhedron-face-count-unsupported")]+ [InlineData("Polyhedron<6> stock { edgeLength: 20 }", "", "field-value-invalid")]+ [InlineData("Ellipsoid stock { radii: [18mm, 0mm, 25mm] }", "", "ellipsoid-radii-invalid")]+ [InlineData("Cylinder stock { radius: 10mm; height: 20mm }", "EdgeFinish<Fillet> rounding { target: AllEdges; radius: 1mm }", "uniform-stock-fillet-unsupported")]+ [InlineData("Ellipsoid stock { radii: [18mm, 12mm, 25mm] }", "EdgeFinish<Fillet> rounding { target: AllEdges; radius: 1mm }", "uniform-stock-fillet-unsupported")]+ [InlineData("Box stock { size: [20mm, 20mm, 20mm] }", "EdgeFinish<Fillet> rounding { target: AllEdges; radius: 10mm }", "UniformFilletRadiusTooLarge")]+ [InlineData("Box stock { size: [20mm, 20mm, 20mm] }", "EdgeFinish<Fillet> rounding { target: AllEdges; face: [1, 2]; radius: 1mm }", "field-value-invalid")]+ [InlineData("Box stock { size: [20mm, 20mm, 20mm] }", "EdgeFinish<Fillet> rounding { target: AllEdges; kind: 9; radius: 1mm }", "field-value-invalid")]+ [InlineData("Box stock { size: [20mm, 20mm, 20mm] }", "EdgeFinish<Fillet> rounding { target: AllEdges; distance: 1mm }", "field-value-invalid")]+ [InlineData("Box stock { size: [20mm, 20mm, 20mm] }", "EdgeFinish<Chamfer> rounding { target: AllEdges; distance: 1mm }", "uniform-stock-fillet-unsupported")]+ [InlineData("Box stock { size: [20mm, 20mm, 20mm] }", "EdgeFinish<Fillet> rounding { target: AllEdges; radius: 1mm } Hole<Shaft> H { on: +Z; center: [0mm, 0mm]; diameter: 2mm; end: ThroughAll }", "uniform-stock-fillet-unsupported")]+ public void UnsupportedAndInvalidIntentCannotProduceAnArtifact(string stock, string operation, string code)+ {+ var source = "Model Rejected {\n units: mm\n " + stock + "\n" + (operation.Length == 0 ? "" : " Modify stock {\n " + operation + "\n }\n") + "}";+ WithSource(source, (path, output) =>+ {+ foreach (var command in new[] { "validate", "build" })+ {+ var stdout = new StringWriter(); var stderr = new StringWriter();+ var args = command == "validate" ? new[] { command, path, "--json" } : new[] { command, path, "--out", output, "--json" };+ Assert.NotEqual(0, CliRunner.Run(args, stdout, stderr));+ using var json = JsonDocument.Parse(stdout.ToString());+ var report = command == "validate" ? json.RootElement.GetProperty("firmamentV2Validation") : json.RootElement;+ Assert.Contains(report.GetProperty("diagnostics").EnumerateArray(), d =>+ (d.GetProperty("code").GetString()!.Contains(code, StringComparison.Ordinal) || d.GetProperty("message").GetString()!.Contains(code, StringComparison.Ordinal))+ && d.GetProperty("line").GetInt32() > 1);+ }+ Assert.False(File.Exists(output));+ });+ }++ private static string Fixture(string name) => File.ReadAllText(Path.Combine(Root(), "fixtures/Regression/ConvexStock", name + ".firmament"));+ private static void WithSource(string source, Action<string, string> assertion)+ {+ var directory = Path.Combine(Root(), "artifacts/local/tests/convex-stock", Guid.NewGuid().ToString("N"));+ Directory.CreateDirectory(directory);+ try+ {+ var path = Path.Combine(directory, "source.firmament"); File.WriteAllText(path, source);+ assertion(path, Path.Combine(directory, "body.step"));+ }+ finally { Directory.Delete(directory, true); }+ }+ private static string Root()+ {+ 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.Kernel.Core.Tests/Brep/ConvexStockPrimitiveTests.cs b/Aetheris.Kernel.Core.Tests/Brep/ConvexStockPrimitiveTests.csnew file mode 100644index 00000000..200f49c9--- /dev/null+++ b/Aetheris.Kernel.Core.Tests/Brep/ConvexStockPrimitiveTests.cs@@ -0,0 +1,155 @@+using Aetheris.Kernel.Core.Brep;+using Aetheris.Kernel.Core.Brep.Tessellation;+using Aetheris.Kernel.Core.Geometry;+using Aetheris.Kernel.Core.Math;+using Aetheris.Kernel.Core.Step242;++namespace Aetheris.Kernel.Core.Tests.Brep;++public sealed class ConvexStockPrimitiveTests+{+ [Theory]+ [InlineData(4, 4, 6)]+ [InlineData(6, 8, 12)]+ [InlineData(8, 6, 12)]+ [InlineData(12, 20, 30)]+ [InlineData(20, 12, 30)]+ public void RegularStocksAndUniformFilletsHaveClosedSharedTopology(int faces, int vertices, int edges)+ {+ foreach (var radius in new[] { 0d, 1d })+ {+ var result = ConvexStockPrimitives.CreateRegular(faces, 20, radius);+ Assert.True(result.IsSuccess, string.Join("\n", result.Diagnostics));+ var body = result.Value;+ Assert.Equal(radius == 0 ? faces : faces + edges + vertices, body.Topology.Faces.Count());+ if (radius == 0)+ {+ Assert.Equal(vertices, body.Topology.Vertices.Count()); Assert.Equal(edges, body.Topology.Edges.Count());+ foreach (var e in body.Topology.Edges)+ {+ Assert.True(body.TryGetVertexPoint(e.StartVertexId, out var a)); Assert.True(body.TryGetVertexPoint(e.EndVertexId, out var b));+ Assert.Equal(20, (a - b).Length, 8);+ }+ }+ else+ {+ Assert.Equal(edges, body.Geometry.Surfaces.Count(s => s.Value.Kind == SurfaceGeometryKind.Cylinder));+ Assert.Equal(vertices, body.Geometry.Surfaces.Count(s => s.Value.Kind == SurfaceGeometryKind.Sphere));+ }+ Check(body);+ var step = Step242Exporter.ExportBody(body);+ Assert.True(step.IsSuccess, string.Join("\n", step.Diagnostics));+ var imported = Step242Importer.ImportBody(step.Value);+ Assert.True(imported.IsSuccess, string.Join("\n", imported.Diagnostics));+ Check(imported.Value);+ Assert.Equal(body.Topology.Faces.Count(), imported.Value.Topology.Faces.Count());+ var mesh = BrepDisplayTessellator.Tessellate(imported.Value);+ Assert.True(mesh.IsSuccess, string.Join("\n", mesh.Diagnostics));+ Assert.Equal(body.Topology.Faces.Count(), mesh.Value.FacePatches.Count(p => p.TriangleIndices.Count > 0));+ }+ }++ [Fact]+ public void WholeBoxRoundingPreservesExtentsAndHasEveryCorner()+ {+ var result = ConvexStockPrimitives.CreateRoundedBox(20, 30, 40, 2);+ Assert.True(result.IsSuccess, string.Join("\n", result.Diagnostics));+ var body = result.Value; Check(body);+ Assert.Equal(26, body.Topology.Faces.Count());+ var points = body.Topology.Vertices.Select(v => { Assert.True(body.TryGetVertexPoint(v.Id, out var p)); return p; }).ToArray();+ Assert.Equal(-10, points.Min(p => p.X), 8); Assert.Equal(10, points.Max(p => p.X), 8);+ Assert.Equal(-15, points.Min(p => p.Y), 8); Assert.Equal(15, points.Max(p => p.Y), 8);+ Assert.Equal(-20, points.Min(p => p.Z), 8); Assert.Equal(20, points.Max(p => p.Z), 8);+ var tooLarge = ConvexStockPrimitives.CreateRoundedBox(20, 30, 40, 10);+ Assert.False(tooLarge.IsSuccess); Assert.Contains(tooLarge.Diagnostics, d => d.Message.StartsWith("UniformFilletRadiusTooLarge:"));+ var mesh = BrepDisplayTessellator.TessellateSurfaceMeshIr(body);+ Assert.True(mesh.IsSuccess, string.Join("\n", mesh.Diagnostics));+ var expected = 16d * 26 * 36 + 4d * (16 * 26 + 26 * 36 + 16 * 36)+ + double.Pi * 4 * (16 + 26 + 36) + 4d / 3 * double.Pi * 8;+ Assert.InRange(SignedMeshVolume(mesh.Value) / expected, .997, 1.001);+ }++ [Theory]+ [InlineData(18, 12, 25)]+ [InlineData(5, 9, 3)]+ [InlineData(10, 10, 10)]+ [InlineData(10, 10, 20)]+ public void EllipsoidIsAnExactQuadricAcrossTheWholeDomainAndStepRoundTrip(double radiusX, double radiusY, double radiusZ)+ {+ var result = EllipsoidPrimitive.Create(radiusX, radiusY, radiusZ); Assert.True(result.IsSuccess);+ var step = Step242Exporter.ExportBody(result.Value); Assert.True(step.IsSuccess, string.Join("\n", step.Diagnostics));+ var import = Step242Importer.ImportBody(step.Value); Assert.True(import.IsSuccess, string.Join("\n", import.Diagnostics));+ foreach (var body in new[] { result.Value, import.Value })+ {+ Check(body);+ foreach (var entry in body.Geometry.Surfaces)+ {+ Assert.True(entry.Value.Kind == SurfaceGeometryKind.Ellipsoid+ || radiusX == radiusY && radiusY == radiusZ && entry.Value.Kind == SurfaceGeometryKind.Sphere);+ var surface = entry.Value.Ellipsoid?.ToStepPatch();+ if (surface is not null) Assert.NotNull(surface.Weights);+ for (var u = 0; u <= 28; u++) for (var v = 0; v <= 28; v++)+ {+ var p = surface is not null ? surface.Evaluate(u / 28d, v / 28d) : entry.Value.Sphere!.Value.Evaluate(u / 28d, v / 28d);+ Assert.Equal(1, p.X * p.X / (radiusX * radiusX) + p.Y * p.Y / (radiusY * radiusY) + p.Z * p.Z / (radiusZ * radiusZ), 11);+ }+ }+ var mesh = BrepDisplayTessellator.Tessellate(body);+ Assert.True(mesh.IsSuccess, string.Join("\n", mesh.Diagnostics));+ Assert.Equal(8, mesh.Value.FacePatches.Count(p => p.TriangleIndices.Count > 0));+ var sharedMesh = BrepDisplayTessellator.TessellateSurfaceMeshIr(body);+ Assert.True(sharedMesh.IsSuccess, string.Join("\n", sharedMesh.Diagnostics));+ Assert.InRange(SignedMeshVolume(sharedMesh.Value) / (4d / 3 * double.Pi * radiusX * radiusY * radiusZ), .995, 1.001);+ }+ }++ [Fact]+ public void EllipsoidRecoveryRequiresItsExactNetAndWorksInARigidFrame()+ {+ var patch = new Aetheris.Kernel.Core.Geometry.Surfaces.EllipsoidSurface(new(13, -5, 7),+ Direction3D.Create(new Vector3D(1, 1, 1)), Direction3D.Create(new Vector3D(1, -1, 0)), 18, 12, 25, true);+ Assert.True(Aetheris.Kernel.Core.Geometry.Surfaces.EllipsoidSurface.TryRecover(patch.ToStepPatch(), out var recovered));+ Assert.Equal(0, (patch.Center - recovered.Center).Length, 8);+ Assert.Equal(18, recovered.RadiusX, 8); Assert.Equal(12, recovered.RadiusY, 8); Assert.Equal(25, recovered.RadiusZ, 8);+ var exact = patch.ToStepPatch(); var altered = exact.ControlPoints.Select(row => row.ToArray()).ToArray();+ altered[1][1] += new Vector3D(.001, 0, 0);+ var freeform = new Aetheris.Kernel.Core.Geometry.Surfaces.BSplineSurfaceWithKnots(2, 2, altered,+ "UNSPECIFIED", false, false, false, [3, 3], [3, 3], [0, 1], [0, 1], "UNSPECIFIED", exact.Weights);+ Assert.False(Aetheris.Kernel.Core.Geometry.Surfaces.EllipsoidSurface.TryRecover(freeform, out _));+ }++ private static double SignedMeshVolume(DisplayTessellationResult mesh)+ {+ var volume = 0d;+ foreach (var patch in mesh.FacePatches)+ for (var i = 0; i < patch.TriangleIndices.Count; i += 3)+ {+ var a = patch.Positions[patch.TriangleIndices[i]] - Point3D.Origin;+ var b = patch.Positions[patch.TriangleIndices[i + 1]] - Point3D.Origin;+ var c = patch.Positions[patch.TriangleIndices[i + 2]] - Point3D.Origin;+ volume += a.Dot(b.Cross(c)) / 6;+ }+ return volume;+ }++ private static void Check(BrepBody body)+ {+ var preflight = BrepExportPreflight.Validate(body);+ Assert.True(preflight.IsValid, string.Join("\n", preflight.Diagnostics));+ foreach (var edge in body.Topology.Edges)+ {+ var uses = body.Topology.Coedges.Where(c => c.EdgeId == edge.Id).ToArray();+ Assert.Equal(2, uses.Length); Assert.NotEqual(uses[0].IsReversed, uses[1].IsReversed);+ }+ foreach (var loop in body.Topology.Loops)+ {+ var uses = loop.CoedgeIds.Select(body.Topology.GetCoedge).ToArray();+ for (var i = 0; i < uses.Length; i++)+ {+ var use = uses[i]; var next = uses[(i + 1) % uses.Length];+ var a = body.Topology.GetEdge(use.EdgeId); var b = body.Topology.GetEdge(next.EdgeId);+ Assert.Equal(use.IsReversed ? a.StartVertexId : a.EndVertexId, next.IsReversed ? b.EndVertexId : b.StartVertexId);+ }+ }+ }+}diff --git a/Aetheris.Kernel.Core/Brep/BrepExportPreflight.cs b/Aetheris.Kernel.Core/Brep/BrepExportPreflight.csindex c080b100..506b4660 100644--- a/Aetheris.Kernel.Core/Brep/BrepExportPreflight.cs+++ b/Aetheris.Kernel.Core/Brep/BrepExportPreflight.cs@@ -286,11 +286,17 @@ public static class BrepExportPreflightSurfaceGeometryKind.Cylinder when surface.Cylinder is CylinderSurface cylinder => double.Abs(RadialDistance(point, cylinder.Origin, cylinder.Axis) - cylinder.Radius),SurfaceGeometryKind.Cone when surface.Cone is ConeSurface cone => double.Abs(RadialDistance(point, cone.Apex, cone.Axis) - double.Abs((point - cone.Apex).Dot(cone.Axis.ToVector())) * double.Tan(cone.SemiAngleRadians)),SurfaceGeometryKind.Sphere when surface.Sphere is SphereSurface sphere => double.Abs(Distance(point, sphere.Center) - sphere.Radius),+ SurfaceGeometryKind.Ellipsoid when surface.Ellipsoid is { } ellipsoid => EllipsoidResidual(ellipsoid, point),SurfaceGeometryKind.Torus when surface.Torus is TorusSurface torus => double.Abs(double.Sqrt(double.Pow(RadialDistance(point, torus.Center, torus.Axis) - torus.MajorRadius, 2d) + double.Pow((point - torus.Center).Dot(torus.Axis.ToVector()), 2d)) - torus.MinorRadius),_ => Unsupported(out supported),};}+ private static double EllipsoidResidual(EllipsoidSurface e, Point3D point)+ {+ var q = e.UnitCoordinates(point);+ return (point - e.Evaluate(double.Atan2(q.Y, q.X), double.Atan2(q.Z, double.Sqrt(q.X * q.X + q.Y * q.Y)))).Length;+ }private static double Unsupported(out bool supported) { supported = false; return 0d; }private static double RadialDistance(Point3D point, Point3D origin, Direction3D axis) { var v = point - origin; var axial = v.Dot(axis.ToVector()); return (v - axis.ToVector() * axial).Length; }private static double Distance(Point3D a, Point3D b) => (a - b).Length;diff --git a/Aetheris.Kernel.Core/Brep/BrepPcurveValidator.cs b/Aetheris.Kernel.Core/Brep/BrepPcurveValidator.csindex 63c2d4b7..cd8f9fa4 100644--- a/Aetheris.Kernel.Core/Brep/BrepPcurveValidator.cs+++ b/Aetheris.Kernel.Core/Brep/BrepPcurveValidator.cs@@ -204,6 +204,7 @@ public static class BrepPcurveValidatorSurfaceGeometryKind.Cone => surface.Cone!.Value.Evaluate(uv.U, uv.V),SurfaceGeometryKind.Sphere => surface.Sphere!.Value.Evaluate(uv.U, uv.V),SurfaceGeometryKind.Torus => surface.Torus!.Value.Evaluate(uv.U, uv.V),+ SurfaceGeometryKind.Ellipsoid => surface.Ellipsoid!.Evaluate(uv.U, uv.V),SurfaceGeometryKind.BSplineSurfaceWithKnots => surface.BSplineSurfaceWithKnots!.Evaluate(uv.U, uv.V),_ => null};diff --git a/Aetheris.Kernel.Core/Brep/ConvexStockPrimitives.cs b/Aetheris.Kernel.Core/Brep/ConvexStockPrimitives.csnew file mode 100644index 00000000..179c6662--- /dev/null+++ b/Aetheris.Kernel.Core/Brep/ConvexStockPrimitives.cs@@ -0,0 +1,214 @@+using Aetheris.Kernel.Core.Diagnostics;+using Aetheris.Kernel.Core.Geometry;+using Aetheris.Kernel.Core.Geometry.Curves;+using Aetheris.Kernel.Core.Geometry.Surfaces;+using Aetheris.Kernel.Core.Math;+using Aetheris.Kernel.Core.Results;+using Aetheris.Kernel.Core.Topology;++namespace Aetheris.Kernel.Core.Brep;++/// <summary>+/// Exact construction for the five regular convex stocks and the all-edge rolling+/// ball finish on those stocks or a Box. This is deliberately not a general BRep+/// fillet: the original convex face lattice is the construction authority.+/// </summary>+public static class ConvexStockPrimitives+{+ public static bool IsRegularFaceCount(int count) => count is 4 or 6 or 8 or 12 or 20;++ public static KernelResult<BrepBody> CreateRegular(int faceCount, double edgeLength, double filletRadius = 0)+ {+ if (!IsRegularFaceCount(faceCount)) return Failure("PolyhedronFaceCountUnsupported: Regular convex Polyhedron<N> admits 4, 6, 8, 12 or 20 faces.");+ if (!Positive(edgeLength)) return Failure("PolyhedronEdgeLengthInvalid: edgeLength must be finite and positive.");+ var phi = (1 + double.Sqrt(5)) / 2;+ var vertices = new List<Point3D>();+ int[] signs = [-1, 1];+ switch (faceCount)+ {+ case 4: vertices.AddRange([new(1, 1, 1), new(1, -1, -1), new(-1, 1, -1), new(-1, -1, 1)]); break;+ case 6:+ foreach (var x in signs) foreach (var y in signs) foreach (var z in signs) vertices.Add(new(x, y, z));+ break;+ case 8:+ vertices.AddRange([new(1, 0, 0), new(-1, 0, 0), new(0, 1, 0), new(0, -1, 0), new(0, 0, 1), new(0, 0, -1)]);+ break;+ case 12:+ foreach (var x in signs) foreach (var y in signs) foreach (var z in signs) vertices.Add(new(x, y, z));+ foreach (var a in signs) foreach (var b in signs)+ vertices.AddRange([new(0, a / phi, b * phi), new(a / phi, b * phi, 0), new(b * phi, 0, a / phi)]);+ break;+ case 20:+ foreach (var a in signs) foreach (var b in signs)+ vertices.AddRange([new(0, a, b * phi), new(a, b * phi, 0), new(b * phi, 0, a)]);+ break;+ }+ var length = vertices.SelectMany((p, i) => vertices.Skip(i + 1).Select(q => (p - q).Length)).Min();+ var scale = edgeLength / length;+ return Build(vertices.Select(p => new Point3D(p.X * scale, p.Y * scale, p.Z * scale)).ToArray(), filletRadius, faceCount);+ }++ /// <summary>Kernel-centered Box; Firmament applies its existing bottom-on-XY stock frame.</summary>+ public static KernelResult<BrepBody> CreateRoundedBox(double x, double y, double z, double radius)+ {+ if (!Positive(x) || !Positive(y) || !Positive(z)) return Failure("BoxSizeInvalid: dimensions must be finite and positive.");+ if (!Positive(radius)) return Failure("UniformFilletRadiusInvalid: radius must be finite and positive.");+ var points = new List<Point3D>();+ foreach (var a in new[] { -1, 1 }) foreach (var b in new[] { -1, 1 }) foreach (var c in new[] { -1, 1 })+ points.Add(new(a * x / 2, b * y / 2, c * z / 2));+ return Build(points, radius, 6);+ }++ private sealed record StockFace(int[] Vertices, Vector3D Normal, double Offset);+ private readonly record struct Use(EdgeId Edge, bool Reverse);++ private static KernelResult<BrepBody> Build(IReadOnlyList<Point3D> points, double radius, int expectedFaces)+ {+ if (!double.IsFinite(radius) || radius < 0) return Failure("UniformFilletRadiusInvalid: radius must be finite and positive.");+ var extent = points.Max(p => (p - Point3D.Origin).Length);+ if (!double.IsFinite(extent) || extent < 1e-7) return Failure("ConvexStockSizeUnsupported: stock is below the kernel construction tolerance or exceeds finite range.");+ var tolerance = System.Math.Max(1e-9, extent * 1e-10);+ var faces = Hull(points, tolerance);+ if (faces.Count != expectedFaces) return Failure("ConvexStockHullInvalid: the regular stock did not produce its expected closed face lattice.");+ var limit = faces.Min(f => f.Offset);+ if (radius > 0 && radius >= limit - tolerance)+ return Failure(FormattableString.Invariant($"UniformFilletRadiusTooLarge: radius {radius:R}mm must be smaller than the stock inradius {limit:R}mm, leaving positive planar faces and edge spans."));+ if (radius > 0 && radius <= tolerance) return Failure("UniformFilletRadiusInvalid: radius is below the stock construction tolerance.");++ var builder = new TopologyBuilder();+ var geometry = new BrepGeometryStore();+ var bindings = new BrepBindingModel();+ var positions = new Dictionary<VertexId, Point3D>();+ var resultFaces = new List<FaceId>();+ var contact = new Dictionary<(int Vertex, int Face), VertexId>();+ var lines = new Dictionary<(int A, int B, int Face), EdgeId>();+ var arcs = new Dictionary<(int Vertex, int A, int B), EdgeId>();+ var incident = Enumerable.Range(0, points.Count).Select(v => Enumerable.Range(0, faces.Count).Where(f => faces[f].Vertices.Contains(v)).ToArray()).ToArray();+ var inner = radius == 0 ? points.ToArray() : Enumerable.Range(0, points.Count).Select(v => OffsetVertex(incident[v], faces, radius)).ToArray();+ if (inner.Any(p => !double.IsFinite(p.X) || !double.IsFinite(p.Y) || !double.IsFinite(p.Z)))+ return Failure("ConvexStockOffsetInvalid: the stock's incident planes do not have a finite common inward offset.");++ VertexId Vertex(int v, int f)+ {+ var key = (v, radius == 0 ? -1 : f);+ if (contact.TryGetValue(key, out var found)) return found;+ var id = builder.AddVertex();+ positions[id] = inner[v] + faces[f].Normal * radius;+ contact.Add(key, id); return id;+ }+ EdgeId Curve(VertexId a, VertexId b, CurveGeometry curve, double end)+ {+ var edge = builder.AddEdge(a, b); var id = new CurveGeometryId(geometry.Curves.Count() + 1);+ geometry.AddCurve(id, curve); bindings.AddEdgeBinding(new(edge, id, new(0, end))); return edge;+ }+ Use Line(int a, int b, int f)+ {+ var key = (System.Math.Min(a, b), System.Math.Max(a, b), radius == 0 ? -1 : f);+ if (!lines.TryGetValue(key, out var edge))+ {+ var start = Vertex(key.Item1, f); var end = Vertex(key.Item2, f); var vector = positions[end] - positions[start];+ edge = Curve(start, end, CurveGeometry.FromLine(new(positions[start], Direction3D.Create(vector))), vector.Length);+ lines.Add(key, edge);+ }+ return new(edge, a > b);+ }+ Use Arc(int v, int a, int b)+ {+ var key = (v, System.Math.Min(a, b), System.Math.Max(a, b));+ if (!arcs.TryGetValue(key, out var edge))+ {+ var n = faces[key.Item2].Normal; var m = faces[key.Item3].Normal;+ edge = Curve(Vertex(v, key.Item2), Vertex(v, key.Item3),+ CurveGeometry.FromCircle(new(inner[v], Direction3D.Create(n.Cross(m)), radius, Direction3D.Create(n))),+ double.Acos(double.Clamp(n.Dot(m), -1, 1)));+ arcs.Add(key, edge);+ }+ return new(edge, a > b);+ }+ void Face(IReadOnlyList<Use> uses, SurfaceGeometry surface, Vector3D outward)+ {+ // Orient the shared coedges from material-outward winding, independently+ // of edge allocation order. Curves/surfaces remain exact analytic supports.+ var polygon = uses.Select(u => positions[u.Reverse ? builder.Model.GetEdge(u.Edge).EndVertexId : builder.Model.GetEdge(u.Edge).StartVertexId]).ToArray();+ var area = Vector3D.Zero;+ for (var i = 0; i < polygon.Length; i++) area += (polygon[i] - polygon[0]).Cross(polygon[(i + 1) % polygon.Length] - polygon[0]);+ if (area.Dot(outward) < 0) uses = uses.Reverse().Select(u => new Use(u.Edge, !u.Reverse)).ToArray();+ var loop = builder.AllocateLoopId(); var ids = uses.Select(_ => builder.AllocateCoedgeId()).ToArray();+ for (var i = 0; i < ids.Length; i++) builder.AddCoedge(new(ids[i], uses[i].Edge, loop, ids[(i + 1) % ids.Length], ids[(i + ids.Length - 1) % ids.Length], uses[i].Reverse));+ builder.AddLoop(new Loop(loop, ids)); var face = builder.AddFace([loop]); resultFaces.Add(face);+ var id = new SurfaceGeometryId(geometry.Surfaces.Count() + 1); geometry.AddSurface(id, surface); bindings.AddFaceBinding(new(face, id));+ }+ for (var f = 0; f < faces.Count; f++)+ {+ var face = faces[f]; var n = Direction3D.Create(face.Normal); var x = Direction3D.Create(points[face.Vertices[1]] - points[face.Vertices[0]]);+ Face(face.Vertices.Select((v, i) => Line(v, face.Vertices[(i + 1) % face.Vertices.Length], f)).ToArray(),+ SurfaceGeometry.FromPlane(new(points[face.Vertices[0]], n, x)), face.Normal);+ }+ if (radius > 0)+ {+ var edges = new Dictionary<(int A, int B), List<int>>();+ for (var f = 0; f < faces.Count; f++)+ foreach (var pair in faces[f].Vertices.Select((v, i) => (A: System.Math.Min(v, faces[f].Vertices[(i + 1) % faces[f].Vertices.Length]), B: System.Math.Max(v, faces[f].Vertices[(i + 1) % faces[f].Vertices.Length]))))+ { if (!edges.TryGetValue(pair, out var owners)) edges.Add(pair, owners = []); owners.Add(f); }+ foreach (var (edge, owners) in edges.OrderBy(e => e.Key.A).ThenBy(e => e.Key.B))+ {+ if (owners.Count != 2) return Failure("ConvexStockHullInvalid: an edge does not have exactly two incident faces.");+ var a = owners[0]; var b = owners[1]; var normal = faces[a].Normal + faces[b].Normal;+ Face([Line(edge.A, edge.B, a), Arc(edge.B, a, b), Line(edge.B, edge.A, b), Arc(edge.A, b, a)],+ SurfaceGeometry.FromCylinder(new(inner[edge.A], Direction3D.Create(inner[edge.B] - inner[edge.A]), radius, Direction3D.Create(faces[a].Normal))), normal);+ }+ for (var v = 0; v < points.Count; v++)+ {+ var normal = incident[v].Aggregate(Vector3D.Zero, (n, f) => n + faces[f].Normal);+ var axis = Direction3D.Create(normal); var x = Tangent(axis.ToVector()); var y = axis.ToVector().Cross(x);+ var ordered = incident[v].OrderBy(f => double.Atan2(faces[f].Normal.Dot(y), faces[f].Normal.Dot(x))).ToArray();+ Face(ordered.Select((f, i) => Arc(v, f, ordered[(i + 1) % ordered.Length])).ToArray(),+ SurfaceGeometry.FromSphere(new(inner[v], axis, radius, Direction3D.Create(x))), normal);+ }+ }+ builder.AddBody([builder.AddShell(resultFaces)]);+ var body = new BrepBody(builder.Model, geometry, bindings, positions);+ var validation = BrepBindingValidator.Validate(body, requireAllEdgeAndFaceBindings: true);+ return validation.IsSuccess ? KernelResult<BrepBody>.Success(body) : KernelResult<BrepBody>.Failure(validation.Diagnostics);+ }++ private static List<StockFace> Hull(IReadOnlyList<Point3D> points, double tolerance)+ {+ var found = new Dictionary<string, StockFace>(StringComparer.Ordinal);+ for (var a = 0; a < points.Count; a++) for (var b = a + 1; b < points.Count; b++) for (var c = b + 1; c < points.Count; c++)+ {+ var cross = (points[b] - points[a]).Cross(points[c] - points[a]);+ if (cross.Length <= tolerance * tolerance) continue;+ var normal = cross * (1 / cross.Length); var d = normal.Dot(points[a] - Point3D.Origin);+ if (d < 0) { normal *= -1; d *= -1; }+ if (d <= tolerance || points.Any(p => normal.Dot(p - Point3D.Origin) > d + tolerance)) continue;+ var coplanar = Enumerable.Range(0, points.Count).Where(i => double.Abs(normal.Dot(points[i] - Point3D.Origin) - d) <= tolerance).ToArray();+ var key = string.Join(',', coplanar); if (found.ContainsKey(key)) continue;+ var x = Tangent(normal); var y = normal.Cross(x);+ var ordered = coplanar.OrderBy(i => double.Atan2((points[i] - Point3D.Origin).Dot(y), (points[i] - Point3D.Origin).Dot(x))).ToArray();+ found.Add(key, new(ordered, normal, d));+ }+ return found.OrderBy(k => k.Key, StringComparer.Ordinal).Select(k => k.Value).ToList();+ }++ private static Point3D OffsetVertex(IReadOnlyList<int> incident, IReadOnlyList<StockFace> faces, double radius)+ {+ for (var a = 0; a < incident.Count; a++) for (var b = a + 1; b < incident.Count; b++) for (var c = b + 1; c < incident.Count; c++)+ {+ var f = faces[incident[a]]; var g = faces[incident[b]]; var h = faces[incident[c]];+ var det = f.Normal.Dot(g.Normal.Cross(h.Normal)); if (double.Abs(det) < 1e-10) continue;+ var p = (g.Normal.Cross(h.Normal) * (f.Offset - radius) + h.Normal.Cross(f.Normal) * (g.Offset - radius) + f.Normal.Cross(g.Normal) * (h.Offset - radius)) * (1 / det);+ return Point3D.Origin + p;+ }+ return new(double.NaN, double.NaN, double.NaN);+ }++ private static Vector3D Tangent(Vector3D normal)+ {+ var axis = double.Abs(normal.X) < 0.8 ? new Vector3D(1, 0, 0) : new Vector3D(0, 1, 0);+ return Direction3D.Create(axis - normal * axis.Dot(normal)).ToVector();+ }+ private static bool Positive(double value) => double.IsFinite(value) && value > 0;+ private static KernelResult<BrepBody> Failure(string message) => KernelResult<BrepBody>.Failure([+ new(KernelDiagnosticCode.ValidationFailed, KernelDiagnosticSeverity.Error, message, "ConvexStock.Admission")]);+}diff --git a/Aetheris.Kernel.Core/Brep/EllipsoidPrimitive.cs b/Aetheris.Kernel.Core/Brep/EllipsoidPrimitive.csnew file mode 100644index 00000000..f349a4a0--- /dev/null+++ b/Aetheris.Kernel.Core/Brep/EllipsoidPrimitive.cs@@ -0,0 +1,60 @@+using Aetheris.Kernel.Core.Diagnostics;+using Aetheris.Kernel.Core.Geometry;+using Aetheris.Kernel.Core.Geometry.Surfaces;+using Aetheris.Kernel.Core.Geometry.Curves;+using Aetheris.Kernel.Core.Math;+using Aetheris.Kernel.Core.Results;+using Aetheris.Kernel.Core.Topology;++namespace Aetheris.Kernel.Core.Brep;++/// <summary>Exact native ellipsoid stock with explicit shared octant boundaries.</summary>+public static class EllipsoidPrimitive+{+ public static KernelResult<BrepBody> Create(double radiusX, double radiusY, double radiusZ)+ {+ if (new[] { radiusX, radiusY, radiusZ }.Any(r => !double.IsFinite(r) || r <= 1e-7 || r > 1e100))+ return KernelResult<BrepBody>.Failure([new(KernelDiagnosticCode.ValidationFailed, KernelDiagnosticSeverity.Error,+ "EllipsoidRadiiInvalid: radii must be finite positive X/Y/Z semiaxes above the kernel construction tolerance and within finite engineering range.", "Ellipsoid.Admission")]);++ // Eight native quadric octants project exactly to rational quadratic+ // STEP patches. Shared equator/meridian edges close the engineering shell.+ var builder = new TopologyBuilder(); var geometry = new BrepGeometryStore(); var bindings = new BrepBindingModel();+ var positions = new Dictionary<VertexId, Point3D>();+ (double X, double Y)[] longitude = [(1, 0), (0, 1), (-1, 0), (0, -1)];+ var equator = longitude.Select(p => AddVertex(new(radiusX * p.X, radiusY * p.Y, 0))).ToArray();+ var north = AddVertex(new(0, 0, radiusZ)); var south = AddVertex(new(0, 0, -radiusZ));+ var ring = Enumerable.Range(0, 4).Select(i => Arc(equator[i], equator[(i + 1) % 4])).ToArray();+ var upper = equator.Select(v => Arc(v, north)).ToArray(); var lower = equator.Select(v => Arc(v, south)).ToArray();+ var faces = new List<FaceId>();+ for (var i = 0; i < 4; i++) foreach (var top in new[] { true, false })+ {+ var a = longitude[i];+ var surface = new EllipsoidSurface(Point3D.Origin, Direction3D.Create(new Vector3D(0, 0, 1)),+ Direction3D.Create(new Vector3D(a.X, a.Y, 0)), i % 2 == 0 ? radiusX : radiusY,+ i % 2 == 0 ? radiusY : radiusX, radiusZ, top);+ (EdgeId Edge, bool Reverse)[] uses = top+ ? [(ring[i], false), (upper[(i + 1) % 4], false), (upper[i], true)]+ : [(ring[i], true), (lower[i], false), (lower[(i + 1) % 4], true)];+ var loop = builder.AllocateLoopId(); var ids = uses.Select(_ => builder.AllocateCoedgeId()).ToArray();+ for (var k = 0; k < 3; k++) builder.AddCoedge(new(ids[k], uses[k].Edge, loop, ids[(k + 1) % 3], ids[(k + 2) % 3], uses[k].Reverse));+ builder.AddLoop(new Loop(loop, ids)); var face = builder.AddFace([loop]); faces.Add(face);+ var surfaceId = new SurfaceGeometryId(geometry.Surfaces.Count() + 1);+ geometry.AddSurface(surfaceId, SurfaceGeometry.FromEllipsoid(surface)); bindings.AddFaceBinding(new(face, surfaceId));+ }+ builder.AddBody([builder.AddShell(faces)]);+ return KernelResult<BrepBody>.Success(new(builder.Model, geometry, bindings, positions));++ VertexId AddVertex(Point3D point) { var id = builder.AddVertex(); positions.Add(id, point); return id; }+ EdgeId Arc(VertexId start, VertexId end)+ {+ var a = positions[start] - Point3D.Origin; var b = positions[end] - Point3D.Origin;+ var major = a.Length >= b.Length ? a : b; var minor = a.Length >= b.Length ? b : a * -1;+ var angle = a.Length >= b.Length ? 0d : 1.5 * double.Pi;+ var ellipse = new Ellipse3Curve(Point3D.Origin, Direction3D.Create(Direction3D.Create(major).ToVector().Cross(Direction3D.Create(minor).ToVector())), major.Length, minor.Length, Direction3D.Create(major));+ var id = new CurveGeometryId(geometry.Curves.Count() + 1); geometry.AddCurve(id, CurveGeometry.FromEllipse(ellipse));+ var edge = builder.AddEdge(start, end); bindings.AddEdgeBinding(new(edge, id, new(angle, angle + double.Pi / 2)));+ return edge;+ }+ }+}diff --git a/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.cs b/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.csindex a512922f..82543d58 100644--- a/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.cs+++ b/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.cs@@ -42,7 +42,7 @@ public static class BrepDisplayTessellatorvar effectiveOptions = options ?? DisplayTessellationOptions.Default;return SurfaceMeshIrTessellator.TryTessellate(body, effectiveOptions, out var result)? KernelResult<DisplayTessellationResult>.Success(result)- : KernelResult<DisplayTessellationResult>.Failure([CreateNotImplemented("SurfaceMeshIR M3 supports Plane/Cylinder, full circular-trim Cone strips, closed cube-chart Spheres, and doubly-periodic Toruses. General conic and arbitrary trimmed-patch remeshing remains on the explicit legacy route.", "Viewer.SurfaceMeshIr.Unsupported")]);+ : KernelResult<DisplayTessellationResult>.Failure([CreateNotImplemented("SurfaceMeshIR supports admitted planar/conic bands, closed sphere charts, bounded convex sphere/ellipsoid trims and admitted torus patches. General arbitrary trimmed-patch remeshing remains unsupported by this route.", "Viewer.SurfaceMeshIr.Unsupported")]);}public static KernelResult<DisplayTessellationResult> TessellateBounded(@@ -269,6 +269,7 @@ public static class BrepDisplayTessellatorSurfaceGeometryKind.Cylinder => TessellateCylinderFace(body, faceId, surface.Cylinder!.Value, options, executionBudget),SurfaceGeometryKind.Cone => TessellateConeFace(body, faceId, surface.Cone!.Value, options, executionBudget),SurfaceGeometryKind.Sphere => TessellateSphereFace(body, faceId, surface.Sphere!.Value, options, executionBudget),+ SurfaceGeometryKind.Ellipsoid => TessellateEllipsoidFace(body, faceId, surface.Ellipsoid!, options, executionBudget),SurfaceGeometryKind.Torus => TessellateTorusFace(body, faceId, surface.Torus!.Value, options, executionBudget),SurfaceGeometryKind.BSplineSurfaceWithKnots => TessellateBSplineSurfaceFace(body, faceId, surface.BSplineSurfaceWithKnots!, options, executionBudget),SurfaceGeometryKind.LinearExtrusion when surface.LinearExtrusion!.Value.Directrix.BSpline3 is { } curve@@ -1860,6 +1861,36 @@ public static class BrepDisplayTessellatorreturn normalized;}+ private static KernelResult<DisplayFaceMeshPatch> TessellateEllipsoidFace(BrepBody body, FaceId faceId,+ EllipsoidSurface ellipsoid, DisplayTessellationOptions options, DisplayTessellationExecutionBudget? budget)+ {+ // Affine pullback to the existing spherical trim authority. Refinement's+ // unit-sphere chord bound is tightened by the largest singular value.+ var loops = new List<IReadOnlyList<Point3D>>();+ foreach (var loop in body.GetLoopIds(faceId))+ {+ var coedges = body.GetCoedgeIds(loop).Select(body.Topology.GetCoedge).ToArray();+ var lookup = BuildLoopVertexPointLookup(body, coedges, faceId);+ if (!lookup.IsSuccess) return KernelResult<DisplayFaceMeshPatch>.Failure(lookup.Diagnostics);+ var points = new List<Point3D>();+ foreach (var use in coedges)+ {+ var samples = TrySampleCoedgeForTrimEvaluation(body, faceId, use, lookup.Value, options, budget, SurfaceGeometryKind.Ellipsoid);+ if (!samples.IsSuccess) return KernelResult<DisplayFaceMeshPatch>.Failure(samples.Diagnostics);+ points.AddRange(samples.Value.Skip(points.Count > 0 ? 1 : 0).Select(p => Point3D.Origin + ellipsoid.UnitCoordinates(p)));+ }+ loops.Add(points);+ }+ var unit = new SphereSurface(Point3D.Origin, Direction3D.Create(new Vector3D(0, 0, 1)), 1, Direction3D.Create(new Vector3D(1, 0, 0)));+ var mesh = SphericalTrimTessellator.Tessellate(faceId, unit, loops, 0,+ body.Bindings.GetFaceBinding(faceId).Orientation.IsAlignedWithSurface,+ options with { ChordTolerance = options.ChordTolerance / double.Max(ellipsoid.RadiusX, double.Max(ellipsoid.RadiusY, ellipsoid.RadiusZ)) }, budget);+ if (!mesh.IsSuccess) return mesh;+ var positions = mesh.Value.Positions.Select(ellipsoid.FromUnit).ToArray();+ return KernelResult<DisplayFaceMeshPatch>.Success(mesh.Value with+ { Positions = positions, Normals = positions.Select(ellipsoid.Normal).ToArray() }, mesh.Diagnostics);+ }+private static KernelResult<DisplayFaceMeshPatch> TessellateSphereFace(BrepBody body, FaceId faceId, SphereSurface sphere, DisplayTessellationOptions options, DisplayTessellationExecutionBudget? executionBudget = null){var edgeLoops = body.GetLoopIds(faceId).Where(id => body.Topology.GetLoop(id).Kind == LoopKind.Edge).ToArray();diff --git a/Aetheris.Kernel.Core/Brep/Tessellation/SurfaceMeshIr.cs b/Aetheris.Kernel.Core/Brep/Tessellation/SurfaceMeshIr.csindex d33338fc..9fcb34bd 100644--- a/Aetheris.Kernel.Core/Brep/Tessellation/SurfaceMeshIr.cs+++ b/Aetheris.Kernel.Core/Brep/Tessellation/SurfaceMeshIr.cs@@ -70,7 +70,7 @@ public sealed record ForeignTrimResolution(double RecognitionTolerance,string Provenance);-public enum SurfaceMeshSupportKind { Plane, Cylinder, Cone, Sphere, Torus, BoundedParametricPatch }+public enum SurfaceMeshSupportKind { Plane, Cylinder, Cone, Sphere, Torus, BoundedParametricPatch, Ellipsoid }public enum SurfaceMeshCellKind { Quad, Triangle, BoundaryPolygon, Singular }public enum SurfaceMeshCellProvenance { Unclassified, FeatureBand, Bridge, CoarseRemainder, ResidualTransition }/// <summary>@@ -102,7 +102,8 @@ public sealed record SurfaceMeshSupport(SphereSurface? Sphere = null,TorusSurface? Torus = null,[property: JsonIgnore] ISurfaceMeshBoundedPatch? BoundedPatch = null,- string? BoundedPatchStableId = null);+ string? BoundedPatchStableId = null,+ EllipsoidSurface? Ellipsoid = null);public abstract record SurfaceMeshCell(SurfaceMeshCellKind Kind, IReadOnlyList<int> VertexIds, int RefinementLevel = 0, int? ParentCellId = null){@@ -243,7 +244,7 @@ public static class SurfaceMeshIrTessellatorvar unsupportedSupports = 0;foreach (var face in body.Topology.Faces){- if (body.TryGetFaceSurfaceGeometry(face.Id, out var surface) && surface?.Kind is SurfaceGeometryKind.Plane or SurfaceGeometryKind.Cylinder or SurfaceGeometryKind.Cone or SurfaceGeometryKind.Sphere or SurfaceGeometryKind.Torus) analytic++;+ if (body.TryGetFaceSurfaceGeometry(face.Id, out var surface) && surface?.Kind is SurfaceGeometryKind.Plane or SurfaceGeometryKind.Cylinder or SurfaceGeometryKind.Cone or SurfaceGeometryKind.Sphere or SurfaceGeometryKind.Torus or SurfaceGeometryKind.Ellipsoid) analytic++;else unsupportedSupports++;}foreach (var edge in body.Topology.Edges.OrderBy(edge => edge.Id.Value))@@ -413,10 +414,10 @@ public static class SurfaceMeshIrTessellatorforeach (var face in body.Topology.Faces.OrderBy(f => f.Id.Value)){if (!body.TryGetFaceSurfaceGeometry(face.Id, out var surface) || surface is null ||- surface.Kind is not (SurfaceGeometryKind.Plane or SurfaceGeometryKind.Cylinder or SurfaceGeometryKind.Cone or SurfaceGeometryKind.Sphere or SurfaceGeometryKind.Torus) ||+ surface.Kind is not (SurfaceGeometryKind.Plane or SurfaceGeometryKind.Cylinder or SurfaceGeometryKind.Cone or SurfaceGeometryKind.Sphere or SurfaceGeometryKind.Torus or SurfaceGeometryKind.Ellipsoid) ||!body.Bindings.TryGetFaceBinding(face.Id, out var faceBinding)){- failure = $"SurfaceMeshIR does not support face {face.Id.Value}: the face has no bound Plane/Cylinder/Cone/Sphere/Torus support.";+ failure = $"SurfaceMeshIR does not support face {face.Id.Value}: the face has no bound Plane/Cylinder/Cone/Sphere/Torus/Ellipsoid support.";return false;}switch (surface.Kind)@@ -436,7 +437,20 @@ public static class SurfaceMeshIrTessellatorif (conePatch is null) { failure = $"SurfaceMeshIR does not support trim topology on conical face {face.Id.Value}."; return false; }patches.Add(conePatch);break;+ case SurfaceGeometryKind.Ellipsoid:+ var ellipsoidPatch = TryBuildConvexQuadricPatch(body, face.Id, faceBinding.Orientation.IsAlignedWithSurface,+ new SurfaceMeshSupport(SurfaceMeshSupportKind.Ellipsoid, Ellipsoid: surface.Ellipsoid), byEdge, policy, vertices, ref nextVertexId);+ if (ellipsoidPatch is null) { failure = $"SurfaceMeshIR does not support chart/trim topology on ellipsoid face {face.Id.Value}."; return false; }+ patches.Add(ellipsoidPatch);+ break;case SurfaceGeometryKind.Sphere:+ if (body.GetLoopIds(face.Id).Count > 0)+ {+ var cornerPatch = TryBuildConvexQuadricPatch(body, face.Id, faceBinding.Orientation.IsAlignedWithSurface,+ new SurfaceMeshSupport(SurfaceMeshSupportKind.Sphere, Sphere: surface.Sphere), byEdge, policy, vertices, ref nextVertexId);+ if (cornerPatch is null) { failure = $"SurfaceMeshIR does not support convex spherical trim on face {face.Id.Value}."; return false; }+ patches.Add(cornerPatch); break;+ }if (!TryBuildSphereCharts(body, face.Id, faceBinding.Orientation.IsAlignedWithSurface, surface.Sphere!.Value, vertices, ref nextVertexId, out var spherePatches)) { failure = $"SurfaceMeshIR does not support chart/trim topology on spherical face {face.Id.Value}."; return false; }patches.AddRange(spherePatches);break;@@ -1373,6 +1387,77 @@ public static class SurfaceMeshIrTessellatorreturn new SurfacePatch(faceId, support, loops, cells, sameSense, HasPeriodicUSeam: hasPeriodicUSeam);}+ // One bounded convex spherical chart, optionally transformed by the exact+ // ellipsoid frame. Shared trim samples stay immutable; concentric inner rings+ // refine only the face interior, so neighboring edge/face identities agree.+ private static SurfacePatch? TryBuildConvexQuadricPatch(BrepBody body, FaceId face, bool sameSense,+ SurfaceMeshSupport support, IReadOnlyDictionary<EdgeId, SharedEdgeSamplePlan> plans, SurfaceMeshPolicy policy,+ List<SurfaceMeshVertex> vertices, ref int nextId)+ {+ var loops = body.GetLoopIds(face);+ if (loops.Count != 1) return null;+ var boundary = new List<SurfaceMeshVertex>();+ foreach (var coedge in body.GetCoedgeIds(loops[0]).Select(body.Topology.GetCoedge))+ {+ var plan = plans[coedge.EdgeId];+ if (plan.CurveKind is not (CurveGeometryKind.Circle3 or CurveGeometryKind.Ellipse3)) return null;+ var reversed = coedge.IsReversed ^ !body.Bindings.GetEdgeBinding(coedge.EdgeId).OrientedEdgeSense;+ var samples = reversed ? plan.Samples.Reverse().ToArray() : plan.Samples;+ boundary.AddRange(samples.Take(samples.Count - 1));+ }+ if (boundary.Count < 3) return null;+ var ellipsoid = support.Ellipsoid;+ var sphere = support.Sphere;+ Vector3D Unit(Point3D point) => ellipsoid is not null ? ellipsoid.UnitCoordinates(point)+ : (point - sphere!.Value.Center) * (1 / sphere.Value.Radius);+ Point3D World(Vector3D unit) => ellipsoid is not null ? ellipsoid.FromUnit(Point3D.Origin + unit)+ : sphere!.Value.Center + unit * sphere.Value.Radius;+ var directions = boundary.Select(p => Unit(p.Position)).ToArray();+ if (directions.Any(v => double.Abs(v.Length - 1) > 1e-8)) return null;+ var sum = directions.Aggregate(Vector3D.Zero, (a, b) => a + b);+ if (!Direction3D.TryCreate(sum, out var direction)) return null;+ var center = direction.ToVector();+ if (directions.Any(d => center.Dot(d) < .1)) return null;+ var area = Vector3D.Zero;+ for (var i = 0; i < directions.Length; i++) area += directions[i].Cross(directions[(i + 1) % directions.Length]);+ if (area.Dot(center) < 0) { boundary.Reverse(); Array.Reverse(directions); }+ // A small convex normal polygon is the admitted domain. Concave or+ // self-crossing loops cannot be replaced by this radial chart.+ for (var i = 0; i < directions.Length; i++)+ {+ var normal = directions[i].Cross(directions[(i + 1) % directions.Length]);+ if (normal.Length < 1e-12) continue;+ if (directions.Any(d => normal.Dot(d) < -1e-9)) return null;+ }+ var maxRadius = ellipsoid is null ? sphere!.Value.Radius : double.Max(ellipsoid.RadiusX, double.Max(ellipsoid.RadiusY, ellipsoid.RadiusZ));+ var minRadius = ellipsoid is null ? maxRadius : double.Min(ellipsoid.RadiusX, double.Min(ellipsoid.RadiusY, ellipsoid.RadiusZ));+ var angle = double.Min(policy.TargetNormalErrorRadians * minRadius / maxRadius, double.Sqrt(8 * policy.TargetChordalError / maxRadius)) / 2;+ if (!double.IsFinite(angle) || angle <= 0) return null;+ var count = double.Ceiling(2 * directions.Max(d => double.Acos(double.Clamp(center.Dot(d), -1, 1))) / angle);+ if (!double.IsFinite(count) || count > policy.MaxBoundarySamples) return null;+ var rings = System.Math.Max(1, (int)count);+ var centerId = nextId++; vertices.Add(new(centerId, World(center)));+ var previous = Array.Empty<int>(); var cells = new List<SurfaceMeshCell>();+ for (var ring = 1; ring <= rings; ring++)+ {+ var current = new int[boundary.Count]; var t = (double)ring / rings;+ for (var i = 0; i < current.Length; i++)+ {+ if (ring == rings) { current[i] = boundary[i].Id; continue; }+ var q = Direction3D.Create(center * (1 - t) + directions[i] * t).ToVector();+ current[i] = nextId++; vertices.Add(new(current[i], World(q)));+ }+ for (var i = 0; i < current.Length; i++)+ {+ var j = (i + 1) % current.Length;+ if (ring == 1) cells.Add(new TriangleCell(Orient([centerId, current[i], current[j]], sameSense)));+ else cells.Add(new QuadCell(Orient([previous[i], current[i], current[j], previous[j]], sameSense)));+ }+ previous = current;+ }+ return new(face, support, loops, cells, sameSense, ChartId: "ConvexQuadricTrim");+ }+private static bool TryBuildSphereCharts(BrepBody body,FaceId faceId,@@ -1935,6 +2020,8 @@ public static class SurfaceMeshIrTessellatorvar exact = cone.Normal(angle).ToVector();return patch.IsAlignedWithSupport ? exact : -exact;},+ SurfaceMeshSupportKind.Ellipsoid when patch.Support.Ellipsoid is { } ellipsoid => p =>+ patch.IsAlignedWithSupport ? ellipsoid.Normal(p) : -ellipsoid.Normal(p),SurfaceMeshSupportKind.Sphere when patch.Support.Sphere is { } sphere => p =>{var exact = Direction3D.Create(p - sphere.Center).ToVector();diff --git a/Aetheris.Kernel.Core/Brep/Tessellation/SurfaceMeshObjExporter.cs b/Aetheris.Kernel.Core/Brep/Tessellation/SurfaceMeshObjExporter.csindex cd20939c..479a9ac6 100644--- a/Aetheris.Kernel.Core/Brep/Tessellation/SurfaceMeshObjExporter.cs+++ b/Aetheris.Kernel.Core/Brep/Tessellation/SurfaceMeshObjExporter.cs@@ -94,6 +94,7 @@ public static class SurfaceMeshObjExporterSurfaceMeshSupportKind.Plane when patch.Support.Plane is { } plane => ((point - plane.Origin).Dot(plane.UAxis.ToVector()), (point - plane.Origin).Dot(plane.VAxis.ToVector())),SurfaceMeshSupportKind.Cylinder when patch.Support.Cylinder is { } cylinder => PolarUv(point - cylinder.Origin, cylinder.Axis.ToVector(), cylinder.XAxis.ToVector(), cylinder.YAxis.ToVector()),SurfaceMeshSupportKind.Cone when patch.Support.Cone is { } cone => ConeUv(cone, point),+ SurfaceMeshSupportKind.Ellipsoid when patch.Support.Ellipsoid is { } ellipsoid => EllipsoidUv(ellipsoid, point),SurfaceMeshSupportKind.Sphere when patch.Support.Sphere is { } sphere => SphereUv(sphere, point),SurfaceMeshSupportKind.Torus when patch.Support.Torus is { } torus => TorusUv(torus, point),SurfaceMeshSupportKind.BoundedParametricPatch when patch.Support.BoundedPatch is { } bounded && bounded.TryProject(point, out var u, out var v) => (u, v),@@ -107,6 +108,7 @@ public static class SurfaceMeshObjExporterSurfaceMeshSupportKind.Plane when patch.Support.Plane is { } plane => plane.Normal.ToVector(),SurfaceMeshSupportKind.Cylinder when patch.Support.Cylinder is { } cylinder => cylinder.Normal(PolarUv(point - cylinder.Origin, cylinder.Axis.ToVector(), cylinder.XAxis.ToVector(), cylinder.YAxis.ToVector()).U).ToVector(),SurfaceMeshSupportKind.Cone when patch.Support.Cone is { } cone => cone.Normal(ConeUv(cone, point).U).ToVector(),+ SurfaceMeshSupportKind.Ellipsoid when patch.Support.Ellipsoid is { } ellipsoid => ellipsoid.Normal(point),SurfaceMeshSupportKind.Sphere when patch.Support.Sphere is { } sphere => Direction3D.Create(point - sphere.Center).ToVector(),SurfaceMeshSupportKind.Torus when patch.Support.Torus is { } torus => torus.Normal(TorusUv(torus, point).U, TorusUv(torus, point).V).ToVector(),SurfaceMeshSupportKind.BoundedParametricPatch when patch.Support.BoundedPatch is { } bounded && bounded.Evaluate(uv.U, uv.V).TryNormal(out var evaluated) => evaluated,@@ -115,6 +117,12 @@ public static class SurfaceMeshObjExporterreturn patch.IsAlignedWithSupport ? normal : -normal;}+ private static (double U, double V) EllipsoidUv(Geometry.Surfaces.EllipsoidSurface ellipsoid, Point3D point)+ {+ var q = ellipsoid.UnitCoordinates(point);+ return (double.Atan2(q.Y, q.X), double.Atan2(q.Z, double.Sqrt(q.X * q.X + q.Y * q.Y)));+ }+private static (double U, double V) PolarUv(Vector3D offset, Vector3D axis, Vector3D xAxis, Vector3D yAxis)=> (double.Atan2(offset.Dot(yAxis), offset.Dot(xAxis)), offset.Dot(axis));diff --git a/Aetheris.Kernel.Core/Geometry/SurfaceGeometry.cs b/Aetheris.Kernel.Core/Geometry/SurfaceGeometry.csindex 8c32b71c..74aac539 100644--- a/Aetheris.Kernel.Core/Geometry/SurfaceGeometry.cs+++ b/Aetheris.Kernel.Core/Geometry/SurfaceGeometry.cs@@ -12,6 +12,7 @@ public enum SurfaceGeometryKindLinearExtrusion,SurfaceOfRevolution,BSplineSurfaceWithKnots,+ Ellipsoid,}/// <summary>@@ -59,6 +60,10 @@ public sealed record SurfaceGeometrypublic BSplineSurfaceWithKnots? BSplineSurfaceWithKnots { get; }+ public EllipsoidSurface? Ellipsoid { get; private init; }++ public static SurfaceGeometry FromEllipsoid(EllipsoidSurface surface) => new(SurfaceGeometryKind.Ellipsoid, null, null, null, null, null, null, null, null) { Ellipsoid = surface };+public SplineRecoveryProvenance? RecoveryProvenance { get; private init; }public static SurfaceGeometry FromPlane(PlaneSurface plane) => new(SurfaceGeometryKind.Plane, plane, null, null, null, null, null, null, null);diff --git a/Aetheris.Kernel.Core/Geometry/Surfaces/EllipsoidSurface.cs b/Aetheris.Kernel.Core/Geometry/Surfaces/EllipsoidSurface.csnew file mode 100644index 00000000..4a60aef1--- /dev/null+++ b/Aetheris.Kernel.Core/Geometry/Surfaces/EllipsoidSurface.cs@@ -0,0 +1,71 @@+using Aetheris.Kernel.Core.Math;++namespace Aetheris.Kernel.Core.Geometry.Surfaces;++/// <summary>+/// Native exact ellipsoid octant. Longitude is [0, pi/2], latitude is [0, pi/2]+/// or [-pi/2, 0]. STEP projects this quadric to an exact rational patch; the+/// rational net is an interchange representation, never the native authority.+/// </summary>+public sealed record EllipsoidSurface(Point3D Center, Direction3D Axis, Direction3D XAxis,+ double RadiusX, double RadiusY, double RadiusZ, bool Northern)+{+ public Direction3D YAxis => Direction3D.Create(Axis.ToVector().Cross(XAxis.ToVector()));+ public Point3D Evaluate(double u, double v) => Center+ + XAxis.ToVector() * (RadiusX * double.Cos(u) * double.Cos(v))+ + YAxis.ToVector() * (RadiusY * double.Sin(u) * double.Cos(v))+ + Axis.ToVector() * (RadiusZ * double.Sin(v));+ public Vector3D UnitCoordinates(Point3D point)+ {+ var p = point - Center;+ return new(p.Dot(XAxis.ToVector()) / RadiusX, p.Dot(YAxis.ToVector()) / RadiusY, p.Dot(Axis.ToVector()) / RadiusZ);+ }+ public Point3D FromUnit(Point3D p) => Center + XAxis.ToVector() * (p.X * RadiusX)+ + YAxis.ToVector() * (p.Y * RadiusY) + Axis.ToVector() * (p.Z * RadiusZ);+ public Vector3D Normal(Point3D p)+ {+ var q = UnitCoordinates(p);+ var gradient = new Vector3D(q.X / RadiusX, q.Y / RadiusY, q.Z / RadiusZ);+ var scale = double.Max(double.Abs(gradient.X), double.Max(double.Abs(gradient.Y), double.Abs(gradient.Z)));+ return Direction3D.Create(XAxis.ToVector() * (gradient.X / scale)+ + YAxis.ToVector() * (gradient.Y / scale) + Axis.ToVector() * (gradient.Z / scale)).ToVector();+ }++ public BSplineSurfaceWithKnots ToStepPatch()+ {+ (double X, double Y)[] u = [(1, 0), (1, 1), (0, 1)];+ (double R, double Z)[] v = Northern ? [(1, 0), (1, 1), (0, 1)] : [(0, -1), (1, -1), (1, 0)];+ var net = u.Select(p => (IReadOnlyList<Point3D>)v.Select(q => FromUnit(new(p.X * q.R, p.Y * q.R, q.Z))).ToArray()).ToArray();+ var w = double.Sqrt(0.5);+ var weights = Enumerable.Range(0, 3).Select(j => (IReadOnlyList<double>)Enumerable.Range(0, 3).Select(k => (j == 1 ? w : 1) * (k == 1 ? w : 1)).ToArray()).ToArray();+ return new(2, 2, net, "UNSPECIFIED", false, false, false, [3, 3], [3, 3], [0, 1], [0, 1], "UNSPECIFIED", weights);+ }++ /// <summary>Recognize only the exact canonical octant control net and weights, not a nearby freeform fit.</summary>+ public static bool TryRecover(BSplineSurfaceWithKnots s, out EllipsoidSurface surface)+ {+ surface = null!;+ if (s.DegreeU != 2 || s.DegreeV != 2 || s.ControlPoints.Count != 3 || s.ControlPoints[0].Count != 3+ || s.Weights is null || !s.KnotMultiplicitiesU.SequenceEqual([3, 3]) || !s.KnotMultiplicitiesV.SequenceEqual([3, 3])+ || !s.KnotValuesU.SequenceEqual([0d, 1d]) || !s.KnotValuesV.SequenceEqual([0d, 1d]) || s.UClosed || s.VClosed || s.SelfIntersect) return false;+ var p = s.ControlPoints;+ var scale = (p[0][0] - p[2][2]).Length; var tolerance = double.Max(1e-10, scale * 1e-11);+ var north = (p[0][2] - p[2][2]).Length <= tolerance;+ var south = (p[0][0] - p[2][0]).Length <= tolerance;+ if (north == south) return false;+ var equator = north ? 0 : 2; var pole = north ? p[0][2] : p[0][0];+ var center = p[0][equator] + (p[2][equator] - p[1][equator]);+ var a = p[0][equator] - center; var b = p[2][equator] - center; var c = pole - center;+ if (new[] { a.Length, b.Length, c.Length }.Any(r => !double.IsFinite(r) || r < 1e-7)) return false;+ var x = Direction3D.Create(a); var y = Direction3D.Create(b); var axis = Direction3D.Create(x.ToVector().Cross(y.ToVector()));+ if (double.Abs(x.ToVector().Dot(y.ToVector())) > 1e-11 || double.Abs(a.Dot(c) / (a.Length * c.Length)) > 1e-11+ || double.Abs(b.Dot(c) / (b.Length * c.Length)) > 1e-11 || (axis.ToVector().Dot(c) > 0) != north) return false;+ var candidate = new EllipsoidSurface(center, axis, x, a.Length, b.Length, c.Length, north);+ var expected = candidate.ToStepPatch();+ var weightScale = s.Weights[0][0];+ for (var i = 0; i < 3; i++) for (var j = 0; j < 3; j++)+ if ((p[i][j] - expected.ControlPoints[i][j]).Length > tolerance+ || double.Abs(s.Weights[i][j] / weightScale - expected.Weights![i][j]) > 1e-12) return false;+ surface = candidate; return true;+ }+}diff --git a/Aetheris.Kernel.Core/Step242/Step242BsplineSurfaceRecoveryLane.cs b/Aetheris.Kernel.Core/Step242/Step242BsplineSurfaceRecoveryLane.csindex f63c1d51..ec6f23ae 100644--- a/Aetheris.Kernel.Core/Step242/Step242BsplineSurfaceRecoveryLane.cs+++ b/Aetheris.Kernel.Core/Step242/Step242BsplineSurfaceRecoveryLane.cs@@ -27,6 +27,7 @@ internal static class Step242BsplineSurfaceRecoveryLaneprivate const string AnalyticConeCandidate = "analytic_cone";private const string AnalyticSphereCandidate = "analytic_sphere";private const string AnalyticTorusCandidate = "analytic_torus";+ private const string AnalyticEllipsoidCandidate = "analytic_ellipsoid_octant";private const string RejectCandidate = "reject";/// <summary>Samples taken along one candidate circular section.</summary>@@ -97,7 +98,8 @@ internal static class Step242BsplineSurfaceRecoveryLaneCandidate(AnalyticCylinderCandidate, context => context.Cylinder, 103d, 0),Candidate(AnalyticConeCandidate, context => context.Cone, 102d, 1),Candidate(AnalyticSphereCandidate, context => context.Sphere, 101d, 2),- Candidate(AnalyticTorusCandidate, context => context.Torus, 100d, 3)+ Candidate(AnalyticTorusCandidate, context => context.Torus, 100d, 3),+ Candidate(AnalyticEllipsoidCandidate, context => context.Ellipsoid, 99d, 4)];}@@ -126,7 +128,8 @@ internal static class Step242BsplineSurfaceRecoveryLaneSurfaceProbe Cylinder,SurfaceProbe Cone,SurfaceProbe Sphere,- SurfaceProbe Torus)+ SurfaceProbe Torus,+ SurfaceProbe Ellipsoid){public SurfaceProbe Select(string candidateName) => candidateName switch{@@ -134,6 +137,7 @@ internal static class Step242BsplineSurfaceRecoveryLaneAnalyticConeCandidate => Cone,AnalyticSphereCandidate => Sphere,AnalyticTorusCandidate => Torus,+ AnalyticEllipsoidCandidate => Ellipsoid,_ => SurfaceProbe.Rejected($"Unknown candidate '{candidateName}'.")};@@ -174,7 +178,10 @@ internal static class Step242BsplineSurfaceRecoveryLanetorus = Preferred(torus, ProbeTorus(surface, sections, model));}- return new RecoveryContext(cylinder, cone, sphere, torus);+ var ellipsoid = EllipsoidSurface.TryRecover(surface, out var recovered)+ ? new SurfaceProbe(SurfaceGeometry.FromEllipsoid(recovered), 0, "exact canonical rational ellipsoid octant control net and weights")+ : SurfaceProbe.Rejected("not an exact canonical ellipsoid octant");+ return new RecoveryContext(cylinder, cone, sphere, torus, ellipsoid);}}diff --git a/Aetheris.Kernel.Core/Step242/Step242ExportOptions.cs b/Aetheris.Kernel.Core/Step242/Step242ExportOptions.csindex b0235e5c..b4706f5d 100644--- a/Aetheris.Kernel.Core/Step242/Step242ExportOptions.cs+++ b/Aetheris.Kernel.Core/Step242/Step242ExportOptions.cs@@ -38,7 +38,9 @@ public sealed class Step242ExportOptionspublic BrepExportPreflightMode BrepExportPreflightMode { get; init; } = BrepExportPreflightMode.Audit;/// <summary>- /// TrustedProductionRoute rejects rational B-spline supports and pcurves.+ /// TrustedProductionRoute rejects rational B-spline supports and pcurves in+ /// the native body. Native ellipsoid octants have exact rational STEP+ /// projection and recover to the same native quadric on import./// LegacyRoute retains interchange/debug compatibility, including rational evidence./// </summary>public BrepExportPreflightPolicy BrepExportPreflightPolicy { get; init; } = BrepExportPreflightPolicy.LegacyRoute;diff --git a/Aetheris.Kernel.Core/Step242/Step242Exporter.cs b/Aetheris.Kernel.Core/Step242/Step242Exporter.csindex 801c861e..ed42e347 100644--- a/Aetheris.Kernel.Core/Step242/Step242Exporter.cs+++ b/Aetheris.Kernel.Core/Step242/Step242Exporter.cs@@ -50,6 +50,10 @@ public static class Step242Exporter}}+ foreach (var binding in body.Bindings.PcurveBindings)+ if (body.TryGetFaceSurfaceGeometry(binding.FaceId, out var support) && support?.Ellipsoid is not null)+ return Failure("EllipsoidPcurveProjectionUnsupported: native angular pcurves must be remapped to the rational STEP patch domain before export. The ellipsoid primitive exports its exact 3D edge curves without pcurves.", $"Face:{binding.FaceId.Value}");+var preflight = options.BrepExportPreflightMode == BrepExportPreflightMode.Disabled? null: BrepExportPreflight.Validate(body, options.ImportedRecoveryToleranceMillimetres,@@ -803,6 +807,7 @@ public static class Step242ExporterSurfaceGeometryKind.Torus when surface.Torus is TorusSurface torus => KernelResult<string>.Success(BuildTorus(writer, torus)),SurfaceGeometryKind.LinearExtrusion when surface.LinearExtrusion is LinearExtrusionSurface linearExtrusion => BuildLinearExtrusionSurface(writer, linearExtrusion),SurfaceGeometryKind.SurfaceOfRevolution when surface.SurfaceOfRevolution is SurfaceOfRevolutionSurface surfaceOfRevolution => BuildSurfaceOfRevolutionSurface(writer, surfaceOfRevolution),+ SurfaceGeometryKind.Ellipsoid when surface.Ellipsoid is { } ellipsoid => KernelResult<string>.Success(BuildBSplineSurfaceWithKnots(writer, ellipsoid.ToStepPatch())),SurfaceGeometryKind.BSplineSurfaceWithKnots when surface.BSplineSurfaceWithKnots is BSplineSurfaceWithKnots bSplineSurface => KernelResult<string>.Success(BuildBSplineSurfaceWithKnots(writer, bSplineSurface)),_ => Failure($"Unsupported surface kind '{surface.Kind}'.", $"Face:{faceId.Value}")};diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentSemanticSchemaTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentSemanticSchemaTests.csindex 5242ef38..04a287bb 100644--- a/Aetheris.Kernel.Firmament.Tests/FirmamentSemanticSchemaTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentSemanticSchemaTests.cs@@ -11,9 +11,9 @@ public sealed class FirmamentSemanticSchemaTestsstring[] expectedNames =["Appearance", "FrameTransform", "Placement", "Pmi", "Note", "Provenance",- "Box", "Concept", "Points", "Door", "Drape", "Fabric", "FigureFit", "Fitting", "Garment",+ "Box", "Concept", "Points", "Door", "Drape", "Ellipsoid", "Fabric", "FigureFit", "Fitting", "Garment","Helix", "Hole", "Interface<Fixed>", "Interface<Prismatic>", "Interface<Revolute>",- "Interface<Stitch>", "Inventory", "Joint", "Loft", "Panel", "Perforation", "Material", "Linear", "Series", "Pose", "PoseTransition",+ "Interface<Stitch>", "Inventory", "Joint", "Loft", "Panel", "Perforation", "Material", "Linear", "Series", "Polyhedron", "Pose", "PoseTransition","Room", "Scene", "Camera", "Section", "Thread", "Window", "Follow", "WireRoute",];Assert.Equal(expectedNames, FirmamentSemanticSchemas.All.Select(schema => schema.Name));diff --git a/Aetheris.Kernel.Firmament.Tests/Integration/ConvexStockAuthoringTests.cs b/Aetheris.Kernel.Firmament.Tests/Integration/ConvexStockAuthoringTests.csnew file mode 100644index 00000000..b73363b4--- /dev/null+++ b/Aetheris.Kernel.Firmament.Tests/Integration/ConvexStockAuthoringTests.cs@@ -0,0 +1,60 @@+using Aetheris.Kernel.Firmament.FirmamentV2;++namespace Aetheris.Kernel.Firmament.Tests.Integration;++public sealed class ConvexStockAuthoringTests+{+ [Theory]+ [InlineData("Ellipsoid stock { radii: [18mm, 12mm, 25mm] }", "Ellipsoid stock { Radii: [18mm, 12mm, 25mm] }")]+ [InlineData("Polyhedron<12> stock { edgeLength: 20mm }", "Polyhedron<12> stock { EdgeLength: 20mm }")]+ public void CanonicalFieldsAndCompatibilitySpellingProduceIdenticalEngineeringGeometry(string preferred, string compatible)+ {+ var a = FirmamentBuildAndExport.CompileSource("Model Part { units: mm; " + preferred + " }");+ var b = FirmamentBuildAndExport.CompileSource("Model Part { Units: mm; " + compatible + " }");+ Assert.True(a.IsSuccess, string.Join("\n", a.Diagnostics)); Assert.True(b.IsSuccess, string.Join("\n", b.Diagnostics));+ Assert.Equal(a.Value.StepText, b.Value.StepText);+ }++ [Theory]+ [InlineData("Polyhedron<12> stock { edgeLength: dimension }", "Polyhedron<12> stock { edgeLength: 20mm }")]+ [InlineData("Ellipsoid stock { radii: [dimension, 12mm, 25mm] }", "Ellipsoid stock { radii: [20mm, 12mm, 25mm] }")]+ public void NewPrimitivesUseTheExistingCompileTimeValueBinder(string bound, string literal)+ {+ var a = FirmamentBuildAndExport.CompileSource("Model Part { units: mm; Static dimension: Length = 20mm; " + bound + " }");+ var b = FirmamentBuildAndExport.CompileSource("Model Part { units: mm; " + literal + " }");+ Assert.True(a.IsSuccess, string.Join("\n", a.Diagnostics)); Assert.True(b.IsSuccess, string.Join("\n", b.Diagnostics));+ Assert.Equal(a.Value.StepText, b.Value.StepText);+ }++ [Fact]+ public void RoundingKeepsItsFeatureIdentityAndUsesActualBrepDisplay()+ {+ const string source = "Model Die { units: mm; Box stock { size: [20mm, 20mm, 20mm] } Modify stock { EdgeFinish<Fillet> rounding { target: AllEdges; radius: 2mm } } }";+ var built = FirmamentBuildAndExport.CompileSource(source);+ Assert.True(built.IsSuccess, string.Join("\n", built.Diagnostics));+ Assert.Equal(26, built.Value.RuntimeBody!.Topology.Faces.Count());+ Assert.Equal("mesh", built.Value.Cir!.Qualification); Assert.Null(built.Value.Cir.RuntimeRoot);+ var feature = Assert.Single(built.Value.EngineeringFeatures!);+ Assert.Equal("edgefinish:rounding", feature.FeatureId); Assert.Equal("AllEdges", feature.Support); Assert.Equal(2, feature.Extent);+ Assert.NotNull(feature.SupportSpan);+ Assert.Equal(built.Value.StepText, FirmamentBuildAndExport.CompileSource(source).Value.StepText);+ }++ [Fact]+ public void PolyhedronFaceCountCanUseAnExistingTypedCompileTimeInteger()+ {+ var bound = FirmamentBuildAndExport.CompileSource("Model Die { units: mm; Static faces: Int = 12; Polyhedron<faces> stock { edgeLength: 20mm } }");+ var literal = FirmamentBuildAndExport.CompileSource("Model Die { units: mm; Polyhedron<12> stock { edgeLength: 20mm } }");+ Assert.True(bound.IsSuccess, string.Join("\n", bound.Diagnostics)); Assert.True(literal.IsSuccess);+ Assert.Equal(literal.Value.StepText, bound.Value.StepText);+ }++ [Theory]+ [InlineData("Ellipsoid stock { ra", "radii")]+ [InlineData("Polyhedron<12> stock { ed", "edgeLength")]+ public void CompletionUsesTheSharedPrimitiveSchema(string source, string expected)+ {+ var completion = FirmamentLanguageService.Complete(source, "memory", "1", source.Length);+ Assert.Contains(completion.Fields, f => FirmamentSourceSpelling.PreferredField(f.Name) == expected);+ }+}diff --git a/Aetheris.Kernel.Firmament/Assembly/FirmasmAssemblyExecutor.cs b/Aetheris.Kernel.Firmament/Assembly/FirmasmAssemblyExecutor.csindex 5466e3fd..88a7a84d 100644--- a/Aetheris.Kernel.Firmament/Assembly/FirmasmAssemblyExecutor.cs+++ b/Aetheris.Kernel.Firmament/Assembly/FirmasmAssemblyExecutor.cs@@ -179,6 +179,7 @@ public sealed class FirmasmAssemblyExecutortransform.Apply(surface.Sphere.Value.Axis, ToleranceContext.Default),surface.Sphere.Value.Radius,transform.Apply(surface.Sphere.Value.XAxis, ToleranceContext.Default))),+ SurfaceGeometryKind.Ellipsoid => SurfaceGeometry.FromEllipsoid(surface.Ellipsoid! with { Center = transform.Apply(surface.Ellipsoid.Center), Axis = transform.Apply(surface.Ellipsoid.Axis, ToleranceContext.Default), XAxis = transform.Apply(surface.Ellipsoid.XAxis, ToleranceContext.Default) }),SurfaceGeometryKind.Torus => SurfaceGeometry.FromTorus(new TorusSurface(transform.Apply(surface.Torus!.Value.Center),transform.Apply(surface.Torus.Value.Axis, ToleranceContext.Default),diff --git a/Aetheris.Kernel.Firmament/Execution/FirmamentPrimitiveExecutionTranslation.cs b/Aetheris.Kernel.Firmament/Execution/FirmamentPrimitiveExecutionTranslation.csindex f7fb57fc..715200fd 100644--- a/Aetheris.Kernel.Firmament/Execution/FirmamentPrimitiveExecutionTranslation.cs+++ b/Aetheris.Kernel.Firmament/Execution/FirmamentPrimitiveExecutionTranslation.cs@@ -20,6 +20,7 @@ internal static class FirmamentPrimitiveExecutionTranslation{CurveGeometryKind.Line3 => CurveGeometry.FromLine(new Line3Curve(curveEntry.Value.Line3!.Value.Origin + translation, curveEntry.Value.Line3.Value.Direction)),CurveGeometryKind.Circle3 => CurveGeometry.FromCircle(new Circle3Curve(curveEntry.Value.Circle3!.Value.Center + translation, curveEntry.Value.Circle3.Value.Normal, curveEntry.Value.Circle3.Value.Radius, curveEntry.Value.Circle3.Value.XAxis)),+ CurveGeometryKind.Ellipse3 => CurveGeometry.FromEllipse(new Ellipse3Curve(curveEntry.Value.Ellipse3!.Value.Center + translation, curveEntry.Value.Ellipse3.Value.Normal, curveEntry.Value.Ellipse3.Value.MajorRadius, curveEntry.Value.Ellipse3.Value.MinorRadius, curveEntry.Value.Ellipse3.Value.XAxis)),_ => curveEntry.Value});}@@ -33,6 +34,7 @@ internal static class FirmamentPrimitiveExecutionTranslationSurfaceGeometryKind.Cone => SurfaceGeometry.FromCone(new ConeSurface(surfaceEntry.Value.Cone!.Value.PlacementOrigin + translation, surfaceEntry.Value.Cone.Value.Axis, surfaceEntry.Value.Cone.Value.PlacementRadius, surfaceEntry.Value.Cone.Value.SemiAngleRadians, surfaceEntry.Value.Cone.Value.ReferenceAxis)),SurfaceGeometryKind.Torus => SurfaceGeometry.FromTorus(new TorusSurface(surfaceEntry.Value.Torus!.Value.Center + translation, surfaceEntry.Value.Torus.Value.Axis, surfaceEntry.Value.Torus.Value.MajorRadius, surfaceEntry.Value.Torus.Value.MinorRadius, surfaceEntry.Value.Torus.Value.XAxis)),SurfaceGeometryKind.Sphere => SurfaceGeometry.FromSphere(new SphereSurface(surfaceEntry.Value.Sphere!.Value.Center + translation, surfaceEntry.Value.Sphere.Value.Axis, surfaceEntry.Value.Sphere.Value.Radius, surfaceEntry.Value.Sphere.Value.XAxis)),+ SurfaceGeometryKind.Ellipsoid => SurfaceGeometry.FromEllipsoid(surfaceEntry.Value.Ellipsoid! with { Center = surfaceEntry.Value.Ellipsoid.Center + translation }),_ => surfaceEntry.Value});}diff --git a/Aetheris.Kernel.Firmament/Execution/FirmamentPrimitiveExecutor.cs b/Aetheris.Kernel.Firmament/Execution/FirmamentPrimitiveExecutor.csindex fb43eb94..cd5255b3 100644--- a/Aetheris.Kernel.Firmament/Execution/FirmamentPrimitiveExecutor.cs+++ b/Aetheris.Kernel.Firmament/Execution/FirmamentPrimitiveExecutor.cs@@ -54,7 +54,7 @@ internal static class FirmamentPrimitiveExecutorbooleanExecutionBodiesByFeatureId[primitive.FeatureId] = bodyResult.Value.LegacyForBoolean;featureGraphStates[primitive.FeatureId] = primitive.Kind switch{- FirmamentLoweredPrimitiveKind.Box => FirmamentSafeSubtractFeatureGraphState.BoxRoot,+ FirmamentLoweredPrimitiveKind.Box when primitive.Parameters is FirmamentLoweredBoxParameters { UniformFilletRadius: null } => FirmamentSafeSubtractFeatureGraphState.BoxRoot,FirmamentLoweredPrimitiveKind.Cylinder => FirmamentSafeSubtractFeatureGraphState.CylinderRoot,_ => FirmamentSafeSubtractFeatureGraphState.Other};@@ -634,6 +634,7 @@ internal static class FirmamentPrimitiveExecutorif (primitive.Kind == FirmamentLoweredPrimitiveKind.Box){var box = (FirmamentLoweredBoxParameters)primitive.Parameters;+ if (box.UniformFilletRadius is { } rounding) return ConvexStockPrimitives.CreateRoundedBox(box.SizeX, box.SizeY, box.SizeZ, rounding);return BrepPrimitives.CreateBoxWithTopology(box.SizeX, box.SizeY, box.SizeZ, out boxTopology);}return primitive.Kind switch@@ -641,6 +642,8 @@ internal static class FirmamentPrimitiveExecutorFirmamentLoweredPrimitiveKind.Cylinder => BrepPrimitives.CreateCylinder(((FirmamentLoweredCylinderParameters)primitive.Parameters).Radius, ((FirmamentLoweredCylinderParameters)primitive.Parameters).Height),FirmamentLoweredPrimitiveKind.Cone => ExecuteCone((FirmamentLoweredConeParameters)primitive.Parameters),FirmamentLoweredPrimitiveKind.Torus => BrepPrimitives.CreateTorus(((FirmamentLoweredTorusParameters)primitive.Parameters).MajorRadius, ((FirmamentLoweredTorusParameters)primitive.Parameters).MinorRadius),+ FirmamentLoweredPrimitiveKind.Ellipsoid => EllipsoidPrimitive.Create(((FirmamentLoweredEllipsoidParameters)primitive.Parameters).RadiusX, ((FirmamentLoweredEllipsoidParameters)primitive.Parameters).RadiusY, ((FirmamentLoweredEllipsoidParameters)primitive.Parameters).RadiusZ),+ FirmamentLoweredPrimitiveKind.Polyhedron => ConvexStockPrimitives.CreateRegular(((FirmamentLoweredPolyhedronParameters)primitive.Parameters).FaceCount, ((FirmamentLoweredPolyhedronParameters)primitive.Parameters).EdgeLength, ((FirmamentLoweredPolyhedronParameters)primitive.Parameters).UniformFilletRadius ?? 0),FirmamentLoweredPrimitiveKind.Sphere => BrepPrimitives.CreateSphere(((FirmamentLoweredSphereParameters)primitive.Parameters).Radius),FirmamentLoweredPrimitiveKind.TriangularPrism => BrepPrimitives.CreateTriangularPrism(((FirmamentLoweredTriangularPrismParameters)primitive.Parameters).BaseWidth,diff --git a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.csindex f6a33b61..feea6c89 100644--- a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs+++ b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs@@ -177,13 +177,14 @@ public static class FirmamentBuildAndExport"EdgeFinish",$"edgefinish:{finish.Name}",modification.TargetSolid,- finish.FaceAxis,- finish.Target,+ finish.Target == "AllEdges" ? "AllEdges" : finish.FaceAxis,+ finish.Target == "AllEdges" ? "" : finish.Target,finish.Distance,string.Equals(finish.Kind, "Fillet", StringComparison.Ordinal) ? "Radius" : "Distance","Remove",PolicySource: finish.Kind,- MaterializationRoute: "SemanticEdgeFinish")))+ MaterializationRoute: finish.Target == "AllEdges" ? "ConvexStockRollingBall" : "SemanticEdgeFinish",+ SupportSpan: finish.Target == "AllEdges" ? $"{finish.SourceSpan.Start}:{finish.SourceSpan.Length}" : null))).ToArray();var patterns = (parsed.Document.StaticAuthoring?.Patterns ?? []).Select(pattern => new FirmamentSemanticPatternReport(@@ -593,7 +594,9 @@ public static class FirmamentBuildAndExportvar execution = FirmamentPrimitiveExecutor.Execute(lowering.Value);if (!execution.IsSuccess){- return KernelResult<FirmamentStepExportResult>.Failure(execution.Diagnostics);+ var span = (v2Parse.Document.ModifyBlocks ?? []).SelectMany(m => m.EdgeFinishes ?? []).FirstOrDefault(f => f.Target == "AllEdges")?.SourceSpan ?? v2Parse.Document.Solid.SourceSpan;+ return KernelResult<FirmamentStepExportResult>.Failure(execution.Diagnostics.Select(d => d with+ { SourceSpan = span is { } location ? new(location.Start, location.Length) : d.SourceSpan }).ToArray());}var executedPrimitive = execution.Value.ExecutedPrimitives.LastOrDefault();@@ -1592,7 +1595,7 @@ public static class FirmamentBuildAndExportprivate static KernelResult<FirmamentStepExportResult>? TryExportV2AirChamferBody(FirmamentV2Document document){var finishes = (document.ModifyBlocks ?? []).SelectMany(m => (m.EdgeFinishes ?? []).Select(f => (Modify: m, Finish: f))).ToArray();- if (finishes.Length == 0) return null;+ if (finishes.Length == 0 || finishes.Any(f => f.Finish.Target == "AllEdges")) return null;// A narrow finish-only route never owns a document that also has semantic holes.// CombinedHoleEdgeFinish is the only X1 route permitted to claim that shape.if ((document.ModifyBlocks ?? []).Any(m => m.SemanticHoles.Count > 0)) return null;diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentLanguageService.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentLanguageService.csindex ddebeb49..c4ec4a49 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentLanguageService.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentLanguageService.cs@@ -56,6 +56,8 @@ public static class FirmamentLanguageService}else if (LoftAuthoringParser.TryGetAuthoringFields(source, offset, out fields)) context = "Loft";else if (IsInsideConstruct(source, offset, "Box")) { fields = FirmamentSchemaAuthoringFields.For("Box"); context = "Box"; }+ else if (IsInsideConstruct(source, offset, "Ellipsoid")) { fields = FirmamentSchemaAuthoringFields.For("Ellipsoid"); context = "Ellipsoid"; }+ else if (IsInsideConstruct(source, offset, "Polyhedron")) { fields = FirmamentSchemaAuthoringFields.For("Polyhedron"); context = "Polyhedron"; }else if (IsInsideConstruct(source, offset, "Hole")) { fields = FirmamentSchemaAuthoringFields.For("Hole"); context = "Hole"; }else{diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Ast.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Ast.csindex b97a5cf7..b8e4172f 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Ast.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Ast.cs@@ -78,6 +78,8 @@ public sealed record FirmamentV2BoxRecord(IReadOnlyList<double> Size, IReadOnlyLpublic 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 FirmamentV2EllipsoidRecord(IReadOnlyList<double> Radii) : FirmamentV2PrimitiveRecord;+public sealed record FirmamentV2PolyhedronRecord(int FaceCount, double EdgeLength) : FirmamentV2PrimitiveRecord;public sealed record FirmamentV2TorusRecord(double MajorRadius, double MinorRadius) : FirmamentV2PrimitiveRecord;/// <summary>Silhouette-defined rounded rectangle swept along +Z; CornerRadius is not an edge finish.</summary>public sealed record FirmamentV2RoundedBoxRecord(IReadOnlyList<double> Size, double CornerRadius) : FirmamentV2PrimitiveRecord;diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2BuildLowering.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2BuildLowering.csindex b6017805..a86b40a3 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2BuildLowering.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2BuildLowering.cs@@ -15,13 +15,16 @@ internal static class FirmamentV2BuildLowering{ArgumentNullException.ThrowIfNull(document);- if (document.ModifyBlocks is { Count: > 0 })+ if (UniformStockFilletAdmission.Error(document.Solids, document.ModifyBlocks ?? [],+ document.Threads is { Count: > 0 } || document.Replacements is { Count: > 0 }) is { } admissionError) return Failure(admissionError);+ var rounding = (document.ModifyBlocks ?? []).SelectMany(m => m.EdgeFinishes ?? []).SingleOrDefault(f => f.Target == "AllEdges");+ if (document.ModifyBlocks is { Count: > 0 } && rounding is null){return Failure("Firmament V2 build/export currently admits only a single primitive solid with no modify blocks.");}var solid = document.Solid;- var primitive = ToLoweredPrimitive(solid);+ var primitive = ToLoweredPrimitive(solid, rounding?.Distance);if (primitive is null){return Failure($"Firmament V2 build/export does not admit primitive record '{solid.RecordType}'.");@@ -30,14 +33,16 @@ internal static class FirmamentV2BuildLoweringreturn KernelResult<FirmamentPrimitiveLoweringPlan>.Success(new FirmamentPrimitiveLoweringPlan([primitive], [], []));}- private static FirmamentLoweredPrimitive? ToLoweredPrimitive(FirmamentV2SolidBinding solid)+ private static FirmamentLoweredPrimitive? ToLoweredPrimitive(FirmamentV2SolidBinding solid, double? rounding){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])),+ FirmamentV2BoxRecord box when box.Size.Count == 3 => (FirmamentLoweredPrimitiveKind.Box, (FirmamentLoweredPrimitiveParameters)new FirmamentLoweredBoxParameters(box.Size[0], box.Size[1], box.Size[2]) { UniformFilletRadius = rounding }),FirmamentV2CylinderRecord cylinder => (FirmamentLoweredPrimitiveKind.Cylinder, new FirmamentLoweredCylinderParameters(cylinder.Radius, cylinder.Height)),FirmamentV2FrustumRecord frustum => (FirmamentLoweredPrimitiveKind.Cone, new FirmamentLoweredConeParameters(frustum.BottomRadius, frustum.TopRadius, frustum.Height)),FirmamentV2ConeRecord cone => (FirmamentLoweredPrimitiveKind.Cone, new FirmamentLoweredConeParameters(cone.BottomRadius, cone.TopRadius, cone.Height)),+ FirmamentV2EllipsoidRecord ellipsoid => (FirmamentLoweredPrimitiveKind.Ellipsoid, new FirmamentLoweredEllipsoidParameters(ellipsoid.Radii[0], ellipsoid.Radii[1], ellipsoid.Radii[2])),+ FirmamentV2PolyhedronRecord polyhedron => (FirmamentLoweredPrimitiveKind.Polyhedron, new FirmamentLoweredPolyhedronParameters(polyhedron.FaceCount, polyhedron.EdgeLength, rounding)),FirmamentV2SphereRecord sphere => (FirmamentLoweredPrimitiveKind.Sphere, new FirmamentLoweredSphereParameters(sphere.Radius)),FirmamentV2TorusRecord torus => (FirmamentLoweredPrimitiveKind.Torus, new FirmamentLoweredTorusParameters(torus.MajorRadius, torus.MinorRadius)),_ => defaultdiff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2MechanicalBinding.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2MechanicalBinding.csindex 0f686bfb..64686893 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2MechanicalBinding.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2MechanicalBinding.cs@@ -17,7 +17,7 @@ public static partial class FirmamentV2Parser}internal static bool IsPrimitiveDeclaration(DeclarationSyntax d) => d.Type.Name.Text is- "Box" or "Cylinder" or "Cone" or "Sphere" or "Torus" or "RoundedBox" or "Frustum" or "StandardPart" or "ExactCoaxialPart";+ "Box" or "Cylinder" or "Cone" or "Sphere" or "Ellipsoid" or "Polyhedron" or "Torus" or "RoundedBox" or "Frustum" or "StandardPart" or "ExactCoaxialPart";private static FirmamentV2ParseResult? RejectMultipleMaterialBodies(IReadOnlyList<DeclarationSyntax> bodies,string model, List<string> diagnostics)@@ -73,6 +73,18 @@ public static partial class FirmamentV2Parser.Any(d => d.Type.Name.Text == "Hole" && d.Body?.Statements.OfType<FieldSyntax>().Any(f => FirmamentSyntaxFields.SameField(f.Name.Text, "From")|| FirmamentSyntaxFields.SameField(f.Name.Text, "Center") && f.Value is IndexSyntax) == true);var constructionConsumer = materialConstruction || semanticStock || primitives.Any(d => d.Body?.Statements.OfType<FieldSyntax>().Any(f => FirmamentSyntaxFields.SameField(f.Name.Text, "Bounds")) == true);+ var wholeStockFinish = declarations.Where(d => d.Type.Name.Text == "Modify")+ .SelectMany(d => d.Body?.Statements.OfType<DeclarationSyntax>() ?? [])+ .FirstOrDefault(d => d.Type.Name.Text == "EdgeFinish" && d.Body?.Statements.OfType<FieldSyntax>()+ .Any(f => FirmamentSyntaxFields.SameField(f.Name.Text, "Target") && FirmamentSyntaxValues.Reference(f.Value) == "AllEdges") == true);+ if (constructionConsumer && wholeStockFinish is not null)+ {+ diagnostics.Add(UniformStockFilletAdmission.Code);+ return CanonicalFailure(diagnostics, CanonicalDocumentMalformed) with+ { SyntaxDiagnostics = [new(UniformStockFilletAdmission.Code, "fatal",+ "target: AllEdges currently requires direct size-based Box or regular Polyhedron stock. Profile, Pattern and semantic Bounds construction adapters do not yet admit whole-stock rounding; arbitrary-body rounding is unsupported.")+ { SourceSpan = wholeStockFinish.Span, Stage = "Capability" }] };+ }if (constructions.Length > 1 && constructions.All(d => d.Type.Name.Text == "Extrude") && primitives.Length == 0)return BindMechanicalExtrusionStack(model, constructions, source, diagnostics);if (constructions.Length > 1 || materialConstruction && primitives.Length > 0)@@ -102,14 +114,34 @@ public static partial class FirmamentV2Parserdiagnostics.AddRange(pathDiagnostics);}var solids = new Dictionary<string, FirmamentV2SolidBinding>(StringComparer.Ordinal);+ var fieldDiagnostics = new List<FirmamentV2ValidationDiagnostic>();+ void CaptureFieldDiagnostics(DeclarationSyntax declaration, int start)+ {+ for (var index = start; index < diagnostics.Count; index++)+ {+ var diagnostic = diagnostics[index];+ var parts = diagnostic.Split(": ", 2, StringSplitOptions.None);+ var adapted = FirmamentInterop.FirmamentV2DiagnosticAdapter.FromParserDiagnosticCode(diagnostic);+ var fieldName = parts[0].Split(':')[^1];+ var field = declaration.Body?.Statements.OfType<FieldSyntax>().FirstOrDefault(f => FirmamentSyntaxFields.SameField(f.Name.Text, fieldName));+ // Keep the stable code separate from its explanatory text. Both+ // presentation and preflight consume this same owner-located error.+ diagnostics[index] = parts[0];+ fieldDiagnostics.Add(new(parts[0], adapted.Severity.ToString().ToLowerInvariant(), parts.Length == 2 ? parts[1] : adapted.Message,+ FieldName: field?.Name.Text, Target: declaration.Name?.Text)+ { SourceSpan = field?.Name.Span ?? declaration.Span, Stage = "Binding" });+ }+ }foreach (var declaration in primitives){var fields = new FirmamentSyntaxFields(declaration, diagnostics);+ var diagnosticStart = diagnostics.Count;var primitive = BindMechanicalPrimitive(fields, diagnostics);FirmamentV2HollowIntent? hollow = null;- if (declaration.Type.Arguments.Count > 0)+ if (declaration.Type.Arguments.Count > 0 && declaration.Type.Name.Text != "Polyhedron")hollow = BindMechanicalHollow(fields, primitive, diagnostics);fields.Complete();+ CaptureFieldDiagnostics(declaration, diagnosticStart);if (primitive is null) { diagnostics.Add(CanonicalPrimitiveMalformed); continue; }if (declaration.Name is null || !solids.TryAdd(declaration.Name.Text, new(declaration.Name.Text,declaration.Type.Name.Text, primitive, ConstructionPolicy: hollow is null ? FirmamentV2ConstructionPolicy.Solid : FirmamentV2ConstructionPolicy.Hollow, Hollow: hollow, SourceSpan: declaration.Span, AuthoredFields: fields.AuthoredFields))) diagnostics.Add(DuplicateName);@@ -135,6 +167,7 @@ public static partial class FirmamentV2Parser{if (statement is not DeclarationSyntax feature) { diagnostics.Add(CanonicalModifyMalformed); continue; }var fields = new FirmamentSyntaxFields(feature, diagnostics);+ var diagnosticStart = diagnostics.Count;switch (feature.Type.Name.Text){case "Hole":@@ -149,6 +182,7 @@ public static partial class FirmamentV2Parserdefault: diagnostics.Add($"{CanonicalDeclarationUnknown}:Modify:{feature.Type.Name.Text}"); break;}fields.Complete();+ CaptureFieldDiagnostics(feature, diagnosticStart);}if (holes.Count > 0 && solid.Box is null) diagnostics.Add(ModifyTargetNotSolid);if (solid.ConstructionPolicy == FirmamentV2ConstructionPolicy.Hollow &&@@ -157,6 +191,14 @@ public static partial class FirmamentV2Parserdiagnostics.Add("firmament-v2-hollow-modify-unsupported");modifies.Add(new(solid.Name, [], holes, finishes, perforations));}+ if (UniformStockFilletAdmission.Error(solids.Values.ToArray(), modifies,+ declarations.Any(d => d.Type.Name.Text is "Thread" or "Replace")) is { } stockError)+ {+ var operation = modifies.SelectMany(m => m.EdgeFinishes ?? []).First(f => f.Target == "AllEdges");+ diagnostics.Add(UniformStockFilletAdmission.Code);+ return CanonicalFailure(diagnostics, CanonicalDocumentMalformed) with+ { SyntaxDiagnostics = [new(UniformStockFilletAdmission.Code, "fatal", stockError) { SourceSpan = operation.SourceSpan, Stage = "Capability" }] };+ }var bodyText = source.Substring(model.Body.Span.Start + 1, model.Body.Span.Length - 2);var recognized = ParseCanonicalRecognizedRegions(bodyText, solids, diagnostics);var replacements = ParseCanonicalReplacements(bodyText, solids, recognized, diagnostics);@@ -164,7 +206,7 @@ public static partial class FirmamentV2ParserValidateCanonicalSelectionSources(bodyText, selections, [], diagnostics);var (pmi, pmiBlock, boundPmi) = ParsePmi(source, solids, modifies, recognized, staticValues.Values, [], diagnostics);var pmiDiagnostics = ValidateStaticPmi(pmiBlock, boundPmi, modifies, staticValues.Values, diagnostics);- var locatedDiagnostics = (compileTime?.Diagnostics ?? []).Concat(staticValues.Diagnostics).Concat(pmiDiagnostics).ToArray();+ var locatedDiagnostics = (compileTime?.Diagnostics ?? []).Concat(staticValues.Diagnostics).Concat(pmiDiagnostics).Concat(fieldDiagnostics).ToArray();if (diagnostics.Any(IsFatalDiagnosticCode)) return CanonicalFailure(diagnostics, CanonicalDocumentMalformed)with { SyntaxDiagnostics = locatedDiagnostics };return FirmamentV2ParseResult.Success(new(model.Name!.Text, "mm", solids.Values.ToArray(), modifies,@@ -269,6 +311,21 @@ public static partial class FirmamentV2Parservar bottom = Length("BottomRadius"); var top = Length("TopRadius"); var coneHeight = Length("Height");return bottom > 0 && top >= 0 && coneHeight > 0 ? new FirmamentV2ConeRecord(bottom, top, coneHeight) : null;case "Sphere": var sphere = Length("Radius"); return sphere > 0 ? new FirmamentV2SphereRecord(sphere) : null;+ case "Ellipsoid":+ if (!f.Vector("Radii", "mm", out var radii) || radii.Length != 3 || radii.Any(r => !double.IsFinite(r) || r <= 0))+ { diagnostics.Add("firmament-v2-ellipsoid-radii-invalid: radii requires three finite positive X/Y/Z semiaxes in length units."); return null; }+ return new FirmamentV2EllipsoidRecord(radii);+ case "Polyhedron":+ var arguments = f.Declaration.Type.Arguments;+ var edgeLength = Length("EdgeLength");+ if (arguments.Count != 1 || arguments[0].Name is not null || arguments[0].Default is not null+ || !FirmamentSyntaxValues.TryMeasure(arguments[0].Value, "", out var faceCount)+ || faceCount != double.Truncate(faceCount) || faceCount < 0 || faceCount > int.MaxValue+ || !Aetheris.Kernel.Core.Brep.ConvexStockPrimitives.IsRegularFaceCount((int)faceCount))+ { diagnostics.Add("firmament-v2-polyhedron-face-count-unsupported: Polyhedron<N> uses a regular convex face count: 4, 6, 8, 12 or 20. Other dice families require a separate construction."); return null; }+ if (!double.IsFinite(edgeLength) || edgeLength <= 0)+ { diagnostics.Add("firmament-v2-polyhedron-edge-length-invalid: edgeLength must be a finite positive length."); return null; }+ return new FirmamentV2PolyhedronRecord((int)faceCount, edgeLength);case "Torus":var major = Length("MajorRadius"); var minor = Length("MinorRadius");return major > minor && minor > 0 ? new FirmamentV2TorusRecord(major, minor) : null;@@ -361,7 +418,9 @@ public static partial class FirmamentV2Parservar arguments = fields.Declaration.Type.Arguments;var generic = arguments.Count == 1 && arguments[0].Name is null && arguments[0].Default is null? FirmamentSyntaxValues.Reference(arguments[0].Value) : null;- var alias = fields.Word("Kind");+ var aliasExpression = fields.Take("Kind");+ var alias = FirmamentSyntaxValues.Reference(aliasExpression);+ if (aliasExpression is not null && alias is null) { fields.Invalid("Kind"); return null; }if (arguments.Count > 0 && generic is not ("Chamfer" or "Fillet") || generic is not null && alias is not null && generic != alias){ diagnostics.Add("firmament-v2-edgefinish-variant-conflict: Use EdgeFinish<Chamfer> or EdgeFinish<Fillet>; Kind, if supplied, must agree."); return null; }return generic ?? alias;@@ -431,14 +490,16 @@ public static partial class FirmamentV2Parserprivate static FirmamentV2EdgeFinishDecl? BindMechanicalFinish(FirmamentSyntaxFields f, List<string> diagnostics){var kind = MechanicalFinishKind(f, diagnostics);- var axis = f.Word("Face"); var target = f.Word("Target");+ var face = f.Take("Face"); var axis = FirmamentSyntaxValues.Reference(face); var target = f.Word("Target");var distance = f.Take("Distance"); var radius = f.Take("Radius");- if ((distance is not null && radius is not null) || f.Declaration.Name is null || axis is null || target is null || kind is null+ if (face is not null && (axis is null || target == "AllEdges")) { f.Invalid("Face"); return null; }+ if (target == "AllEdges" && kind == "Fillet" && radius is null) { f.Invalid("Radius"); return null; }+ if ((distance is not null && radius is not null) || f.Declaration.Name is null || axis is null && target != "AllEdges" || target is null || kind is null|| !FirmamentSyntaxValues.TryMeasure(distance ?? radius, "mm", out var value)){ diagnostics.Add(CanonicalModifyMalformed); return null; }// The selected feature admission owner diagnoses nonpositive distances and// radii with its existing capability-specific explanation during preflight.- return new(f.Declaration.Name.Text, axis, target, kind, value, f.Declaration.Span);+ return new(f.Declaration.Name.Text, axis ?? "", target, kind, value, f.Declaration.Span);}private static FirmamentV2PerforationDecl? BindMechanicalPerforation(FirmamentSyntaxFields f, List<string> diagnostics)@@ -508,7 +569,7 @@ public static partial class FirmamentV2Parsercase "Struct" when declaration.Annotation is not null: break;case "Struct" when !declaration.Modifiers.Any(m => m.Name.Text == "Concept"):BindMechanicalScope(declaration.Body?.Statements ?? [], diagnostics); break;- case "Box" or "Cylinder" or "Cone" or "Sphere" or "Torus" or "RoundedBox" or "Frustum" or "StandardPart" or "ExactCoaxialPart":+ case "Box" or "Cylinder" or "Cone" or "Sphere" or "Ellipsoid" or "Polyhedron" or "Torus" or "RoundedBox" or "Frustum" or "StandardPart" or "ExactCoaxialPart":case "Plane" or "Axis" or "Axis2" or "Point2" or "Line2" or "CubicBezier2" or "Rect2" or "Square2" or "Triangle2" or "Polygon2" or "RegularPolygon2" or "Circle2" or "Ellipse2" or "Ellipse2Guide" or "Slot2" or "RoundedRect2" or "SmoothRoundedRect2" or "Path":case "Plateau" or "Concept" or "Struct" or "Profile" or "Span" or "Compose" or "Boss" or "Pocket" or "AddOffset" or "RemoveOffset" or "EdgeFinish" or "Extrude":case "Enum" or "Expose" or "Record" or "Template" or "template" or "Feature" or "Pattern" or "ProfileDelta" or "Selection" or "InlineStep" or "Recognize" or "Replace" or "Pmi" or "Modify" or "Match" or "Require" or "Assert" or "Thread":diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2StaticValues.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2StaticValues.csindex 4e9f9857..3b2c4c51 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2StaticValues.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2StaticValues.cs@@ -141,7 +141,14 @@ public static partial class FirmamentV2Parser{// These names belong to their semantic owners, not scalar lookup.DeclarationSyntax { Type.Name.Text: "Static" or "Pmi" or "Concept" or "Feature" or "Template" } => s,- DeclarationSyntax d when d.Modifiers.Count == 0 => d with { Body = d.Body is null ? null : d.Body with { Statements = d.Body.Statements.Select(Project).ToArray() } },+ DeclarationSyntax d when d.Modifiers.Count == 0 => d with+ {+ // Polyhedron's sole generic is a compile-time numeric face count;+ // type/variant names in other owners must never become scalar lookups.+ Type = d.Type.Name.Text == "Polyhedron" ? d.Type with+ { Arguments = d.Type.Arguments.Select(a => a with { Value = Nominal(a.Value) }).ToArray() } : d.Type,+ Body = d.Body is null ? null : d.Body with { Statements = d.Body.Statements.Select(Project).ToArray() }+ },FieldSyntax f => f with { Value = Nominal(f.Value) },_ => s};diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/SemanticConstructDeclarations.cs b/Aetheris.Kernel.Firmament/FirmamentV2/SemanticConstructDeclarations.csindex c6e592c5..596d4e38 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/SemanticConstructDeclarations.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/SemanticConstructDeclarations.cs@@ -6,6 +6,14 @@ namespace Aetheris.Kernel.Firmament.FirmamentV2;[FirmamentField("Bounds", "Bounds", FirmamentSchemaValueKind.Box3, Description = "A semantic Box3 bound instead of Size.")]public static class BoxSemanticDeclaration { }+[FirmamentConstruct("Ellipsoid", "Ellipsoid", Context = "Model or Struct", Entry = "Ellipsoid Body { radii: [18mm, 12mm, 25mm] }", Description = "Exact centered ellipsoid; radii are local X/Y/Z semiaxes.")]+[FirmamentField("Radii", "Radii", FirmamentSchemaValueKind.Vector, Unit = FirmamentUnitKind.Length, Required = true, Description = "Three positive X/Y/Z semiaxes, not diameters.")]+public static class EllipsoidSemanticDeclaration { }++[FirmamentConstruct("Polyhedron", "Polyhedron", Context = "Model or Struct", Entry = "Polyhedron<12> Body { edgeLength: 12mm }", Description = "Regular convex solid with 4, 6, 8, 12 or 20 faces, centered on its origin.")]+[FirmamentField("EdgeLength", "EdgeLength", FirmamentSchemaValueKind.Length, Unit = FirmamentUnitKind.Length, Required = true, Description = "Length of each original straight edge.")]+public static class PolyhedronSemanticDeclaration { }+[FirmamentConstruct("Hole", "Hole", Context = "Modify body", Entry = "Modify Body { Hole<Shaft> H { On: +Z; Center: Point2(0mm, 0mm); Diameter: 6mm; End: ThroughAll } }", Description = "Semantic drilled hole.")][FirmamentField("On", "On", FirmamentSchemaValueKind.FaceSelector, Required = true, Description = "Entry face of the hole.")][FirmamentField("Center", "Center", FirmamentSchemaValueKind.Point, Required = true, Description = "Center in the support face.")]diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/UniformStockFilletAdmission.cs b/Aetheris.Kernel.Firmament/FirmamentV2/UniformStockFilletAdmission.csnew file mode 100644index 00000000..a03ed058--- /dev/null+++ b/Aetheris.Kernel.Firmament/FirmamentV2/UniformStockFilletAdmission.cs@@ -0,0 +1,24 @@+namespace Aetheris.Kernel.Firmament.FirmamentV2;++/// <summary>Shared AST admission for one whole-stock finish. No arbitrary-body promise.</summary>+internal static class UniformStockFilletAdmission+{+ internal const string Code = "firmament-v2-uniform-stock-fillet-unsupported";+ internal static string? Error(IReadOnlyList<FirmamentV2SolidBinding> solids, IReadOnlyList<FirmamentV2ModifyBlock> modifies, bool hasOtherEdits = false)+ {+ var finishes = modifies.SelectMany(m => m.EdgeFinishes ?? []).ToArray();+ if (!finishes.Any(f => f.Target == "AllEdges")) return null;+ if (solids.Count != 1 || solids[0].Primitive is not (FirmamentV2BoxRecord or FirmamentV2PolyhedronRecord)+ || solids[0].ConstructionPolicy != FirmamentV2ConstructionPolicy.Solid)+ return "target: AllEdges currently admits only an untouched Box or regular Polyhedron<4|6|8|12|20>. Rounding all edges on arbitrary bodies, imported bodies, RoundedBox or hollow stock is unsupported. Use an admitted local EdgeFinish selection where available.";+ if (hasOtherEdits || modifies.Count != 1 || modifies[0].TargetSolid != solids[0].Name || finishes.Length != 1+ || modifies[0].Regions.Count != 0 || modifies[0].SemanticHoles.Count != 0 || modifies[0].Perforations is { Count: > 0 })+ return "target: AllEdges requires one finish on untouched stock. Combining whole-stock rounding with holes, other finishes or body edits is currently unsupported.";+ var finish = finishes[0];+ if (finish.Kind != "Fillet" || finish.FaceAxis.Length != 0)+ return "target: AllEdges uses EdgeFinish<Fillet> with radius and no face selector. Whole-stock chamfer is not currently admitted.";+ if (!double.IsFinite(finish.Distance) || finish.Distance <= 0)+ return "target: AllEdges requires a finite positive fillet radius.";+ return null;+ }+}diff --git a/Aetheris.Kernel.Firmament/Lowering/FirmamentCirLowerer.cs b/Aetheris.Kernel.Firmament/Lowering/FirmamentCirLowerer.csindex b046fd25..4159c573 100644--- a/Aetheris.Kernel.Firmament/Lowering/FirmamentCirLowerer.cs+++ b/Aetheris.Kernel.Firmament/Lowering/FirmamentCirLowerer.cs@@ -120,7 +120,7 @@ internal static class FirmamentCirLowererprivate static SdfNode? LowerPrimitive(FirmamentLoweredPrimitive primitive, List<CirLoweringDiagnostic> diagnostics) => primitive switch{- { Kind: FirmamentLoweredPrimitiveKind.Box, Parameters: FirmamentLoweredBoxParameters box } => new SdfBoxNode(box.SizeX, box.SizeY, box.SizeZ),+ { Kind: FirmamentLoweredPrimitiveKind.Box, Parameters: FirmamentLoweredBoxParameters { UniformFilletRadius: null } box } => new SdfBoxNode(box.SizeX, box.SizeY, box.SizeZ),{ Kind: FirmamentLoweredPrimitiveKind.Cylinder, Parameters: FirmamentLoweredCylinderParameters cylinder } => new SdfCylinderNode(cylinder.Radius, cylinder.Height),{ Kind: FirmamentLoweredPrimitiveKind.Sphere, Parameters: FirmamentLoweredSphereParameters sphere } => new SdfSphereNode(sphere.Radius),{ Kind: FirmamentLoweredPrimitiveKind.Torus, Parameters: FirmamentLoweredTorusParameters torus } => new SdfTorusNode(torus.MajorRadius, torus.MinorRadius),diff --git a/Aetheris.Kernel.Firmament/Lowering/FirmamentPrimitiveLoweringPlan.cs b/Aetheris.Kernel.Firmament/Lowering/FirmamentPrimitiveLoweringPlan.csindex 60a85da9..c6d1c2c8 100644--- a/Aetheris.Kernel.Firmament/Lowering/FirmamentPrimitiveLoweringPlan.cs+++ b/Aetheris.Kernel.Firmament/Lowering/FirmamentPrimitiveLoweringPlan.cs@@ -60,13 +60,18 @@ public enum FirmamentLoweredPrimitiveKindStraightSlot,RoundedCornerBox,SlotCut,- LibraryPart+ LibraryPart,+ Ellipsoid,+ Polyhedron}public abstract record FirmamentLoweredPrimitiveParameters;public sealed record FirmamentLoweredBoxParameters(double SizeX, double SizeY, double SizeZ)- : FirmamentLoweredPrimitiveParameters;+ : FirmamentLoweredPrimitiveParameters+{+ public double? UniformFilletRadius { get; init; }+}public sealed record FirmamentLoweredCylinderParameters(double Radius, double Height): FirmamentLoweredPrimitiveParameters;@@ -77,6 +82,10 @@ public sealed record FirmamentLoweredConeParameters(double BottomRadius, doublepublic sealed record FirmamentLoweredTorusParameters(double MajorRadius, double MinorRadius): FirmamentLoweredPrimitiveParameters;+public sealed record FirmamentLoweredEllipsoidParameters(double RadiusX, double RadiusY, double RadiusZ) : FirmamentLoweredPrimitiveParameters;++public sealed record FirmamentLoweredPolyhedronParameters(int FaceCount, double EdgeLength, double? UniformFilletRadius = null) : FirmamentLoweredPrimitiveParameters;+public sealed record FirmamentLoweredSphereParameters(double Radius): FirmamentLoweredPrimitiveParameters;diff --git a/docs/development/FIRMAMENT-CONVEX-STOCK-2026-10-18.md b/docs/development/FIRMAMENT-CONVEX-STOCK-2026-10-18.mdnew file mode 100644index 00000000..1f2c5140--- /dev/null+++ b/docs/development/FIRMAMENT-CONVEX-STOCK-2026-10-18.md@@ -0,0 +1,74 @@+# Firmament convex stock and exact ellipsoid qualification++Date: 2026-10-18. Outcome: **Success within the stated primitive and stock-fillet boundaries.**++## Implemented surface++- `Polyhedron<N>`: regular convex face counts 4, 6, 8, 12 and 20, with positive `edgeLength`. Numeric compile-time expressions and bound Static integer values use the existing value binder. Stock is centered on its origin.+- `Ellipsoid`: positive X/Y/Z semiaxes in `radii`. Stock is centered on its origin. An asymmetric egg is a separate construction.+- `EdgeFinish<Fillet>` with `target: AllEdges` and `radius`: one operation on untouched direct size-based Box or regular Polyhedron stock. No face selector. Box keeps its bottom-on-XY frame.++See the executable sources under `fixtures/Regression/ConvexStock/` and the updated public syntax guide.++## Geometry ownership++The existing mechanical AST binder, primitive lowering records and executor own admission/execution. There is no new source parser, whole-document dispatch route or source rewrite. Shared admission checks refuse arbitrary-body rounding and mixed edits before a stock-only lowerer can discard them.++`ConvexStockPrimitives` builds the five known regular vertex sets and their deterministic outward convex face lattices. For radius r, it offsets each stock plane inward by r and constructs the boundary of that inner polytope plus a radius-r ball: retained planar supports, cylindrical edge rolls and spherical vertex patches. All seams share topology and exact curve geometry. This is a deterministic construction, not a competition among blend strategies; it does not need a Judgment selector. Radius must be below the stock inradius so topology does not collapse. Original planar support planes remain; a rounded polyhedron's vertex extrema can recede. Box outer dimensions stay unchanged.++`EllipsoidSurface` is a native exact quadric octant. Eight patches share exact ellipse meridians/equator edges. STEP projects each patch to an exact rational quadratic net. The existing Judgment surface-recovery lane gains a bounded ellipsoid candidate: it verifies the canonical net, orthogonal axes and rational weights rather than fitting a nearby freeform surface. Native rational geometry policy is unchanged. An isotropic patch may recover to the simpler exact Sphere support.++SurfaceMeshIR retains shared edge sample identities and evaluates bounded convex spherical/ellipsoidal interiors on their native supports. Rounded Box cannot reuse the sharp Box CIR mirror; it projects the actual BRep. The legacy display path also handles the new native ellipsoid through the existing spherical trim owner under an affine pullback.++## STEP entity review requested during qualification++The STEP Tools AP242 EXPRESS definitions include an exact [`ellipsoid`](https://www.steptools.com/docs/stp_aim/html/t_ellipsoid.html), positioned by an axis frame and three positive semiaxes. It is included in [`csg_primitive`](https://www.steptools.com/docs/stp_aim/html/t_csg_primitive.html), so the user's observation is correct.++It is not a BRep face surface: [`advanced_face_geometry_select`](https://www.steptools.com/docs/stp_aim/html/t_advanced_face_geometry_select.html) admits B-spline, elementary and swept surfaces; [`elementary_surface`](https://www.steptools.com/docs/stp_aim/html/t_elementary_surface.html) does not include an ellipsoid. A `surface_replica` is also outside that advanced-face select. Therefore the CSG entity cannot simply replace the surface reference of the current `MANIFOLD_SOLID_BREP` export.++Decision: retain exact rational quadratic patch projection for the current BRep/PMI interchange path. This is an exact representation, not a fitted polynomial approximation. Direct `ELLIPSOID` output requires a deliberately qualified CSG representation and corresponding import/product/consumer support. This pass does not silently replace an editable BRep artifact with a CSG-only artifact or add an unrequested parallel export route.++## Admission and diagnostics++Unknown fields, non-length dimensions, unsupported regular face counts, nonpositive dimensions, excessive radii, malformed selectors and invalid variant values reject. The mechanical owner captures spans for primitive and Modify-field errors, separates explanatory text from stable codes and preserves severity. Validate and build share compilation admission; no alternate validator was added.++Whole-stock rounding on Cylinder, Ellipsoid, RoundedBox, imported/hollow bodies, profile construction, semantic Bounds/Pattern construction adapters and bodies with other edits is unsupported. Combined holes, repeated finishes, threading/replacement edits and all-edge chamfer reject. Existing local finish routes remain available under their existing limits.++Ellipsoid angular pcurves require a STEP-domain remapping before export. The primitive emits exact 3D edge curves without pcurves; an ellipsoid face carrying native angular pcurves rejects export rather than attaching them to incompatible rational patch coordinates. General ellipsoid face editing and pcurve succession are outside this primitive pass.++## Compatibility and code quality++Canonical constructs use PascalCase and fields use camelCase. Existing title-case field aliases remain admitted. Existing RoundedBox still means its original rounded silhouette and rim behavior. Existing enum values and the three-argument lowered Box record constructor/deconstruction are retained. Numeric generic substitution is restricted to the numeric Polyhedron owner; other generic variant/type names do not become scalar references.++No new regex, global diagnostic allowlist, mutable parser state, background service or product-side validator was introduced. New schemas use the existing generated metadata owner; completion projects those schemas.++## Qualification evidence++Generated commands, reports, STEP/OBJ files and logs are kept under ignored `artifacts/local/convex-stock/`.++| Gate | Result |+| --- | --- |+| Full Release solution build, serial, shared compilation disabled | Passed; 0 errors, 30 existing warnings |+| Focused CLI admission/export checks | 24 passed |+| Focused authoring, schema and original-token diagnostic spans | 31 passed |+| Fast Core lane (`Category!=SlowCorpus`) | 1,087 passed |+| Full solution lane, including slow interchange corpus and editable V8 | 5,629 passed, 0 failed, 0 skipped; 20 test assemblies |+| Previously qualified current domain STEP artifacts | 30/30 byte-identical SHA-256 |+| Historical domain frontend witnesses | 37/37 matched: 35 accepted STEP artifacts byte-identical and 2 expected rejections |+| Complete canonical corpus | 296 owner operations, 69 consumed modules and 4 explicit external-body boundaries; all 369 records qualified |+| FrontendX4 authoring/geometry corpus | 32/32 passed against the existing references and recorded geometry |+| SheetMetalSyntax | 26/26 passed; formed STEP / flat parity retained |+| SheetMetalSemantics | 29/29 passed |+| Prior exact-face / box-cage / sphere-cage compatibility | Validate, inspect and exact STEP or STL/GLB export witnesses passed |+| New stock fixtures through the real CLI | 12/12 validate, inspect, STEP build, STEP reimport analysis and OBJ export passed; all enclosed-manifold, connected, watertight and outward-oriented |+| Final repository/resource checks | `git diff --check` passed; no remaining .NET/testhost/MSBuild/VBCSCompiler/CLI hosts |++The new 43 regression cases exercise actual topology, exact curve/surface support, shared seams, manifold winding, preflight, STEP reimport, display mesh closure/orientation, volume controls, deterministic feature identity, static-value binding and validate/build rejection agreement. Exact geometry checks do not depend on matching diagnostic sentences. The generated semantic schema expected list is extended for the two new public constructs.++The asymmetric ellipsoid reimports with bounds `[-18,-12,-25]` to `[18,12,25]` mm, 8 faces, 12 ellipse edges and 6 vertices. The rounded 20mm Box retains `[-10,-10,0]` to `[10,10,20]` mm and has 6 planar faces, 12 cylindrical rolls and 8 spherical corners. `new-stock-summary.json` records the topology, bounds, integrity results and deterministic mesh hashes of all 12 specimens.++The exact commands were the serial Release solution build (`--no-restore -m:1 -nr:false -p:UseSharedCompilation=false`), the required fast and full test lanes, `scripts/qualify-firmament-domain-frontend.ps1`, `scripts/Test-CanonicalFixtures.ps1 -NoBuild`, and the existing FrontendX4/SheetMetalSyntax/SheetMetalSemantics runners without `--record`. The ignored `qualify-corpus.ps1` driver and log files preserve the CLI commands and final results. Existing fixtures, geometry references and recorded expectations were not rewritten.++## Verdict++The motivating die stock and oval stock now compile through the unified admission path to exact native BRep geometry. Whole-stock fillets construct all edge and corner patches together within the explicit Box/regular-Polyhedron boundary. Invalid or unsupported intent rejects through validate and build rather than being omitted. Existing full regressions, canonical authoring and sampled byte-for-byte geometry controls pass. This does not qualify general arbitrary-body blending, CSG interchange, general ellipsoid editing or interactive Helios behavior.diff --git a/docs/development/FIRMAMENT-LANGUAGE-DECISIONS-2026-10.md b/docs/development/FIRMAMENT-LANGUAGE-DECISIONS-2026-10.mdindex 0efad37f..215117da 100644--- a/docs/development/FIRMAMENT-LANGUAGE-DECISIONS-2026-10.md+++ b/docs/development/FIRMAMENT-LANGUAGE-DECISIONS-2026-10.md@@ -464,3 +464,16 @@ the remaining imported-product/PMI projection prerequisite.| `MeshState` | Explicit box/sphere cage conversion and finite Catmull-Clark editing under the existing Sculpting AST owner. One operation per successor, stable parent-derived handles and protected vertices. || Output and precision | Mesh successors are STL/GLB artifacts, never implicit STEP. Validation reports `MeshBuilt` and unavailable STEP output. `maximumDeviation` bounds conversion and inherited output quantization; deformations remain explicit. || Future boundaries | Arbitrary BRep retopology, new cage constructors, full PMI/import metadata succession, global mesh self-intersection proof and interactive editing remain separate qualification work. No silent fallback or implied X2 closure. |++## Exact convex-stock primitive follow-up (2026-10-18)++| Decision | Disposition |+| --- | --- |+| `Polyhedron<N>` | N is the compile-time face count of a regular convex solid: 4, 6, 8, 12 or 20. Positive `edgeLength` supplies its size. Other face counts do not imply a unique regular construction and reject. |+| `Ellipsoid` | Three positive `radii` are local X/Y/Z semiaxes. The native authority is an exact ellipsoid quadric split into eight octants. Rational patches are an exact STEP projection and recover to native quadrics through the existing Judgment recovery owner. An asymmetric egg is a separate construction. |+| Whole-stock rounding | Reuse `EdgeFinish<Fillet>` with `target: AllEdges`, no face selector and a positive radius. Admit one operation on untouched direct size-based Box or regular Polyhedron stock. Realize all cylindrical rolls and spherical corners together from the inward-offset convex lattice. |+| Geometry meaning | Box stock retains its frame and outer dimensions. Polyhedra retain original support planes; vertex extrema can recede under rounding. Radius stays below the inradius, leaving planar faces and straight spans. Existing RoundedBox silhouette geometry is unchanged. |+| Capability boundary | Arbitrary-body all-edge blends, mixed edits, hollow stock, all-edge chamfer and semantic Bounds/Pattern construction adapters reject. General blending remains separate work. No implicit mesh conversion. |+| Presentation and interchange | Rounded Box must not reuse a sharp Box CIR mirror. Use its actual BRep mesh. Native ellipsoid angular pcurves require explicit STEP-domain remapping before export; the primitive emits exact 3D edge curves without pcurves. General ellipsoid editing/pcurve succession remains outside this pass. |++The STEP entity review confirmed that [`ELLIPSOID`](https://www.steptools.com/docs/stp_aim/html/t_ellipsoid.html) exists as a CSG primitive, while [`advanced_face_geometry_select`](https://www.steptools.com/docs/stp_aim/html/t_advanced_face_geometry_select.html) does not admit it as a BRep face surface. Direct CSG interchange needs separate qualification; this pass retains exact patch projection for BRep exchange. See [the qualification report](FIRMAMENT-CONVEX-STOCK-2026-10-18.md#step-entity-review-requested-during-qualification).diff --git a/docs/public/firmament/geometry.md b/docs/public/firmament/geometry.mdindex 33d71dbf..48d9eda5 100644--- a/docs/public/firmament/geometry.md+++ b/docs/public/firmament/geometry.md@@ -1,5 +1,15 @@# Geometry and semantic features+For exact regular solids, ellipsoids and the bounded whole-stock fillet, see+[regular polyhedra and ellipsoids in the syntax guide](syntax.md#regular-polyhedra-ellipsoids-and-whole-stock-rounding).+`target: AllEdges` currently applies only to untouched size-based Box and regular+Polyhedron stock. It does not admit rounding all edges of an arbitrary body.++Ellipsoid BRep export uses exact rational quadratic patches and reimports them as+native exact quadrics. STEP also defines an [`ELLIPSOID` CSG primitive](https://www.steptools.com/docs/stp_aim/html/t_ellipsoid.html);+that entity is outside the [BRep face-surface select](https://www.steptools.com/docs/stp_aim/html/t_advanced_face_geometry_select.html).+The current exporter retains the BRep artifact contract.+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/syntax.md b/docs/public/firmament/syntax.mdindex fb050e73..0a286a62 100644--- a/docs/public/firmament/syntax.md+++ b/docs/public/firmament/syntax.md@@ -577,6 +577,60 @@ as Extrude. For a circular span and full material consumer, see the completeSee [geometry](geometry.md), [spans](spans.md), [Concept derivation](concept-derivation.md)and [boundary edits](profile-boundary-edits.md) for detailed construction forms.+## Regular polyhedra, ellipsoids and whole-stock rounding++`Polyhedron<N>` constructs a **regular convex solid**. `N` is its face count,+not its number of vertices or the side count of a prism. The admitted values+are 4 (tetrahedron), 6 (cube), 8 (octahedron), 12 (dodecahedron) and 20+(icosahedron). Required `edgeLength` sizes every original edge. Other counts+reject: a ten-sided die needs a different construction family.++`Ellipsoid` uses required `radii: [x, y, z]`: three positive local semiaxes,+not full diameters. It is an exact native quadric, with exact rational patch+projection for STEP interchange and native recovery on reimport. It is symmetric;+an asymmetric egg still needs a separate construction or explicit mesh sculpt.++Both new primitives are centered on their local origin. The regular solids use+a deterministic coordinate orientation; Polyhedron<6> has axis-aligned faces,+Polyhedron<8> has axis-aligned vertices. Box retains its existing bottom-on-XY+stock frame. Place modular Parts through Assembly frames and mates.++**Complete examples:**++```firmament+Model RoundedDie {+ units: mm+ Polyhedron<12> stock { edgeLength: 20mm }+ Modify stock {+ EdgeFinish<Fillet> rounding { target: AllEdges; radius: 1mm }+ }+}+```++```firmament+Model Oval {+ units: mm+ Ellipsoid stock { radii: [18mm, 12mm, 25mm] }+}+```++`target: AllEdges` currently admits **only an untouched Box or one of these+regular Polyhedron stocks** (direct `size` / `edgeLength` construction, including+bound compile-time values), with one `EdgeFinish<Fillet>`, a positive `radius`+and no `face` selector. All edge blends and spherical corner patches are built+together. Rounding removes material while retaining the original planar support+planes; for a Box its outer dimensions stay unchanged. Radius must remain+strictly below the stock inradius so planar faces and straight edge spans remain.++Whole-stock rounding on arbitrary bodies, Ellipsoid, imported bodies, hollow+stock, RoundedBox, profile extrusions or bodies with holes/other edits is currently+unsupported. Combining this operation with other edits, repeating it or requesting+an all-edge chamfer rejects explicitly. This is a bounded convex-stock capability,+not a promise of general BRep blending. Existing `RoundedBox` continues to mean a+rounded rectangular silhouette extruded with its existing rim behavior.+The semantic `bounds` and Pattern construction adapters do not yet admit this+whole-stock finish; they reject instead of dropping it.+## Adding and removing material`Modify` targets an existing body. `Compose` creates a profile-based body with adiff --git a/docs/public/reference/diagnostics.md b/docs/public/reference/diagnostics.mdindex 102ca161..c2baff4c 100644--- a/docs/public/reference/diagnostics.md+++ b/docs/public/reference/diagnostics.md@@ -118,6 +118,10 @@ Common recovery patterns:| unknown keyword/Template | spelling, `Use` declaration, and qualified Template name || missing Template argument | the Template's typed parameter list or Forge `describe` output || unit mismatch | use the required dimension (`mm`, `deg`, `N`) rather than a bare/wrong-dimension value |+| `firmament-v2-polyhedron-face-count-unsupported` | `Polyhedron<N>` requires a compile-time regular convex face count: 4, 6, 8, 12 or 20; N is not the side count of a prism. |+| `firmament-v2-ellipsoid-radii-invalid` | Supply three finite positive X/Y/Z semiaxes with length units in `radii`. |+| `firmament-v2-uniform-stock-fillet-unsupported` | Use one `EdgeFinish<Fillet>` with `target: AllEdges`, positive `radius` and no face selector on untouched direct Box or regular Polyhedron stock. Arbitrary bodies, hollow stock, other edits and construction adapters are outside this capability. |+| `UniformFilletRadiusTooLarge` | Reduce the radius below the reported stock inradius; this construction requires positive remaining planar faces and edge spans. || unknown material | one of the four exact catalog references in the materials guide || unresolved PMI target | named hole/face selector exists in the same semantic domain || invalid tolerance | `PlusMinus(plus, minus)` uses Length values for a diameter |diff --git a/docs/public/reference/supported-features.md b/docs/public/reference/supported-features.mdindex 9b72db1e..ece7a832 100644--- a/docs/public/reference/supported-features.md+++ b/docs/public/reference/supported-features.md@@ -4,7 +4,8 @@| Area | Status | Preview 3 boundary ||---|---|---|-| Firmament V2 native primitives/profiles | Bounded | Named Box/Cylinder/Frustum/RoundedBox and admitted line/arc profile construction/composition |+| Firmament V2 native primitives/profiles | Bounded | Named Box/Cylinder/Frustum/RoundedBox, exact Ellipsoid, regular Polyhedron<4/6/8/12/20>, and admitted line/arc profile construction/composition |+| Uniform stock fillet | Bounded | `EdgeFinish<Fillet> { target: AllEdges; radius: ... }` on untouched Box or regular Polyhedron stock; all edge/corner patches together. Arbitrary bodies and mixed edits reject. || Profile rim fillet/chamfer | Bounded ordinary CAD | Top/bottom rims of convex polygons (including non-right-angle corners), admitted tangent line/arc loops, and circular segments formed by one arc and chord. Source-bound Judgment selects qualified construction; shared analytic-support intersections, certified finite fillet miter curves and exact quadratic chamfer miters. Collapsed caps and unqualified sharp curved junction families reject. See [fillets and chamfers](../firmament/fillet-profiles.md). || Box top-boundary finish with holes | Bounded | One complete +Z Boundary Chamfer or constant-radius Fillet with disjoint ThroughAll shaft/counterbore holes; exact cylindrical fillets and elliptical corner seams. Intersecting holes/finish bands, other combined selectors and general feature chains remain unsupported. See [geometry](../firmament/geometry.md#box-top-fillet-with-holes). || Gear Standard Library | Supported / bounded by family | Supported external/internal standard involute spur gears; bounded straight bevel/miter and ratchet/pawl; typed `Interface<Gear>` compatibility and ideal ratios; deterministic manifold AP242. No contact, dynamics, ratings, helical/worm, spiral-bevel, or qualified hub/keyway geometry. See the [gear guide](../firmament/gears.md). |diff --git a/fixtures/Regression/ConvexStock/README.md b/fixtures/Regression/ConvexStock/README.mdnew file mode 100644index 00000000..ca2c03ff--- /dev/null+++ b/fixtures/Regression/ConvexStock/README.md@@ -0,0 +1,12 @@+# Convex stock and exact ellipsoid regression specimens++The five `polyhedron-N` sources declare regular convex stock with N faces and+20mm edges. Their `-rounded` partners apply a 1mm whole-stock fillet. `box-rounded`+is a 20mm cube rounded with a 2mm radius. `ellipsoid` has 18/12/25mm semiaxes.++The Core and CLI ConvexStock tests cover actual topology, exact STEP export and+reimport, full face display, mesh closure/orientation, and validate/build agreement.+Invalid mutations are tested separately without rewriting these accepted sources.++`AllEdges` applies only to untouched Box and the five regular Polyhedron stocks.+It does not admit arbitrary-body blending or silently ignore other operations.diff --git a/fixtures/Regression/ConvexStock/box-rounded.firmament b/fixtures/Regression/ConvexStock/box-rounded.firmamentnew file mode 100644index 00000000..73c1a8a0--- /dev/null+++ b/fixtures/Regression/ConvexStock/box-rounded.firmament@@ -0,0 +1,7 @@+Model Die {+ units: mm+ Box stock { size: [20mm, 20mm, 20mm] }+ Modify stock {+ EdgeFinish<Fillet> rounding { target: AllEdges; radius: 2mm }+ }+}diff --git a/fixtures/Regression/ConvexStock/ellipsoid.firmament b/fixtures/Regression/ConvexStock/ellipsoid.firmamentnew file mode 100644index 00000000..9421543d--- /dev/null+++ b/fixtures/Regression/ConvexStock/ellipsoid.firmament@@ -0,0 +1,4 @@+Model Oval {+ units: mm+ Ellipsoid stock { radii: [18mm, 12mm, 25mm] }+}diff --git a/fixtures/Regression/ConvexStock/polyhedron-12-rounded.firmament b/fixtures/Regression/ConvexStock/polyhedron-12-rounded.firmamentnew file mode 100644index 00000000..ef5b2b59--- /dev/null+++ b/fixtures/Regression/ConvexStock/polyhedron-12-rounded.firmament@@ -0,0 +1,5 @@+Model Die12 {+ units: mm+ Polyhedron<12> stock { edgeLength: 20mm }+ Modify stock { EdgeFinish<Fillet> rounding { target: AllEdges; radius: 1mm } }+}diff --git a/fixtures/Regression/ConvexStock/polyhedron-12.firmament b/fixtures/Regression/ConvexStock/polyhedron-12.firmamentnew file mode 100644index 00000000..2055dc6f--- /dev/null+++ b/fixtures/Regression/ConvexStock/polyhedron-12.firmament@@ -0,0 +1,4 @@+Model Die12 {+ units: mm+ Polyhedron<12> stock { edgeLength: 20mm }+}diff --git a/fixtures/Regression/ConvexStock/polyhedron-20-rounded.firmament b/fixtures/Regression/ConvexStock/polyhedron-20-rounded.firmamentnew file mode 100644index 00000000..03708999--- /dev/null+++ b/fixtures/Regression/ConvexStock/polyhedron-20-rounded.firmament@@ -0,0 +1,5 @@+Model Die20 {+ units: mm+ Polyhedron<20> stock { edgeLength: 20mm }+ Modify stock { EdgeFinish<Fillet> rounding { target: AllEdges; radius: 1mm } }+}diff --git a/fixtures/Regression/ConvexStock/polyhedron-20.firmament b/fixtures/Regression/ConvexStock/polyhedron-20.firmamentnew file mode 100644index 00000000..f8ee42af--- /dev/null+++ b/fixtures/Regression/ConvexStock/polyhedron-20.firmament@@ -0,0 +1,4 @@+Model Die20 {+ units: mm+ Polyhedron<20> stock { edgeLength: 20mm }+}diff --git a/fixtures/Regression/ConvexStock/polyhedron-4-rounded.firmament b/fixtures/Regression/ConvexStock/polyhedron-4-rounded.firmamentnew file mode 100644index 00000000..5da5452c--- /dev/null+++ b/fixtures/Regression/ConvexStock/polyhedron-4-rounded.firmament@@ -0,0 +1,5 @@+Model Die4 {+ units: mm+ Polyhedron<4> stock { edgeLength: 20mm }+ Modify stock { EdgeFinish<Fillet> rounding { target: AllEdges; radius: 1mm } }+}diff --git a/fixtures/Regression/ConvexStock/polyhedron-4.firmament b/fixtures/Regression/ConvexStock/polyhedron-4.firmamentnew file mode 100644index 00000000..09caa56c--- /dev/null+++ b/fixtures/Regression/ConvexStock/polyhedron-4.firmament@@ -0,0 +1,4 @@+Model Die4 {+ units: mm+ Polyhedron<4> stock { edgeLength: 20mm }+}diff --git a/fixtures/Regression/ConvexStock/polyhedron-6-rounded.firmament b/fixtures/Regression/ConvexStock/polyhedron-6-rounded.firmamentnew file mode 100644index 00000000..532f2459--- /dev/null+++ b/fixtures/Regression/ConvexStock/polyhedron-6-rounded.firmament@@ -0,0 +1,5 @@+Model Die6 {+ units: mm+ Polyhedron<6> stock { edgeLength: 20mm }+ Modify stock { EdgeFinish<Fillet> rounding { target: AllEdges; radius: 1mm } }+}diff --git a/fixtures/Regression/ConvexStock/polyhedron-6.firmament b/fixtures/Regression/ConvexStock/polyhedron-6.firmamentnew file mode 100644index 00000000..52d16a06--- /dev/null+++ b/fixtures/Regression/ConvexStock/polyhedron-6.firmament@@ -0,0 +1,4 @@+Model Die6 {+ units: mm+ Polyhedron<6> stock { edgeLength: 20mm }+}diff --git a/fixtures/Regression/ConvexStock/polyhedron-8-rounded.firmament b/fixtures/Regression/ConvexStock/polyhedron-8-rounded.firmamentnew file mode 100644index 00000000..939f131e--- /dev/null+++ b/fixtures/Regression/ConvexStock/polyhedron-8-rounded.firmament@@ -0,0 +1,5 @@+Model Die8 {+ units: mm+ Polyhedron<8> stock { edgeLength: 20mm }+ Modify stock { EdgeFinish<Fillet> rounding { target: AllEdges; radius: 1mm } }+}diff --git a/fixtures/Regression/ConvexStock/polyhedron-8.firmament b/fixtures/Regression/ConvexStock/polyhedron-8.firmamentnew file mode 100644index 00000000..76a9c4f6--- /dev/null+++ b/fixtures/Regression/ConvexStock/polyhedron-8.firmament@@ -0,0 +1,4 @@+Model Die8 {+ units: mm+ Polyhedron<8> stock { edgeLength: 20mm }+}