Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Kernel: exact offset cylinder intersections; fillets cut off by a tangent wall. CTC-01 complete (85/85)

Claude6b393ca2f916
diff --git a/Aetheris.CLI.Tests/ShapeComparisonCliTests.cs b/Aetheris.CLI.Tests/ShapeComparisonCliTests.cs
index d46b2f69..ea348cfe 100644
--- a/Aetheris.CLI.Tests/ShapeComparisonCliTests.cs
+++ b/Aetheris.CLI.Tests/ShapeComparisonCliTests.cs
@@ -1,5 +1,6 @@
using System.Text.Json;
using Aetheris.CLI;
+using Aetheris.Kernel.Core.Step242;
namespace Aetheris.CLI.Tests;
@@ -47,20 +48,38 @@ public sealed class ShapeComparisonCliTests
}
[Fact]
- public void Ctc01ReconstructionMatchesTheOriginalExceptForKnownLanguageGaps()
+ public void Ctc01ReconstructionMatchesTheOriginal()
{
var result = StepShapeComparison.Compare(Ctc01Original, Ctc01.Value);
-
- // Everything the reconstruction builds is on the original's surfaces.
+ // Every analytic surface of the original, and nothing else.
+ Assert.Empty(result.Carriers.MissingFromCandidate);
Assert.Empty(result.Carriers.ExtraInCandidate);
- Assert.True(result.Overlap.IntersectionOverUnion >= 0.999, $"IoU {result.Overlap.IntersectionOverUnion}");
- Assert.True(result.Carriers.MatchedCarrierCount >= 81, $"matched {result.Carriers.MatchedCarrierCount}");
+ Assert.Equal(85, result.Carriers.MatchedCarrierCount);
+ Assert.True(result.Overlap.IntersectionOverUnion >= 0.99995, $"IoU {result.Overlap.IntersectionOverUnion}");
+ }
- // What is missing is exactly the features Firmament cannot yet express (see the fixture's header).
- // Closing one of these gaps shrinks this list; a new kind of discrepancy fails here.
- foreach (var carrier in result.Carriers.MissingFromCandidate)
+ [Fact]
+ public void Ctc01LugRootFilletsEndOnTheWaistAlongTheExactCylinderIntersection()
+ {
+ var import = Step242Importer.ImportBody(File.ReadAllText(Ctc01.Value));
+ Assert.True(import.IsSuccess);
+ var body = import.Value;
+ var splines = body.Topology.Edges.Select(e => body.Bindings.TryGetEdgeBinding(e.Id, out var b) && body.Geometry.TryGetCurve(b.CurveGeometryId, out var c) ? c?.BSpline3 : null)
+ .OfType<Aetheris.Kernel.Core.Geometry.Curves.BSpline3Curve>().ToArray();
+ // One cut per lug, where its root fillet meets the R25 waist.
+ Assert.Equal(4, splines.Length);
+ foreach (var spline in splines)
{
- Assert.True(IsLugUndersideFillet(carrier), $"Unexpected missing carrier: {carrier.Description}");
+ var (t0, t1) = (spline.KnotValues[0], spline.KnotValues[^1]);
+ var start = spline.Evaluate(t0);
+ // The waist centre and the fillet's axis, by symmetry from the lug's quadrant.
+ var (sx, sy) = (double.Sign(start.X), double.Sign(start.Y));
+ for (var i = 0; i <= 200; i++)
+ {
+ var p = spline.Evaluate(t0 + (t1 - t0) * i / 200);
+ Assert.Equal(25d, double.Hypot(p.X - sx * 225, p.Y - sy * 150), 6);
+ Assert.Equal(10d, double.Hypot(p.X - sx * 240, p.Z + 60), 6);
+ }
}
}
@@ -108,10 +127,6 @@ public sealed class ShapeComparisonCliTests
Assert.True(shape.GetProperty("overlap").GetProperty("candidateOnlyVolume").GetDouble() > 0);
}
- private static bool IsLugUndersideFillet(StepShapeComparison.CarrierGroup c)
- => c.Kind == "Cylinder" && c.Description.Contains("r=10 ", StringComparison.Ordinal)
- && c.BoundsMin is { } lo && c.BoundsMax is { } hi && lo[2] >= -60.01 && hi[2] <= -49.99;
-
private static string Build(string fixture)
{
var directory = Path.Combine(Path.GetTempPath(), "aetheris-shape-compare", Guid.NewGuid().ToString("N"));
diff --git a/Aetheris.Kernel.Core.Tests/Geometry/CylinderCylinderIntersectionCurveTests.cs b/Aetheris.Kernel.Core.Tests/Geometry/CylinderCylinderIntersectionCurveTests.cs
index 216086cf..b81ca940 100644
--- a/Aetheris.Kernel.Core.Tests/Geometry/CylinderCylinderIntersectionCurveTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Geometry/CylinderCylinderIntersectionCurveTests.cs
@@ -171,6 +171,77 @@ public sealed class CylinderCylinderIntersectionCurveTests
Point3D.Origin, CylinderIntersectionBranch.PositiveCutterAxis, domain).Diagnostics[0].Source);
}
+ // CTC-01's lug root fillet (R10, axis +Y through x = -240, z = -60) cut off by an R25 waist wall (axis +Z through
+ // x = -225, y = 150). The fillet's wall x = -250 is tangent to the waist at y = 150, so the cutter touches the host
+ // from inside: the curve runs from that touching point (t = 0) to the fillet's floor contact (t = pi/2).
+ private static CylinderCylinderIntersectionCurve LugRootEnd(double toolRadius = 10d, double toolX = -240d) =>
+ CylinderCylinderIntersectionCurve.CreateOffset(
+ new CylinderSurface(new Point3D(-225, 150, -50), Z, 25d, X),
+ new CylinderSurface(new Point3D(toolX, 0, -60), Y, toolRadius, Z),
+ CylinderIntersectionBranch.NegativeCutterAxis, new ParameterInterval(0d, double.Pi / 2d)).Value;
+
+ [Fact]
+ public void OffsetTouchingCutter_RunsExactlyFromTheTouchingPointToTheFloor()
+ {
+ var curve = LugRootEnd();
+ Assert.Equal(15d, double.Abs(curve.Offset), 12);
+ Assert.True((curve.Evaluate(0d) - new Point3D(-250, 150, -60)).Length < 1e-12);
+ Assert.True((curve.Evaluate(double.Pi / 2d) - new Point3D(-240, 130, -50)).Length < 1e-12);
+ for (var i = 0; i <= 1024; i++)
+ {
+ var p = curve.Evaluate(double.Pi / 2d * i / 1024d);
+ Assert.True(double.Abs(double.Hypot(p.X + 225, p.Y - 150) - 25d) < 1e-12, $"off the waist at {p}");
+ Assert.True(double.Abs(double.Hypot(p.X + 240, p.Z + 60) - 10d) < 1e-12, $"off the fillet at {p}");
+ // The fillet side of the waist: between the wall and the floor contact, short of the touching line.
+ Assert.InRange(p.Y, 130d - 1e-9, 150d + 1e-9);
+ }
+ }
+
+ [Fact]
+ public void OffsetDerivative_AgreesWithCenteredDifference_IncludingAtTheTouchingPoint()
+ {
+ const double h = 1e-6d;
+ foreach (var curve in new[] { LugRootEnd(), LugRootEnd(toolRadius: 6d, toolX: -238d) })
+ foreach (var t in new[] { h, 0.01d, 0.4d, 1.2d, double.Pi / 2d - h })
+ {
+ var difference = (curve.Evaluate(t + h) - curve.Evaluate(t - h)) / (2d * h);
+ Assert.True((difference - curve.Derivative(t)).Length < 1e-7d, $"t={t}: {difference} vs {curve.Derivative(t)}");
+ }
+ // At the touching point itself the derivative is finite: the curve is analytic through it.
+ Assert.True(double.IsFinite(LugRootEnd().Derivative(0d).Length));
+ }
+
+ [Theory]
+ [InlineData(10d, -240d)] // touching from inside
+ [InlineData(6d, -238d)] // strictly inside the silhouette (|e| + r = 19 < 25)
+ public void OffsetRealization_IsCertifiedAgainstTheExactCurve(double toolRadius, double toolX)
+ {
+ var curve = LugRootEnd(toolRadius, toolX);
+ var realized = CylinderIntersectionCurveRealizer.Realize(curve, ToleranceContext.Default);
+ Assert.True(realized.IsSuccess, string.Join("; ", realized.Diagnostics.Select(d => d.Message)));
+ var result = realized.Value;
+ Assert.True(result.CertifiedDeviationBoundMm <= ToleranceContext.Default.Linear);
+ var observed = 0d;
+ for (var i = 0; i <= 4096; i++)
+ {
+ var t = double.Pi / 2d * i / 4096d;
+ var deviation = (result.Curve.Evaluate(t) - curve.Evaluate(t)).Length;
+ observed = double.Max(observed, deviation);
+ Assert.True(deviation <= result.CertifiedDeviationBoundMm + 1e-12d, $"t={t}: {deviation} > {result.CertifiedDeviationBoundMm}");
+ }
+ _output.WriteLine($"r={toolRadius} segments={result.SegmentCount} boundMm={result.CertifiedDeviationBoundMm:G6} sampledMaxMm={observed:G6}");
+ }
+
+ [Fact]
+ public void OffsetCutterReachingOutsideTheHost_IsRefused()
+ {
+ var result = CylinderCylinderIntersectionCurve.CreateOffset(
+ new CylinderSurface(new Point3D(-225, 150, -50), Z, 25d, X),
+ new CylinderSurface(new Point3D(-245, 0, -60), Y, 10d, Z),
+ CylinderIntersectionBranch.NegativeCutterAxis, new ParameterInterval(0d, double.Pi / 2d));
+ Assert.Contains("TangentOrOversize", result.Diagnostics[0].Source);
+ }
+
private static CylinderCylinderIntersectionCurve Create(double hostRadius, double toolRadius, CylinderIntersectionBranch branch)
{
var host = new CylinderSurface(Point3D.Origin, Z, hostRadius, X);
diff --git a/Aetheris.Kernel.Core/Brep/Blends/LocalRounding.cs b/Aetheris.Kernel.Core/Brep/Blends/LocalRounding.cs
index dbfee39c..cbf2d40a 100644
--- a/Aetheris.Kernel.Core/Brep/Blends/LocalRounding.cs
+++ b/Aetheris.Kernel.Core/Brep/Blends/LocalRounding.cs
@@ -115,20 +115,24 @@ internal static class LocalRounding
}
}
- /// <summary>An edge's shape from its start to its end: a segment, an arc about a normal (right-handed), or a
- /// quarter ellipse about <see cref="Mitre"/> whose two semi-axes run to its ends (a mitre between two strips).</summary>
- private sealed record Shape(Point3D Start, Point3D End, Point3D? Center, Vector3D Normal, double Sweep, Point3D? Mitre = null)
+ /// <summary>An edge's shape from its start to its end: a segment, an arc about a normal (right-handed), a
+ /// quarter ellipse about <see cref="Mitre"/> whose two semi-axes run to its ends (a mitre between two strips), or
+ /// an exact cylinder intersection over its whole domain (<see cref="Certified"/>: a strip cut off by a wall).</summary>
+ private sealed record Shape(Point3D Start, Point3D End, Point3D? Center, Vector3D Normal, double Sweep, Point3D? Mitre = null,
+ QualifiedCylinderIntersectionRepresentation? Certified = null)
{
public bool Arc => Center is not null;
- public Point3D At(double t) => Mitre is { } m
+ public Point3D At(double t) => Certified is { } c
+ ? c.Authority.Evaluate(c.Authority.Domain.Start + (c.Authority.Domain.End - c.Authority.Domain.Start) * t)
+ : Mitre is { } m
? m + (Start - m) * double.Cos(t * double.Pi / 2) + (End - m) * double.Sin(t * double.Pi / 2)
: !Arc ? Start + (End - Start) * t : Rotate(Start, Center!.Value, Normal, Sweep * t);
public Vector3D Tangent(Point3D p) => !Arc ? Unit(End - Start) : Unit(Normal.Cross(p - Center!.Value));
public IEnumerable<Point3D> Points(int arcSegments) =>
- Arc || Mitre is not null ? Enumerable.Range(0, arcSegments + 1).Select(i => At(i / (double)arcSegments)) : [Start, End];
+ Arc || Mitre is not null || Certified is not null ? Enumerable.Range(0, arcSegments + 1).Select(i => At(i / (double)arcSegments)) : [Start, End];
}
/// <summary>Which edges a pass rounds: every sharp edge, or only the concave ones (the first pass where convex
@@ -146,8 +150,8 @@ internal static class LocalRounding
{
public required Edge Edge { get; init; }
public required Shape Shape { get; init; }
- public required Support A { get; init; }
- public required Support B { get; init; }
+ public required Support A { get; set; }
+ public required Support B { get; set; }
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).
@@ -158,7 +162,7 @@ internal static class LocalRounding
public Point3D Centre { get; set; }
}
- private enum VertexKind { Untouched, Corner, End, Junction, Mitre }
+ private enum VertexKind { Untouched, Corner, End, Junction, Mitre, Wall }
/// <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
@@ -176,6 +180,11 @@ internal static class LocalRounding
// Mitre: where the kept edge leaves the strips (one ball radius off the common face).
public Point3D Touch { get; init; }
public double Radius { get; init; }
+ // Wall: the strip's floor contact where the wall cuts it off (Touch is its wall contact), and the exact
+ // curve along which the wall cuts the strip.
+ public Point3D Reach { get; init; }
+ public FaceId Floor { get; init; }
+ public QualifiedCylinderIntersectionRepresentation? Cut { get; init; }
}
/// <summary>Every sharp edge rounded, in one pass, or in two where convex and concave edges meet at a corner:
@@ -290,6 +299,7 @@ internal static class LocalRounding
// 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: tangent
+ var split = new List<EdgeId>();
foreach (var (edgeId, (f0, f1)) in pairs)
{
var edge = topology.GetEdge(edgeId); var shape = shapes[edgeId];
@@ -302,7 +312,10 @@ internal static class LocalRounding
var (na, nb) = (a.Outward(p), b.Outward(p));
if (na.Cross(nb).Length < 1e-7 && na.Dot(nb) > 0)
{
- // A selective rounding leaves every edge it was not asked for alone, split faces included.
+ // A selective rounding merges a face split in two on one plane (some constructions cut a wall where
+ // another operation's outline meets it) back into one face: the edge between them is not an edge of
+ // the part, and a strip ending there must see the whole wall.
+ if (pass == Pass.Selected && a.Kind == SurfaceGeometryKind.Plane && b.Kind == SurfaceGeometryKind.Plane) { split.Add(edgeId); continue; }
if (pass == Pass.Selected) { kept.Add(edgeId, (f0, f1, 0)); continue; }
// 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.
@@ -328,6 +341,7 @@ internal static class LocalRounding
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, A = a, B = b, Side = side, Radius = radius });
}
+ if (split.Count > 0 && Merge(topology, split, supports, oriented, shapes, sharp, kept, boundaries) is { } unmerged) return Refuse("uniform-rounding-edge-unsupported", unmerged);
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];
@@ -335,7 +349,7 @@ internal static class LocalRounding
var plans = new Dictionary<VertexId, Plan>();
foreach (var vertex in topology.Vertices.OrderBy(v => v.Id.Value))
{
- var open = topology.Edges.Where(e => (e.StartVertexId == vertex.Id || e.EndVertexId == vertex.Id) && e.StartVertexId != e.EndVertexId && !seams.ContainsKey(e.Id)).ToArray();
+ var open = topology.Edges.Where(e => (e.StartVertexId == vertex.Id || e.EndVertexId == vertex.Id) && e.StartVertexId != e.EndVertexId && !seams.ContainsKey(e.Id) && shapes.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; }
@@ -410,6 +424,22 @@ internal static class LocalRounding
plans.Add(vertex.Id, new Plan { Kind = VertexKind.Mitre, Centre = centre.Value, Faces = [floor, walls[0], walls[1]], Rounded = rounded, Side = side, Touch = touch, Radius = r });
continue;
}
+ if (pass == Pass.Selected && rounded.Length == 1 && others.Length == 2 && faces.Length == 3
+ && others.Count(e => kept[e].Side == 0) == 1 && others.Count(e => kept[e].Side != 0) == 1)
+ {
+ // A strip whose floor runs out into a curved wall standing square to it, tangent to the strip's own
+ // wall: the wall carried down through the strip cuts it off (the wall's face grows over the strip's
+ // end), along the exact intersection of the strip's cylinder with the wall's.
+ var s = sharp[rounded[0]];
+ var across = faces.Single(f => f != s.A.Face && f != s.B.Face);
+ var tangentEdge = others.Single(e => kept[e].Side == 0);
+ var wall = kept[tangentEdge].F0 == across ? kept[tangentEdge].F1 : kept[tangentEdge].F0;
+ var floor = wall == s.A.Face ? s.B.Face : s.A.Face;
+ var plan = WallEnd(vertex.Id, s, supports[floor], supports[wall], supports[across], shapes[tangentEdge], points, side, r, tol, out var why);
+ if (plan is null) return Refuse("uniform-rounding-vertex-unsupported", $"vertex {vertex.Id.Value} joins edges {joins}: {why}");
+ plans.Add(vertex.Id, plan);
+ continue;
+ }
if (sides.Length > 1)
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)"
@@ -462,7 +492,12 @@ internal static class LocalRounding
|| shape.Arc && shape.Sweep <= 1e-9)
throw new Degenerate();
var edge = builder.AddEdge(a, b); var id = new CurveGeometryId(geometry.Curves.Count() + 1);
- if (shape.Mitre is { } m)
+ if (shape.Certified is { } certified)
+ {
+ geometry.AddCurve(id, CurveGeometry.FromCertifiedIntersection(certified));
+ bindings.AddEdgeBinding(new(edge, id, certified.Authority.Domain));
+ }
+ else if (shape.Mitre is { } m)
{
// A quarter ellipse whose semi-axes run from the centre to the two ends; the longer one is the major.
var (u, v) = (shape.Start - m, shape.End - m);
@@ -529,6 +564,10 @@ internal static class LocalRounding
case VertexKind.End:
foreach (var face in plan.Faces.Take(2)) contact.Add((vertex, face), NewVertex(supports[face].Foot(plan.Centre)));
break;
+ case VertexKind.Wall:
+ contact.Add((vertex, plan.Floor), NewVertex(plan.Reach));
+ contact.Add((vertex, plan.Faces[0] == plan.Floor ? plan.Faces[1] : plan.Faces[0]), NewVertex(plan.Touch));
+ break;
case VertexKind.Mitre:
contact.Add((vertex, plan.Faces[0]), NewVertex(supports[plan.Faces[0]].Foot(plan.Centre)));
var touches = NewVertex(plan.Touch);
@@ -588,6 +627,14 @@ internal static class LocalRounding
var joined = plans[vertex].Kind is VertexKind.Junction or VertexKind.Mitre;
if (joined && 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)]);
+ if (plans[vertex].Cut is { } exact)
+ {
+ // The wall's cut runs its own way: start at whichever contact its domain starts at.
+ var forward = (exact.Authority.Evaluate(exact.Authority.Domain.Start) - positions[a]).Length < (exact.Authority.Evaluate(exact.Authority.Domain.Start) - positions[b]).Length;
+ var (from, to) = forward ? (a, b) : (b, a);
+ section.Add((s.Edge.Id, vertex), NewEdge(from, to, new Shape(positions[from], positions[to], null, Vector3D.Zero, 0, Certified: exact)));
+ continue;
+ }
var cut = NewEdge(a, b, plans[vertex].Kind == VertexKind.Mitre
? new Shape(positions[a], positions[b], null, Vector3D.Zero, 0, centre)
: Cross(positions[a], positions[b], centre, shape.Tangent(shape.Arc ? Project(centre, shape) : centre)));
@@ -682,9 +729,9 @@ internal static class LocalRounding
// 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))
+ foreach (var face in topology.Faces.Where(f => supports.ContainsKey(f.Id)).OrderBy(f => f.Id.Value))
{
- var ends = plans.Where(p => p.Value.Kind == VertexKind.End && p.Value.Faces[2] == face.Id)
+ var ends = plans.Where(p => p.Value.Kind is VertexKind.End or VertexKind.Wall && 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])
@@ -740,6 +787,120 @@ internal static class LocalRounding
: Refuse("uniform-rounding-build-failed", string.Join("; ", validation.Diagnostics.Select(d => d.Message)));
}
+ /// <summary>
+ /// Merges faces split on one plane into one face across their split edges: the lowest face id of each group
+ /// stands for it, its loops are its members' uses without the split edges, re-chained, and every edge and blend
+ /// refers to it. All members share the plane and its outward side, so their walking directions agree. Returns
+ /// why it could not, or null.
+ /// </summary>
+ private static string? Merge(TopologyModel topology, List<EdgeId> split, 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<FaceId, Shape[]> boundaries)
+ {
+ var parent = supports.Keys.ToDictionary(f => f, f => f);
+ FaceId Root(FaceId f) { while (parent[f] != f) f = parent[f] = parent[parent[f]]; return f; }
+ var faceOfUse = oriented.SelectMany(x => x.Value.SelectMany(l => l).Select(u => (u.Edge, Face: x.Key))).ToLookup(x => x.Edge, x => x.Face);
+ foreach (var edge in split)
+ {
+ var faces = faceOfUse[edge].Select(Root).Distinct().OrderBy(f => f.Value).ToArray();
+ for (var i = 1; i < faces.Length; i++) parent[faces[i]] = faces[0];
+ }
+ var absorbed = split.ToHashSet();
+ foreach (var group in supports.Keys.GroupBy(Root).Where(g => g.Count() > 1).ToArray())
+ {
+ var root = group.Key;
+ var uses = group.OrderBy(f => f.Value).SelectMany(f => oriented[f].SelectMany(l => l)).Where(u => !absorbed.Contains(u.Edge)).ToList();
+ VertexId From((EdgeId Edge, bool Reversed) u) { var e = topology.GetEdge(u.Edge); return u.Reversed ? e.EndVertexId : e.StartVertexId; }
+ VertexId To((EdgeId Edge, bool Reversed) u) { var e = topology.GetEdge(u.Edge); return u.Reversed ? e.StartVertexId : e.EndVertexId; }
+ var loops = new List<List<(EdgeId, bool)>>();
+ while (uses.Count > 0)
+ {
+ var loop = new List<(EdgeId Edge, bool Reversed)> { uses[0] }; uses.RemoveAt(0);
+ while (From(loop[0]) != To(loop[^1]))
+ {
+ // At a vertex where the merged face's boundary touches itself, keep to the use that turns the
+ // face's interior the same way: the one whose edge is not the reverse of the last.
+ var next = uses.FindIndex(u => From(u) == To(loop[^1]) && u.Edge != loop[^1].Edge);
+ if (next < 0) return $"faces {string.Join(", ", group.Select(f => f.Value))} lie on one plane, but their boundaries do not close once merged";
+ loop.Add(uses[next]); uses.RemoveAt(next);
+ }
+ loops.Add(loop);
+ }
+ foreach (var member in group) { if (member != root) { supports.Remove(member); oriented.Remove(member); boundaries.Remove(member); } }
+ oriented[root] = loops;
+ boundaries[root] = loops.SelectMany(l => l).Select(u => shapes[u.Item1]).ToArray();
+ }
+ foreach (var edge in split) { shapes.Remove(edge); kept.Remove(edge); }
+ foreach (var (edge, k) in kept.ToArray()) kept[edge] = (Root(k.F0), Root(k.F1), k.Side);
+ foreach (var s in sharp.Values) { s.A = supports[Root(s.A.Face)]; s.B = supports[Root(s.B.Face)]; }
+ return null;
+ }
+
+ /// <summary>
+ /// The end of a straight strip (floor and wall planes) where its floor runs out into a cylindrical wall that
+ /// stands square to the floor and is tangent to the strip's wall along <paramref name="tangent"/>. The strip's
+ /// wall contact ends on that tangent line one ball radius off the floor (where the strip touches the cylinder);
+ /// its floor contact ends where it crosses the cylinder; between them the cylinder cuts the strip along an exact
+ /// cylinder-cylinder curve, certified as a B-spline for export.
+ /// </summary>
+ private static Plan? WallEnd(VertexId vertex, Sharp s, Support floor, Support wall, Support across, Shape tangent,
+ Dictionary<VertexId, Point3D> points, double side, double r, double tol, out string why)
+ {
+ why = "";
+ if (s.Shape.Arc || tangent.Arc || floor.Kind != SurfaceGeometryKind.Plane || wall.Kind != SurfaceGeometryKind.Plane || across.Kind != SurfaceGeometryKind.Cylinder)
+ { why = "a strip ends on a wall only along a straight edge between planes, against a cylinder"; return null; }
+ var v = points[vertex];
+ var cylinder = across.Surface.Cylinder!.Value; var axis = cylinder.Axis.ToVector();
+ var nf = floor.Outward(v); var nw = wall.Outward(v);
+ var u = Unit(tangent.End - tangent.Start);
+ if (axis.Cross(nf).Length > 1e-9 || u.Cross(axis).Length > 1e-9)
+ { why = $"the wall face {across.Face.Value} does not stand square to the floor face {floor.Face.Value}"; return null; }
+ // Into the strip from this end, along the rounded edge.
+ var other = s.Edge.StartVertexId == vertex ? s.Shape.End : s.Shape.Start;
+ var d = Unit(other - v); var length = (other - v).Length;
+ // Wall contact: on the tangent line, one radius outside (concave) or inside (convex) the floor.
+ var touch = v + u * (-side * r / u.Dot(nf));
+ var centre = touch - nw * (side * r);
+ // Floor contact: the floor's contact line, where it first meets the cylinder going into the strip.
+ var foot = floor.Foot(centre);
+ var p = foot - cylinder.Origin; p -= axis * p.Dot(axis);
+ var (bq, cq) = (p.Dot(d), p.Dot(p) - cylinder.Radius * cylinder.Radius);
+ var disc = bq * bq - cq;
+ if (disc < 0) { why = "the strip's floor contact never meets the wall"; return null; }
+ var mu = new[] { -bq - double.Sqrt(disc), -bq + double.Sqrt(disc) }.Where(m => m > tol).DefaultIfEmpty(double.NaN).Min();
+ if (!(mu < length - tol)) { why = "the wall cuts the strip off beyond the rounded edge's far end"; return null; }
+ var reach = foot + d * mu;
+ // The cut: the wall's cylinder as host, the strip's as cutter, over the section between the two contacts.
+ var tool = new CylinderSurface(centre, Direction3D.Create(d), r, Direction3D.Create(nw));
+ double Angle(Point3D q)
+ {
+ var x = Unit(d); var z = axis; var y = z.Cross(x);
+ var rel = q - centre; rel -= x * rel.Dot(x);
+ return double.Atan2(rel.Dot(z), rel.Dot(y));
+ }
+ var (tq, tt) = (Angle(reach), Angle(touch));
+ tt = tq + double.Ieee754Remainder(tt - tq, 2 * double.Pi);
+ var domain = new ParameterInterval(double.Min(tq, tt), double.Max(tq, tt));
+ QualifiedCylinderIntersectionRepresentation? best = null;
+ foreach (var branch in new[] { CylinderIntersectionBranch.PositiveCutterAxis, CylinderIntersectionBranch.NegativeCutterAxis })
+ {
+ var curve = CylinderCylinderIntersectionCurve.CreateOffset(cylinder, tool, branch, domain);
+ if (!curve.IsSuccess) { why = string.Join("; ", curve.Diagnostics.Select(x => x.Message)); continue; }
+ var lo = curve.Value.Evaluate(domain.Start); var hi = curve.Value.Evaluate(domain.End);
+ var ends = new[] { reach, touch };
+ if (ends.Min(e => (e - lo).Length) > 1e3 * tol || ends.Min(e => (e - hi).Length) > 1e3 * tol) continue;
+ var realized = CylinderIntersectionCurveRealizer.Realize(curve.Value);
+ if (!realized.IsSuccess) { why = string.Join("; ", realized.Diagnostics.Select(x => x.Message)); return null; }
+ best = realized.Value; break;
+ }
+ if (best is null) { why = why.Length > 0 ? why : "the wall's cut does not run between the strip's contacts"; return null; }
+ return new Plan
+ {
+ Kind = VertexKind.Wall, Centre = centre, Faces = [s.A.Face, s.B.Face, across.Face], Rounded = [s.Edge.Id], Side = side,
+ Radius = r, Touch = touch, Reach = reach, Floor = floor.Face, Cut = best,
+ };
+ }
+
/// <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)
{
@@ -825,7 +986,7 @@ internal static class LocalRounding
continue;
}
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 or VertexKind.Mitre).SelectMany(p => p.Faces)).Distinct().ToArray();
+ var own = new[] { s.A.Face, s.B.Face }.Concat(new[] { p0, p1 }.Where(p => p.Kind is VertexKind.End or VertexKind.Junction or VertexKind.Mitre or VertexKind.Wall).SelectMany(p => p.Faces)).Distinct().ToArray();
var (c0, c1) = (p0.Centre, p1.Centre);
for (var i = 1; i < 8; i++)
{
diff --git a/Aetheris.Kernel.Core/Geometry/Curves/CylinderCylinderIntersectionCurve.cs b/Aetheris.Kernel.Core/Geometry/Curves/CylinderCylinderIntersectionCurve.cs
index becec076..af4fb70a 100644
--- a/Aetheris.Kernel.Core/Geometry/Curves/CylinderCylinderIntersectionCurve.cs
+++ b/Aetheris.Kernel.Core/Geometry/Curves/CylinderCylinderIntersectionCurve.cs
@@ -13,9 +13,16 @@ public enum IntersectionCurveSense { Forward, Reverse }
public readonly record struct CylinderIntersectionUv(double U, double V);
/// <summary>
-/// Exact intersection of perpendicular, centerline-crossing cylinders with cutter radius
-/// strictly inside host radius. The parameter runs around the cutter cross-section;
-/// the branch selects the side of the host along the cutter axis. No BRep topology is implied.
+/// Exact intersection of perpendicular cylinders. The parameter runs around the cutter cross-section; the branch
+/// selects the side of the host along the cutter axis. No BRep topology is implied.
+/// <para>
+/// The cutter's axis crosses the host's centreline (<see cref="Create"/>), or passes it at an offset e along their
+/// common perpendicular (<see cref="CreateOffset"/>). In cutter-section coordinates y = e + r·cos t, z = r·sin t,
+/// the point along the cutter axis is x = ±√(R² − y²). The cutter stays strictly inside the host's silhouette
+/// (|e| + r &lt; R), or touches it from inside at one point (|e| + r = R: a fillet whose wall is tangent to the
+/// host). There R² − y² has a double root, R ∓ y = 2r·sin²(t/2) or 2r·cos²(t/2), and the evaluator takes its
+/// square root exactly, so the curve is analytic through the touching point.
+/// </para>
/// </summary>
public sealed class CylinderCylinderIntersectionCurve
{
@@ -27,12 +34,18 @@ public sealed class CylinderCylinderIntersectionCurve
private readonly double _toolAxialOffset;
private readonly double _hostUAtStart;
private readonly double _toolUAtStart;
+ private readonly double _offset;
+ private readonly Touching _touching;
+
+ private enum Touching { None, AtPositiveY, AtNegativeY }
private CylinderCylinderIntersectionCurve(
CylinderSurface host, CylinderSurface tool, Point3D center,
CylinderIntersectionBranch branch, ParameterInterval domain,
- IntersectionCurveSense sense)
+ IntersectionCurveSense sense, double offset = 0d, Touching touching = Touching.None)
{
+ _offset = offset;
+ _touching = touching;
Host = host;
Tool = tool;
Center = center;
@@ -56,6 +69,104 @@ public sealed class CylinderCylinderIntersectionCurve
public ParameterInterval Domain { get; }
public IntersectionCurveSense Sense { get; }
+ /// <summary>The cutter axis's offset from the host centreline along their common perpendicular (0 when they cross).</summary>
+ public double Offset => _offset;
+
+ /// <summary>
+ /// Perpendicular cylinders whose axes need not cross: the centre is the foot of their common perpendicular on
+ /// the host axis. Admits a cutter strictly inside the host's silhouette, or touching it from inside at one point;
+ /// refuses one that reaches outside it (the curve would end where it turns back).
+ /// </summary>
+ public static KernelResult<CylinderCylinderIntersectionCurve> CreateOffset(
+ CylinderSurface host, CylinderSurface tool,
+ CylinderIntersectionBranch branch, ParameterInterval domain,
+ IntersectionCurveSense sense = IntersectionCurveSense.Forward,
+ ToleranceContext? tolerance = null)
+ {
+ var tol = tolerance ?? ToleranceContext.Default;
+ if (domain.End <= domain.Start || domain.End - domain.Start > 2d * double.Pi + tol.Angular)
+ return Failure("Intersection domain must be nonempty and span no more than one revolution.", "Geometry.CylinderIntersection.InvalidDomain");
+ if (!Enum.IsDefined(branch) || !Enum.IsDefined(sense))
+ return Failure("Intersection branch and sense must be recognized values.", "Geometry.CylinderIntersection.InvalidOrientation");
+ var x = tool.Axis.ToVector();
+ var z = host.Axis.ToVector();
+ if (double.Abs(x.Dot(z)) > double.Min(tol.Angular, 64d * MachineEpsilon))
+ return Failure("Only perpendicular cylinder axes are admitted.", "Geometry.CylinderIntersection.ObliqueAxes");
+ var y = z.Cross(x);
+ // Foot of the common perpendicular on the host axis, and the cutter axis's offset from it along y.
+ var d = tool.Origin - host.Origin;
+ var center = host.Origin + z * d.Dot(z);
+ var offset = d.Dot(y);
+ var scale = double.Max(1d, double.Max(
+ double.Max(double.Abs(center.X), double.Abs(center.Y)),
+ double.Max(double.Abs(center.Z), host.Radius + tool.Radius + double.Abs(offset))));
+ var reach = double.Abs(offset) + tool.Radius;
+ var touching = Touching.None;
+ if (double.Abs(reach - host.Radius) <= 64d * MachineEpsilon * scale)
+ touching = offset >= 0 ? Touching.AtPositiveY : Touching.AtNegativeY;
+ else if (reach >= host.Radius - tol.Linear)
+ return Failure("The cutter must stay inside the host's silhouette, or touch it from inside.", "Geometry.CylinderIntersection.TangentOrOversize");
+ return KernelResult<CylinderCylinderIntersectionCurve>.Success(
+ new CylinderCylinderIntersectionCurve(host, tool, center, branch, domain, sense, offset, touching));
+ }
+
+ /// <summary>
+ /// A bound on the fourth derivative |P⁽⁴⁾| over [start, end], for the cubic Hermite remainder |P⁽⁴⁾|·h⁴/384.
+ /// Crossing axes keep the closed-form chain-rule bound. Offset or touching cutters use a Cauchy estimate: P is
+ /// analytic in the strip |Im t| &lt; ρ, so |P⁽⁴⁾| ≤ 4!·M/ρ⁴ with M bounding |P − centre| there.
+ /// </summary>
+ internal double FourthDerivativeBound(double start, double end)
+ {
+ if (_offset == 0d && _touching == Touching.None) return CrossingFourthDerivativeBound(Host.Radius, Tool.Radius, start, end);
+ var (R, r, e) = (Host.Radius, Tool.Radius, double.Abs(_offset));
+ var best = double.PositiveInfinity;
+ for (var i = 1; i <= 64; i++)
+ {
+ var rho = 3d * i / 64d;
+ var c = double.Cosh(rho);
+ // In the strip |cos t| ≤ cosh ρ, so |y| ≤ e + r·cosh ρ. Each square-rooted factor must keep a positive
+ // real part there (no branch point): R - y and R + y, or the one left after the double root comes out.
+ double axial;
+ if (_touching == Touching.None)
+ {
+ if (R - e - r * c <= 0) break;
+ axial = R + e + r * c;
+ }
+ else
+ {
+ // Remaining factor R + e - r·cos t (Re ≥ R + e - r·cosh ρ), times √(2r)·|cos(t/2)| ≤ √(2r)·cosh(ρ/2).
+ if (R + e - r * c <= 0) break;
+ axial = double.Sqrt(R + e + r * c) * double.Sqrt(2d * r) * double.Cosh(rho / 2d);
+ }
+ var section = e + r * c;
+ var m = double.Sqrt(axial * axial + 2d * section * section);
+ best = double.Min(best, 24d * m / double.Pow(rho, 4d));
+ }
+ return best;
+ }
+
+ private static double CrossingFourthDerivativeBound(double hostRadius, double toolRadius, double start, double end)
+ {
+ var r2 = toolRadius * toolRadius;
+ var maxCosSq = double.Max(double.Pow(double.Cos(start), 2d), double.Pow(double.Cos(end), 2d));
+ if (double.Ceiling(start / double.Pi) * double.Pi <= end)
+ maxCosSq = 1d;
+ var minG = hostRadius * hostRadius - r2 * maxCosSq;
+ if (minG <= 0d) return double.PositiveInfinity;
+ var sqrtG = double.Sqrt(minG);
+ var g3 = minG * sqrtG;
+ var g5 = minG * g3;
+ var g7 = minG * g5;
+ // For x=sqrt(g), g=R²-r²cos²(t): the first four derivatives of g are bounded by r², 2r², 4r² and 8r².
+ // The chain rule bounds the fourth derivative of x by the expression below. Both remaining
+ // coordinates are r*cos(t), r*sin(t), with fourth derivatives <=r.
+ var xFourth = (15d * double.Pow(r2, 4d) / (16d * g7))
+ + (4.5d * double.Pow(r2, 3d) / g5)
+ + (7d * r2 * r2 / g3)
+ + (4d * r2 / sqrtG);
+ return double.Sqrt(xFourth * xFourth + 2d * toolRadius * toolRadius);
+ }
+
public static KernelResult<CylinderCylinderIntersectionCurve> Create(
CylinderSurface host, CylinderSurface tool, Point3D center,
CylinderIntersectionBranch branch, ParameterInterval domain,
@@ -93,23 +204,59 @@ public sealed class CylinderCylinderIntersectionCurve
{
CheckParameter(t);
var r = Tool.Radius;
- var y = r * double.Cos(t);
+ var y = _offset + r * double.Cos(t);
var z = r * double.Sin(t);
- var x = BranchSign * double.Sqrt((Host.Radius * Host.Radius) - (y * y));
- return Center + (_x * x) + (_y * y) + (_z * z);
+ return Center + (_x * Axial(t)) + (_y * y) + (_z * z);
+ }
+
+ // x = ±√((R - y)(R + y)); a touching cutter has one factor 2r·sin²(t/2) or 2r·cos²(t/2), rooted exactly.
+ private double Axial(double t)
+ {
+ var (R, r) = (Host.Radius, Tool.Radius);
+ var y = _offset + r * double.Cos(t);
+ return BranchSign * _touching switch
+ {
+ Touching.None => double.Sqrt((R * R) - (y * y)),
+ // e = R - r: R - y = r(1 - cos t) = 2r·sin²(t/2).
+ Touching.AtPositiveY => double.Sqrt(R + y) * double.Sqrt(2d * r) * double.Sin(t / 2d),
+ // e = r - R: R + y = r(1 + cos t) = 2r·cos²(t/2).
+ _ => double.Sqrt(R - y) * double.Sqrt(2d * r) * double.Cos(t / 2d),
+ };
}
public Vector3D Derivative(double t)
{
CheckParameter(t);
- var r = Tool.Radius;
+ var (R, r) = (Host.Radius, Tool.Radius);
var sin = double.Sin(t);
var cos = double.Cos(t);
- var root = double.Sqrt((Host.Radius * Host.Radius) - (r * r * cos * cos));
- var dx = BranchSign * r * r * cos * sin / root;
+ var y = _offset + r * cos;
+ double dx;
+ switch (_touching)
+ {
+ case Touching.None:
+ // d/dt √(R² - y²) = -y·y' / √(R² - y²), with y' = -r sin t.
+ dx = BranchSign * y * r * sin / double.Sqrt((R * R) - (y * y));
+ break;
+ case Touching.AtPositiveY:
+ {
+ // x = √(2r)·√(R + y)·sin(t/2), with (R + y)' = -r sin t.
+ var f = double.Sqrt(R + y);
+ dx = BranchSign * double.Sqrt(2d * r) * ((-r * sin / (2d * f)) * double.Sin(t / 2d) + f * double.Cos(t / 2d) / 2d);
+ break;
+ }
+ default:
+ {
+ // x = √(2r)·√(R - y)·cos(t/2), with (R - y)' = r sin t.
+ var f = double.Sqrt(R - y);
+ dx = BranchSign * double.Sqrt(2d * r) * ((r * sin / (2d * f)) * double.Cos(t / 2d) - f * double.Sin(t / 2d) / 2d);
+ break;
+ }
+ }
return (_x * dx) - (_y * (r * sin)) + (_z * (r * cos));
}
+
public CylinderIntersectionUv EvaluateHostPcurve(double t)
{
var point = Evaluate(t);
diff --git a/Aetheris.Kernel.Core/Geometry/Curves/CylinderIntersectionCurveRealizer.cs b/Aetheris.Kernel.Core/Geometry/Curves/CylinderIntersectionCurveRealizer.cs
index 56ea8244..167d14a4 100644
--- a/Aetheris.Kernel.Core/Geometry/Curves/CylinderIntersectionCurveRealizer.cs
+++ b/Aetheris.Kernel.Core/Geometry/Curves/CylinderIntersectionCurveRealizer.cs
@@ -34,7 +34,7 @@ public static class CylinderIntersectionCurveRealizer
var tol = tolerance ?? ToleranceContext.Default;
var scale = double.Max(1d, double.Max(
double.Max(double.Abs(authority.Center.X), double.Abs(authority.Center.Y)),
- double.Max(double.Abs(authority.Center.Z), authority.Host.Radius + authority.Tool.Radius)));
+ double.Max(double.Abs(authority.Center.Z), authority.Host.Radius + authority.Tool.Radius + double.Abs(authority.Offset))));
// Keep roundoff separate from the analytic Hermite remainder. Large coordinates
// whose floating-point allowance consumes the tolerance fail explicitly.
var numericalAllowance = 256d * MachineEpsilon * scale;
@@ -49,7 +49,7 @@ public static class CylinderIntersectionCurveRealizer
while (pending.Count > 0)
{
var (start, end) = pending.Pop();
- var bound = HermiteErrorBound(authority.Host.Radius, authority.Tool.Radius, start, end);
+ var bound = authority.FourthDerivativeBound(start, end) * double.Pow(end - start, 4d) / 384d;
if (!double.IsFinite(bound))
return Failure("The intersection remainder bound is nonfinite.",
"Geometry.CylinderIntersection.NonFiniteBound");
@@ -94,31 +94,6 @@ public static class CylinderIntersectionCurveRealizer
numericalAllowance, spans.Count));
}
- private static double HermiteErrorBound(double hostRadius, double toolRadius, double start, double end)
- {
- var r2 = toolRadius * toolRadius;
- var maxCosSq = double.Max(double.Pow(double.Cos(start), 2d), double.Pow(double.Cos(end), 2d));
- if (double.Ceiling(start / double.Pi) * double.Pi <= end)
- maxCosSq = 1d;
- var minG = hostRadius * hostRadius - r2 * maxCosSq;
- if (minG <= 0d) return double.PositiveInfinity;
- var sqrtG = double.Sqrt(minG);
- var g3 = minG * sqrtG;
- var g5 = minG * g3;
- var g7 = minG * g5;
- // For x=sqrt(g), g=R²-r²cos²(t):
- // |g'|<=r², |g''|<=2r², |g'''|<=4r², |g''''|<=8r².
- // The chain rule bounds |x''''| by the expression below. Both remaining
- // coordinates are r*cos(t), r*sin(t), with fourth derivatives <=r.
- var xFourth = (15d * double.Pow(r2, 4d) / (16d * g7))
- + (4.5d * double.Pow(r2, 3d) / g5)
- + (7d * r2 * r2 / g3)
- + (4d * r2 / sqrtG);
- var vectorFourth = double.Sqrt(xFourth * xFourth + 2d * toolRadius * toolRadius);
- var h = end - start;
- return vectorFourth * double.Pow(h, 4d) / 384d;
- }
-
private static KernelResult<QualifiedCylinderIntersectionRepresentation> Failure(string message, string source)
=> KernelResult<QualifiedCylinderIntersectionRepresentation>.Failure([
new KernelDiagnostic(KernelDiagnosticCode.InvalidArgument, KernelDiagnosticSeverity.Error, message, source)]);
diff --git a/docs/development/reports/2026-11/CTC-01-DECOMPILE.md b/docs/development/reports/2026-11/CTC-01-DECOMPILE.md
index bf13b6e5..0327594c 100644
--- a/docs/development/reports/2026-11/CTC-01-DECOMPILE.md
+++ b/docs/development/reports/2026-11/CTC-01-DECOMPILE.md
@@ -225,8 +225,38 @@ the waist cylinder carried down through the lug. That end edge is a cylinder–c
spline. Closing it needs a general intersection curve and a rule for where a strip ends against a curved wall.
That is a feature of its own, not a patch to this one.
+## Follow-up: lug root fillets end on the waist (CTC-01 complete)
+
+`EdgeFinish<Fillet> LugRoots { where: role Pad meets PlateStock; radius: 10mm }` closes the last gap.
+
+What changed:
+- **Exact curve:** `CylinderCylinderIntersectionCurve.CreateOffset` takes perpendicular cylinders whose axes need
+ not cross, including a cutter touching the host from inside.
+ - At the touching point R² − y² has a double root: R ∓ y = 2r·sin²(t/2) or 2r·cos²(t/2). The evaluator roots
+ it exactly, so the curve stays analytic through the fillet's tangent end.
+ - The export fit is certified by a Cauchy estimate on a complex strip, |P⁽⁴⁾| ≤ 4!·M/ρ⁴.
+ - The crossing-axes path, and every STEP file it writes, is unchanged.
+- **Doctrine:** the exact curve lives in the B-rep (`CurveGeometry.FromCertifiedIntersection`). STEP gets a
+ non-rational B-spline with a certified deviation. Every consumer already reads it as a `BSpline3`.
+- **Coplanar merge:** a selective rounding merges faces split on one plane before classifying vertices. The
+ section stack splits the x = −250 wall three ways at the waist's tangent line.
+- **`Wall` vertex:** a strip whose floor runs out into a cylindrical wall standing square to it, tangent to the
+ strip's wall. The wall contact ends on the tangent line one radius off the floor. The floor contact ends where it
+ crosses the cylinder. The wall's face grows over the strip's end, bounded by the certified cut.
+
+Evidence:
+- **CTC-01:** 85/85 carriers, 0 extra, IoU 0.999992. Enclosed manifold.
+- **The cut against NIST's edge 180:** our cut runs exactly from (−240, 130, −50) to (−250, 150, −60). NIST's
+ edge 180 is a 6-control-point spline lying 3.4 µm off both cylinders, and it is within 3.5 µm of our exact
+ curve (its own fitting error). Our fit is certified at 1.26e-7 mm, with a sampled maximum of 1.3e-8 mm over
+ 64 spans.
+- **Topology at the cut vertex:** tangent line, wall contact and cut meet as in the original (edges 180/187 there).
+
+Remaining difference: face count, 154 against NIST's 117. It comes from cylinders and other faces the section
+stack splits; carriers and volume agree.
+
## Verdict
-Meaningful progression. CTC-01 builds with every feature Firmament can express, and the comparison
-proves the rest are exactly three language gaps. Items 1 and 2 are the features worth designing. Items
-3–6 are small and independent.
+Success. CTC-01 decompiles into Firmament that rebuilds every surface of the NIST original (85/85, IoU 0.999992),
+from shape-based outlines with `|> Round(r)` stages, derived-plane drills, and `where: A meets B` fillets. The
+only approximated geometry is four exported edges, each certified against its exact curve.
diff --git a/docs/public/reference/language/solids-and-features.md b/docs/public/reference/language/solids-and-features.md
index 2eda9497..d6c928d6 100644
--- a/docs/public/reference/language/solids-and-features.md
+++ b/docs/public/reference/language/solids-and-features.md
@@ -217,14 +217,23 @@ rounds a hexagonal boss's foot this way.
edges on one face turn a corner and the edge between their walls stands square
to that face, as at a boss's foot, they meet in an exact quarter-ellipse mitre.
A rounded edge may also end on a face standing square to it.
+- Where a fillet's floor runs out into a cylindrical wall that stands square to
+ the floor and is tangent to the fillet's own wall (a pad's root reaching a
+ rounded waist in the plate's outline), the wall is carried down through the
+ fillet and cuts it off. The cut is an exact cylinder–cylinder curve; in STEP it
+ is written as a B-spline whose distance from that curve is certified below the
+ model tolerance.
+- A wall split in two on one plane, as where another operation's outline meets
+ it, is treated as one face.
- Several `where` finishes on one body are built together, each with its own
radius, after the body's other construction (holes and another finish
included). Edges of different radii must not meet.
- Rejected: `where` on a chamfer; operations that are not on XY along +Z; names
that are not operations or roles of the Compose body; a junction with no edges;
- a rounded edge that ends where its face's edge runs on tangentially into a
- curved wall, or at a corner of convex and concave edges other than a mitre; and
- a radius that does not fit, which is refused with the largest that does.
+ a fillet that runs out into a wall other than a square-standing cylinder
+ tangent to its own wall, or ends at any other corner of convex and concave
+ edges than a mitre; and a radius that does not fit, which is refused with the
+ largest that does.
What you can select depends on the body:
diff --git a/fixtures/Regression/Decompile/ctc-01.firmament b/fixtures/Regression/Decompile/ctc-01.firmament
index 382b3003..ec9db80b 100644
--- a/fixtures/Regression/Decompile/ctc-01.firmament
+++ b/fixtures/Regression/Decompile/ctc-01.firmament
@@ -2,9 +2,9 @@
// a dog-bone plate (two rounded ends and a bridge) with four lugs underneath, a hexagonal boss on top,
// through holes, slots, side drills, and notches in the long edges. Compare against the original with
// aetheris analyze compare <original.stp> <this.step> --shape
-// Not expressible yet, and therefore absent here: the R10 fillets where the lugs' inner walls meet the plate
-// underside. Each ends where the underside's edge runs tangentially into an R25 waist wall; the original ends it
-// against that wall's cylinder carried down through the lug, which leaves a spline edge.
+// Every feature of the original is expressed. Each R10 lug-root fillet ends where the plate underside runs into an
+// R25 waist wall; the wall is carried down and cuts the fillet off along an exact cylinder-cylinder curve,
+// exported as a certified B-spline.
Model Ctc01 {
units: mm
@@ -170,5 +170,6 @@ Model Ctc01 {
Mirrored Feature SideDrillLeft from SideDrillRight { across: CenterPlane }
EdgeFinish<Chamfer> HexTop { on: Top; target: HexBoss.Outer; distance: 5mm }
EdgeFinish<Fillet> HexFoot { where: Hex meets PlateStock; radius: 5mm }
+ EdgeFinish<Fillet> LugRoots { where: role Pad meets PlateStock; radius: 10mm }
}
}