Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Add convex junction fillet shell planning

Yuechen Licc4e98da9f13
diff --git a/Aetheris.CLI/CliRunner.cs b/Aetheris.CLI/CliRunner.cs
index 56438466..eede481a 100644
--- a/Aetheris.CLI/CliRunner.cs
+++ b/Aetheris.CLI/CliRunner.cs
@@ -3232,22 +3232,35 @@ public static class CliRunner
string? Side, double? Radius, double? EndClearance, string? EndpointPolicy,
double[]? CylinderAxis, double[]? CylinderCenterlineStart, double[]? CylinderCenterlineEnd,
double[]? CapContactStart, double[]? CapContactEnd, double[]? SideContactStart, double[]? SideContactEnd,
- string CorridorClassification, IReadOnlyList<string> GeneratedDescendants, IReadOnlyList<string> Provenance);
+ string CorridorClassification, IReadOnlyList<string> GeneratedDescendants, IReadOnlyList<string> Provenance,
+ ProfileConvexFilletJunctionInspection? ConvexJunction);
+
+ private sealed record ProfileConvexFilletJunctionInspection(
+ string VertexId, string Classification, double InteriorAngleDegrees, double Radius,
+ double[] SphereCenter, IReadOnlyList<double[]> RollAxes, IReadOnlyList<double[]> RollExternalCenters,
+ IReadOnlyList<double[]> RollJunctionCenters);
private static ProfileStraightEdgeFilletInspection? DescribeProfileStraightEdgeFillet(ResolvedProfile2D profile, string source, string hostBodyId)
{
if (!ProfileBoundaryChamferSourceBinder.HasProfileBoundaryFillet(source)) return null;
if (!ProfileBoundaryChamferSourceBinder.TryBindFillet(source, profile, hostBodyId, out var target, out var radius, out var clearance, out var diagnostic))
- return new(false, diagnostic, null, null, null, null, [], null, null, null, null, null, null, null, null, null, null, null, "RejectedBeforePlan", [], []);
- var result = ProfileStraightEdgeFilletPlanner.TryPlan(profile, target!, radius, clearance);
- if (!result.Succeeded || result.Plan is null)
- return new(false, result.Diagnostics.FirstOrDefault(), target!.StableId, target.ProfileId, target.LoopId, target.ChainKind.ToString(), target.SegmentIds, target.Side.ToString(), radius, clearance, null, null, null, null, null, null, null, null, "RejectedBeforeTopology", [], []);
- var plan = result.Plan;
+ return new(false, diagnostic, null, null, null, null, [], null, null, null, null, null, null, null, null, null, null, null, "RejectedBeforePlan", [], [], null);
+ var result = ProfileFilletShellPlanner.TryPlan(profile, target!, radius, clearance);
+ if (!result.Succeeded)
+ return new(false, result.Diagnostics.FirstOrDefault(), target!.StableId, target.ProfileId, target.LoopId, target.ChainKind.ToString(), target.SegmentIds, target.Side.ToString(), radius, clearance, null, null, null, null, null, null, null, null, "RejectedBeforeTopology", [], [], null);
static double[] V(Direction3D value) => [value.ToVector().X, value.ToVector().Y, value.ToVector().Z];
static double[] P(Point3D value) => [value.X, value.Y, value.Z];
- return new(true, null, target!.StableId, target.ProfileId, target.LoopId, target.ChainKind.ToString(), target.SegmentIds, target.Side.ToString(), radius, clearance, plan.EndpointPolicy,
- V(plan.Tangent), P(plan.CylinderCenterlineStart), P(plan.CylinderCenterlineEnd), P(plan.CapContactStart), P(plan.CapContactEnd), P(plan.SideContactStart), P(plan.SideContactEnd),
- "DisjointNoCavitiesInBareProfileM1", result.Correspondence?.Descendants.Select(x => x.StableId).OrderBy(x => x, StringComparer.Ordinal).ToArray() ?? [], result.Correspondence?.ProvenanceChain ?? []);
+ if (result.Plan is not null)
+ {
+ var plan = result.Plan;
+ var junction = new ProfileConvexFilletJunctionInspection(plan.Junction.VertexId, plan.Junction.Classification.Classification.ToString(), plan.Junction.Classification.MaterialInteriorAngleRadians * 180d / Math.PI, plan.Junction.Radius, P(plan.Junction.Center), plan.Rolls.Select(roll => V(roll.Tangent)).ToArray(), plan.Rolls.Select(roll => P(roll.ExternalCenter)).ToArray(), plan.Rolls.Select(roll => P(roll.JunctionCenter)).ToArray());
+ return new(true, null, target!.StableId, target.ProfileId, target.LoopId, target.ChainKind.ToString(), target.SegmentIds, target.Side.ToString(), radius, clearance, plan.EndpointPolicy,
+ null, null, null, null, null, null, null, "DisjointNoCavitiesInBareProfileM2", result.Correspondence?.Descendants.Select(x => x.StableId).OrderBy(x => x, StringComparer.Ordinal).ToArray() ?? [], result.Correspondence?.ProvenanceChain ?? [], junction);
+ }
+ var single = result.SingleSegmentPlan!;
+ return new(true, null, target!.StableId, target.ProfileId, target.LoopId, target.ChainKind.ToString(), target.SegmentIds, target.Side.ToString(), radius, clearance, single.EndpointPolicy,
+ V(single.Tangent), P(single.CylinderCenterlineStart), P(single.CylinderCenterlineEnd), P(single.CapContactStart), P(single.CapContactEnd), P(single.SideContactStart), P(single.SideContactEnd),
+ "DisjointNoCavitiesInBareProfileM1", result.Correspondence?.Descendants.Select(x => x.StableId).OrderBy(x => x, StringComparer.Ordinal).ToArray() ?? [], result.Correspondence?.ProvenanceChain ?? [], null);
}
private static IReadOnlyList<ProfileJunctionInspection> DescribeProfileJunctions(ResolvedProfile2D profile, string source, string hostBodyId)
diff --git a/Aetheris.Kernel.Firmament.Tests/Integration/ProfileBoundaryChamferFixtureTests.cs b/Aetheris.Kernel.Firmament.Tests/Integration/ProfileBoundaryChamferFixtureTests.cs
index b74c4180..461f8d41 100644
--- a/Aetheris.Kernel.Firmament.Tests/Integration/ProfileBoundaryChamferFixtureTests.cs
+++ b/Aetheris.Kernel.Firmament.Tests/Integration/ProfileBoundaryChamferFixtureTests.cs
@@ -90,11 +90,53 @@ public sealed class ProfileBoundaryChamferFixtureTests
}
}
+ [Theory]
+ [InlineData("profile-fillet-convex-two-segment-top.firmament")]
+ [InlineData("profile-fillet-convex-two-segment-bottom.firmament")]
+ public void ConvexTwoSegmentFilletFixture_ExportsDeterministicTwoCylindersAndSphere(string fixtureName)
+ {
+ var source = FirmamentCorpusHarness.ResolveFixtureFullPath($"fixtures/FirmamentV2/Canonical/valid/{fixtureName}");
+ var firstOutput = Path.Combine(Path.GetTempPath(), $"aetheris-{Guid.NewGuid():N}.step");
+ var secondOutput = Path.Combine(Path.GetTempPath(), $"aetheris-{Guid.NewGuid():N}.step");
+ try
+ {
+ var first = FirmamentBuildAndExport.Run(source, firstOutput); var second = FirmamentBuildAndExport.Run(source, secondOutput);
+ Assert.True(first.IsSuccess, string.Join(Environment.NewLine, first.Diagnostics.Select(item => item.Message)));
+ Assert.True(second.IsSuccess, string.Join(Environment.NewLine, second.Diagnostics.Select(item => item.Message)));
+ Assert.Equal(first.Value.Export.StepText, second.Value.Export.StepText);
+ var imported = Step242Importer.ImportBody(first.Value.Export.StepText);
+ Assert.True(imported.IsSuccess, string.Join(Environment.NewLine, imported.Diagnostics.Select(item => item.Message)));
+ Assert.Equal(2, imported.Value!.Geometry.Surfaces.Count(item => item.Value.Kind == SurfaceGeometryKind.Cylinder));
+ Assert.Equal(1, imported.Value.Geometry.Surfaces.Count(item => item.Value.Kind == SurfaceGeometryKind.Sphere));
+ var mass = BrepMassProperties.Evaluate(imported.Value);
+ Assert.True(mass.IsEnclosed);
+ Assert.True(mass.IsOrientationConsistent);
+ }
+ finally
+ {
+ if (File.Exists(firstOutput)) File.Delete(firstOutput);
+ if (File.Exists(secondOutput)) File.Delete(secondOutput);
+ }
+ }
+
+ [Fact]
+ public void ConvexTwoSegmentFillet_ConceptPathAndExplicitSegmentsAreStepEquivalent()
+ {
+ var concept = FirmamentCorpusHarness.ResolveFixtureFullPath("fixtures/FirmamentV2/Canonical/valid/profile-fillet-convex-two-segment-concept-path.firmament");
+ var lowLevel = FirmamentCorpusHarness.ResolveFixtureFullPath("fixtures/FirmamentV2/Canonical/valid/profile-fillet-convex-two-segment-low-level.firmament");
+ var conceptResult = FirmamentBuildAndExport.Run(concept, Path.Combine(Path.GetTempPath(), $"aetheris-{Guid.NewGuid():N}.step"));
+ var lowLevelResult = FirmamentBuildAndExport.Run(lowLevel, Path.Combine(Path.GetTempPath(), $"aetheris-{Guid.NewGuid():N}.step"));
+
+ Assert.True(conceptResult.IsSuccess, string.Join(Environment.NewLine, conceptResult.Diagnostics.Select(item => item.Message)));
+ Assert.True(lowLevelResult.IsSuccess, string.Join(Environment.NewLine, lowLevelResult.Diagnostics.Select(item => item.Message)));
+ Assert.Equal(conceptResult.Value.Export.StepText, lowLevelResult.Value.Export.StepText);
+ }
+
[Theory]
[InlineData("profile-compose-reflex-chamfer-shaft-collision.firmament", "ProfileBoundaryChamferIntersectsShaft")]
[InlineData("profile-compose-reflex-chamfer-counterbore-collision.firmament", "ProfileBoundaryChamferIntersectsCounterbore")]
[InlineData("profile-chamfer-reflex-inset-collapse.firmament", "ProfileBoundaryChamferInsetCollapse")]
- [InlineData("profile-fillet-reflex-junction-not-materialized.firmament", "ProfileBoundaryFilletJunctionTopologyNotMaterialized")]
+ [InlineData("profile-fillet-reflex-junction-not-materialized.firmament", "ProfileBoundaryFilletReflexJunctionUnsupported")]
[InlineData("profile-straight-edge-fillet-shaft-collision.firmament", "ProfileBoundaryFilletIntersectsShaft")]
public void InvalidFixture_ProducesTypedProfileBoundaryDiagnostic(string fixtureName, string diagnostic)
{
diff --git a/Aetheris.Kernel.Firmament.Tests/Integration/ProfileBoundaryChamferTests.cs b/Aetheris.Kernel.Firmament.Tests/Integration/ProfileBoundaryChamferTests.cs
index 2ab3c4fe..8d6fc719 100644
--- a/Aetheris.Kernel.Firmament.Tests/Integration/ProfileBoundaryChamferTests.cs
+++ b/Aetheris.Kernel.Firmament.Tests/Integration/ProfileBoundaryChamferTests.cs
@@ -1,4 +1,5 @@
using Aetheris.Kernel.Firmament.Materializer;
+using Aetheris.Kernel.Core.Geometry;
namespace Aetheris.Kernel.Firmament.Tests.Integration;
@@ -146,6 +147,47 @@ public sealed class ProfileBoundaryChamferTests
Assert.Contains(build.Diagnostics, x => x.Message.StartsWith("ProfileBoundaryFilletIntersectsShaft", StringComparison.Ordinal));
}
+ [Theory]
+ [InlineData("Top", 6d)]
+ [InlineData("Bottom", 2d)]
+ public void PlansTwoAdjacentConvexSegmentsAsTwoRollsAndOneSphere(string side, double expectedCenterZ)
+ {
+ var source = $"Selection Corner {{ Source: Bracket.Outer.[South, East] Require: ConnectedChain }} Modify Body {{ EdgeFinish Round {{ Target: Corner On: {side} Kind: Fillet Radius: 2mm EndClearance: 3mm }} }}";
+ Assert.True(ProfileBoundaryChamferSourceBinder.TryBindFillet(source, Profile(), "Bracket", out var target, out var radius, out var clearance, out var diagnostic), diagnostic);
+
+ var result = ProfileFilletShellPlanner.TryPlan(Profile(), target!, radius, clearance);
+
+ Assert.True(result.Succeeded, string.Join("; ", result.Diagnostics));
+ Assert.NotNull(result.Plan);
+ Assert.Equal(2, result.Plan!.Rolls.Count);
+ Assert.Equal(ProfileJunctionKind.ConvexProfileJunction, result.Plan.Junction.Classification.Classification);
+ Assert.Equal(18d, result.Plan.Junction.Center.X, 8);
+ Assert.Equal(2d, result.Plan.Junction.Center.Y, 8);
+ Assert.Equal(expectedCenterZ, result.Plan.Junction.Center.Z, 8);
+ Assert.Equal(2d, result.Plan.Junction.Radius, 8);
+ var sphereToRollA = (result.Plan.Junction.SideAContact - result.Plan.Junction.Center) / result.Plan.Junction.Radius;
+ var sphereToRollB = (result.Plan.Junction.SideBContact - result.Plan.Junction.Center) / result.Plan.Junction.Radius;
+ Assert.InRange((sphereToRollA + result.Plan.Rolls[0].InwardNormal.ToVector()).Length, 0d, 1e-12d);
+ Assert.InRange((sphereToRollB + result.Plan.Rolls[1].InwardNormal.ToVector()).Length, 0d, 1e-12d);
+ Assert.Equal(2, result.Body!.Geometry.Surfaces.Count(item => item.Value.Kind == SurfaceGeometryKind.Cylinder));
+ Assert.Equal(1, result.Body.Geometry.Surfaces.Count(item => item.Value.Kind == SurfaceGeometryKind.Sphere));
+ 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));
+ }
+
+ [Fact]
+ public void RejectsReflexAndThreeSegmentFilletChainsBeforeTopology()
+ {
+ const string reflex = "Selection Notch { Source: Bracket.Outer.[Inner, Upright] Require: ConnectedChain } Modify Body { EdgeFinish Round { Target: Notch On: Top Kind: Fillet Radius: 2mm } }";
+ Assert.True(ProfileBoundaryChamferSourceBinder.TryBindFillet(reflex, LProfile(), "Bracket", out var reflexTarget, out var reflexRadius, out var reflexClearance, out var diagnostic), diagnostic);
+ Assert.Contains("ProfileBoundaryFilletReflexJunctionUnsupported", ProfileFilletShellPlanner.TryPlan(LProfile(), reflexTarget!, reflexRadius, reflexClearance).Diagnostics);
+
+ 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);
+ Assert.Contains("ProfileBoundaryFilletJunctionTopologyNotMaterialized", ProfileFilletShellPlanner.TryPlan(Profile(), threeTarget!, threeRadius, threeClearance).Diagnostics);
+ }
+
private static ResolvedProfile2D Profile()
{
var points = new[] { (0d, 0d), (20d, 0d), (20d, 10d), (0d, 10d) };
diff --git a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs
index 7a70e7a3..9e538572 100644
--- a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs
@@ -366,21 +366,21 @@ public static class FirmamentBuildAndExport
{
if (!ProfileBoundaryChamferSourceBinder.TryBindFillet(source, profile, profile.Name, out var filletTarget, out var radius, out var clearance, out var filletDiagnostic))
return Fail(filletDiagnostic ?? "ProfileBoundaryFilletBindingFailed");
- var fillet = ProfileStraightEdgeFilletPlanner.TryPlan(profile, filletTarget!, radius, clearance);
+ var fillet = ProfileFilletShellPlanner.TryPlan(profile, filletTarget!, radius, clearance);
if (!fillet.Succeeded || fillet.Body is null || fillet.Correspondence is null)
return Fail(fillet.Diagnostics.FirstOrDefault() ?? "ProfileBoundaryFilletPlanningFailed");
if (!FirmamentManifoldChecker.IsManifold(fillet.Body)) return Fail("ProfileBoundaryFilletNonManifold");
var filletStep = Step242Exporter.ExportBody(fillet.Body, new Step242ExportOptions
{
ProductName = filletTarget!.StableId,
- ApplicationName = "Aetheris.Firmament.ProfileStraightEdgeFillet.M1",
+ ApplicationName = fillet.Plan is null ? "Aetheris.Firmament.ProfileStraightEdgeFillet.M1" : "Aetheris.Firmament.ProfileConvexFilletJunction.M2",
BrepExportPreflightMode = BrepExportPreflightMode.Enforce,
BrepExportPreflightPolicy = BrepExportPreflightPolicy.TrustedProductionRoute
});
if (!filletStep.IsSuccess || filletStep.Value is null) return KernelResult<FirmamentStepExportResult>.Failure(filletStep.Diagnostics);
var filletReimport = Step242Importer.ImportBody(filletStep.Value);
if (!filletReimport.IsSuccess || filletReimport.Value is null || !FirmamentManifoldChecker.IsManifold(filletReimport.Value)) return Fail("ProfileBoundaryFilletStepReimportFailed");
- return KernelResult<FirmamentStepExportResult>.Success(new FirmamentStepExportResult(filletStep.Value, filletTarget.StableId, fillet.Correspondence.Descendants.Count, "profile-straight-edge-fillet", "source-grounded-profile-straight-edge-fillet"));
+ return KernelResult<FirmamentStepExportResult>.Success(new FirmamentStepExportResult(filletStep.Value, filletTarget.StableId, fillet.Correspondence.Descendants.Count, fillet.Plan is null ? "profile-straight-edge-fillet" : "profile-convex-fillet-junction", "source-grounded-profile-fillet"));
}
if (!ProfileBoundaryChamferSourceBinder.TryBind(source, profile, profile.Name, out var target, out var distance, out var bindingDiagnostic))
return Fail(bindingDiagnostic ?? "ProfileBoundaryChamferBindingFailed");
diff --git a/Aetheris.Kernel.Firmament/Materializer/ProfileBoundaryChamfer.cs b/Aetheris.Kernel.Firmament/Materializer/ProfileBoundaryChamfer.cs
index 429f653d..c81eaf49 100644
--- a/Aetheris.Kernel.Firmament/Materializer/ProfileBoundaryChamfer.cs
+++ b/Aetheris.Kernel.Firmament/Materializer/ProfileBoundaryChamfer.cs
@@ -613,6 +613,111 @@ public static class ProfileStraightEdgeFilletPlanner
}
}
+/// <summary>
+/// The authoritative Profile-fillet dispatch. M1 remains a self-contained
+/// finite-span construction; M2 owns the first connected topology instead of
+/// trying to join two already-emitted M1 bodies.
+/// </summary>
+public enum ProfileFilletRollEndKind { EndpointTermination, ConvexJunction }
+public sealed record ProfileFilletStraightRollPlan(string SegmentId, Direction3D Tangent, Direction3D InwardNormal, Point3D ExternalCenter, Point3D JunctionCenter, ProfileFilletRollEndKind ExternalEnd, ProfileFilletRollEndKind JunctionEnd);
+public sealed record ProfileConvexSphericalJunctionPlan(string VertexId, ProfileJunctionClassification Classification, Point3D Center, double Radius, Point3D CapContact, Point3D SideAContact, Point3D SideBContact);
+public sealed record ProfileFilletShellPlan(ProfileBoundaryChamferTarget Target, double Radius, double EndClearance, IReadOnlyList<ProfileFilletStraightRollPlan> Rolls, ProfileConvexSphericalJunctionPlan Junction, string EndpointPolicy = "ExternalEndpointsOnly");
+public sealed record ProfileFilletShellPlanResult(bool Succeeded, BrepBody? Body, SemanticTopologyCorrespondence? Correspondence, ProfileFilletShellPlan? Plan, ProfileStraightEdgeFilletPlan? SingleSegmentPlan, IReadOnlyList<string> Diagnostics);
+
+public static class ProfileFilletShellPlanner
+{
+ private const double Tol = 1e-8;
+
+ public static ProfileFilletShellPlanResult TryPlan(ResolvedProfile2D profile, ProfileBoundaryChamferTarget target, double radius, double clearance)
+ {
+ ProfileFilletShellPlanResult Fail(string code) => new(false, null, null, null, null, [code]);
+ if (target.ChainKind == ProfileBoundaryChamferChainKind.SingleSegment)
+ {
+ var m1 = ProfileStraightEdgeFilletPlanner.TryPlan(profile, target, radius, clearance);
+ return new(m1.Succeeded, m1.Body, m1.Correspondence, null, m1.Plan, m1.Diagnostics);
+ }
+ if (target.ChainKind == ProfileBoundaryChamferChainKind.ClosedLoop) return Fail("ProfileBoundaryFilletLoopTopologyNotMaterialized");
+ if (target.SegmentIds.Count != 2) return Fail("ProfileBoundaryFilletJunctionTopologyNotMaterialized");
+ var loop = profile.Loops.SingleOrDefault(x => x.Name == target.LoopId);
+ if (loop is null) return Fail("ProfileBoundaryFilletLoopUnknown");
+ if (!loop.IsOuter || profile.Loops.Count != 1) return Fail("ProfileBoundaryFilletInnerLoopUnsupported");
+ if (loop.Segments.Any(segment => segment.Geometry is not LineArcLineSegment2D)) return Fail("ProfileBoundaryFilletSegmentKindUnsupported");
+ if (!double.IsFinite(radius) || radius <= Tol) return Fail("ProfileBoundaryFilletRadiusMustBePositive");
+ if (!double.IsFinite(clearance) || clearance <= Tol) return Fail("ProfileBoundaryFilletEndClearanceMustBePositive");
+ var a = IndexOf(loop, target.SegmentIds[0]); var b = IndexOf(loop, target.SegmentIds[1]); var count = loop.Segments.Count;
+ if (a < 0 || b < 0) return Fail("ProfileBoundaryFilletSegmentUnknown");
+ if ((a + 1) % count != b) return Fail("ProfileBoundaryFilletDisconnectedChain");
+ var classification = ProfileJunctionClassifier.Classify(profile, loop).Single(x => x.PredecessorSegmentId == target.SegmentIds[0] && x.SuccessorSegmentId == target.SegmentIds[1]);
+ if (classification.Classification == ProfileJunctionKind.ReflexProfileJunction) return Fail("ProfileBoundaryFilletReflexJunctionUnsupported");
+ if (classification.Classification == ProfileJunctionKind.Collinear) return Fail("ProfileBoundaryFilletConvexJunctionCollinear");
+ if (classification.Classification != ProfileJunctionKind.ConvexProfileJunction) return Fail("ProfileBoundaryFilletConvexJunctionDegenerate");
+ if (Math.Abs(classification.MaterialInteriorAngleRadians - Math.PI / 2d) > Tol) return Fail("ProfileBoundaryFilletConvexAngleUnsupported");
+ var lineA = (LineArcLineSegment2D)loop.Segments[a].Geometry; var lineB = (LineArcLineSegment2D)loop.Segments[b].Geometry;
+ var lengthA = Length(lineA); var lengthB = Length(lineB);
+ if (lengthA <= clearance + radius + Tol || lengthB <= clearance + radius + Tol) return Fail("ProfileBoundaryFilletConvexRadiusTooLarge");
+ var start = profile.LocalStartDepth ?? -1d; var end = profile.LocalEndDepth ?? 1d;
+ if (radius >= end - start - Tol) return Fail("ProfileBoundaryFilletRadiusExceedsHost");
+ return Build(profile, loop, target, radius, clearance, a, b, lineA, lineB, classification, start, end);
+ }
+
+ private static ProfileFilletShellPlanResult Build(ResolvedProfile2D profile, ResolvedProfileLoop2D loop, ProfileBoundaryChamferTarget target, double radius, double clearance, int a, int b, LineArcLineSegment2D lineA, LineArcLineSegment2D lineB, ProfileJunctionClassification classification, double start, double end)
+ {
+ ProfileFilletShellPlanResult Fail(string code) => new(false, null, null, null, null, [code]);
+ var frame = profile.EffectiveConstructionPlane; var isTop = target.Side == ProfileBoundaryChamferSide.Top;
+ var capOut = isTop ? frame.AxisZ : Direction3D.Create(-frame.AxisZ.ToVector()); var axialInto = -capOut.ToVector(); var station = isTop ? end : start;
+ var ta = Direction(lineA, frame); var tb = Direction(lineB, frame); var signedArea = SignedArea(loop);
+ if (Math.Abs(signedArea) <= Tol) return Fail("ProfileBoundaryFilletConvexJunctionDegenerate");
+ var na = Inward(lineA, signedArea, frame); var nb = Inward(lineB, signedArea, frame);
+ if (Math.Abs(ta.ToVector().Dot(tb.ToVector())) > Tol || Math.Abs(na.ToVector().Dot(tb.ToVector()) - 1d) > Tol || Math.Abs(nb.ToVector().Dot(-ta.ToVector()) - 1d) > Tol)
+ return Fail("ProfileBoundaryFilletConvexAngleUnsupported");
+ var sourceAStart = frame.ToWorld(lineA.Start, station); var sourceBEnd = frame.ToWorld(lineB.End, station); var vertex = frame.ToWorld(lineA.End, station);
+ var sharpA = sourceAStart + ta.ToVector() * clearance; var sharpB = sourceBEnd - tb.ToVector() * clearance;
+ var capA = sharpA + na.ToVector() * radius; var sideAExternal = sharpA + axialInto * radius; var centerA = sharpA + na.ToVector() * radius + axialInto * radius;
+ var capB = sharpB + nb.ToVector() * radius; var sideBExternal = sharpB + axialInto * radius; var centerB = sharpB + nb.ToVector() * radius + axialInto * radius;
+ var center = vertex + na.ToVector() * radius + nb.ToVector() * radius + axialInto * radius;
+ var capJunction = center + capOut.ToVector() * radius; var sideA = center - na.ToVector() * radius; var sideB = center - nb.ToVector() * radius; var verticalDepth = vertex + axialInto * radius;
+ var rolls = new[] { new ProfileFilletStraightRollPlan(loop.Segments[a].Name, ta, na, centerA, center, ProfileFilletRollEndKind.EndpointTermination, ProfileFilletRollEndKind.ConvexJunction), new ProfileFilletStraightRollPlan(loop.Segments[b].Name, tb, nb, centerB, center, ProfileFilletRollEndKind.EndpointTermination, ProfileFilletRollEndKind.ConvexJunction) };
+ var junction = new ProfileConvexSphericalJunctionPlan(classification.VertexId, classification, center, radius, capJunction, sideA, sideB);
+ var plan = new ProfileFilletShellPlan(target, radius, clearance, rolls, junction);
+
+ 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;
+ VertexId Vertex(string key, Point3D point) { if (vertices.TryGetValue(key, out var id)) return id; id = builder.AddVertex(); vertices[key] = id; points[id] = point; return id; }
+ EdgeId LineEdge(VertexId x, VertexId y) { var key = x.Value < y.Value ? (x, y) : (y, x); if (edges.TryGetValue(key, out var id)) return id; id = builder.AddEdge(x, y); edges[key] = id; var curve = new CurveGeometryId(curveId++); geometry.AddCurve(curve, CurveGeometry.FromLine(new Line3Curve(points[x], Direction3D.Create(points[y] - points[x])))); bindings.AddEdgeBinding(new EdgeGeometryBinding(id, curve, new ParameterInterval(0d, (points[y] - points[x]).Length), true)); return id; }
+ EdgeId ArcEdge(VertexId x, VertexId y, Point3D c) { var key = x.Value < y.Value ? (x, y) : (y, x); if (edges.TryGetValue(key, out var id)) return id; var ux = points[x] - c; var uy = points[y] - c; var normal = ux.Cross(uy); if (normal.Length <= Tol) throw new InvalidOperationException($"ProfileBoundaryFilletConvexTrimDegenerate:{x.Value}->{y.Value}"); id = builder.AddEdge(x, y); edges[key] = id; var curve = new CurveGeometryId(curveId++); geometry.AddCurve(curve, CurveGeometry.FromCircle(new Circle3Curve(c, Direction3D.Create(normal), radius, Direction3D.Create(ux)))); bindings.AddEdgeBinding(new EdgeGeometryBinding(id, curve, new ParameterInterval(0d, Math.PI / 2d), true)); return id; }
+ FaceId Face(string stable, IReadOnlyList<(VertexId Vertex, bool Arc, Point3D? Center)> boundary, SurfaceGeometry surface, SemanticTopologyRole role, string source, string? parent = null) { var loopId = builder.AllocateLoopId(); var coedges = Enumerable.Range(0, boundary.Count).Select(_ => builder.AllocateCoedgeId()).ToArray(); for (var i = 0; i < boundary.Count; i++) { var current = boundary[i]; var next = boundary[(i + 1) % boundary.Count]; var edge = current.Arc ? ArcEdge(current.Vertex, next.Vertex, current.Center!.Value) : LineEdge(current.Vertex, next.Vertex); var modelEdge = builder.Model.Edges.Single(item => item.Id == edge); builder.AddCoedge(new Coedge(coedges[i], edge, loopId, coedges[(i + 1) % boundary.Count], coedges[(i + boundary.Count - 1) % boundary.Count], modelEdge.StartVertexId != current.Vertex)); } builder.AddLoop(new Loop(loopId, coedges)); var face = builder.AddFace([loopId]); var surfaceIdValue = new SurfaceGeometryId(surfaceId++); geometry.AddSurface(surfaceIdValue, surface); bindings.AddFaceBinding(new FaceGeometryBinding(face, surfaceIdValue, true)); descendants.Add(new(stable, "Face", role, source, Face: face, ParentStableId: parent)); return face; }
+ static (VertexId Vertex, bool Arc, Point3D? Center) L(VertexId x) => (x, false, null); static (VertexId Vertex, bool Arc, Point3D? Center) A(VertexId x, Point3D c) => (x, true, c);
+
+ var n = loop.Segments.Count; var lower = new VertexId[n]; var upper = new VertexId[n];
+ for (var i = 0; i < n; i++) { var line = (LineArcLineSegment2D)loop.Segments[i].Geometry; lower[i] = Vertex($"lower:{i}", frame.ToWorld(line.Start, start)); upper[i] = Vertex($"upper:{i}", frame.ToWorld(line.Start, end)); }
+ var cap = isTop ? upper : lower; var opposite = isTop ? lower : upper; var sharpAV = Vertex("sharp-a", sharpA); var sharpBV = Vertex("sharp-b", sharpB); var capAV = Vertex("cap-a", capA); var capBV = Vertex("cap-b", capB); var sideAEV = Vertex("side-a-external", sideAExternal); var sideBEV = Vertex("side-b-external", sideBExternal); var capJV = Vertex("junction-cap", capJunction); var sideAV = Vertex("junction-side-a", sideA); var sideBV = Vertex("junction-side-b", sideB); var depthV = Vertex("junction-vertical-depth", verticalDepth);
+ var capBoundary = new List<(VertexId Vertex, bool Arc, Point3D? Center)>();
+ for (var i = 0; i < n; i++) { if (i == a) { capBoundary.AddRange([L(cap[i]), L(sharpAV), L(capAV), L(capJV), L(capBV), L(sharpBV)]); continue; } if (i == b) continue; capBoundary.Add(L(cap[i])); }
+ var capPlane = SurfaceGeometry.FromPlane(new PlaneSurface(frame.ToWorld((0d, 0d), station), capOut, ta)); var oppositePlane = SurfaceGeometry.FromPlane(new PlaneSurface(frame.ToWorld((0d, 0d), isTop ? start : end), Direction3D.Create(-capOut.ToVector()), ta));
+ Face($"{target.StableId}:{(isTop ? "top" : "bottom")}-cap", isTop ? capBoundary : capBoundary.AsEnumerable().Reverse().ToArray(), capPlane, isTop ? SemanticTopologyRole.TopFaceBoundaryLoop : SemanticTopologyRole.BottomFaceBoundaryLoop, $"profile:{profile.Name}.{loop.Name}", target.StableId);
+ Face($"{target.StableId}:{(isTop ? "bottom" : "top")}-cap", (isTop ? lower.Reverse() : upper).Select(L).ToArray(), oppositePlane, isTop ? SemanticTopologyRole.BottomFaceBoundaryLoop : SemanticTopologyRole.TopFaceBoundaryLoop, $"profile:{profile.Name}.{loop.Name}", target.StableId);
+ for (var i = 0; i < n; i++) { var next = (i + 1) % n; var line = (LineArcLineSegment2D)loop.Segments[i].Geometry; var tangent = Direction(line, frame); var inward = Inward(line, signedArea, frame); var sideSurface = SurfaceGeometry.FromPlane(new PlaneSurface(frame.ToWorld(line.Start, start), Direction3D.Create(-inward.ToVector()), tangent)); if (i == a) Face($"profile:{profile.Name}.{loop.Name}.{loop.Segments[i].Name}:trimmed-side", [L(opposite[i]), L(opposite[next]), L(depthV), L(sideAV), L(sideAEV), L(sharpAV), L(cap[i])], sideSurface, SemanticTopologyRole.ExtrusionSideFace, $"profile:{profile.Name}.{loop.Name}.{loop.Segments[i].Name}", target.StableId); else if (i == b) Face($"profile:{profile.Name}.{loop.Name}.{loop.Segments[i].Name}:trimmed-side", [L(opposite[i]), L(opposite[next]), L(cap[next]), L(sharpBV), L(sideBEV), L(sideBV), L(depthV)], sideSurface, SemanticTopologyRole.ExtrusionSideFace, $"profile:{profile.Name}.{loop.Name}.{loop.Segments[i].Name}", target.StableId); else Face($"profile:{profile.Name}.{loop.Name}.{loop.Segments[i].Name}:side", [L(lower[i]), L(lower[next]), L(upper[next]), L(upper[i])], sideSurface, SemanticTopologyRole.ExtrusionSideFace, $"profile:{profile.Name}.{loop.Name}.{loop.Segments[i].Name}"); }
+ var cylinderA = SurfaceGeometry.FromCylinder(new CylinderSurface(centerA, ta, radius, capOut)); var cylinderB = SurfaceGeometry.FromCylinder(new CylinderSurface(center, tb, radius, capOut)); var sphere = SurfaceGeometry.FromSphere(new SphereSurface(center, capOut, radius, Direction3D.Create(-na.ToVector())));
+ Face($"{target.StableId}:FilletSurface({loop.Segments[a].Name})", [L(capAV), A(capJV, center), L(sideAV), A(sideAEV, centerA)], cylinderA, SemanticTopologyRole.FilletSurface, $"profile:{profile.Name}.{loop.Name}.{loop.Segments[a].Name}", target.StableId);
+ Face($"{target.StableId}:FilletSurface({loop.Segments[b].Name})", [L(capJV), A(capBV, centerB), L(sideBEV), A(sideBV, center)], cylinderB, SemanticTopologyRole.FilletSurface, $"profile:{profile.Name}.{loop.Name}.{loop.Segments[b].Name}", target.StableId);
+ Face($"{target.StableId}:ConvexJunctionPatch({loop.Segments[a].Name},{loop.Segments[b].Name})", [A(capJV, center), A(sideBV, center), A(sideAV, center)], sphere, SemanticTopologyRole.ConvexJunctionPatch, classification.VertexId, target.StableId);
+ Face($"{target.StableId}:ConvexJunctionSupport", [L(depthV), A(sideBV, center), L(sideAV)], SurfaceGeometry.FromPlane(new PlaneSurface(verticalDepth, capOut, ta)), SemanticTopologyRole.EdgeFinishReplacementFace, classification.VertexId, target.StableId);
+ Face($"{target.StableId}:StartTerminationFace", [L(sharpAV), A(capAV, centerA), L(sideAEV)], SurfaceGeometry.FromPlane(new PlaneSurface(sharpA, Direction3D.Create(-ta.ToVector()), capOut)), SemanticTopologyRole.StartTerminationFace, target.StableId, target.StableId);
+ Face($"{target.StableId}:EndTerminationFace", [L(sharpBV), A(sideBEV, centerB), L(capBV)], SurfaceGeometry.FromPlane(new PlaneSurface(sharpB, tb, capOut)), SemanticTopologyRole.EndTerminationFace, target.StableId, target.StableId);
+ var shell = builder.AddShell(builder.Model.Faces.Select(face => face.Id).ToArray()); builder.AddBody([shell]); var body = new BrepBody(builder.Model, geometry, bindings, points); var validation = BrepBindingValidator.Validate(body, true); if (!validation.IsSuccess) return Fail("ProfileBoundaryFilletConvexTopologyPlanInvalid");
+ void AddEdge(string name, EdgeId edge, SemanticTopologyRole role, string source) => descendants.Add(new($"{target.StableId}:{name}", "Edge", role, source, Edge: edge, ParentStableId: target.StableId));
+ AddEdge($"CapContactEdge({loop.Segments[a].Name})", LineEdge(capAV, capJV), SemanticTopologyRole.CapContactEdge, loop.Segments[a].Provenance.StableId); AddEdge($"CapContactEdge({loop.Segments[b].Name})", LineEdge(capJV, capBV), SemanticTopologyRole.CapContactEdge, loop.Segments[b].Provenance.StableId); AddEdge($"SideContactEdge({loop.Segments[a].Name})", LineEdge(sideAV, sideAEV), SemanticTopologyRole.SideContactEdge, loop.Segments[a].Provenance.StableId); AddEdge($"SideContactEdge({loop.Segments[b].Name})", LineEdge(sideBEV, sideBV), SemanticTopologyRole.SideContactEdge, loop.Segments[b].Provenance.StableId); AddEdge("JunctionToRollA", ArcEdge(capJV, sideAV, center), SemanticTopologyRole.JunctionToRollA, classification.VertexId); AddEdge("JunctionToRollB", ArcEdge(sideBV, capJV, center), SemanticTopologyRole.JunctionToRollB, classification.VertexId);
+ var correspondence = new SemanticTopologyCorrespondence(target.HostBodyId, descendants, ["ResolvedProfile2D", "ProfileFilletShellPlan", "StraightRoll", "ConvexSphericalJunction", "AuthoritativeBRepPlan"]);
+ return new(true, body, correspondence, plan, null, ["ProfileFilletShellPlan", "ProfileBoundaryFilletExactQuarterCylinders", "ProfileBoundaryFilletConvexSphericalJunction"]);
+ }
+
+ private static int IndexOf(ResolvedProfileLoop2D loop, string segmentId) => loop.Segments.Select((segment, index) => (segment, index)).Where(item => item.segment.Name == segmentId).Select(item => item.index).DefaultIfEmpty(-1).Single();
+ private static double Length(LineArcLineSegment2D line) => Math.Sqrt(Math.Pow(line.End.X - line.Start.X, 2d) + Math.Pow(line.End.Y - line.Start.Y, 2d));
+ private static Direction3D Direction(LineArcLineSegment2D line, ConstructionPlane frame) { var length = Length(line); return Direction3D.Create(frame.ToWorldDirection(new Vector3D((line.End.X - line.Start.X) / length, (line.End.Y - line.Start.Y) / length, 0d))); }
+ private static Direction3D Inward(LineArcLineSegment2D line, double signedArea, ConstructionPlane frame) { var length = Length(line); var normal = signedArea > 0d ? new Vector3D(-(line.End.Y - line.Start.Y) / length, (line.End.X - line.Start.X) / length, 0d) : new Vector3D((line.End.Y - line.Start.Y) / length, -(line.End.X - line.Start.X) / length, 0d); return Direction3D.Create(frame.ToWorldDirection(normal)); }
+ private static double SignedArea(ResolvedProfileLoop2D loop) => loop.Segments.Cast<ResolvedProfileSegment2D>().Select(segment => (LineArcLineSegment2D)segment.Geometry).Select((line, index) => line.Start.X * ((LineArcLineSegment2D)loop.Segments[(index + 1) % loop.Segments.Count].Geometry).Start.Y - ((LineArcLineSegment2D)loop.Segments[(index + 1) % loop.Segments.Count].Geometry).Start.X * line.Start.Y).Sum() * .5d;
+}
+
/// <summary>
/// Conservative source-space corridor check used before a composed host can ever
/// attempt a future M2 materialization. M1 still rejects composed hosts after a
diff --git a/Aetheris.Kernel.Firmament/Materializer/SemanticTopologySelections.cs b/Aetheris.Kernel.Firmament/Materializer/SemanticTopologySelections.cs
index 8d4978ba..f90aaa26 100644
--- a/Aetheris.Kernel.Firmament/Materializer/SemanticTopologySelections.cs
+++ b/Aetheris.Kernel.Firmament/Materializer/SemanticTopologySelections.cs
@@ -5,7 +5,7 @@ using System.Text.RegularExpressions;
namespace Aetheris.Kernel.Firmament.Materializer;
/// <summary>Stable roles assigned while an authoritative plan is materialized. These are not geometric queries.</summary>
-public enum SemanticTopologyRole { Unknown, ProfileVertex, VerticalExtrusionEdge, LocalStartBoundary, LocalEndBoundary, LocalStartCapLoop, LocalEndCapLoop, TopBoundary, BottomBoundary, ExtrusionSideFace, TopFaceBoundaryLoop, BottomFaceBoundaryLoop, HoleEntryLoop, HoleExitLoop, HoleWallFace, HoleShaftToDrillPointLoop, HoleShaftToDrillPointEdge, HoleDrillPointFace, HoleTipVertex, HoleCounterboreMouthLoop, HoleCounterboreWallFace, HoleCounterboreShoulderLoop, HoleCounterboreShaftWallFace, SlotEntryLoop, SlotExitLoop, SlotWallFace, SlotStraightWallFace, SlotEndWallFace, ComposeTransition, EdgeFinishReplacementFace, FilletSurface, CapContactEdge, SideContactEdge, StartTerminationFace, EndTerminationFace, StartEndpointArc, EndEndpointArc, RetainedStartSharpEdge, RetainedEndSharpEdge }
+public enum SemanticTopologyRole { Unknown, ProfileVertex, VerticalExtrusionEdge, LocalStartBoundary, LocalEndBoundary, LocalStartCapLoop, LocalEndCapLoop, TopBoundary, BottomBoundary, ExtrusionSideFace, TopFaceBoundaryLoop, BottomFaceBoundaryLoop, HoleEntryLoop, HoleExitLoop, HoleWallFace, HoleShaftToDrillPointLoop, HoleShaftToDrillPointEdge, HoleDrillPointFace, HoleTipVertex, HoleCounterboreMouthLoop, HoleCounterboreWallFace, HoleCounterboreShoulderLoop, HoleCounterboreShaftWallFace, SlotEntryLoop, SlotExitLoop, SlotWallFace, SlotStraightWallFace, SlotEndWallFace, ComposeTransition, EdgeFinishReplacementFace, FilletSurface, ConvexJunctionPatch, CapContactEdge, SideContactEdge, JunctionToRollA, JunctionToRollB, JunctionCapContact, JunctionSideAContact, JunctionSideBContact, StartTerminationFace, EndTerminationFace, StartEndpointArc, EndEndpointArc, RetainedStartSharpEdge, RetainedEndSharpEdge }
public enum SemanticSelectionRequirement { ExactlyOne, OneOrMore, ConnectedChain, ClosedLoop, NonEmptyFaceSet }
public enum SemanticSelectionFailure { None, SemanticSourceNotFound, NoMaterializedDescendants, AmbiguousBodyContext, SelectionCardinalityMismatch, DescendantsNotConnected, DescendantsBranch, DescendantsDoNotClose, MixedBoundaryRoles, UnsupportedTopologyChange, SelectionConsumerMismatch }
diff --git a/docs/firmament/profile-convex-fillet-junction-m2.md b/docs/firmament/profile-convex-fillet-junction-m2.md
new file mode 100644
index 00000000..4a54e0b2
--- /dev/null
+++ b/docs/firmament/profile-convex-fillet-junction-m2.md
@@ -0,0 +1,45 @@
+# Profile convex fillet junction M2
+
+M2 adds one source-bound connected fillet: exactly two adjacent outer `Line2`
+segments meeting at one 90-degree `ConvexProfileJunction`. It uses the existing
+selection spelling:
+
+```firmament
+Selection CornerPair { Source: Bracket.Outer.[South, East] Require: ConnectedChain }
+Modify Body { EdgeFinish RoundedCorner { Target: CornerPair On: Top Kind: Fillet Radius: 2mm EndClearance: 3mm } }
+```
+
+The route is plan-first: resolved Profile -> `ProfileFilletShellPlan` -> two
+typed `StraightRoll` plans -> one `ConvexSphericalJunction` plan -> one B-rep
+shell. M1 is still used unchanged for a single segment. M2 applies
+`EndClearance` only at the external start of A and external end of B.
+
+For source vertex `V`, inward material normals `nA`, `nB`, local outward cap
+normal `c`, and `into = -c`, the same-radius sphere centre is
+`V + r*nA + r*nB + r*into`. For the canonical Top XY example this is
+`(18, 2, 6)`; Bottom changes only the axial term, giving `(18, 2, 2)`.
+Each roll ends at the plane through that centre. Its sphere/cylinder seam is an
+exact quarter circle. The sphere has three quarter-circle boundaries: one to
+each roll and one to the retained local vertical-corner support. Cap contact is
+the shared tangent point; each vertical side contact is a tangent point. The
+support is an actual horizontal retained-corner face, not either suppressed M1
+endpoint termination face; the original vertical corner remains below the
+fillet depth.
+
+The emitted body has two `Cylinder` faces, one `Sphere` face, exact `Circle3`
+seams, two external planar termination faces, and no internal termination
+descendant. Descendants retain both source segment stable IDs, the shared
+Profile vertex, `ConvexJunctionPatch`, both roll/cap/side contacts, and the
+two external terminations.
+
+M2 admits only 90-degree convex line-line pairs, positive radii below host
+thickness, and `length > EndClearance + Radius` for both source segments.
+Reflex, collinear, degenerate, non-orthogonal, whole-loop, and three-or-more
+chain routes fail specifically before topology emission. Compose/cavity support
+remains M1-only and is intentionally not widened here.
+
+`profile-fillet-convex-two-segment-top.firmament` and Bottom declare an
+`Assert Volume` literal of `1570.7317878719023 mm^3` with `0.5 mm^3`
+tolerance, matching the deterministic trimmed-face mass evaluator for the
+12-face canonical construction. The Concept Path and explicit Segment/Trace
+fixtures export byte-identical STEP (`0EE611CCB963620D2ADD6DB94044EFBCD4FDAB142679325BE78758A60DA1462A`).
diff --git a/docs/firmament/profile-fillet-common-cases-x2.md b/docs/firmament/profile-fillet-common-cases-x2.md
index 9c4ceb72..157c8d27 100644
--- a/docs/firmament/profile-fillet-common-cases-x2.md
+++ b/docs/firmament/profile-fillet-common-cases-x2.md
@@ -46,12 +46,13 @@ notch-width and local-medial-space admission. Reusing convex face orientation
for a reflex vertex would invert material side, so neither patch is emitted by
M1.
-Accordingly, an admitted chain currently reports
-`ProfileBoundaryFilletJunctionTopologyNotMaterialized`; a complete loop reports
-`ProfileBoundaryFilletLoopTopologyNotMaterialized`. This is an intentional
-honest stop, not a geometry fallback. Composed hosts keep M1's conservative
-single-roll Shaft/Counterbore corridor check and report the feature-specific
-collision diagnostics before the separate compose-materialization boundary.
+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
+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,
diff --git a/docs/firmament/profile-straight-edge-fillet-m1.md b/docs/firmament/profile-straight-edge-fillet-m1.md
index 8d96e234..09c277fa 100644
--- a/docs/firmament/profile-straight-edge-fillet-m1.md
+++ b/docs/firmament/profile-straight-edge-fillet-m1.md
@@ -67,3 +67,8 @@ uses the assertion to change the fillet route.
Current limitations: no adjacent-junction continuation, convex/reflex patch,
whole-loop or chain finish, inner loop, curve source, variable radius, imported
edge, cavity interaction, or composed Profile host is supported.
+
+M2 supersedes that limitation only for one adjacent 90-degree convex two-line
+pair. It leaves M1's single-segment topology and endpoint policy unchanged; see
+`profile-convex-fillet-junction-m2.md`. Reflex, longer chains, and loops remain
+outside both materializers.
diff --git a/docs/firmament/v2-canonical-authoring.md b/docs/firmament/v2-canonical-authoring.md
index 874a5b45..43a72b9d 100644
--- a/docs/firmament/v2-canonical-authoring.md
+++ b/docs/firmament/v2-canonical-authoring.md
@@ -223,6 +223,18 @@ selection failure. Continuous multi-segment convex/reflex junction fillets,
chains, and whole loops remain unmaterialized; a Concept Path `Arc` only changes
a 2D outline and is not a substitute for this 3D edge finish.
+One practical continuation is now available: select two adjacent outside lines
+with `Require: ConnectedChain` and use one constant `Radius`. The compiler
+recognizes the convex 90-degree corner and chooses its junction topology:
+
+```firmament
+Selection OutsideCorner { Source: Bracket.Outer.[South, East] Require: ConnectedChain }
+Modify Body { EdgeFinish CornerRound { Target: OutsideCorner On: Top Kind: Fillet Radius: 2mm EndClearance: 3mm } }
+```
+
+The same form works on `Bottom`; reflex corners and chains longer than two have
+specific unsupported diagnostics.
+
## Canonical examples
- `fixtures/FirmamentV2/Canonical/valid/bare-box.firmament`
diff --git a/fixtures/FirmamentV2/Canonical/valid/profile-fillet-convex-two-segment-bottom.firmament b/fixtures/FirmamentV2/Canonical/valid/profile-fillet-convex-two-segment-bottom.firmament
new file mode 100644
index 00000000..7bf9d293
--- /dev/null
+++ b/fixtures/FirmamentV2/Canonical/valid/profile-fillet-convex-two-segment-bottom.firmament
@@ -0,0 +1,21 @@
+Model ProfileFilletConvexTwoSegmentBottom {
+Units: mm
+Concept Struct RectangleLayout On XY {
+ Point2 A { Position: [0mm, 0mm] } Point2 B { Position: [20mm, 0mm] }
+ Point2 C { Position: [20mm, 10mm] } Point2 D { Position: [0mm, 10mm] }
+ Line2 South { From: A; To: B } Line2 East { From: B; To: C }
+ Line2 North { From: C; To: D } Line2 West { From: D; To: A }
+}
+Profile Bracket Using RectangleLayout { Loop Outer {
+ Segment South { Trace: South; From: A; To: B } Segment East { Trace: East; From: B; To: C }
+ Segment North { Trace: North; From: C; To: D } Segment West { Trace: West; From: D; To: A }
+} }
+Struct Body { Extrude Bracket { Profile: Bracket; From: 0mm; To: 8mm } }
+Selection CornerPair { Source: Bracket.Outer.[South, East] Require: ConnectedChain }
+Modify Body { EdgeFinish RoundedCorner { Target: CornerPair On: Bottom Kind: Fillet Radius: 2mm EndClearance: 3mm } }
+Assert Volume Body {
+ Expected: 1570.7317878719023mm^3
+ Tolerance: 0.5mm^3
+ Note: "Bottom mirror of two straight Profile rolls joined by one convex spherical fillet junction"
+}
+}
diff --git a/fixtures/FirmamentV2/Canonical/valid/profile-fillet-convex-two-segment-concept-path.firmament b/fixtures/FirmamentV2/Canonical/valid/profile-fillet-convex-two-segment-concept-path.firmament
new file mode 100644
index 00000000..2471d388
--- /dev/null
+++ b/fixtures/FirmamentV2/Canonical/valid/profile-fillet-convex-two-segment-concept-path.firmament
@@ -0,0 +1,15 @@
+Model ProfileFilletConvexTwoSegmentConceptPath {
+ Units: mm
+ Concept Path Outline {
+ Start: Point2(0mm, 0mm)
+ Heading: 0deg
+ Line South { Length: 20mm }
+ Line East { Turn: 90deg; Length: 10mm }
+ Line North { Turn: 90deg; Length: 20mm }
+ Close West
+ }
+ Profile Bracket From Outline
+ Struct Body { Extrude Bracket { Profile: Bracket; From: 0mm; To: 8mm } }
+ Selection CornerPair { Source: Bracket.Outer.[South, East] Require: ConnectedChain }
+ Modify Body { EdgeFinish RoundedCorner { Target: CornerPair On: Top Kind: Fillet Radius: 2mm EndClearance: 3mm } }
+}
diff --git a/fixtures/FirmamentV2/Canonical/valid/profile-fillet-convex-two-segment-low-level.firmament b/fixtures/FirmamentV2/Canonical/valid/profile-fillet-convex-two-segment-low-level.firmament
new file mode 100644
index 00000000..4114cd82
--- /dev/null
+++ b/fixtures/FirmamentV2/Canonical/valid/profile-fillet-convex-two-segment-low-level.firmament
@@ -0,0 +1,20 @@
+Model ProfileFilletConvexTwoSegmentLowLevel {
+ Units: mm
+ Concept Path Outline {
+ Start: Point2(0mm, 0mm)
+ Heading: 0deg
+ Line South { Length: 20mm }
+ Line East { Turn: 90deg; Length: 10mm }
+ Line North { Turn: 90deg; Length: 20mm }
+ Close West
+ }
+ Profile Bracket { Loop Outer {
+ Segment South { Trace: Outline.South; From: Outline.Start; To: Outline.South.End }
+ Segment East { Trace: Outline.East; From: Outline.South.End; To: Outline.East.End }
+ Segment North { Trace: Outline.North; From: Outline.East.End; To: Outline.North.End }
+ Segment West { Trace: Outline.West; From: Outline.North.End; To: Outline.West.End }
+ } }
+ Struct Body { Extrude Bracket { Profile: Bracket; From: 0mm; To: 8mm } }
+ Selection CornerPair { Source: Bracket.Outer.[South, East] Require: ConnectedChain }
+ Modify Body { EdgeFinish RoundedCorner { Target: CornerPair On: Top Kind: Fillet Radius: 2mm EndClearance: 3mm } }
+}
diff --git a/fixtures/FirmamentV2/Canonical/valid/profile-fillet-convex-two-segment-top.firmament b/fixtures/FirmamentV2/Canonical/valid/profile-fillet-convex-two-segment-top.firmament
new file mode 100644
index 00000000..16d6f637
--- /dev/null
+++ b/fixtures/FirmamentV2/Canonical/valid/profile-fillet-convex-two-segment-top.firmament
@@ -0,0 +1,21 @@
+Model ProfileFilletConvexTwoSegmentTop {
+Units: mm
+Concept Struct RectangleLayout On XY {
+ Point2 A { Position: [0mm, 0mm] } Point2 B { Position: [20mm, 0mm] }
+ Point2 C { Position: [20mm, 10mm] } Point2 D { Position: [0mm, 10mm] }
+ Line2 South { From: A; To: B } Line2 East { From: B; To: C }
+ Line2 North { From: C; To: D } Line2 West { From: D; To: A }
+}
+Profile Bracket Using RectangleLayout { Loop Outer {
+ Segment South { Trace: South; From: A; To: B } Segment East { Trace: East; From: B; To: C }
+ Segment North { Trace: North; From: C; To: D } Segment West { Trace: West; From: D; To: A }
+} }
+Struct Body { Extrude Bracket { Profile: Bracket; From: 0mm; To: 8mm } }
+Selection CornerPair { Source: Bracket.Outer.[South, East] Require: ConnectedChain }
+Modify Body { EdgeFinish RoundedCorner { Target: CornerPair On: Top Kind: Fillet Radius: 2mm EndClearance: 3mm } }
+Assert Volume Body {
+ Expected: 1570.7317878719023mm^3
+ Tolerance: 0.5mm^3
+ Note: "Two straight Profile rolls joined by one convex spherical fillet junction"
+}
+}