Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Uniform rounding stage 3: tangent junctions and mixed corners
Claudeef9e0b2325c4
diff --git a/Aetheris.CLI.Tests/ConvexStockCliTests.cs b/Aetheris.CLI.Tests/ConvexStockCliTests.csindex 9186a4d3..567a90b2 100644--- a/Aetheris.CLI.Tests/ConvexStockCliTests.cs+++ b/Aetheris.CLI.Tests/ConvexStockCliTests.cs@@ -16,7 +16,9 @@ public sealed class ConvexStockCliTests{ "../UniformRounding/box-hole-rounded", 29 }, { "../UniformRounding/d-profile-rounded", 14 },// Concave edges too.{ "../UniformRounding/bushing-rounded", 12 }, { "../UniformRounding/counterbore-rounded", 33 },- { "../UniformRounding/blind-hole-rounded", 30 }+ { "../UniformRounding/blind-hole-rounded", 30 },+ // Tangent junctions, and a corner where a concave edge meets convex ones.+ { "../UniformRounding/rounded-rect-rounded", 26 }, { "../UniformRounding/ell-rounded", 38 }};[Theory]diff --git a/Aetheris.Kernel.Core/Brep/Blends/LocalRounding.cs b/Aetheris.Kernel.Core/Brep/Blends/LocalRounding.csindex e1fa1dea..62ddb00b 100644--- a/Aetheris.Kernel.Core/Brep/Blends/LocalRounding.cs+++ b/Aetheris.Kernel.Core/Brep/Blends/LocalRounding.cs@@ -54,6 +54,16 @@ internal static class LocalRoundingvar c = Surface.Cylinder!.Value; var a = c.Axis.ToVector(); var q = x - c.Origin; var h = q.Dot(a);return c.Origin + a * h + Radial(q, a, c.XAxis.ToVector()) * c.Radius;}+ case SurfaceGeometryKind.Sphere:+ {+ var c = Surface.Sphere!.Value; var q = x - c.Center;+ return c.Center + (q.Length > 1e-14 ? q * (c.Radius / q.Length) : c.XAxis.ToVector() * c.Radius);+ }+ case SurfaceGeometryKind.Torus:+ {+ var t = Surface.Torus!.Value; var tube = Tube(t, x); var q = x - tube;+ return tube + (q.Length > 1e-14 ? q * (t.MinorRadius / q.Length) : t.Axis.ToVector() * t.MinorRadius);+ }default:{var k = Surface.Cone!.Value; var a = k.Axis.ToVector(); var q = x - k.Apex; var h = q.Dot(a);@@ -76,6 +86,8 @@ internal static class LocalRoundingvar c = Surface.Cylinder!.Value;n = Radial(x - c.Origin, c.Axis.ToVector(), c.XAxis.ToVector()); break;}+ case SurfaceGeometryKind.Sphere: n = Unit(Foot(x) - Surface.Sphere!.Value.Center); break;+ case SurfaceGeometryKind.Torus: n = Unit(Foot(x) - Tube(Surface.Torus!.Value, x)); break;default:{var k = Surface.Cone!.Value; var a = k.Axis.ToVector();@@ -89,6 +101,13 @@ internal static class LocalRounding/// <summary>Signed distance to the surface, positive on the material side.</summary>public double Inside(Point3D x) { var f = Foot(x); return -Outward(x).Dot(x - f); }+ /// <summary>The nearest point of the torus's tube circle.</summary>+ private static Point3D Tube(TorusSurface t, Point3D x)+ {+ var a = t.Axis.ToVector(); var r = Radial(x - t.Center, a, t.XAxis.ToVector());+ return t.Center + r * t.MajorRadius;+ }+private static Vector3D Radial(Vector3D q, Vector3D axis, Vector3D fallback){var r = q - axis * q.Dot(axis);@@ -109,25 +128,55 @@ internal static class LocalRoundingArc ? Enumerable.Range(0, arcSegments + 1).Select(i => At(i / (double)arcSegments)) : [Start, End];}- /// <summary>A sharp edge to round: its two faces (A uses it forward), its shape, and what it is built from.</summary>+ /// <summary>Which edges a pass rounds: every sharp edge, or only the concave ones (the first pass where convex+ /// and concave edges meet at a corner: fillets before rounds).</summary>+ internal enum Pass { All, ConcaveOnly }++ internal const string MixedCode = "uniform-rounding-mixed-vertex-unsupported";++ /// <summary>A sharp edge to round: its two faces (A walks it forward), its shape and side.</summary>private sealed class Sharp{public required Edge Edge { get; init; }public required Shape Shape { get; init; }- public required Support F0 { get; init; }- public required Support F1 { get; init; }- // Once the faces' loops are oriented: A walks the edge forward, B backward.public required Support A { get; init; }public required Support B { get; init; }public bool Closed => Edge.StartVertexId == Edge.EndVertexId;// +1 across a convex edge (the ball inside the material, cutting it away), -1 across a concave one (the ball// outside, filling the corner).public required double Side { get; init; }- // Closed circles: the ball centre, and where it touches A and B, at the seam's meridian.+ // Closed circles: the ball centre at the seam's meridian.public Point3D Centre { get; set; }}- internal static Outcome Round(BrepBody body, double radius)+ private enum VertexKind { Untouched, Corner, End, Junction }++ /// <summary>What becomes of a vertex: kept; a piece of the ball where three rounded edges meet; the end of a+ /// rounded edge's strip on the face across it (the two other edges kept); or two rounded edges whose strips+ /// run on into each other where their faces meet tangentially. One ball centre each.</summary>+ private sealed class Plan+ {+ public required VertexKind Kind { get; init; }+ public Point3D Centre { get; init; }+ // Corner: its three faces. End: the strip's two faces, then the face it ends on. Junction: the common face,+ // then the two tangent faces.+ public FaceId[] Faces { get; init; } = [];+ public EdgeId[] Rounded { get; init; } = [];+ public double Side { get; init; }+ }++ /// <summary>Every sharp edge rounded, in one pass, or in two where convex and concave edges meet at a corner:+ /// the concave edges filled first, then everything that is still sharp rounded (on a body this construction+ /// built, so its orientation is trusted).</summary>+ internal static Outcome RoundAll(BrepBody body, double radius)+ {+ var outcome = Round(body, radius, Pass.All, trusted: false);+ if (outcome.Refusal?.Code != MixedCode || outcome.Refusal.Message.Contains("two concave", StringComparison.Ordinal)) return outcome;+ var filled = Round(body, radius, Pass.ConcaveOnly, trusted: false);+ return filled.Body is null ? filled : Round(filled.Body, radius, Pass.All, trusted: true);+ }++ internal static Outcome Round(BrepBody body, double radius, Pass pass = Pass.All, bool trusted = false){var topology = body.Topology;var points = VertexPoints(body);@@ -137,11 +186,12 @@ internal static class LocalRoundingvar tol = double.Max(1e-9, (extent + 1) * 1e-10) * 1e2;if (radius <= 1e3 * tol) return Refuse("uniform-rounding-radius-invalid", $"radius {radius:G6} mm is below the construction tolerance");- // Faces: supports with their outward side.+ // Faces: supports with their outward side. A body this construction built may carry its own blends.var supports = new Dictionary<FaceId, Support>();foreach (var face in 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))+ if (!body.TryGetFaceSurfaceGeometry(face.Id, out var surface) || surface is null+ || surface.Kind is not (SurfaceGeometryKind.Plane or SurfaceGeometryKind.Cylinder or SurfaceGeometryKind.Cone) && !(trusted && surface.Kind is SurfaceGeometryKind.Sphere or SurfaceGeometryKind.Torus))return Refuse("uniform-rounding-curved-face-unsupported", $"rounding every edge supports faces on planes, cylinders and cones for now; face {face.Id.Value} is {surface?.Kind.ToString() ?? "unbound"}");body.Bindings.TryGetFaceBinding(face.Id, out var binding);supports.Add(face.Id, new Support(face.Id, surface, binding.Orientation.IsAlignedWithSurface ? 1 : -1));@@ -149,9 +199,8 @@ internal static class LocalRoundingvar faceOfLoop = topology.Faces.SelectMany(f => f.LoopIds.Select(l => (l, f.Id))).ToDictionary(x => x.l, x => x.Id);var uses = topology.Coedges.GroupBy(c => c.EdgeId).ToDictionary(g => g.Key, g => g.ToArray());- // Edges: shapes, seams, and the sharp convex edges to round.+ // Edges: shapes, seams (one face on both sides) and pairs of faces.var shapes = new Dictionary<EdgeId, Shape>();- var sharp = new Dictionary<EdgeId, Sharp>();var seams = new Dictionary<EdgeId, FaceId>();var pairs = new Dictionary<EdgeId, (FaceId F0, FaceId F1)>();foreach (var edge in topology.Edges.OrderBy(e => e.Id.Value))@@ -165,62 +214,68 @@ internal static class LocalRoundingvar (f0, f1) = (faceOfLoop[pair[0].LoopId], faceOfLoop[pair[1].LoopId]);if (f0 == f1){- if (shape.Arc || supports[f0].Kind == SurfaceGeometryKind.Plane)+ if (!trusted && (shape.Arc || supports[f0].Kind == SurfaceGeometryKind.Plane))return Refuse("uniform-rounding-edge-unsupported", $"edge {edge.Id.Value} has face {f0.Value} on both sides and is not the seam of a cylinder or cone");seams.Add(edge.Id, f0); continue;}pairs.Add(edge.Id, (f0, f1));}-- // Orientation: every edge of a face walked with the face's interior on its left about the outward normal.- // Decided per edge by stepping off it into the face, because the input's loops are not oriented (their- // coedge senses are not even consistent within one loop). Seams are walked both ways.- var span = 1e-6 * (extent + 1);var boundaries = topology.Faces.ToDictionary(f => f.Id, f => f.LoopIds.SelectMany(l => topology.GetLoop(l).CoedgeIds.Select(c => topology.GetCoedge(c).EdgeId)).Distinct().Select(e => shapes[e]).ToArray());- // Outward sides, by ray parity from just off each face: the input's face orientations are not relied on- // either (a revolved body's cap can be bound facing into its material).- foreach (var face in topology.Faces.OrderBy(f => f.Id.Value))+ // Orientation: every edge of a face walked with the face's interior on its left about the outward normal.+ // A body from elsewhere is not trusted for it (its loops' senses are not even consistent within one loop,+ // and a revolved body's cap can be bound facing into its material): outward sides by ray parity from just+ // off each face, each edge's direction by stepping off it into the face. Seams are walked both ways.+ var oriented = new Dictionary<FaceId, List<List<(EdgeId Edge, bool Reversed)>>>();+ if (trusted){- var support = supports[face.Id];- var edge = face.LoopIds.SelectMany(l => topology.GetLoop(l).CoedgeIds.Select(c => topology.GetCoedge(c).EdgeId)).FirstOrDefault(e => !seams.ContainsKey(e));- var shape = shapes[edge]; var p = shape.At(0.5); var t = shape.Tangent(p);- var w = Unit(support.Outward(p).Cross(t));- var onFace = new[] { support.Foot(p + w * span * 1e3), support.Foot(p - w * span * 1e3) }.Where(q => InsideFace(support, boundaries[face.Id], q)).ToArray();- if (onFace.Length != 1) return Refuse("uniform-rounding-edge-unsupported", $"could not find the inside of face {face.Id.Value}");- var normal = support.Outward(onFace[0]) * support.Sense; // the surface's own normal there- var outside = !Inside(supports.Values, boundaries, onFace[0] + normal * (span * 1e2));- var inside = Inside(supports.Values, boundaries, onFace[0] - normal * (span * 1e2));- if (outside != inside) return Refuse("uniform-rounding-edge-unsupported", $"could not tell which side of face {face.Id.Value} the material is on");- support.Sense = outside ? 1 : -1;+ foreach (var face in topology.Faces)+ oriented.Add(face.Id, face.LoopIds.Select(l => topology.GetLoop(l).CoedgeIds.Select(topology.GetCoedge).Select(c => (c.EdgeId, c.IsReversed)).ToList()).ToList());}-- var oriented = new Dictionary<FaceId, List<List<(EdgeId Edge, bool Reversed)>>>();- foreach (var face in topology.Faces.OrderBy(f => f.Id.Value))+ else{- var support = supports[face.Id];- var boundary = boundaries[face.Id];- var loops = new List<List<(EdgeId, bool)>>();- foreach (var loopId in face.LoopIds)+ var span = 1e-6 * (extent + 1);+ foreach (var face in topology.Faces.OrderBy(f => f.Id.Value)){- var loop = new List<(EdgeId, bool)>();- foreach (var edge in topology.GetLoop(loopId).CoedgeIds.Select(c => topology.GetCoedge(c).EdgeId).Distinct())+ var support = supports[face.Id];+ var edge = face.LoopIds.SelectMany(l => topology.GetLoop(l).CoedgeIds.Select(c => topology.GetCoedge(c).EdgeId)).FirstOrDefault(e => !seams.ContainsKey(e));+ var shape = shapes[edge]; var p = shape.At(0.5); var t = shape.Tangent(p);+ var w = Unit(support.Outward(p).Cross(t));+ var onFace = new[] { support.Foot(p + w * span * 1e3), support.Foot(p - w * span * 1e3) }.Where(q => InsideFace(support, boundaries[face.Id], q)).ToArray();+ if (onFace.Length != 1) return Refuse("uniform-rounding-edge-unsupported", $"could not find the inside of face {face.Id.Value}");+ var normal = support.Outward(onFace[0]) * support.Sense; // the surface's own normal there+ var outside = !Inside(supports.Values, boundaries, onFace[0] + normal * (span * 1e2));+ var inside = Inside(supports.Values, boundaries, onFace[0] - normal * (span * 1e2));+ if (outside != inside) return Refuse("uniform-rounding-edge-unsupported", $"could not tell which side of face {face.Id.Value} the material is on");+ support.Sense = outside ? 1 : -1;+ }+ foreach (var face in topology.Faces.OrderBy(f => f.Id.Value))+ {+ var support = supports[face.Id];+ var loops = new List<List<(EdgeId, bool)>>();+ foreach (var loopId in face.LoopIds){- if (seams.ContainsKey(edge)) { loop.Add((edge, false)); loop.Add((edge, true)); continue; }- var shape = shapes[edge]; var p = shape.At(0.5); var t = shape.Tangent(p);- var w = Unit(support.Outward(p).Cross(t));- var (left, right) = (InsideFace(support, boundary, support.Foot(p + w * span)), InsideFace(support, boundary, support.Foot(p - w * span)));- if (left == right)- return Refuse("uniform-rounding-edge-unsupported", $"could not tell which side of edge {edge.Value} face {face.Id.Value} lies on");- loop.Add((edge, !left));+ var loop = new List<(EdgeId, bool)>();+ foreach (var edge in topology.GetLoop(loopId).CoedgeIds.Select(c => topology.GetCoedge(c).EdgeId).Distinct())+ {+ if (seams.ContainsKey(edge)) { loop.Add((edge, false)); loop.Add((edge, true)); continue; }+ var shape = shapes[edge]; var p = shape.At(0.5); var t = shape.Tangent(p);+ var w = Unit(support.Outward(p).Cross(t));+ var (left, right) = (InsideFace(support, boundaries[face.Id], support.Foot(p + w * span)), InsideFace(support, boundaries[face.Id], support.Foot(p - w * span)));+ if (left == right)+ return Refuse("uniform-rounding-edge-unsupported", $"could not tell which side of edge {edge.Value} face {face.Id.Value} lies on");+ loop.Add((edge, !left));+ }+ loops.Add(loop);}- loops.Add(loop);+ oriented.Add(face.Id, loops);}- oriented.Add(face.Id, loops);}- // Sharp convex edges: A walks the edge forward, B backward; B's interior is left of B's direction about its- // outward normal, and across a convex edge it lies behind A's tangent plane.+ // Edges between two faces: tangent ones are kept; sharp ones have a side (A walks the edge forward, and across+ // a convex edge B's interior, left of B's direction about its outward normal, lies behind A's tangent plane).+ var sharp = new Dictionary<EdgeId, Sharp>();+ var kept = new Dictionary<EdgeId, (FaceId F0, FaceId F1, double Side)>(); // side 0: tangentforeach (var (edgeId, (f0, f1)) in pairs){var edge = topology.GetEdge(edgeId); var shape = shapes[edgeId];@@ -232,40 +287,84 @@ internal static class LocalRoundingvar p = shape.At(0.5);var (na, nb) = (a.Outward(p), b.Outward(p));if (na.Cross(nb).Length < 1e-7 && na.Dot(nb) > 0)- return Refuse("uniform-rounding-tangent-edge-unsupported", $"rounding every edge does not support edges where faces meet tangentially yet: edge {edgeId.Value} between faces {a.Face.Value} and {b.Face.Value} is smooth");- var intoB = nb.Cross(shape.Tangent(p) * -1);- var side = na.Dot(intoB) < 0 ? 1d : -1d;+ {+ // Two faces on one plane: one face split in two (some constructions leave a wall cut at a pocket's+ // depth). The edge between them is not an edge of the part.+ if (a.Kind == SurfaceGeometryKind.Plane && b.Kind == SurfaceGeometryKind.Plane)+ return Refuse("uniform-rounding-split-face-unsupported", $"faces {f0.Value} and {f1.Value} lie on one plane and meet at edge {edgeId.Value}: the body has a face split in two, and rounding every edge needs each face whole for now");+ kept.Add(edgeId, (f0, f1, 0)); continue;+ }+ var side = na.Dot(nb.Cross(shape.Tangent(p) * -1)) < 0 ? 1d : -1d;+ if (pass == Pass.ConcaveOnly && side > 0) { kept.Add(edgeId, (f0, f1, side)); continue; }if (!Shares(a, shape, tol) || !Shares(b, shape, tol))return Refuse("uniform-rounding-edge-unsupported", $"rounding every edge needs each edge's faces to run along its line or around its circle's axis: edge {edgeId.Value} {(shape.Arc ? "is a circle" : "is a line")} between a {Article(a.Kind)} and a {Article(b.Kind)} face that do not, so the ball's path along it is not a line or a circle");- sharp.Add(edgeId, new Sharp { Edge = edge, Shape = shape, F0 = a, F1 = b, A = a, B = b, Side = side });+ sharp.Add(edgeId, new Sharp { Edge = edge, Shape = shape, A = a, B = b, Side = side });}+ string Kind(EdgeId e) => sharp.TryGetValue(e, out var s) ? s.Side > 0 ? "convex" : "concave" : kept[e].Side > 0 ? "convex" : kept[e].Side < 0 ? "concave" : "tangent";+ FaceId[] FacesOf(EdgeId e) => sharp.TryGetValue(e, out var s) ? [s.A.Face, s.B.Face] : [kept[e].F0, kept[e].F1];- // Corners: every vertex on an open sharp edge joins exactly three sharp edges and three faces.- var corners = new Dictionary<VertexId, (Point3D Centre, EdgeId[] Edges, FaceId[] Faces, double Side)>();+ // Vertices.+ var plans = new Dictionary<VertexId, Plan>();foreach (var vertex in topology.Vertices.OrderBy(v => v.Id.Value)){- var incident = topology.Edges.Where(e => e.StartVertexId == vertex.Id || e.EndVertexId == vertex.Id).ToArray();- var open = incident.Where(e => e.StartVertexId != e.EndVertexId).ToArray();- if (open.Length == 0) continue;- if (open.Any(e => seams.ContainsKey(e.Id)) && open.All(e => seams.ContainsKey(e.Id))) continue; // seam ends- if (open.Length != 3 || open.Any(e => !sharp.ContainsKey(e.Id)))- return Refuse("uniform-rounding-vertex-unsupported", $"vertex {vertex.Id.Value} joins {open.Length} edges; rounding every edge on a body with curved faces needs three sharp edges at each corner for now");- var faces = open.SelectMany(e => new[] { sharp[e.Id].F0.Face, sharp[e.Id].F1.Face }).Distinct().ToArray();- if (faces.Length != 3)- return Refuse("uniform-rounding-vertex-unsupported", $"vertex {vertex.Id.Value} joins {faces.Length} faces with three edges; rounding needs three faces at each corner");- var sides = open.Select(e => sharp[e.Id].Side).Distinct().ToArray();+ var open = topology.Edges.Where(e => (e.StartVertexId == vertex.Id || e.EndVertexId == vertex.Id) && e.StartVertexId != e.EndVertexId && !seams.ContainsKey(e.Id)).ToArray();+ var rounded = open.Where(e => sharp.ContainsKey(e.Id)).Select(e => e.Id).ToArray();+ var others = open.Where(e => !sharp.ContainsKey(e.Id)).Select(e => e.Id).ToArray();+ if (rounded.Length == 0) { plans.Add(vertex.Id, new Plan { Kind = VertexKind.Untouched }); continue; }+ var joins = string.Join(", ", open.Select(e => $"{e.Id.Value} ({Kind(e.Id)})"));+ var sides = rounded.Select(e => sharp[e].Side).Concat(others.Where(e => kept[e].Side != 0).Select(e => kept[e].Side)).Distinct().ToArray();+ var faces = open.SelectMany(e => FacesOf(e.Id)).Distinct().ToArray();+ var side = sharp[rounded[0]].Side;+ if (rounded.Length == 3 && others.Length == 0 && faces.Length == 3)+ {+ if (sides.Length > 1)+ return Refuse(MixedCode, $"rounding every edge does not support corners where convex and concave edges meet yet: vertex {vertex.Id.Value} joins edges {joins}");+ var centre = Centre(faces.Select(f => supports[f]).ToArray(), points[vertex.Id], [side * radius, side * radius, side * radius], tol);+ if (centre is null || (centre.Value - points[vertex.Id]).Length > 50 * radius)+ return TooLarge(radius, $"the ball does not fit in the corner at vertex {vertex.Id.Value}");+ plans.Add(vertex.Id, new Plan { Kind = VertexKind.Corner, Centre = centre.Value, Faces = faces, Rounded = rounded, Side = side });+ continue;+ }+ if (rounded.Length == 1 && others.Length == 2 && faces.Length == 3 && others.All(e => kept[e].Side != 0) && pass == Pass.ConcaveOnly)+ {+ // The strip ends on the face across the vertex, which must stand square to it: the ball's+ // cross-section is then where the strip meets that face.+ var s = sharp[rounded[0]]; var across = faces.Single(f => f != s.A.Face && f != s.B.Face);+ if (s.Shape.Arc || supports[across].Kind != SurfaceGeometryKind.Plane || supports[across].Surface.Plane!.Value.Normal.ToVector().Cross(Unit(s.Shape.End - s.Shape.Start)).Length > 1e-9)+ return Refuse("uniform-rounding-vertex-unsupported", $"at vertex {vertex.Id.Value} the concave edge {rounded[0].Value} ends on face {across.Value}, which does not stand square to it; filling it there is not built yet");+ var centre = Centre([s.A, s.B, supports[across]], points[vertex.Id], [side * radius, side * radius, 0], tol);+ if (centre is null || new[] { s.A, s.B }.Any(f => double.Abs(supports[across].Inside(f.Foot(centre.Value))) > tol))+ return TooLarge(radius, $"the ball does not fit where edge {rounded[0].Value} ends at vertex {vertex.Id.Value}");+ plans.Add(vertex.Id, new Plan { Kind = VertexKind.End, Centre = centre.Value, Faces = [s.A.Face, s.B.Face, across], Rounded = rounded, Side = side });+ continue;+ }+ if (rounded.Length == 2 && others.Length == 1 && kept[others[0]].Side == 0 && faces.Length == 3 && sides.Length == 1)+ {+ // Two strips run on into each other: their common face, and the two faces meeting tangentially.+ var (e1, e2) = (sharp[rounded[0]], sharp[rounded[1]]);+ var common = new[] { e1.A.Face, e1.B.Face }.Intersect([e2.A.Face, e2.B.Face]).ToArray();+ var tangent = shapes[others[0]];+ if (common.Length != 1 || tangent.Arc)+ return Refuse("uniform-rounding-vertex-unsupported", $"vertex {vertex.Id.Value} joins edges {joins}; two strips meeting where faces join tangentially need a straight tangent edge and one common face");+ var g = common[0]; var (fa, fb) = (kept[others[0]].F0, kept[others[0]].F1);+ var d = Unit(tangent.End - tangent.Start) * (topology.GetEdge(others[0]).StartVertexId == vertex.Id ? 1 : -1);+ var centre = Junction(supports[g], supports[fa], points[vertex.Id], d, side * radius, tol);+ if (centre is null || double.Abs(supports[fb].Inside(centre.Value) - side * radius) > tol * 1e2)+ return TooLarge(radius, $"the ball does not fit where the strips meet at vertex {vertex.Id.Value}");+ plans.Add(vertex.Id, new Plan { Kind = VertexKind.Junction, Centre = centre.Value, Faces = [g, fa, fb], Rounded = rounded, Side = side });+ continue;+ }if (sides.Length > 1)- return Refuse("uniform-rounding-mixed-vertex-unsupported", $"rounding every edge does not support corners where convex and concave edges meet yet: vertex {vertex.Id.Value} joins edges {string.Join(", ", open.Select(e => $"{e.Id.Value} ({(sharp[e.Id].Side > 0 ? "convex" : "concave")})"))}");- var centre = Centre(faces.Select(f => supports[f]).ToArray(), points[vertex.Id], sides[0] * radius, tol);- if (centre is null || (centre.Value - points[vertex.Id]).Length > 50 * radius)- return TooLarge(radius, $"the ball does not fit in the corner at vertex {vertex.Id.Value}");- corners.Add(vertex.Id, (centre.Value, open.Select(e => e.Id).ToArray(), faces, sides[0]));+ return Refuse(MixedCode, rounded.Length == 2 && pass == Pass.ConcaveOnly+ ? $"rounding every edge does not support corners where two concave edges and a convex one meet: vertex {vertex.Id.Value} joins edges {joins} (filling the concave edges leaves the convex one between two fills, which does not round to a torus)"+ : $"rounding every edge does not support corners where convex and concave edges meet yet: vertex {vertex.Id.Value} joins edges {joins}");+ return Refuse("uniform-rounding-vertex-unsupported", $"vertex {vertex.Id.Value} joins edges {joins}; rounding needs three edges at a corner, or two strips meeting where faces join tangentially");}// Closed circles: the ball centre at the seam's meridian (or the circle's own start).foreach (var s in sharp.Values.Where(s => s.Closed)){- var seam = seams.Where(x => x.Value == s.F0.Face || x.Value == s.F1.Face).Select(x => shapes[x.Key].Start).ToArray();+ var seam = seams.Where(x => x.Value == s.A.Face || x.Value == s.B.Face).Select(x => shapes[x.Key].Start).ToArray();var c = s.Shape.Center!.Value; var nu = s.Shape.Normal;var x0 = Unit(s.Shape.Start - c);if (seam.Length > 0)@@ -275,17 +374,18 @@ internal static class LocalRoundingreturn Refuse("uniform-rounding-edge-unsupported", $"the faces around circle edge {s.Edge.Id.Value} have seams at different angles");x0 = meridian;}- var centre = Meridian(s.F0, s.F1, c, nu, x0, s.Shape.Start, s.Side * radius, tol, (s.Shape.Start - c).Length);+ var centre = Meridian(s.A, s.B, c, nu, x0, s.Shape.Start, s.Side * radius, tol, (s.Shape.Start - c).Length);if (centre is null) return TooLarge(radius, $"the ball does not fit along circle edge {s.Edge.Id.Value}");s.Centre = centre.Value;}- return Build(body, radius, tol, supports, oriented, shapes, sharp, seams, corners, boundaries);+ return Build(body, radius, tol, points, supports, oriented, shapes, sharp, kept, seams, plans, boundaries);}- private static Outcome Build(BrepBody body, double radius, double tol, Dictionary<FaceId, Support> supports, Dictionary<FaceId, List<List<(EdgeId Edge, bool Reversed)>>> oriented,- Dictionary<EdgeId, Shape> shapes, Dictionary<EdgeId, Sharp> sharp, Dictionary<EdgeId, FaceId> seams,- Dictionary<VertexId, (Point3D Centre, EdgeId[] Edges, FaceId[] Faces, double Side)> corners, Dictionary<FaceId, Shape[]> boundaries)+ private static Outcome Build(BrepBody body, double radius, double tol, Dictionary<VertexId, Point3D> points, Dictionary<FaceId, Support> supports,+ Dictionary<FaceId, List<List<(EdgeId Edge, bool Reversed)>>> oriented, Dictionary<EdgeId, Shape> shapes, Dictionary<EdgeId, Sharp> sharp,+ Dictionary<EdgeId, (FaceId F0, FaceId F1, double Side)> kept, Dictionary<EdgeId, FaceId> seams, Dictionary<VertexId, Plan> plans,+ Dictionary<FaceId, Shape[]> boundaries){var topology = body.Topology;var builder = new TopologyBuilder();@@ -330,13 +430,30 @@ internal static class LocalRoundingvar sid = new SurfaceGeometryId(geometry.Surfaces.Count() + 1); geometry.AddSurface(sid, surface);bindings.AddFaceBinding(new FaceGeometryBinding(face, sid, aligned));}+ VertexId StartOfEdge(EdgeId e) => builder.Model.GetEdge(e).StartVertexId;- // Contact vertices: where the ball at a corner touches each of its faces; for closed circles, where the ball- // at the meridian touches each side.+ // Vertices: kept ones once; where the ball touches each face at a corner, an end or a junction (both tangent+ // faces at one point); for closed circles, where the ball at the meridian touches each side.+ var keep = new Dictionary<VertexId, VertexId>();+ VertexId Kept(VertexId v) => keep.TryGetValue(v, out var k) ? k : keep[v] = NewVertex(points[v]);var contact = new Dictionary<(VertexId Vertex, FaceId Face), VertexId>();- foreach (var (vertex, corner) in corners)- foreach (var face in corner.Faces)- contact.Add((vertex, face), NewVertex(supports[face].Foot(corner.Centre)));+ foreach (var (vertex, plan) in plans.OrderBy(p => p.Key.Value))+ {+ switch (plan.Kind)+ {+ case VertexKind.Corner:+ foreach (var face in plan.Faces) contact.Add((vertex, face), NewVertex(supports[face].Foot(plan.Centre)));+ break;+ case VertexKind.End:+ foreach (var face in plan.Faces.Take(2)) contact.Add((vertex, face), NewVertex(supports[face].Foot(plan.Centre)));+ break;+ case VertexKind.Junction:+ contact.Add((vertex, plan.Faces[0]), NewVertex(supports[plan.Faces[0]].Foot(plan.Centre)));+ var touch = NewVertex(supports[plan.Faces[1]].Foot(plan.Centre));+ contact.Add((vertex, plan.Faces[1]), touch); contact.Add((vertex, plan.Faces[2]), touch);+ break;+ }+ }var ring = new Dictionary<(EdgeId Edge, FaceId Face), VertexId>();foreach (var s in sharp.Values.Where(s => s.Closed)){@@ -344,9 +461,11 @@ internal static class LocalRoundingring.Add((s.Edge.Id, s.B.Face), NewVertex(s.B.Foot(s.Centre)));}- // Contact edges along each sharp edge, on each of its faces; the ball's cross-section arcs at its ends.+ // Rounded edges: contact edges on each face, the ball's cross-section at each end (shared where two strips+ // meet), and the strip.var along = new Dictionary<(EdgeId Edge, FaceId Face), EdgeId>();var section = new Dictionary<(EdgeId Edge, VertexId Vertex), EdgeId>();+ var shared = new Dictionary<VertexId, EdgeId>();var strips = new List<(Sharp Sharp, SurfaceGeometry Surface)>();foreach (var s in sharp.Values.OrderBy(s => s.Edge.Id.Value)){@@ -361,8 +480,7 @@ internal static class LocalRoundingalong.Add((s.Edge.Id, face.Face), NewEdge(v, v, new Shape(p, p, centre, nu, Turn)));}var (a, b) = (ring[(s.Edge.Id, s.A.Face)], ring[(s.Edge.Id, s.B.Face)]);- var tangent = Unit(nu.Cross(s.Centre - c));- section.Add((s.Edge.Id, s.Edge.StartVertexId), NewEdge(a, b, Cross(positions[a], positions[b], s.Centre, tangent)));+ section.Add((s.Edge.Id, s.Edge.StartVertexId), NewEdge(a, b, Cross(positions[a], positions[b], s.Centre, Unit(nu.Cross(s.Centre - c)))));var axisCentre = c + nu * (s.Centre - c).Dot(nu); var major = (s.Centre - axisCentre).Length;if (major <= radius + tol) return TooLarge(radius, $"the ball along circle edge {s.Edge.Id.Value} reaches the circle's axis");strips.Add((s, SurfaceGeometry.FromTorus(new TorusSurface(axisCentre, Direction3D.Create(nu), major, radius, Direction3D.Create(s.Centre - axisCentre)))));@@ -370,32 +488,21 @@ internal static class LocalRounding}var (start, end) = (s.Edge.StartVertexId, s.Edge.EndVertexId);- var (c0, c1) = (corners[start].Centre, corners[end].Centre);+ var (c0, c1) = (plans[start].Centre, plans[end].Centre);foreach (var face in new[] { s.A, s.B }){var (v0, v1) = (contact[(start, face.Face)], contact[(end, face.Face)]);- var (p0, p1) = (positions[v0], positions[v1]);- Shape? path = null;- if (!shape.Arc)- {- if ((p1 - p0).Dot(shape.End - shape.Start) <= tol * (shape.End - shape.Start).Length)- return TooLarge(radius, $"the rounding uses up edge {s.Edge.Id.Value} on face {face.Face.Value}");- path = new Shape(p0, p1, null, Vector3D.Zero, 0);- }- else- {- var c = shape.Center!.Value; var nu = shape.Normal; var centre = c + nu * (p0 - c).Dot(nu);- var sweep = Angle(p0 - centre, p1 - centre, nu);- if ((p0 - centre).Length <= tol || double.Abs(sweep - shape.Sweep) >= double.Pi / 2 || sweep <= 1e-9)- return TooLarge(radius, $"the rounding uses up edge {s.Edge.Id.Value} on face {face.Face.Value}");- path = new Shape(p0, p1, centre, nu, sweep);- }+ var path = Trimmed(shape, positions[v0], positions[v1], tol);+ if (path is null) return TooLarge(radius, $"the rounding uses up edge {s.Edge.Id.Value} on face {face.Face.Value}");along.Add((s.Edge.Id, face.Face), NewEdge(v0, v1, path));}foreach (var (vertex, centre) in new[] { (start, c0), (end, c1) }){+ if (plans[vertex].Kind == VertexKind.Junction && shared.TryGetValue(vertex, out var existing)) { section.Add((s.Edge.Id, vertex), existing); continue; }var (a, b) = (contact[(vertex, s.A.Face)], contact[(vertex, s.B.Face)]);- section.Add((s.Edge.Id, vertex), NewEdge(a, b, Cross(positions[a], positions[b], centre, shape.Tangent(shape.Arc ? Project(centre, shape) : centre))));+ var cut = NewEdge(a, b, Cross(positions[a], positions[b], centre, shape.Tangent(shape.Arc ? Project(centre, shape) : centre)));+ section.Add((s.Edge.Id, vertex), cut);+ if (plans[vertex].Kind == VertexKind.Junction) shared.Add(vertex, cut);}if (!shape.Arc){@@ -411,20 +518,55 @@ internal static class LocalRounding}}- // Seams: the generator between the contacts at either end of the periodic face.+ // Kept edges, trimmed to wherever their ends went: a kept vertex, the contact on the face they share with a+ // strip that ends there, or the tangent faces' common contact.+ VertexId EndOf(EdgeId edge, VertexId vertex)+ {+ var plan = plans.GetValueOrDefault(vertex);+ if (plan is null || plan.Kind == VertexKind.Untouched) return Kept(vertex);+ var faces = kept[edge] is var k ? new[] { k.F0, k.F1 } : [];+ return contact[(vertex, faces.First(f => contact.ContainsKey((vertex, f))))];+ }+ var keptEdges = new Dictionary<EdgeId, EdgeId>();+ foreach (var edge in kept.Keys.Concat(seams.Keys.Where(e => !sharp.Values.Any(s => s.Closed && (s.A.Face == seams[e] || s.B.Face == seams[e])))).OrderBy(e => e.Value))+ {+ var original = topology.GetEdge(edge); var shape = shapes[edge];+ var (v0, v1) = (EndOf(edge, original.StartVertexId), original.StartVertexId == original.EndVertexId ? EndOf(edge, original.StartVertexId) : EndOf(edge, original.EndVertexId));+ var path = original.StartVertexId == original.EndVertexId ? shape with { Start = positions[v0], End = positions[v0] } : Trimmed(shape, positions[v0], positions[v1], tol);+ if (path is null) return TooLarge(radius, $"the rounding uses up edge {edge.Value}");+ keptEdges.Add(edge, NewEdge(v0, v1, path));+ }++ // Seams of faces whose rims are rounded: the generator between the contacts at either end.var seam = new Dictionary<EdgeId, EdgeId>();- foreach (var (edge, face) in seams)+ foreach (var (edge, face) in seams.Where(x => !keptEdges.ContainsKey(x.Key))){var shape = shapes[edge];- VertexId? Nearest(Point3D p) => sharp.Values.Where(s => s.Closed && (s.A.Face == face || s.B.Face == face))- .OrderBy(s => double.Abs((p - s.Shape.Center!.Value).Dot(s.Shape.Normal))).Select(s => (VertexId?)ring[(s.Edge.Id, face)]).FirstOrDefault();+ VertexId? Nearest(Point3D p) => sharp.Values.Where(s => s.Closed && (s.A.Face == face || s.B.Face == face)).Select(s => (Shape: s.Shape, Vertex: ring[(s.Edge.Id, face)]))+ .Concat(kept.Keys.Where(e => topology.GetEdge(e).StartVertexId == topology.GetEdge(e).EndVertexId && (kept[e].F0 == face || kept[e].F1 == face)).Select(e => (Shape: shapes[e], Vertex: builder.Model.GetEdge(keptEdges[e]).StartVertexId)))+ .OrderBy(x => double.Abs((p - x.Shape.Center!.Value).Dot(x.Shape.Normal))).Select(x => (VertexId?)x.Vertex).FirstOrDefault();if (Nearest(shape.Start) is not { } v0 || Nearest(shape.End) is not { } v1 || v0 == v1)return Refuse("uniform-rounding-edge-unsupported", $"seam edge {edge.Value} on face {face.Value} does not run between two circle edges");- if ((positions[v1] - positions[v0]).Dot(shape.End - shape.Start) <= tol)+ if ((positions[v1] - positions[v0]).Dot(shape.End - shape.Start) <= tol || Unit(positions[v1] - positions[v0]).Cross(Unit(shape.End - shape.Start)).Length > 1e-7)return TooLarge(radius, $"the rounding uses up face {face.Value} along its seam");seam.Add(edge, NewEdge(v0, v1, new Shape(positions[v0], positions[v1], null, Vector3D.Zero, 0)));}+ // Strips: the contact on A from the end back to the start, the section at the start across to B, the+ // contact on B, the section at the end back to A. Each section's direction from its own ends.+ var stripUse = new Dictionary<EdgeId, bool>();+ var stripLoops = new List<(Sharp Sharp, SurfaceGeometry Surface, List<(EdgeId, bool)> Loop)>();+ foreach (var (s, surface) in strips)+ {+ var a = along[(s.Edge.Id, s.A.Face)]; var b = along[(s.Edge.Id, s.B.Face)];+ var first = section[(s.Edge.Id, s.Edge.StartVertexId)];+ var last = s.Closed ? first : section[(s.Edge.Id, s.Edge.EndVertexId)];+ var firstReversed = StartOfEdge(first) != StartOfEdge(a);+ var lastReversed = s.Closed ? !firstReversed : StartOfEdge(last) != builder.Model.GetEdge(b).EndVertexId;+ stripUse[first] = firstReversed; if (!s.Closed) stripUse[last] = lastReversed;+ stripLoops.Add((s, surface, [(a, true), (first, firstReversed), (b, false), (last, lastReversed)]));+ }+// Each loop's uses in walking order, from the new edges' shared vertices.List<(EdgeId Edge, bool Reversed)>? Chain(List<(EdgeId Edge, bool Reversed)> uses){@@ -442,17 +584,23 @@ internal static class LocalRoundingreturn From(ordered[0]) == To(ordered[^1]) ? ordered : null;}- // Original faces, trimmed: each edge replaced by its contact edge (or rebuilt seam), same direction.+ // Original faces, trimmed: each edge replaced by its contact edge, kept edge or rebuilt seam, same+ // direction; a strip that ends on the face leaves its end section in the loop where the vertex was.var originalLoops = new Dictionary<FaceId, List<List<(EdgeId Edge, bool Reversed)>>>();foreach (var face in topology.Faces.OrderBy(f => f.Id.Value)){+ var ends = plans.Where(p => p.Value.Kind == VertexKind.End && p.Value.Faces[2] == face.Id)+ .Select(p => (Edge: section[(p.Value.Rounded[0], p.Key)], Vertex: p.Key)).ToList();var loops = new List<List<(EdgeId Edge, bool Reversed)>>();foreach (var loop in oriented[face.Id]){- var chained = Chain(loop.Select(u => (seam.TryGetValue(u.Edge, out var rebuilt) ? rebuilt : along[(u.Edge, face.Id)], u.Reversed)).ToList());+ var mapped = loop.Select(u => (seam.TryGetValue(u.Edge, out var rebuilt) ? rebuilt : keptEdges.TryGetValue(u.Edge, out var k) ? k : along[(u.Edge, face.Id)], u.Reversed)).ToList();+ var touching = ends.Where(x => topology.Edges.Any(e => (e.StartVertexId == x.Vertex || e.EndVertexId == x.Vertex) && loop.Any(u => u.Edge == e.Id))).ToList();+ mapped.AddRange(touching.Select(x => (x.Edge, !stripUse[x.Edge])));+ var chained = Chain(mapped);if (chained is null){- var walk = string.Join(" ", loop.Select(u => { var n = seam.TryGetValue(u.Edge, out var r) ? r : along[(u.Edge, face.Id)]; var e = builder.Model.GetEdge(n); return $"{u.Edge.Value}{(u.Reversed ? "-" : "+")}:{e.StartVertexId.Value}>{e.EndVertexId.Value}"; }));+ var walk = string.Join(" ", mapped.Select(u => { var e = builder.Model.GetEdge(u.Item1); return $"{u.Item1.Value}{(u.Item2 ? "-" : "+")}:{e.StartVertexId.Value}>{e.EndVertexId.Value}"; }));return Refuse("uniform-rounding-edge-unsupported", $"a boundary of face {face.Id.Value} does not close after rounding ({walk})");}loops.Add(chained);@@ -469,35 +617,25 @@ internal static class LocalRoundingNewFace(loops.Select(l => (IReadOnlyList<(EdgeId, bool)>)l).ToList(), supports[face.Id].Surface, supports[face.Id].Sense > 0);}- // Strips: the contact on A against A's direction, the section at the start, the contact on B, the section- // at the end back. A uses the edge forward, so every shared edge is used once each way.- foreach (var (s, surface) in strips)- {- var a = along[(s.Edge.Id, s.A.Face)]; var b = along[(s.Edge.Id, s.B.Face)];- var first = section[(s.Edge.Id, s.Edge.StartVertexId)];- var last = s.Closed ? first : section[(s.Edge.Id, s.Edge.EndVertexId)];- // A concave strip faces its own axis: the body's outward normal opposes the tube's.- NewFace([[(a, true), (first, false), (b, false), (last, true)]], surface, s.Side > 0);- }+ // A concave strip faces its own axis: the body's outward normal opposes the tube's.+ foreach (var (s, surface, loop) in stripLoops)+ NewFace([loop], surface, s.Side > 0);// Corners: the three sections, each against the direction its strip uses it.- foreach (var (vertex, corner) in corners.OrderBy(c => c.Key.Value))+ foreach (var (vertex, plan) in plans.Where(p => p.Value.Kind == VertexKind.Corner).OrderBy(p => p.Key.Value)){- var arcs = corner.Edges.Select(e => (Edge: section[(e, vertex)], Reversed: sharp[e].Edge.StartVertexId == vertex)).ToList();- var ordered = new List<(EdgeId, bool)> { arcs[0] }; arcs.RemoveAt(0);- while (arcs.Count > 0)- {- var (last, reversed) = ordered[^1]; var e = builder.Model.GetEdge(last); var end = reversed ? e.StartVertexId : e.EndVertexId;- var next = arcs.FindIndex(x => (x.Reversed ? builder.Model.GetEdge(x.Edge).EndVertexId : builder.Model.GetEdge(x.Edge).StartVertexId) == end);- if (next < 0) return Refuse("uniform-rounding-vertex-unsupported", $"the corner at vertex {vertex.Value} does not close");- ordered.Add(arcs[next]); arcs.RemoveAt(next);- }- var axis = Unit(corner.Faces.Aggregate(Vector3D.Zero, (n, f) => n + supports[f].Outward(corner.Centre)));- NewFace([ordered], SurfaceGeometry.FromSphere(new SphereSurface(corner.Centre, Direction3D.Create(axis), radius, Direction3D.Create(Perpendicular(axis)))), corner.Side > 0);+ var ordered = Chain(plan.Rounded.Select(e => (section[(e, vertex)], !stripUse[section[(e, vertex)]])).ToList());+ if (ordered is null) return Refuse("uniform-rounding-vertex-unsupported", $"the corner at vertex {vertex.Value} does not close");+ var axis = Unit(plan.Faces.Aggregate(Vector3D.Zero, (n, f) => n + supports[f].Outward(plan.Centre)));+ NewFace([ordered], SurfaceGeometry.FromSphere(new SphereSurface(plan.Centre, Direction3D.Create(axis), radius, Direction3D.Create(Perpendicular(axis)))), plan.Side > 0);}+ // Every edge used once each way (a seam twice by one face).+ var wrong = builder.Model.Coedges.GroupBy(c => c.EdgeId).Where(g => g.Count() != 2 || g.First().IsReversed == g.Last().IsReversed).Select(g => g.Key.Value).ToArray();+ if (wrong.Length > 0) return Refuse("uniform-rounding-build-failed", $"the rounded body does not use edges {string.Join(", ", wrong.Take(8))} once each way");+// Fit: the ball touches nothing beyond its own faces, and planar faces keep their loops simple.- var refusal = Clearance(boundaries, radius, tol, supports, sharp, corners) ?? Planar(radius, tol, supports, shapes, built, originalLoops);+ var refusal = Clearance(boundaries, radius, tol, supports, sharp, plans) ?? Planar(radius, tol, supports, shapes, built, originalLoops);if (refusal is not null) return new Outcome { Refusal = refusal };builder.AddBody([builder.AddShell(resultFaces)]);@@ -507,23 +645,51 @@ internal static class LocalRounding: Refuse("uniform-rounding-build-failed", string.Join("; ", validation.Diagnostics.Select(d => d.Message)));}- /// <summary>The ball centre at signed inward distance <paramref name="radius"/> from three faces (negative:- /// outside, across concave edges), by Newton on their distance functions (whose gradients are the inward+ /// <summary>The same line or circle between new ends, still running the original way; null if it folded.</summary>+ private static Shape? Trimmed(Shape shape, Point3D p0, Point3D p1, double tol)+ {+ if (!shape.Arc)+ return (p1 - p0).Dot(shape.End - shape.Start) > tol * (shape.End - shape.Start).Length ? new Shape(p0, p1, null, Vector3D.Zero, 0) : null;+ var c = shape.Center!.Value; var nu = shape.Normal; var centre = c + nu * (p0 - c).Dot(nu);+ var sweep = Angle(p0 - centre, p1 - centre, nu);+ return (p0 - centre).Length > tol && sweep > 1e-9 && double.Abs(sweep - shape.Sweep) < double.Pi / 2 ? new Shape(p0, p1, centre, nu, sweep) : null;+ }++ /// <summary>The ball centre at the given signed inward distances from three faces (negative: outside, across+ /// concave edges; zero: on the face), by Newton on their distance functions (whose gradients are the inward/// normals); exact in one step on planes.</summary>- private static Point3D? Centre(Support[] faces, Point3D vertex, double radius, double tol)+ private static Point3D? Centre(Support[] faces, Point3D vertex, double[] targets, double tol){- var x = vertex - Unit(faces.Aggregate(Vector3D.Zero, (n, f) => n + f.Outward(vertex))) * radius;+ var x = vertex - Unit(faces.Zip(targets).Where(p => p.Second != 0).Aggregate(Vector3D.Zero, (n, p) => n + p.First.Outward(vertex))) * targets[0];for (var i = 0; i < 60; i++){var rows = faces.Select(f => f.Outward(x) * -1).ToArray();- var residual = faces.Select(f => f.Inside(x) - radius).ToArray();+ var residual = faces.Select((f, k) => f.Inside(x) - targets[k]).ToArray();if (residual.All(r => double.Abs(r) <= tol * 1e-3)) return x;var det = rows[0].Dot(rows[1].Cross(rows[2]));if (double.Abs(det) < 1e-12) return null;var step = (rows[1].Cross(rows[2]) * -residual[0] + rows[2].Cross(rows[0]) * -residual[1] + rows[0].Cross(rows[1]) * -residual[2]) * (1 / det);x += step;}- return faces.All(f => double.Abs(f.Inside(x) - radius) <= tol) ? x : null;+ return faces.Select((f, k) => double.Abs(f.Inside(x) - targets[k])).All(r => r <= tol) ? x : null;+ }++ /// <summary>Where two strips meet across a tangent edge: the ball touching the tangent faces at one point of+ /// the edge and the common face, found along the edge from the vertex.</summary>+ private static Point3D? Junction(Support common, Support tangent, Point3D vertex, Vector3D along, double target, double tol)+ {+ Point3D Ball(double s) { var q = vertex + along * s; return q - tangent.Outward(q) * target; }+ var t = 0d;+ for (var i = 0; i < 60; i++)+ {+ var f = common.Inside(Ball(t)) - target;+ if (double.Abs(f) <= tol * 1e-3) return Ball(t);+ var h = 1e-6 * (double.Abs(target) + double.Abs(t));+ var slope = (common.Inside(Ball(t + h)) - common.Inside(Ball(t - h))) / (2 * h);+ if (double.Abs(slope) < 1e-12) return null;+ t -= f / slope;+ }+ return null;}/// <summary>The ball centre at signed inward distance <paramref name="radius"/> from two coaxial faces, in the@@ -531,9 +697,8 @@ internal static class LocalRoundingprivate static Point3D? Meridian(Support a, Support b, Point3D centre, Vector3D axis, Vector3D meridian, Point3D onEdge, double radius, double tol, double rho0){var start = centre + meridian * rho0;- var (rho, z) = (rho0, 0d);var guess = start - Unit(a.Outward(start) + b.Outward(start)) * radius;- (rho, z) = ((guess - centre).Dot(meridian), (guess - centre).Dot(axis));+ var (rho, z) = ((guess - centre).Dot(meridian), (guess - centre).Dot(axis));for (var i = 0; i < 60; i++){var x = centre + meridian * rho + axis * z;@@ -549,29 +714,31 @@ internal static class LocalRounding}/// <summary>Sampled ball centres along every strip and at every corner stay further than r from each face that- /// is not one of their own, wherever that face actually is.</summary>+ /// is not one of their own (a strip's own include the face it ends on and the faces it meets tangentially),+ /// wherever that face actually is.</summary>private static Refusal? Clearance(Dictionary<FaceId, Shape[]> boundaries, double radius, double tol, Dictionary<FaceId, Support> supports,- Dictionary<EdgeId, Sharp> sharp, Dictionary<VertexId, (Point3D Centre, EdgeId[] Edges, FaceId[] Faces, double Side)> corners)+ Dictionary<EdgeId, Sharp> sharp, Dictionary<VertexId, Plan> plans){IEnumerable<(Point3D Centre, FaceId[] Own, string Where)> Samples(){foreach (var s in sharp.Values){- var own = new[] { s.A.Face, s.B.Face };if (s.Closed){var c = s.Shape.Center!.Value;- for (var i = 0; i < 24; i++) yield return (Rotate(s.Centre, c, s.Shape.Normal, Turn * i / 24), own, $"along edge {s.Edge.Id.Value}");+ for (var i = 0; i < 24; i++) yield return (Rotate(s.Centre, c, s.Shape.Normal, Turn * i / 24), [s.A.Face, s.B.Face], $"along edge {s.Edge.Id.Value}");continue;}- var (c0, c1) = (corners[s.Edge.StartVertexId].Centre, corners[s.Edge.EndVertexId].Centre);+ var (p0, p1) = (plans[s.Edge.StartVertexId], plans[s.Edge.EndVertexId]);+ var own = new[] { s.A.Face, s.B.Face }.Concat(new[] { p0, p1 }.Where(p => p.Kind is VertexKind.End or VertexKind.Junction).SelectMany(p => p.Faces)).Distinct().ToArray();+ var (c0, c1) = (p0.Centre, p1.Centre);for (var i = 1; i < 8; i++){var t = i / 8d;yield return (!s.Shape.Arc ? c0 + (c1 - c0) * t : Rotate(c0, s.Shape.Center!.Value, s.Shape.Normal, Angle(c0 - Axial(c0, s.Shape), c1 - Axial(c0, s.Shape), s.Shape.Normal) * t), own, $"along edge {s.Edge.Id.Value}");}}- foreach (var (vertex, corner) in corners) yield return (corner.Centre, corner.Faces, $"at vertex {vertex.Value}");+ foreach (var (vertex, plan) in plans.Where(p => p.Value.Kind == VertexKind.Corner)) yield return (plan.Centre, plan.Faces, $"at vertex {vertex.Value}");}foreach (var (centre, own, where) in Samples())foreach (var (face, support) in supports)@@ -702,6 +869,9 @@ internal static class LocalRounding}return crossings % 2 == 1;}+ // A blend this construction made (a sphere corner, a closed rim's torus) is never asked: it only comes back+ // as a face of a second pass, never in the way of a ball there.+ if (face.Kind is not (SurfaceGeometryKind.Cylinder or SurfaceGeometryKind.Cone)) return false;var (origin, axis) = face.Kind == SurfaceGeometryKind.Cylinder? (face.Surface.Cylinder!.Value.Origin, face.Surface.Cylinder!.Value.Axis.ToVector()): (face.Surface.Cone!.Value.Apex, face.Surface.Cone!.Value.Axis.ToVector());diff --git a/Aetheris.Kernel.Core/Brep/Blends/UniformRounding.cs b/Aetheris.Kernel.Core/Brep/Blends/UniformRounding.csindex bfa516cc..2a8a9ad0 100644--- a/Aetheris.Kernel.Core/Brep/Blends/UniformRounding.cs+++ b/Aetheris.Kernel.Core/Brep/Blends/UniformRounding.cs@@ -25,12 +25,12 @@ public static class UniformRounding/// bisection: every check that refuses a radius also refuses every larger one).</summary>private static KernelResult<BrepBody> Local(BrepBody body, double radius){- var outcome = LocalRounding.Round(body, radius);+ var outcome = LocalRounding.RoundAll(body, radius);if (outcome.Body is not null) return KernelResult<BrepBody>.Success(outcome.Body);var refusal = outcome.Refusal!;if (refusal.Code != TooLargeCode) return Failure(refusal.Code, refusal.Message);var (lo, hi) = (0d, radius);- for (var i = 0; i < 40; i++) { var mid = 0.5 * (lo + hi); if (LocalRounding.Round(body, mid).Body is not null) lo = mid; else hi = mid; }+ for (var i = 0; i < 40; i++) { var mid = 0.5 * (lo + hi); if (LocalRounding.RoundAll(body, mid).Body is not null) lo = mid; else hi = mid; }return Failure(refusal.Code, $"{refusal.Message}; the largest that fits is under {hi:G6} mm");}diff --git a/Aetheris.Kernel.Firmament.Tests/Experiments/BlendNetworkRemovalTests.cs b/Aetheris.Kernel.Firmament.Tests/Experiments/BlendNetworkRemovalTests.csindex 65ab1602..609c1fdc 100644--- a/Aetheris.Kernel.Firmament.Tests/Experiments/BlendNetworkRemovalTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/Experiments/BlendNetworkRemovalTests.cs@@ -170,6 +170,8 @@ public sealed class BlendNetworkRemovalTests(ITestOutputHelper output)[InlineData("bushing-rounded")][InlineData("counterbore-rounded")][InlineData("blind-hole-rounded")]+ [InlineData("rounded-rect-rounded")]+ [InlineData("ell-rounded")]public void RemovingWholeBodyRounding_ReturnsTheBody(string name){var source = File.ReadAllText(Path.Combine(Root(), "fixtures/Regression/UniformRounding", name + ".firmament"));diff --git a/Aetheris.Kernel.Firmament.Tests/Integration/UniformRoundingRouteTests.cs b/Aetheris.Kernel.Firmament.Tests/Integration/UniformRoundingRouteTests.csindex f9089e92..109fec1c 100644--- a/Aetheris.Kernel.Firmament.Tests/Integration/UniformRoundingRouteTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/Integration/UniformRoundingRouteTests.cs@@ -70,17 +70,45 @@ public sealed class UniformRoundingRouteTestsAssert.NotNull(refused.Diagnostics.Single().SourceSpan);}- /// <summary>An L-shaped extrusion: its inner vertical edge is concave and meets the convex top and bottom- /// edges, a corner whose two possible orders of rounding give different geometry. Refused, naming it.</summary>+ /// <summary>An L-shaped extrusion: its inner vertical edge is concave and meets the convex top and bottom edges.+ /// The concave edge is filled first (fillets before rounds): its strip ends square on the top and bottom, whose+ /// new arcs round to tori running on into the neighbouring strips. Every blend reads back at the radius.</summary>[Fact]- public void MixedCorner_RefusesNamingTheVertex()+ public void MixedCorner_FilledThenRounded(){- var message = Assert.Single(FirmamentBuildAndExport.CompileSource(File.ReadAllText(Path.Combine(Root(), "fixtures/Regression/UniformRounding/ell-mixed-corner.firmament"))).Diagnostics).Message;+ var built = FirmamentBuildAndExport.CompileSource(File.ReadAllText(Path.Combine(Root(), "fixtures/Regression/UniformRounding/ell-rounded.firmament")));+ Assert.True(built.IsSuccess, string.Join("\n", built.Diagnostics.Select(d => d.Message)));+ var body = Step242Importer.ImportBody(built.Value.StepText).Value;+ int Count(SurfaceGeometryKind kind) => body.Topology.Faces.Count(f => body.TryGetFaceSurfaceGeometry(f.Id, out var g) && g!.Kind == kind);+ Assert.Equal((8, 18, 2, 10), (Count(SurfaceGeometryKind.Plane), Count(SurfaceGeometryKind.Cylinder), Count(SurfaceGeometryKind.Torus), Count(SurfaceGeometryKind.Sphere)));+ var read = BlendRecognition.Recognize(body);+ Assert.Equal(30, read.Count(r => r.Role is BlendFaceRole.Strip or BlendFaceRole.Joiner));+ Assert.All(read.Where(r => r.Role == BlendFaceRole.Strip), b => Assert.Equal(1, b.Blend!.Size, 9));+ // The concave fill is the only concave strip; its tori are major radius 2r around its axis.+ Assert.All(body.Topology.Faces.Select(f => body.TryGetFaceSurfaceGeometry(f.Id, out var g) ? g!.Torus : null).Where(t => t is not null), t => Assert.Equal(2, t!.Value.MajorRadius, 9));+ }++ /// <summary>A boss on a plate: at each foot corner two concave edges meet a convex one. Filling the concave+ /// edges first would leave the convex edge between two fills; refused, naming the corner.</summary>+ [Fact]+ public void TwoConcaveAndAConvex_RefusesNamingTheVertex()+ {+ var message = Assert.Single(FirmamentBuildAndExport.CompileSource(File.ReadAllText(Path.Combine(Root(), "fixtures/Regression/UniformRounding/boss-mixed-corner.firmament"))).Diagnostics).Message;Assert.Contains("uniform-rounding-mixed-vertex-unsupported", message);- Assert.Contains("convex and concave edges meet", message);+ Assert.Contains("two concave edges and a convex one meet", message);Assert.Matches(@"vertex \d+ joins edges \d+ \((convex|concave)\), \d+ \((convex|concave)\), \d+ \((convex|concave)\)", message);}+ /// <summary>A plate with a pocket, built by composition, has each side wall split at the pocket's depth into two+ /// faces on one plane. Refused by name rather than rounded along the split.</summary>+ [Fact]+ public void SplitFace_RefusesByName()+ {+ var message = Assert.Single(FirmamentBuildAndExport.CompileSource(File.ReadAllText(Path.Combine(Root(), "fixtures/Regression/UniformRounding/pocket-split-face.firmament"))).Diagnostics).Message;+ Assert.Contains("uniform-rounding-split-face-unsupported", message);+ Assert.Contains("lie on one plane", message);+ }+/// <summary>A blind hole's floor rounds to a concave torus around the hole's axis with major radius R - r: it/// needs R - r > r, so a 8 mm hole takes radii under 2 mm.</summary>[Fact]@@ -106,6 +134,8 @@ public sealed class UniformRoundingRouteTests[InlineData("bushing-rounded", 1, 3, 3, 6, 0, 0, 6)][InlineData("counterbore-rounded", 1, 7, 14, 4, 8, 0, 16)][InlineData("blind-hole-rounded", 0.5, 7, 13, 2, 8, 0, 14)]+ // Strips running on into each other where flat and curved walls meet tangentially.+ [InlineData("rounded-rect-rounded", 1, 6, 12, 8, 0, 0, 16)]public void CircularEdges_RoundToTori(string name, double radius, int planes, int cylinders, int tori, int spheres, int cones, int edges){var built = FirmamentBuildAndExport.CompileSource(File.ReadAllText(Path.Combine(Root(), "fixtures/Regression/UniformRounding", name + ".firmament")));diff --git a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.csindex 19bec8d2..56b297de 100644--- a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs+++ b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs@@ -292,20 +292,26 @@ public static partial class FirmamentBuildAndExportvar canonicalParseWatch = System.Diagnostics.Stopwatch.StartNew();var v2Parse = FirmamentV2Parser.Parse(sourceText, sourceDirectory, null, explicitSchema, resources);canonicalParseWatch.Stop();- // Fillet every edge on a body the dedicated Box/Polyhedron route does not take (the source fails only- // because of the finish: without it, it parses): build the body without the finish, then round it whole,- // or refuse with the rounding's reason, at the finish.- if (!v2Parse.IsSuccess && UniformRoundingRoute.Find(sourceText) is { } rounding- && FirmamentV2Parser.Parse(rounding.Stripped, sourceDirectory, null, explicitSchema, resources).IsSuccess)- {- // The source as written does not parse (the stock route refuses the finish), so the admitted document- // (bodies, assertions) is the one without it; assertions then measure the rounded body.+ // Fillet every edge on a body no dedicated route takes: the source fails only because of the finish (without+ // it, it parses), or it parses but the edge-finish lowering refuses the whole-body selector. Build the body+ // without the finish, then round it whole, or refuse with the rounding's reason, at the finish. The+ // dedicated Box/Polyhedron builder keeps its own refusals (UniformFillet...).+ KernelResult<FirmamentStepExportResult> Round(UniformRoundingRoute.Request rounding)+ {+ // The admitted document (bodies, assertions) is the one without the finish; assertions then measure the+ // rounded body.var rounded = UniformRoundingRoute.Export(rounding, stripped => ExportSource(stripped, sourceDirectory, allowV1Compatibility, explicitSchema, resources));return rounded.IsSuccess && rounded.Value.RuntimeAdmissionDocument is null && ParseSemanticSource(rounding.Stripped, sourceDirectory).Document is { } admitted? KernelResult<FirmamentStepExportResult>.Success(rounded.Value with { RuntimeAdmissionDocument = admitted }, rounded.Diagnostics): rounded;}+ if (!v2Parse.IsSuccess && UniformRoundingRoute.Find(sourceText) is { } unparsed+ && FirmamentV2Parser.Parse(unparsed.Stripped, sourceDirectory, null, explicitSchema, resources).IsSuccess)+ return Round(unparsed);var built = ExportAdmittedSource(sourceText, sourceDirectory, allowV1Compatibility, explicitSchema, resources, v2Parse, canonicalParseWatch);+ if (!built.IsSuccess && !built.Diagnostics.Any(d => d.Message.StartsWith("UniformFillet", StringComparison.Ordinal))+ && UniformRoundingRoute.Find(sourceText) is { } unbuilt)+ return Round(unbuilt);if (!built.IsSuccess) return built;var accounting = FirmamentFeatureAccounting.Verify(v2Parse, authoredSource, built.Value);return accounting.IsSuccess ? KernelResult<FirmamentStepExportResult>.Success(accounting.Value, built.Diagnostics) : accounting;diff --git a/docs/development/reports/2026-11/UNIFORM-ROUNDING.md b/docs/development/reports/2026-11/UNIFORM-ROUNDING.mdindex e38fffaa..598d4e38 100644--- a/docs/development/reports/2026-11/UNIFORM-ROUNDING.md+++ b/docs/development/reports/2026-11/UNIFORM-ROUNDING.md@@ -137,3 +137,36 @@ outward, read back by the certificate at r, and Remove(Round(x)) restores x'sfaces and edges. Concave fit sizes are exact: a Ø8 blind hole's floor refusesr = 2.5 "under 2 mm" (major radius R − r must exceed r). `ell-mixed-corner`refuses at the inner corner.++## Stage 3: tangent junctions and mixed corners++Every vertex gets a plan with one ball centre: kept; a sphere corner; a strip+end (one rounded edge whose strip runs square into the face across, which+takes the ball's cross-section into its loop where the vertex was); or a+junction (two rounded edges meeting where their other faces join tangentially,+sharing one cross-section; the tangent edge is trimmed to the ball's contact).+Edges a pass leaves alone, tangent or sharp, are trimmed to wherever their+ends went. Section directions come from their own ends, so the kinds compose.++Mixed corners (one concave edge, convex others): two passes, fillets before+rounds. Pass 1 fills only concave edges: at the mixed corner the fill ends+square on the top face, leaving a convex arc and a tangent junction. Pass 2+rounds everything still sharp on that body, whose orientation is trusted+(this construction built it, with explicit boundary roles). The other order+is not exact (crossing strips meet in an ellipse), so there is no competing+interpretation to judge: the order is a rule. Two concave edges with a convex+one stay refused; rounding the odd edge first would work there too, but the+same edge's far end would then become a rolled corner instead of a sphere, a+real choice of geometry left for when it is wanted.++The route also takes AllEdges fillets that parse but that the edge-finish+lowering refuses (Compose bodies), leaving the dedicated stock builder's own+refusals alone.++Results: `rounded-rect-rounded` (8 cylinder strips, 8 tori, no corners),+`ell-rounded` (the concave fill, 17 convex strips, 2 tori of major radius 2r+over the fill's ends, 10 spheres) build through the CLI, mesh watertight and+outward, read back at r, and Remove(Round(x)) restores x's faces and edges.+Refused by name: `boss-mixed-corner` (two concave and one convex at each foot+corner), `pocket-split-face` (the composed plate's walls are split in two+coplanar faces at the pocket's depth: needs a coplanar-face merge first).diff --git a/docs/public/firmament/geometry.md b/docs/public/firmament/geometry.mdindex 54758a4f..8abeb928 100644--- a/docs/public/firmament/geometry.md+++ b/docs/public/firmament/geometry.md@@ -6,10 +6,12 @@ For exact regular solids, ellipsoids and the bounded whole-stock fillet, seestock, and of other bodies whose faces are planes, cylinders and cones:extruded polygons and line-and-arc profiles, cylinders, frustums, revolvedstepped parts, blocks with through, blind and counterbored holes. Convex edges-are rounded off and concave edges filled in. The body is built without the-finish and then rounded whole. Spline and elliptical edges, tangent junctions,-corners where convex and concave edges meet, and corners where more than three-edges meet on a curved body are refused at the finish with what was found.+are rounded off and concave edges filled in, including where flat and curved+walls meet tangentially and where a concave edge meets convex ones (the inner+corner of an L). The body is built without the finish and then rounded whole.+Spline and elliptical edges, corners where two concave edges meet a convex one,+faces split in two along a plane, and corners where more than three edges meet+on a curved body are refused at the finish with what was found.Ellipsoid BRep export uses exact rational quadratic patches and reimports them asnative exact quadrics. STEP also defines an [`ELLIPSOID` CSG primitive](https://www.steptools.com/docs/stp_aim/html/t_ellipsoid.html);diff --git a/docs/public/reference/diagnostics.md b/docs/public/reference/diagnostics.mdindex 95053854..ab58b4e1 100644--- a/docs/public/reference/diagnostics.md+++ b/docs/public/reference/diagnostics.md@@ -130,7 +130,7 @@ Common recovery patterns:| `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. A body that is not Box or Polyhedron stock is built first and rounded whole, which reports `firmament-uniform-rounding` instead; this code remains for chamfers, several AllEdges finishes and `validate --parse-only`. |-| `firmament-uniform-rounding` | Rounding every edge of the built body was refused; the message names why. `uniform-rounding-spline-edge-unsupported` / `-elliptical-edge-unsupported`: the body has those edges (count and ids given); use a local `EdgeFinish` on the edges you need. `-mixed-vertex-unsupported`: the named corner joins convex and concave edges. `-tangent-edge-unsupported`: the named faces meet tangentially. `-curved-face-unsupported`: a face is not a plane, cylinder or cone. `-edge-unsupported` / `-vertex-unsupported`: the named edge's faces do not share its line or axis, or the named corner joins other than three edges. `-radius-too-large` / `-radius-consumes-faces`: the message says what the radius used up or where the ball reached another face; use a radius below the one reported. |+| `firmament-uniform-rounding` | Rounding every edge of the built body was refused; the message names why. `uniform-rounding-spline-edge-unsupported` / `-elliptical-edge-unsupported`: the body has those edges (count and ids given); use a local `EdgeFinish` on the edges you need. `-mixed-vertex-unsupported`: the named corner joins two concave edges and a convex one (a boss's foot corner). `-split-face-unsupported`: the named faces lie on one plane (a face split in two by its construction). `-curved-face-unsupported`: a face is not a plane, cylinder or cone. `-edge-unsupported` / `-vertex-unsupported`: the named edge's faces do not share its line or axis, or the named corner joins other than three edges. `-radius-too-large` / `-radius-consumes-faces`: the message says what the radius used up or where the ball reached another face; use a radius below the one reported. || `UniformFilletRadiusTooLarge` | Reduce the radius below the reported stock inradius; this construction requires positive remaining planar faces and edge spans. || `drawing-pmi-target-unlocated` | The PMI needs a geometric face association. Automatic generation refuses a model-center leader. || `drawing-pmi-value-unavailable` | Supply an admitted finite PMI nominal/depth; a missing measure is not interpreted as zero. |diff --git a/docs/public/reference/language/solids-and-features.md b/docs/public/reference/language/solids-and-features.mdindex 90e31dc5..edbc4f9e 100644--- a/docs/public/reference/language/solids-and-features.md+++ b/docs/public/reference/language/solids-and-features.md@@ -171,14 +171,19 @@ The details that trip people up:cylinder's rim, a hole's rim, an arc in an extruded profile) a torus, and eachcorner a sphere. Faces may be planes, cylinders and cones. Convex edges arerounded off; concave edges (a shoulder, a counterbore's step, a blind hole's- floor) are filled in with the same radius. On convex bodies bounded by planes,- corners where four or more faces meet unevenly open into short strips, as a- rolled ball would leave them; on curved bodies each corner must join three- edges. Not supported yet: spline or elliptical edges (common on imported parts- and on planes cut at an angle through cylinders), faces meeting tangentially,- and corners where convex and concave edges meet (the inner corner of an- L-shaped extrusion, a rectangular pocket's rim); each is refused at the- finish, naming the edges or corner found. A radius that does not fit, for+ floor) are filled in with the same radius. Where flat and curved walls meet+ tangentially (a rounded-rectangle extrusion) the strips run on into each+ other. Where one concave edge meets convex ones (the inner corner of an+ L-shaped extrusion) the concave edge is filled first and then rounded over,+ as fillets before rounds. On convex bodies bounded by planes, corners where+ four or more faces meet unevenly open into short strips, as a rolled ball+ would leave them; on curved bodies each corner must join three edges. Not+ supported yet: spline or elliptical edges (common on imported parts and on+ planes cut at an angle through cylinders), corners where two concave edges+ meet a convex one (a boss's foot corner), and faces split in two along one+ plane (some compositions leave a pocketed plate's walls split at the pocket's+ depth); each is refused at the finish, naming the edges, corner or faces+ found. A radius that does not fit, forinstance one whose ball would reach a nearby hole or a small hole's axis, isrefused with the largest that does. Assertions measure the rounded body. Anall-edge chamfer is refused.diff --git a/docs/public/reference/supported-features.md b/docs/public/reference/supported-features.mdindex 3051b99a..563e5c6d 100644--- a/docs/public/reference/supported-features.md+++ b/docs/public/reference/supported-features.md@@ -6,7 +6,7 @@|---|---|---|| 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 || Drawing generation | Bounded | Complete nominal PDF/SVG/editable PPTX for rectangular plates/boxes with disjoint Z-through holes: stock/thickness dimensions, coordinate schedule and grouped limits. Explicit reference-only mode for incomplete PMI views; no process-capability or manufacturing-release claim. Authored Assembly drawings remain available. See [drawings](../drawings.md). |-| Uniform fillet (all edges) | Bounded | `EdgeFinish<Fillet> { target: AllEdges; radius: ... }` on untouched Box or regular Polyhedron stock, and on any other body of plane, cylinder and cone faces: line edges become cylinder strips, circular edges tori, corners spheres, convex edges rounded off and concave ones filled, exact. Spline, elliptical and tangent edges, and corners joining convex with concave edges, reject by name; a radius that does not fit rejects with the largest that does. |+| Uniform fillet (all edges) | Bounded | `EdgeFinish<Fillet> { target: AllEdges; radius: ... }` on untouched Box or regular Polyhedron stock, and on any other body of plane, cylinder and cone faces: line edges become cylinder strips, circular edges tori, corners spheres, convex edges rounded off and concave ones filled, exact, including tangent wall junctions and corners where one concave edge meets convex ones. Spline and elliptical edges, corners where two concave edges meet a convex one, and split faces reject by name; a radius that does not fit rejects with the largest that does. || 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 face rim | Bounded | A whole-face Boundary chamfer or fillet on any principal face of unmodified Box stock. One complete +Z rim can also retain disjoint ThroughAll shaft/counterbore/countersink holes. Intersecting holes/finish bands, other combined selectors and general feature chains remain unsupported. Constant native-XY Profile stock with disjoint through round holes supports either cap's rim, including rounded corners. See [fillets and chamfers](../firmament/fillet-profiles.md). || 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/UniformRounding/README.md b/fixtures/Regression/UniformRounding/README.mdindex 94d496cb..98ca0374 100644--- a/fixtures/Regression/UniformRounding/README.md+++ b/fixtures/Regression/UniformRounding/README.md@@ -8,8 +8,11 @@ rims round to tori next to the block's cylinder strips and sphere corners) andcylinder down each line-to-arc edge, spheres at the four corners). With concaveedges filled in: `bushing-rounded` (a revolved stepped bushing: the shoulder'sinner corner is a concave torus), `counterbore-rounded` (the step's corner) and-`blind-hole-rounded` (the floor's corner). `ell-mixed-corner` is refused: its-inner corner joins a concave edge with convex ones.+`blind-hole-rounded` (the floor's corner). `rounded-rect-rounded` runs strips on+into each other where flat and arc walls meet tangentially; `ell-rounded` fills+the L's concave inner edge first and rounds over it. Refused by name:+`boss-mixed-corner` (two concave edges and a convex one at each foot corner) and+`pocket-split-face` (the composed plate's walls are split at the pocket's depth).The Firmament UniformRoundingRoute tests build them; the BlendNetworkRemovalexperiments remove the rounding again.diff --git a/fixtures/Regression/UniformRounding/boss-mixed-corner.firmament b/fixtures/Regression/UniformRounding/boss-mixed-corner.firmamentnew file mode 100644index 00000000..019b3d0a--- /dev/null+++ b/fixtures/Regression/UniformRounding/boss-mixed-corner.firmament@@ -0,0 +1,17 @@+Model Composed {+ Units: mm+Concept Path StockOutline { Start: Point2(-30.0mm,-20.0mm) Heading: 0deg Line Bottom { Length: 60mm } Line Right { Turn: 90deg; Length: 40mm } Line Top { Turn: 90deg; Length: 60mm } Close Left }+Profile Stock From StockOutline+Concept Path PadOutline { Start: Point2(-12.0mm,-10.0mm) Heading: 0deg Line Bottom { Length: 24mm } Line Right { Turn: 90deg; Length: 20mm } Line Top { Turn: 90deg; Length: 24mm } Close Left }+Profile Pad From PadOutline+Concept Path CrownOutline { Start: Point2(-6.0mm,-5.0mm) Heading: 0deg Line Bottom { Length: 12mm } Line Right { Turn: 90deg; Length: 10mm } Line Top { Turn: 90deg; Length: 12mm } Close Left }+Profile Crown From CrownOutline+Concept Path RecessOutline { Start: Point2(-8.0mm,-6.0mm) Heading: 0deg Line Bottom { Length: 16mm } Line Right { Turn: 90deg; Length: 12mm } Line Top { Turn: 90deg; Length: 16mm } Close Left }+Profile Recess From RecessOutline+Struct Part { Compose Body { Base Stock { Profile: Stock; From: 0mm; To: 12mm; Role: Stock }+Boss Pad { On: Top; Profile: Pad; Height: 5mm }+Boss Crown { On: Top; Profile: Crown; Height: 4mm }+ } }++Modify Part { EdgeFinish<Fillet> Round { target: AllEdges; radius: 0.5mm } }+}diff --git a/fixtures/Regression/UniformRounding/ell-mixed-corner.firmament b/fixtures/Regression/UniformRounding/ell-rounded.firmamentsimilarity index 96%rename from fixtures/Regression/UniformRounding/ell-mixed-corner.firmamentrename to fixtures/Regression/UniformRounding/ell-rounded.firmamentindex 618497ab..b155f540 100644--- a/fixtures/Regression/UniformRounding/ell-mixed-corner.firmament+++ b/fixtures/Regression/UniformRounding/ell-rounded.firmament@@ -1,4 +1,4 @@-Model MixedCorner {+Model RoundedEll {units: mmPath Outline {start: Point2(0mm, 0mm)diff --git a/fixtures/Regression/UniformRounding/pocket-split-face.firmament b/fixtures/Regression/UniformRounding/pocket-split-face.firmamentnew file mode 100644index 00000000..a2fadc71--- /dev/null+++ b/fixtures/Regression/UniformRounding/pocket-split-face.firmament@@ -0,0 +1,22 @@+Concept Struct PocketLayout On XY {+ Point2 A { Position: [-10mm, -10mm] } Point2 B { Position: [10mm, -10mm] } Point2 C { Position: [10mm, 10mm] } Point2 D { Position: [-10mm, 10mm] }+ Point2 E { Position: [-4mm, -4mm] } Point2 F { Position: [4mm, -4mm] } Point2 G { Position: [4mm, 4mm] } Point2 H { Position: [-4mm, 4mm] }+ Line2 AB { From: A; To: B } Line2 BC { From: B; To: C } Line2 CD { From: C; To: D } Line2 DA { From: D; To: A }+ Line2 EF { From: E; To: F } Line2 FG { From: F; To: G } Line2 GH { From: G; To: H } Line2 HE { From: H; To: E }+}+Profile Plate Using PocketLayout { Loop Outer {+ AB+ |> BC+ |> CD+ |> DA+ |> Close+ } }+Profile Pocket Using PocketLayout { Loop Outer {+ EF+ |> FG+ |> GH+ |> HE+ |> Close+ } }+Struct Pocket { Compose Body { Base PrimaryPlate { Profile: Plate; From: 0mm; To: 10mm; Role: Stock } Remove TopPocket { Profile: Pocket; From: 7mm; To: 10mm; Role: Relief } } }+Modify Pocket { EdgeFinish<Fillet> Round { target: AllEdges; radius: 0.5mm } }diff --git a/fixtures/Regression/UniformRounding/rounded-rect-rounded.firmament b/fixtures/Regression/UniformRounding/rounded-rect-rounded.firmamentnew file mode 100644index 00000000..dc342bc6--- /dev/null+++ b/fixtures/Regression/UniformRounding/rounded-rect-rounded.firmament@@ -0,0 +1,18 @@+Model RoundedRect {+ units: mm+ Path Outline {+ start: Point2(6mm, 0mm)+ heading: 0deg+ Line South { length: 28mm }+ Arc SE { turn: 90deg; radius: 6mm }+ Line East { length: 13mm }+ Arc NE { turn: 90deg; radius: 6mm }+ Line North { length: 28mm }+ Arc NW { turn: 90deg; radius: 6mm }+ Line West { length: 13mm }+ Arc SW { turn: 90deg; radius: 6mm }+ }+ Profile Section from Outline+ Struct Body { Extrude Stock { profile: Section; from: 0mm; to: 10mm } }+ Modify Body { EdgeFinish<Fillet> Round { target: AllEdges; radius: 1mm } }+}