Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Support semantic profile-boundary chamfers in Firmament exports

Yuechen Li9b60691d8c29
diff --git a/Aetheris.CLI/CliRunner.cs b/Aetheris.CLI/CliRunner.cs
index acd0e457..26a0fb2b 100644
--- a/Aetheris.CLI/CliRunner.cs
+++ b/Aetheris.CLI/CliRunner.cs
@@ -430,6 +430,7 @@ public static class CliRunner
lineSegments = profile.Loops.SelectMany(x => x.Segments).Count(x => x.Geometry is LineArcLineSegment2D),
arcSegments = profile.Loops.SelectMany(x => x.Segments).Count(x => x.Geometry is LineArcCircularArc2D),
validation.IsValid, validation.SignedArea, validation.Diagnostics,
+ junctions = DescribeProfileJunctions(profile, source, profile.Name),
provenance = profile.Loops.SelectMany(x => x.Segments).Select(x => new { x.Name, x.Provenance.StableId, x.Provenance.ConceptStableId, x.Provenance.Derivation })
};
}).ToArray();
@@ -456,6 +457,7 @@ public static class CliRunner
return new { x.Name, guide = guide.Name, guideKind = guide.Kind, parentGuide = guide.Parent, stableId = x.Provenance.StableId, derivation = x.Provenance.Derivation, geometry = x.Geometry.GetType().Name };
}),
validation.IsValid, validation.SignedArea, validation.Diagnostics,
+ junctions = DescribeProfileJunctions(parsed.Profile, source, parsed.Profile.Name),
extrusionHeight = parsed.Height,
brepPlan = plan.Plan is null ? null : new
{
@@ -3217,6 +3219,33 @@ public static class CliRunner
private static string FormatDouble(double? value) => value?.ToString("G17") ?? "n/a";
+ private sealed record ProfileJunctionInspection(
+ string ProfileId, string LoopId, string PredecessorSegment, string SuccessorSegment,
+ string VertexId, double SignedTurnDegrees, double MaterialInteriorAngleDegrees,
+ string Classification, bool SelectedByEdgeFinish, IReadOnlyList<string> GeneratedDescendants);
+
+ private static IReadOnlyList<ProfileJunctionInspection> DescribeProfileJunctions(ResolvedProfile2D profile, string source, string hostBodyId)
+ {
+ ProfileBoundaryChamferTarget? target = null;
+ SemanticTopologyCorrespondence? correspondence = null;
+ if (ProfileBoundaryChamferSourceBinder.TryBind(source, profile, hostBodyId, out var bound, out var distance, out _))
+ {
+ target = bound;
+ var plan = ProfileBoundaryChamferPlanner.TryPlan(profile, bound!, distance);
+ correspondence = plan.Correspondence;
+ }
+ var selected = target?.SegmentIds.ToHashSet(StringComparer.Ordinal) ?? [];
+ return ProfileJunctionClassifier.Classify(profile).Select(junction =>
+ {
+ var selectedByFinish = selected.Contains(junction.PredecessorSegmentId) && selected.Contains(junction.SuccessorSegmentId);
+ var descendantPrefix = target is null ? string.Empty : $"{target.StableId}:{junction.Classification}({junction.VertexId})";
+ var descendants = correspondence?.Descendants.Where(descendant => descendant.StableId == descendantPrefix).Select(descendant => descendant.StableId).ToArray() ?? [];
+ return new ProfileJunctionInspection(junction.ProfileId, junction.LoopId, junction.PredecessorSegmentId, junction.SuccessorSegmentId,
+ junction.VertexId, junction.SignedTurnRadians * 180d / Math.PI, junction.MaterialInteriorAngleRadians * 180d / Math.PI,
+ junction.Classification.ToString(), selectedByFinish, descendants);
+ }).ToArray();
+ }
+
private static string ProfileSignature(ResolvedProfile2D profile) => Hash(string.Join(";", profile.Loops.SelectMany(l => l.Segments).Select(s => s.Geometry switch
{
LineArcLineSegment2D line => $"L:{Q(line.Start.X)},{Q(line.Start.Y)}:{Q(line.End.X)},{Q(line.End.Y)}",
diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentV2CanonicalAdvancedGrammarTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentV2CanonicalAdvancedGrammarTests.cs
index e8619e66..82756bac 100644
--- a/Aetheris.Kernel.Firmament.Tests/FirmamentV2CanonicalAdvancedGrammarTests.cs
+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentV2CanonicalAdvancedGrammarTests.cs
@@ -333,7 +333,10 @@ public sealed class FirmamentV2CanonicalAdvancedGrammarTests
Assert.True(imported.IsSuccess, string.Join(Environment.NewLine, imported.Diagnostics.Select(diagnostic => diagnostic.Message)));
var mass = BrepMassProperties.Evaluate(imported.Value);
Assert.True(mass.IsEnclosed); Assert.True(mass.IsOrientationConsistent);
- Assert.InRange(Math.Abs(mass.AbsoluteVolume - (28800d - 540d * Math.PI)), 0d, 0.01d);
+ // The source now carries its authored 1 mm Profile-boundary chamfer.
+ // This is the deterministic composed section-stack result after the
+ // unchanged Shaft/Counterbore cavities are carried through that interval.
+ Assert.InRange(Math.Abs(mass.AbsoluteVolume - 26966.084223687798d), 0d, 0.01d);
}
finally
{
diff --git a/Aetheris.Kernel.Firmament.Tests/Integration/ProfileBoundaryChamferFixtureTests.cs b/Aetheris.Kernel.Firmament.Tests/Integration/ProfileBoundaryChamferFixtureTests.cs
new file mode 100644
index 00000000..0cb5acbf
--- /dev/null
+++ b/Aetheris.Kernel.Firmament.Tests/Integration/ProfileBoundaryChamferFixtureTests.cs
@@ -0,0 +1,79 @@
+using Aetheris.Kernel.Core.Brep.Verification;
+using Aetheris.Kernel.Core.Geometry;
+using Aetheris.Kernel.Core.Step242;
+
+namespace Aetheris.Kernel.Firmament.Tests.Integration;
+
+public sealed class ProfileBoundaryChamferFixtureTests
+{
+ [Theory]
+ [InlineData("profile-chamfer-convex-junction-top.firmament", 12, 6370.333333333333d)]
+ [InlineData("profile-chamfer-reflex-junction-top.firmament", 18, 5569.666666666666d)]
+ [InlineData("profile-chamfer-mixed-convex-reflex-loop-top.firmament", 14, 5521.333333333333d)]
+ [InlineData("profile-chamfer-reflex-junction-bottom.firmament", 16, 5569.666666666666d)]
+ [InlineData("profile-chamfer-reflex-low-level-segments.firmament", 18, 5569.666666666666d)]
+ public void CanonicalFixture_ExportsAnEnclosedDeterministicPlanarStep(string fixtureName, int expectedFaces, double expectedVolume)
+ {
+ 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(x => x.Message)));
+ Assert.True(second.IsSuccess, string.Join(Environment.NewLine, second.Diagnostics.Select(x => x.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(x => x.Message)));
+ Assert.NotNull(imported.Value);
+ Assert.Equal(expectedFaces, imported.Value.Topology.Faces.Count());
+ Assert.All(imported.Value.Bindings.FaceBindings, binding => Assert.Equal(SurfaceGeometryKind.Plane, imported.Value.Geometry.GetSurface(binding.SurfaceGeometryId).Kind));
+ var mass = BrepMassProperties.Evaluate(imported.Value);
+ Assert.True(mass.IsEnclosed);
+ Assert.True(mass.IsOrientationConsistent);
+ Assert.InRange(Math.Abs(mass.AbsoluteVolume - expectedVolume), 0d, 1e-8d);
+ }
+ finally
+ {
+ if (File.Exists(firstOutput)) File.Delete(firstOutput);
+ if (File.Exists(secondOutput)) File.Delete(secondOutput);
+ }
+ }
+
+ [Theory]
+ [InlineData("profile-compose-reflex-chamfer-with-shaft.firmament")]
+ [InlineData("profile-compose-reflex-chamfer-with-counterbore.firmament")]
+ public void ComposedReflexFixture_AdmitsDisjointCavity(string fixtureName)
+ {
+ var source = FirmamentCorpusHarness.ResolveFixtureFullPath($"fixtures/FirmamentV2/Canonical/valid/{fixtureName}");
+ var output = Path.Combine(Path.GetTempPath(), $"aetheris-{Guid.NewGuid():N}.step");
+ try
+ {
+ var build = FirmamentBuildAndExport.Run(source, output);
+ Assert.True(build.IsSuccess, string.Join(Environment.NewLine, build.Diagnostics.Select(x => x.Message)));
+ var imported = Step242Importer.ImportBody(build.Value.Export.StepText);
+ Assert.True(imported.IsSuccess, string.Join(Environment.NewLine, imported.Diagnostics.Select(x => x.Message)));
+ Assert.True(BrepMassProperties.Evaluate(imported.Value!).IsEnclosed);
+ }
+ finally
+ {
+ if (File.Exists(output)) File.Delete(output);
+ }
+ }
+
+ [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", "ProfileBoundaryFilletNotMaterialized")]
+ public void InvalidFixture_ProducesTypedProfileBoundaryDiagnostic(string fixtureName, string diagnostic)
+ {
+ var source = FirmamentCorpusHarness.ResolveFixtureFullPath($"fixtures/FirmamentV2/Canonical/invalid/{fixtureName}");
+ var build = FirmamentBuildAndExport.Run(source, Path.Combine(Path.GetTempPath(), $"aetheris-{Guid.NewGuid():N}.step"));
+
+ Assert.False(build.IsSuccess);
+ Assert.Contains(build.Diagnostics, x => x.Message.StartsWith(diagnostic, StringComparison.Ordinal));
+ }
+}
diff --git a/Aetheris.Kernel.Firmament.Tests/Integration/ProfileBoundaryChamferTests.cs b/Aetheris.Kernel.Firmament.Tests/Integration/ProfileBoundaryChamferTests.cs
new file mode 100644
index 00000000..69799ade
--- /dev/null
+++ b/Aetheris.Kernel.Firmament.Tests/Integration/ProfileBoundaryChamferTests.cs
@@ -0,0 +1,100 @@
+using Aetheris.Kernel.Firmament.Materializer;
+
+namespace Aetheris.Kernel.Firmament.Tests.Integration;
+
+public sealed class ProfileBoundaryChamferTests
+{
+ [Fact]
+ public void BindsWholeLoopAndPlansExactTopSectionTransition()
+ {
+ var profile = Profile();
+ const string source = "Modify Body { EdgeFinish TopBreak { Target: Bracket.Outer On: Top Kind: Chamfer Distance: 1mm } }";
+
+ Assert.True(ProfileBoundaryChamferSourceBinder.TryBind(source, profile, "Bracket", out var target, out var distance, out var diagnostic), diagnostic);
+ Assert.Equal(ProfileBoundaryChamferChainKind.ClosedLoop, target!.ChainKind);
+ var result = ProfileBoundaryChamferPlanner.TryPlan(profile, target, distance);
+
+ Assert.True(result.Succeeded, string.Join("; ", result.Diagnostics));
+ Assert.NotNull(result.Body);
+ Assert.Equal(10, result.Body!.Topology.Faces.Count());
+ }
+
+ [Fact]
+ public void BindsSingleSegmentAndRejectsDisconnectedSelection()
+ {
+ var profile = Profile();
+ const string single = "Modify Body { EdgeFinish SouthBreak { Target: Bracket.Outer.South On: Top Kind: Chamfer Distance: 1mm } }";
+ Assert.True(ProfileBoundaryChamferSourceBinder.TryBind(single, profile, "Bracket", out var singleTarget, out _, out var singleDiagnostic), singleDiagnostic);
+ Assert.Equal(ProfileBoundaryChamferChainKind.SingleSegment, singleTarget!.ChainKind);
+
+ const string disconnected = "Selection Bad { Source: Bracket.Outer.[South, North] Require: ConnectedChain } Modify Body { EdgeFinish BadBreak { Target: Bad On: Top Kind: Chamfer Distance: 1mm } }";
+ Assert.False(ProfileBoundaryChamferSourceBinder.TryBind(disconnected, profile, "Bracket", out _, out _, out var diagnostic));
+ Assert.Equal("ProfileBoundaryChamferDisconnectedChain", diagnostic);
+ }
+
+ [Fact]
+ public void ClassifiesConvexAndReflexJunctionsFromLoopMaterialSide()
+ {
+ var profile = LProfile();
+
+ var junctions = ProfileJunctionClassifier.Classify(profile, profile.Loops.Single()).ToDictionary(x => x.SuccessorSegmentId);
+
+ Assert.Equal(ProfileJunctionKind.ConvexProfileJunction, junctions["East"].Classification);
+ Assert.Equal(ProfileJunctionKind.ReflexProfileJunction, junctions["Upright"].Classification);
+ Assert.Equal(90d, junctions["East"].MaterialInteriorAngleRadians * 180d / Math.PI, 8);
+ Assert.Equal(270d, junctions["Upright"].MaterialInteriorAngleRadians * 180d / Math.PI, 8);
+ }
+
+ [Fact]
+ public void ClassifiesInnerLoopUsingReversedMaterialSide()
+ {
+ var outer = Profile().Loops.Single();
+ var inner = new ResolvedProfileLoop2D("Hole", false, outer.Segments);
+ var profile = new ResolvedProfile2D("Plate", "XY", [outer, inner]);
+
+ var junction = ProfileJunctionClassifier.Classify(profile, inner).Single(x => x.SuccessorSegmentId == "East");
+
+ Assert.Equal(ProfileJunctionKind.ReflexProfileJunction, junction.Classification);
+ Assert.Equal(270d, junction.MaterialInteriorAngleRadians * 180d / Math.PI, 8);
+ }
+
+ [Fact]
+ public void PlansReflexChainAndPreservesClassificationDescendant()
+ {
+ var profile = LProfile();
+ const string source = "Selection Notch { Source: Bracket.Outer.[Inner, Upright] Require: ConnectedChain } Modify Body { EdgeFinish NotchBreak { Target: Notch On: Top Kind: Chamfer Distance: 1mm } }";
+
+ Assert.True(ProfileBoundaryChamferSourceBinder.TryBind(source, profile, "Bracket", out var target, out var distance, out var diagnostic), diagnostic);
+ var result = ProfileBoundaryChamferPlanner.TryPlan(profile, target!, distance);
+
+ Assert.True(result.Succeeded, string.Join("; ", result.Diagnostics));
+ Assert.NotNull(result.Body);
+ Assert.Contains(result.Correspondence!.Descendants, x => x.StableId.Contains("ReflexProfileJunction", StringComparison.Ordinal));
+ }
+
+ [Fact]
+ public void RejectsProfileFilletAtMaterializationBoundary()
+ {
+ const string source = "Modify Body { EdgeFinish TopRound { Target: Bracket.Outer On: Top Kind: Fillet Radius: 2mm } }";
+
+ Assert.False(ProfileBoundaryChamferSourceBinder.TryBind(source, Profile(), "Bracket", out _, out _, out var diagnostic));
+
+ Assert.Equal("ProfileBoundaryFilletNotMaterialized", diagnostic);
+ }
+
+ private static ResolvedProfile2D Profile()
+ {
+ var points = new[] { (0d, 0d), (20d, 0d), (20d, 10d), (0d, 10d) };
+ var names = new[] { "South", "East", "North", "West" };
+ var segments = points.Select((point, index) => new ResolvedProfileSegment2D(names[index], new LineArcLineSegment2D(point, points[(index + 1) % points.Length]), new ProfileSegmentProvenance($"profile:Bracket.Outer.{names[index]}", "test", "test", "test", "XY"))).ToArray();
+ return new ResolvedProfile2D("Bracket", "XY", [new ResolvedProfileLoop2D("Outer", true, segments)], LocalStartDepth: 0d, LocalEndDepth: 8d);
+ }
+
+ private static ResolvedProfile2D LProfile()
+ {
+ var points = new[] { (0d, 0d), (40d, 0d), (40d, 10d), (10d, 10d), (10d, 40d), (0d, 40d) };
+ var names = new[] { "South", "East", "Inner", "Upright", "North", "West" };
+ var segments = points.Select((point, index) => new ResolvedProfileSegment2D(names[index], new LineArcLineSegment2D(point, points[(index + 1) % points.Length]), new ProfileSegmentProvenance($"profile:Bracket.Outer.{names[index]}", "test", "test", "test", "XY"))).ToArray();
+ return new ResolvedProfile2D("Bracket", "XY", [new ResolvedProfileLoop2D("Outer", true, segments)], LocalStartDepth: 0d, LocalEndDepth: 8d);
+ }
+}
diff --git a/Aetheris.Kernel.Firmament.Tests/Integration/VariableOuterSectionIntervalTests.cs b/Aetheris.Kernel.Firmament.Tests/Integration/VariableOuterSectionIntervalTests.cs
new file mode 100644
index 00000000..a641c0bc
--- /dev/null
+++ b/Aetheris.Kernel.Firmament.Tests/Integration/VariableOuterSectionIntervalTests.cs
@@ -0,0 +1,34 @@
+using Aetheris.Kernel.Firmament.Materializer;
+
+namespace Aetheris.Kernel.Firmament.Tests.Integration;
+
+public sealed class VariableOuterSectionIntervalTests
+{
+ [Fact]
+ public void AcceptsExplicitOuterCorrespondenceAndUnchangedCircularInnerLoop()
+ {
+ var lower = Rectangle("lower", 0d); var upper = Rectangle("upper", 1d);
+ var inner = Circle("shaft", 5d, 5d, 2d);
+ var interval = new VariableOuterSectionInterval("transition", 7d, 8d, lower, upper,
+ Enumerable.Range(0, 4).Select(i => new VariableOuterVertexCorrespondence(lower.Loops[0].Segments[i].Provenance.StableId, upper.Loops[0].Segments[i].Provenance.StableId, i, i)).ToArray(),
+ Enumerable.Range(0, 4).Select(i => new VariableOuterSegmentCorrespondence(lower.Loops[0].Segments[i].Provenance.StableId, upper.Loops[0].Segments[i].Provenance.StableId, i, i)).ToArray(),
+ [new("inner:shaft", "hole:shaft", inner, inner)], "edgefinish:Top", ["test"]);
+ Assert.True(VariableOuterSectionIntervalValidator.Validate(interval).IsValid);
+ }
+
+ [Fact]
+ public void RejectsChangingInnerLoop()
+ {
+ var lower = Rectangle("lower", 0d); var upper = Rectangle("upper", 1d); var a = Circle("shaft", 5d, 5d, 2d); var b = Circle("shaft", 5d, 5d, 3d);
+ var interval = new VariableOuterSectionInterval("transition", 7d, 8d, lower, upper, [], [], [new("inner:shaft", "hole:shaft", a, b)], "edgefinish:Top", ["test"]);
+ Assert.Contains(VariableOuterSectionIntervalValidator.Validate(interval).Diagnostics, x => x.StartsWith("VariableOuterSectionIntervalInnerLoopChanged", StringComparison.Ordinal));
+ }
+
+ private static ResolvedProfile2D Rectangle(string name, double inset)
+ {
+ var p = new[] { (inset, inset), (10d - inset, inset), (10d - inset, 10d - inset), (inset, 10d - inset) };
+ var segments = p.Select((point, i) => new ResolvedProfileSegment2D($"S{i}", new LineArcLineSegment2D(point, p[(i + 1) % 4]), new ProfileSegmentProvenance($"{name}:S{i}", "test", "test", "test", "XY"))).ToArray();
+ return new(name, "XY", [new("Outer", true, segments)]);
+ }
+ private static ResolvedProfile2D Circle(string name, double x, double y, double radius) => new(name, "XY", [new("Outer", true, [new ResolvedProfileSegment2D("Circle", new LineArcFullCircle2D((x, y), radius), new ProfileSegmentProvenance($"{name}:circle", "test", "test", "test", "XY"))])]);
+}
diff --git a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs
index b0740884..e25ac414 100644
--- a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs
@@ -106,7 +106,7 @@ public static class FirmamentBuildAndExport
emitted = new PrismaticSectionStackEmissionResult(materialized.Body, finalPlan, emitted.Diagnostics.Concat(bridgeDiagnostics).ToArray(), finalPlan.Correspondence);
}
if (materializerSource.Contains("EdgeFinish", StringComparison.Ordinal))
- return ExportComposedSemanticTopBoundaryChamfer(materializerSource, parsed, stack, emitted);
+ return ExportComposedSemanticTopBoundaryChamfer(materializerSource, parsed, stack, emitted, v2Parse.Document);
// The composition route either retained the checked body above or
// replaced it with a checked blind-drill materialization.
var completedBody = emitted.Body;
@@ -253,10 +253,43 @@ public static class FirmamentBuildAndExport
}
private static KernelResult<FirmamentStepExportResult> ExportComposedSemanticTopBoundaryChamfer(
- string source, PrismaticProfileCompositionParseResult parsed, PrismaticSectionStackConstruction stack, PrismaticSectionStackEmissionResult emitted)
+ string source, PrismaticProfileCompositionParseResult parsed, PrismaticSectionStackConstruction stack, PrismaticSectionStackEmissionResult emitted,
+ FirmamentV2Document? canonicalDocument)
{
KernelResult<FirmamentStepExportResult> Fail(string code) => KernelResult<FirmamentStepExportResult>.Failure([
new Kernel.Core.Diagnostics.KernelDiagnostic(Kernel.Core.Diagnostics.KernelDiagnosticCode.ValidationFailed, Kernel.Core.Diagnostics.KernelDiagnosticSeverity.Error, code, "FirmamentV2.ComposeSemanticSelection")]);
+ if (ProfileBoundaryChamferSourceBinder.HasSemanticProfileBoundaryFinish(source))
+ {
+ ProfileBoundaryChamferTarget? target = null; double distance = 0d; string? bindingDiagnostic = null; ResolvedProfile2D? profile = null;
+ foreach (var candidate in parsed.Profiles.Values.OrderBy(x => x.Name, StringComparer.Ordinal))
+ {
+ if (ProfileBoundaryChamferSourceBinder.TryBind(source, candidate, stack.Feature.Name, out target, out distance, out bindingDiagnostic)) { profile = candidate; break; }
+ }
+ if (profile is null || target is null) return Fail(bindingDiagnostic ?? "ProfileBoundaryChamferProfileUnknown");
+ var admission = ComposedProfileBoundaryChamferAdmissionChecker.Check(stack, profile, target, distance);
+ if (!admission.Admitted) return Fail(admission.Diagnostics.FirstOrDefault() ?? "ProfileBoundaryChamferCavityInteractionUnsupported");
+ var adjusted = ComposedProfileBoundaryChamferStackPlanner.TryApply(stack, profile, target, distance, out var planDiagnostics);
+ if (adjusted is null) return Fail(planDiagnostics.FirstOrDefault() ?? "ProfileBoundaryChamferComposeTopologyPlanNotMaterialized");
+ var plannedEmission = PrismaticSectionStackEmitter.Emit(adjusted);
+ if (plannedEmission.Body is null) return Fail(plannedEmission.Diagnostics.FirstOrDefault() ?? "ProfileBoundaryChamferComposeMaterializationFailed");
+ if (!FirmamentManifoldChecker.IsManifold(plannedEmission.Body)) return Fail("ProfileBoundaryChamferNonManifold");
+ var semanticPmi = Array.Empty<Step242SemanticPmi>();
+ if (canonicalDocument is not null)
+ {
+ var support = ValidateV2PmiExportSupport(canonicalDocument);
+ if (!support.IsSuccess) return KernelResult<FirmamentStepExportResult>.Failure(support.Diagnostics);
+ var features = (stack.Feature.ShaftHoles ?? []).ToDictionary(hole => hole.Name, hole => hole.StableId, StringComparer.Ordinal);
+ foreach (var hole in stack.Feature.CounterboreHoles ?? []) features[hole.Name] = hole.StableId;
+ semanticPmi = BuildV2SemanticPmi(canonicalDocument, [], stack.Feature.Name, features).ToArray();
+ }
+ var plannedStep = Step242Exporter.ExportBody(plannedEmission.Body, semanticPmi, new Step242ExportOptions { ProductName = target.StableId, ApplicationName = "Aetheris.Firmament.ComposedProfileBoundaryChamfer.M3", BrepExportPreflightMode = BrepExportPreflightMode.Enforce, BrepExportPreflightPolicy = BrepExportPreflightPolicy.TrustedProductionRoute });
+ if (!plannedStep.IsSuccess || plannedStep.Value is null) return KernelResult<FirmamentStepExportResult>.Failure(plannedStep.Diagnostics);
+ var plannedReimport = Step242Importer.ImportBody(plannedStep.Value);
+ if (!plannedReimport.IsSuccess || plannedReimport.Value is null || !FirmamentManifoldChecker.IsManifold(plannedReimport.Value)) return Fail("ProfileBoundaryChamferStepReimportFailed");
+ return KernelResult<FirmamentStepExportResult>.Success(new FirmamentStepExportResult(plannedStep.Value, target.StableId, 0, "composed-profile-boundary-chamfer-section-stack", "source-grounded-composed-profile-boundary-chamfer",
+ DatumInspection: canonicalDocument?.Pmi?.Where(p => p.Kind == FirmamentV2PmiKind.DatumPlane).Select(p => new FirmamentPmiInspectionDatum(p.Name, "planar", p.Target)).ToArray() ?? [],
+ DimensionInspection: canonicalDocument?.Pmi?.Where(p => p.Kind == FirmamentV2PmiKind.HoleDiameter).Select(p => new FirmamentPmiInspectionDimension("Diameter", p.Target, null, p.Value ?? 0d, "explicit-v2-record-pmi", p.Name)).ToArray() ?? []));
+ }
if (emitted.Body is null || emitted.Correspondence is null) return Fail("MissingCorrespondenceEvidence");
var composedCurves = stack.Slabs.MaxBy(s => s.To)!.Region.Outer.Loops.Single().Segments.Select(segment => segment.Geometry).ToArray();
if (!IsAdmittedPrimitiveBoundary(composedCurves))
@@ -290,6 +323,26 @@ public static class FirmamentBuildAndExport
{
KernelResult<FirmamentStepExportResult> Fail(string code) => KernelResult<FirmamentStepExportResult>.Failure([
new Kernel.Core.Diagnostics.KernelDiagnostic(Kernel.Core.Diagnostics.KernelDiagnosticCode.ValidationFailed, Kernel.Core.Diagnostics.KernelDiagnosticSeverity.Error, code, "FirmamentV2.SemanticSelection")]);
+ if (ProfileBoundaryChamferSourceBinder.HasSemanticProfileBoundaryFinish(source))
+ {
+ if (!ProfileBoundaryChamferSourceBinder.TryBind(source, profile, profile.Name, out var target, out var distance, out var bindingDiagnostic))
+ return Fail(bindingDiagnostic ?? "ProfileBoundaryChamferBindingFailed");
+ var planned = ProfileBoundaryChamferPlanner.TryPlan(profile, target!, distance);
+ if (!planned.Succeeded || planned.Body is null || planned.Correspondence is null)
+ return Fail(planned.Diagnostics.FirstOrDefault() ?? "ProfileBoundaryChamferPlanningFailed");
+ if (!FirmamentManifoldChecker.IsManifold(planned.Body)) return Fail("ProfileBoundaryChamferNonManifold");
+ var plannedStep = Step242Exporter.ExportBody(planned.Body, new Step242ExportOptions
+ {
+ ProductName = target!.StableId,
+ ApplicationName = "Aetheris.Firmament.ProfileBoundaryChamfer.M1",
+ BrepExportPreflightMode = BrepExportPreflightMode.Enforce,
+ BrepExportPreflightPolicy = BrepExportPreflightPolicy.TrustedProductionRoute
+ });
+ if (!plannedStep.IsSuccess || plannedStep.Value is null) return KernelResult<FirmamentStepExportResult>.Failure(plannedStep.Diagnostics);
+ var plannedReimport = Step242Importer.ImportBody(plannedStep.Value);
+ if (!plannedReimport.IsSuccess || plannedReimport.Value is null || !FirmamentManifoldChecker.IsManifold(plannedReimport.Value)) return Fail("ProfileBoundaryChamferStepReimportFailed");
+ return KernelResult<FirmamentStepExportResult>.Success(new FirmamentStepExportResult(plannedStep.Value, target.StableId, 0, "profile-boundary-chamfer-section-stack", "source-grounded-profile-boundary-chamfer"));
+ }
if (emitted.Body is null || emitted.Correspondence is null) return Fail("NoMaterializedDescendants");
if (!IsAdmittedPrimitiveBoundary(profile.Loops.Single().Segments.Select(segment => segment.Geometry).ToArray()))
return Fail($"{EdgeFinishProfileComposeBoundaryUnsupported}:host={profile.Name}:construction=Profile:face=+Z:target=Boundary:supported=primitive-box-or-explicit-semantic-chain:Profile/Compose polygon-boundary materialization is not implemented.");
diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs
index 7fcce185..d5e89a9a 100644
--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs
@@ -963,6 +963,7 @@ public static class FirmamentV2Parser
var (compositionPmi, compositionPmiBlock, compositionBoundPmi) = ParsePmi(
source, compositionSolids, [], [], [], [], diagnostics, (feature.ShaftHoles ?? []).Select(hole => hole.Name).Concat((feature.CounterboreHoles ?? []).Select(hole => hole.Name)));
if (Regex.IsMatch(body, @"\bEdgeFinish\b", RegexOptions.CultureInvariant)
+ && !ProfileBoundaryChamferSourceBinder.HasSemanticProfileBoundaryFinish(body)
&& composition.Profiles.Values.Any(profile => profile.Loops.Single().Segments.Count != 4))
{
diagnostics.Add($"{EdgeFinishProfileComposeBoundaryUnsupported}:host={feature.Name}:construction=Compose:face=+Z:target=Boundary:supported=primitive-box-or-explicit-semantic-chain:Profile/Compose polygon-boundary materialization is not implemented.");
@@ -1009,6 +1010,7 @@ public static class FirmamentV2Parser
};
var (profilePmi, profilePmiBlock, profileBoundPmi) = ParsePmi(source, profileSolids, [], [], [], [], diagnostics);
if (Regex.IsMatch(body, @"\bEdgeFinish\b", RegexOptions.CultureInvariant)
+ && !ProfileBoundaryChamferSourceBinder.HasSemanticProfileBoundaryFinish(body)
&& resolved.Loops.Single().Segments.Count != 4)
{
diagnostics.Add($"{EdgeFinishProfileComposeBoundaryUnsupported}:host={resolved.Name}:construction=Profile:face=+Z:target=Boundary:supported=primitive-box-or-explicit-semantic-chain:Profile/Compose polygon-boundary materialization is not implemented.");
diff --git a/Aetheris.Kernel.Firmament/Materializer/ComposedProfileBoundaryChamferAdmission.cs b/Aetheris.Kernel.Firmament/Materializer/ComposedProfileBoundaryChamferAdmission.cs
new file mode 100644
index 00000000..22a70d7d
--- /dev/null
+++ b/Aetheris.Kernel.Firmament/Materializer/ComposedProfileBoundaryChamferAdmission.cs
@@ -0,0 +1,81 @@
+namespace Aetheris.Kernel.Firmament.Materializer;
+
+/// <summary>
+/// Source-level admission for a composed-host boundary chamfer. This is deliberately
+/// evaluated from the normalized Profile and cavity declarations, before a topology plan
+/// exists; no materialized edge or face participates in the decision.
+/// </summary>
+public sealed record ProfileBoundaryChamferCorridor(
+ string EdgeFinishId, string ProfileId, string LoopId, double Distance,
+ double From, double To, IReadOnlyList<string> SourceSegmentIds);
+public sealed record ProfileBoundaryChamferCavityInteraction(
+ string FeatureId, string Kind, double CenterX, double CenterY, double Radius,
+ double From, double To, string Classification, string Diagnostic);
+public sealed record ComposedProfileBoundaryChamferAdmission(
+ bool Admitted, ProfileBoundaryChamferCorridor? Corridor,
+ IReadOnlyList<ProfileBoundaryChamferCavityInteraction> Interactions,
+ IReadOnlyList<string> Diagnostics);
+
+public static class ComposedProfileBoundaryChamferAdmissionChecker
+{
+ private const double Tol = 1e-7;
+
+ public static ComposedProfileBoundaryChamferAdmission Check(
+ PrismaticSectionStackConstruction stack, ResolvedProfile2D profile,
+ ProfileBoundaryChamferTarget target, double distance)
+ {
+ if (target.ChainKind != ProfileBoundaryChamferChainKind.ClosedLoop)
+ return new(false, null, [], ["ProfileBoundaryChamferComposeOpenChainUnsupported"]);
+ if (target.Side != ProfileBoundaryChamferSide.Top)
+ return new(false, null, [], ["ProfileBoundaryChamferComposeBottomUnsupported"]);
+ var loop = profile.Loops.SingleOrDefault(x => x.Name == target.LoopId);
+ if (loop is null || !loop.IsOuter || loop.Segments.Any(x => x.Geometry is not LineArcLineSegment2D))
+ return new(false, null, [], ["ProfileBoundaryChamferSegmentKindUnsupported"]);
+ var top = stack.Feature.CriticalLevels.Max();
+ var corridor = new ProfileBoundaryChamferCorridor(target.StableId, profile.Name, loop.Name, distance, top - distance, top, target.SegmentIds);
+ var interactions = new List<ProfileBoundaryChamferCavityInteraction>();
+ foreach (var hole in stack.Feature.ShaftHoles ?? [])
+ interactions.Add(Classify(loop, corridor, hole.StableId, "Shaft", hole.CenterX, hole.CenterY, hole.Diameter / 2d, hole.From, hole.To));
+ foreach (var hole in stack.Feature.CounterboreHoles ?? [])
+ {
+ // The entry recess overlaps the Top corridor in the admitted +Z family.
+ // It must be tested with its larger radius, not merely its shaft radius.
+ var boreFrom = Math.Max(hole.From, hole.To - hole.CounterboreDepth);
+ interactions.Add(Classify(loop, corridor, hole.StableId, "Counterbore", hole.CenterX, hole.CenterY, hole.CounterboreDiameter / 2d, boreFrom, hole.To));
+ if (boreFrom > hole.From + Tol)
+ interactions.Add(Classify(loop, corridor, hole.StableId, "CounterboreShaft", hole.CenterX, hole.CenterY, hole.Diameter / 2d, hole.From, boreFrom));
+ }
+ var rejected = interactions.Where(x => x.Classification != "Disjoint").ToArray();
+ return new(rejected.Length == 0, corridor, interactions,
+ rejected.Select(x => x.Diagnostic).Distinct(StringComparer.Ordinal).ToArray());
+ }
+
+ private static ProfileBoundaryChamferCavityInteraction Classify(
+ ResolvedProfileLoop2D loop, ProfileBoundaryChamferCorridor corridor,
+ string featureId, string kind, double x, double y, double radius, double from, double to)
+ {
+ var overlaps = from < corridor.To - Tol && to > corridor.From + Tol;
+ if (!overlaps) return new(featureId, kind, x, y, radius, from, to, "Disjoint", string.Empty);
+ var boundaryDistance = loop.Segments.Cast<ResolvedProfileSegment2D>()
+ .Select(segment => (LineArcLineSegment2D)segment.Geometry)
+ .Select(line => PointSegmentDistance((x, y), line.Start, line.End)).Min();
+ // This is a conservative analytic ring test: the Minkowski sum of the
+ // profile-boundary corridor and the circular cavity footprint. A touching
+ // result is intentionally rejected; a later exact cell test may only relax it.
+ if (boundaryDistance <= radius + corridor.Distance + Tol)
+ {
+ var code = kind == "Shaft" ? "ProfileBoundaryChamferIntersectsShaft" : "ProfileBoundaryChamferIntersectsCounterbore";
+ var classification = Math.Abs(boundaryDistance - radius - corridor.Distance) <= Tol ? "TouchingWithinTolerance" : "Intersecting";
+ return new(featureId, kind, x, y, radius, from, to, classification,
+ $"{code}:edgeFinish={corridor.EdgeFinishId}:cavity={featureId}:profile={corridor.ProfileId}.{corridor.LoopId}:distance={corridor.Distance:R}:center=({x:R},{y:R}):radius={radius:R}:interval=({Math.Max(from, corridor.From):R},{Math.Min(to, corridor.To):R})");
+ }
+ return new(featureId, kind, x, y, radius, from, to, "Disjoint", string.Empty);
+ }
+
+ private static double PointSegmentDistance((double X, double Y) p, (double X, double Y) a, (double X, double Y) b)
+ {
+ var dx = b.X - a.X; var dy = b.Y - a.Y; var lengthSquared = dx * dx + dy * dy;
+ var t = Math.Clamp(((p.X - a.X) * dx + (p.Y - a.Y) * dy) / lengthSquared, 0d, 1d);
+ var rx = p.X - (a.X + t * dx); var ry = p.Y - (a.Y + t * dy); return Math.Sqrt(rx * rx + ry * ry);
+ }
+}
diff --git a/Aetheris.Kernel.Firmament/Materializer/ComposedProfileBoundaryChamferStackPlanner.cs b/Aetheris.Kernel.Firmament/Materializer/ComposedProfileBoundaryChamferStackPlanner.cs
new file mode 100644
index 00000000..cc4b613a
--- /dev/null
+++ b/Aetheris.Kernel.Firmament/Materializer/ComposedProfileBoundaryChamferStackPlanner.cs
@@ -0,0 +1,34 @@
+namespace Aetheris.Kernel.Firmament.Materializer;
+
+/// <summary>Transforms normalized source sections into one final variable-outer interval before emission.</summary>
+public static class ComposedProfileBoundaryChamferStackPlanner
+{
+ private const double Tol = 1e-7;
+ public static PrismaticSectionStackConstruction? TryApply(PrismaticSectionStackConstruction stack, ResolvedProfile2D profile, ProfileBoundaryChamferTarget target, double distance, out IReadOnlyList<string> diagnostics)
+ {
+ var d = new List<string>(); var top = stack.Feature.CriticalLevels.Max(); var lower = top - distance;
+ var topSlab = stack.Slabs.SingleOrDefault(x => x.From < lower + Tol && x.To >= top - Tol);
+ if (topSlab is null) { diagnostics = ["ProfileBoundaryChamferComposeStationUnavailable"]; return null; }
+ if (stack.Feature.CounterboreHoles?.Any(h => h.To - h.CounterboreDepth > lower + Tol && h.To - h.CounterboreDepth < top - Tol) == true) { diagnostics = ["ProfileBoundaryChamferCounterboreStationOverlapUnsupported"]; return null; }
+ var outer = topSlab.Region.Outer;
+ // The arrangement-owned outer loop is the exact section consumed by this
+ // stack. Offset that source-equivalent loop, rather than assuming its
+ // ordering matches the parser's profile declaration.
+ var arrangedTarget = target with { ProfileId = outer.Name, LoopId = outer.Loops.Single(x => x.IsOuter).Name, SegmentIds = outer.Loops.Single(x => x.IsOuter).Segments.Select(x => x.Name).ToArray(), ChainKind = ProfileBoundaryChamferChainKind.ClosedLoop };
+ if (!ProfileBoundaryChamferPlanner.TryCreateInsetOuterProfile(outer, arrangedTarget, distance, out var inset, out var insetDiagnostic)) { diagnostics = [insetDiagnostic ?? "ProfileBoundaryChamferInsetCollapse"]; return null; }
+ if (outer.Loops[0].Segments.Count != inset!.Loops[0].Segments.Count) { diagnostics = ["VariableOuterSectionIntervalOuterVertexCountMismatch"]; return null; }
+ var vertices = outer.Loops[0].Segments.Select((segment, i) => new VariableOuterVertexCorrespondence(segment.Provenance.StableId, inset.Loops[0].Segments[i].Provenance.StableId, i, i)).ToArray();
+ var segments = outer.Loops[0].Segments.Select((segment, i) => new VariableOuterSegmentCorrespondence(segment.Provenance.StableId, inset.Loops[0].Segments[i].Provenance.StableId, i, i)).ToArray();
+ var inners = topSlab.Region.Holes.OrderBy(x => x.Name, StringComparer.Ordinal).Select(hole => new UnchangedInnerLoopCorrespondence($"inner:{hole.Name}", FeatureFor(hole.Name), hole, hole)).ToArray();
+ var interval = new VariableOuterSectionInterval($"variable-outer:{target.StableId}", lower, top, outer, inset, vertices, segments, inners, target.StableId, ["ProfileBoundaryChamfer", "PrismaticSectionStackTopologyPlan"]);
+ d.AddRange(VariableOuterSectionIntervalValidator.Validate(interval).Diagnostics);
+ if (d.Count != 0) { diagnostics = d; return null; }
+ var slabs = stack.Slabs.Where(x => !ReferenceEquals(x, topSlab)).Append(new PrismaticSectionSlab(topSlab.From, lower, topSlab.Region, topSlab.ActiveOperations, topSlab.Arrangement)).OrderBy(x => x.From).ToArray();
+ var capRegion = new PrismaticSectionRegion(inset, topSlab.Region.Holes, topSlab.Region.Provenance.Concat([target.StableId]).ToArray());
+ var transitions = stack.Transitions.Where(x => Math.Abs(x.Level - top) > Tol).Append(new PrismaticSectionTransition(top, [capRegion], [])).OrderBy(x => x.Level).ToArray();
+ diagnostics = [];
+ return stack with { Slabs = slabs, Transitions = transitions, VariableOuterIntervals = [interval] };
+
+ string FeatureFor(string profileName) => stack.Feature.Operations.FirstOrDefault(x => x.ProfileReference == profileName)?.SemanticFeatureId ?? $"profile:{profileName}";
+ }
+}
diff --git a/Aetheris.Kernel.Firmament/Materializer/PrismaticProfileComposition.cs b/Aetheris.Kernel.Firmament/Materializer/PrismaticProfileComposition.cs
index 6dbfa842..334ecd1c 100644
--- a/Aetheris.Kernel.Firmament/Materializer/PrismaticProfileComposition.cs
+++ b/Aetheris.Kernel.Firmament/Materializer/PrismaticProfileComposition.cs
@@ -70,7 +70,8 @@ public sealed record PrismaticSectionTransition(
double Level, IReadOnlyList<PrismaticSectionRegion> UpwardRegions, IReadOnlyList<PrismaticSectionRegion> DownwardRegions);
public sealed record PrismaticSectionStackConstruction(
PrismaticProfileCompositionFeature Feature, IReadOnlyList<PrismaticSectionSlab> Slabs,
- IReadOnlyList<PrismaticSectionTransition> Transitions, double AnalyticVolume, IReadOnlyList<string> Diagnostics);
+ IReadOnlyList<PrismaticSectionTransition> Transitions, double AnalyticVolume, IReadOnlyList<string> Diagnostics,
+ IReadOnlyList<VariableOuterSectionInterval>? VariableOuterIntervals = null);
public sealed record PrismaticProfileCompositionParseResult(
PrismaticProfileCompositionFeature? Feature, IReadOnlyDictionary<string, ResolvedProfile2D> Profiles, IReadOnlyList<string> Diagnostics,
StaticGeometryExpansionEvidence? Expansion = null);
diff --git a/Aetheris.Kernel.Firmament/Materializer/PrismaticSectionStackCompiler.cs b/Aetheris.Kernel.Firmament/Materializer/PrismaticSectionStackCompiler.cs
index c544604d..4ec0719e 100644
--- a/Aetheris.Kernel.Firmament/Materializer/PrismaticSectionStackCompiler.cs
+++ b/Aetheris.Kernel.Firmament/Materializer/PrismaticSectionStackCompiler.cs
@@ -161,9 +161,15 @@ public static class PrismaticSectionStackEmitter
var builder = new TopologyBuilder(); var points = new Dictionary<VertexId, Point3D>(); var curves = new Dictionary<EdgeId, CurveGeometry>(); var profileCurves = new Dictionary<EdgeId, LineArcProfileCurve2D>();
var vertices = new Dictionary<(long X, long Y, long Z), VertexId>(); var edges = new Dictionary<string, EdgeId>();
var sideFaces = new List<(LoopId Loop, SurfaceGeometry Surface, bool SameSense, string Source, string Construction, double From, double To)>(); var capFaces = new List<(FaceId Face, double Z, bool Up)>();
+ var variableIntervals = stack.VariableOuterIntervals ?? [];
+ foreach (var interval in variableIntervals)
+ d.AddRange(VariableOuterSectionIntervalValidator.Validate(interval).Diagnostics);
+ if (d.Any(x => x.StartsWith("VariableOuterSectionInterval", StringComparison.Ordinal)))
+ return new(null, d.Distinct().ToArray());
var splitPoints = stack.Slabs.SelectMany(s => Loops(s.Region)).Concat(stack.Transitions.SelectMany(t =>
t.UpwardRegions.Concat(t.DownwardRegions).SelectMany(Loops)))
- .SelectMany(x => x.Profile.Loops[0].Segments).SelectMany(x => Ends(x.Geometry)).DistinctBy(p => $"{Math.Round(p.X / Tol):F0},{Math.Round(p.Y / Tol):F0}").ToArray();
+ .SelectMany(x => x.Profile.Loops[0].Segments).Concat(variableIntervals.SelectMany(v => v.LowerOuter.Loops.Concat(v.UpperOuter.Loops).Concat(v.InnerLoops.SelectMany(i => i.LowerLoop.Loops))).SelectMany(x => x.Segments))
+ .SelectMany(x => Ends(x.Geometry)).DistinctBy(p => $"{Math.Round(p.X / Tol):F0},{Math.Round(p.Y / Tol):F0}").ToArray();
(long X, long Y, long Z) Key((double X, double Y) p, double z) => ((long)Math.Round(p.X / Tol), (long)Math.Round(p.Y / Tol), (long)Math.Round(z / Tol));
VertexId Vertex((double X, double Y) p, double z) { var key = Key(p, z); if (vertices.TryGetValue(key, out var id)) return id; id = builder.AddVertex(); vertices[key] = id; points[id] = new(p.X, p.Y, z); return id; }
(EdgeId Edge, bool Reverse) Edge(LineArcProfileCurve2D curve, double z)
@@ -179,6 +185,13 @@ public static class PrismaticSectionStackEmitter
if (edges.TryGetValue(key, out var e)) return (e, false); if (edges.TryGetValue(reverse, out e)) return (e, true);
var created = builder.AddEdge(Vertex(p, from), Vertex(p, to)); edges[key] = created; curves[created] = CurveGeometry.FromLine(new Line3Curve(points[Vertex(p, from)], Direction3D.Create(points[Vertex(p, to)] - points[Vertex(p, from)]))); return (created, false);
}
+ (EdgeId Edge, bool Reverse) Transition((double X, double Y) from, (double X, double Y) to, double lower, double upper)
+ {
+ var key = $"T:{Key(from, lower)}:{Key(to, upper)}"; var reverse = $"T:{Key(to, upper)}:{Key(from, lower)}";
+ if (edges.TryGetValue(key, out var e)) return (e, false); if (edges.TryGetValue(reverse, out e)) return (e, true);
+ var created = builder.AddEdge(Vertex(from, lower), Vertex(to, upper)); edges[key] = created;
+ curves[created] = CurveGeometry.FromLine(new Line3Curve(points[Vertex(from, lower)], Direction3D.Create(points[Vertex(to, upper)] - points[Vertex(from, lower)]))); return (created, false);
+ }
foreach (var slab in stack.Slabs)
foreach (var item in Loops(slab.Region))
foreach (var segment in item.Profile.Loops[0].Segments)
@@ -189,6 +202,26 @@ public static class PrismaticSectionStackEmitter
var source = SourceId(segment.Provenance.StableId);
sideFaces.Add((loop, SideSurface(curve, slab.From, item.IsHole), !(item.IsHole && curve is LineArcCircularArc2D), source, $"slab:{slab.From:R}..{slab.To:R}:{segment.Provenance.Derivation}", slab.From, slab.To));
}
+ foreach (var interval in variableIntervals)
+ {
+ var lower = interval.LowerOuter.Loops.Single(x => x.IsOuter); var upper = interval.UpperOuter.Loops.Single(x => x.IsOuter);
+ for (var i = 0; i < lower.Segments.Count; i++)
+ {
+ var l = (LineArcLineSegment2D)lower.Segments[i].Geometry; var u = (LineArcLineSegment2D)upper.Segments[i].Geometry;
+ var bottom = Edge(l, interval.LowerStation); var top = Edge(u, interval.UpperStation); var end = Transition(l.End, u.End, interval.LowerStation, interval.UpperStation); var start = Transition(l.Start, u.Start, interval.LowerStation, interval.UpperStation);
+ var loop = AddLoop(builder, [new(bottom.Edge, bottom.Reverse), new(end.Edge, end.Reverse), new(top.Edge, !top.Reverse), new(start.Edge, !start.Reverse)]);
+ var origin = points[Vertex(l.Start, interval.LowerStation)]; var normal = (points[Vertex(l.End, interval.LowerStation)] - origin).Cross(points[Vertex(u.Start, interval.UpperStation)] - origin);
+ sideFaces.Add((loop, SurfaceGeometry.FromPlane(new PlaneSurface(origin, Direction3D.Create(normal), Direction3D.Create(points[Vertex(l.End, interval.LowerStation)] - origin))), true, SourceId(lower.Segments[i].Provenance.StableId), $"variable:{interval.StableId}:{i}", interval.LowerStation, interval.UpperStation));
+ }
+ foreach (var inner in interval.InnerLoops)
+ foreach (var segment in inner.LowerLoop.Loops[0].Segments)
+ foreach (var curve in Split(segment.Geometry, splitPoints))
+ {
+ var ends = Ends(curve); var bottom = Edge(curve, interval.LowerStation); var top = Edge(curve, interval.UpperStation); var v0 = Vertical(ends[0], interval.LowerStation, interval.UpperStation); var v1 = Vertical(ends[1], interval.LowerStation, interval.UpperStation);
+ var loop = AddLoop(builder, [new(bottom.Edge, !bottom.Reverse), new(v0.Edge, v0.Reverse), new(top.Edge, top.Reverse), new(v1.Edge, !v1.Reverse)]);
+ sideFaces.Add((loop, SideSurface(curve, interval.LowerStation, true), false, inner.FeatureId, $"variable:{interval.StableId}:inner:{inner.FeatureId}", interval.LowerStation, interval.UpperStation));
+ }
+ }
foreach (var transition in stack.Transitions)
{
foreach (var region in transition.UpwardRegions) capFaces.Add((AddCap(builder, region, transition.Level, Edge, splitPoints), transition.Level, true));
diff --git a/Aetheris.Kernel.Firmament/Materializer/ProfileBoundaryChamfer.cs b/Aetheris.Kernel.Firmament/Materializer/ProfileBoundaryChamfer.cs
new file mode 100644
index 00000000..9d57cb32
--- /dev/null
+++ b/Aetheris.Kernel.Firmament/Materializer/ProfileBoundaryChamfer.cs
@@ -0,0 +1,375 @@
+using System.Globalization;
+using System.Text.RegularExpressions;
+using Aetheris.Kernel.Core.Brep;
+using Aetheris.Kernel.Core.Geometry;
+using Aetheris.Kernel.Core.Geometry.Curves;
+using Aetheris.Kernel.Core.Geometry.Surfaces;
+using Aetheris.Kernel.Core.Math;
+using Aetheris.Kernel.Core.Topology;
+
+namespace Aetheris.Kernel.Firmament.Materializer;
+
+/// <summary>
+/// A source-bound edge finish. It deliberately contains resolved Profile identities rather
+/// than BRep edge ids: the BRep is produced by this plan, never searched to discover a target.
+/// </summary>
+public enum ProfileBoundaryChamferSide { Top, Bottom }
+public enum ProfileBoundaryChamferChainKind { SingleSegment, OpenConnectedChain, ClosedLoop }
+public sealed record ProfileBoundaryChamferTarget(
+ string StableId, string HostBodyId, string ProfileId, string LoopId,
+ IReadOnlyList<string> SegmentIds, ProfileBoundaryChamferSide Side,
+ ProfileBoundaryChamferChainKind ChainKind, string SourceSpan, string SelectionProvenance);
+public sealed record ProfileBoundaryChamferPlanResult(
+ bool Succeeded, BrepBody? Body, SemanticTopologyCorrespondence? Correspondence,
+ ProfileBoundaryChamferTarget? Target, IReadOnlyList<string> Diagnostics);
+
+public static class ProfileBoundaryChamferSourceBinder
+{
+ private static readonly Regex EdgeFinishHeader = new(@"\bEdgeFinish\s+(?<name>\w+)\s*\{", RegexOptions.CultureInvariant);
+ private static readonly Regex Target = new(@"\bTarget\s*:\s*(?<value>[A-Za-z_]\w*(?:\.[A-Za-z_]\w*){0,2})", RegexOptions.CultureInvariant);
+ private static readonly Regex On = new(@"\bOn\s*:\s*(?<value>Top|Bottom)\b", RegexOptions.CultureInvariant);
+ private static readonly Regex Kind = new(@"\bKind\s*:\s*(?<value>\w+)\b", RegexOptions.CultureInvariant);
+ private static readonly Regex Distance = new(@"\bDistance\s*:\s*(?<value>[-+.\deE]+)mm\b", RegexOptions.CultureInvariant);
+ private static readonly Regex Radius = new(@"\bRadius\s*:\s*(?<value>[-+.\deE]+)mm\b", RegexOptions.CultureInvariant);
+ private static readonly Regex SelectionHeader = new(@"\bSelection\s+(?<name>\w+)\s*\{", RegexOptions.CultureInvariant);
+ private static readonly Regex CanonicalSelection = new(@"\bSource\s*:\s*(?<profile>\w+)\.(?<loop>\w+)\.\[\s*(?<segments>[\w\s,]+)\s*\]", RegexOptions.CultureInvariant);
+ private static readonly Regex HistoricalSelection = new(@"\bSource\s*:\s*(?<profile>\w+)\.ProfileSegments\s*\(\s*\[(?<segments>[\w\s,]+)\]\s*\)", RegexOptions.CultureInvariant);
+ private static readonly Regex Require = new(@"\bRequire\s*:\s*(?<value>ConnectedChain|ClosedLoop)\b", RegexOptions.CultureInvariant);
+
+ public static bool HasSemanticProfileBoundaryFinish(string source) =>
+ EdgeFinishHeader.Matches(source).Cast<Match>().Any(header =>
+ {
+ var body = Block(source, header.Index + header.Length - 1);
+ return body is not null && On.IsMatch(body);
+ });
+
+ public static bool TryBind(string source, ResolvedProfile2D profile, string hostBodyId, out ProfileBoundaryChamferTarget? target, out double distance, out string? diagnostic)
+ {
+ target = null; distance = 0d; diagnostic = null;
+ var finish = EdgeFinishHeader.Matches(source).Cast<Match>().Select(match => (Match: match, Body: Block(source, match.Index + match.Length - 1))).FirstOrDefault(x => x.Body is not null && On.IsMatch(x.Body));
+ if (finish.Body is null) { diagnostic = "ProfileBoundaryChamferBoundaryRequired"; return false; }
+ var name = finish.Match.Groups["name"].Value;
+ var targetMatch = Target.Match(finish.Body); var on = On.Match(finish.Body); var kind = Kind.Match(finish.Body); var amount = Distance.Match(finish.Body);
+ if (!targetMatch.Success || !on.Success || !kind.Success) { diagnostic = "ProfileBoundaryChamferDeclarationInvalid"; return false; }
+ if (string.Equals(kind.Groups["value"].Value, "Fillet", StringComparison.Ordinal))
+ {
+ diagnostic = Radius.IsMatch(finish.Body) ? "ProfileBoundaryFilletNotMaterialized" : "ProfileBoundaryFilletRadiusRequired";
+ return false;
+ }
+ if (!amount.Success) { diagnostic = "ProfileBoundaryChamferDeclarationInvalid"; return false; }
+ if (!string.Equals(kind.Groups["value"].Value, "Chamfer", StringComparison.Ordinal)) { diagnostic = "ProfileBoundaryChamferKindUnsupported"; return false; }
+ if (!double.TryParse(amount.Groups["value"].Value, NumberStyles.Float, CultureInfo.InvariantCulture, out distance) || !double.IsFinite(distance) || distance <= 0d) { diagnostic = "ProfileBoundaryChamferDistanceMustBePositive"; return false; }
+
+ var rawTarget = targetMatch.Groups["value"].Value;
+ string requestedProfile; string loop; IReadOnlyList<string> segments; ProfileBoundaryChamferChainKind chainKind; string provenance;
+ var parts = rawTarget.Split('.');
+ if (parts.Length >= 2)
+ {
+ requestedProfile = parts[0]; loop = parts[1];
+ if (parts.Length == 3) { segments = [parts[2]]; chainKind = ProfileBoundaryChamferChainKind.SingleSegment; }
+ else { segments = []; chainKind = ProfileBoundaryChamferChainKind.ClosedLoop; }
+ provenance = "DirectProfileBoundaryTarget";
+ }
+ else
+ {
+ var selection = SelectionHeader.Matches(source).Cast<Match>().Select(match => (Match: match, Body: Block(source, match.Index + match.Length - 1))).FirstOrDefault(x => x.Match.Groups["name"].Value == rawTarget);
+ if (selection.Body is null) { diagnostic = "ProfileBoundaryChamferTargetUnknown"; return false; }
+ var canonical = CanonicalSelection.Match(selection.Body); var historical = HistoricalSelection.Match(selection.Body); var sourceMatch = canonical.Success ? canonical : historical;
+ var require = Require.Match(selection.Body);
+ if (!sourceMatch.Success || !require.Success) { diagnostic = "ProfileBoundaryChamferSelectionKindUnsupported"; return false; }
+ requestedProfile = sourceMatch.Groups["profile"].Value; loop = canonical.Success ? canonical.Groups["loop"].Value : "Outer";
+ segments = sourceMatch.Groups["segments"].Value.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
+ chainKind = string.Equals(require.Groups["value"].Value, "ClosedLoop", StringComparison.Ordinal) ? ProfileBoundaryChamferChainKind.ClosedLoop : ProfileBoundaryChamferChainKind.OpenConnectedChain;
+ provenance = $"Selection:{rawTarget}";
+ }
+ if (!string.Equals(requestedProfile, profile.Name, StringComparison.Ordinal)) { diagnostic = "ProfileBoundaryChamferProfileUnknown"; return false; }
+ var resolvedLoop = profile.Loops.SingleOrDefault(x => string.Equals(x.Name, loop, StringComparison.Ordinal));
+ if (resolvedLoop is null) { diagnostic = "ProfileBoundaryChamferLoopUnknown"; return false; }
+ if (!resolvedLoop.IsOuter) { diagnostic = "ProfileBoundaryChamferInnerLoopUnsupported"; return false; }
+ if (segments.Count == 0) segments = resolvedLoop.Segments.Select(x => x.Name).ToArray();
+ if (segments.Distinct(StringComparer.Ordinal).Count() != segments.Count) { diagnostic = "ProfileBoundaryChamferDuplicateSegment"; return false; }
+ var indices = segments.Select(id => IndexOf(resolvedLoop, id)).ToArray();
+ if (indices.Any(index => index < 0)) { diagnostic = "ProfileBoundaryChamferSegmentUnknown"; return false; }
+ var ordered = NormalizeConnectedOrder(resolvedLoop, indices, out var closed);
+ if (ordered is null) { diagnostic = "ProfileBoundaryChamferDisconnectedChain"; return false; }
+ if (chainKind == ProfileBoundaryChamferChainKind.ClosedLoop && !closed) { diagnostic = "ProfileBoundaryChamferSelectionMustClose"; return false; }
+ if (chainKind == ProfileBoundaryChamferChainKind.OpenConnectedChain && closed) { diagnostic = "ProfileBoundaryChamferSelectionMustBeOpen"; return false; }
+ if (closed) chainKind = ProfileBoundaryChamferChainKind.ClosedLoop;
+ else if (ordered.Count == 1) chainKind = ProfileBoundaryChamferChainKind.SingleSegment;
+ target = new($"edgefinish:{name}", hostBodyId, profile.Name, loop, ordered.Select(index => resolvedLoop.Segments[index].Name).ToArray(),
+ Enum.Parse<ProfileBoundaryChamferSide>(on.Groups["value"].Value), chainKind, $"offset:{finish.Match.Index}", provenance);
+ return true;
+ }
+
+ private static int IndexOf(ResolvedProfileLoop2D loop, string name) => loop.Segments.Select((segment, index) => (segment, index)).Where(x => x.segment.Name == name).Select(x => x.index).DefaultIfEmpty(-1).Single();
+ private static IReadOnlyList<int>? NormalizeConnectedOrder(ResolvedProfileLoop2D loop, IReadOnlyList<int> indices, out bool closed)
+ {
+ var selected = indices.ToHashSet(); var count = loop.Segments.Count; closed = selected.Count == count;
+ if (closed) return Enumerable.Range(0, count).ToArray();
+ var starts = selected.Where(index => !selected.Contains((index + count - 1) % count)).ToArray();
+ if (starts.Length != 1) return null;
+ var result = new List<int>(); var current = starts[0];
+ while (selected.Contains(current)) { result.Add(current); current = (current + 1) % count; }
+ return result.Count == selected.Count ? result : null;
+ }
+ private static string? Block(string text, int open)
+ {
+ var depth = 0;
+ for (var i = open; i < text.Length; i++) { if (text[i] == '{') depth++; else if (text[i] == '}' && --depth == 0) return text[(open + 1)..i]; }
+ return null;
+ }
+}
+
+/// <summary>Exact polyhedral section transition for an outer, line-only Profile boundary.</summary>
+public static class ProfileBoundaryChamferPlanner
+{
+ private const double Tol = 1e-8;
+ public static ProfileBoundaryChamferPlanResult TryPlan(ResolvedProfile2D profile, ProfileBoundaryChamferTarget target, double distance)
+ {
+ ProfileBoundaryChamferPlanResult Fail(string code) => new(false, null, null, target, [code]);
+ var loop = profile.Loops.SingleOrDefault(x => x.Name == target.LoopId);
+ if (loop is null) return Fail("ProfileBoundaryChamferLoopUnknown");
+ if (!loop.IsOuter) return Fail("ProfileBoundaryChamferInnerLoopUnsupported");
+ if (profile.Loops.Count != 1) return Fail("ProfileBoundaryChamferInnerLoopUnsupported");
+ if (loop.Segments.Any(x => x.Geometry is not LineArcLineSegment2D)) return Fail("ProfileBoundaryChamferSegmentKindUnsupported");
+ var lines = loop.Segments.Select(x => (LineArcLineSegment2D)x.Geometry).ToArray();
+ var selected = target.SegmentIds.Select(id => Array.FindIndex(loop.Segments.ToArray(), x => x.Name == id)).ToHashSet();
+ if (selected.Count != target.SegmentIds.Count || selected.Any(x => x < 0)) return Fail("ProfileBoundaryChamferSegmentUnknown");
+ var start = profile.LocalStartDepth ?? -1d; var end = profile.LocalEndDepth ?? 1d;
+ var thickness = end - start;
+ if (distance >= thickness - Tol) return Fail("ProfileBoundaryChamferDistanceExceedsHostThickness");
+ var area = SignedArea(lines.Select(x => x.Start).ToArray());
+ if (Math.Abs(area) <= Tol) return Fail("ProfileBoundaryChamferInsetCollapse");
+ var junctions = ProfileJunctionClassifier.Classify(profile, loop);
+ if (junctions.Any(x => (x.Classification is ProfileJunctionKind.Collinear or ProfileJunctionKind.Degenerate) &&
+ (selected.Contains(IndexOf(loop, x.PredecessorSegmentId)) || selected.Contains(IndexOf(loop, x.SuccessorSegmentId)))))
+ return Fail("ProfileBoundaryChamferJunctionDegenerate");
+ var inset = BuildInset(lines, selected, area, distance, out var insetDiagnostic);
+ if (inset is null) return Fail(insetDiagnostic!);
+ return BuildBody(profile, target, lines, selected, inset, start, end, distance);
+ }
+
+ /// <summary>Creates the upper, source-derived section used by a composed variable interval.</summary>
+ public static bool TryCreateInsetOuterProfile(ResolvedProfile2D profile, ProfileBoundaryChamferTarget target, double distance, out ResolvedProfile2D? insetProfile, out string? diagnostic)
+ {
+ insetProfile = null; diagnostic = null;
+ var loop = profile.Loops.SingleOrDefault(x => x.Name == target.LoopId);
+ if (loop is null || !loop.IsOuter || loop.Segments.Any(x => x.Geometry is not LineArcLineSegment2D)) { diagnostic = "ProfileBoundaryChamferSegmentKindUnsupported"; return false; }
+ var lines = loop.Segments.Select(x => (LineArcLineSegment2D)x.Geometry).ToArray(); var selected = target.SegmentIds.Select(id => Array.FindIndex(loop.Segments.ToArray(), x => x.Name == id)).ToHashSet();
+ if (selected.Count != lines.Length || selected.Any(x => x < 0)) { diagnostic = "ProfileBoundaryChamferComposeWholeLoopRequired"; return false; }
+ var junctions = ProfileJunctionClassifier.Classify(profile, loop);
+ if (junctions.Any(x => x.Classification is ProfileJunctionKind.Collinear or ProfileJunctionKind.Degenerate)) { diagnostic = "ProfileBoundaryChamferJunctionDegenerate"; return false; }
+ var inset = BuildInset(lines, selected, SignedArea(lines.Select(x => x.Start).ToArray()), distance, out diagnostic);
+ if (inset is null) return false;
+ var segments = lines.Select((_, i) => new ResolvedProfileSegment2D(loop.Segments[i].Name, new LineArcLineSegment2D(inset[i], inset[(i + 1) % inset.Length]), loop.Segments[i].Provenance with { StableId = loop.Segments[i].Provenance.StableId + ":inset", Derivation = "ProfileBoundaryChamferInset" })).ToArray();
+ insetProfile = new ResolvedProfile2D(profile.Name + ":inset", profile.PlaneFrame, [new ResolvedProfileLoop2D(loop.Name, true, segments)], profile.ConstructionPlane, profile.LocalStartDepth, profile.LocalEndDepth);
+ return true;
+ }
+
+ private static (double X, double Y)[]? BuildInset(IReadOnlyList<LineArcLineSegment2D> lines, HashSet<int> selected, double signedArea, double distance, out string? diagnostic)
+ {
+ diagnostic = null; var count = lines.Count; var result = new (double X, double Y)[count];
+ for (var vertex = 0; vertex < count; vertex++)
+ {
+ var previous = (vertex + count - 1) % count; var next = vertex;
+ var previousSelected = selected.Contains(previous); var nextSelected = selected.Contains(next);
+ var original = lines[next].Start;
+ if (!previousSelected && !nextSelected) { result[vertex] = original; continue; }
+ if (previousSelected && nextSelected)
+ {
+ if (!TryOffsetIntersection(lines[previous], lines[next], signedArea, distance, out result[vertex])) { diagnostic = "ProfileBoundaryChamferJunctionUnsupported"; return null; }
+ }
+ else
+ {
+ var line = previousSelected ? lines[previous] : lines[next];
+ var (nx, ny) = InwardNormal(line, signedArea);
+ result[vertex] = (original.X + nx * distance, original.Y + ny * distance);
+ }
+ }
+ for (var i = 0; i < count; i++)
+ {
+ var line = lines[i]; var a = selected.Contains(i) ? result[i] : line.Start; var b = selected.Contains(i) ? result[(i + 1) % count] : line.End;
+ if (Distance(a, b) <= Tol) { diagnostic = "ProfileBoundaryChamferInsetCollapse"; return null; }
+ }
+ if (HasSelfIntersection(result)) { diagnostic = "ProfileBoundaryChamferOffsetSelfIntersection"; return null; }
+ return result;
+ }
+
+ private static bool HasSelfIntersection(IReadOnlyList<(double X, double Y)> polygon)
+ {
+ for (var i = 0; i < polygon.Count; i++)
+ for (var j = i + 1; j < polygon.Count; j++)
+ {
+ if (j == i || (j + 1) % polygon.Count == i || (i + 1) % polygon.Count == j) continue;
+ if (ProperIntersection(polygon[i], polygon[(i + 1) % polygon.Count], polygon[j], polygon[(j + 1) % polygon.Count])) return true;
+ }
+ return false;
+ }
+
+ private static bool ProperIntersection((double X, double Y) a, (double X, double Y) b, (double X, double Y) c, (double X, double Y) d)
+ {
+ var abC = Orientation(a, b, c); var abD = Orientation(a, b, d); var cdA = Orientation(c, d, a); var cdB = Orientation(c, d, b);
+ return abC * abD < -Tol && cdA * cdB < -Tol;
+ }
+ private static double Orientation((double X, double Y) a, (double X, double Y) b, (double X, double Y) c) =>
+ (b.X - a.X) * (c.Y - a.Y) - (b.Y - a.Y) * (c.X - a.X);
+
+ private static bool TryOffsetIntersection(LineArcLineSegment2D first, LineArcLineSegment2D second, double area, double distance, out (double X, double Y) point)
+ {
+ var (n1x, n1y) = InwardNormal(first, area); var (n2x, n2y) = InwardNormal(second, area);
+ var a = (X: first.Start.X + n1x * distance, Y: first.Start.Y + n1y * distance);
+ var b = (X: second.Start.X + n2x * distance, Y: second.Start.Y + n2y * distance);
+ var r = (X: first.End.X - first.Start.X, Y: first.End.Y - first.Start.Y); var s = (X: second.End.X - second.Start.X, Y: second.End.Y - second.Start.Y);
+ var cross = r.X * s.Y - r.Y * s.X;
+ if (Math.Abs(cross) <= Tol) { point = default; return false; }
+ var q = (X: b.X - a.X, Y: b.Y - a.Y); var t = (q.X * s.Y - q.Y * s.X) / cross;
+ point = (a.X + t * r.X, a.Y + t * r.Y); return double.IsFinite(point.X) && double.IsFinite(point.Y);
+ }
+ private static (double X, double Y) InwardNormal(LineArcLineSegment2D line, double area)
+ {
+ var dx = line.End.X - line.Start.X; var dy = line.End.Y - line.Start.Y; var length = Math.Sqrt(dx * dx + dy * dy);
+ // A CCW outer loop has material on the left; CW has it on the right.
+ return area > 0d ? (-dy / length, dx / length) : (dy / length, -dx / length);
+ }
+
+ private static ProfileBoundaryChamferPlanResult BuildBody(ResolvedProfile2D profile, ProfileBoundaryChamferTarget target, IReadOnlyList<LineArcLineSegment2D> lines, HashSet<int> selected, (double X, double Y)[] inset, double start, double end, double distance)
+ {
+ var builder = new TopologyBuilder(); var geometry = new BrepGeometryStore(); var bindings = new BrepBindingModel(); var points = new Dictionary<VertexId, Point3D>();
+ var resolvedLoop = profile.Loops.Single(x => x.Name == target.LoopId);
+ var frame = profile.EffectiveConstructionPlane; var vertices = new Dictionary<string, VertexId>(StringComparer.Ordinal); var edges = new Dictionary<(VertexId, VertexId), EdgeId>(); var descendants = new List<SemanticTopologyDescendant>();
+ VertexId Vertex(string key, (double X, double Y) xy, double depth)
+ {
+ if (vertices.TryGetValue(key, out var existing)) return existing;
+ var id = builder.AddVertex(); vertices.Add(key, id); points.Add(id, frame.ToWorld(xy, depth)); return id;
+ }
+ EdgeId Edge(VertexId a, VertexId b)
+ {
+ var key = a.Value < b.Value ? (a, b) : (b, a);
+ if (edges.TryGetValue(key, out var existing)) return existing;
+ var id = builder.AddEdge(a, b); edges.Add(key, id);
+ var from = points[a]; var to = points[b]; var length = (to - from).Length;
+ var curve = new CurveGeometryId(geometry.Curves.Count() + 1);
+ geometry.AddCurve(curve, CurveGeometry.FromLine(new Line3Curve(from, Direction3D.Create(to - from))));
+ bindings.AddEdgeBinding(new EdgeGeometryBinding(id, curve, new ParameterInterval(0d, length), true)); return id;
+ }
+ // The topology model requires coedge next/previous ids at construction. Use a local helper
+ // that creates them with known ids before registering the loop.
+ FaceId AddFace(string stableId, IReadOnlyList<VertexId> boundary, SemanticTopologyRole role, string source, string? parent = null)
+ {
+ var loopId = builder.AllocateLoopId(); var coedgeIds = Enumerable.Range(0, boundary.Count).Select(_ => new CoedgeId(builder.Model.Coedges.Count() + 1 + _)).ToArray();
+ for (var i = 0; i < boundary.Count; i++)
+ {
+ var a = boundary[i]; var b = boundary[(i + 1) % boundary.Count]; var edge = Edge(a, b); var modelEdge = builder.Model.Edges.Single(x => x.Id == edge);
+ builder.AddCoedge(new Coedge(coedgeIds[i], edge, loopId, coedgeIds[(i + 1) % boundary.Count], coedgeIds[(i + boundary.Count - 1) % boundary.Count], modelEdge.StartVertexId != a));
+ }
+ builder.AddLoop(new Loop(loopId, coedgeIds));
+ var faceId = builder.AddFace([loopId]);
+ var p0 = points[boundary[0]]; Vector3D? normal = null;
+ for (var i = 1; i < boundary.Count - 1 && normal is null; i++)
+ {
+ var candidate = (points[boundary[i]] - p0).Cross(points[boundary[i + 1]] - p0);
+ if (candidate.Length > Tol) normal = candidate;
+ }
+ if (normal is null) throw new InvalidOperationException($"ProfileBoundaryChamferDegenerateFace:{stableId}");
+ var surface = new SurfaceGeometryId(geometry.Surfaces.Count() + 1);
+ geometry.AddSurface(surface, SurfaceGeometry.FromPlane(new PlaneSurface(p0, Direction3D.Create(normal.Value), Direction3D.Create(points[boundary[1]] - p0))));
+ bindings.AddFaceBinding(new FaceGeometryBinding(faceId, surface, true));
+ descendants.Add(new(stableId, "Face", role, source, Face: faceId, ParentStableId: parent)); return faceId;
+ }
+
+ var n = lines.Count; var lower = new VertexId[n]; var middle = new VertexId[n]; var modified = new VertexId[n]; var originalTop = new VertexId[n]; var upper = new VertexId[n];
+ var transitionStart = target.Side == ProfileBoundaryChamferSide.Top ? end - distance : start;
+ var transitionEnd = target.Side == ProfileBoundaryChamferSide.Top ? end : start + distance;
+ for (var i = 0; i < n; i++)
+ {
+ var p = lines[i].Start;
+ lower[i] = Vertex($"lower:{i}", p, start); middle[i] = Vertex($"middle:{i}", p, transitionStart);
+ originalTop[i] = Vertex($"original-top:{i}", p, transitionEnd); modified[i] = Vertex($"modified:{i}", inset[i], target.Side == ProfileBoundaryChamferSide.Top ? end : start);
+ upper[i] = Vertex($"upper:{i}", p, end);
+ }
+ var topBoundary = new List<VertexId>();
+ for (var i = 0; i < n; i++)
+ {
+ var previousSelected = selected.Contains((i + n - 1) % n); var nextSelected = selected.Contains(i);
+ // An open run terminates at one planar triangular patch on either side.
+ // The cap therefore meets the inset endpoint directly; retaining both
+ // the original and inset vertex would create a zero-area cap spur.
+ topBoundary.Add(previousSelected || nextSelected
+ ? modified[i]
+ : target.Side == ProfileBoundaryChamferSide.Top ? originalTop[i] : lower[i]);
+ }
+ if (target.Side == ProfileBoundaryChamferSide.Top)
+ {
+ AddFace("profile-boundary-chamfer:bottom-cap", lower.Reverse().ToArray(), SemanticTopologyRole.BottomFaceBoundaryLoop, $"profile:{profile.Name}.{target.LoopId}");
+ foreach (var i in Enumerable.Range(0, n)) AddFace($"profile-boundary-chamfer:lower-side:{i}", [middle[(i + 1) % n], middle[i], lower[i], lower[(i + 1) % n]], SemanticTopologyRole.ExtrusionSideFace, loopSource(profile, target, i));
+ AddTransition(middle, originalTop, modified, topBoundary, true);
+ AddFace("profile-boundary-chamfer:top-cap", topBoundary, SemanticTopologyRole.TopFaceBoundaryLoop, $"profile:{profile.Name}.{target.LoopId}");
+ }
+ else
+ {
+ AddFace("profile-boundary-chamfer:bottom-cap", topBoundary.Reverse<VertexId>().ToArray(), SemanticTopologyRole.BottomFaceBoundaryLoop, $"profile:{profile.Name}.{target.LoopId}");
+ AddTransition(lower, originalTop, modified, topBoundary, false);
+ foreach (var i in Enumerable.Range(0, n)) AddFace($"profile-boundary-chamfer:upper-side:{i}", [originalTop[i], originalTop[(i + 1) % n], upper[(i + 1) % n], upper[i]], SemanticTopologyRole.ExtrusionSideFace, loopSource(profile, target, i));
+ AddFace("profile-boundary-chamfer:top-cap", upper, SemanticTopologyRole.TopFaceBoundaryLoop, $"profile:{profile.Name}.{target.LoopId}");
+ }
+ if (builder.AddShell(builder.Model.Faces.Select(x => x.Id).ToArray()).Value != 1 || builder.AddBody([new ShellId(1)]).Value != 1) return new(false, null, null, target, ["ProfileBoundaryChamferTopologyPlanInvalid"]);
+ var body = new BrepBody(builder.Model, geometry, bindings, points);
+ foreach (var junction in ProfileJunctionClassifier.Classify(profile, resolvedLoop).Where(junction =>
+ selected.Contains(IndexOf(resolvedLoop, junction.PredecessorSegmentId)) &&
+ selected.Contains(IndexOf(resolvedLoop, junction.SuccessorSegmentId))))
+ {
+ descendants.Add(new($"{target.StableId}:{junction.Classification}({junction.VertexId})", "Junction", SemanticTopologyRole.EdgeFinishReplacementFace,
+ $"profile:{profile.Name}.{target.LoopId}:{junction.PredecessorSegmentId}->{junction.SuccessorSegmentId}", ParentStableId: target.StableId));
+ }
+ var correspondence = new SemanticTopologyCorrespondence(target.HostBodyId, descendants, ["ResolvedProfile2D", "ProfileJunctionClassification", "ProfileBoundaryChamferTarget", "ProfileBoundaryChamferSectionStackPlan", "AuthoritativeBRepPlan"]);
+ return new(true, body, correspondence, target, ["ProfileBoundaryChamferSectionStackPlan", "ProfileBoundaryChamferExactPlanarFaces"]);
+
+ void AddTransition(VertexId[] originalAtStart, VertexId[] originalAtEnd, VertexId[] insetAtModified, IReadOnlyList<VertexId> cap, bool isTop)
+ {
+ for (var i = 0; i < n; i++)
+ {
+ var next = (i + 1) % n;
+ if (selected.Contains(i))
+ {
+ var face = isTop
+ ? new[] { originalAtStart[i], originalAtStart[next], insetAtModified[next], insetAtModified[i] }
+ : new[] { originalAtEnd[next], originalAtEnd[i], insetAtModified[i], insetAtModified[next] };
+ AddFace($"{target.StableId}:ChamferFace({resolvedLoop.Segments[i].Name})", face, SemanticTopologyRole.EdgeFinishReplacementFace, loopSource(profile, target, i), target.StableId);
+ var insetEdge = Edge(insetAtModified[i], insetAtModified[next]);
+ descendants.Add(new($"{target.StableId}:InsetEdge({resolvedLoop.Segments[i].Name})", "Edge", SemanticTopologyRole.TopBoundary, loopSource(profile, target, i), Edge: insetEdge, ParentStableId: target.StableId));
+ }
+ else
+ {
+ var prevSelected = selected.Contains((i + n - 1) % n);
+ var startBoundary = prevSelected ? insetAtModified[i] : originalAtEnd[i];
+ var endBoundary = selected.Contains(next) ? insetAtModified[next] : originalAtEnd[next];
+ if (isTop)
+ {
+ AddFace($"profile-boundary-chamfer:transition-side:{i}:a", [endBoundary, startBoundary, originalAtStart[i]], SemanticTopologyRole.ExtrusionSideFace, loopSource(profile, target, i));
+ AddFace($"profile-boundary-chamfer:transition-side:{i}:b", [endBoundary, originalAtStart[i], originalAtStart[next]], SemanticTopologyRole.ExtrusionSideFace, loopSource(profile, target, i));
+ }
+ else
+ {
+ if (prevSelected || selected.Contains(next))
+ {
+ // At a Bottom-chain termination the changed cap endpoint lies on
+ // the cap plane. Splitting through the original lower endpoint
+ // would create a collinear triangle (the old failure mode).
+ AddFace($"profile-boundary-chamfer:transition-side:{i}", [originalAtEnd[i], cap[i], cap[next], originalAtEnd[next]], SemanticTopologyRole.ExtrusionSideFace, loopSource(profile, target, i));
+ }
+ else
+ {
+ AddFace($"profile-boundary-chamfer:transition-side:{i}:a", [originalAtEnd[next], originalAtEnd[i], originalAtStart[i]], SemanticTopologyRole.ExtrusionSideFace, loopSource(profile, target, i));
+ AddFace($"profile-boundary-chamfer:transition-side:{i}:b", [originalAtEnd[next], originalAtStart[i], originalAtStart[next]], SemanticTopologyRole.ExtrusionSideFace, loopSource(profile, target, i));
+ }
+ }
+ }
+ }
+ }
+ static string loopSource(ResolvedProfile2D p, ProfileBoundaryChamferTarget t, int i) => $"profile:{p.Name}.{t.LoopId}.{p.Loops.Single(x => x.Name == t.LoopId).Segments[i].Name}";
+ }
+
+ private static double SignedArea(IReadOnlyList<(double X, double Y)> points) => points.Select((p, i) => p.X * points[(i + 1) % points.Count].Y - points[(i + 1) % points.Count].X * p.Y).Sum() * .5d;
+ private static double Distance((double X, double Y) a, (double X, double Y) b) => Math.Sqrt((a.X - b.X) * (a.X - b.X) + (a.Y - b.Y) * (a.Y - b.Y));
+ private static int IndexOf(ResolvedProfileLoop2D loop, string segmentId) => loop.Segments.Select((segment, index) => (segment, index)).Single(x => x.segment.Name == segmentId).index;
+}
diff --git a/Aetheris.Kernel.Firmament/Materializer/ProfileJunctionClassification.cs b/Aetheris.Kernel.Firmament/Materializer/ProfileJunctionClassification.cs
new file mode 100644
index 00000000..1016298f
--- /dev/null
+++ b/Aetheris.Kernel.Firmament/Materializer/ProfileJunctionClassification.cs
@@ -0,0 +1,123 @@
+using Aetheris.Kernel.Core.Geometry.Curves;
+
+namespace Aetheris.Kernel.Firmament.Materializer;
+
+/// <summary>Material-side classification of a vertex in an authored Profile loop.</summary>
+public enum ProfileJunctionKind
+{
+ Collinear,
+ ConvexProfileJunction,
+ ReflexProfileJunction,
+ Degenerate
+}
+
+public sealed record ProfileJunctionClassification(
+ string ProfileId,
+ string LoopId,
+ string PredecessorSegmentId,
+ string SuccessorSegmentId,
+ string VertexId,
+ double SignedTurnRadians,
+ double MaterialInteriorAngleRadians,
+ ProfileJunctionKind Classification);
+
+/// <summary>
+/// Computes junction polarity from directed resolved-Profile semantics. The material is
+/// on the left of an outer CCW loop and on the right of an inner CCW loop; winding reverses
+/// both relationships. No world-axis or post-BRep face orientation is consulted.
+/// </summary>
+public static class ProfileJunctionClassifier
+{
+ private const double Tolerance = 1e-8;
+
+ public static IReadOnlyList<ProfileJunctionClassification> Classify(ResolvedProfile2D profile) =>
+ profile.Loops.SelectMany(loop => Classify(profile, loop)).ToArray();
+
+ public static IReadOnlyList<ProfileJunctionClassification> Classify(ResolvedProfile2D profile, ResolvedProfileLoop2D loop)
+ {
+ if (loop.Segments.Count < 2)
+ return [];
+
+ var winding = SignedArea(loop);
+ if (Math.Abs(winding) <= Tolerance)
+ return loop.Segments.Select((successor, index) => new ProfileJunctionClassification(
+ profile.Name, loop.Name, loop.Segments[(index + loop.Segments.Count - 1) % loop.Segments.Count].Name,
+ successor.Name, $"{loop.Name}.{successor.Name}.Start", 0d, double.NaN, ProfileJunctionKind.Degenerate)).ToArray();
+
+ var windingSign = Math.Sign(winding);
+ var materialSideSign = loop.IsOuter ? windingSign : -windingSign;
+ var classifications = new List<ProfileJunctionClassification>(loop.Segments.Count);
+ for (var successorIndex = 0; successorIndex < loop.Segments.Count; successorIndex++)
+ {
+ var predecessor = loop.Segments[(successorIndex + loop.Segments.Count - 1) % loop.Segments.Count];
+ var successor = loop.Segments[successorIndex];
+ if (!TryEndTangent(predecessor.Geometry, out var incoming) || !TryStartTangent(successor.Geometry, out var outgoing))
+ {
+ classifications.Add(new(profile.Name, loop.Name, predecessor.Name, successor.Name, $"{loop.Name}.{successor.Name}.Start", 0d, double.NaN, ProfileJunctionKind.Degenerate));
+ continue;
+ }
+
+ var cross = incoming.X * outgoing.Y - incoming.Y * outgoing.X;
+ var dot = Math.Clamp(incoming.X * outgoing.X + incoming.Y * outgoing.Y, -1d, 1d);
+ var turn = Math.Atan2(cross, dot);
+ var materialInterior = Math.PI - materialSideSign * turn;
+ if (materialInterior <= 0d) materialInterior += 2d * Math.PI;
+ if (materialInterior > 2d * Math.PI) materialInterior -= 2d * Math.PI;
+ var classification = Math.Abs(turn) <= Tolerance
+ ? ProfileJunctionKind.Collinear
+ : Math.Abs(Math.Abs(turn) - Math.PI) <= Tolerance
+ ? ProfileJunctionKind.Degenerate
+ : turn * materialSideSign > 0d
+ ? ProfileJunctionKind.ConvexProfileJunction
+ : ProfileJunctionKind.ReflexProfileJunction;
+ classifications.Add(new(profile.Name, loop.Name, predecessor.Name, successor.Name, $"{loop.Name}.{successor.Name}.Start", turn, materialInterior, classification));
+ }
+ return classifications;
+ }
+
+ private static double SignedArea(ResolvedProfileLoop2D loop)
+ {
+ var points = loop.Segments.Select(segment => Start(segment.Geometry)).ToArray();
+ return points.Any(point => point is null)
+ ? 0d
+ : points.Select((point, index) => point!.Value.X * points[(index + 1) % points.Length]!.Value.Y - points[(index + 1) % points.Length]!.Value.X * point.Value.Y).Sum() / 2d;
+ }
+
+ private static bool TryStartTangent(LineArcProfileCurve2D geometry, out (double X, double Y) tangent) =>
+ TryTangent(geometry, false, out tangent);
+
+ private static bool TryEndTangent(LineArcProfileCurve2D geometry, out (double X, double Y) tangent) =>
+ TryTangent(geometry, true, out tangent);
+
+ private static bool TryTangent(LineArcProfileCurve2D geometry, bool atEnd, out (double X, double Y) tangent)
+ {
+ switch (geometry)
+ {
+ case LineArcLineSegment2D line:
+ return Normalize(line.End.X - line.Start.X, line.End.Y - line.Start.Y, out tangent);
+ case LineArcCircularArc2D arc:
+ var angle = arc.StartAngleRadians + (atEnd ? arc.SweepAngleRadians : 0d);
+ var sign = Math.Sign(arc.SweepAngleRadians);
+ if (sign == 0d) { tangent = default; return false; }
+ return Normalize(-Math.Sin(angle) * sign, Math.Cos(angle) * sign, out tangent);
+ default:
+ tangent = default;
+ return false;
+ }
+ }
+
+ private static (double X, double Y)? Start(LineArcProfileCurve2D geometry) => geometry switch
+ {
+ LineArcLineSegment2D line => line.Start,
+ LineArcCircularArc2D arc => (arc.Center.X + arc.Radius * Math.Cos(arc.StartAngleRadians), arc.Center.Y + arc.Radius * Math.Sin(arc.StartAngleRadians)),
+ _ => null
+ };
+
+ private static bool Normalize(double x, double y, out (double X, double Y) tangent)
+ {
+ var length = Math.Sqrt(x * x + y * y);
+ if (!double.IsFinite(length) || length <= Tolerance) { tangent = default; return false; }
+ tangent = (x / length, y / length);
+ return true;
+ }
+}
diff --git a/Aetheris.Kernel.Firmament/Materializer/VariableOuterSectionInterval.cs b/Aetheris.Kernel.Firmament/Materializer/VariableOuterSectionInterval.cs
new file mode 100644
index 00000000..0e5c1973
--- /dev/null
+++ b/Aetheris.Kernel.Firmament/Materializer/VariableOuterSectionInterval.cs
@@ -0,0 +1,65 @@
+using Aetheris.Kernel.Core.Geometry.Curves;
+
+namespace Aetheris.Kernel.Firmament.Materializer;
+
+/// <summary>
+/// A narrow, plan-time section transition: only the outer line loop may change.
+/// Inner loops are carried by stable feature identity and must be identical in local
+/// Profile coordinates. This is intentionally distinct from <see cref="PrismaticSectionSlab"/>.
+/// </summary>
+public sealed record VariableOuterVertexCorrespondence(string LowerSegmentStableId, string UpperSegmentStableId, int LowerVertexIndex, int UpperVertexIndex);
+public sealed record VariableOuterSegmentCorrespondence(string LowerSegmentStableId, string UpperSegmentStableId, int LowerSegmentIndex, int UpperSegmentIndex);
+public sealed record UnchangedInnerLoopCorrespondence(string StableId, string FeatureId, ResolvedProfile2D LowerLoop, ResolvedProfile2D UpperLoop);
+public sealed record VariableOuterSectionInterval(
+ string StableId, double LowerStation, double UpperStation,
+ ResolvedProfile2D LowerOuter, ResolvedProfile2D UpperOuter,
+ IReadOnlyList<VariableOuterVertexCorrespondence> OuterVertices,
+ IReadOnlyList<VariableOuterSegmentCorrespondence> OuterSegments,
+ IReadOnlyList<UnchangedInnerLoopCorrespondence> InnerLoops,
+ string SemanticOwner, IReadOnlyList<string> Provenance);
+public sealed record VariableOuterSectionIntervalValidation(bool IsValid, IReadOnlyList<string> Diagnostics);
+
+public static class VariableOuterSectionIntervalValidator
+{
+ private const double Tol = 1e-8;
+
+ public static VariableOuterSectionIntervalValidation Validate(VariableOuterSectionInterval interval)
+ {
+ var diagnostics = new List<string>();
+ if (!double.IsFinite(interval.LowerStation) || !double.IsFinite(interval.UpperStation) || interval.UpperStation - interval.LowerStation <= Tol)
+ diagnostics.Add("VariableOuterSectionIntervalStationInvalid");
+ var lower = interval.LowerOuter.Loops.SingleOrDefault(x => x.IsOuter);
+ var upper = interval.UpperOuter.Loops.SingleOrDefault(x => x.IsOuter);
+ if (lower is null || upper is null) diagnostics.Add("VariableOuterSectionIntervalOuterLoopMissing");
+ else
+ {
+ if (lower.Segments.Count != upper.Segments.Count) diagnostics.Add("VariableOuterSectionIntervalOuterVertexCountMismatch");
+ if (lower.Segments.Any(x => x.Geometry is not LineArcLineSegment2D) || upper.Segments.Any(x => x.Geometry is not LineArcLineSegment2D)) diagnostics.Add("VariableOuterSectionIntervalOuterSegmentKindUnsupported");
+ var expected = lower.Segments.Count;
+ if (interval.OuterVertices.Count != expected || interval.OuterSegments.Count != expected) diagnostics.Add("VariableOuterSectionIntervalCorrespondenceMissing");
+ if (interval.OuterVertices.Select(x => x.LowerVertexIndex).Distinct().Count() != interval.OuterVertices.Count || interval.OuterVertices.Select(x => x.UpperVertexIndex).Distinct().Count() != interval.OuterVertices.Count || interval.OuterSegments.Select(x => x.LowerSegmentIndex).Distinct().Count() != interval.OuterSegments.Count || interval.OuterSegments.Select(x => x.UpperSegmentIndex).Distinct().Count() != interval.OuterSegments.Count) diagnostics.Add("VariableOuterSectionIntervalCorrespondenceDuplicate");
+ foreach (var pair in interval.OuterSegments)
+ if (pair.LowerSegmentIndex < 0 || pair.LowerSegmentIndex >= expected || pair.UpperSegmentIndex < 0 || pair.UpperSegmentIndex >= expected || lower.Segments[pair.LowerSegmentIndex].Provenance.StableId != pair.LowerSegmentStableId || upper.Segments[pair.UpperSegmentIndex].Provenance.StableId != pair.UpperSegmentStableId)
+ diagnostics.Add("VariableOuterSectionIntervalCorrespondenceInvalid");
+ }
+ if (interval.InnerLoops.Select(x => x.FeatureId).Distinct(StringComparer.Ordinal).Count() != interval.InnerLoops.Count) diagnostics.Add("VariableOuterSectionIntervalInnerLoopDuplicate");
+ foreach (var inner in interval.InnerLoops)
+ if (!Equivalent(inner.LowerLoop, inner.UpperLoop)) diagnostics.Add($"VariableOuterSectionIntervalInnerLoopChanged:{inner.FeatureId}");
+ return new(diagnostics.Count == 0, diagnostics.Distinct(StringComparer.Ordinal).ToArray());
+ }
+
+ private static bool Equivalent(ResolvedProfile2D lower, ResolvedProfile2D upper)
+ {
+ if (lower.Loops.Count != 1 || upper.Loops.Count != 1 || lower.Loops[0].Segments.Count != upper.Loops[0].Segments.Count) return false;
+ for (var i = 0; i < lower.Loops[0].Segments.Count; i++)
+ {
+ var a = lower.Loops[0].Segments[i].Geometry; var b = upper.Loops[0].Segments[i].Geometry;
+ if (a.GetType() != b.GetType()) return false;
+ if (a is LineArcLineSegment2D al && b is LineArcLineSegment2D bl && (!Near(al.Start, bl.Start) || !Near(al.End, bl.End))) return false;
+ if (a is LineArcCircularArc2D aa && b is LineArcCircularArc2D ba && (!Near(aa.Center, ba.Center) || Math.Abs(aa.Radius - ba.Radius) > Tol || Math.Abs(aa.StartAngleRadians - ba.StartAngleRadians) > Tol || Math.Abs(aa.SweepAngleRadians - ba.SweepAngleRadians) > Tol)) return false;
+ if (a is LineArcFullCircle2D ac && b is LineArcFullCircle2D bc && (!Near(ac.Center, bc.Center) || Math.Abs(ac.Radius - bc.Radius) > Tol)) return false;
+ }
+ return true;
+ }
+ private static bool Near((double X, double Y) a, (double X, double Y) b) => Math.Abs(a.X - b.X) <= Tol && Math.Abs(a.Y - b.Y) <= Tol;
+}
diff --git a/docs/firmament/composed-profile-chamfer-integration-m2.md b/docs/firmament/composed-profile-chamfer-integration-m2.md
new file mode 100644
index 00000000..98c8fee0
--- /dev/null
+++ b/docs/firmament/composed-profile-chamfer-integration-m2.md
@@ -0,0 +1,9 @@
+# Composed Profile chamfer integration M2
+
+The composed-host route and the bare Profile route diverge at the authoritative plan boundary. `PrismaticSectionStackTopologyPlan` owns stock, through-shaft loops, counterbore mouth/shoulder/shaft intervals, semantic correspondence, and normalized PMI. M1's `ProfileBoundaryChamferPlanner` owns an outer-loop transition but intentionally has no inner-loop/cavity section representation.
+
+M2 adds required pre-materialization admission. A semantic `On: Top` whole-loop target is bound to the Compose stock Profile, and a typed corridor spans `[Top - Distance, Top]`. Shaft circles are compared against the outer boundary by the conservative analytic condition `distance(center, outer boundary) > shaftRadius + chamferDistance`. A counterbore uses its larger entry radius over the entry interval and its shaft radius below the shoulder. Touching is rejected.
+
+This leaves a deliberate boundary: a disjoint composed target reports `ProfileBoundaryChamferComposeTopologyPlanNotMaterialized` rather than modifying the emitted shell. The next implementation must extend the section-stack generator with a `Top - Distance` station, carry active inner loops across that interval, and generate the inset outer cap inside the same `PrismaticSectionStackTopologyPlan`; it must not patch a materialized BRep.
+
+Admission records each cavity feature id, center, radius, interval, and classification. Shaft collisions report `ProfileBoundaryChamferIntersectsShaft`; counterbore entry collisions report `ProfileBoundaryChamferIntersectsCounterbore`.
diff --git a/docs/firmament/profile-boundary-chamfer-m1.md b/docs/firmament/profile-boundary-chamfer-m1.md
new file mode 100644
index 00000000..1c1fb6ad
--- /dev/null
+++ b/docs/firmament/profile-boundary-chamfer-m1.md
@@ -0,0 +1,31 @@
+# Profile-boundary chamfer M1
+
+M1 binds a chamfer to an authored Profile identity, never to a rediscovered BRep edge. The admitted target is a straight-line segment, a connected chain selected from one outer loop, or the complete outer loop of one prismatic Profile extrusion.
+
+```firmament
+Modify Body {
+ EdgeFinish TopPerimeter {
+ Target: Bracket.Outer
+ On: Top
+ Kind: Chamfer
+ Distance: 1mm
+ }
+}
+```
+
+For one segment use `Target: Bracket.Outer.South`. A chain can be named with Selection:
+
+```firmament
+Selection BreakChain { Source: Bracket.Outer.[South, East, North] Require: ConnectedChain }
+Modify Body { EdgeFinish Break { Target: BreakChain On: Top Kind: Chamfer Distance: 1mm } }
+```
+
+`On` is required. `Top` and `Bottom` are evaluated in the Profile extrusion's local construction-plane axis, not global Z. The inset uses exact line support offsets: material side follows resolved loop winding, selected-selected supports intersect exactly, and an open chain is closed by planar triangular termination patches without extending the finish to another source segment.
+
+The current contract is one outer line-only Profile loop, a positive equal distance below the extrusion thickness, and one segment/connected chain/whole loop. Curves, inner loops, disconnected or duplicate chains, and legacy `Face: +Z / Target: Boundary` requests receive typed rejection diagnostics.
+
+Junction polarity is classified from resolved Profile semantics, never BRep edge direction: predecessor/successor tangents give the signed turn; loop winding and outer/inner role determine the material side. A positive material-side turn is a `ConvexProfileJunction`; a negative one is a `ReflexProfileJunction`. Thus an orthogonal outer CCW L notch has a `-90°` signed turn and a `270°` material interior angle. The planar inset construction intersects the two inward line supports at either class; it does not use a distinct rolling-surface patch. `profile-chamfer-reflex-junction-top.firmament`, the Bottom counterpart, and the mixed L-loop fixture make those guarantees explicit.
+
+Compose now admits a Top whole-outer-loop chamfer with disjoint Shaft or Counterbore cavities. Admission conservatively rejects touching/intersecting circular cavity footprints in the transition corridor with `ProfileBoundaryChamferIntersectsShaft` or `ProfileBoundaryChamferIntersectsCounterbore`. Bottom Compose, open-chain Compose, inner-loop chamfers, and non-line source segments remain outside this bounded route.
+
+The authoritative polyhedral section transition preserves EdgeFinish and Profile/loop/segment provenance. For the 20×10×8 rectangle at `d=1`, the whole-loop section proof is `7 * 200 + (200 + 4 * 171 + 144) / 6 = 1571.3333333333333 mm³`; the canonical fixture verifies that value after STEP reimport.
diff --git a/docs/firmament/profile-edgefinish-convex-concave-audit-x1.md b/docs/firmament/profile-edgefinish-convex-concave-audit-x1.md
new file mode 100644
index 00000000..facd3812
--- /dev/null
+++ b/docs/firmament/profile-edgefinish-convex-concave-audit-x1.md
@@ -0,0 +1,120 @@
+# Profile EdgeFinish convex/reflex audit X1
+
+## Result
+
+Profile-boundary chamfers are explicit source-bound constructions for both
+`ConvexProfileJunction` and `ReflexProfileJunction`. Profile-boundary fillets
+do **not** currently exist: canonical `EdgeFinish ... Kind: Fillet Radius: ...`
+is parsed, reaches the resolved-Profile finish binder, and stops at the typed
+`ProfileBoundaryFilletNotMaterialized` boundary. No 2D Profile arc is counted
+as a 3D fillet.
+
+## Junction model
+
+For predecessor tangent `u` and successor tangent `v`, the signed turn is
+`atan2(cross(u,v), dot(u,v))`. Material side is left/right according to loop
+winding, then reversed for an inner loop. The material interior angle is
+`pi - materialSideSign * signedTurn`. Positive material-side turn is convex;
+negative is reflex; zero is collinear; an antiparallel/invalid tangent is
+degenerate. This handles outer and inner loops without any global-axis rule.
+
+`aetheris inspect-profile <fixture> --json` emits Profile/loop IDs,
+predecessor/successor segments, vertex ID, signed turn, material interior angle,
+classification, and EdgeFinish-selection/descendant slots. The L fixture reports
+five convex junctions and one reflex junction; the reflex is `Inner -> Upright`,
+signed turn `-90°`, material interior angle `270°`.
+
+## Chamfer route and evidence
+
+The route is `Concept Path or Segment/Trace -> ResolvedProfile2D ->
+ProfileBoundaryChamferTarget -> ProfileBoundaryChamferPlanner -> authoritative
+planar section-transition BRep -> STEP export/reimport`. It admits one outer
+line loop, a source segment, connected chain, or complete loop. Selected
+selected junctions intersect inward offset supports directly. The same
+section-polygon reconstruction handles convex and reflex vertices; it adds no
+separate junction patch and emits planar `ChamferFace`/`InsetEdge` descendants,
+plus classification descendants for selected junctions.
+
+| Fixture | Result | STEP SHA-256 | Reimport topology / volume |
+| --- | --- | --- | --- |
+| `profile-chamfer-convex-junction-top` | convex chain | `5bafdd7f…33d9d` | enclosed, 12 planar faces, 6370.333333333333 mm³ |
+| `profile-chamfer-reflex-junction-top` | reflex chain | `4fbca459…20fea` | enclosed, 18 planar faces, 5569.666666666666 mm³ |
+| `profile-chamfer-mixed-convex-reflex-loop-top` | whole L loop | `76c8f9e1…f7aaf` | enclosed, 14 planar faces, 5521.333333333333 mm³ |
+| `profile-chamfer-reflex-junction-bottom` | Bottom reflex chain | `e4580c5a…e2a04` | enclosed, 16 planar faces, 5569.666666666666 mm³ |
+| `profile-chamfer-reflex-low-level-segments` | low-level Segment/Trace reflex chain | `4fbca459…20fea` | byte-identical STEP to the Concept Path route |
+
+For the 40×40 L with 30×30 notch, lower area is 700. At `d=1`, whole-loop
+upper inset area is 544 and the midpoint section area is 621. The exact
+piecewise-linear transition volume is `(700 + 4*621 + 544)/6 = 621.333333333333`;
+the unmodified 7 mm prism contributes 4900, giving 5521.333333333333 mm³.
+All generated surfaces in these fixtures are planes (no cylinder, torus, or
+sphere), each result has one enclosed orientation-consistent shell, and the
+fixture tests compare two independently materialized STEP strings.
+
+The Bottom construction initially exposed a collinear chain-termination
+triangle. It now uses the changed Bottom cap endpoint directly, rather than
+splitting through that collinear original endpoint.
+
+## Compose and invalid admission
+
+`profile-compose-reflex-chamfer-with-shaft` and
+`profile-compose-reflex-chamfer-with-counterbore` prove a Top whole-loop
+variable-outer interval carries a disjoint ThroughAll Shaft or Counterbore.
+Counterbore admission uses its entry radius, not merely its shaft radius.
+`profile-compose-reflex-chamfer-shaft-collision` fails before materialization
+with `ProfileBoundaryChamferIntersectsShaft`; its source cavity is contained in
+the stock but its radius-plus-corridor reaches the nearby reflex-side boundary.
+`profile-compose-reflex-chamfer-counterbore-collision` similarly proves the
+larger entry radius is checked and reports
+`ProfileBoundaryChamferIntersectsCounterbore`.
+`profile-chamfer-reflex-inset-collapse` fails with
+`ProfileBoundaryChamferInsetCollapse`. The planner also has typed
+`ProfileBoundaryChamferOffsetSelfIntersection` and
+`ProfileBoundaryChamferJunctionDegenerate` paths.
+
+## Edge-finish inventory and fillet matrix
+
+| Route | Target / support | Generated family | State |
+| --- | --- | --- | --- |
+| Box chamfer | authored primitive boundary/edge | plane | supported |
+| Box/rounded primitive fillet | bounded authored primitive support | cylinder; selected routes also torus/sphere | supported |
+| bounded internal primitive fillet | explicit internal concave vertical edge | cylinder | supported, fixture-backed |
+| RoundedBox top boundary fillet | primitive top perimeter | torus plus retained cylinders | supported |
+| Frustum routes | bounded primitive rim routes | analytic primitive support | supported where admitted |
+| Profile chamfer | source Profile outer line loop/chain, Top/Bottom | planar section transition | supported |
+| Compose Profile chamfer | Top whole outer line loop, disjoint cavities | planar variable-outer transition | supported |
+| Profile fillet segment / convex junction / reflex junction | source Profile boundary | no rolling-surface plan | unsupported: `ProfileBoundaryFilletNotMaterialized` |
+
+Primitive internal/reflex fillet support is not evidence of a Profile fillet:
+the former is a bounded primitive/cell planner and emits cylinders. The missing
+Profile primitive is the first authoritative constant-radius straight
+Profile-boundary rolling-surface plan, including cap/side contact curves and
+semantic descendants. Until that exists, convex/reflex junction patches,
+trim/intersection topology, cavity corridors, and whole-loop fillets must not
+be claimed.
+
+Recommended bounded follow-up: **PROFILE-STRAIGHT-EDGE-FILLET-M1** — one
+source-selected straight outer Profile segment on Top, with a constant-radius
+cylinder, explicit endpoint termination policy, `FilletSurface`,
+`TopContactEdge`, and `SideContactEdge` descendants. Only after that evidence
+should a convex two-line junction be considered; reflex junctions are a later,
+separate milestone.
+
+## Authoring and performance notes
+
+Fresh canonical authoring used the `Selection { Source:
+Profile.Loop.[segments] Require: ConnectedChain }` spelling on the first attempt
+for both convex and reflex chains, and direct `Target: Bracket.Outer` for the
+whole loop. The low-level Segment/Trace fixture was byte-identical after STEP
+export to its Concept Path counterpart. The first Bottom reflex attempt exposed
+the collinear termination defect described above; after the local fix it needed
+no syntax retry. The composed disjoint/colliding Shaft fixtures and the
+unsupported reflex fillet likewise reached their intended result first attempt;
+the fillet diagnostic named the backend boundary rather than implying a 2D arc.
+
+On this development machine, three warm `dotnet run` samples for the mixed L
+fixture averaged 1672.2 ms for `inspect-profile --json` (including process and
+build-host startup), 1819.8 ms for build/export, and 1737.7 ms for verify.
+These are end-to-end CLI timings, not kernel-only microbenchmarks. Repeated
+builds have byte-identical STEP, while classification order follows resolved
+loop segment order and descendant IDs derive from authored IDs.
diff --git a/docs/firmament/v2-canonical-authoring.md b/docs/firmament/v2-canonical-authoring.md
index 9c316ad2..0f36a408 100644
--- a/docs/firmament/v2-canonical-authoring.md
+++ b/docs/firmament/v2-canonical-authoring.md
@@ -182,11 +182,26 @@ guide's original endpoints. Close the loop and use counter-clockwise winding.
The multi-guide L example is
`fixtures/FirmamentV2/Canonical/valid/profile-compose-l-bracket.firmament`.
-It uses two overlapping `Rect2` guides plus a named notch point. The valid
-fixture intentionally has no EdgeFinish: arbitrary Profile/Compose polygon
-boundary chamfer and fillet materialization is not yet admitted. Such a finish
-reports `EdgeFinishProfileComposeBoundaryUnsupported`, rather than a missing
-semantic source; see the paired invalid fixture.
+It uses two overlapping `Rect2` guides plus a named notch point. A bounded,
+source-bound outer-line-loop chamfer is now admitted on `Top` or `Bottom`:
+
+```firmament
+Selection ReflexNotch { Source: Bracket.Outer.[Inner, Upright] Require: ConnectedChain }
+Modify BracketBody {
+ EdgeFinish NotchBreak { Target: ReflexNotch On: Top Kind: Chamfer Distance: 1mm }
+}
+```
+
+The `Inner -> Upright` L-notch junction is a `ReflexProfileJunction` (270°
+material-side interior angle); this is not a 2D arc or a BRep-edge guess.
+`profile-chamfer-convex-junction-top.firmament` shows the corresponding convex
+chain and `profile-chamfer-mixed-convex-reflex-loop-top.firmament` applies the
+same exact planar section transition around the whole outer loop.
+
+`Kind: Fillet` is parsed as an EdgeFinish declaration, but no Profile-boundary
+rolling-surface planner exists. A source-bound Profile fillet is deliberately
+rejected as `ProfileBoundaryFilletNotMaterialized`; a Concept Path `Arc` only
+changes the 2D outline and is not a substitute for that 3D fillet.
## Canonical examples
diff --git a/docs/firmament/v2-concept-path.md b/docs/firmament/v2-concept-path.md
index ab8358dd..c1f63753 100644
--- a/docs/firmament/v2-concept-path.md
+++ b/docs/firmament/v2-concept-path.md
@@ -38,3 +38,5 @@ Profile Plate {
Use explicit `Segment { Trace; From; To }` when selecting part of a guide or when the desired boundary is not simply the complete Path. There is no `MoveTo`, branching, subpath, automatic reversal, `Arc To`, spline, or path-level geometry validation in M1.
Canonical examples are maintained under `fixtures/FirmamentV2/Canonical/valid/concept-path-*.firmament`.
+
+Path steps become stable resolved Profile segment identities. For example, a `South` step in a Path consumed by `Profile Bracket From Outline` can be targeted later as `Bracket.Outer.South` in an M1 Profile-boundary chamfer; this remains source binding, not BRep-edge lookup.
diff --git a/docs/firmament/variable-outer-section-stack-m3.md b/docs/firmament/variable-outer-section-stack-m3.md
new file mode 100644
index 00000000..e328b1ba
--- /dev/null
+++ b/docs/firmament/variable-outer-section-stack-m3.md
@@ -0,0 +1,7 @@
+# Variable outer section stack M3
+
+Constant composed slabs reuse one two-dimensional region at both stations. M3 introduces `VariableOuterSectionInterval` as a separate plan-time type for the narrow case in which the outer line loop changes while every cavity loop is unchanged.
+
+The interval owns lower/upper stations, lower/upper outer Profiles, explicit vertex and segment correspondence, unchanged inner-loop correspondences keyed by feature id, semantic owner, and provenance. Its validator rejects non-increasing stations, missing or duplicate correspondence, outer vertex-count mismatch, non-line outer segments, duplicate cavity identities, and any inner-loop center/radius/curve change.
+
+This type is not yet consumed by `PrismaticSectionStackEmitter`; the emitter still assumes each slab has one constant `PrismaticSectionRegion`. The required next patch is deliberately localized: add a typed interval union to the authoritative section-stack construction and teach the emitter to create outer planar transition faces while reusing each unchanged inner loop's analytic wall and final cap loop. No materialized BRep may be changed afterward.
diff --git a/fixtures/FirmamentV2/Canonical/invalid/profile-chamfer-reflex-inset-collapse.firmament b/fixtures/FirmamentV2/Canonical/invalid/profile-chamfer-reflex-inset-collapse.firmament
new file mode 100644
index 00000000..90a9714c
--- /dev/null
+++ b/fixtures/FirmamentV2/Canonical/invalid/profile-chamfer-reflex-inset-collapse.firmament
@@ -0,0 +1,16 @@
+Model ProfileChamferReflexInsetCollapse {
+ Units: mm
+ Concept Path Outline {
+ Start: Point2(0mm, 0mm)
+ Heading: 0deg
+ Line South { Length: 40mm }
+ Line East { Turn: 90deg; Length: 10mm }
+ Line Inner { Turn: 90deg; Length: 30mm }
+ Line Upright { Turn: -90deg; Length: 30mm }
+ Line North { Turn: 90deg; Length: 10mm }
+ Close West
+ }
+ Profile Bracket From Outline
+ Struct Body { Extrude Bracket { Profile: Bracket; From: 0mm; To: 12mm } }
+ Modify Body { EdgeFinish Collapse { Target: Bracket.Outer On: Top Kind: Chamfer Distance: 5mm } }
+}
diff --git a/fixtures/FirmamentV2/Canonical/invalid/profile-compose-reflex-chamfer-counterbore-collision.firmament b/fixtures/FirmamentV2/Canonical/invalid/profile-compose-reflex-chamfer-counterbore-collision.firmament
new file mode 100644
index 00000000..dc5fc94f
--- /dev/null
+++ b/fixtures/FirmamentV2/Canonical/invalid/profile-compose-reflex-chamfer-counterbore-collision.firmament
@@ -0,0 +1,21 @@
+Model ProfileComposeReflexChamferCounterboreCollision {
+ Units: mm
+ Concept Struct Layout On XY {
+ Rect2 Horizontal { Center: [0mm, -10mm]; Size: [80mm, 20mm] }
+ Rect2 Vertical { Center: [-30mm, 10mm]; Size: [20mm, 60mm] }
+ Point2 Notch { Position: [-20mm, 0mm] }
+ }
+ Profile Bracket Using Layout { Loop Outer {
+ Segment South { Trace: Horizontal.Bottom; From: Horizontal.BottomLeft; To: Horizontal.BottomRight }
+ Segment East { Trace: Horizontal.Right; From: Horizontal.BottomRight; To: Horizontal.TopRight }
+ Segment Inner { Trace: Horizontal.Top; From: Horizontal.TopRight; To: Notch }
+ Segment Upright { Trace: Vertical.Right; From: Notch; To: Vertical.TopRight }
+ Segment North { Trace: Vertical.Top; From: Vertical.TopRight; To: Vertical.TopLeft }
+ Segment West { Trace: Vertical.Left; From: Vertical.TopLeft; To: Horizontal.BottomLeft }
+ } }
+ Struct BracketBody { Compose BracketBody {
+ Base Stock { Profile: Bracket; From: 0mm; To: 12mm; Role: Stock }
+ Hole<Counterbore> CollidingCounterbore { On: +Z; Center: Point2(-17mm, -6.5mm); Diameter: 8mm; CounterboreDiameter: 12mm; CounterboreDepth: 4mm; End: ThroughAll }
+ } }
+ Modify BracketBody { EdgeFinish TopPerimeter { Target: Bracket.Outer On: Top Kind: Chamfer Distance: 1mm } }
+}
diff --git a/fixtures/FirmamentV2/Canonical/invalid/profile-compose-reflex-chamfer-shaft-collision.firmament b/fixtures/FirmamentV2/Canonical/invalid/profile-compose-reflex-chamfer-shaft-collision.firmament
new file mode 100644
index 00000000..adcbf55b
--- /dev/null
+++ b/fixtures/FirmamentV2/Canonical/invalid/profile-compose-reflex-chamfer-shaft-collision.firmament
@@ -0,0 +1,21 @@
+Model ProfileComposeReflexChamferShaftCollision {
+ Units: mm
+ Concept Struct Layout On XY {
+ Rect2 Horizontal { Center: [0mm, -10mm]; Size: [80mm, 20mm] }
+ Rect2 Vertical { Center: [-30mm, 10mm]; Size: [20mm, 60mm] }
+ Point2 Notch { Position: [-20mm, 0mm] }
+ }
+ Profile Bracket Using Layout { Loop Outer {
+ Segment South { Trace: Horizontal.Bottom; From: Horizontal.BottomLeft; To: Horizontal.BottomRight }
+ Segment East { Trace: Horizontal.Right; From: Horizontal.BottomRight; To: Horizontal.TopRight }
+ Segment Inner { Trace: Horizontal.Top; From: Horizontal.TopRight; To: Notch }
+ Segment Upright { Trace: Vertical.Right; From: Notch; To: Vertical.TopRight }
+ Segment North { Trace: Vertical.Top; From: Vertical.TopRight; To: Vertical.TopLeft }
+ Segment West { Trace: Vertical.Left; From: Vertical.TopLeft; To: Horizontal.BottomLeft }
+ } }
+ Struct BracketBody { Compose BracketBody {
+ Base Stock { Profile: Bracket; From: 0mm; To: 12mm; Role: Stock }
+ Hole<Shaft> CollidingShaft { On: +Z; Center: Point2(-17mm, -3.5mm); Diameter: 6mm; End: ThroughAll }
+ } }
+ Modify BracketBody { EdgeFinish TopPerimeter { Target: Bracket.Outer On: Top Kind: Chamfer Distance: 1mm } }
+}
diff --git a/fixtures/FirmamentV2/Canonical/invalid/profile-fillet-reflex-junction-not-materialized.firmament b/fixtures/FirmamentV2/Canonical/invalid/profile-fillet-reflex-junction-not-materialized.firmament
new file mode 100644
index 00000000..4e940da5
--- /dev/null
+++ b/fixtures/FirmamentV2/Canonical/invalid/profile-fillet-reflex-junction-not-materialized.firmament
@@ -0,0 +1,17 @@
+Model ProfileFilletReflexJunctionNotMaterialized {
+ Units: mm
+ Concept Path Outline {
+ Start: Point2(0mm, 0mm)
+ Heading: 0deg
+ Line South { Length: 40mm }
+ Line East { Turn: 90deg; Length: 10mm }
+ Line Inner { Turn: 90deg; Length: 30mm }
+ Line Upright { Turn: -90deg; Length: 30mm }
+ Line North { Turn: 90deg; Length: 10mm }
+ Close West
+ }
+ Profile Bracket From Outline
+ Struct Body { Extrude Bracket { Profile: Bracket; From: 0mm; To: 8mm } }
+ Selection ReflexNotch { Source: Bracket.Outer.[Inner, Upright] Require: ConnectedChain }
+ Modify Body { EdgeFinish ReflexRound { Target: ReflexNotch On: Top Kind: Fillet Radius: 2mm } }
+}
diff --git a/fixtures/FirmamentV2/Canonical/valid/profile-boundary-chamfer-loop-bottom.firmament b/fixtures/FirmamentV2/Canonical/valid/profile-boundary-chamfer-loop-bottom.firmament
new file mode 100644
index 00000000..ac661193
--- /dev/null
+++ b/fixtures/FirmamentV2/Canonical/valid/profile-boundary-chamfer-loop-bottom.firmament
@@ -0,0 +1,12 @@
+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 } }
+Modify Body { EdgeFinish BottomPerimeter { Target: Bracket.Outer On: Bottom Kind: Chamfer Distance: 1mm } }
diff --git a/fixtures/FirmamentV2/Canonical/valid/profile-boundary-chamfer-rectangle-loop-top.firmament b/fixtures/FirmamentV2/Canonical/valid/profile-boundary-chamfer-rectangle-loop-top.firmament
new file mode 100644
index 00000000..d758ed24
--- /dev/null
+++ b/fixtures/FirmamentV2/Canonical/valid/profile-boundary-chamfer-rectangle-loop-top.firmament
@@ -0,0 +1,29 @@
+Concept Struct RectangleLayout On XY {
+ Point2 SouthWest { Position: [-10mm, -5mm] }
+ Point2 SouthEast { Position: [10mm, -5mm] }
+ Point2 NorthEast { Position: [10mm, 5mm] }
+ Point2 NorthWest { Position: [-10mm, 5mm] }
+ Line2 South { From: SouthWest; To: SouthEast }
+ Line2 East { From: SouthEast; To: NorthEast }
+ Line2 North { From: NorthEast; To: NorthWest }
+ Line2 West { From: NorthWest; To: SouthWest }
+}
+
+Profile Bracket Using RectangleLayout {
+ Loop Outer {
+ Segment South { Trace: South; From: SouthWest; To: SouthEast }
+ Segment East { Trace: East; From: SouthEast; To: NorthEast }
+ Segment North { Trace: North; From: NorthEast; To: NorthWest }
+ Segment West { Trace: West; From: NorthWest; To: SouthWest }
+ }
+}
+
+Struct Body { Extrude Bracket { Profile: Bracket; From: 0mm; To: 8mm } }
+Modify Body {
+ EdgeFinish TopPerimeter {
+ Target: Bracket.Outer
+ On: Top
+ Kind: Chamfer
+ Distance: 1mm
+ }
+}
diff --git a/fixtures/FirmamentV2/Canonical/valid/profile-boundary-chamfer-single-segment-top.firmament b/fixtures/FirmamentV2/Canonical/valid/profile-boundary-chamfer-single-segment-top.firmament
new file mode 100644
index 00000000..da28f800
--- /dev/null
+++ b/fixtures/FirmamentV2/Canonical/valid/profile-boundary-chamfer-single-segment-top.firmament
@@ -0,0 +1,12 @@
+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 } }
+Modify Body { EdgeFinish SouthTopBreak { Target: Bracket.Outer.South On: Top Kind: Chamfer Distance: 1mm } }
diff --git a/fixtures/FirmamentV2/Canonical/valid/profile-chamfer-convex-junction-top.firmament b/fixtures/FirmamentV2/Canonical/valid/profile-chamfer-convex-junction-top.firmament
new file mode 100644
index 00000000..acdc480a
--- /dev/null
+++ b/fixtures/FirmamentV2/Canonical/valid/profile-chamfer-convex-junction-top.firmament
@@ -0,0 +1,15 @@
+Model ProfileChamferConvexJunctionTop {
+ Units: mm
+ Concept Path Outline {
+ Start: Point2(0mm, 0mm)
+ Heading: 0deg
+ Line South { Length: 40mm }
+ Line East { Turn: 90deg; Length: 20mm }
+ Line North { Turn: 90deg; Length: 40mm }
+ Close West
+ }
+ Profile Bracket From Outline
+ Struct Body { Extrude Bracket { Profile: Bracket; From: 0mm; To: 8mm } }
+ Selection ConvexCorner { Source: Bracket.Outer.[South, East] Require: ConnectedChain }
+ Modify Body { EdgeFinish ConvexTopBreak { Target: ConvexCorner On: Top Kind: Chamfer Distance: 1mm } }
+}
diff --git a/fixtures/FirmamentV2/Canonical/valid/profile-chamfer-mixed-convex-reflex-loop-top.firmament b/fixtures/FirmamentV2/Canonical/valid/profile-chamfer-mixed-convex-reflex-loop-top.firmament
new file mode 100644
index 00000000..a2d20c17
--- /dev/null
+++ b/fixtures/FirmamentV2/Canonical/valid/profile-chamfer-mixed-convex-reflex-loop-top.firmament
@@ -0,0 +1,16 @@
+Model ProfileChamferMixedConvexReflexLoopTop {
+ Units: mm
+ Concept Path Outline {
+ Start: Point2(0mm, 0mm)
+ Heading: 0deg
+ Line South { Length: 40mm }
+ Line East { Turn: 90deg; Length: 10mm }
+ Line Inner { Turn: 90deg; Length: 30mm }
+ Line Upright { Turn: -90deg; Length: 30mm }
+ Line North { Turn: 90deg; Length: 10mm }
+ Close West
+ }
+ Profile Bracket From Outline
+ Struct Body { Extrude Bracket { Profile: Bracket; From: 0mm; To: 8mm } }
+ Modify Body { EdgeFinish MixedTopBreak { Target: Bracket.Outer On: Top Kind: Chamfer Distance: 1mm } }
+}
diff --git a/fixtures/FirmamentV2/Canonical/valid/profile-chamfer-reflex-junction-bottom.firmament b/fixtures/FirmamentV2/Canonical/valid/profile-chamfer-reflex-junction-bottom.firmament
new file mode 100644
index 00000000..b7b7d8f0
--- /dev/null
+++ b/fixtures/FirmamentV2/Canonical/valid/profile-chamfer-reflex-junction-bottom.firmament
@@ -0,0 +1,17 @@
+Model ProfileChamferReflexJunctionBottom {
+ Units: mm
+ Concept Path Outline {
+ Start: Point2(0mm, 0mm)
+ Heading: 0deg
+ Line South { Length: 40mm }
+ Line East { Turn: 90deg; Length: 10mm }
+ Line Inner { Turn: 90deg; Length: 30mm }
+ Line Upright { Turn: -90deg; Length: 30mm }
+ Line North { Turn: 90deg; Length: 10mm }
+ Close West
+ }
+ Profile Bracket From Outline
+ Struct Body { Extrude Bracket { Profile: Bracket; From: 0mm; To: 8mm } }
+ Selection ReflexNotch { Source: Bracket.Outer.[Inner, Upright] Require: ConnectedChain }
+ Modify Body { EdgeFinish ReflexBottomBreak { Target: ReflexNotch On: Bottom Kind: Chamfer Distance: 1mm } }
+}
diff --git a/fixtures/FirmamentV2/Canonical/valid/profile-chamfer-reflex-junction-top.firmament b/fixtures/FirmamentV2/Canonical/valid/profile-chamfer-reflex-junction-top.firmament
new file mode 100644
index 00000000..db32cdd7
--- /dev/null
+++ b/fixtures/FirmamentV2/Canonical/valid/profile-chamfer-reflex-junction-top.firmament
@@ -0,0 +1,17 @@
+Model ProfileChamferReflexJunctionTop {
+ Units: mm
+ Concept Path Outline {
+ Start: Point2(0mm, 0mm)
+ Heading: 0deg
+ Line South { Length: 40mm }
+ Line East { Turn: 90deg; Length: 10mm }
+ Line Inner { Turn: 90deg; Length: 30mm }
+ Line Upright { Turn: -90deg; Length: 30mm }
+ Line North { Turn: 90deg; Length: 10mm }
+ Close West
+ }
+ Profile Bracket From Outline
+ Struct Body { Extrude Bracket { Profile: Bracket; From: 0mm; To: 8mm } }
+ Selection ReflexNotch { Source: Bracket.Outer.[Inner, Upright] Require: ConnectedChain }
+ Modify Body { EdgeFinish ReflexTopBreak { Target: ReflexNotch On: Top Kind: Chamfer Distance: 1mm } }
+}
diff --git a/fixtures/FirmamentV2/Canonical/valid/profile-chamfer-reflex-low-level-segments.firmament b/fixtures/FirmamentV2/Canonical/valid/profile-chamfer-reflex-low-level-segments.firmament
new file mode 100644
index 00000000..7f4b0257
--- /dev/null
+++ b/fixtures/FirmamentV2/Canonical/valid/profile-chamfer-reflex-low-level-segments.firmament
@@ -0,0 +1,24 @@
+Model ProfileChamferReflexLowLevelSegments {
+ Units: mm
+ Concept Path Outline {
+ Start: Point2(0mm, 0mm)
+ Heading: 0deg
+ Line South { Length: 40mm }
+ Line East { Turn: 90deg; Length: 10mm }
+ Line Inner { Turn: 90deg; Length: 30mm }
+ Line Upright { Turn: -90deg; Length: 30mm }
+ Line North { Turn: 90deg; Length: 10mm }
+ 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 Inner { Trace: Outline.Inner; From: Outline.East.End; To: Outline.Inner.End }
+ Segment Upright { Trace: Outline.Upright; From: Outline.Inner.End; To: Outline.Upright.End }
+ Segment North { Trace: Outline.North; From: Outline.Upright.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 ReflexNotch { Source: Bracket.Outer.[Inner, Upright] Require: ConnectedChain }
+ Modify Body { EdgeFinish ReflexTopBreak { Target: ReflexNotch On: Top Kind: Chamfer Distance: 1mm } }
+}
diff --git a/fixtures/FirmamentV2/Canonical/valid/profile-compose-l-bracket-counterbore-pmi.firmament b/fixtures/FirmamentV2/Canonical/valid/profile-compose-l-bracket-counterbore-pmi.firmament
index 9081ea9d..c4fd858f 100644
--- a/fixtures/FirmamentV2/Canonical/valid/profile-compose-l-bracket-counterbore-pmi.firmament
+++ b/fixtures/FirmamentV2/Canonical/valid/profile-compose-l-bracket-counterbore-pmi.firmament
@@ -45,6 +45,15 @@ Model ProfileComposeLBracketCounterborePmi {
}
}
+ Modify BracketBody {
+ EdgeFinish TopPerimeter {
+ Target: Bracket.Outer
+ On: Top
+ Kind: Chamfer
+ Distance: 1mm
+ }
+ }
+
Pmi {
Datum A { Target: face(+Z) }
HoleDiameter CounterboredMountDiameter {
diff --git a/fixtures/FirmamentV2/Canonical/valid/profile-compose-reflex-chamfer-with-counterbore.firmament b/fixtures/FirmamentV2/Canonical/valid/profile-compose-reflex-chamfer-with-counterbore.firmament
new file mode 100644
index 00000000..54c6eed7
--- /dev/null
+++ b/fixtures/FirmamentV2/Canonical/valid/profile-compose-reflex-chamfer-with-counterbore.firmament
@@ -0,0 +1,21 @@
+Model ProfileComposeReflexChamferWithCounterbore {
+ Units: mm
+ Concept Struct Layout On XY {
+ Rect2 Horizontal { Center: [0mm, -10mm]; Size: [80mm, 20mm] }
+ Rect2 Vertical { Center: [-30mm, 10mm]; Size: [20mm, 60mm] }
+ Point2 Notch { Position: [-20mm, 0mm] }
+ }
+ Profile Bracket Using Layout { Loop Outer {
+ Segment South { Trace: Horizontal.Bottom; From: Horizontal.BottomLeft; To: Horizontal.BottomRight }
+ Segment East { Trace: Horizontal.Right; From: Horizontal.BottomRight; To: Horizontal.TopRight }
+ Segment Inner { Trace: Horizontal.Top; From: Horizontal.TopRight; To: Notch }
+ Segment Upright { Trace: Vertical.Right; From: Notch; To: Vertical.TopRight }
+ Segment North { Trace: Vertical.Top; From: Vertical.TopRight; To: Vertical.TopLeft }
+ Segment West { Trace: Vertical.Left; From: Vertical.TopLeft; To: Horizontal.BottomLeft }
+ } }
+ Struct BracketBody { Compose BracketBody {
+ Base Stock { Profile: Bracket; From: 0mm; To: 12mm; Role: Stock }
+ Hole<Counterbore> NearReflexButDisjoint { On: +Z; Center: Point2(-20mm, -10mm); Diameter: 8mm; CounterboreDiameter: 12mm; CounterboreDepth: 4mm; End: ThroughAll }
+ } }
+ Modify BracketBody { EdgeFinish TopPerimeter { Target: Bracket.Outer On: Top Kind: Chamfer Distance: 1mm } }
+}
diff --git a/fixtures/FirmamentV2/Canonical/valid/profile-compose-reflex-chamfer-with-shaft.firmament b/fixtures/FirmamentV2/Canonical/valid/profile-compose-reflex-chamfer-with-shaft.firmament
new file mode 100644
index 00000000..5141d152
--- /dev/null
+++ b/fixtures/FirmamentV2/Canonical/valid/profile-compose-reflex-chamfer-with-shaft.firmament
@@ -0,0 +1,21 @@
+Model ProfileComposeReflexChamferWithShaft {
+ Units: mm
+ Concept Struct Layout On XY {
+ Rect2 Horizontal { Center: [0mm, -10mm]; Size: [80mm, 20mm] }
+ Rect2 Vertical { Center: [-30mm, 10mm]; Size: [20mm, 60mm] }
+ Point2 Notch { Position: [-20mm, 0mm] }
+ }
+ Profile Bracket Using Layout { Loop Outer {
+ Segment South { Trace: Horizontal.Bottom; From: Horizontal.BottomLeft; To: Horizontal.BottomRight }
+ Segment East { Trace: Horizontal.Right; From: Horizontal.BottomRight; To: Horizontal.TopRight }
+ Segment Inner { Trace: Horizontal.Top; From: Horizontal.TopRight; To: Notch }
+ Segment Upright { Trace: Vertical.Right; From: Notch; To: Vertical.TopRight }
+ Segment North { Trace: Vertical.Top; From: Vertical.TopRight; To: Vertical.TopLeft }
+ Segment West { Trace: Vertical.Left; From: Vertical.TopLeft; To: Horizontal.BottomLeft }
+ } }
+ Struct BracketBody { Compose BracketBody {
+ Base Stock { Profile: Bracket; From: 0mm; To: 12mm; Role: Stock }
+ Hole<Shaft> NearReflexButDisjoint { On: +Z; Center: Point2(-20mm, -5mm); Diameter: 6mm; End: ThroughAll }
+ } }
+ Modify BracketBody { EdgeFinish TopPerimeter { Target: Bracket.Outer On: Top Kind: Chamfer Distance: 1mm } }
+}