Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Export counterbore PMI through canonical profile compositions
Yuechen Li700ad03a7195
diff --git a/Aetheris.CLI/CliRunner.cs b/Aetheris.CLI/CliRunner.csindex 7c1383bc..96c96f84 100644--- a/Aetheris.CLI/CliRunner.cs+++ b/Aetheris.CLI/CliRunner.cs@@ -687,7 +687,13 @@ public static class CliRunnerif (!File.Exists(args[0])) { stderr.WriteLine($"Composition source was not found: {args[0]}"); return 1; }var total = Stopwatch.StartNew();var parseClock = Stopwatch.StartNew();- var parsed = PrismaticProfileCompositionParser.Parse(File.ReadAllText(args[0]));+ var source = File.ReadAllText(args[0]);+ if (!FirmamentV2Parser.TryExpandCanonicalStaticAuthoring(source, out var materializerSource, out var staticDiagnostics))+ {+ stderr.WriteLine(string.Join(Environment.NewLine, staticDiagnostics));+ return 1;+ }+ var parsed = PrismaticProfileCompositionParser.Parse(materializerSource);parseClock.Stop(); var normalizeClock = Stopwatch.StartNew();var stack = PrismaticSectionStackCompiler.Normalize(parsed, out var diagnostics);normalizeClock.Stop();@@ -705,6 +711,7 @@ public static class CliRunnersignatures = new { composition = CompositionSignature(stack), profiles = parsed.Profiles.OrderBy(x => x.Key, StringComparer.Ordinal).ToDictionary(x => x.Key, x => ProfileSignature(x.Value), StringComparer.Ordinal) },operations = stack.Feature.Operations.Select(x => new { x.Name, intent = x.Intent.ToString(), profile = x.ProfileReference, x.From, x.To, x.SemanticRole, x.SourceSpan, x.SemanticFeatureId, x.SemanticFeatureKind, x.Diameter, signature = Hash($"{x.Intent}|{x.ProfileReference}|{x.From:R}|{x.To:R}|{x.SemanticRole}|{x.SemanticFeatureId}|{x.Diameter:R}") }),shaftHoles = (stack.Feature.ShaftHoles ?? []).Select(x => new { x.Name, x.StableId, profile = x.ProfileReference, center = new[] { x.CenterX, x.CenterY }, x.Diameter, x.From, x.To, endCondition = "ThroughAll", x.SemanticRole, x.SourceSpan }),+ counterboreHoles = (stack.Feature.CounterboreHoles ?? []).Select(x => new { x.Name, x.StableId, shaftProfile = x.ShaftProfileReference, counterboreProfile = x.CounterboreProfileReference, center = new[] { x.CenterX, x.CenterY }, x.Diameter, x.CounterboreDiameter, x.CounterboreDepth, x.From, x.To, endCondition = "ThroughAll", x.SemanticRole, x.SourceSpan }),capsuleSlots = (stack.Feature.CapsuleSlots ?? []).Select(x => new { x.Name, x.StableId, kind = "Slot<Capsule>", profile = x.ProfileReference, center = new[] { x.CenterX, x.CenterY }, direction = new[] { x.DirectionX, x.DirectionY }, x.Length, x.Width, radius = x.Radius, straightSpan = x.StraightSpan, endCenters = new[] { new[] { x.CenterX - x.DirectionX * x.StraightSpan / 2d, x.CenterY - x.DirectionY * x.StraightSpan / 2d }, new[] { x.CenterX + x.DirectionX * x.StraightSpan / 2d, x.CenterY + x.DirectionY * x.StraightSpan / 2d } }, x.From, x.To, x.Extent, x.SemanticRole, x.SourceSpan, segments = parsed.Profiles[x.ProfileReference].Loops.Single().Segments.Select(s => s.Name) }),roundedRectangleSlots = (stack.Feature.RoundedRectangleSlots ?? []).Select(x => new { x.Name, x.StableId, kind = "Slot<RoundedRectangle>", profile = x.ProfileReference, center = new[] { x.CenterX, x.CenterY }, direction = new[] { x.DirectionX, x.DirectionY }, x.Length, x.Width, x.CornerRadius, x.From, x.To, x.Extent, x.SemanticRole, x.SourceSpan, segments = parsed.Profiles[x.ProfileReference].Loops.Single().Segments.Select(s => s.Name) }),criticalLevels = stack.Feature.CriticalLevels,@@ -768,7 +775,7 @@ public static class CliRunnerexpansion = parsed.Expansion,timingsMilliseconds = new { parse = parseClock.Elapsed.TotalMilliseconds, normalize = normalizeClock.Elapsed.TotalMilliseconds, materialize = materializeClock.TotalMilliseconds, total = total.Elapsed.TotalMilliseconds },executionBoundary = new { inspectionOnly = !materialize, bRepMaterialized = materialize, stepExported = false, m8Executed = false, cirExecuted = false },- diagnostics = emitted?.Diagnostics ?? stack.Diagnostics+ diagnostics = staticDiagnostics.Concat(emitted?.Diagnostics ?? stack.Diagnostics).Distinct()}};stdout.WriteLine(JsonSerializer.Serialize(report, JsonOptions));diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentV2CanonicalAdvancedGrammarTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentV2CanonicalAdvancedGrammarTests.csindex 4611cf94..e8619e66 100644--- a/Aetheris.Kernel.Firmament.Tests/FirmamentV2CanonicalAdvancedGrammarTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentV2CanonicalAdvancedGrammarTests.cs@@ -1,4 +1,6 @@using Aetheris.Kernel.Firmament.FirmamentV2;+using Aetheris.Kernel.Core.Brep.Verification;+using Aetheris.Kernel.Core.Step242;namespace Aetheris.Kernel.Firmament.Tests;@@ -305,6 +307,41 @@ public sealed class FirmamentV2CanonicalAdvancedGrammarTests}}+ [Fact]+ public void CanonicalLProfilePatternCounterborePmi_ExportsDeterministicAp242AndReimports()+ {+ var path = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "../../../../fixtures/FirmamentV2/Canonical/valid/profile-compose-l-bracket-counterbore-pmi.firmament"));+ var firstOutput = Path.Combine(Path.GetTempPath(), "aetheris-l-profile-counterbore-" + Guid.NewGuid().ToString("N") + ".step");+ var secondOutput = Path.Combine(Path.GetTempPath(), "aetheris-l-profile-counterbore-" + Guid.NewGuid().ToString("N") + ".step");+ try+ {+ var parse = FirmamentV2Parser.Parse(File.ReadAllText(path));+ Assert.True(parse.IsSuccess, string.Join(Environment.NewLine, parse.Diagnostics));+ Assert.Equal(2, parse.Document!.Pmi!.Count);+ var first = FirmamentBuildAndExport.Run(path, firstOutput);+ var second = FirmamentBuildAndExport.Run(path, secondOutput);+ Assert.True(first.IsSuccess, string.Join(Environment.NewLine, first.Diagnostics.Select(diagnostic => diagnostic.Message)));+ Assert.True(second.IsSuccess, string.Join(Environment.NewLine, second.Diagnostics.Select(diagnostic => diagnostic.Message)));+ Assert.Contains(first.Value.Export.DatumInspection!, datum => datum.Label == "A" && datum.Target == "face(+Z)");+ Assert.Contains(first.Value.Export.DimensionInspection!, dimension => dimension.Target == "CounterboredMount" && dimension.Value == 8d);+ var firstStep = File.ReadAllText(firstOutput); var secondStep = File.ReadAllText(secondOutput);+ Assert.Equal(firstStep, secondStep);+ Assert.Contains("firmament-datum:A", firstStep, StringComparison.Ordinal);+ Assert.Contains("diameter:hole:BracketBody.CounterboredMount", firstStep, StringComparison.Ordinal);+ Assert.Contains("diameter_tolerance:hole:BracketBody.CounterboredMount", firstStep, StringComparison.Ordinal);+ var imported = Step242Importer.ImportBody(firstStep);+ Assert.True(imported.IsSuccess, string.Join(Environment.NewLine, imported.Diagnostics.Select(diagnostic => diagnostic.Message)));+ var mass = BrepMassProperties.Evaluate(imported.Value);+ Assert.True(mass.IsEnclosed); Assert.True(mass.IsOrientationConsistent);+ Assert.InRange(Math.Abs(mass.AbsoluteVolume - (28800d - 540d * Math.PI)), 0d, 0.01d);+ }+ finally+ {+ if (File.Exists(firstOutput)) File.Delete(firstOutput);+ if (File.Exists(secondOutput)) File.Delete(secondOutput);+ }+ }+[Fact]public void ProfileComposePolygonEdgeFinish_ReportsHostAdmissionInsteadOfMissingSemanticSource(){diff --git a/Aetheris.Kernel.Firmament.Tests/PrismaticProfileCompositionRoundTripTests.cs b/Aetheris.Kernel.Firmament.Tests/PrismaticProfileCompositionRoundTripTests.csindex 18d77fdf..69de47a0 100644--- a/Aetheris.Kernel.Firmament.Tests/PrismaticProfileCompositionRoundTripTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/PrismaticProfileCompositionRoundTripTests.cs@@ -8,6 +8,63 @@ namespace Aetheris.Kernel.Firmament.Tests;public sealed class PrismaticProfileCompositionRoundTripTests{+ [Fact]+ public void LProfileCounterbore_UsesSteppedSectionPlanAndPublishesSemanticDescendants()+ {+ var source = File.ReadAllText(Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "../../../../fixtures/FirmamentV2/Canonical/valid/profile-compose-l-bracket.firmament")))+ .Replace("Base Stock { Profile: Bracket; From: 0mm; To: 12mm; Role: Stock }", """+ Base Stock { Profile: Bracket; From: 0mm; To: 12mm; Role: Stock }+ Hole<Counterbore> CounterboredMount {+ On: +Z+ Center: Point2(-30mm, -10mm)+ Diameter: 8mm+ CounterboreDiameter: 14mm+ CounterboreDepth: 4mm+ End: ThroughAll+ }+ """, StringComparison.Ordinal);+ var parsed = PrismaticProfileCompositionParser.Parse(source);+ Assert.Empty(parsed.Diagnostics);+ var stack = Assert.IsType<PrismaticSectionStackConstruction>(PrismaticSectionStackCompiler.Normalize(parsed, out var diagnostics));+ Assert.Empty(diagnostics);+ var counterbore = Assert.Single(stack.Feature.CounterboreHoles!);+ Assert.Equal(8d, counterbore.Diameter); Assert.Equal(14d, counterbore.CounterboreDiameter); Assert.Equal(4d, counterbore.CounterboreDepth);+ Assert.Equal(27782.12398023691d, stack.AnalyticVolume, 8);+ var emitted = PrismaticSectionStackEmitter.Emit(stack);+ Assert.NotNull(emitted.Body); Assert.NotNull(emitted.Correspondence);+ Assert.Contains(emitted.Correspondence!.Descendants, item => item.SourceStableId == counterbore.StableId && item.Role == SemanticTopologyRole.HoleCounterboreMouthLoop);+ Assert.Contains(emitted.Correspondence.Descendants, item => item.SourceStableId == counterbore.StableId && item.Role == SemanticTopologyRole.HoleCounterboreWallFace);+ Assert.Contains(emitted.Correspondence.Descendants, item => item.SourceStableId == counterbore.StableId && item.Role == SemanticTopologyRole.HoleCounterboreShoulderLoop);+ Assert.Contains(emitted.Correspondence.Descendants, item => item.SourceStableId == counterbore.StableId && item.Role == SemanticTopologyRole.HoleCounterboreShaftWallFace);+ Assert.Contains(emitted.Correspondence.Descendants, item => item.SourceStableId == counterbore.StableId && item.Role == SemanticTopologyRole.HoleExitLoop);+ }++ [Theory]+ [InlineData("Point2(-20mm, 5mm) Diameter: 8mm CounterboreDiameter: 14mm CounterboreDepth: 4mm", "ComposeCounterboreFootprintLeavesProfileMaterial")]+ [InlineData("Point2(-30mm, -10mm) Diameter: 8mm CounterboreDiameter: 14mm CounterboreDepth: 13mm", "ComposeCounterboreDepthExceedsHost")]+ public void LProfileCounterbore_InvalidAdmission_IsTyped(string centerAndDimensions, string expected)+ {+ var source = """+ Model InvalidCounterbore {+ Units: mm+ Concept Struct Layout On XY { Rect2 Stock { Center: [0mm, 0mm]; Size: [40mm, 20mm] } }+ Profile Plate Using Layout { Loop Outer {+ Segment South { Trace: Stock.Bottom; From: Stock.BottomLeft; To: Stock.BottomRight }+ Segment East { Trace: Stock.Right; From: Stock.BottomRight; To: Stock.TopRight }+ Segment North { Trace: Stock.Top; From: Stock.TopRight; To: Stock.TopLeft }+ Segment West { Trace: Stock.Left; From: Stock.TopLeft; To: Stock.BottomLeft }+ } }+ Struct Body { Compose Body {+ Base Stock { Profile: Plate; From: 0mm; To: 12mm; Role: Stock }+ Hole<Counterbore> Bad { On: +Z Center: CENTER Diameter: 8mm CounterboreDiameter: 14mm CounterboreDepth: 4mm End: ThroughAll }+ } }+ }+ """.Replace("CENTER Diameter: 8mm CounterboreDiameter: 14mm CounterboreDepth: 4mm", centerAndDimensions, StringComparison.Ordinal);+ var parsed = PrismaticProfileCompositionParser.Parse(source);+ Assert.Null(parsed.Feature);+ Assert.Contains(parsed.Diagnostics, diagnostic => diagnostic.StartsWith(expected, StringComparison.Ordinal));+ }+[Fact]public void SemanticCapsuleSlot_LowersToExactProfileAndPublishesStableDescendants(){diff --git a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.csindex 4027c02e..b0740884 100644--- a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs+++ b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs@@ -80,6 +80,10 @@ public static class FirmamentBuildAndExport.ToArray());}var materializerInput = staticExpansion.Source;+ // Parse the canonical document before selecting the materializer. Advanced+ // Profile/Compose hosts still use their bounded section-stack materializer,+ // but their normalized PMI records must follow the same AP242 route.+ var v2Parse = FirmamentV2Parser.Parse(sourceText, sourceDirectory);var canonicalAdvanced = FirmamentV2Parser.TryGetCanonicalAdvancedBody(materializerInput, out var canonicalBody);var materializerSource = canonicalAdvanced ? canonicalBody : materializerInput;if (PrismaticProfileCompositionParser.IsCompositionSource(materializerSource))@@ -108,9 +112,20 @@ public static class FirmamentBuildAndExportvar completedBody = emitted.Body;if (completedBody is null)return KernelResult<FirmamentStepExportResult>.Failure([new Kernel.Core.Diagnostics.KernelDiagnostic(Kernel.Core.Diagnostics.KernelDiagnosticCode.ValidationFailed, Kernel.Core.Diagnostics.KernelDiagnosticSeverity.Error, "profile-composition-materialization-missing-body", "FirmamentV2.ProfileComposition")]);- var step = Step242Exporter.ExportBody(completedBody);+ var semanticPmi = Array.Empty<Step242SemanticPmi>();+ if (v2Parse.IsSuccess && v2Parse.Document is not null)+ {+ var support = ValidateV2PmiExportSupport(v2Parse.Document);+ if (!support.IsSuccess) return KernelResult<FirmamentStepExportResult>.Failure(support.Diagnostics);+ var features = (stack.Feature.ShaftHoles ?? []).ToDictionary(hole => hole.Name, hole => hole.StableId, StringComparer.Ordinal);+ foreach (var hole in stack.Feature.CounterboreHoles ?? []) features[hole.Name] = hole.StableId;+ semanticPmi = BuildV2SemanticPmi(v2Parse.Document, [], stack.Feature.Name, features).ToArray();+ }+ var step = Step242Exporter.ExportBody(completedBody, semanticPmi);if (!step.IsSuccess) return KernelResult<FirmamentStepExportResult>.Failure(step.Diagnostics);- return KernelResult<FirmamentStepExportResult>.Success(new FirmamentStepExportResult(step.Value, stack.Feature.Name, 0, "prismatic-section-stack", "line-arc-profile-composition"));+ return KernelResult<FirmamentStepExportResult>.Success(new FirmamentStepExportResult(step.Value, stack.Feature.Name, 0, "prismatic-section-stack", "line-arc-profile-composition",+ DatumInspection: v2Parse.Document?.Pmi?.Where(p => p.Kind == FirmamentV2PmiKind.DatumPlane).Select(p => new FirmamentPmiInspectionDatum(p.Name, "planar", p.Target)).ToArray() ?? [],+ DimensionInspection: v2Parse.Document?.Pmi?.Where(p => p.Kind == FirmamentV2PmiKind.HoleDiameter).Select(p => new FirmamentPmiInspectionDimension("Diameter", p.Target, null, p.Value ?? 0d, "explicit-v2-record-pmi", p.Name)).ToArray() ?? []));}if (ProfileAuthoringParser.IsProfileSource(materializerSource)){@@ -123,7 +138,6 @@ public static class FirmamentBuildAndExportvar step = Step242Exporter.ExportBody(emitted.Body); if (!step.IsSuccess) return KernelResult<FirmamentStepExportResult>.Failure(step.Diagnostics);return KernelResult<FirmamentStepExportResult>.Success(new FirmamentStepExportResult(step.Value, parsed.Profile.Name, 0, "profile-extrude", "line-arc-profile"));}- var v2Parse = FirmamentV2Parser.Parse(sourceText, sourceDirectory);if (v2Parse.IsSuccess && v2Parse.Document is not null){var dfm = FirmamentV2DfmEnforcement.Validate(v2Parse.Document);@@ -1469,7 +1483,7 @@ public static class FirmamentBuildAndExport"FirmamentV2.PmiExport")).ToArray());}- private static IReadOnlyList<Step242SemanticPmi> BuildV2SemanticPmi(FirmamentV2Document document, IReadOnlyList<Core.Air.AirHoleFeature> semanticHoles, string targetSolid)+ private static IReadOnlyList<Step242SemanticPmi> BuildV2SemanticPmi(FirmamentV2Document document, IReadOnlyList<Core.Air.AirHoleFeature> semanticHoles, string targetSolid, IReadOnlyDictionary<string, string>? explicitFeatureIds = null){if (document.Pmi is null || document.Pmi.Count == 0){@@ -1491,6 +1505,10 @@ public static class FirmamentBuildAndExport{result.Add(new Step242SemanticPmiHole(pmiHole.FeatureId, pmi.Value.Value, null, "explicit_v2_semantic_hole_diameter", tolerancePlus, toleranceMinus));}+ else if (explicitFeatureIds is not null && explicitFeatureIds.TryGetValue(pmi.Target, out var featureId))+ {+ result.Add(new Step242SemanticPmiHole(featureId, pmi.Value.Value, null, "explicit_v2_semantic_hole_diameter", tolerancePlus, toleranceMinus));+ }else if (TryResolveV2RecognizedRegionTarget(document, targetBinding, pmi.Target, out var importedTarget) || TryResolveV2ImportedFaceTarget(targetBinding, pmi.Target, out importedTarget)){result.Add(new Step242SemanticPmiHole($"{targetSolid}.{pmi.Name}", pmi.Value.Value, null, $"imported_canonical_face:{importedTarget}", tolerancePlus, toleranceMinus));diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.csindex a04ab95c..7fcce185 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs@@ -961,7 +961,7 @@ public static class FirmamentV2Parser[feature.Name] = new FirmamentV2SolidBinding(feature.Name, "Compose", new FirmamentV2AdvancedMaterialRecord("Compose"))};var (compositionPmi, compositionPmiBlock, compositionBoundPmi) = ParsePmi(- source, compositionSolids, [], [], [], [], diagnostics, (feature.ShaftHoles ?? []).Select(hole => hole.Name));+ source, compositionSolids, [], [], [], [], diagnostics, (feature.ShaftHoles ?? []).Select(hole => hole.Name).Concat((feature.CounterboreHoles ?? []).Select(hole => hole.Name)));if (Regex.IsMatch(body, @"\bEdgeFinish\b", RegexOptions.CultureInvariant)&& composition.Profiles.Values.Any(profile => profile.Loops.Single().Segments.Count != 4)){@@ -2705,6 +2705,17 @@ public static class FirmamentV2Parserreturn -1;}+ /// <summary>Exposes the canonical static-erasure boundary to inspection clients.+ /// Materialization and inspection therefore observe identical generated feature identities.</summary>+ public static bool TryExpandCanonicalStaticAuthoring(string source, out string expandedSource, out IReadOnlyList<string> diagnostics)+ {+ var collected = new List<string>();+ var expanded = CanonicalStaticAuthoring.Expand(source, collected);+ expandedSource = expanded?.Source ?? source;+ diagnostics = collected.Distinct(StringComparer.Ordinal).Order(StringComparer.Ordinal).ToArray();+ return expanded is not null;+ }+private static string StripLineComments(string sourceText) => string.Join('\n', sourceText.Split('\n').Select(line =>{var index = line.IndexOf("//", StringComparison.Ordinal);diff --git a/Aetheris.Kernel.Firmament/Materializer/PrismaticProfileComposition.cs b/Aetheris.Kernel.Firmament/Materializer/PrismaticProfileComposition.csindex 3ed68ce3..6dbfa842 100644--- a/Aetheris.Kernel.Firmament/Materializer/PrismaticProfileComposition.cs+++ b/Aetheris.Kernel.Firmament/Materializer/PrismaticProfileComposition.cs@@ -17,6 +17,14 @@ public sealed record PrismaticProfileOperation(public sealed record PrismaticShaftHoleFeature(string Name, string StableId, string ProfileReference, double CenterX, double CenterY, double Diameter,double From, double To, string SemanticRole, string SourceSpan);+/// <summary>+/// A bounded stepped through cavity in an admitted +Z prismatic compose host.+/// The two profile references are planner-owned section cuts, not Boolean tools.+/// </summary>+public sealed record PrismaticCounterboreHoleFeature(+ string Name, string StableId, string ShaftProfileReference, string CounterboreProfileReference,+ double CenterX, double CenterY, double Diameter, double CounterboreDiameter, double CounterboreDepth,+ double From, double To, string SemanticRole, string SourceSpan);/// <summary>Source-owned transverse blind drill; its cavity is planned after host construction.</summary>public sealed record PrismaticConstructionPlaneBlindDrillFeature(string Name, string StableId, string ConstructionPlaneId, string SourceConceptPlaneId,@@ -46,7 +54,8 @@ public sealed record PrismaticProfileCompositionFeature(IReadOnlyList<double> CriticalLevels, string Provenance, IReadOnlyList<PrismaticShaftHoleFeature>? ShaftHoles = null,IReadOnlyList<PrismaticCapsuleSlotFeature>? CapsuleSlots = null,IReadOnlyList<PrismaticRoundedRectangleSlotFeature>? RoundedRectangleSlots = null,- IReadOnlyList<PrismaticConstructionPlaneBlindDrillFeature>? ConstructionPlaneBlindDrills = null)+ IReadOnlyList<PrismaticConstructionPlaneBlindDrillFeature>? ConstructionPlaneBlindDrills = null,+ IReadOnlyList<PrismaticCounterboreHoleFeature>? CounterboreHoles = null){public IEnumerable<(string Name, string StableId, string ProfileReference)> AllSlotProfiles =>(CapsuleSlots ?? []).Select(x => (x.Name, x.StableId, x.ProfileReference))@@ -86,6 +95,9 @@ public static class PrismaticProfileCompositionParserprivate static readonly Regex HoleCenter = new(@"\bCenter\s*:\s*\[(?<x>[-+.\d]+)mm\s*,\s*(?<y>[-+.\d]+)mm\]", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);private static readonly Regex HolePoint2Center = new(@"\bCenter\s*:\s*Point2\s*\(\s*(?<x>[-+.\d]+)mm\s*,\s*(?<y>[-+.\d]+)mm\s*\)", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);private static readonly Regex HoleDiameter = new(@"\bDiameter\s*:\s*(?<d>[-+.\d]+)mm", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);+ private static readonly Regex HoleCounterboreDiameter = new(@"\bCounterboreDiameter\s*:\s*(?<d>[-+.\d]+)mm", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);+ private static readonly Regex HoleCounterboreDepth = new(@"\bCounterboreDepth\s*:\s*(?<d>[-+.\d]+)mm", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);+ private static readonly Regex HoleOn = new(@"\bOn\s*:\s*(?<face>[+-][XYZ])", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);private static readonly Regex HoleEnd = new(@"\bEnd\s*:\s*(?<end>\w+)", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);private static readonly Regex HoleDepthEnd = new(@"\bEnd\s*:\s*(?<kind>ShaftDepth|TotalDepth)\s*\(\s*(?<depth>[-+.\d]+)mm\s*\)", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);private static readonly Regex HoleFrom = new(@"\bFrom\s*:\s*(?<plane>\w+)", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);@@ -194,6 +206,7 @@ public static class PrismaticProfileCompositionParser}if (operations.Count(o => o.Intent == PrismaticProfileIntent.Base) != 1) diagnostics.Add("compose-requires-exactly-one-base-operation");var shaftHoles = new List<PrismaticShaftHoleFeature>();+ var counterboreHoles = new List<PrismaticCounterboreHoleFeature>();var constructionPlaneBlindDrills = new List<PrismaticConstructionPlaneBlindDrillFeature>();var capsuleSlots = new List<PrismaticCapsuleSlotFeature>();var roundedRectangleSlots = new List<PrismaticRoundedRectangleSlotFeature>();@@ -206,6 +219,7 @@ public static class PrismaticProfileCompositionParserif (body is null) { diagnostics.Add($"compose-hole-unclosed:{name}"); continue; }var center = HoleCenter.Match(body); if (!center.Success) center = HolePoint2Center.Match(body);var diameter = HoleDiameter.Match(body); var end = HoleEnd.Match(body); var role = HoleRole.Match(body);+ var counterboreDiameter = HoleCounterboreDiameter.Match(body); var counterboreDepth = HoleCounterboreDepth.Match(body); var on = HoleOn.Match(body);var from = HoleFrom.Match(body); var depthEnd = HoleDepthEnd.Match(body); var termination = HoleTermination.Match(body);if (from.Success){@@ -230,7 +244,38 @@ public static class PrismaticProfileCompositionParserrole.Success ? role.Groups["role"].Value : "BlindDrillPoint", $"offset:{header.Index}", plane.Provenance));continue;}- if (!string.Equals(header.Groups["variant"].Value, "Shaft", StringComparison.OrdinalIgnoreCase)+ var variant = header.Groups["variant"].Value;+ if (string.Equals(variant, "Counterbore", StringComparison.OrdinalIgnoreCase))+ {+ if (!end.Success || !string.Equals(end.Groups["end"].Value, "ThroughAll", StringComparison.OrdinalIgnoreCase))+ { diagnostics.Add($"ComposeCounterboreEndUnsupported:{name}:supported=ThroughAll"); continue; }+ if (!on.Success || !string.Equals(on.Groups["face"].Value, "+Z", StringComparison.OrdinalIgnoreCase))+ { diagnostics.Add($"ComposeCounterboreAxisUnsupported:{name}:supported=+Z"); continue; }+ if (!center.Success || !diameter.Success || !counterboreDiameter.Success || !counterboreDepth.Success)+ { diagnostics.Add($"ComposeCounterboreMissingRequiredField:{name}"); continue; }+ var counterboreX = N(center, "x"); var counterboreY = N(center, "y"); var shaftDiameter = N(diameter, "d"); var boreDiameter = N(counterboreDiameter, "d"); var boreDepth = N(counterboreDepth, "d");+ if (!double.IsFinite(counterboreX) || !double.IsFinite(counterboreY) || !double.IsFinite(shaftDiameter) || shaftDiameter <= 0d || !double.IsFinite(boreDiameter) || boreDiameter <= shaftDiameter || !double.IsFinite(boreDepth) || boreDepth <= 0d)+ { diagnostics.Add($"ComposeCounterboreInvalidGeometry:{name}"); continue; }+ var hostDepth = materialTo - materialFrom;+ if (boreDepth > hostDepth + 1e-8d)+ { diagnostics.Add($"ComposeCounterboreDepthExceedsHost:{name}:depth={boreDepth:R}:hostDepth={hostDepth:R}"); continue; }+ if (!names.Add(name)) { diagnostics.Add($"compose-duplicate-operation:{name}"); continue; }+ var counterboreStableId = $"hole:{compose.Groups["n"].Value}.{name}";+ if (!CircleContainedInBaseProfile(operations, profiles, counterboreX, counterboreY, boreDiameter / 2d))+ { diagnostics.Add($"ComposeCounterboreFootprintLeavesProfileMaterial:{name}:radius={boreDiameter / 2d:R}"); continue; }+ if (IntersectsExistingCircularCavity(shaftHoles, counterboreHoles, counterboreX, counterboreY, boreDiameter / 2d))+ { diagnostics.Add($"ComposeCounterboreIntersectsExistingCavity:{name}"); continue; }+ var shaftProfile = $"{name}ShaftProfile"; var boreProfile = $"{name}CounterboreProfile";+ if (profiles.ContainsKey(shaftProfile) || profiles.ContainsKey(boreProfile)) { diagnostics.Add($"compose-hole-profile-name-collision:{name}"); continue; }+ profiles.Add(shaftProfile, CircleProfile(shaftProfile, counterboreX, counterboreY, shaftDiameter / 2d, counterboreStableId, $"offset:{header.Index}"));+ profiles.Add(boreProfile, CircleProfile(boreProfile, counterboreX, counterboreY, boreDiameter / 2d, counterboreStableId, $"offset:{header.Index}"));+ var counterboreSourceSpan = $"offset:{header.Index}"; var counterboreSemanticRole = role.Success ? role.Groups["role"].Value : "CounterboreHole";+ counterboreHoles.Add(new(name, counterboreStableId, shaftProfile, boreProfile, counterboreX, counterboreY, shaftDiameter, boreDiameter, boreDepth, materialFrom, materialTo, counterboreSemanticRole, counterboreSourceSpan));+ operations.Add(new($"{name}Shaft", PrismaticProfileIntent.Remove, shaftProfile, materialFrom, materialTo, counterboreSemanticRole, counterboreSourceSpan, counterboreStableId, "Hole<Counterbore>", shaftDiameter));+ operations.Add(new($"{name}Counterbore", PrismaticProfileIntent.Remove, boreProfile, materialTo - boreDepth, materialTo, counterboreSemanticRole, counterboreSourceSpan, counterboreStableId, "Hole<Counterbore>", boreDiameter));+ continue;+ }+ if (!string.Equals(variant, "Shaft", StringComparison.OrdinalIgnoreCase)|| !end.Success || !string.Equals(end.Groups["end"].Value, "ThroughAll", StringComparison.OrdinalIgnoreCase)){ diagnostics.Add($"compose-hole-unsupported-variant-or-end:{name}"); continue; }if (!center.Success || !diameter.Success) { diagnostics.Add($"compose-hole-missing-center-or-diameter:{name}"); continue; }@@ -250,6 +295,14 @@ public static class PrismaticProfileCompositionParsershaftHoles.Add(new(name, stableId, profileName, x, y, d, materialFrom, materialTo, semanticRole, sourceSpan));operations.Add(new(name, PrismaticProfileIntent.Remove, profileName, materialFrom, materialTo, semanticRole, sourceSpan, stableId, "Hole<Shaft>", d));}+ // Source order must not decide whether an intersecting shaft/counterbore+ // pair is accepted. Counterbores normally reject immediately against+ // preceding shafts; this final symmetric check covers a shaft authored+ // after a counterbore without changing the established shaft-only route.+ foreach (var shaft in shaftHoles)+ foreach (var counterbore in counterboreHoles)+ if (CirclesTouchOrOverlap(shaft.CenterX, shaft.CenterY, shaft.Diameter / 2d, counterbore.CenterX, counterbore.CenterY, counterbore.CounterboreDiameter / 2d))+ diagnostics.Add($"ComposeCounterboreIntersectsExistingCavity:{counterbore.Name}:shaft={shaft.Name}");foreach (Match header in SlotHeader.Matches(composeBody)){var name = header.Groups["n"].Value; var body = Block(composeBody, header.Index + header.Length - 1);@@ -282,7 +335,7 @@ public static class PrismaticProfileCompositionParser}}var levels = operations.SelectMany(o => new[] { o.From, o.To }).Distinct().Order().ToArray();- var feature = diagnostics.Count == 0 ? new PrismaticProfileCompositionFeature(compose.Groups["n"].Value, "XY", "+Z", placement, operations, levels, "parser-backed-scaffold-profile-composition", shaftHoles, capsuleSlots, roundedRectangleSlots, constructionPlaneBlindDrills) : null;+ var feature = diagnostics.Count == 0 ? new PrismaticProfileCompositionFeature(compose.Groups["n"].Value, "XY", "+Z", placement, operations, levels, "parser-backed-scaffold-profile-composition", shaftHoles, capsuleSlots, roundedRectangleSlots, constructionPlaneBlindDrills, counterboreHoles) : null;return new(feature, profiles, diagnostics.Distinct().ToArray(), expansion.Evidence);}@@ -294,6 +347,37 @@ public static class PrismaticProfileCompositionParsernew($"profile:{profileName}.Outer.{names[i]}", $"{holeStableId}.axis", sourceSpan, $"Hole<Shaft>({holeStableId})", "XY"))).ToArray();return new(profileName, "XY", [new ResolvedProfileLoop2D("Outer", true, segments)]);}+ private static bool CircleContainedInBaseProfile(IReadOnlyList<PrismaticProfileOperation> operations, IReadOnlyDictionary<string, ResolvedProfile2D> profiles, double x, double y, double radius)+ {+ var baseOperation = operations.SingleOrDefault(operation => operation.Intent == PrismaticProfileIntent.Base);+ if (baseOperation is null || !profiles.TryGetValue(baseOperation.ProfileReference, out var profile) || ProfileArrangementBuilder.PointInProfile(profile, (x, y)) != ArrangementPointLocation.Inside) return false;+ return profile.Loops.Single().Segments.All(segment => DistanceToCurve((x, y), segment.Geometry) > radius + 1e-8d);+ }+ private static bool IntersectsExistingCircularCavity(IReadOnlyList<PrismaticShaftHoleFeature> shafts, IReadOnlyList<PrismaticCounterboreHoleFeature> counterbores, double x, double y, double radius) =>+ shafts.Any(hole => CirclesTouchOrOverlap(x, y, radius, hole.CenterX, hole.CenterY, hole.Diameter / 2d)) ||+ counterbores.Any(hole => CirclesTouchOrOverlap(x, y, radius, hole.CenterX, hole.CenterY, hole.CounterboreDiameter / 2d));+ private static bool CirclesTouchOrOverlap(double ax, double ay, double ar, double bx, double by, double br) => Math.Sqrt((ax - bx) * (ax - bx) + (ay - by) * (ay - by)) <= ar + br + 1e-8d;+ private static double DistanceToCurve((double X, double Y) point, LineArcProfileCurve2D curve) => curve switch+ {+ LineArcLineSegment2D line => DistanceToSegment(point, line.Start, line.End),+ LineArcCircularArc2D arc => DistanceToArc(point, arc),+ _ => double.NaN+ };+ private static double DistanceToSegment((double X, double Y) point, (double X, double Y) start, (double X, double Y) end)+ {+ var dx = end.X - start.X; var dy = end.Y - start.Y; var lengthSquared = dx * dx + dy * dy;+ var t = Math.Clamp(((point.X - start.X) * dx + (point.Y - start.Y) * dy) / lengthSquared, 0d, 1d);+ return Math.Sqrt(Math.Pow(point.X - (start.X + t * dx), 2d) + Math.Pow(point.Y - (start.Y + t * dy), 2d));+ }+ private static double DistanceToArc((double X, double Y) point, LineArcCircularArc2D arc)+ {+ var dx = point.X - arc.Center.X; var dy = point.Y - arc.Center.Y; var radial = Math.Sqrt(dx * dx + dy * dy); var angle = Math.Atan2(dy, dx);+ var delta = angle - arc.StartAngleRadians;+ if (arc.SweepAngleRadians >= 0d) while (delta < 0d) delta += 2d * Math.PI; else while (delta > 0d) delta -= 2d * Math.PI;+ if (delta / arc.SweepAngleRadians is >= -1e-8d and <= 1d + 1e-8d) return Math.Abs(radial - arc.Radius);+ var a = (arc.Center.X + arc.Radius * Math.Cos(arc.StartAngleRadians), arc.Center.Y + arc.Radius * Math.Sin(arc.StartAngleRadians)); var b = (arc.Center.X + arc.Radius * Math.Cos(arc.StartAngleRadians + arc.SweepAngleRadians), arc.Center.Y + arc.Radius * Math.Sin(arc.StartAngleRadians + arc.SweepAngleRadians));+ return Math.Min(Math.Sqrt(Math.Pow(point.X - a.Item1, 2d) + Math.Pow(point.Y - a.Item2, 2d)), Math.Sqrt(Math.Pow(point.X - b.Item1, 2d) + Math.Pow(point.Y - b.Item2, 2d)));+ }private static ResolvedProfile2D CapsuleProfile(string profileName, double x, double y, double dx, double dy, double length, double width, string slotId, string sourceSpan){var r=width/2d; var h=(length-width)/2d; var nx=-dy; var ny=dx;diff --git a/Aetheris.Kernel.Firmament/Materializer/PrismaticSectionStackCompiler.cs b/Aetheris.Kernel.Firmament/Materializer/PrismaticSectionStackCompiler.csindex 8a0bbc1c..c544604d 100644--- a/Aetheris.Kernel.Firmament/Materializer/PrismaticSectionStackCompiler.cs+++ b/Aetheris.Kernel.Firmament/Materializer/PrismaticSectionStackCompiler.cs@@ -272,6 +272,37 @@ public static class PrismaticSectionStackEmitterif (entryEdges.Length > 0 && LoopFor(entryEdges) is { } entryLoop) descendants.Add(new($"material:{hole.StableId}:entry-loop", "Loop", SemanticTopologyRole.HoleEntryLoop, hole.StableId, Loop: entryLoop, ParentStableId: hole.StableId, GeometryPreview: $"diameter={hole.Diameter:R}"));if (exitEdges.Length > 0 && LoopFor(exitEdges) is { } exitLoop) descendants.Add(new($"material:{hole.StableId}:exit-loop", "Loop", SemanticTopologyRole.HoleExitLoop, hole.StableId, Loop: exitLoop, ParentStableId: hole.StableId, GeometryPreview: $"diameter={hole.Diameter:R}"));}+ foreach (var hole in stack.Feature.CounterboreHoles ?? [])+ {+ var borePrefix = $"profile:{hole.CounterboreProfileReference}.Outer.";+ var shaftPrefix = $"profile:{hole.ShaftProfileReference}.Outer.";+ var boreSides = sideFaces.Select((side, index) => (Side: side, Face: faces[capFaces.Count + index]))+ .Where(item => item.Side.Source.StartsWith(borePrefix, StringComparison.Ordinal)).ToArray();+ var shaftSides = sideFaces.Select((side, index) => (Side: side, Face: faces[capFaces.Count + index]))+ .Where(item => item.Side.Source.StartsWith(shaftPrefix, StringComparison.Ordinal)).ToArray();+ if (boreSides.Length == 0 || shaftSides.Length == 0) { d.Add($"ComposeCounterboreSemanticSourceMissing:{hole.Name}"); continue; }+ var boreEdges = boreSides.SelectMany(item => builder.Model.Loops.Single(loop => loop.Id == item.Side.Loop).CoedgeIds)+ .Select(id => builder.Model.Coedges.Single(coedge => coedge.Id == id).EdgeId).Distinct()+ .Select(id => (Edge: id, Topology: builder.Model.Edges.Single(edge => edge.Id == id)))+ .Where(item => Math.Abs(points[item.Topology.StartVertexId].Z - points[item.Topology.EndVertexId].Z) <= Tol)+ .Select(item => (item.Edge, points[item.Topology.StartVertexId].Z)).ToArray();+ var shaftEdges = shaftSides.SelectMany(item => builder.Model.Loops.Single(loop => loop.Id == item.Side.Loop).CoedgeIds)+ .Select(id => builder.Model.Coedges.Single(coedge => coedge.Id == id).EdgeId).Distinct()+ .Select(id => (Edge: id, Topology: builder.Model.Edges.Single(edge => edge.Id == id)))+ .Where(item => Math.Abs(points[item.Topology.StartVertexId].Z - points[item.Topology.EndVertexId].Z) <= Tol)+ .Select(item => (item.Edge, points[item.Topology.StartVertexId].Z)).ToArray();+ var mouthZ = boreEdges.Max(item => item.Z); var shoulderZ = boreEdges.Min(item => item.Z); var exitZ = shaftEdges.Min(item => item.Z);+ var mouthEdges = boreEdges.Where(item => Math.Abs(item.Z - mouthZ) <= Tol).Select(item => item.Edge).Distinct().OrderBy(id => id.Value).ToArray();+ var shoulderEdges = boreEdges.Where(item => Math.Abs(item.Z - shoulderZ) <= Tol).Select(item => item.Edge).Distinct().OrderBy(id => id.Value).ToArray();+ var exitEdges = shaftEdges.Where(item => Math.Abs(item.Z - exitZ) <= Tol).Select(item => item.Edge).Distinct().OrderBy(id => id.Value).ToArray();+ LoopId? LoopFor(IReadOnlyList<EdgeId> boundary) => builder.Model.Loops.Select(loop => (loop.Id, Edges: loop.CoedgeIds.Select(id => builder.Model.Coedges.Single(x => x.Id == id).EdgeId).ToHashSet()))+ .Where(item => item.Edges.SetEquals(boundary.ToHashSet())).Select(item => (LoopId?)item.Id).SingleOrDefault();+ foreach (var face in boreSides.Select(item => item.Face).Distinct().OrderBy(id => id.Value)) descendants.Add(new($"material:{hole.StableId}:counterbore-wall:{face.Value}", "Face", SemanticTopologyRole.HoleCounterboreWallFace, hole.StableId, Face: face, ParentStableId: hole.StableId, GeometryPreview: $"diameter={hole.CounterboreDiameter:R}"));+ foreach (var face in shaftSides.Select(item => item.Face).Distinct().OrderBy(id => id.Value)) descendants.Add(new($"material:{hole.StableId}:shaft-wall:{face.Value}", "Face", SemanticTopologyRole.HoleCounterboreShaftWallFace, hole.StableId, Face: face, ParentStableId: hole.StableId, GeometryPreview: $"diameter={hole.Diameter:R}"));+ if (mouthEdges.Length > 0 && LoopFor(mouthEdges) is { } mouthLoop) descendants.Add(new($"material:{hole.StableId}:mouth", "Loop", SemanticTopologyRole.HoleCounterboreMouthLoop, hole.StableId, Loop: mouthLoop, ParentStableId: hole.StableId));+ if (shoulderEdges.Length > 0 && LoopFor(shoulderEdges) is { } shoulderLoop) descendants.Add(new($"material:{hole.StableId}:shoulder", "Loop", SemanticTopologyRole.HoleCounterboreShoulderLoop, hole.StableId, Loop: shoulderLoop, ParentStableId: hole.StableId));+ if (exitEdges.Length > 0 && LoopFor(exitEdges) is { } exitLoop) descendants.Add(new($"material:{hole.StableId}:exit", "Loop", SemanticTopologyRole.HoleExitLoop, hole.StableId, Loop: exitLoop, ParentStableId: hole.StableId));+ }foreach (var slot in stack.Feature.AllSlotProfiles){var prefix = $"profile:{slot.ProfileReference}.Outer.";@@ -300,6 +331,7 @@ public static class PrismaticSectionStackEmitter}var provenance = new List<string> { "ProfileArrangement2D", "PrismaticSectionStackConstruction", "PrismaticSectionStackBrepPlan", "AuthoritativeBRepPlan" };if ((stack.Feature.ShaftHoles?.Count ?? 0) > 0) provenance.Insert(0, "SemanticHoleComposeLowering");+ if ((stack.Feature.CounterboreHoles?.Count ?? 0) > 0) provenance.Insert(0, "SemanticCounterboreComposeLowering");if (stack.Feature.AllSlotProfiles.Any()) provenance.Insert(0, "SemanticSlotComposeLowering");var correspondence = new SemanticTopologyCorrespondence(stack.Feature.Name, descendants.DistinctBy(x => x.StableId).ToArray(), provenance);var faceMappings = new List<PrismaticSectionStackFacePlanMapping>();diff --git a/Aetheris.Kernel.Firmament/Materializer/SemanticTopologySelections.cs b/Aetheris.Kernel.Firmament/Materializer/SemanticTopologySelections.csindex bc672878..c2ecbf4a 100644--- a/Aetheris.Kernel.Firmament/Materializer/SemanticTopologySelections.cs+++ b/Aetheris.Kernel.Firmament/Materializer/SemanticTopologySelections.cs@@ -5,7 +5,7 @@ using System.Text.RegularExpressions;namespace Aetheris.Kernel.Firmament.Materializer;/// <summary>Stable roles assigned while an authoritative plan is materialized. These are not geometric queries.</summary>-public enum SemanticTopologyRole { Unknown, ProfileVertex, VerticalExtrusionEdge, LocalStartBoundary, LocalEndBoundary, LocalStartCapLoop, LocalEndCapLoop, TopBoundary, BottomBoundary, ExtrusionSideFace, TopFaceBoundaryLoop, BottomFaceBoundaryLoop, HoleEntryLoop, HoleExitLoop, HoleWallFace, HoleShaftToDrillPointLoop, HoleShaftToDrillPointEdge, HoleDrillPointFace, HoleTipVertex, SlotEntryLoop, SlotExitLoop, SlotWallFace, SlotStraightWallFace, SlotEndWallFace, ComposeTransition, EdgeFinishReplacementFace }+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 }public enum SemanticSelectionRequirement { ExactlyOne, OneOrMore, ConnectedChain, ClosedLoop, NonEmptyFaceSet }public enum SemanticSelectionFailure { None, SemanticSourceNotFound, NoMaterializedDescendants, AmbiguousBodyContext, SelectionCardinalityMismatch, DescendantsNotConnected, DescendantsBranch, DescendantsDoNotClose, MixedBoundaryRoles, UnsupportedTopologyChange, SelectionConsumerMismatch }diff --git a/docs/firmament/composed-host-counterbore-pmi-x6.md b/docs/firmament/composed-host-counterbore-pmi-x6.mdnew file mode 100644index 00000000..727425c6--- /dev/null+++ b/docs/firmament/composed-host-counterbore-pmi-x6.md@@ -0,0 +1,36 @@+# Composed-host Counterbore and PMI (X6)++Profile/Compose used to take an early geometry-only export route. It admitted+through `Hole<Shaft>` cuts, but bypassed the normalized V2 PMI records and had+no stepped Counterbore plan.++X6 admits one bounded host class: a single enclosed, constant-XY-section+Profile/Compose stock body with an implicit or explicit world-XY/+Z placement.+`Hole<Counterbore>` is currently a top-entry (`On: +Z`) `ThroughAll` feature.+Its shaft and counterbore circles must each lie strictly inside the base profile;+counterbore depth must not exceed host depth; and the largest counterbore circle+must be disjoint from every other circular cavity. Other axes, blind endings,+touching cavities, and multi-body/non-prismatic hosts are rejected with typed+`ComposeCounterbore*` diagnostics.++The authoritative plan is a prismatic section stack, not a Boolean operation:+the shaft circle removes material over the full extrusion interval, while the+larger counterbore circle removes material over the entry-depth interval. The+stack emits exact cylindrical walls, the planar shoulder transition, entry and+exit loops, and stable semantic descendants for Mouth, CounterboreWall,+Shoulder, ShaftWall, and Exit.++All V2 PMI now passes from the normalized document through the common AP242+export boundary, including for Profile/Compose. `HoleDiameter` targets the+shaft diameter of a Counterbore feature; it does not silently dimension the+larger counterbore relief. Datum targets continue to resolve through the+canonical face selector binder.++The acceptance source is+`fixtures/FirmamentV2/Canonical/valid/profile-compose-l-bracket-counterbore-pmi.firmament`.+It has two Pattern-generated shaft holes, one Counterbore, Datum A, and a+toleranced HoleDiameter callout. Its analytic volume is+`28800 - 540π = 27103.539816... mm³`.++Polygon-boundary EdgeFinish remains deliberately unsupported on Profile/Compose.+This work neither adds arbitrary boundary finishing nor generic Boolean support.diff --git a/docs/firmament/v2-canonical-authoring.md b/docs/firmament/v2-canonical-authoring.mdindex 783e0acb..da22aec1 100644--- a/docs/firmament/v2-canonical-authoring.md+++ b/docs/firmament/v2-canonical-authoring.md@@ -60,6 +60,21 @@ it binds to semantic features rather than raw topology IDs. SeeThe currently proven low-ceremony production shape is one Box, one top-face ThroughAll shaft Hole, and one disjoint `+Z Boundary Chamfer`. It routes to `CombinedHoleEdgeFinish`, then authoritative STEP export and STEP reimport verification.+### Profile/Compose holes++An admitted prismatic `Profile`/`Compose` body supports deterministic+Pattern-generated `Hole<Shaft>` features and a direct `Hole<Counterbore>` on+its `+Z` entry face. The counterbore is currently `ThroughAll`, must have its+full circular footprint inside the profile material, and must be disjoint from+all other cavities. Profile/Compose bodies also use the normal `Pmi` export+route. A complete L-bracket with Pattern shafts, Counterbore, Datum, and a+toleranced diameter callout is maintained at+`fixtures/FirmamentV2/Canonical/valid/profile-compose-l-bracket-counterbore-pmi.firmament`.++Other Counterbore orientations/end conditions, touching or overlapping+cavities, non-prismatic composition, and polygon-boundary EdgeFinish remain+unsupported and diagnose explicitly.+## Advanced declarations in the same documentAdvanced source uses the same `Model { Units: mm }` root. Declarations may bediff --git a/docs/firmament/v2-pmi-authoring.md b/docs/firmament/v2-pmi-authoring.mdindex 2f623351..876101c3 100644--- a/docs/firmament/v2-pmi-authoring.md+++ b/docs/firmament/v2-pmi-authoring.md@@ -27,3 +27,12 @@ use `Tolerance`, `DatumRefs`, `Target`, and `Value` exactly; misspellings arenot ignored. See`fixtures/FirmamentV2/Canonical/valid/box-hole-pmi.firmament` for anexportable example.++Profile/Compose uses this exact same normalized PMI route. A `Datum` may target+the composed host's admitted `face(+Z)` selector, and `HoleDiameter` may target+a composed `Hole<Shaft>` or `Hole<Counterbore>` by feature name. For a+Counterbore, `HoleDiameter` means the shaft diameter; there is no separate+counterbore-diameter PMI kind. See+`fixtures/FirmamentV2/Canonical/valid/profile-compose-l-bracket-counterbore-pmi.firmament`+for the complete accepted example. Datum and HoleDiameter are the currently+supported composed-host PMI kinds.diff --git a/fixtures/FirmamentV2/Canonical/valid/profile-compose-l-bracket-counterbore-pmi.firmament b/fixtures/FirmamentV2/Canonical/valid/profile-compose-l-bracket-counterbore-pmi.firmamentnew file mode 100644index 00000000..9081ea9d--- /dev/null+++ b/fixtures/FirmamentV2/Canonical/valid/profile-compose-l-bracket-counterbore-pmi.firmament@@ -0,0 +1,57 @@+Model ProfileComposeLBracketCounterborePmi {+ Units: mm++ Record MountSpec { Center: Point2 Diameter: Length }+ Static Mounts: MountSpec[] = [+ MountSpec { Center: Point2(20mm, -10mm) Diameter: 6mm }+ MountSpec { Center: Point2(-30mm, 20mm) Diameter: 6mm }+ ]+ Template ShaftHole(MountSpec spec) {+ Hole<Shaft> Mount {+ On: +Z+ Center: spec.Center+ Diameter: spec.Diameter+ End: ThroughAll+ }+ }++ Concept Struct Layout On XY {+ Rect2 Horizontal { Center: [0mm, -10mm]; Size: [80mm, 20mm] }+ Rect2 Vertical { Center: [-30mm, 10mm]; Size: [20mm, 60mm] }+ Point2 Notch { Position: [-20mm, 0mm] }+ }++ Profile Bracket Using Layout { Loop Outer {+ Segment South { Trace: Horizontal.Bottom; From: Horizontal.BottomLeft; To: Horizontal.BottomRight }+ Segment East { Trace: Horizontal.Right; From: Horizontal.BottomRight; To: Horizontal.TopRight }+ Segment Inner { Trace: Horizontal.Top; From: Horizontal.TopRight; To: Notch }+ Segment Upright { Trace: Vertical.Right; From: Notch; To: Vertical.TopRight }+ Segment North { Trace: Vertical.Top; From: Vertical.TopRight; To: Vertical.TopLeft }+ Segment West { Trace: Vertical.Left; From: Vertical.TopLeft; To: Horizontal.BottomLeft }+ } }++ Struct BracketBody {+ Compose BracketBody {+ Base Stock { Profile: Bracket; From: 0mm; To: 12mm; Role: Stock }+ Pattern MountPattern Over Mounts { ShaftHole(Current) }+ Hole<Counterbore> CounterboredMount {+ On: +Z+ Center: Point2(-30mm, -10mm)+ Diameter: 8mm+ CounterboreDiameter: 14mm+ CounterboreDepth: 4mm+ End: ThroughAll+ }+ }+ }++ Pmi {+ Datum A { Target: face(+Z) }+ HoleDiameter CounterboredMountDiameter {+ Target: CounterboredMount+ Value: 8mm+ Tolerance: PlusMinus(0.05mm, 0.02mm)+ DatumRefs: [A]+ }+ }+}