Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Add reusable fillet components and validate shell planning

Yuechen Li51a467641a18
diff --git a/Aetheris.Kernel.Firmament.Tests/Integration/ProfileBoundaryChamferTests.cs b/Aetheris.Kernel.Firmament.Tests/Integration/ProfileBoundaryChamferTests.cs
index d2f8f753..bef8e7b6 100644
--- a/Aetheris.Kernel.Firmament.Tests/Integration/ProfileBoundaryChamferTests.cs
+++ b/Aetheris.Kernel.Firmament.Tests/Integration/ProfileBoundaryChamferTests.cs
@@ -126,6 +126,10 @@ public sealed class ProfileBoundaryChamferTests
Assert.Equal(17d, result.Plan.SpanEnd.X, 8);
Assert.Equal(2d, result.Plan.CylinderCenterlineStart.Y, 8);
Assert.Equal(6d, result.Plan.CylinderCenterlineStart.Z, 8);
+ var roll = Assert.IsType<StraightFilletRollComponent>(result.Plan.RollComponent);
+ Assert.Equal(ProfileEdgeFinishSurfaceFamily.Cylinder, roll.SurfaceFamily);
+ Assert.Equal("open-start", roll.PredecessorInterface);
+ Assert.DoesNotContain("TerminationFace", roll.SemanticDescendants);
Assert.False(ProfileBoundaryChamferSourceBinder.TryBindFillet("Modify Body { EdgeFinish Bad { Target: Bracket.Outer.South On: Top Kind: Fillet Radius: 0mm } }", Profile(), "Bracket", out _, out _, out _, out diagnostic));
Assert.Equal("ProfileBoundaryFilletRadiusMustBePositive", diagnostic);
@@ -175,6 +179,10 @@ public sealed class ProfileBoundaryChamferTests
Assert.Equal(2, result.Correspondence!.Descendants.Count(item => item.Role is SemanticTopologyRole.StartTerminationFace or SemanticTopologyRole.EndTerminationFace));
Assert.Contains(result.Correspondence.Descendants, item => item.Role == SemanticTopologyRole.ConvexJunctionPatch);
Assert.DoesNotContain(result.Correspondence.Descendants, item => item.StableId.Contains("InternalTermination", StringComparison.Ordinal));
+ Assert.Collection(result.Plan.Components!,
+ component => Assert.IsType<StraightFilletRollComponent>(component),
+ component => Assert.IsType<ConvexSharpFilletJunctionComponent>(component),
+ component => Assert.IsType<StraightFilletRollComponent>(component));
}
[Fact]
@@ -193,6 +201,7 @@ public sealed class ProfileBoundaryChamferTests
Assert.Equal(1, reflexPlan.Body.Geometry.Surfaces.Count(item => item.Value.Kind == SurfaceGeometryKind.Torus));
Assert.Contains(reflexPlan.Correspondence!.Descendants, item => item.Role == SemanticTopologyRole.ReflexJunctionPatch);
Assert.Equal(2, reflexPlan.Correspondence.Descendants.Count(item => item.Role is SemanticTopologyRole.StartTerminationFace or SemanticTopologyRole.EndTerminationFace));
+ Assert.IsType<ReflexSharpExactRollingJunctionComponent>(reflexPlan.Plan.Components![1]);
const string three = "Selection Three { Source: Bracket.Outer.[South, East, North] Require: ConnectedChain } Modify Body { EdgeFinish Round { Target: Three On: Top Kind: Fillet Radius: 2mm } }";
Assert.True(ProfileBoundaryChamferSourceBinder.TryBindFillet(three, Profile(), "Bracket", out var threeTarget, out var threeRadius, out var threeClearance, out diagnostic), diagnostic);
@@ -232,6 +241,7 @@ public sealed class ProfileBoundaryChamferTests
Assert.Equal(1, result.Body.Geometry.Surfaces.Count(item => item.Value.Kind == SurfaceGeometryKind.Sphere));
Assert.Equal(0, result.Body.Geometry.Surfaces.Count(item => item.Value.Kind == SurfaceGeometryKind.Torus));
Assert.Contains(result.Correspondence!.ProvenanceChain, item => item == "ReflexSphereSeamCompatibility");
+ Assert.IsType<ReflexSharpSphereCompatibilityComponent>(result.Plan.Components![1]);
const string unsupported = "Selection Notch { Source: Bracket.Outer.[Inner, Upright] Require: ConnectedChain } Modify Body { EdgeFinish Round { Target: Notch On: Top Kind: Fillet Radius: 2mm ReflexJunction: Legacy } }";
Assert.False(ProfileBoundaryChamferSourceBinder.TryBindFillet(unsupported, LProfile(), "Bracket", out _, out _, out _, out diagnostic));
diff --git a/Aetheris.Kernel.Firmament.Tests/Integration/ProfileEdgeFinishMixedShellPlanTests.cs b/Aetheris.Kernel.Firmament.Tests/Integration/ProfileEdgeFinishMixedShellPlanTests.cs
index 9d2a95de..df15ff5f 100644
--- a/Aetheris.Kernel.Firmament.Tests/Integration/ProfileEdgeFinishMixedShellPlanTests.cs
+++ b/Aetheris.Kernel.Firmament.Tests/Integration/ProfileEdgeFinishMixedShellPlanTests.cs
@@ -108,6 +108,19 @@ public sealed class ProfileEdgeFinishMixedShellPlanTests
Assert.DoesNotContain(plan.OrderedPatches.SelectMany(x => x.SemanticDescendants), x => x.Contains("Termination", StringComparison.Ordinal));
}
+ [Fact]
+ public void SevenStationFillet_RejectsNaiveContactCompositionBeforeTopologyAtTheFirstSharpStation()
+ {
+ var (profile, target) = ReleaseCard("profile-edgefinish-chimera-fillet.firmament", ProfileEdgeFinishKind.Fillet);
+ var mixed = ProfileEdgeFinishMixedShellPlanner.TryPlan(profile, target, ProfileEdgeFinishKind.Fillet, 4d);
+
+ Assert.True(mixed.Succeeded, string.Join(Environment.NewLine, mixed.Diagnostics));
+ var contacts = ProfileFilletContactShellPlanner.TryPlan(profile, target, Assert.IsType<ProfileEdgeFinishMixedShellPlan>(mixed.Plan));
+
+ Assert.False(contacts.Succeeded);
+ Assert.Equal("ProfileFilletContactSharpJunctionComponentRequired:vertex=Outer.Bottom.Start", Assert.Single(contacts.Diagnostics));
+ }
+
private static (ResolvedProfile2D Profile, ProfileBoundaryChamferTarget Target) ReleaseCard(string fixture, ProfileEdgeFinishKind kind)
{
var source = File.ReadAllText(FirmamentCorpusHarness.ResolveFixtureFullPath($"fixtures/FirmamentV2/Canonical/valid/{fixture}"));
diff --git a/Aetheris.Kernel.Firmament/Materializer/ProfileBoundaryChamfer.cs b/Aetheris.Kernel.Firmament/Materializer/ProfileBoundaryChamfer.cs
index 9bdae1da..5544a847 100644
--- a/Aetheris.Kernel.Firmament/Materializer/ProfileBoundaryChamfer.cs
+++ b/Aetheris.Kernel.Firmament/Materializer/ProfileBoundaryChamfer.cs
@@ -40,7 +40,8 @@ public sealed record ProfileStraightEdgeFilletPlan(
Direction3D Tangent, Direction3D InwardNormal, Direction3D ExtrusionAxis,
Point3D CylinderCenterlineStart, Point3D CylinderCenterlineEnd,
Point3D CapContactStart, Point3D CapContactEnd, Point3D SideContactStart, Point3D SideContactEnd,
- string EndpointPolicy = "FilletSpanInset");
+ string EndpointPolicy = "FilletSpanInset",
+ StraightFilletRollComponent? RollComponent = null);
public sealed record ProfileStraightEdgeFilletPlanResult(
bool Succeeded, BrepBody? Body, SemanticTopologyCorrespondence? Correspondence,
ProfileStraightEdgeFilletPlan? Plan, IReadOnlyList<string> Diagnostics);
@@ -612,7 +613,12 @@ public static class ProfileStraightEdgeFilletPlanner
var centerEnd = spanEnd + inward.ToVector() * radius + axialIntoBody * radius;
var capStart = spanStart + inward.ToVector() * radius; var capEnd = spanEnd + inward.ToVector() * radius;
var sideStart = spanStart + axialIntoBody * radius; var sideEnd = spanEnd + axialIntoBody * radius;
- var plan = new ProfileStraightEdgeFilletPlan(target, radius, clearance, sourceStart, sourceEnd, spanStart, spanEnd, tangent, inward, axis, centerStart, centerEnd, capStart, capEnd, sideStart, sideEnd);
+ var capOut = target.Side == ProfileBoundaryChamferSide.Top ? axis : Direction3D.Create(-axis.ToVector());
+ var component = new StraightFilletRollComponent($"{target.StableId}:roll:{loop.Segments[index].Name}", loop.Segments[index].Provenance.StableId,
+ new CylinderSurface(centerStart, tangent, radius, capOut), centerStart, centerEnd, capStart, capEnd, sideStart, sideEnd,
+ $"axis={tangent};inward={inward};cap={capOut}", "open-start", "open-end",
+ [$"FilletSurface({loop.Segments[index].Name})"], ["M1", "ResolvedProfileSegment", "ReusableStraightRoll"]);
+ var plan = new ProfileStraightEdgeFilletPlan(target, radius, clearance, sourceStart, sourceEnd, spanStart, spanEnd, tangent, inward, axis, centerStart, centerEnd, capStart, capEnd, sideStart, sideEnd, RollComponent: component);
return BuildBody(profile, loop, index, plan, start, end);
}
@@ -728,6 +734,80 @@ public static class ProfileStraightEdgeFilletPlanner
/// trying to join two already-emitted M1 bodies.
/// </summary>
public enum ProfileFilletRollEndKind { EndpointTermination, ConvexJunction, ReflexJunction }
+
+/// <summary>
+/// Reusable analytic constituents of a Profile fillet. Components carry only
+/// their own exact surface and local interfaces; a parent shell decides whether
+/// an interface is joined to another component or an open-chain termination.
+/// </summary>
+public abstract record ProfileFilletComponent(
+ string StableId,
+ string SourceStableId,
+ ProfileEdgeFinishSurfaceFamily SurfaceFamily,
+ string LocalFrame,
+ string PredecessorInterface,
+ string SuccessorInterface,
+ string CapContactBoundary,
+ string SideContactBoundary,
+ IReadOnlyList<string> SemanticDescendants,
+ IReadOnlyList<string> Provenance);
+
+public sealed record StraightFilletRollComponent(
+ string StableId,
+ string SourceStableId,
+ CylinderSurface Surface,
+ Point3D CenterlineStart,
+ Point3D CenterlineEnd,
+ Point3D CapContactStart,
+ Point3D CapContactEnd,
+ Point3D SideContactStart,
+ Point3D SideContactEnd,
+ string LocalFrame,
+ string PredecessorInterface,
+ string SuccessorInterface,
+ IReadOnlyList<string> SemanticDescendants,
+ IReadOnlyList<string> Provenance)
+ : ProfileFilletComponent(StableId, SourceStableId, ProfileEdgeFinishSurfaceFamily.Cylinder, LocalFrame,
+ PredecessorInterface, SuccessorInterface, "cap-contact-line", "side-contact-line", SemanticDescendants, Provenance);
+
+public sealed record ConvexSharpFilletJunctionComponent(
+ string StableId,
+ string SourceStableId,
+ SphereSurface Surface,
+ string LocalFrame,
+ IReadOnlyList<string> SemanticDescendants,
+ IReadOnlyList<string> Provenance)
+ : ProfileFilletComponent(StableId, SourceStableId, ProfileEdgeFinishSurfaceFamily.Sphere, LocalFrame,
+ "roll-a-sphere-seam", "roll-b-sphere-seam", "cap-contact-point", "side-a/side-b-contact", SemanticDescendants, Provenance);
+
+public sealed record ReflexSharpExactRollingJunctionComponent(
+ string StableId,
+ string SourceStableId,
+ TorusSurface Surface,
+ string LocalFrame,
+ IReadOnlyList<string> SemanticDescendants,
+ IReadOnlyList<string> Provenance)
+ : ProfileFilletComponent(StableId, SourceStableId, ProfileEdgeFinishSurfaceFamily.Torus, LocalFrame,
+ "roll-a-torus-seam", "roll-b-torus-seam", "torus-cap-contact", "notch-side-contact", SemanticDescendants, Provenance);
+
+public sealed record ReflexSharpSphereCompatibilityComponent(
+ string StableId,
+ string SourceStableId,
+ SphereSurface Surface,
+ string LocalFrame,
+ IReadOnlyList<string> SemanticDescendants,
+ IReadOnlyList<string> Provenance)
+ : ProfileFilletComponent(StableId, SourceStableId, ProfileEdgeFinishSurfaceFamily.Sphere, LocalFrame,
+ "roll-a-sphere-seam", "roll-b-sphere-seam", "cap-contact-point", "notch-side-contact", SemanticDescendants, Provenance);
+
+public sealed record FilletSeamComponent(
+ string StableId,
+ string PredecessorComponentId,
+ string SuccessorComponentId,
+ string CurveFamily,
+ bool TraversesWithCurveParameter,
+ IReadOnlyList<string> Provenance);
+
public sealed record ProfileFilletStraightRollPlan(string SegmentId, Direction3D Tangent, Direction3D InwardNormal, Point3D ExternalCenter, Point3D JunctionCenter, ProfileFilletRollEndKind ExternalEnd, ProfileFilletRollEndKind JunctionEnd);
public abstract record ProfileFilletJunctionPlan(string VertexId, ProfileJunctionClassification Classification, Point3D Center, double Radius)
{
@@ -746,7 +826,7 @@ public sealed record ProfileReflexFilletJunctionPlan(string VertexId, ProfileJun
public override Point3D SideAContact { get => VerticalNotchContact; init { } }
public override Point3D SideBContact { get => VerticalNotchContact; init { } }
}
-public sealed record ProfileFilletShellPlan(ProfileBoundaryChamferTarget Target, double Radius, double EndClearance, IReadOnlyList<ProfileFilletStraightRollPlan> Rolls, ProfileFilletJunctionPlan Junction, string EndpointPolicy = "ExternalEndpointsOnly");
+public sealed record ProfileFilletShellPlan(ProfileBoundaryChamferTarget Target, double Radius, double EndClearance, IReadOnlyList<ProfileFilletStraightRollPlan> Rolls, ProfileFilletJunctionPlan Junction, string EndpointPolicy = "ExternalEndpointsOnly", IReadOnlyList<ProfileFilletComponent>? Components = null);
public sealed record ProfileFilletShellPlanResult(bool Succeeded, BrepBody? Body, SemanticTopologyCorrespondence? Correspondence, ProfileFilletShellPlan? Plan, ProfileStraightEdgeFilletPlan? SingleSegmentPlan, IReadOnlyList<string> Diagnostics);
public static class ProfileFilletShellPlanner
@@ -821,7 +901,22 @@ public static class ProfileFilletShellPlanner
ProfileFilletJunctionPlan junction = reflexCompatibility
? new ProfileReflexSphereSeamCompatibilityJunctionPlan(classification.VertexId, classification, center, radius, capJunction, sideA, sideB)
: new ProfileConvexSphericalJunctionPlan(classification.VertexId, classification, center, radius, capJunction, sideA, sideB);
- var plan = new ProfileFilletShellPlan(target, radius, clearance, rolls, junction);
+ var rollAComponent = new StraightFilletRollComponent($"{target.StableId}:roll:{loop.Segments[a].Name}", loop.Segments[a].Provenance.StableId,
+ new CylinderSurface(centerA, ta, radius, capOut), centerA, center, capA, capJunction, sideAExternal, sideA,
+ $"axis={ta};inward={na};cap={capOut}", "external-or-parent", "junction-a",
+ [$"FilletSurface({loop.Segments[a].Name})"], ["M2/M3", "ReusableStraightRoll"]);
+ var rollBComponent = new StraightFilletRollComponent($"{target.StableId}:roll:{loop.Segments[b].Name}", loop.Segments[b].Provenance.StableId,
+ new CylinderSurface(center, tb, radius, capOut), centerB, center, capJunction, capB, sideB, sideBExternal,
+ $"axis={tb};inward={nb};cap={capOut}", "junction-b", "external-or-parent",
+ [$"FilletSurface({loop.Segments[b].Name})"], ["M2/M3", "ReusableStraightRoll"]);
+ ProfileFilletComponent junctionComponent = reflexCompatibility
+ ? new ReflexSharpSphereCompatibilityComponent($"{target.StableId}:junction:{classification.VertexId}", classification.VertexId,
+ new SphereSurface(center, capOut, radius, Direction3D.Create(-na.ToVector())), $"cap={capOut}",
+ ["ReflexJunctionPatch", "policy=SphereSeamCompatibility"], ["M3R", "SphereSeamCompatibility"])
+ : new ConvexSharpFilletJunctionComponent($"{target.StableId}:junction:{classification.VertexId}", classification.VertexId,
+ new SphereSurface(center, capOut, radius, Direction3D.Create(-na.ToVector())), $"cap={capOut}",
+ ["ConvexJunctionPatch"], ["M2", "ConvexSphere"]);
+ var plan = new ProfileFilletShellPlan(target, radius, clearance, rolls, junction, Components: [rollAComponent, junctionComponent, rollBComponent]);
var builder = new TopologyBuilder(); var geometry = new BrepGeometryStore(); var bindings = new BrepBindingModel(); var points = new Dictionary<VertexId, Point3D>();
var vertices = new Dictionary<string, VertexId>(StringComparer.Ordinal); var edges = new Dictionary<(VertexId, VertexId), EdgeId>(); var descendants = new List<SemanticTopologyDescendant>(); var curveId = 1; var surfaceId = 1;
@@ -883,7 +978,18 @@ public static class ProfileFilletShellPlanner
var torus = new TorusSurface(torusCenter, capOut, radius, radius, na);
var rolls = new[] { new ProfileFilletStraightRollPlan(loop.Segments[a].Name, ta, na, centerA, centerAJunction, ProfileFilletRollEndKind.EndpointTermination, ProfileFilletRollEndKind.ReflexJunction), new ProfileFilletStraightRollPlan(loop.Segments[b].Name, tb, nb, centerB, centerBJunction, ProfileFilletRollEndKind.EndpointTermination, ProfileFilletRollEndKind.ReflexJunction) };
var junction = new ProfileReflexFilletJunctionPlan(classification.VertexId, classification, torusCenter, radius, torus, capJA, capJB, depth, 0d, majorEnd, Math.PI / 2d, Math.PI);
- var plan = new ProfileFilletShellPlan(target, radius, clearance, rolls, junction);
+ var rollAComponent = new StraightFilletRollComponent($"{target.StableId}:roll:{loop.Segments[a].Name}", loop.Segments[a].Provenance.StableId,
+ new CylinderSurface(centerA, ta, radius, capOut), centerA, centerAJunction, capAE, capJA, sideAE, depth,
+ $"axis={ta};inward={na};cap={capOut}", "external-or-parent", "junction-a",
+ [$"FilletSurface({loop.Segments[a].Name})"], ["M3", "ReusableStraightRoll"]);
+ var rollBComponent = new StraightFilletRollComponent($"{target.StableId}:roll:{loop.Segments[b].Name}", loop.Segments[b].Provenance.StableId,
+ new CylinderSurface(centerBJunction, tb, radius, capOut), centerBJunction, centerB, capJB, capBE, depth, sideBE,
+ $"axis={tb};inward={nb};cap={capOut}", "junction-b", "external-or-parent",
+ [$"FilletSurface({loop.Segments[b].Name})"], ["M3", "ReusableStraightRoll"]);
+ var junctionComponent = new ReflexSharpExactRollingJunctionComponent($"{target.StableId}:junction:{classification.VertexId}", classification.VertexId,
+ torus, $"axis={capOut};major={radius:R};minor={radius:R}",
+ ["ReflexJunctionPatch", "policy=ExactRolling"], ["M3", "ExactRolling", "HornToroidalPatch"]);
+ var plan = new ProfileFilletShellPlan(target, radius, clearance, rolls, junction, Components: [rollAComponent, junctionComponent, rollBComponent]);
var builder = new TopologyBuilder(); var geometry = new BrepGeometryStore(); var bindings = new BrepBindingModel(); var points = new Dictionary<VertexId, Point3D>();
var vertices = new Dictionary<string, VertexId>(StringComparer.Ordinal); var edges = new Dictionary<(VertexId, VertexId), EdgeId>(); var descendants = new List<SemanticTopologyDescendant>(); var curveId = 1; var surfaceId = 1;
diff --git a/Aetheris.Kernel.Firmament/Materializer/ProfileEdgeFinishMixedShellPlan.cs b/Aetheris.Kernel.Firmament/Materializer/ProfileEdgeFinishMixedShellPlan.cs
index 3cd8f76c..1c630b48 100644
--- a/Aetheris.Kernel.Firmament/Materializer/ProfileEdgeFinishMixedShellPlan.cs
+++ b/Aetheris.Kernel.Firmament/Materializer/ProfileEdgeFinishMixedShellPlan.cs
@@ -60,6 +60,21 @@ public sealed record ConicalChamferPatch(
LocalFrame, "source-arc@transition", InsetRadius == 0d ? "apex-vertex@cap" : "inset-arc@cap",
"line-seam:start", "line-seam:end", SemanticDescendants);
+/// <summary>
+/// Exact zero-source-radius limit at a sharp reflex line/line Profile vertex.
+/// The source boundary is one real apex vertex; the cap boundary is a circular
+/// arc of radius <see cref="FinishSize"/>. It is deliberately not represented
+/// as two mitered planar Chamfer patches.
+/// </summary>
+public sealed record SharpReflexChamferApexPatch(
+ string StableId, string SourceVertexId, ConeSurface Surface, double FinishSize,
+ double StartAngleRadians, double SweepAngleRadians, string LocalFrame,
+ IReadOnlyList<string> SemanticDescendants)
+ : AnalyticEdgeFinishPatch(StableId, SourceVertexId, ProfileEdgeFinishSurfaceFamily.Cone,
+ ProfileEdgeFinishRegularity.BoundedDegenerate, "SharpReflexChamferConeApexPlan", LocalFrame,
+ "sharp-reflex-apex@transition", "cap-contact-arc@cap",
+ "plane-cone-generator:start", "plane-cone-generator:end", SemanticDescendants);
+
/// <summary>
/// The regular rounded-source Chamfer is one conical-frustum sector. Its two
/// circular boundaries belong to the source and inset sections respectively;
@@ -478,6 +493,7 @@ public static class ProfileEdgeFinishMixedShellMaterializer
{
PlanarChamferPatch plane => SurfaceGeometry.FromPlane(plane.Surface),
ConicalChamferPatch cone => SurfaceGeometry.FromCone(cone.Surface),
+ SharpReflexChamferApexPatch apex => SurfaceGeometry.FromCone(apex.Surface),
_ => throw new InvalidOperationException("Mixed Chamfer plan contains non-Chamfer patch.")
};
Face($"{target.StableId}:chamfer:{loop.Segments[i].Name}", transitionUses, surface, SemanticTopologyRole.EdgeFinishReplacementFace, loop.Segments[i].Provenance.StableId);
diff --git a/Aetheris.Kernel.Firmament/Materializer/ProfileFilletContactShellPlan.cs b/Aetheris.Kernel.Firmament/Materializer/ProfileFilletContactShellPlan.cs
new file mode 100644
index 00000000..74d949e9
--- /dev/null
+++ b/Aetheris.Kernel.Firmament/Materializer/ProfileFilletContactShellPlan.cs
@@ -0,0 +1,174 @@
+using Aetheris.Kernel.Core.Geometry;
+using Aetheris.Kernel.Core.Geometry.Curves;
+using Aetheris.Kernel.Core.Math;
+
+namespace Aetheris.Kernel.Firmament.Materializer;
+
+/// <summary>Exact local boundary supplied by one analytic fillet component to its parent shell.</summary>
+public sealed record ProfileFilletContactBoundary(
+ string StableId,
+ string ComponentId,
+ string SourceStableId,
+ ProfileFilletContactBoundaryKind Kind,
+ CurveGeometry Curve,
+ ParameterInterval Trim,
+ bool TraversesWithCurveParameter,
+ Point3D Start,
+ Point3D End,
+ string RegularityEvidence,
+ IReadOnlyList<string> Provenance);
+
+public enum ProfileFilletContactBoundaryKind { CapContact, SideContact, PreviousInterface, NextInterface }
+
+/// <summary>
+/// Immutable, source-order contract used before a closed Fillet shell allocates
+/// any topology. It deliberately has no face or endpoint-termination ids.
+/// </summary>
+public sealed record ProfileFilletContactShellPlan(
+ ProfileBoundaryChamferTarget Target,
+ IReadOnlyList<ProfileFilletComponentContactContract> OrderedComponents,
+ IReadOnlyList<ProfileFilletContactBoundary> OrderedInterfaces,
+ IReadOnlyList<ProfileFilletContactBoundary> OrderedCapContacts,
+ IReadOnlyDictionary<string, IReadOnlyList<ProfileFilletContactBoundary>> SideContactsBySource,
+ IReadOnlyList<string> Provenance);
+
+public sealed record ProfileFilletComponentContactContract(
+ string ComponentId,
+ string SourceStableId,
+ ProfileEdgeFinishSurfaceFamily SurfaceFamily,
+ ProfileFilletContactBoundary CapContact,
+ IReadOnlyList<ProfileFilletContactBoundary> SideContacts,
+ ProfileFilletContactBoundary PreviousInterface,
+ ProfileFilletContactBoundary NextInterface,
+ IReadOnlyList<string> SemanticDescendants,
+ IReadOnlyList<string> Provenance);
+
+public sealed record ProfileFilletContactShellPlanResult(bool Succeeded, ProfileFilletContactShellPlan? Plan, IReadOnlyList<string> Diagnostics);
+
+/// <summary>
+/// Contact-only planner for the rounded, source-tangent portion of a whole
+/// Profile. Sharp vertices are intentionally rejected here until their M2/M3
+/// components supply the displaced cap/side boundaries; this prevents a future
+/// emitter from silently substituting a naïve source offset at those vertices.
+/// </summary>
+public static class ProfileFilletContactShellPlanner
+{
+ private const double Tolerance = 1e-8;
+
+ public static ProfileFilletContactShellPlanResult TryPlan(
+ ResolvedProfile2D profile, ProfileBoundaryChamferTarget target, ProfileEdgeFinishMixedShellPlan mixed)
+ {
+ ProfileFilletContactShellPlanResult Fail(string diagnostic) => new(false, null, [diagnostic]);
+ if (mixed.FinishKind != ProfileEdgeFinishKind.Fillet) return Fail("ProfileFilletContactShellFilletPlanRequired");
+ var loop = profile.Loops.SingleOrDefault(x => x.Name == target.LoopId);
+ if (loop is null || target.ChainKind != ProfileBoundaryChamferChainKind.ClosedLoop) return Fail("ProfileFilletContactShellClosedLoopRequired");
+ if (loop.Segments.Count != mixed.OrderedPatches.Count) return Fail("ProfileFilletContactShellProfileMismatch");
+ var area = SignedArea(loop);
+ if (Math.Abs(area) <= Tolerance) return Fail("ProfileFilletContactShellProfileDegenerate");
+
+ // The extracted M2/M3 components own displaced contacts at sharp
+ // line/line vertices. Do not let a rounded-source planner invent them.
+ for (var i = 0; i < loop.Segments.Count; i++)
+ {
+ var previous = loop.Segments[(i + loop.Segments.Count - 1) % loop.Segments.Count].Geometry;
+ var current = loop.Segments[i].Geometry;
+ if (previous is LineArcLineSegment2D && current is LineArcLineSegment2D)
+ return Fail($"ProfileFilletContactSharpJunctionComponentRequired:vertex={loop.Name}.{loop.Segments[i].Name}.Start");
+ }
+
+ var frame = profile.EffectiveConstructionPlane;
+ var cap = profile.LocalEndDepth ?? 1d;
+ var transition = cap - mixed.FinishSize;
+ var components = new List<ProfileFilletComponentContactContract>(loop.Segments.Count);
+ var interfaces = new List<ProfileFilletContactBoundary>(loop.Segments.Count);
+ var caps = new List<ProfileFilletContactBoundary>(loop.Segments.Count);
+ var sides = new Dictionary<string, IReadOnlyList<ProfileFilletContactBoundary>>(StringComparer.Ordinal);
+
+ for (var i = 0; i < loop.Segments.Count; i++)
+ {
+ var segment = loop.Segments[i];
+ var patch = mixed.OrderedPatches[i];
+ var source = segment.Provenance.StableId;
+ var componentId = patch.StableId;
+ var (sourceStart, sourceEnd) = Ends(segment.Geometry);
+ var start = frame.ToWorld(sourceStart, transition);
+ var end = frame.ToWorld(sourceEnd, transition);
+ var capCurve = CapCurve(segment.Geometry, area, mixed.FinishSize, cap, frame, out var capStart, out var capEnd);
+ var capContact = new ProfileFilletContactBoundary($"{componentId}:cap", componentId, source, ProfileFilletContactBoundaryKind.CapContact,
+ capCurve, Trim(segment.Geometry), Oriented(segment.Geometry), capStart, capEnd, patch.Regularity.ToString(), ["SourceOrder", "ParentCap"]);
+ var side = new ProfileFilletContactBoundary($"{componentId}:side", componentId, source, ProfileFilletContactBoundaryKind.SideContact,
+ Curve(segment.Geometry, transition, frame, start, end), Trim(segment.Geometry), Oriented(segment.Geometry), start, end, patch.Regularity.ToString(), ["SourceOrder", "ParentSide"]);
+ var previous = Interface(componentId, source, ProfileFilletContactBoundaryKind.PreviousInterface, start, capStart, patch, mixed.FinishSize);
+ var next = Interface(componentId, source, ProfileFilletContactBoundaryKind.NextInterface, capEnd, end, patch, mixed.FinishSize);
+ components.Add(new(componentId, source, patch.SurfaceFamily, capContact, [side], previous, next, patch.SemanticDescendants, [patch.PlannerKind, "ContactContract"]));
+ caps.Add(capContact); interfaces.Add(previous); interfaces.Add(next); sides.Add(source, [side]);
+ }
+
+ return new(true, new(target, components, interfaces, caps, sides,
+ ["ResolvedProfile2D", "ProfileEdgeFinishMixedShellPlan", "ContactBeforeTopology"]), []);
+ }
+
+ private static ProfileFilletContactBoundary Interface(string componentId, string source, ProfileFilletContactBoundaryKind kind,
+ Point3D start, Point3D end, AnalyticEdgeFinishPatch patch, double radius)
+ {
+ var centre = start + (end - start) * .5d;
+ var radial = start - centre;
+ var normal = radial.Cross(end - centre);
+ if (normal.Length <= Tolerance) normal = new Vector3D(0d, 0d, 1d);
+ return new($"{componentId}:{kind}", componentId, source, kind,
+ CurveGeometry.FromCircle(new Circle3Curve(centre, Direction3D.Create(normal), radius, Direction3D.Create(radial))),
+ new ParameterInterval(0d, Math.PI / 2d), true, start, end, patch.Regularity.ToString(), ["ExactRollingMeridian", "SourceTangency"]);
+ }
+
+ private static CurveGeometry CapCurve(LineArcProfileCurve2D curve, double area, double distance, double depth, ConstructionPlane frame, out Point3D start, out Point3D end)
+ {
+ LineArcProfileCurve2D? inset = curve switch
+ {
+ LineArcLineSegment2D line => OffsetLine(line, area, distance),
+ LineArcCircularArc2D arc => OffsetArc(arc, area, distance),
+ _ => throw new NotSupportedException()
+ };
+ if (inset is null) throw new InvalidOperationException("ProfileFilletContactSphereLimitRequiresExplicitApexComponent");
+ var ends = Ends(inset); start = frame.ToWorld(ends.Start, depth); end = frame.ToWorld(ends.End, depth);
+ return Curve(inset, depth, frame, start, end);
+ }
+
+ private static LineArcLineSegment2D OffsetLine(LineArcLineSegment2D line, double area, double distance)
+ {
+ var dx = line.End.X - line.Start.X; var dy = line.End.Y - line.Start.Y; var length = Math.Sqrt(dx * dx + dy * dy);
+ var nx = area > 0d ? -dy / length : dy / length; var ny = area > 0d ? dx / length : -dx / length;
+ return new((line.Start.X + nx * distance, line.Start.Y + ny * distance), (line.End.X + nx * distance, line.End.Y + ny * distance));
+ }
+ private static LineArcCircularArc2D? OffsetArc(LineArcCircularArc2D arc, double area, double distance)
+ {
+ var convex = Math.Sign(arc.SweepAngleRadians) * Math.Sign(area) >= 0d;
+ var radius = convex ? arc.Radius - distance : arc.Radius + distance;
+ return radius <= Tolerance ? null : new(arc.Center, radius, arc.StartAngleRadians, arc.SweepAngleRadians);
+ }
+ private static ((double X, double Y) Start, (double X, double Y) End) Ends(LineArcProfileCurve2D curve) => curve switch
+ {
+ LineArcLineSegment2D line => (line.Start, line.End),
+ LineArcCircularArc2D arc => ((arc.Center.X + arc.Radius * Math.Cos(arc.StartAngleRadians), arc.Center.Y + arc.Radius * Math.Sin(arc.StartAngleRadians)),
+ (arc.Center.X + arc.Radius * Math.Cos(arc.StartAngleRadians + arc.SweepAngleRadians), arc.Center.Y + arc.Radius * Math.Sin(arc.StartAngleRadians + arc.SweepAngleRadians))),
+ _ => throw new NotSupportedException()
+ };
+ private static CurveGeometry Curve(LineArcProfileCurve2D curve, double depth, ConstructionPlane frame, Point3D start, Point3D end) => curve switch
+ {
+ LineArcLineSegment2D => CurveGeometry.FromLine(new Line3Curve(start, Direction3D.Create(end - start))),
+ LineArcCircularArc2D arc => CurveGeometry.FromCircle(new Circle3Curve(frame.ToWorld(arc.Center, depth), frame.AxisZ, arc.Radius, frame.AxisX)),
+ _ => throw new NotSupportedException()
+ };
+ private static ParameterInterval Trim(LineArcProfileCurve2D curve) => curve switch
+ {
+ LineArcLineSegment2D line => new(0d, Math.Sqrt(Math.Pow(line.End.X - line.Start.X, 2d) + Math.Pow(line.End.Y - line.Start.Y, 2d))),
+ LineArcCircularArc2D arc => new(Math.Min(arc.StartAngleRadians, arc.StartAngleRadians + arc.SweepAngleRadians), Math.Max(arc.StartAngleRadians, arc.StartAngleRadians + arc.SweepAngleRadians)),
+ _ => throw new NotSupportedException()
+ };
+ private static bool Oriented(LineArcProfileCurve2D curve) => curve is not LineArcCircularArc2D arc || arc.SweepAngleRadians >= 0d;
+ private static double SignedArea(ResolvedProfileLoop2D loop) => loop.Segments.Sum(x => x.Geometry switch
+ {
+ LineArcLineSegment2D line => line.Start.X * line.End.Y - line.End.X * line.Start.Y,
+ LineArcCircularArc2D arc => 2d * (arc.Center.X * arc.Radius * (Math.Sin(arc.StartAngleRadians + arc.SweepAngleRadians) - Math.Sin(arc.StartAngleRadians)) - arc.Center.Y * arc.Radius * (Math.Cos(arc.StartAngleRadians + arc.SweepAngleRadians) - Math.Cos(arc.StartAngleRadians)) + arc.Radius * arc.Radius * arc.SweepAngleRadians),
+ _ => 0d
+ }) * .5d;
+}
diff --git a/docs/firmament/fillet-contact-shell-composer-x6.md b/docs/firmament/fillet-contact-shell-composer-x6.md
new file mode 100644
index 00000000..37069d8b
--- /dev/null
+++ b/docs/firmament/fillet-contact-shell-composer-x6.md
@@ -0,0 +1,28 @@
+# Fillet contact-shell composer X6
+
+X6 introduces the contact-boundary IR used to keep Profile Fillet shell
+composition honest. A `ProfileFilletContactBoundary` records a component and
+source owner, exact curve and trim, parameter traversal, endpoints, regularity
+evidence, and provenance. `ProfileFilletComponentContactContract` groups the
+cap contact, source-side contacts, and predecessor/successor interfaces for a
+single analytic component. `ProfileFilletContactShellPlan` is immutable and
+source ordered; it is intentionally free of B-rep faces, shell ids, and
+endpoint-termination topology.
+
+The contact planner now validates the composition boundary before allocating a
+face. Rounded source-tangent components can describe their source and cap
+contacts, while a sharp line/line vertex is rejected with
+`ProfileFilletContactSharpJunctionComponentRequired`. The release card proves
+the first unresolved contact is the wraparound `Outer.Bottom.Start` junction.
+This is materially earlier and more specific than the former
+`ArcDerivedCompositionPending` route failure.
+
+The remaining implementation is narrowly defined: resolve each sharp M2/M3
+component's displaced cap/side contacts into the graph, then emit one
+parent-owned cap, the trimmed source sides, and the shared analytic edges. It
+must not replace those contacts with offset-profile intersections, suppress
+STEP preflight, introduce NURBS, or add Boolean/post-B-rep repair.
+
+No whole-loop Fillet artifact is claimed yet. Existing M1/M2/M3 materializers
+remain the geometry ground truth while their extracted components are promoted
+to exact contact contracts.
diff --git a/docs/firmament/fillet-patch-extraction-x5.md b/docs/firmament/fillet-patch-extraction-x5.md
new file mode 100644
index 00000000..01c9c14c
--- /dev/null
+++ b/docs/firmament/fillet-patch-extraction-x5.md
@@ -0,0 +1,64 @@
+# Fillet patch extraction X5
+
+X5 separates the reusable analytic part of the existing finite Profile Fillet
+routes from their open-chain shell closure. This is deliberately a planning
+change: M1/M2/M3 continue to use their established materializers while the
+closed mixed line/arc shell is completed only after its sharp contact topology
+is composed exactly.
+
+## Audit
+
+The old M1 straight-edge route owns a quarter-cylinder plus two planar endpoint
+termination faces. M2 owns two cylinder rolls, one sphere junction, a cap,
+trimmed sides, and endpoint faces. M3 similarly owns two rolls and its horn
+torus. `SphereSeamCompatibility` substitutes only the M3 torus junction with a
+sphere. The cylinders, sphere/torus surfaces, their roll-to-junction seams,
+cap contacts, side contacts, semantic identity, and source provenance are
+reusable. Endpoint termination faces, retained sharp stubs, and complete cap
+and side closure are not.
+
+## Component IR
+
+`ProfileFilletComponent` records source identity, analytic family, frame,
+predecessor/successor interfaces, cap and side contacts, semantic descendants,
+and provenance. Its concrete variants are:
+
+- `StraightFilletRollComponent`;
+- `ConvexSharpFilletJunctionComponent`;
+- `ReflexSharpExactRollingJunctionComponent`;
+- `ReflexSharpSphereCompatibilityComponent`;
+- `FilletSeamComponent` for an explicit oriented shared boundary.
+
+M1 now exposes its roll component separately from the start/end termination
+policy. M2 and both M3 policies expose ordered roll/junction/roll components
+in `ProfileFilletShellPlan.Components`. The component records have no
+termination-face interface or semantic descendant.
+
+## Composition boundary
+
+The existing X4 mixed plan already owns the rounded-source cylinder, sphere
+limit, and torus components plus source-ordered Cylinder/Torus and
+Cylinder/Sphere seam records. An attempted direct adaptation of the Chamfer
+emitter was rejected by the STEP B-rep preflight: a sharp M2/M3 junction's
+contacts are not source-offset endpoints. In particular, its roll side and
+cap contacts are displaced into the junction, so replacing the junction with
+an ordinary line/arc seam creates trim points off the Cylinder, Sphere, and
+Torus surfaces. This validation is retained as the required next composition
+constraint; it must not be bypassed by disabling preflight or using NURBS.
+
+X6 now adds `ProfileFilletContactBoundary` and an immutable contact-shell plan
+ahead of topology allocation. It rejects the first unresolved sharp
+wraparound contact with a typed invariant rather than allowing an invalid
+offset-derived B-rep. See `fillet-contact-shell-composer-x6.md`. The next
+emitter must resolve the extracted sharp components and the X4 rounded
+components before allocating one parent top-cap boundary and parent-owned side
+trims. A closed loop has zero endpoint termination faces; open M1/M2/M3
+fixtures retain their explicit external terminations.
+
+## Status
+
+The reusable sharp component contract and regression coverage are in place.
+The seven-station closed-loop Fillet materializer, its volume assertion,
+persistent Fillet STEP artifacts, compatibility comparison, inspection JSON,
+and external-kernel smoke remain blocked on that exact global contact-boundary
+composer. No Fillet artifact is claimed by this document.
diff --git a/docs/firmament/mixed-analytic-edgefinish-shell-x4.md b/docs/firmament/mixed-analytic-edgefinish-shell-x4.md
index 274d2a25..3572719e 100644
--- a/docs/firmament/mixed-analytic-edgefinish-shell-x4.md
+++ b/docs/firmament/mixed-analytic-edgefinish-shell-x4.md
@@ -79,12 +79,10 @@ reimport as one enclosed manifold shell with 26 Plane, 5 Cylinder, and 5 Cone
faces and zero NURBS. The finite ConvexMedium apex is a topological vertex,
not a zero-radius edge.
-The Fillet emitter remains blocked. Existing sharp sphere/horn-torus planners
-materialize complete two-line bodies with cap, side, and endpoint-termination
-faces; they do not expose reusable junction patches for insertion into the
-closed source-order shell. That component extraction is now the concrete next
-blocker. No Fillet or compatibility STEP, finished-volume assertion, or
-external-kernel smoke is claimed. The next implementation must extract those
-sharp patches and compose them with the already-planned cylinder/torus/sphere
-patches as one shell; it must not substitute NURBS, Booleans, or post-Brep
-surgery.
+X5 has extracted the M1/M2/M3 sharp analytic components and records them in
+the finite-plan output without granting them ownership of endpoint policy.
+See [fillet-patch-extraction-x5.md](fillet-patch-extraction-x5.md). The
+closed-loop emitter remains intentionally unclaimed: preflight demonstrates
+that sharp contacts cannot be represented as ordinary source-offset seams.
+The next step is the exact parent-owned cap/side composer, without NURBS,
+Booleans, post-Brep surgery, or preflight bypass.
diff --git a/docs/firmament/profile-fillet-common-cases-x2.md b/docs/firmament/profile-fillet-common-cases-x2.md
index 85eb229a..9f30e327 100644
--- a/docs/firmament/profile-fillet-common-cases-x2.md
+++ b/docs/firmament/profile-fillet-common-cases-x2.md
@@ -48,17 +48,19 @@ M1.
M2 now materializes the first admitted chain: two adjacent 90-degree convex
line segments use two cylinders, one exact sphere, and only their two external
-terminations. Reflex pairs and chains longer than two still report their typed
-topology boundary; a complete loop reports
-`ProfileBoundaryFilletLoopTopologyNotMaterialized`. Composed hosts keep M1's
+terminations. X5 exposes those cylinders and the sharp sphere as reusable
+components, and does the equivalent for M3's horn torus and the opt-in
+SphereSeamCompatibility sphere. The finite fixtures retain their external
+terminations; reusable components do not own them. Chains longer than two and
+a complete loop still report `ProfileBoundaryFilletLoopTopologyNotMaterialized`
+until the parent-owned mixed cap/side composer is emitted. Composed hosts keep M1's
conservative single-roll Shaft/Counterbore corridor check and report the
feature-specific collision diagnostics before the separate compose boundary.
-The next bounded implementation must create one authoritative
-`ProfileBoundaryFilletPlan` with typed straight-roll, convex-junction,
-reflex-junction, and endpoint-termination subplans, then emit the complete
-shell from that plan. It cannot be obtained safely by stitching M1 endpoint
-faces or by generic B-rep edge editing.
+The next bounded implementation composes the extracted components with the X4
+rounded-source components into one authoritative closed-loop plan. It cannot
+be obtained safely by stitching M1 endpoint faces or by generic B-rep edge
+editing. See `fillet-patch-extraction-x5.md`.
## Rounded source boundary
diff --git a/docs/firmament/v2-canonical-authoring.md b/docs/firmament/v2-canonical-authoring.md
index 7e836afb..216e531f 100644
--- a/docs/firmament/v2-canonical-authoring.md
+++ b/docs/firmament/v2-canonical-authoring.md
@@ -271,10 +271,12 @@ Legacy lowercase and phase-style inputs remain compatibility inputs during
migration. New authoring should use the canonical root shown above.
Profile EdgeFinish targets are always source-bound (`Profile.Outer`, a source
-segment, or a named source-chain selection). Current materialized Chamfer and
-Fillet routes cover line-only source loops; circular source segments bind and
-report a station-specific missing exact planner rather than falling back to
-anonymous BRep edge inference. See `profile-edgefinish-chimera-x1.md`.
+segment, or a named source-chain selection). Chamfer materializes admitted
+mixed line/arc loops. Fillet exposes exact line-roll, sharp sphere/horn-torus,
+compatibility-sphere, and rounded Cylinder/Sphere/Torus component plans; its
+mixed closed-loop B-rep composer is not yet released, so it continues to
+report a typed materialization boundary rather than falling back to anonymous
+BRep edge inference. See `fillet-patch-extraction-x5.md`.
For the seven-station mixed line/arc release card, EdgeFinish policy is
source-bound: lines select Plane Chamfer/Cylinder Fillet patches; admitted arcs