Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Fix profile corner finishing and align stock frames

Yuechen Lied217a237f2f
diff --git a/Aetheris.CLI.Tests/LocalizedPlanarSingleEdgeChamferPipelineTests.cs b/Aetheris.CLI.Tests/LocalizedPlanarSingleEdgeChamferPipelineTests.cs
index bfd28a19..8d63153f 100644
--- a/Aetheris.CLI.Tests/LocalizedPlanarSingleEdgeChamferPipelineTests.cs
+++ b/Aetheris.CLI.Tests/LocalizedPlanarSingleEdgeChamferPipelineTests.cs
@@ -52,12 +52,12 @@ public sealed class LocalizedPlanarSingleEdgeChamferPipelineTests
Assert.Equal(7, body.Topology.Faces.Count());
Assert.Equal(7, body.Geometry.Surfaces.Count(s => s.Value.Kind == SurfaceGeometryKind.Plane));
var points = body.Topology.Vertices.Select(v => body.TryGetVertexPoint(v.Id, out var p) ? p : throw new InvalidOperationException()).ToArray();
- Assert.Contains(points, p => Math.Abs(p.X - width / 2d) < 1e-9 && Math.Abs(p.Z - (height / 2d - distance)) < 1e-9);
- Assert.Contains(points, p => Math.Abs(p.X - (width / 2d - distance)) < 1e-9 && Math.Abs(p.Z - height / 2d) < 1e-9);
+ Assert.Contains(points, p => Math.Abs(p.X - width / 2d) < 1e-9 && Math.Abs(p.Z - (height - distance)) < 1e-9);
+ Assert.Contains(points, p => Math.Abs(p.X - (width / 2d - distance)) < 1e-9 && Math.Abs(p.Z - height) < 1e-9);
Assert.Equal(-width / 2d, points.Min(p => p.X), 9);
Assert.Equal(width / 2d, points.Max(p => p.X), 9);
- Assert.Equal(-height / 2d, points.Min(p => p.Z), 9);
- Assert.Equal(height / 2d, points.Max(p => p.Z), 9);
+ Assert.Equal(0, points.Min(p => p.Z), 9);
+ Assert.Equal(height, points.Max(p => p.Z), 9);
}
[Theory]
diff --git a/Aetheris.CLI.Tests/LocalizedTangentBlendFilletPipelineTests.cs b/Aetheris.CLI.Tests/LocalizedTangentBlendFilletPipelineTests.cs
index 1524a8c5..957f64a5 100644
--- a/Aetheris.CLI.Tests/LocalizedTangentBlendFilletPipelineTests.cs
+++ b/Aetheris.CLI.Tests/LocalizedTangentBlendFilletPipelineTests.cs
@@ -57,8 +57,8 @@ public sealed class LocalizedTangentBlendFilletPipelineTests
Assert.Equal(radius, cylinder.Radius, 9);
Assert.Equal(0, cylinder.Axis.X, 9); Assert.Equal(1, cylinder.Axis.Y, 9); Assert.Equal(0, cylinder.Axis.Z, 9);
var points = body.Topology.Vertices.Select(v => body.TryGetVertexPoint(v.Id, out var p) ? p : throw new InvalidOperationException()).ToArray();
- Assert.Contains(points, p => Math.Abs(p.X - width / 2d) < 1e-9 && Math.Abs(p.Z - (height / 2d - radius)) < 1e-9);
- Assert.Contains(points, p => Math.Abs(p.X - (width / 2d - radius)) < 1e-9 && Math.Abs(p.Z - height / 2d) < 1e-9);
+ Assert.Contains(points, p => Math.Abs(p.X - width / 2d) < 1e-9 && Math.Abs(p.Z - (height - radius)) < 1e-9);
+ Assert.Contains(points, p => Math.Abs(p.X - (width / 2d - radius)) < 1e-9 && Math.Abs(p.Z - height) < 1e-9);
// Removed corner area = R² - πR²/4: the square setback less the retained quarter-disc.
var removedArea = radius * radius * (1d - Math.PI / 4d);
diff --git a/Aetheris.Kernel.Firmament.Tests/BracketEdgeFinishRobustnessTests.cs b/Aetheris.Kernel.Firmament.Tests/BracketEdgeFinishRobustnessTests.cs
new file mode 100644
index 00000000..c2c6921f
--- /dev/null
+++ b/Aetheris.Kernel.Firmament.Tests/BracketEdgeFinishRobustnessTests.cs
@@ -0,0 +1,127 @@
+using Aetheris.Kernel.Core.Brep;
+using Aetheris.Kernel.Core.Brep.Verification;
+using Aetheris.Kernel.Core.Step242;
+using Aetheris.Kernel.Firmament.Materializer;
+
+namespace Aetheris.Kernel.Firmament.Tests;
+
+public sealed class BracketEdgeFinishRobustnessTests
+{
+ private static string Bracket => FirmamentCorpusHarness.ReadFixtureText("fixtures/Regression/OrientedComposeHoles/bracket-foot-hole.firmament");
+ private static string Empty => Bracket[..Bracket.IndexOf(" Modify", StringComparison.Ordinal)] + "}";
+ private static string Finish(string name, string corner, string kind, double size) => FormattableString.Invariant(
+ $"EdgeFinish {name} {{ Face: Longitudinal Target: section.Outer.{corner}.Start Kind: {kind} {(kind == "Fillet" ? "Radius" : "Distance")}: {size}mm }}");
+ private static string With(string source, params string[] finishes) => source[..source.LastIndexOf('}')]
+ + " Modify bracket { " + string.Join("\n", finishes) + " } }";
+ private static FirmamentStepExportResult Build(string source)
+ {
+ var result = FirmamentBuildAndExport.CompileSource(source);
+ Assert.True(result.IsSuccess, string.Join(";", result.Diagnostics.Select(d => d.Message)));
+ var imported = Step242Importer.ImportBody(result.Value.StepText);
+ Assert.True(imported.IsSuccess);
+ foreach (var body in new[] { result.Value.RuntimeBody!, imported.Value })
+ {
+ Assert.True(BrepExportPreflight.Validate(body).IsValid);
+ var mass = BrepMassProperties.Evaluate(body);
+ Assert.True(mass.IsEnclosed); Assert.True(mass.IsOrientationConsistent);
+ }
+ return result.Value;
+ }
+
+ [Theory]
+ [InlineData("Fillet")] [InlineData("Chamfer")]
+ public void MountingHoleAndInsideBend_CombineWithoutMovingTheHole(string kind)
+ {
+ var original = Build(Bracket);
+ var finished = Build(With(Bracket, Finish("Bend", "Vertex3_Vertex4", kind, 2)));
+ var cylinder = Assert.Single(original.RuntimeBody!.Geometry.Surfaces, s => s.Value.Cylinder is not null).Value.Cylinder!.Value;
+ var retained = Assert.Single(finished.RuntimeBody!.Geometry.Surfaces, s => s.Value.Cylinder is { } c && Math.Abs(c.Radius - 3) < 1e-8).Value.Cylinder!.Value;
+ Assert.Equal(cylinder.Origin, retained.Origin); Assert.Equal(cylinder.Axis, retained.Axis);
+ Assert.Single(finished.Features!);
+ Assert.Contains(finished.EngineeringFeatures!, f => f.Name == "Bend");
+ Assert.Contains(finished.Features!, f => f.Name == "Hole");
+ var side = Assert.Single(finished.RuntimeCorrespondence!.Descendants, d => d.Role == SemanticTopologyRole.ExtrusionSideFace
+ && d.SourceStableId == "profile:section.Outer.Vertex2_Vertex3");
+ var support = PlanarFaceThroughHole.Support(finished.RuntimeBody, side.Face!.Value, side.SupportOrigin)!;
+ Assert.Equal(3, support.Origin[0], 8); // Trimmed face starts at x=5; authored frame stays x=3.
+ }
+
+ [Theory]
+ [InlineData("Shaft", 3.01, true)]
+ [InlineData("Shaft", 3.005, false)]
+ [InlineData("Shaft", 3, false)]
+ [InlineData("Shaft", 2.5, false)]
+ [InlineData("Counterbore", 5.51, true)]
+ [InlineData("Counterbore", 5.5, false)]
+ [InlineData("Countersink", 5.51, true)]
+ [InlineData("Countersink", 5.5, false)]
+ public void FinishHoleAndRecessEnvelopes_RequirePositiveRemainingMaterial(string variant, double x, bool accepted)
+ {
+ // x is authored in the original foot frame. With a 2 mm bend, its
+ // straight support starts at local x=2; a 2 mm shaft needs center>=3.01.
+ var hole = Bracket.Replace("Point2(13mm, 10mm)", FormattableString.Invariant($"Point2({x}mm, 10mm)"), StringComparison.Ordinal)
+ .Replace("Diameter: 6mm", "Diameter: 2mm", StringComparison.Ordinal)
+ .Replace("Hole<Shaft>", "Hole<" + variant + ">", StringComparison.Ordinal);
+ if (variant == "Counterbore") hole = hole.Replace("End: ThroughAll", "CounterboreDiameter: 7mm CounterboreDepth: 1mm End: ThroughAll", StringComparison.Ordinal);
+ if (variant == "Countersink") hole = hole.Replace("End: ThroughAll", "CountersinkDiameter: 7mm CountersinkAngle: 120deg End: ThroughAll", StringComparison.Ordinal);
+ var source = With(hole, Finish("Bend", "Vertex3_Vertex4", "Fillet", 2));
+ if (accepted) Build(source);
+ else
+ {
+ var result = FirmamentBuildAndExport.CompileSource(source);
+ Assert.False(result.IsSuccess); Assert.Contains(result.Diagnostics, d => d.Message.Contains("clearance", StringComparison.Ordinal));
+ }
+ }
+
+ [Theory]
+ [InlineData("Fillet", "Fillet")] [InlineData("Fillet", "Chamfer")]
+ [InlineData("Chamfer", "Fillet")] [InlineData("Chamfer", "Chamfer")]
+ public void InsideBendAndTwoOutsideBreaks_CombineWithTheMountingHole(string inside, string outside)
+ {
+ var result = Build(With(Bracket, Finish("Bend", "Vertex3_Vertex4", inside, 2),
+ Finish("FootTop", "Vertex2_Vertex3", outside, .5), Finish("FootBottom", "Vertex1_Vertex2", outside, .5)));
+ Assert.Equal(3, result.EngineeringFeatures!.Count);
+ Assert.Equal(3, result.MaterializedFeatures!.Count(f => f.Kind == "EdgeFinish"));
+ }
+
+ [Theory]
+ [InlineData(1.494, true)] [InlineData(1.5, false)] [InlineData(1.6, false)]
+ public void AdjacentCornerFinishes_CannotConsumeTheirSharedThreeMillimetreLeg(double size, bool accepted)
+ {
+ var source = With(Empty, Finish("Top", "Vertex2_Vertex3", "Fillet", size), Finish("Bottom", "Vertex1_Vertex2", "Fillet", size));
+ if (accepted) Build(source);
+ else Assert.False(FirmamentBuildAndExport.CompileSource(source).IsSuccess);
+ }
+
+ [Theory]
+ [InlineData(0)] [InlineData(.005)] [InlineData(-1)]
+ public void ZeroAndMicroscopicFinishesAreRefused(double size)
+ => Assert.False(FirmamentBuildAndExport.CompileSource(With(Empty, Finish("Tiny", "Vertex2_Vertex3", "Fillet", size))).IsSuccess);
+
+ [Fact]
+ public void FinishingTheSameOriginalCornerTwiceIsRefused()
+ => Assert.False(FirmamentBuildAndExport.CompileSource(With(Empty,
+ Finish("First", "Vertex3_Vertex4", "Fillet", 2), Finish("Second", "Vertex3_Vertex4", "Chamfer", 1))).IsSuccess);
+
+ [Fact]
+ public void FixtureCombinesBothLegsMountingRecessesAndThreeCornerFinishes()
+ {
+ var result = Build(FirmamentCorpusHarness.ReadFixtureText("fixtures/Regression/OrientedComposeHoles/bracket-finished-mounts.firmament"));
+ Assert.Equal(2, result.Features!.Count); Assert.Equal(3, result.EngineeringFeatures!.Count);
+ var expected = (201 + 3.75 * (1 - Math.PI / 4) - .125) * 20 - (20.25 + 27 + 10d / 3) * Math.PI;
+ foreach (var body in new[] { result.RuntimeBody!, Step242Importer.ImportBody(result.StepText).Value })
+ {
+ var mass = BrepMassProperties.Evaluate(body);
+ Assert.InRange(Math.Abs(mass.AbsoluteVolume - expected), 0, Math.Max(mass.ErrorBound ?? 0, 1e-6));
+ }
+ }
+
+ [Fact]
+ public void AllSixOriginalCornersCanBeFinishedWithoutBecomingAChainSelection()
+ {
+ var finishes = Enumerable.Range(0, 6).Select(i => Finish("Corner" + i, "Vertex" + i + "_Vertex" + ((i + 1) % 6), "Fillet", i == 3 ? 2 : .5)).ToArray();
+ var result = Build(With(Bracket, finishes));
+ Assert.Equal(6, result.MaterializedFeatures!.Count(f => f.Kind == "EdgeFinish"));
+ Assert.Equal(7, result.RuntimeBody!.Geometry.Surfaces.Count(s => s.Value.Cylinder is not null));
+ }
+}
diff --git a/Aetheris.Kernel.Firmament.Tests/LongitudinalEdgeFinishTests.cs b/Aetheris.Kernel.Firmament.Tests/LongitudinalEdgeFinishTests.cs
new file mode 100644
index 00000000..88a715f6
--- /dev/null
+++ b/Aetheris.Kernel.Firmament.Tests/LongitudinalEdgeFinishTests.cs
@@ -0,0 +1,102 @@
+using Aetheris.Kernel.Core.Brep.Verification;
+using Aetheris.Kernel.Core.Step242;
+using Aetheris.Kernel.Firmament.Materializer;
+
+namespace Aetheris.Kernel.Firmament.Tests;
+
+public sealed class LongitudinalEdgeFinishTests
+{
+ private static string Bracket {
+ get { var s=FirmamentCorpusHarness.ReadFixtureText("fixtures/Regression/OrientedComposeHoles/bracket-foot-hole.firmament"); return s[..s.IndexOf(" Modify",StringComparison.Ordinal)]+"}"; }
+ }
+ private static string Source(string target,string kind,double size,string plane="XZ") => Bracket.Replace("on XZ", "on "+plane,StringComparison.Ordinal)[..^1]
+ + FormattableString.Invariant($"Modify bracket {{ EdgeFinish Bend {{ Face: Longitudinal Target: section.Outer.{target}.Start Kind: {kind} {(kind=="Fillet"?"Radius":"Distance")}: {size}mm }} }} }}");
+
+ [Theory]
+ [InlineData("Vertex3_Vertex4", "Fillet", 2d, true)]
+ [InlineData("Vertex2_Vertex3", "Fillet", .5d, false)]
+ [InlineData("Vertex3_Vertex4", "Chamfer", 2d, true)]
+ [InlineData("Vertex2_Vertex3", "Chamfer", .5d, false)]
+ public void InsideAndOutsideFinish_SweepTheCompleteWidth_AndRetainExactSectionArea(string target,string kind,double size,bool inside)
+ {
+ var source=Source(target,kind,size);
+ var original=FirmamentBuildAndExport.CompileSource(Bracket).Value;
+ var map=original.RuntimeCorrespondence!;
+ var role=inside?SemanticTopologyRole.ReflexLongitudinalEdge:SemanticTopologyRole.ConvexLongitudinalEdge;
+ var edge=Assert.Single(map.Descendants,d=>d.Role==role && d.SourceStableId=="profile:section.Outer."+target);
+ var selected=SingleEdgeFinishSelection.Resolve(map,edge.Edge!.Value)!;
+ Assert.Equal("Longitudinal",selected.Face); Assert.True(selected.FilletSupported);
+ Assert.Equal("section.Outer."+target+".Start",selected.Target);
+ var bound=ProfileLongitudinalEdgeFinish.Apply(source,FirmamentV2.ProfileAuthoringParser.Parse(Bracket).Profile!,"bracket");
+ Assert.Null(bound.Diagnostic); Assert.NotNull(bound.Profile);
+ var change=size*size*(kind=="Fillet"?1-Math.PI/4:.5)*(inside?1:-1);
+ Assert.Equal(201+change,ResolvedProfile2DValidator.Validate(bound.Profile).SignedArea,8);
+ var build=FirmamentBuildAndExport.CompileSource(source);
+ Assert.True(build.IsSuccess,string.Join(";",build.Diagnostics.Select(d=>d.Message)));
+ var body=build.Value.RuntimeBody!;
+ var imported=Step242Importer.ImportBody(build.Value.StepText); Assert.True(imported.IsSuccess);
+ foreach(var b in new[]{body,imported.Value}) {
+ var mass=BrepMassProperties.Evaluate(b); Assert.True(mass.IsEnclosed); Assert.True(mass.IsOrientationConsistent);
+ Assert.InRange(Math.Abs(mass.AbsoluteVolume-(201+change)*20),0,Math.Max(mass.ErrorBound??0,1e-6));
+ var points=b.Topology.Vertices.Select(v=>{ Assert.True(b.TryGetVertexPoint(v.Id,out var p)); return p; }).ToArray();
+ Assert.Equal(-20,points.Min(p=>p.Y),8); Assert.Equal(0,points.Max(p=>p.Y),8);
+ if(kind=="Fillet") {
+ var surface=Assert.Single(b.Geometry.Surfaces,s=>s.Value.Cylinder is not null).Value.Cylinder!.Value;
+ Assert.Equal(size,surface.Radius,8); Assert.Equal(1,Math.Abs(surface.Axis.Y),8);
+ // The blend ends on both stock caps, rather than stopping short inside a side face.
+ Assert.Equal(9,b.Topology.Faces.Count());
+ }
+ }
+ }
+
+ [Theory]
+ [InlineData(0d)] [InlineData(-1d)] [InlineData(27d)] [InlineData(50d)]
+ public void InvalidInsideSize_IsRefusedWithoutAResult(double size)
+ {
+ var result=FirmamentBuildAndExport.CompileSource(Source("Vertex3_Vertex4","Fillet",size));
+ Assert.False(result.IsSuccess); Assert.Contains(result.Diagnostics,d=>d.Message.Contains("longitudinal-edge-finish:",StringComparison.Ordinal));
+ }
+
+ [Fact]
+ public void LargeOutsideRound_CannotCrossTheOtherArmOfTheBracket()
+ {
+ var result=FirmamentBuildAndExport.CompileSource(Source("Vertex0_Vertex1","Fillet",12));
+ Assert.False(result.IsSuccess); Assert.Contains(result.Diagnostics,d=>d.Message.Contains("another boundary",StringComparison.Ordinal));
+ }
+
+ [Theory]
+ [InlineData("XY")] [InlineData("YZ")] [InlineData("XZ")]
+ public void ConstructionPlaneControlsTheFullLengthBlend(string plane)
+ {
+ var result=FirmamentBuildAndExport.CompileSource(Source("Vertex3_Vertex4","Fillet",2,plane));
+ Assert.True(result.IsSuccess,string.Join(";",result.Diagnostics.Select(d=>d.Message)));
+ Assert.True(BrepMassProperties.Evaluate(result.Value.RuntimeBody!).IsEnclosed);
+ }
+
+ [Fact]
+ public void PreferredFieldSpellingAndVariantRetainTheSameFeature()
+ {
+ var source=Source("Vertex3_Vertex4","Fillet",2).Replace("EdgeFinish Bend", "EdgeFinish<Fillet> Bend",StringComparison.Ordinal)
+ .Replace("Kind: Fillet", "",StringComparison.Ordinal).Replace("Face:","face:",StringComparison.Ordinal)
+ .Replace("Target:","target:",StringComparison.Ordinal).Replace("Radius:","radius:",StringComparison.Ordinal);
+ var result=FirmamentBuildAndExport.CompileSource(source);
+ Assert.True(result.IsSuccess,string.Join(";",result.Diagnostics.Select(d=>d.Message)));
+ var feature=Assert.Single(result.Value.EngineeringFeatures!);
+ Assert.Equal("Longitudinal",feature.Support); Assert.Equal("Add",feature.MaterialEffect);
+ }
+
+ [Fact]
+ public void InsetTerminationField_IsNotSilentlyAcceptedOnAFullLengthFinish()
+ {
+ var source=Source("Vertex3_Vertex4","Fillet",2).Replace("Radius: 2mm", "Radius: 2mm EndClearance: 1mm",StringComparison.Ordinal);
+ var result=FirmamentBuildAndExport.CompileSource(source);
+ Assert.False(result.IsSuccess); Assert.Contains(result.Diagnostics,d=>d.Message.Contains("EndClearance",StringComparison.Ordinal));
+ }
+
+ [Fact]
+ public void AnonymousFinish_IsDiagnosedInsteadOfThrowing()
+ {
+ var source=Source("Vertex3_Vertex4","Fillet",2).Replace("EdgeFinish Bend", "EdgeFinish",StringComparison.Ordinal);
+ Assert.False(FirmamentBuildAndExport.CompileSource(source).IsSuccess);
+ }
+}
diff --git a/Aetheris.Kernel.Firmament.Tests/SingleEdgeFinishSelectionTests.cs b/Aetheris.Kernel.Firmament.Tests/SingleEdgeFinishSelectionTests.cs
new file mode 100644
index 00000000..337515d7
--- /dev/null
+++ b/Aetheris.Kernel.Firmament.Tests/SingleEdgeFinishSelectionTests.cs
@@ -0,0 +1,94 @@
+using Aetheris.Kernel.Core.Brep.Verification;
+using Aetheris.Kernel.Core.Step242;
+using Aetheris.Kernel.Core.Topology;
+using Aetheris.Kernel.Firmament.Materializer;
+
+namespace Aetheris.Kernel.Firmament.Tests;
+
+public sealed class SingleEdgeFinishSelectionTests
+{
+ private static string Bracket {
+ get {
+ var source = FirmamentCorpusHarness.ReadFixtureText("fixtures/Regression/OrientedComposeHoles/bracket-foot-hole.firmament");
+ return source[..source.IndexOf(" Modify", StringComparison.Ordinal)] + "}";
+ }
+ }
+
+ [Theory]
+ [InlineData("Top", "Fillet")]
+ [InlineData("Bottom", "Fillet")]
+ [InlineData("Top", "Chamfer")]
+ [InlineData("Bottom", "Chamfer")]
+ public void LegacyCapFeature_RemainsBuildable_WithoutAdvertisingAFullEdgeFillet(string side, string kind)
+ {
+ var original = FirmamentBuildAndExport.CompileSource(Bracket).Value;
+ var correspondence = original.RuntimeCorrespondence!;
+ var role = side == "Top" ? SemanticTopologyRole.TopBoundary : SemanticTopologyRole.BottomBoundary;
+ var descendant = Assert.Single(correspondence.Descendants, d => d.Role == role && d.SourceStableId == "profile:section.Outer.Vertex2_Vertex3");
+ var selected = SingleEdgeFinishSelection.Resolve(correspondence, descendant.Edge!.Value)!;
+ Assert.Equal(new("bracket", side, "section.Outer.Vertex2_Vertex3", "Extrusion end-face edge", FilletSupported: false), selected);
+ var field = kind == "Fillet" ? "Radius" : "Distance";
+ var source = Bracket[..Bracket.LastIndexOf('}')] + $"Modify {selected.Body} {{ EdgeFinish Picked {{ Face: {selected.Face} Target: {selected.Target} Kind: {kind} {field}: 0.5mm }} }} }}";
+ var result = FirmamentBuildAndExport.CompileSource(source);
+ Assert.True(result.IsSuccess, string.Join(";", result.Diagnostics.Select(d => d.Message)));
+ var mass = BrepMassProperties.Evaluate(result.Value.RuntimeBody!);
+ Assert.True(mass.IsEnclosed); Assert.True(mass.IsOrientationConsistent);
+ Assert.InRange(mass.AbsoluteVolume, 4000, 4019.99);
+ var imported = Step242Importer.ImportBody(result.Value.StepText); Assert.True(imported.IsSuccess);
+ var reimported = BrepMassProperties.Evaluate(imported.Value);
+ Assert.True(reimported.IsEnclosed); Assert.True(reimported.IsOrientationConsistent);
+ Assert.True(Math.Abs(mass.AbsoluteVolume - reimported.AbsoluteVolume) <= Math.Max(1e-6, (mass.ErrorBound ?? 0) + (reimported.ErrorBound ?? 0)),
+ $"Native {mass.AbsoluteVolume} +/- {mass.ErrorBound} ({mass.EvaluationMethod}); STEP {reimported.AbsoluteVolume} +/- {reimported.ErrorBound} ({reimported.EvaluationMethod})");
+ if (kind == "Fillet") Assert.Single(result.Value.RuntimeBody!.Geometry.Surfaces, s => s.Value.Cylinder is not null);
+ }
+
+ [Fact]
+ public void SplitOrUnmappedEdges_DoNotBecomeWholeSegmentSelections()
+ {
+ var map = FirmamentBuildAndExport.CompileSource(Bracket).Value.RuntimeCorrespondence!;
+ var edge = map.Descendants.First(d => d.Role == SemanticTopologyRole.TopBoundary && d.Edge is not null);
+ var split = map with { Descendants = [.. map.Descendants, edge with { StableId = "split", Edge = new EdgeId(9999) }] };
+ Assert.Null(SingleEdgeFinishSelection.Resolve(split, edge.Edge!.Value));
+ Assert.Null(SingleEdgeFinishSelection.Resolve(map, new EdgeId(9999)));
+ }
+
+ [Theory]
+ [InlineData("Fillet")]
+ [InlineData("Chamfer")]
+ public void BoxFacePair_UsesTheExistingLocalizedSingleEdgeRoute(string kind)
+ {
+ const string stock = "Box Stock { Size: [20mm, 15mm, 10mm] }";
+ var original = FirmamentBuildAndExport.CompileSource($"Model Part {{ Units: mm {stock} }}");
+ Assert.True(original.IsSuccess, string.Join(";", original.Diagnostics.Select(d => d.Message)));
+ var map = original.Value.RuntimeCorrespondence!;
+ var edge = Assert.Single(map.Descendants, d => d.StableId == "Stock.edge(TopRight)");
+ var selection = SingleEdgeFinishSelection.Resolve(map, edge.Edge!.Value)!;
+ Assert.Equal("+X", selection.Face); Assert.Equal("SharedEdgePlusZ", selection.Target);
+ var field = kind == "Fillet" ? "Radius" : "Distance";
+ var result = FirmamentBuildAndExport.CompileSource($"Model Part {{ Units: mm {stock} Modify Stock {{ EdgeFinish Picked {{ Face: {selection.Face} Target: {selection.Target} Kind: {kind} {field}: 1mm }} }} }}");
+ Assert.True(result.IsSuccess, string.Join(";", result.Diagnostics.Select(d => d.Message)));
+ var imported = Step242Importer.ImportBody(result.Value.StepText); Assert.True(imported.IsSuccess);
+ Assert.Equal(7, imported.Value.Topology.Faces.Count());
+ var originalPoints = original.Value.RuntimeBody!.Topology.Vertices.Select(v => {
+ Assert.True(original.Value.RuntimeBody.TryGetVertexPoint(v.Id, out var point)); return point;
+ }).ToArray();
+ var finishedPoints = imported.Value.Topology.Vertices.Select(v => {
+ Assert.True(imported.Value.TryGetVertexPoint(v.Id, out var point)); return point;
+ }).ToArray();
+ Assert.Equal(originalPoints.Min(p => p.Z), finishedPoints.Min(p => p.Z), 9);
+ Assert.Equal(originalPoints.Max(p => p.Z), finishedPoints.Max(p => p.Z), 9);
+ }
+
+ [Fact]
+ public void OrientedBracketWithPickedFaceHole_AdmitsSeparatedFinishHistory()
+ {
+ var source = FirmamentCorpusHarness.ReadFixtureText("fixtures/Regression/OrientedComposeHoles/bracket-foot-hole.firmament");
+ source = source.Insert(source.LastIndexOf(" }", StringComparison.Ordinal),
+ "EdgeFinish EdgeFillet { Face: Longitudinal Target: section.Outer.Vertex3_Vertex4.Start Kind: Fillet Radius: 0.5mm }\n");
+ var result = FirmamentBuildAndExport.CompileSource(source);
+ Assert.True(result.IsSuccess, string.Join(";", result.Diagnostics.Select(d => d.Message)));
+ var accepted=FirmamentBuildAndExport.CompileSource(FirmamentCorpusHarness.ReadFixtureText("fixtures/Regression/OrientedComposeHoles/bracket-foot-hole.firmament"));
+ Assert.Null(SingleEdgeFinishSelection.UnavailableReason(accepted.Value.RuntimeCorrespondence!));
+ Assert.Contains(accepted.Value.RuntimeCorrespondence!.Descendants, d => d.Role == SemanticTopologyRole.ReflexLongitudinalEdge);
+ }
+}
diff --git a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.Longitudinal.cs b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.Longitudinal.cs
new file mode 100644
index 00000000..36c07e50
--- /dev/null
+++ b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.Longitudinal.cs
@@ -0,0 +1,123 @@
+using Aetheris.Kernel.Core.Diagnostics;
+using Aetheris.Kernel.Core.Results;
+using Aetheris.Kernel.Core.Step242;
+using Aetheris.Kernel.Core.Brep.Verification;
+using Aetheris.Kernel.Core.Brep;
+using Aetheris.Kernel.Firmament.Execution;
+using Aetheris.Kernel.Firmament.FirmamentV2;
+using Aetheris.Kernel.Firmament.Materializer;
+
+namespace Aetheris.Kernel.Firmament;
+
+public static partial class FirmamentBuildAndExport
+{
+ private static SemanticTopologyCorrespondence? ProfileDisplayCorrespondence(ResolvedProfile2D profile, LineArcProfileExtrudeResult emitted, string bodyName)
+ {
+ if (emitted.Correspondence is not { } correspondence) return null;
+ var loop = profile.Loops.First(l => l.IsOuter);
+ var uniqueNames = loop.Segments.Select(s => s.Name).Distinct(StringComparer.Ordinal).Count() == loop.Segments.Count;
+ var corners = (uniqueNames ? ProfileJunctionClassifier.Classify(profile) : []).Where(j => j.LoopId == loop.Name && (j.Classification is ProfileJunctionKind.ConvexProfileJunction or ProfileJunctionKind.ReflexProfileJunction)
+ && loop.Segments.Single(s => s.Name == j.PredecessorSegmentId).Geometry is LineArcLineSegment2D
+ && loop.Segments.Single(s => s.Name == j.SuccessorSegmentId).Geometry is LineArcLineSegment2D)
+ .ToDictionary(j => $"profile:{profile.Name}.{j.LoopId}.{j.SuccessorSegmentId}", j => j.Classification);
+ return correspondence with { BodyStableId = bodyName, Descendants = correspondence.Descendants.Where(d =>
+ d.Role is SemanticTopologyRole.ExtrusionSideFace or SemanticTopologyRole.TopBoundary or SemanticTopologyRole.BottomBoundary
+ || d.Role == SemanticTopologyRole.VerticalExtrusionEdge && d.StableId.EndsWith(":vertical-start", StringComparison.Ordinal) && corners.ContainsKey(d.SourceStableId))
+ .Select(d => d.Role == SemanticTopologyRole.VerticalExtrusionEdge
+ ? d with { Role = corners[d.SourceStableId] == ProfileJunctionKind.ReflexProfileJunction ? SemanticTopologyRole.ReflexLongitudinalEdge : SemanticTopologyRole.ConvexLongitudinalEdge,
+ Addressability = SemanticTopologyAddressability.DerivedStable }
+ : d.Face is { } id && PlanarFaceThroughHole.Support(emitted.Body!, id) is not null
+ ? d with { FirmamentSelector = $"face({bodyName}.Side({System.Text.Json.JsonSerializer.Serialize(d.SourceStableId)}))", Addressability = SemanticTopologyAddressability.DerivedStable }
+ : d).ToArray() };
+ }
+
+ private static KernelResult<FirmamentStepExportResult> ExportLongitudinalFinish(string source, ResolvedProfile2D profile, double height, string bodyName, string? diagnosticSource)
+ => ExportProfileCornerHost(source, profile, height, bodyName, diagnosticSource, null);
+
+ // A single prism and source-side holes share the profile plan. General Compose
+ // histories still belong to their existing planners and are never flattened here.
+ private static KernelResult<FirmamentStepExportResult>? TryExportProfileCornerHost(string source,
+ PrismaticProfileCompositionParseResult parsed, string? diagnosticSource, FirmamentV2Document? document)
+ {
+ var feature = parsed.Feature;
+ if (feature is null) return null;
+ var requested = ProfileLongitudinalEdgeFinish.Requested(source);
+ var operation = feature.Operations.Count == 1 ? feature.Operations[0] : null;
+ var qualified = operation is { Intent: PrismaticProfileIntent.Base, From: 0 } && !feature.Placement.IsExplicit
+ && feature.Hollow is null && (feature.ShaftHoles?.Count ?? 0) == 0
+ && (feature.CounterboreHoles?.Count ?? 0) == 0 && (feature.CountersinkHoles?.Count ?? 0) == 0
+ && (feature.ConstructionPlaneBlindDrills?.Count ?? 0) == 0 && !feature.AllSlotProfiles.Any()
+ && (feature.Bosses?.Count ?? 0) == 0 && (feature.Pockets?.Count ?? 0) == 0 && (feature.MaterialOffsets?.Count ?? 0) == 0;
+ if (!qualified)
+ return requested ? KernelResult<FirmamentStepExportResult>.Failure([new(KernelDiagnosticCode.ValidationFailed, KernelDiagnosticSeverity.Error,
+ "longitudinal-edge-finish: This history needs a single profile extrusion with source-side through holes. Other Compose operations are not supported by this finish planner.", "FirmamentV2.EdgeFinish")]) : null;
+ if (!parsed.Profiles.TryGetValue(operation!.ProfileReference, out var profile)) return null;
+ // Resolved Compose operands carry a plane, while their axial interval
+ // belongs to Base. Publish that interval to the profile plan explicitly;
+ // otherwise its compatibility default centers the extrusion on the plane.
+ profile = profile with { LocalStartDepth = operation.From, LocalEndDepth = operation.To };
+ if (!requested && (feature.FaceHoles.Count == 0 || source.Contains("EdgeFinish", StringComparison.Ordinal)
+ || profile.Loops.Count != 1 || profile.Loops[0].Segments.Any(s => s.Geometry is not LineArcLineSegment2D))) return null;
+ return ExportProfileCornerHost(source, profile, operation.To, feature.Name, diagnosticSource, feature, document);
+ }
+
+ private static KernelResult<FirmamentStepExportResult> ExportProfileCornerHost(string source, ResolvedProfile2D profile,
+ double height, string bodyName, string? diagnosticSource, PrismaticProfileCompositionFeature? feature, FirmamentV2Document? document = null)
+ {
+ var result = ProfileLongitudinalEdgeFinish.ApplyAll(source, profile, bodyName);
+ KernelResult<FirmamentStepExportResult> Fail(string message)
+ {
+ var span = ProfileBoundaryChamferSourceBinder.FinishDeclarations(diagnosticSource ?? source).FirstOrDefault()?.Span;
+ return KernelResult<FirmamentStepExportResult>.Failure([new KernelDiagnostic(KernelDiagnosticCode.ValidationFailed, KernelDiagnosticSeverity.Error, message, "FirmamentV2.EdgeFinish")
+ { SourceSpan = span is { } s ? new(s.Start, s.Length) : null }]);
+ }
+ if (result.Profile is null) return Fail(result.Diagnostic!);
+ var emitted = ResolvedProfile2DValidator.Extrude(result.Profile, height);
+ if (emitted.Body is null || emitted.BRepPlan is null) return Fail(string.Join("; ", emitted.Diagnostics));
+ var correspondence = ProfileDisplayCorrespondence(result.Profile, emitted, bodyName)!;
+ var original = ResolvedProfile2DValidator.Extrude(profile, height);
+ if (original.Body is null || original.Correspondence is null) return Fail("longitudinal-edge-finish: Missing original support plan.");
+ var anchors = original.Correspondence.Descendants.Where(d => d.Face is not null && d.Role == SemanticTopologyRole.ExtrusionSideFace)
+ .Select(d => (d.SourceStableId, Support: PlanarFaceThroughHole.Support(original.Body, d.Face!.Value)))
+ .Where(d => d.Support is not null).ToDictionary(d => d.SourceStableId, d => d.Support!.Origin, StringComparer.Ordinal);
+ correspondence = correspondence with {
+ Descendants = correspondence.Descendants.Select(d => d.Face is not null && anchors.TryGetValue(d.SourceStableId, out var origin)
+ ? d with { SupportOrigin = origin } : d).ToArray(),
+ ProvenanceChain = correspondence.ProvenanceChain.Append("ProfileCornerFinishHost").ToArray()
+ };
+ var completed = PlanarFaceThroughHole.FromProfile(emitted, correspondence);
+ foreach (var hole in feature?.FaceHoles ?? [])
+ {
+ completed = PlanarFaceThroughHole.Apply(completed, hole);
+ if (completed.Body is null) return Fail(string.Join("; ", completed.Diagnostics));
+ }
+ var body = completed.Body!;
+ correspondence = completed.Correspondence!;
+ var preflight = BrepExportPreflight.Validate(body);
+ if (!preflight.IsValid || !FirmamentManifoldChecker.IsManifold(body)) return Fail("longitudinal-edge-finish: The resulting body did not pass closed-manifold verification.");
+ var semanticPmi = Array.Empty<Step242SemanticPmi>();
+ if (document is not null && feature is not null)
+ {
+ var support = ValidateV2PmiExportSupport(document);
+ if (!support.IsSuccess) return KernelResult<FirmamentStepExportResult>.Failure(support.Diagnostics);
+ semanticPmi = BuildV2SemanticPmi(document, [], bodyName, feature.FaceHoles.ToDictionary(h => h.Name, h => h.StableId, StringComparer.Ordinal),
+ correspondence, body, ComposeOperationCapFaces(feature, body, correspondence), feature).ToArray();
+ }
+ var step = Step242Exporter.ExportBody(body, semanticPmi, new Step242ExportOptions { ProductName = bodyName,
+ ApplicationName = "Aetheris.Firmament.FullLengthEdgeFinish", BrepExportPreflightMode = BrepExportPreflightMode.Enforce });
+ if (!step.IsSuccess) return KernelResult<FirmamentStepExportResult>.Failure(step.Diagnostics);
+ var imported = Step242Importer.ImportBody(step.Value);
+ if (!imported.IsSuccess || !FirmamentManifoldChecker.IsManifold(imported.Value)) return Fail("longitudinal-edge-finish: STEP reimport did not preserve a closed manifold.");
+ var receipts = result.Finishes.SelectMany(f => FirmamentFeatureAccounting.ProfileFinish(source, f.Name!, bodyName))
+ .Concat((feature?.FaceHoles ?? []).Select(h => new FirmamentFeatureReceipt(bodyName, "Hole", h.Name))).ToArray();
+ return KernelResult<FirmamentStepExportResult>.Success(new FirmamentStepExportResult(step.Value, bodyName, 0, "profile-longitudinal-edge-finish", "profile-corner-host",
+ Features: feature is null ? [] : CompositionHoleReports(feature, body, correspondence)) {
+ RuntimeBody = body, RuntimeBodySourceName = bodyName,
+ RuntimeCorrespondence = correspondence,
+ MaterializedFeatures = receipts,
+ EngineeringFeatures = result.Finishes.Select(f => new FirmamentEngineeringFeatureReport(
+ f.Name!, "EdgeFinish", "edgefinish:" + f.Name, bodyName, "Longitudinal", f.Target!, f.Size,
+ f.Kind == "Fillet" ? "Radius" : "Distance", f.AddsMaterial ? "Add" : "Remove", PolicySource: f.Kind, MaterializationRoute: "FullLengthProfileCorner")).ToArray()
+ });
+ }
+}
diff --git a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs
index 116c4464..c93487dd 100644
--- a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs
@@ -529,6 +529,8 @@ public static partial class FirmamentBuildAndExport
if (v2Parse.BoundComposition is not null || (!v2Parse.OwnsUnifiedAdmission && PrismaticProfileCompositionParser.IsCompositionSource(materializerSource)))
{
var parsed = v2Parse.BoundComposition ?? PrismaticProfileCompositionParser.Parse(materializerSource);
+ if (TryExportProfileCornerHost(materializerSource, parsed, v2Parse.DiagnosticSource, v2Parse.Document) is { } cornerHost)
+ return cornerHost;
var stack = PrismaticSectionStackCompiler.Normalize(parsed, out var diagnostics);
if (stack is null)
return KernelResult<FirmamentStepExportResult>.Failure(diagnostics.Select(x => new Kernel.Core.Diagnostics.KernelDiagnostic(Kernel.Core.Diagnostics.KernelDiagnosticCode.ValidationFailed, Kernel.Core.Diagnostics.KernelDiagnosticSeverity.Error, x, "FirmamentV2.ProfileComposition")).ToArray());
@@ -578,18 +580,14 @@ public static partial class FirmamentBuildAndExport
if (parsed.Profile is null) return KernelResult<FirmamentStepExportResult>.Failure(parsed.Diagnostics.Select(x => new Kernel.Core.Diagnostics.KernelDiagnostic(Kernel.Core.Diagnostics.KernelDiagnosticCode.ValidationFailed, Kernel.Core.Diagnostics.KernelDiagnosticSeverity.Error, x, "FirmamentV2.Profile")).ToArray());
var emitted = ResolvedProfile2DValidator.Extrude(parsed.Profile, parsed.Height);
if (emitted.Status != LineArcProfileExtrudeStatus.Succeeded || emitted.Body is null) return KernelResult<FirmamentStepExportResult>.Failure(emitted.Diagnostics.Select(x => new Kernel.Core.Diagnostics.KernelDiagnostic(Kernel.Core.Diagnostics.KernelDiagnosticCode.ValidationFailed, Kernel.Core.Diagnostics.KernelDiagnosticSeverity.Error, x, "FirmamentV2.Profile")).ToArray());
+ var extrusionName = FirmamentV2Parser.MechanicalDeclarations(FirmamentSyntaxParser.Parse(materializerSource).Document.Statements)
+ .FirstOrDefault(d => d.Type.Name.Text == "Extrude")?.Name?.Text ?? parsed.Profile.Name;
+ if (ProfileLongitudinalEdgeFinish.Requested(materializerSource))
+ return ExportLongitudinalFinish(materializerSource, parsed.Profile, parsed.Height, extrusionName, v2Parse.DiagnosticSource);
if (materializerSource.Contains("EdgeFinish", StringComparison.Ordinal))
return ExportProfileSemanticTopBoundaryChamfer(materializerSource, parsed.Profile, parsed.Height, emitted, v2Parse.DiagnosticSource);
var step = Step242Exporter.ExportBody(emitted.Body); if (!step.IsSuccess) return KernelResult<FirmamentStepExportResult>.Failure(step.Diagnostics);
- var extrusionName = FirmamentV2Parser.MechanicalDeclarations(FirmamentSyntaxParser.Parse(materializerSource).Document.Statements)
- .FirstOrDefault(d => d.Type.Name.Text == "Extrude")?.Name?.Text ?? parsed.Profile.Name;
- var profileCorrespondence = emitted.Correspondence is not { } correspondence ? null : correspondence with {
- // The extrusion plan also carries overlapping edge roles for finish planners.
- // Publish its unique side-face owners here; edge picking remains unqualified.
- Descendants = correspondence.Descendants.Where(d => d.Role == SemanticTopologyRole.ExtrusionSideFace).Select(d => d.Face is { } id
- && PlanarFaceThroughHole.Support(emitted.Body, id) is not null
- ? d with { FirmamentSelector = $"face({extrusionName}.Side({System.Text.Json.JsonSerializer.Serialize(d.SourceStableId)}))", Addressability = SemanticTopologyAddressability.DerivedStable } : d).ToArray()
- };
+ var profileCorrespondence = ProfileDisplayCorrespondence(parsed.Profile, emitted, extrusionName);
return KernelResult<FirmamentStepExportResult>.Success(new FirmamentStepExportResult(step.Value, parsed.Profile.Name, 0, "profile-extrude", "line-arc-profile") {
RuntimeBody = emitted.Body, RuntimeCorrespondence = profileCorrespondence, RuntimeBodySourceName = extrusionName });
}
@@ -1869,7 +1867,9 @@ public static partial class FirmamentBuildAndExport
if (!compiled.Succeeded || compiled.Body is null || compiled.Construction is null || compiled.BRepPlan?.LocalizedEdgeReplacementRealizationPlan is null)
return AirChamferFailure(compiled.Error?.Code ?? compiled.Feature.AdmissionReason, compiled.Diagnostics);
- var body = compiled.Body;
+ // AIR builds centered kernel stock; publish in the same bottom-anchored frame as the authored Box.
+ var body = FirmamentPrimitiveExecutionTranslation.TranslateBody(compiled.Body,
+ new Vector3D(0, 0, FirmamentStockFrame.ForBox(box.Size[0], box.Size[1], box.Size[2]).KernelCenteredToStockZ));
var preflight = BrepExportPreflight.Validate(body);
if (!preflight.IsValid) return AirChamferFailure("localized-chamfer-preflight-verification-failed", preflight.Diagnostics.Select(d => d.Code));
if (!FirmamentManifoldChecker.IsManifold(body)) return AirChamferFailure("localized-chamfer-emitted-body-is-not-manifold");
@@ -2312,7 +2312,9 @@ public static partial class FirmamentBuildAndExport
if (!compiled.Succeeded || compiled.Body is null || compiled.Construction is null || compiled.BRepPlan?.LocalizedEdgeReplacementRealizationPlan is null)
return AirChamferFailure(compiled.Error?.Code ?? compiled.Feature.AdmissionReason, compiled.Diagnostics);
- var body = compiled.Body;
+ // AIR builds centered kernel stock; publish in the same bottom-anchored frame as the authored Box.
+ var body = FirmamentPrimitiveExecutionTranslation.TranslateBody(compiled.Body,
+ new Vector3D(0, 0, FirmamentStockFrame.ForBox(box.Size[0], box.Size[1], box.Size[2]).KernelCenteredToStockZ));
var preflight = BrepExportPreflight.Validate(body);
if (!preflight.IsValid) return AirChamferFailure("localized-fillet-preflight-verification-failed", preflight.Diagnostics.Select(d => d.Code));
if (!FirmamentManifoldChecker.IsManifold(body)) return AirChamferFailure("localized-fillet-emitted-body-is-not-manifold");
diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/SemanticConstructDeclarations.cs b/Aetheris.Kernel.Firmament/FirmamentV2/SemanticConstructDeclarations.cs
index 539774a1..99719377 100644
--- a/Aetheris.Kernel.Firmament/FirmamentV2/SemanticConstructDeclarations.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentV2/SemanticConstructDeclarations.cs
@@ -88,8 +88,8 @@ public static class HoleSemanticDeclaration
public static double ProjectDiameter(FirmamentV2SemanticHoleDecl instance) => instance.ShaftDiameter;
}
-[FirmamentConstruct("EdgeFinish", "EdgeFinish", Context = "Modify body", Entry = "EdgeFinish TopChamfer { Face: +Z; Target: Boundary; Kind: Chamfer; Distance: 1mm }", Description = "An exact fillet or chamfer on an admitted boundary: the edges around one face. To round the vertical edges of a plate or block, round the corners of its Profile instead (Extrude or Compose on RoundedRect2). Preview checks host, selector and feature combinations.")]
-[FirmamentField("Face", "Face", FirmamentSchemaValueKind.FaceSelector, Choices = ["+Z", "-Z", "+X", "-X", "+Y", "-Y"], Description = "Support face whose boundary is finished. Supported faces depend on the body and existing features.")]
+[FirmamentConstruct("EdgeFinish", "EdgeFinish", Context = "Modify body", Entry = "EdgeFinish TopChamfer { Face: +Z; Target: Boundary; Kind: Chamfer; Distance: 1mm }", Description = "An exact fillet or chamfer on an admitted boundary. Face: Longitudinal with Target: Profile.Outer.Segment.Start finishes a full extrusion corner, including a concave inside bend. Boundary targets finish a face rim. Preview checks geometry and feature combinations.")]
+[FirmamentField("Face", "Face", FirmamentSchemaValueKind.FaceSelector, Choices = ["+Z", "-Z", "+X", "-X", "+Y", "-Y", "Longitudinal"], Description = "Support face whose boundary is finished, or Longitudinal for a full-length profile corner. Supported faces depend on the body and existing features.")]
[FirmamentField("Target", "Target", FirmamentSchemaValueKind.Choice, Required = true, Choices = ["Boundary", "AllEdges"], Description = "Boundary finishes the selected face perimeter. AllEdges is a uniform fillet on supported Box or Polyhedron stock only; omit Face for AllEdges.")]
[FirmamentField("Kind", "Kind", FirmamentSchemaValueKind.Choice, Choices = ["Chamfer", "Fillet"], Description = "Chamfer makes a bevel; Fillet makes a circular round. May also be specified by EdgeFinish<Chamfer> or EdgeFinish<Fillet>.")]
[FirmamentField("Distance", "Distance", FirmamentSchemaValueKind.Length, Unit = FirmamentUnitKind.Length, Description = "Chamfer distance. Supply Distance or Radius, not both.")]
diff --git a/Aetheris.Kernel.Firmament/Materializer/BoxConstructionCorrespondence.cs b/Aetheris.Kernel.Firmament/Materializer/BoxConstructionCorrespondence.cs
index 912adad3..0998975b 100644
--- a/Aetheris.Kernel.Firmament/Materializer/BoxConstructionCorrespondence.cs
+++ b/Aetheris.Kernel.Firmament/Materializer/BoxConstructionCorrespondence.cs
@@ -38,6 +38,10 @@ public static class BoxConstructionCorrespondence
$"{bodyStableId}.edge(TopFront)", "Edge", SemanticTopologyRole.BoxEdge,
bodyStableId, Edge: topology.TopEdges[0], ParentStableId: bodyStableId,
Addressability: SemanticTopologyAddressability.DerivedStable));
+ descendants.Add(new SemanticTopologyDescendant(
+ $"{bodyStableId}.edge(TopRight)", "Edge", SemanticTopologyRole.BoxEdge,
+ bodyStableId, Edge: topology.TopEdges[1], ParentStableId: bodyStableId,
+ Addressability: SemanticTopologyAddressability.DerivedStable));
return new(bodyStableId, descendants, ["FirmamentBox", "BrepPrimitives.CreateBox", "BrepExtrudeConstructionTopology"],
sourceSpan is null ? null : new Dictionary<string, FirmamentV2SourceSpan> { [bodyStableId] = sourceSpan });
}
diff --git a/Aetheris.Kernel.Firmament/Materializer/PlanarFaceThroughHole.cs b/Aetheris.Kernel.Firmament/Materializer/PlanarFaceThroughHole.cs
index 47af2abe..e4922f50 100644
--- a/Aetheris.Kernel.Firmament/Materializer/PlanarFaceThroughHole.cs
+++ b/Aetheris.Kernel.Firmament/Materializer/PlanarFaceThroughHole.cs
@@ -18,7 +18,20 @@ public static class PlanarFaceThroughHole
{
public const double MinimumClearance = .01;
private const double Tol = 1e-7;
- public static PlanarFaceSupport? Support(BrepBody body, FaceId id)
+ /// <summary>Reuse the exact profile plan as a host for the existing side-hole planner.</summary>
+ public static PrismaticSectionStackEmissionResult FromProfile(LineArcProfileExtrudeResult emitted, SemanticTopologyCorrespondence correspondence)
+ {
+ var plan = emitted.BRepPlan ?? throw new ArgumentException("An authoritative profile plan is required.", nameof(emitted));
+ var body = emitted.Body!.Clone();
+ var mappings = correspondence.Descendants.Where(d => d.Face is not null && d.Role == SemanticTopologyRole.ExtrusionSideFace)
+ .Select(d => new PrismaticSectionStackFacePlanMapping(d.Face!.Value, "PrismaticSide", d.SourceStableId, d.StableId, null, null, plan.Provenance)).ToArray();
+ var topology = new PrismaticSectionStackTopologyPlan(plan.StableId, body.Topology, body.Geometry, body.Bindings,
+ plan.Vertices.ToDictionary(v => v.Id, v => v.WorldPoint), mappings, correspondence, correspondence.ProvenanceChain);
+ var host = new PrismaticSectionStackBrepPlan(plan.StableId, plan.Vertices.Count, plan.Edges.Count, plan.Faces.Count,
+ "ProfilePlanSideHoleAdapter", true, correspondence, topology);
+ return new(body, host, [], correspondence);
+ }
+ public static PlanarFaceSupport? Support(BrepBody body, FaceId id, double[]? constructionOrigin = null)
{
var face = body.Topology.Faces.SingleOrDefault(f => f.Id == id);
if (face is null || face.LoopIds.Count == 0 || !body.TryGetFaceSurface(id, out var surface) || surface?.Plane is not { } plane
@@ -43,6 +56,14 @@ public static class PlanarFaceThroughHole
var minU = boundary.Min(p => p[0]); var minV = boundary.Min(p => p[1]);
var origin = plane.Origin + x * minU + y * minV;
boundary = boundary.Select(p => new[] { p[0] - minU, p[1] - minV }).ToArray();
+ if (constructionOrigin is { Length: 3 })
+ {
+ var anchored = P(constructionOrigin);
+ if (Math.Abs((anchored - origin).Dot(normal)) > Tol) return null;
+ var offset = origin - anchored;
+ boundary = boundary.Select(p => new[] { p[0] + offset.Dot(x), p[1] + offset.Dot(y) }).ToArray();
+ origin = anchored;
+ }
var area = boundary.Select((p, i) => p[0] * boundary[(i + 1) % boundary.Length][1] - p[1] * boundary[(i + 1) % boundary.Length][0]).Sum();
if (area < 0d) Array.Reverse(boundary);
// Convex supports give exact half-plane clearance; other trims fail closed.
@@ -104,7 +125,9 @@ public static class PlanarFaceThroughHole
if (source is null || body is null) return Fail("missing-host-plan");
var matches = source.FaceMappings.Where(m => m.SourceStableId == hole.SupportSource && m.Kind is "PrismaticSide" or "HostFaceReplacement").ToArray();
if (matches.Length != 1) return Fail("support-must-resolve-to-one-construction-face");
- var entryId = matches[0].FaceId; var entry = Support(body, entryId);
+ var entryId = matches[0].FaceId;
+ var anchor = source.Correspondence.Descendants.FirstOrDefault(d => d.Face == entryId && d.SupportOrigin is not null)?.SupportOrigin;
+ var entry = Support(body, entryId, anchor);
if (entry is null) return Fail("support-requires-a-convex-planar-face-with-straight-boundaries");
var normal = V(entry.Normal); var axis = -normal; var radius = hole.Diameter / 2d;
var outerRadius = hole.Variant == "Shaft" ? radius : (hole.RecessDiameter ?? double.NaN) / 2d;
@@ -160,9 +183,16 @@ public static class PlanarFaceThroughHole
bounds.Add(source.VertexPoints[edge.StartVertexId]); bounds.Add(source.VertexPoints[edge.EndVertexId]);
if (curve?.Circle3 is { } circle)
{
- var n = circle.Normal.ToVector();
- var extent = new Vector3D(circle.Radius * Math.Sqrt(Math.Max(0d, 1d - n.X * n.X)), circle.Radius * Math.Sqrt(Math.Max(0d, 1d - n.Y * n.Y)), circle.Radius * Math.Sqrt(Math.Max(0d, 1d - n.Z * n.Z)));
- bounds.Add(circle.Center + extent); bounds.Add(circle.Center - extent);
+ // Bounds belong to the trimmed arc, not its entire supporting circle.
+ var circleX = circle.XAxis.ToVector(); var circleY = circle.YAxis.ToVector();
+ var trim = binding.TrimInterval ?? new ParameterInterval(0, 2 * Math.PI);
+ foreach (var angle in new[] { Math.Atan2(circleY.X, circleX.X), Math.Atan2(circleY.Y, circleX.Y), Math.Atan2(circleY.Z, circleX.Z) })
+ foreach (var extremum in new[] { angle, angle + Math.PI })
+ {
+ var turn = Math.Ceiling((trim.Start - extremum) / (2 * Math.PI));
+ var parameter = extremum + turn * 2 * Math.PI;
+ if (parameter <= trim.End + Tol) bounds.Add(circle.Evaluate(parameter));
+ }
}
else if (curve?.Kind != CurveGeometryKind.Line3) return Fail("unsupported-corridor-edge-geometry");
}
@@ -170,7 +200,8 @@ public static class PlanarFaceThroughHole
double C(Point3D p) => i == 0 ? p.X : i == 1 ? p.Y : p.Z;
var n = i == 0 ? normal.X : i == 1 ? normal.Y : normal.Z;
var extent = outerRadius * Math.Sqrt(Math.Max(0d, 1d - n * n));
- return bounds.Max(C) < Math.Min(C(mouth), C(end)) - extent - MinimumClearance || bounds.Min(C) > Math.Max(C(mouth), C(end)) + extent + MinimumClearance;
+ return bounds.Max(C) <= Math.Min(C(mouth), C(end)) - extent - MinimumClearance + Tol
+ || bounds.Min(C) >= Math.Max(C(mouth), C(end)) + extent + MinimumClearance - Tol;
});
if (!separated) return Fail("tool-corridor-interaction-not-admitted");
}
diff --git a/Aetheris.Kernel.Firmament/Materializer/PrismaticProfileComposition.cs b/Aetheris.Kernel.Firmament/Materializer/PrismaticProfileComposition.cs
index 94018b1e..b3096956 100644
--- a/Aetheris.Kernel.Firmament/Materializer/PrismaticProfileComposition.cs
+++ b/Aetheris.Kernel.Firmament/Materializer/PrismaticProfileComposition.cs
@@ -427,7 +427,7 @@ public static class PrismaticProfileCompositionParser
// Other adapters still bind world supports and must fail closed.
foreach (var dependent in operationsSyntax.Document.Statements.OfType<DeclarationSyntax>()
.Where(d => d.Type.Name.Text is "Boss" or "Pocket" or "Hole" or "Slot" or "EdgeFinish")
- .Where(d => !IsAdmittedOrientedHole(d, compose.Name.Text)))
+ .Where(d => !IsAdmittedOrientedHole(d, compose.Name.Text) && !ProfileLongitudinalEdgeFinish.IsLongitudinal(d)))
diagnostics.Add($"compose-oriented-feature-not-admitted:{dependent.Type.Name.Text}:{dependent.Name?.Text}: Oriented Compose admits Base/Add/Remove, local +Z through shafts, and separated through shafts/counterbores/countersinks on qualified source Side faces; this feature needs another support adapter.");
}
if (stock is not null)
diff --git a/Aetheris.Kernel.Firmament/Materializer/ProfileLongitudinalEdgeFinish.cs b/Aetheris.Kernel.Firmament/Materializer/ProfileLongitudinalEdgeFinish.cs
new file mode 100644
index 00000000..b4773241
--- /dev/null
+++ b/Aetheris.Kernel.Firmament/Materializer/ProfileLongitudinalEdgeFinish.cs
@@ -0,0 +1,196 @@
+using Aetheris.Kernel.Firmament.FirmamentV2;
+using Aetheris.Kernel.Firmament.FirmamentV2.Syntax;
+
+namespace Aetheris.Kernel.Firmament.Materializer;
+
+/// <summary>Exact full-length finish of one polygon corner in an extruded profile.</summary>
+public static class ProfileLongitudinalEdgeFinish
+{
+ public const double Clearance = .01;
+ public static bool IsLongitudinal(DeclarationSyntax declaration) => declaration.Type.Name.Text == "EdgeFinish"
+ && declaration.Body?.Statements.OfType<FieldSyntax>().Any(f => (FirmamentSyntaxFields.SameField(f.Name.Text,"Face") || FirmamentSyntaxFields.SameField(f.Name.Text,"On"))
+ && FirmamentSyntaxValues.Reference(f.Value) == "Longitudinal") == true;
+ public static bool Requested(string source) => ProfileBoundaryChamferSourceBinder.FinishDeclarations(source).Any(IsLongitudinal);
+
+ public sealed record Result(ResolvedProfile2D? Profile, string? Name, string? Kind, string? Diagnostic, double Size = 0, string? Target = null, bool AddsMaterial = false);
+ public sealed record Batch(ResolvedProfile2D? Profile, IReadOnlyList<Result> Finishes, string? Diagnostic);
+ public static Batch ApplyAll(string source, ResolvedProfile2D profile, string body)
+ {
+ var declarations = ProfileBoundaryChamferSourceBinder.FinishDeclarations(source).ToArray();
+ if (declarations.Length > 0 && (profile.Loops.Count != 1 || !profile.Loops[0].IsOuter
+ || profile.Loops[0].Segments.Any(s => s.Geometry is not LineArcLineSegment2D)))
+ return new(null, [], "longitudinal-edge-finish: Start with a polygonal outer profile without inner loops.");
+ var results = new List<Result>();
+ var names = new HashSet<string>(StringComparer.Ordinal);
+ var targets = new HashSet<string>(StringComparer.Ordinal);
+ foreach (var declaration in declarations)
+ {
+ var finish = ApplyOne(source, declaration, profile, body);
+ if (finish.Profile is null) return new(null, results, finish.Diagnostic);
+ if (!names.Add(finish.Name!) || !targets.Add(finish.Target!))
+ return new(null, results, "longitudinal-edge-finish: Each finish needs a unique name and a different original corner.");
+ results.Add(finish);
+ profile = finish.Profile;
+ }
+ return new(profile, results, null);
+ }
+ public static Result Apply(string source, ResolvedProfile2D profile, string body)
+ {
+ var declarations = ProfileBoundaryChamferSourceBinder.FinishDeclarations(source).ToArray();
+ return declarations.Length == 1 ? ApplyOne(source, declarations[0], profile, body)
+ : new(null, null, null, "longitudinal-edge-finish: Expected one finish.");
+ }
+ private static Result ApplyOne(string source, DeclarationSyntax declaration, ResolvedProfile2D profile, string body)
+ {
+ Result Fail(string reason) => new(null, declaration.Name?.Text, null, "longitudinal-edge-finish:" + declaration.Name?.Text + ": " + reason);
+ var errors = new List<string>(); var fields = new FirmamentSyntaxFields(declaration, errors);
+ if (declaration.Name is null) return Fail("Give the edge finish a name.");
+ var receiver = FirmamentV2Parser.MechanicalDeclarations(FirmamentSyntaxParser.Parse(source).Document.Statements)
+ .SingleOrDefault(d => d.Type.Name.Text == "Modify" && d.Body?.Statements.OfType<DeclarationSyntax>().Any(f => f.Span == declaration.Span) == true);
+ if (receiver?.Name?.Text != body) return Fail("The selected edge must belong to the modified extrusion.");
+ var face = FirmamentSyntaxValues.Reference(fields.Take("Face") ?? fields.Take("On"));
+ var target = FirmamentSyntaxValues.Reference(fields.Take("Target"));
+ var kind = FirmamentSyntaxValues.Reference(fields.Take("Kind"));
+ var variant = declaration.Type.Arguments.Count == 1 ? FirmamentSyntaxValues.Reference(declaration.Type.Arguments[0].Value) : null;
+ if (declaration.Type.Arguments.Count > 1 || declaration.Type.Arguments.Count == 1 && variant is not ("Fillet" or "Chamfer")) return Fail("Use EdgeFinish<Fillet> or EdgeFinish<Chamfer>.");
+ if (kind is not null && variant is not null && kind != variant) return Fail("Kind must agree with the EdgeFinish variant.");
+ kind ??= variant;
+ var radius = fields.Take("Radius"); var distance = fields.Take("Distance");
+ if (radius is not null && distance is not null || kind is not ("Fillet" or "Chamfer") || face != "Longitudinal"
+ || kind == "Fillet" && radius is null || kind == "Chamfer" && distance is null
+ || !FirmamentSyntaxValues.TryMeasure(radius ?? distance, "mm", out var amount) || !double.IsFinite(amount) || amount < Clearance)
+ return Fail("Use a fillet Radius or chamfer Distance of at least 0.01 mm, and Face: Longitudinal.");
+ fields.Complete(); if (errors.Count != 0) return Fail(string.Join("; ", errors));
+ var parts = target?.Split('.') ?? [];
+ if (parts.Length != 4 || parts[0] != profile.Name || parts[1] != "Outer" || parts[3] != "Start") return Fail("Select one source-owned longitudinal corner edge.");
+ if (profile.Loops.Count != 1 || !profile.Loops[0].IsOuter || profile.Loops[0].Segments.Any(s => s.Geometry is not (LineArcLineSegment2D or LineArcCircularArc2D)))
+ return Fail("Full-length corner finishes currently require a single polygonal outer profile without inner loops.");
+ var loop = profile.Loops[0]; var segments = loop.Segments.ToArray();
+ if (segments.Count(s => s.Name == parts[2]) != 1) return Fail("The selected corner is missing or ambiguous in this profile.");
+ var index = Array.FindIndex(segments, s => s.Name == parts[2]);
+ if (index < 0) return Fail("The selected corner no longer exists in this profile.");
+ var previousIndex = (index + segments.Length - 1) % segments.Length;
+ if (segments[previousIndex].Geometry is not LineArcLineSegment2D || segments[index].Geometry is not LineArcLineSegment2D)
+ return Fail("This corner is already finished or is curved. Choose a different straight-sided corner.");
+ var classification = ProfileJunctionClassifier.Classify(profile, loop).Single(j => j.SuccessorSegmentId == parts[2]).Classification;
+ if (classification is not (ProfileJunctionKind.ConvexProfileJunction or ProfileJunctionKind.ReflexProfileJunction)) return Fail("Select a nondegenerate corner between two straight sides.");
+ var previous = (LineArcLineSegment2D)segments[previousIndex].Geometry;
+ var next = (LineArcLineSegment2D)segments[index].Geometry;
+ LineArcProfileCurve2D replacement;
+ if (kind == "Fillet")
+ {
+ var round = ProfileCornerRound.TryRound(previous, next, amount, out var reason);
+ if (round is null) return Fail(reason ?? "This corner cannot be rounded.");
+ previous = (LineArcLineSegment2D)round.Previous; next = (LineArcLineSegment2D)round.Next; replacement = round.Arc;
+ }
+ else
+ {
+ var a = Length(previous); var b = Length(next);
+ if (Math.Min(a, b) - amount < Clearance) return Fail("The distance consumes an adjacent edge. Leave at least 0.01 mm of straight edge.");
+ var start = (X: previous.End.X + (previous.Start.X - previous.End.X) * amount / a, Y: previous.End.Y + (previous.Start.Y - previous.End.Y) * amount / a);
+ var end = (X: next.Start.X + (next.End.X - next.Start.X) * amount / b, Y: next.Start.Y + (next.End.Y - next.Start.Y) * amount / b);
+ previous = previous with { End = start }; next = next with { Start = end }; replacement = new LineArcLineSegment2D(start, end);
+ }
+ if (Math.Min(Length(previous), Length(next)) < Clearance) return Fail("The size consumes an adjacent edge. Leave at least 0.01 mm of straight edge.");
+ foreach (var other in segments.Where((_, i) => i != index && i != previousIndex).Select(s => s.Geometry))
+ if (CurveDistance(replacement, other) < Clearance - 1e-8) return Fail("The finish reaches another boundary or finish. Reduce its size to retain at least 0.01 mm clearance.");
+ segments[previousIndex] = segments[previousIndex] with { Geometry = previous };
+ segments[index] = segments[index] with { Geometry = next };
+ var name = declaration.Name!.Text;
+ var added = new ResolvedProfileSegment2D(name, replacement,
+ new("edgefinish:" + name, profile.Name, $"offset:{declaration.Span.Start}", "FullLength" + kind, profile.PlaneFrame));
+ var result = profile with { Loops = [loop with { Segments = segments.Take(index).Concat([added]).Concat(segments.Skip(index)).ToArray() }] };
+ var validation = ResolvedProfile2DValidator.Validate(result);
+ return validation.IsValid ? new(result, name, kind, null, amount, target, classification == ProfileJunctionKind.ReflexProfileJunction) : Fail(string.Join("; ", validation.Diagnostics));
+ }
+
+ private static double Length(LineArcLineSegment2D l) => Hypot(l.End.X - l.Start.X, l.End.Y - l.Start.Y);
+ private static double CurveDistance(LineArcProfileCurve2D a, LineArcProfileCurve2D b)
+ {
+ if (b is LineArcLineSegment2D line) return Distance(a, line);
+ if (a is LineArcLineSegment2D otherLine) return Distance(b, otherLine);
+ var first = (LineArcCircularArc2D)a; var second = (LineArcCircularArc2D)b;
+ var candidates = new List<double>();
+ foreach (var p in new[] { At(first, first.StartAngleRadians), At(first, first.StartAngleRadians + first.SweepAngleRadians) }) candidates.Add(PointArc(p, second));
+ foreach (var p in new[] { At(second, second.StartAngleRadians), At(second, second.StartAngleRadians + second.SweepAngleRadians) }) candidates.Add(PointArc(p, first));
+ var dx = second.Center.X - first.Center.X; var dy = second.Center.Y - first.Center.Y; var centers = Hypot(dx, dy);
+ if (centers > 1e-12)
+ {
+ var angle = Math.Atan2(dy, dx);
+ foreach (var signA in new[] { 0d, Math.PI }) foreach (var signB in new[] { 0d, Math.PI })
+ {
+ var p = At(first, angle + signA); var q = At(second, angle + signB);
+ if (InArc(p, first) && InArc(q, second)) candidates.Add(Hypot(p.X - q.X, p.Y - q.Y));
+ }
+ var along = (first.Radius * first.Radius - second.Radius * second.Radius + centers * centers) / (2 * centers);
+ var height2 = first.Radius * first.Radius - along * along;
+ if (height2 >= -1e-10)
+ {
+ foreach (var sign in new[] { -1d, 1d })
+ {
+ var h = sign * Math.Sqrt(Math.Max(0, height2));
+ var p = (X: first.Center.X + (along * dx - h * dy) / centers, Y: first.Center.Y + (along * dy + h * dx) / centers);
+ if (InArc(p, first) && InArc(p, second)) return 0;
+ }
+ }
+ }
+ return candidates.Min();
+ }
+ private static (double X, double Y) At(LineArcCircularArc2D arc, double angle) => (arc.Center.X + arc.Radius * Math.Cos(angle), arc.Center.Y + arc.Radius * Math.Sin(angle));
+ private static bool InArc((double X, double Y) p, LineArcCircularArc2D arc)
+ {
+ var angle = Math.Atan2(p.Y - arc.Center.Y, p.X - arc.Center.X) - arc.StartAngleRadians;
+ angle = arc.SweepAngleRadians > 0 ? (angle % (2 * Math.PI) + 2 * Math.PI) % (2 * Math.PI) : -((-angle % (2 * Math.PI) + 2 * Math.PI) % (2 * Math.PI));
+ return Math.Abs(angle) <= Math.Abs(arc.SweepAngleRadians) + 1e-8;
+ }
+ private static double PointArc((double X, double Y) p, LineArcCircularArc2D arc)
+ {
+ if (InArc(p, arc)) return Math.Abs(Hypot(p.X - arc.Center.X, p.Y - arc.Center.Y) - arc.Radius);
+ var start = At(arc, arc.StartAngleRadians); var end = At(arc, arc.StartAngleRadians + arc.SweepAngleRadians);
+ return Math.Min(Hypot(p.X - start.X, p.Y - start.Y), Hypot(p.X - end.X, p.Y - end.Y));
+ }
+ private static double Hypot(double x, double y) => Math.Sqrt(x*x + y*y);
+ private static double PointLine((double X, double Y) p, LineArcLineSegment2D l)
+ {
+ var dx = l.End.X-l.Start.X; var dy = l.End.Y-l.Start.Y;
+ var t = Math.Clamp(((p.X-l.Start.X)*dx+(p.Y-l.Start.Y)*dy)/(dx*dx+dy*dy),0,1);
+ return Hypot(p.X-l.Start.X-t*dx,p.Y-l.Start.Y-t*dy);
+ }
+ private static double Distance(LineArcProfileCurve2D curve, LineArcLineSegment2D line)
+ {
+ if (curve is LineArcLineSegment2D chord)
+ {
+ var ax=chord.End.X-chord.Start.X; var ay=chord.End.Y-chord.Start.Y;
+ var bx=line.End.X-line.Start.X; var by=line.End.Y-line.Start.Y; var cross=ax*by-ay*bx;
+ if (Math.Abs(cross)>1e-12) {
+ var deltaX=line.Start.X-chord.Start.X; var deltaY=line.Start.Y-chord.Start.Y;
+ var t=(deltaX*by-deltaY*bx)/cross; var u=(deltaX*ay-deltaY*ax)/cross;
+ if (t>=0 && t<=1 && u>=0 && u<=1) return 0;
+ }
+ return new[] { PointLine(chord.Start,line),PointLine(chord.End,line),PointLine(line.Start,chord),PointLine(line.End,chord) }.Min();
+ }
+ var arc=(LineArcCircularArc2D)curve;
+ (double X,double Y) At(double a)=>(arc.Center.X+arc.Radius*Math.Cos(a),arc.Center.Y+arc.Radius*Math.Sin(a));
+ bool InArc((double X,double Y) p) {
+ var a=Math.Atan2(p.Y-arc.Center.Y,p.X-arc.Center.X)-arc.StartAngleRadians;
+ a=arc.SweepAngleRadians>0 ? (a%(2*Math.PI)+2*Math.PI)%(2*Math.PI) : -((-a%(2*Math.PI)+2*Math.PI)%(2*Math.PI));
+ return Math.Abs(a)<=Math.Abs(arc.SweepAngleRadians)+1e-8;
+ }
+ var start=At(arc.StartAngleRadians); var end=At(arc.StartAngleRadians+arc.SweepAngleRadians);
+ double PointArc((double X,double Y) p)=>InArc(p)?Math.Abs(Hypot(p.X-arc.Center.X,p.Y-arc.Center.Y)-arc.Radius)
+ : Math.Min(Hypot(p.X-start.X,p.Y-start.Y),Hypot(p.X-end.X,p.Y-end.Y));
+ var minimum=new[] { PointLine(start,line),PointLine(end,line),PointArc(line.Start),PointArc(line.End) }.Min();
+ var dx=line.End.X-line.Start.X; var dy=line.End.Y-line.Start.Y; var length2=dx*dx+dy*dy;
+ var fx=line.Start.X-arc.Center.X; var fy=line.Start.Y-arc.Center.Y;
+ var b=2*(fx*dx+fy*dy); var c=fx*fx+fy*fy-arc.Radius*arc.Radius; var disc=b*b-4*length2*c;
+ if(disc>=0) foreach(var t in new[]{(-b-Math.Sqrt(disc))/(2*length2),(-b+Math.Sqrt(disc))/(2*length2)})
+ if(t>=0 && t<=1 && InArc((line.Start.X+t*dx,line.Start.Y+t*dy))) return 0;
+ var length=Math.Sqrt(length2);
+ foreach(var sign in new[]{-1d,1d}) {
+ var p=(X:arc.Center.X+sign*arc.Radius*(-dy)/length,Y:arc.Center.Y+sign*arc.Radius*dx/length);
+ var t=((p.X-line.Start.X)*dx+(p.Y-line.Start.Y)*dy)/length2;
+ if(t>=0 && t<=1 && InArc(p)) minimum=Math.Min(minimum,PointLine(p,line));
+ }
+ return minimum;
+ }
+}
diff --git a/Aetheris.Kernel.Firmament/Materializer/SemanticTopologySelections.cs b/Aetheris.Kernel.Firmament/Materializer/SemanticTopologySelections.cs
index dcc5115f..5f53016a 100644
--- a/Aetheris.Kernel.Firmament/Materializer/SemanticTopologySelections.cs
+++ b/Aetheris.Kernel.Firmament/Materializer/SemanticTopologySelections.cs
@@ -7,7 +7,7 @@ using Aetheris.Semantics;
namespace Aetheris.Kernel.Firmament.Materializer;
/// <summary>Stable roles assigned while an authoritative plan is materialized. These are not geometric queries.</summary>
-public enum SemanticTopologyRole { Unknown, ProfileVertex, VerticalExtrusionEdge, LocalStartBoundary, LocalEndBoundary, LocalStartCapLoop, LocalEndCapLoop, TopBoundary, BottomBoundary, ExtrusionSideFace, TopFaceBoundaryLoop, BottomFaceBoundaryLoop, HoleEntryLoop, HoleExitLoop, HoleWallFace, HoleShaftToDrillPointLoop, HoleShaftToDrillPointEdge, HoleDrillPointFace, HoleTipVertex, HoleCounterboreMouthLoop, HoleCounterboreWallFace, HoleCounterboreShoulderLoop, HoleCounterboreShaftWallFace, SlotEntryLoop, SlotExitLoop, SlotWallFace, SlotStraightWallFace, SlotEndWallFace, ComposeTransition, EdgeFinishReplacementFace, FilletSurface, ConvexJunctionPatch, ReflexJunctionPatch, CapContactEdge, SideContactEdge, JunctionToRollA, JunctionToRollB, JunctionCapContact, JunctionSideAContact, JunctionSideBContact, StartTerminationFace, EndTerminationFace, StartEndpointArc, EndEndpointArc, RetainedStartSharpEdge, RetainedEndSharpEdge, BoxFace, BoxEdge, ThreadRootFace, ThreadLeadingFlank, ThreadTrailingFlank, ThreadCrest, ThreadStartCap, ThreadEndCap, ThreadBoundaryEdge, HoleCountersinkWallFace, PathFeatureFace, HoleCounterboreShoulderFace }
+public enum SemanticTopologyRole { Unknown, ProfileVertex, VerticalExtrusionEdge, LocalStartBoundary, LocalEndBoundary, LocalStartCapLoop, LocalEndCapLoop, TopBoundary, BottomBoundary, ExtrusionSideFace, TopFaceBoundaryLoop, BottomFaceBoundaryLoop, HoleEntryLoop, HoleExitLoop, HoleWallFace, HoleShaftToDrillPointLoop, HoleShaftToDrillPointEdge, HoleDrillPointFace, HoleTipVertex, HoleCounterboreMouthLoop, HoleCounterboreWallFace, HoleCounterboreShoulderLoop, HoleCounterboreShaftWallFace, SlotEntryLoop, SlotExitLoop, SlotWallFace, SlotStraightWallFace, SlotEndWallFace, ComposeTransition, EdgeFinishReplacementFace, FilletSurface, ConvexJunctionPatch, ReflexJunctionPatch, CapContactEdge, SideContactEdge, JunctionToRollA, JunctionToRollB, JunctionCapContact, JunctionSideAContact, JunctionSideBContact, StartTerminationFace, EndTerminationFace, StartEndpointArc, EndEndpointArc, RetainedStartSharpEdge, RetainedEndSharpEdge, BoxFace, BoxEdge, ThreadRootFace, ThreadLeadingFlank, ThreadTrailingFlank, ThreadCrest, ThreadStartCap, ThreadEndCap, ThreadBoundaryEdge, HoleCountersinkWallFace, PathFeatureFace, HoleCounterboreShoulderFace, ConvexLongitudinalEdge, ReflexLongitudinalEdge }
public enum SemanticTopologyAddressability { AuthoredStable, DerivedStable, ImportedStable, RuntimeOnly, Ambiguous, Unstable }
public enum SemanticSelectionRequirement { ExactlyOne, OneOrMore, ConnectedChain, ClosedLoop, NonEmptyFaceSet }
public enum SemanticSelectionFailure { None, SemanticSourceNotFound, NoMaterializedDescendants, AmbiguousBodyContext, SelectionCardinalityMismatch, DescendantsNotConnected, DescendantsBranch, DescendantsDoNotClose, MixedBoundaryRoles, UnsupportedTopologyChange, SelectionConsumerMismatch }
@@ -21,7 +21,9 @@ public sealed record SemanticTopologyDescendant(
SemanticTopologyAddressability Addressability = SemanticTopologyAddressability.RuntimeOnly,
// Producers may retain a construction origin alongside a more specific feature
// owner of the same entity. Aliases remain queryable but do not own viewport picks.
- bool IsTopologyAlias = false);
+ bool IsTopologyAlias = false,
+ // Authored side coordinates remain anchored to the untrimmed construction face.
+ double[]? SupportOrigin = null);
public sealed record SemanticTopologyCorrespondence(
string BodyStableId,
diff --git a/Aetheris.Kernel.Firmament/Materializer/SingleEdgeFinishSelection.cs b/Aetheris.Kernel.Firmament/Materializer/SingleEdgeFinishSelection.cs
new file mode 100644
index 00000000..abfec921
--- /dev/null
+++ b/Aetheris.Kernel.Firmament/Materializer/SingleEdgeFinishSelection.cs
@@ -0,0 +1,48 @@
+using System.Text.RegularExpressions;
+using Aetheris.Kernel.Core.Topology;
+
+namespace Aetheris.Kernel.Firmament.Materializer;
+
+/// <summary>A compiler-owned EdgeFinish binding for exactly one construction edge.</summary>
+public sealed record SingleEdgeFinishSelection(string Body, string Face, string Target, string Label, bool FilletSupported = true)
+{
+ public static string? UnavailableReason(SemanticTopologyCorrespondence correspondence) => correspondence.ProvenanceChain.Contains("PlanarFaceThroughHole")
+ && !correspondence.ProvenanceChain.Contains("ProfileCornerFinishHost")
+ ? "Full-length corner finishes on a body with picked-face holes are not supported yet. The current geometry and source are unchanged." : null;
+ public static SingleEdgeFinishSelection? Resolve(SemanticTopologyCorrespondence correspondence, EdgeId edge)
+ => Index(correspondence).GetValueOrDefault(edge);
+
+ public static IReadOnlyDictionary<EdgeId, SingleEdgeFinishSelection> Index(SemanticTopologyCorrespondence correspondence)
+ {
+ var output = new Dictionary<EdgeId, SingleEdgeFinishSelection>();
+ var boundaries = correspondence.Descendants.Where(d => d.Edge is not null)
+ .Where(d => d.Role is SemanticTopologyRole.TopBoundary or SemanticTopologyRole.LocalEndBoundary
+ or SemanticTopologyRole.BottomBoundary or SemanticTopologyRole.LocalStartBoundary)
+ .Select(d => (Edge: d.Edge!.Value, d.SourceStableId, Face: d.Role is SemanticTopologyRole.TopBoundary or SemanticTopologyRole.LocalEndBoundary ? "Top" : "Bottom"))
+ .Distinct().ToArray();
+ var counts = boundaries.GroupBy(d => (d.SourceStableId, d.Face)).ToDictionary(g => g.Key, g => g.Select(d => d.Edge).Distinct().Count());
+ foreach (var group in boundaries.GroupBy(d => d.Edge))
+ {
+ // Cap finishes need a separate combined-history planner. Do not
+ // advertise that route on the side-hole host.
+ if (correspondence.ProvenanceChain.Contains("ProfileCornerFinishHost")
+ && correspondence.ProvenanceChain.Contains("PlanarFaceThroughHole")) continue;
+ var candidates = group.ToArray();
+ if (candidates.Length != 1) continue;
+ var (_, source, face) = candidates[0];
+ if (!Regex.IsMatch(source, @"^profile:[A-Za-z_]\w*\.Outer\.[A-Za-z_]\w*$", RegexOptions.CultureInvariant)) continue;
+ // A split descendant is only part of a source segment. Never promote it to a whole segment or chain.
+ if (counts[(source, face)] != 1) continue;
+ var target = source["profile:".Length..];
+ output[group.Key] = new(correspondence.BodyStableId, face, target, "Extrusion end-face edge", FilletSupported: false);
+ }
+ foreach (var edge in correspondence.Descendants.Where(d => d.Edge is not null && d.Role is SemanticTopologyRole.ConvexLongitudinalEdge or SemanticTopologyRole.ReflexLongitudinalEdge))
+ output[edge.Edge!.Value] = new(correspondence.BodyStableId, "Longitudinal", edge.SourceStableId["profile:".Length..] + ".Start",
+ edge.Role == SemanticTopologyRole.ReflexLongitudinalEdge ? "Inside bend · full length" : "Outside corner · full length");
+ // The existing localized Box route owns this exact face pair.
+ foreach (var edge in correspondence.Descendants.Where(d => d.Edge is not null && d.Role == SemanticTopologyRole.BoxEdge
+ && d.StableId == $"{correspondence.BodyStableId}.edge(TopRight)"))
+ output[edge.Edge!.Value] = new(correspondence.BodyStableId, "+X", "SharedEdgePlusZ", "Shared edge · +X / +Z");
+ return output;
+ }
+}
diff --git a/Aetheris.Web.Runtime/Program.cs b/Aetheris.Web.Runtime/Program.cs
index 0a0f158f..5d77e992 100644
--- a/Aetheris.Web.Runtime/Program.cs
+++ b/Aetheris.Web.Runtime/Program.cs
@@ -868,6 +868,8 @@ internal static class WebMeshBuilder
var mapPhase = BuildPerfTrace.Phase("web.mesh-source-map-and-arrays");
var positions = new List<double>(); var normals = new List<double>(); var indices = new List<int>(); var ranges = new List<object>();
var sourceMap = correspondence is null ? null : new Aetheris.Kernel.Firmament.Materializer.GeometrySourceMap(correspondence);
+ var edgeFinishes = correspondence is null ? null : Aetheris.Kernel.Firmament.Materializer.SingleEdgeFinishSelection.Index(correspondence);
+ var edgeFinishReason = correspondence is null ? null : Aetheris.Kernel.Firmament.Materializer.SingleEdgeFinishSelection.UnavailableReason(correspondence);
foreach (var face in tessellation.Value.FacePatches.OrderBy(face => face.FaceId.Value))
{
var vertexOffset = positions.Count / 3; var triangleStart = indices.Count / 3;
@@ -886,7 +888,7 @@ internal static class WebMeshBuilder
selector = imported is not null ? $"{importedBodyName}.face(\"#{imported}\")" : semanticFace?.FirmamentSelector,
surfaceKind = surface?.Kind.ToString(), diameterMm = surface?.Cylinder is { } cylinder ? (double?)(2 * cylinder.Radius) : null,
support = semanticFace?.FirmamentSelector?.Contains(".Side(", StringComparison.Ordinal) == true
- ? Aetheris.Kernel.Firmament.Materializer.PlanarFaceThroughHole.Support(body, face.FaceId) : null,
+ ? Aetheris.Kernel.Firmament.Materializer.PlanarFaceThroughHole.Support(body, face.FaceId, semanticFace.SupportOrigin) : null,
selectorReason = imported is not null ? null : semanticFace is null ? "No compiler-owned source topology mapping is available for this display face."
: semanticFace.FirmamentSelector is null ? "Construction identity is known, but Firmament has no qualified source selector for this topology." : null,
source = semanticFace is null ? null : faceSource, buildRevision });
@@ -917,6 +919,8 @@ internal static class WebMeshBuilder
return new { edgeId = $"edge:{edge.EdgeId.Value}", points = edge.Points.Select(point => new[] { point.X, point.Y, point.Z }).ToArray(), closed = edge.IsClosed,
semanticEntityId = owner, semanticTopologyId = semanticEdge?.StableId, topologyKind = "Edge", outputRole = semanticEdge?.Role.ToString(), originFeature = semanticEdge?.SourceStableId,
sourceAddressability = semanticEdge?.Addressability.ToString() ?? "RuntimeOnly", selector = semanticEdge?.FirmamentSelector,
+ edgeFinish = edgeFinishes?.GetValueOrDefault(edge.EdgeId),
+ edgeFinishReason = edgeFinishes?.ContainsKey(edge.EdgeId) == true ? null : edgeFinishReason,
selectorReason = semanticEdge is null ? "Display BRep edge has no construction-owned source correspondence."
: semanticEdge.FirmamentSelector is null ? "Construction identity is known, but Firmament has no qualified source selector for this edge." : null,
source = semanticEdge is null ? null : owner == entityId ? source : featureSources![owner], buildRevision };
diff --git a/Aetheris.Web.Runtime/sdk/src/index.d.ts b/Aetheris.Web.Runtime/sdk/src/index.d.ts
index a1f18915..0b1d9e10 100644
--- a/Aetheris.Web.Runtime/sdk/src/index.d.ts
+++ b/Aetheris.Web.Runtime/sdk/src/index.d.ts
@@ -34,6 +34,12 @@ export interface MeshRange { readonly surfaceKind?: string | null; readonly diam
export interface SelectionDescription { readonly surfaceKind?: string | null; readonly diameterMm?: number | null }
export interface PlanarFaceSupport { readonly origin: readonly number[]; readonly x: readonly number[]; readonly y: readonly number[]; readonly normal: readonly number[]; readonly boundary: readonly (readonly number[])[]; readonly excludedDisks?: readonly { readonly center: readonly number[]; readonly radius: number }[] }
export interface SelectionDescription { readonly support?: PlanarFaceSupport | null }
+/** Exactly one source-owned edge. Admission and positive dimensions are checked by Preview. */
+export interface SingleEdgeFinishSelection { readonly body: string; readonly face: string; readonly target: string; readonly label: string; readonly filletSupported?: boolean }
+export interface SelectionDescription { readonly edgeFinish?: SingleEdgeFinishSelection | null }
+export interface SelectionDescription { readonly edgeFinishReason?: string | null }
+export interface DisplayEdgePolyline { readonly edgeFinish?: SingleEdgeFinishSelection | null }
+export interface DisplayEdgePolyline { readonly edgeFinishReason?: string | null }
export interface MeshRange { readonly support?: PlanarFaceSupport | null }
export interface DisplayMesh { readonly importedAsset?: { readonly path: string; readonly sha256: string; readonly evidence: string; readonly qualification: { readonly status: string; readonly geometryStatus: string } | null } | null }
export interface ChangeSet { readonly changedEntityIds: readonly string[]; readonly addedEntityIds: readonly string[]; readonly removedEntityIds: readonly string[]; readonly meshChanged: boolean; readonly diagnosticsChanged: boolean }
diff --git a/Aetheris.Web.Runtime/sdk/src/index.js b/Aetheris.Web.Runtime/sdk/src/index.js
index 02d81d45..01f5cc27 100644
--- a/Aetheris.Web.Runtime/sdk/src/index.js
+++ b/Aetheris.Web.Runtime/sdk/src/index.js
@@ -212,7 +212,7 @@ export class ModelSession {
semanticTopologyId: range.semanticTopologyId ?? null, topologyKind: range.topologyKind ?? 'Face', outputRole: range.outputRole ?? null, originFeature: range.originFeature ?? null,
selector: range.selector ?? null, sourceAddressability: range.sourceAddressability ?? 'RuntimeOnly',
surfaceKind: range.surfaceKind ?? null, diameterMm: range.diameterMm ?? null,
- support: occurrence.transform.every((v, i) => Math.abs(v - (i % 5 === 0 ? 1 : 0)) < 1e-9) ? range.support ?? null : null,
+ support: (!occurrence.transform || occurrence.transform.every((v, i) => Math.abs(v - (i % 5 === 0 ? 1 : 0)) < 1e-9)) ? range.support ?? null : null,
selectorReason: range.selectorReason ?? null, source: range.source ?? null, buildRevision: range.buildRevision ?? this.revision } : null;
}
describeSelection(definitionId, triangleIndex, occurrenceId) {
@@ -229,6 +229,8 @@ export class ModelSession {
return { semanticEntityId: edge.semanticEntityId ?? occurrence.semanticEntityId, faceId: edge.edgeId, occurrenceId: occurrence.id, definitionId,
semanticTopologyId: edge.semanticTopologyId ?? null, topologyKind: 'Edge', outputRole: edge.outputRole ?? null, originFeature: edge.originFeature ?? null,
selector: edge.selector ?? null, sourceAddressability: edge.sourceAddressability ?? 'RuntimeOnly',
+ edgeFinish: (!occurrence.transform || occurrence.transform.every((v, i) => Math.abs(v - (i % 5 === 0 ? 1 : 0)) < 1e-9)) ? edge.edgeFinish ?? null : null,
+ edgeFinishReason: edge.edgeFinishReason ?? null,
selectorReason: edge.selectorReason ?? 'This edge has no qualified Firmament source selector.',
source: edge.source ?? null, buildRevision: edge.buildRevision ?? this.revision,
sourceAddressable: edge.source != null && ['AuthoredStable', 'DerivedStable'].includes(edge.sourceAddressability) };
diff --git a/Aetheris.Web.Runtime/sdk/tests/selection.test.mjs b/Aetheris.Web.Runtime/sdk/tests/selection.test.mjs
index c80d55dc..b68407a1 100644
--- a/Aetheris.Web.Runtime/sdk/tests/selection.test.mjs
+++ b/Aetheris.Web.Runtime/sdk/tests/selection.test.mjs
@@ -78,6 +78,19 @@ test('BRep edges preserve construction metadata without inventing source selecto
assert.equal(session.geometrySourceMap().filter(item => item.topologyKind === 'Edge').length, 2);
});
+test('single-edge finish bindings survive picking only in their owning identity occurrence', () => {
+ const edgeFinish = { body: 'Body', face: 'Bottom', target: 'Section.Outer.South', label: 'Extrusion end-face edge', filletSupported: false };
+ const identity = [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];
+ const shifted = [...identity]; shifted[12] = 10;
+ const session = new ModelSession({}, { mesh: {
+ definitions: [{ id: 'part', ranges: [], edges: [{ edgeId: 'edge:1', points: [[0,0,0],[20,0,0]], closed: false, edgeFinish }] }],
+ occurrences: [{ id: 'local', definitionId: 'part', transform: identity }, { id: 'placed', definitionId: 'part', transform: shifted }],
+ } });
+ assert.deepEqual(session.describeEdgeSelection('part', 'edge:1', 'local').edgeFinish, edgeFinish);
+ assert.equal(session.describeEdgeSelection('part', 'edge:1', 'placed').edgeFinish, null);
+ assert.equal(session.describeEdgeSelection('part', 'edge:99', 'local'), null);
+});
+
test('a feature face keeps its owner inside a body occurrence', () => {
const source = { source: 'hole.firmament', line: 4, column: 2, start: 65, length: 94 };
const session = new ModelSession({}, { mesh: {
diff --git a/docs/development/reports/2026-11/helios-bracket-edge-bends.md b/docs/development/reports/2026-11/helios-bracket-edge-bends.md
new file mode 100644
index 00000000..93ed153b
--- /dev/null
+++ b/docs/development/reports/2026-11/helios-bracket-edge-bends.md
@@ -0,0 +1,76 @@
+# Helios bracket edge selection and full-length bend finishes
+
+## Problem and correction
+
+Picking an edge tinted its whole occurrence gold, obscuring which edge was
+selected. The old UI advertised an inset fillet on an extrusion cap while the
+bracket's inside bend was unavailable. That local cap blend produced short
+terminations and did not provide the expected full-width corner finish.
+
+The viewport now highlights only the selected occurrence's edge: a thick gold
+line with a translucent halo, with cyan hover feedback. The body remains in
+ordinary shading. Both Telos and WebGL selection paths carry occurrence identity.
+
+The compiler publishes source-correspondent convex and reflex profile corners
+as longitudinal edge bindings. Helios labels these Outside corner / Inside
+bend, full length. Selecting the bracket crease in Iso and applying a 2 mm
+fillet creates one exact concave cylindrical surface through the 20 mm width.
+The corresponding chamfer creates one planar surface. Outside corners use the
+same route with the opposite material effect.
+
+## Geometry and source transaction
+
+`EdgeFinish` with `Face: Longitudinal` and a source target such as
+`section.Outer.Vertex3_Vertex4.Start` modifies one polygon corner before exact
+profile extrusion. The materializer uses tangent circular arcs for fillets and
+equal-distance trimmed legs for chamfers. It does not approximate a fillet with
+a mesh or invoke a general surface/surface Boolean. The feature preserves source
+provenance and contributes engineering metadata to the model tree.
+
+At least 0.01 mm must remain on adjacent legs and between the new curve and all
+nonadjacent boundaries. Exact arc/line distance and intersection checks reject
+crossings, tangencies and slivers. Invalid sizes and anonymous or misspelled
+feature fields produce diagnostics. Preview does not edit source; Apply commits
+one undoable edit. STEP reimport is checked for closed oriented topology.
+
+## Scope
+
+- One finish on one straight-sided polygon outer corner per profile extrusion.
+- Inside and outside longitudinal corners; XY, YZ and XZ profile planes.
+- Cap-edge chamfer remains available. The legacy explicit inset cap-fillet
+ source route remains readable, but the UI disables it because a full-edge
+ cap fillet is not implemented.
+- Existing Box +X/+Z single-edge routes remain available.
+- Curved profile corners, imported bodies, profiles with inner loops and
+ multiple finishes are outside this route.
+- Picked-face holes and longitudinal finishes still lack a combined-history
+ adapter. Both actions are disabled with a specific explanation on that body;
+ accepted geometry and source remain intact.
+- Delete or undo the earlier cap-fillet demo before trying the new bend.
+
+## Verification
+
+- 3,531 Firmament tests and 760 CLI tests passed.
+- 29 focused native cases passed, including 15 longitudinal cases. Independent
+ analytic area checks verify inside addition and outside removal, cylinder
+ radius, full extrusion bounds, all three profile planes, clearance rejection,
+ engineering metadata and closed oriented STEP round trips.
+- Development-browser UI tests passed for inside fillet, inside chamfer,
+ outside fillet, and the disabled end-face fillet. Tests click projected model
+ coordinates in the real viewport and use compiler-projected selection data.
+- Production AOT built successfully. Native WASM is 60,431,161 decoded bytes,
+ SHA-256 `799fc770b7216a16b89c487c2197be52c1cafaf07cfeecab56ec09f7b1b36f6d`.
+- All 24 production graph workflows passed their final checks: the initial
+ suite passed 22, with two new hierarchy assertions using the wrong ARIA role;
+ after changing `row` to `treeitem`, both affected complete workflows passed.
+ Those workflows verify actual picks, one-edge/no-body highlighting, automatic
+ preview, Apply, model hierarchy, source, STEP analysis, undo and redo.
+- Five focused production WebGL cases passed: inside fillet/chamfer, outside
+ fillet with invalid-size recovery, disabled cap fillet and holed-body refusal.
+- All 251 Helios unit tests and six SDK selection tests passed. TypeScript,
+ the production frontend build and both repositories' `git diff --check` passed.
+- Hosted verification is recorded with the deployed build evidence.
+
+The deployment includes complete working-tree patches against the published
+Helios and Aetheris baselines. Owning repositories are not committed or pushed
+by this task.
diff --git a/docs/development/reports/2026-11/helios-bracket-edge-robustness.md b/docs/development/reports/2026-11/helios-bracket-edge-robustness.md
new file mode 100644
index 00000000..142bd0be
--- /dev/null
+++ b/docs/development/reports/2026-11/helios-bracket-edge-robustness.md
@@ -0,0 +1,97 @@
+# Bracket edge finish robustness
+
+## Changes
+
+Longitudinal fillets/chamfers now combine on different original polygon corners
+and with separated source-side mounting shafts, counterbores and countersinks
+on both bracket legs. The same exact profile plan owns the finished host and is
+adapted to the existing planar side-hole planner. General Compose histories
+are not flattened or approximated.
+
+Original construction-face origins travel with topology correspondence. A corner
+trim changes the remaining support boundary but does not move existing hole
+coordinates. The adapter carries the Base axial interval explicitly, avoiding
+the profile emitter's centered compatibility default. Hole metadata uses one
+tree reporting path, with separate engineering metadata for each finish.
+
+The WebGL fallback now ranks visible edge candidates by screen distance within
+an eight-pixel picking radius instead of taking the first depth-sorted line in
+a broad world-space tolerance. Picking updates camera/occurrence matrices before
+the next render. Placement gestures retain their pointer-down support instead
+of consulting a possibly stale previous-face guide at pointer-up. A regression
+test holds the old guide throughout a new-face gesture and verifies both points
+remain on the newly picked face. Upright recess placement passed three repeated
+WebGL runs during diagnosis.
+
+The authoring panel also retains a first face/point pick until compiler-projected
+diameter fields are ready. A click during asynchronous outline loading no longer
+tries to fit a NaN diameter and loses the intended center. A second regression
+test delays the outline response and proves the original picked point is placed
+with the compiler's 8 mm recess envelope when it arrives.
+
+Admission requires finish size >=0.01 mm, >=0.01 mm on adjacent legs and between
+new curves and all other boundaries/finishes. Analytic line/arc and arc/arc
+distance checks include crossings and tangencies. A repeated original corner
+is refused. Side-hole admission checks the full recess/shaft envelope, remaining
+planar entry/exit supports, other cavity envelopes and a conservative finite
+corridor. Corridor circle bounds now honor their actual arc trims. Failed
+previews preserve accepted geometry/source and keep Apply disabled.
+
+## Evidence
+
+- 67 focused native cases passed, including 23 new robustness cases. All six
+ original bracket corners can be rounded independently. Mixed inside/outside
+ fillets and chamfers work; adjacent finishes consuming the 3 mm leg fail.
+- Shaft/recess clearances are checked at 0.01 mm, tangency and overlap. Existing
+ mounting cylinder origins/axes remain unchanged after a bend. Both native
+ bodies and STEP reimports pass closed/oriented checks. The mixed-recess fixture
+ also matches an independently calculated analytic volume.
+- All 3,554 Firmament tests passed after fixing the integration regressions.
+- The real UI sequence passed in development: add a mounting hole, refuse a
+ colliding bend without source changes, apply a 2 mm inside fillet and a 0.5 mm
+ outside chamfer, add another hole in the preserved face frame, export STEP,
+ and undo/redo. The final production workflow also exercises an adjacent
+ outside fillet and a shared-edge collapse refusal.
+- Real CLI validate/build/analyze passed for
+ `fixtures/Regression/OrientedComposeHoles/bracket-finished-mounts.firmament`:
+ one enclosed-manifold body/shell, 16 faces, 45 edges, 32 vertices, unchanged
+ [0,-20,0] to [30,0,40] bounds. The fixture combines counterbore and countersink
+ mounting holes on both legs with three mixed corner finishes.
+
+The full solution gate was executed. Its two bracket integration regressions
+were corrected and the full Firmament project rerun passed. Geometry occurrence
+and CLI slider-export failures passed on focused rerun. Three persistent failures
+also reproduce in an isolated unmodified worktree at published Aetheris
+575e7ec22ff716ebaf503e16f6b53589b9a5f29f: NIST FTC08/STC06 audit SHA snapshots and
+EditableV8 `PhysicalEngineUsesInterfacePlacementAndDimensionalFits` (IntakeRetainer1
+display position reference). No fixes or snapshot rewrites were made outside
+this bracket task. The full solution is not claimed green.
+
+Production AOT built successfully: decoded native WASM is 60,464,558 bytes,
+SHA-256 `321c1868f10cb12aceda40de9d334c59322ec938741e6b00062200d2949d151e`.
+All 760 CLI tests, 253 Helios unit tests and six SDK selection tests passed.
+TypeScript, frontend production build and both owning repositories'
+`git diff --check` passed.
+
+All 25 production graph workflows passed their final checks. The full suite
+passed 23; a new guard assertion expected a different diagnostic phrase, while
+the product correctly refused the collapsing radius. After accepting the
+actual radius-too-large diagnostic, that complete workflow passed. The added
+counterbore/countersink-after-finishing workflow also passed. The final mixed
+workflow covers three finishes, two shafts, refusal recovery, exact coordinate
+tuning, STEP analysis, undo and redo. All six focused final production WebGL
+workflows passed together after the picking/placement fixes. Hosted evidence
+is recorded with the final deployment.
+
+## Limits
+
+One polygonal profile extrusion, multiple original straight-sided corners and
+separated Side through-hole variants. No original curved profile corners or
+inner loops, general Compose Base/Add/Remove histories, imported-body finishing,
+mixed cap/longitudinal finishes or full-edge cap fillets. Cap finishes are not
+advertised on the combined side-hole host. Conservative corridor proof may
+refuse interactions needing a general surface intersection planner. This is
+not a general-purpose rolling-ball fillet engine or manufacturing certification.
+
+Owning repositories retain the accumulated uncommitted changes; deployment
+publishes complete source patches against the existing published baselines.
diff --git a/docs/development/reports/2026-11/helios-single-edge-finishes.md b/docs/development/reports/2026-11/helios-single-edge-finishes.md
new file mode 100644
index 00000000..65823384
--- /dev/null
+++ b/docs/development/reports/2026-11/helios-single-edge-finishes.md
@@ -0,0 +1,88 @@
+# Single-edge finishes in the Helios viewport
+
+The viewport already picked individual BRep edges, but the Graph finish actions
+selected an entire face boundary. Plain profile-extrusion display correspondence
+also dropped its construction-owned cap edges. The new workflow preserves one
+owner per cap edge and exports a compiler-owned body / support / single-segment
+finish binding. It never turns a display edge number into source syntax.
+
+Choose Edges in the viewport toolbar, select an edge, and choose Fillet selected
+edge or Chamfer selected edge. The transaction locks the target to that edge,
+shows only its size controls, previews automatically in gold over the accepted
+solid, and commits one undoable source edit on Apply. Cancel and refused sizes
+retain the original source. The existing graph actions still finish face rims.
+
+The existing geometry planners are unchanged. Qualified source bindings cover
+outer profile cap edges and the Box +X/+Z face pair owned by the existing
+localized route. Longitudinal, imported, split/ambiguous and other unqualified
+edges remain disabled. Unsupported histories, curved targets and degenerating
+sizes are still checked by the real compiler. Finite profile fillets retain
+their existing endpoint clearance; arbitrary-body finishing is not implemented
+by this UI change. Placed nonidentity occurrences cannot supply these bindings.
+
+The runtime builds the edge-binding index once per mesh, using construction
+correspondence rather than nearest-face recognition. SDK selection preserves
+that metadata. Missing occurrence transforms use the existing identity default,
+for both face placement and edge finishing.
+
+Native regression checks build 0.5 mm fillets/chamfers on both extrusion caps
+of the XZ Simple Bracket. They verify closed oriented bodies, STEP reimport,
+volume agreement within the mass evaluator's reported error bounds, one
+cylindrical fillet surface, split-edge refusal and the localized Box route.
+All 3,516 Firmament tests pass, including the combined-history refusal.
+All 19 focused selection / Box / recess regressions pass. All 251 Helios unit tests
+and six SDK selection tests pass.
+
+Both new bracket UI workflows pass in the default renderer and forced WebGL:
+select a real edge, preview, refuse zero size, cancel, apply, save source and
+STEP, validate via the native CLI at Built level, undo, then redo. Artifacts
+are under `HeliosCAD/artifacts/local/graph-authoring/bracket-single-edge-*`.
+Logs are under each repository's `artifacts/local/single-edge-ui/` directory.
+
+Published baselines are Helios `7c3ed3472f71647c5220cdcef00ce1756a8c8e21` and
+Aetheris `575e7ec22ff716ebaf503e16f6b53589b9a5f29f`. This change remains local to
+the owning repositories; the Site publishes corresponding complete patches.
+
+## Concrete remaining kernel blocker
+
+The already-holed oriented bracket is not admitted by the existing geometry
+route. Adding `EdgeFinish EdgeFillet { Face: Top Target:
+section.Outer.Vertex2_Vertex3 Kind: Fillet Radius: 0.5mm }` to the picked-face
+hole fixture fails at ParsedNotBuilt with
+`compose-oriented-feature-not-admitted:EdgeFinish:EdgeFillet`, explaining that
+the feature needs another support adapter. The reproduction is
+`artifacts/local/single-edge-ui/bracket-hole-plus-edge.firmament` and its JSON
+validation output. No fallback removes the hole or silently finishes a rim.
+This UI change removes the selection/transaction blocker; combining a finish
+with these holes still requires a permanent kernel adapter and qualification
+of cavity clearance and trimmed-face preservation. Generalizing that geometry
+pipeline is beyond this bounded UI wiring change.
+
+Production qualification also exposed a form-loading race: Preview was enabled
+and two competing status messages appeared while field controls were still
+being prepared. The form now presents one status and enables Preview only when
+those controls are ready. Box before/after checks exposed an existing stock-frame
+bug: the localized AIR body was exported in its centered kernel frame, shifting
+authored Box stock down by half its height. Both single-edge routes now use the
+existing FirmamentStockFrame authority and primitive translation helper before
+preflight and export. The source Box remains at Z=0..Height through the finish.
+Native tests compare the original and finished bounds; the CLI tests assert the
+actual chamfer/fillet contact points in that authored frame. All 19 targeted CLI
+pipeline tests pass, including the existing junction/trihedral checks. The final
+full runs pass all 3,516 Firmament tests and all 760 CLI tests after this fix.
+
+## Production qualification
+
+The final production AOT SDK and frontend builds pass. The decoded native WASM
+is 60,394,592 bytes, SHA-256
+`fad6d0906b82aec76a5df2ee3828f864534d387fc29dede77aa5ce22405432b8`.
+
+All 22 production graph workflows pass with the optimized AOT runtime required.
+They cover the existing hole/recess authoring paths and the six new single-edge
+workflows: bracket fillet/chamfer, Box fillet/chamfer with unchanged before/after
+stock bounds, disabled longitudinal-edge actions, and refusal of an edge finish
+on the already-holed oriented bracket with source preservation and explanation.
+
+All six single-edge workflows also pass against the production bundle with
+forced WebGL. The final Helios unit run passes all 251 tests. Both repositories
+pass `git diff --check`.
diff --git a/docs/public/firmament/bracket-edge-finishes.md b/docs/public/firmament/bracket-edge-finishes.md
new file mode 100644
index 00000000..6863d46f
--- /dev/null
+++ b/docs/public/firmament/bracket-edge-finishes.md
@@ -0,0 +1,55 @@
+# Bracket corner finishes and mounting holes
+
+Use full-length longitudinal edge finishes to round an inside bend or break
+outside corners on a profile-extruded bracket, together with separated mounting
+holes. Each finish names one original straight-sided profile corner.
+
+The complete [finished mounting bracket](../../../fixtures/Regression/OrientedComposeHoles/bracket-finished-mounts.firmament)
+builds a 30 × 40 × 3 mm L section, extruded 20 mm on XZ. It has a 2 mm inside
+fillet, a 0.5 mm outside chamfer, a 0.5 mm outside fillet, a counterbored foot
+mount and a countersunk upright mount. Build that file with `aetheris build`.
+
+The corner requests in that example are:
+
+```text
+EdgeFinish Bend {
+ Face: Longitudinal
+ Target: section.Outer.Vertex3_Vertex4.Start
+ Kind: Fillet
+ Radius: 2mm
+}
+EdgeFinish FootTop {
+ Face: Longitudinal
+ Target: section.Outer.Vertex2_Vertex3.Start
+ Kind: Chamfer
+ Distance: 0.5mm
+}
+```
+
+Place them inside `Modify bracket` as in the complete fixture. The compiler
+replaces the named profile corner with an exact tangent arc or a straight bevel,
+then extrudes it through the full width. Inside finishes add material; outside
+finishes remove it. Different original corners may use different finishes.
+
+`Radius` for Fillet and `Distance` for Chamfer must be at least 0.01 mm. At least
+0.01 mm must remain on each adjacent straight leg and between a new boundary
+and other boundaries or finishes. Repeating a finish on the same corner,
+consuming a shared edge, and intersecting or tangent boundaries are rejected.
+
+Source-side through shafts, counterbores and countersinks may share this single
+profile host. Hole coordinates remain in the untrimmed construction face frame;
+changing a corner does not relocate an existing mounting hole. Admission checks
+the complete cavity envelope against the remaining planar supports, other
+cavities and intervening faces. Move the hole or reduce the finish when the
+required 0.01 mm clearance is unavailable. The conservative finite corridor
+proof can refuse interactions that need a more general intersection planner.
+
+This route requires one polygonal outer profile extrusion. It does not admit
+inner profile loops, curved original corners, multiple Base/Add/Remove regions,
+imported bodies or mixed end-face and longitudinal finishes. Full-edge cap
+fillets and tangent-chain selection need different planners. In Helios, select
+one edge in Iso/Edges, inspect the automatic gold preview, and Apply; a refused
+preview preserves the accepted part and source.
+
+See [profile boundary edits](profile-boundary-edits.md) and the
+[language reference](../reference/language/README.md).
diff --git a/fixtures/Regression/OrientedComposeHoles/bracket-finished-mounts.firmament b/fixtures/Regression/OrientedComposeHoles/bracket-finished-mounts.firmament
new file mode 100644
index 00000000..8015289a
--- /dev/null
+++ b/fixtures/Regression/OrientedComposeHoles/bracket-finished-mounts.firmament
@@ -0,0 +1,26 @@
+// Separated mounting recesses with a full-width inside bend and two outside breaks.
+Model FinishedBracket {
+ units: mm
+ Concept Struct layout on XZ {
+ Polygon2<Explicit> outline {
+ points: [[0mm,0mm], [30mm,0mm], [30mm,3mm], [3mm,3mm], [3mm,40mm], [0mm,40mm]]
+ }
+ }
+ Profile section using layout { Loop Outer { outline |> TraceLoop } }
+ Extrude bracket { profile: section; from: 0mm; to: 20mm }
+ Modify bracket {
+ Hole<Counterbore> FootMount {
+ On: face(bracket.Side("profile:section.Outer.Vertex2_Vertex3"))
+ Center: Point2(13mm,10mm) Diameter: 4mm
+ CounterboreDiameter: 7mm CounterboreDepth: 1mm End: ThroughAll
+ }
+ Hole<Countersink> UprightMount {
+ On: face(bracket.Side("profile:section.Outer.Vertex3_Vertex4"))
+ Center: Point2(10mm,20mm) Diameter: 6mm
+ CountersinkDiameter: 8mm CountersinkAngle: 90deg End: ThroughAll
+ }
+ EdgeFinish Bend { Face: Longitudinal Target: section.Outer.Vertex3_Vertex4.Start Kind: Fillet Radius: 2mm }
+ EdgeFinish FootTop { Face: Longitudinal Target: section.Outer.Vertex2_Vertex3.Start Kind: Chamfer Distance: 0.5mm }
+ EdgeFinish FootBottom { Face: Longitudinal Target: section.Outer.Vertex1_Vertex2.Start Kind: Fillet Radius: 0.5mm }
+ }
+}