Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Integrate semantic corner profiles into rectangle edge paths

Yuechen Lia7f93019e344
diff --git a/Aetheris.Kernel.Firmament.Tests/SemanticCornerProfileM3Tests.cs b/Aetheris.Kernel.Firmament.Tests/SemanticCornerProfileM3Tests.cs
new file mode 100644
index 00000000..ef39264e
--- /dev/null
+++ b/Aetheris.Kernel.Firmament.Tests/SemanticCornerProfileM3Tests.cs
@@ -0,0 +1,101 @@
+using Aetheris.Kernel.Firmament.FirmamentV2;
+using Aetheris.Kernel.Firmament.Materializer;
+using Aetheris.Semantics;
+
+namespace Aetheris.Kernel.Firmament.Tests;
+
+public sealed class SemanticCornerProfileM3Tests
+{
+ [Fact]
+ public void Firmament_RectangleComposesEdgeFragmentAndTwoSharedCornersThenExtrudes()
+ {
+ const string source = """
+ Rect2 PlateBase { Center: [0mm, 0mm]; Size: [100mm, 60mm] }
+ EdgeProfile PlateBase.Bottom {
+ Tab MountTab { CenteredAt: 50mm; Width: 12mm; Extension: 6mm; Side: Right }
+ }
+ CornerProfile PlateBase.BottomRight {
+ Chamfer CableClearance { SetbackA: 8mm; SetbackB: 5mm; }
+ }
+ CornerProfile PlateBase.TopLeft {
+ NotchCorner LocatingStep { SetbackA: 7mm; SetbackB: 4mm; }
+ }
+ Profile Plate From PlateBase
+ Extrude Solid { Profile: Plate; From: 0mm; To: 3mm }
+ """;
+
+ var parsed = ProfileAuthoringParser.Parse(source);
+
+ Assert.Empty(parsed.Diagnostics);
+ Assert.NotNull(parsed.Profile);
+ Assert.True(ResolvedProfile2DValidator.Validate(parsed.Profile!).IsValid);
+ Assert.Equal(LineArcProfileExtrudeStatus.Succeeded, ResolvedProfile2DValidator.Extrude(parsed.Profile!, parsed.Height).Status);
+ var segments = parsed.Profile.Loops.Single().Segments;
+ Assert.Single(segments, x => x.Provenance.ConceptStableId == "concept-path:PlateBase.BottomRight.CableClearance");
+ Assert.Equal(2, segments.Count(x => x.Provenance.ConceptStableId == "concept-path:PlateBase.TopLeft.LocatingStep"));
+ Assert.Equal(3, segments.Count(x => x.Provenance.ConceptStableId == "concept-path:PlateBase.Bottom.MountTab"));
+
+ var root = FirmamentSemanticValues.FromProfilesAndConceptPaths(source).Single(x => x.ExposedName == "Plate");
+ var reference = new SemanticReference(root, [], new("test", 0, 1));
+ Assert.True(SemanticValueValidator.TryResolveMember(reference, new("BottomRight", new("test", 0, 1)), out var corner, out var cornerDiagnostic), cornerDiagnostic?.Message);
+ Assert.Equal("SemanticCorner", corner!.Value.Type.Name);
+ Assert.True(SemanticValueValidator.TryResolveMember(corner, new("CableClearance", new("test", 0, 1)), out var chamfer, out var chamferDiagnostic), chamferDiagnostic?.Message);
+ Assert.Equal("Chamfer", chamfer!.Value.Type.Name);
+ }
+
+ [Fact]
+ public void Parser_RejectsCornerConsumptionThatOverlapsNamedEdgeFragment()
+ {
+ const string source = """
+ Rect2 PlateBase { Center: [0mm, 0mm]; Size: [100mm, 60mm] }
+ EdgeProfile PlateBase.Bottom {
+ Tab EndTab { FromEnd: 2mm; Width: 5mm; Extension: 2mm; Side: Right }
+ }
+ CornerProfile PlateBase.BottomRight {
+ Chamfer EndChamfer { Setback: 8mm; }
+ }
+ Profile Plate From PlateBase
+ Extrude Solid { Profile: Plate; From: 0mm; To: 3mm }
+ """;
+
+ var parsed = ProfileAuthoringParser.Parse(source);
+
+ Assert.Null(parsed.Profile);
+ Assert.Contains("semantic-corner-edge-fragment-conflict:PlateBase.BottomRight:PlateBase.Bottom.EndTab:owner=PlateBase.Bottom", parsed.Diagnostics);
+ }
+
+ [Fact]
+ public void Resolver_SupportsNonOrthogonalEdgesAndUsesNoCandidateSelection()
+ {
+ var source = new SemanticCornerProfileIr(
+ "Plate.ObliqueCorner", "Plate.ObliqueCorner", "Plate.EdgeA", "Plate.EdgeB",
+ new(-10, 0), new(0, 0), new(5, 10),
+ new SemanticCornerChamferIr("ExactChamfer", "Plate.ObliqueCorner.ExactChamfer", 2, 3, "test"),
+ "u/v", "test");
+
+ var first = SemanticCornerProfileResolver.Resolve(source);
+ var second = SemanticCornerProfileResolver.Resolve(source);
+
+ Assert.True(first.IsSuccess, string.Join('\n', first.Diagnostics));
+ Assert.Single(first.Corner!.CurveDescendants);
+ Assert.Equal(first.Corner.DeterministicHash, second.Corner!.DeterministicHash);
+ Assert.Equal(new SemanticProfilePoint(-2, 0), first.Corner.EdgeAEndpoint);
+ Assert.Equal(3, Math.Sqrt(first.Corner.EdgeBEndpoint.X * first.Corner.EdgeBEndpoint.X + first.Corner.EdgeBEndpoint.Y * first.Corner.EdgeBEndpoint.Y), 8);
+ }
+
+ [Fact]
+ public void Resolver_TrimsBothCarrierEndpointsAndOmitsZeroLengthSpans()
+ {
+ var edge = new SemanticEdgeProfileIr("Plate.Bottom", "Plate.Bottom", new(0, 0), new(100, 0), [], "u/v", "test");
+
+ var result = SemanticEdgeProfileResolver.Resolve(edge, new(6, 8, "Plate.BottomLeft", "Plate.BottomRight"));
+
+ Assert.True(result.IsSuccess, string.Join('\n', result.Diagnostics));
+ var carrier = Assert.Single(result.Profile!.OrderedMembers);
+ Assert.Equal(6, carrier.StartU);
+ Assert.Equal(92, carrier.EndU);
+ var line = Assert.IsType<LineArcLineSegment2D>(Assert.Single(carrier.CurveDescendants).Geometry);
+ Assert.Equal((6d, 0d), line.Start);
+ Assert.Equal((92d, 0d), line.End);
+ }
+}
diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentSemanticValues.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentSemanticValues.cs
index 2f98263b..27783582 100644
--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentSemanticValues.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentSemanticValues.cs
@@ -89,8 +89,8 @@ public static class FirmamentSemanticValues
}
}
members.AddRange(edgeMembers.OrderBy(x => x.Key, StringComparer.Ordinal).Select(pair => new SemanticValue(
- $"concept-path:{inspection.Name}.{pair.Key}", new("SemanticEdge"),
- exposedMembers: pair.Value, provenance: [new("semantic-edge-owner", inspection.Name, pair.Key, authoredSpan)],
+ $"concept-path:{inspection.Name}.{pair.Key}", new(pair.Key is "BottomRight" or "TopRight" or "TopLeft" or "BottomLeft" ? "SemanticCorner" : "SemanticEdge"),
+ exposedMembers: pair.Value, provenance: [new(pair.Key is "BottomRight" or "TopRight" or "TopLeft" or "BottomLeft" ? "semantic-corner-owner" : "semantic-edge-owner", inspection.Name, pair.Key, authoredSpan)],
authoredSourceSpan: authoredSpan, generatedSourceSpan: expansion is null ? null : span, exposedName: pair.Key)));
var capabilities = new List<ISemanticCapability>();
var bindings = new List<SemanticBinding>();
diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringParser.cs b/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringParser.cs
index 2743c95d..39e426aa 100644
--- a/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringParser.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringParser.cs
@@ -184,31 +184,74 @@ public static class ProfileAuthoringParser
private static void BindRectEdgeProfiles(string source, Dictionary<string, BoundPath> result, List<string> diagnostics)
{
var programs = FindBlocks(source, @"\bEdgeProfile\s+(?<owner>[A-Za-z_]\w*)\.(?<edge>[A-Za-z_]\w*)\s*\{").ToArray();
+ var cornerPrograms = FindBlocks(source, @"\bCornerProfile\s+(?<owner>[A-Za-z_]\w*)\.(?<corner>[A-Za-z_]\w*)\s*\{").ToArray();
foreach (Match rectangle in Rect.Matches(source))
{
var name = rectangle.Groups["n"].Value;
var isProfileSource = Regex.IsMatch(source, $@"\bProfile\s+[A-Za-z_]\w*\s+From\s+{Regex.Escape(name)}\b", RegexOptions.CultureInvariant);
- if (!isProfileSource && !programs.Any(x => x.Match.Groups["owner"].Value == name)) continue;
+ if (!isProfileSource && !programs.Any(x => x.Match.Groups["owner"].Value == name) && !cornerPrograms.Any(x => x.Match.Groups["owner"].Value == name)) continue;
if (!TryNumber(rectangle.Groups["w"].Value, out var width) || !TryNumber(rectangle.Groups["h"].Value, out var height) ||
!TryNumber(rectangle.Groups["x"].Value, out var cx) || !TryNumber(rectangle.Groups["y"].Value, out var cy)) continue;
if (result.ContainsKey(name)) { diagnostics.Add($"profile-edge-owner-name-collision:{name}"); continue; }
var bl = (X: cx - width / 2, Y: cy - height / 2); var br = (X: cx + width / 2, Y: cy - height / 2);
var tr = (X: cx + width / 2, Y: cy + height / 2); var tl = (X: cx - width / 2, Y: cy + height / 2);
var path = new BoundPath(name, bl, 0, []);
+ var edges = new Dictionary<string, ((double X, double Y) Start, (double X, double Y) End)>(StringComparer.Ordinal)
+ {
+ ["Bottom"] = (bl, br), ["Right"] = (br, tr), ["Top"] = (tr, tl), ["Left"] = (tl, bl)
+ };
+ var cornerEdges = new Dictionary<string, (string EdgeA, string EdgeB)>(StringComparer.Ordinal)
+ {
+ ["BottomRight"] = ("Bottom", "Right"), ["TopRight"] = ("Right", "Top"),
+ ["TopLeft"] = ("Top", "Left"), ["BottomLeft"] = ("Left", "Bottom")
+ };
+ var resolvedCorners = new Dictionary<string, ResolvedSemanticCornerProfileIr>(StringComparer.Ordinal);
+ foreach (var corner in cornerEdges)
+ {
+ var matching = cornerPrograms.Where(x => x.Match.Groups["owner"].Value == name && x.Match.Groups["corner"].Value == corner.Key).ToArray();
+ if (matching.Length == 0) continue;
+ if (matching.Length > 1) { diagnostics.Add($"semantic-corner-duplicate-program:{name}.{corner.Key}"); continue; }
+ var operations = FindBlocks(matching[0].Body, @"\b(?<kind>Chamfer|Cutback|Taper|NotchCorner)\s+(?<name>[A-Za-z_]\w*)\s*\{").ToArray();
+ if (operations.Length != 1) { diagnostics.Add($"semantic-corner-operation-required:{name}.{corner.Key}"); continue; }
+ var operation = operations[0]; var operationName = operation.Match.Groups["name"].Value; var operationKind = operation.Match.Groups["kind"].Value;
+ var equal = Property(operation.Body, "Setback"); var aText = Property(operation.Body, "SetbackA") ?? equal; var bText = Property(operation.Body, "SetbackB") ?? equal;
+ var operationId = $"{name}.{corner.Key}.{operationName}";
+ if (aText is null || bText is null || !TryMeasure(aText, "mm", out var setbackA) || !TryMeasure(bText, "mm", out var setbackB))
+ { diagnostics.Add($"semantic-corner-setbacks-required:{operationId}"); continue; }
+ var pair = corner.Value; var edgeA = edges[pair.EdgeA]; var edgeB = edges[pair.EdgeB];
+ SemanticCornerOperationIr authored = operationKind switch
+ {
+ "Chamfer" => new SemanticCornerChamferIr(operationName, operationId, setbackA, setbackB, $"offset:{operation.Match.Index}"),
+ "Cutback" => new SemanticCornerCutbackIr(operationName, operationId, setbackA, setbackB, $"offset:{operation.Match.Index}"),
+ "Taper" => new SemanticCornerTaperIr(operationName, operationId, setbackA, setbackB, $"offset:{operation.Match.Index}"),
+ "NotchCorner" => new SemanticCornerNotchIr(operationName, operationId, setbackA, setbackB, $"offset:{operation.Match.Index}"),
+ _ => throw new InvalidOperationException()
+ };
+ var cornerPath = $"{name}.{corner.Key}";
+ var resolution = SemanticCornerProfileResolver.Resolve(new(cornerPath, cornerPath, $"{name}.{pair.EdgeA}", $"{name}.{pair.EdgeB}",
+ new(edgeA.Start.X, edgeA.Start.Y), new(edgeA.End.X, edgeA.End.Y), new(edgeB.End.X, edgeB.End.Y), authored,
+ $"{cornerPath}[u=away-on-{pair.EdgeA},v=away-on-{pair.EdgeB}]", $"CornerProfile {cornerPath}"));
+ if (!resolution.IsSuccess) diagnostics.AddRange(resolution.Diagnostics);
+ else resolvedCorners[corner.Key] = resolution.Corner!;
+ }
AddEdge("Bottom", bl, br); AddEdge("Right", br, tr); AddEdge("Top", tr, tl); AddEdge("Left", tl, bl);
result[name] = path;
void AddEdge(string edge, (double X, double Y) start, (double X, double Y) end)
{
var matching = programs.Where(x => x.Match.Groups["owner"].Value == name && x.Match.Groups["edge"].Value == edge).ToArray();
- if (matching.Length == 0)
+ var startCorner = cornerEdges.First(x => x.Value.EdgeB == edge).Key;
+ var endCorner = cornerEdges.First(x => x.Value.EdgeA == edge).Key;
+ resolvedCorners.TryGetValue(startCorner, out var startResolution);
+ resolvedCorners.TryGetValue(endCorner, out var endResolution);
+ if (matching.Length == 0 && startResolution is null && endResolution is null)
{
path.Steps.Add(new(edge, "Span", $"{name}.{edge}", $"{name}.{edge}.End", [new LineArcLineSegment2D(start, end)], start, end, Heading(start, end)));
return;
}
if (matching.Length > 1) { diagnostics.Add($"semantic-edge-duplicate-program:{name}.{edge}"); return; }
var fragments = new List<SemanticEdgeFragmentIr>();
- foreach (var step in FindPathSteps(matching[0].Body).Where(x => x.Kind is "Chamfer" or "Step" or "Notch" or "Cutback" or "Tab"))
+ foreach (var step in matching.Length == 0 ? Enumerable.Empty<PathStep>() : FindPathSteps(matching[0].Body).Where(x => x.Kind is "Chamfer" or "Step" or "Notch" or "Cutback" or "Tab"))
{
var id = $"{name}.{edge}.{step.Name}";
var anchors = new[] { ("FromStart", SemanticEdgeAnchorKind.FromStart), ("FromEnd", SemanticEdgeAnchorKind.FromEnd), ("CenteredAt", SemanticEdgeAnchorKind.CenteredAt) }
@@ -225,19 +268,31 @@ public static class ProfileAuthoringParser
else diagnostics.Add($"semantic-edge-fragment-properties-invalid:{id}:{step.Kind}");
if (fragment is not null) fragments.Add(fragment);
}
- var resolution = SemanticEdgeProfileResolver.Resolve(new($"{name}.{edge}", $"{name}.{edge}", new(start.X, start.Y), new(end.X, end.Y), fragments, $"{name}.{edge}[u,v]", $"EdgeProfile {name}.{edge}"));
+ var consumption = new SemanticEdgeEndpointConsumptionIr(
+ startResolution?.EdgeBConsumption ?? 0d, endResolution?.EdgeAConsumption ?? 0d,
+ startResolution?.Source.CornerPath, endResolution?.Source.CornerPath);
+ var resolution = SemanticEdgeProfileResolver.Resolve(new($"{name}.{edge}", $"{name}.{edge}", new(start.X, start.Y), new(end.X, end.Y), fragments, $"{name}.{edge}[u,v]", $"EdgeProfile {name}.{edge}"), consumption);
if (!resolution.IsSuccess) { diagnostics.AddRange(resolution.Diagnostics); return; }
foreach (var member in resolution.Profile!.OrderedMembers)
{
var first = ((LineArcLineSegment2D)member.CurveDescendants.First().Geometry).Start; var last = ((LineArcLineSegment2D)member.CurveDescendants.Last().Geometry).End;
path.Steps.Add(new($"{edge}.{member.Name}", member.Kind, $"{name}.{edge}.{member.Name}", $"{name}.{edge}.{member.Name}.End", member.CurveDescendants.Select(x => x.Geometry).ToArray(), first, last, Heading(first, last)));
}
+ if (endResolution is not null)
+ {
+ var member = endResolution.Source.Operation; var first = ((LineArcLineSegment2D)endResolution.CurveDescendants.First().Geometry).Start; var last = ((LineArcLineSegment2D)endResolution.CurveDescendants.Last().Geometry).End;
+ path.Steps.Add(new($"{endCorner}.{member.Name}", member.Kind, member.StableId, $"{member.StableId}.End", endResolution.CurveDescendants.Select(x => x.Geometry).ToArray(), first, last, Heading(first, last)));
+ }
}
}
foreach (var program in programs.Where(p => !result.ContainsKey(p.Match.Groups["owner"].Value)))
diagnostics.Add($"semantic-edge-owner-path-missing:{program.Match.Groups["owner"].Value}.{program.Match.Groups["edge"].Value}");
foreach (var program in programs.Where(p => result.ContainsKey(p.Match.Groups["owner"].Value) && p.Match.Groups["edge"].Value is not ("Bottom" or "Right" or "Top" or "Left")))
diagnostics.Add($"semantic-edge-owner-member-missing:{program.Match.Groups["owner"].Value}.{program.Match.Groups["edge"].Value}:available=Bottom,Right,Top,Left");
+ foreach (var program in cornerPrograms.Where(p => !result.ContainsKey(p.Match.Groups["owner"].Value)))
+ diagnostics.Add($"semantic-corner-owner-path-missing:{program.Match.Groups["owner"].Value}.{program.Match.Groups["corner"].Value}");
+ foreach (var program in cornerPrograms.Where(p => result.ContainsKey(p.Match.Groups["owner"].Value) && p.Match.Groups["corner"].Value is not ("BottomRight" or "TopRight" or "TopLeft" or "BottomLeft")))
+ diagnostics.Add($"semantic-corner-owner-member-missing:{program.Match.Groups["owner"].Value}.{program.Match.Groups["corner"].Value}:available=BottomRight,TopRight,TopLeft,BottomLeft");
}
private static bool TryBindStep(string path, PathStep step, (double X, double Y) current, ref double headingDegrees, (double X, double Y) start, IReadOnlyDictionary<string, (double X, double Y)> points, out IReadOnlyList<LineArcProfileCurve2D>? curves, out (double X, double Y) endpoint, out string? diagnostic)
diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/SemanticCornerProfileIr.cs b/Aetheris.Kernel.Firmament/FirmamentV2/SemanticCornerProfileIr.cs
new file mode 100644
index 00000000..18470628
--- /dev/null
+++ b/Aetheris.Kernel.Firmament/FirmamentV2/SemanticCornerProfileIr.cs
@@ -0,0 +1,118 @@
+using System.Diagnostics;
+using System.Security.Cryptography;
+using System.Text;
+using Aetheris.Kernel.Firmament.Materializer;
+
+namespace Aetheris.Kernel.Firmament.FirmamentV2;
+
+/// <summary>
+/// First-class ownership for the semantic vertex shared by two directed profile edges.
+/// Edge A ends at the corner and edge B starts there. Operations consume a suffix of A
+/// and a prefix of B; exact curve ordinals are descendants, never the corner identity.
+/// </summary>
+public sealed record SemanticCornerProfileIr(
+ string CornerPath,
+ string StableId,
+ string EdgeAPath,
+ string EdgeBPath,
+ SemanticProfilePoint EdgeAStart,
+ SemanticProfilePoint Corner,
+ SemanticProfilePoint EdgeBEnd,
+ SemanticCornerOperationIr Operation,
+ string LocalFrame,
+ string Provenance);
+
+public abstract record SemanticCornerOperationIr(
+ string Name, string StableId, string Kind, double SetbackA, double SetbackB, string SourceSpan);
+
+public sealed record SemanticCornerChamferIr(
+ string Name, string StableId, double SetbackA, double SetbackB, string SourceSpan)
+ : SemanticCornerOperationIr(Name, StableId, "Chamfer", SetbackA, SetbackB, SourceSpan);
+
+public sealed record SemanticCornerCutbackIr(
+ string Name, string StableId, double SetbackA, double SetbackB, string SourceSpan)
+ : SemanticCornerOperationIr(Name, StableId, "Cutback", SetbackA, SetbackB, SourceSpan);
+
+public sealed record SemanticCornerTaperIr(
+ string Name, string StableId, double SetbackA, double SetbackB, string SourceSpan)
+ : SemanticCornerOperationIr(Name, StableId, "Taper", SetbackA, SetbackB, SourceSpan);
+
+/// <summary>A rectangular material-removal step in the bounded corner u/v frame.</summary>
+public sealed record SemanticCornerNotchIr(
+ string Name, string StableId, double SetbackA, double SetbackB, string SourceSpan)
+ : SemanticCornerOperationIr(Name, StableId, "NotchCorner", SetbackA, SetbackB, SourceSpan);
+
+public sealed record ResolvedSemanticCornerProfileIr(
+ SemanticCornerProfileIr Source,
+ SemanticProfilePoint EdgeAEndpoint,
+ SemanticProfilePoint EdgeBEndpoint,
+ IReadOnlyList<ResolvedSemanticProfileCurveIr> CurveDescendants,
+ string DeterministicHash,
+ TimeSpan ResolutionTime)
+{
+ public double EdgeAConsumption => Source.Operation.SetbackA;
+ public double EdgeBConsumption => Source.Operation.SetbackB;
+ public IReadOnlyList<LineArcProfileCurve2D> ExactReplacementChain => CurveDescendants.Select(x => x.Geometry).ToArray();
+}
+
+public sealed record SemanticCornerProfileResolution(ResolvedSemanticCornerProfileIr? Corner, IReadOnlyList<string> Diagnostics)
+{
+ public bool IsSuccess => Corner is not null && Diagnostics.Count == 0;
+}
+
+/// <summary>
+/// Deterministic lowering for fully specified authored corner topology. There is no
+/// candidate selection here: hard semantic and geometric constraints either admit the
+/// single authored construction or reject it before contour assembly.
+/// </summary>
+public static class SemanticCornerProfileResolver
+{
+ private const double Tolerance = 1e-8;
+
+ public static SemanticCornerProfileResolution Resolve(SemanticCornerProfileIr source)
+ {
+ ArgumentNullException.ThrowIfNull(source);
+ var clock = Stopwatch.StartNew();
+ var diagnostics = new List<string>();
+ var aVector = new SemanticProfilePoint(source.EdgeAStart.X - source.Corner.X, source.EdgeAStart.Y - source.Corner.Y);
+ var bVector = new SemanticProfilePoint(source.EdgeBEnd.X - source.Corner.X, source.EdgeBEnd.Y - source.Corner.Y);
+ var aLength = Length(aVector); var bLength = Length(bVector);
+ if (!Positive(aLength) || !Positive(bLength)) diagnostics.Add($"semantic-corner-edge-degenerate:{source.CornerPath}:{source.EdgeAPath}:{source.EdgeBPath}");
+ var cross = aVector.X * bVector.Y - aVector.Y * bVector.X;
+ if (double.IsFinite(aLength) && double.IsFinite(bLength) && Math.Abs(cross) <= Tolerance * aLength * bLength)
+ diagnostics.Add($"semantic-corner-edges-collinear:{source.CornerPath}:{source.EdgeAPath}:{source.EdgeBPath}");
+ var operation = source.Operation;
+ if (!Positive(operation.SetbackA) || !Positive(operation.SetbackB))
+ diagnostics.Add($"semantic-corner-invalid-setback:{operation.StableId}:SetbackA={operation.SetbackA:R}:SetbackB={operation.SetbackB:R}");
+ if (operation.SetbackA >= aLength - Tolerance || operation.SetbackB >= bLength - Tolerance)
+ diagnostics.Add($"semantic-corner-consumption-out-of-bounds:{operation.StableId}:{source.EdgeAPath}={operation.SetbackA:R}/{aLength:R}:{source.EdgeBPath}={operation.SetbackB:R}/{bLength:R}");
+ if (diagnostics.Count > 0) return new(null, diagnostics);
+
+ var u = new SemanticProfilePoint(aVector.X / aLength, aVector.Y / aLength);
+ var v = new SemanticProfilePoint(bVector.X / bLength, bVector.Y / bLength);
+ var a = Add(source.Corner, u, operation.SetbackA);
+ var b = Add(source.Corner, v, operation.SetbackB);
+ IReadOnlyList<LineArcProfileCurve2D> curves = operation switch
+ {
+ SemanticCornerChamferIr or SemanticCornerCutbackIr or SemanticCornerTaperIr =>
+ [new LineArcLineSegment2D(ToTuple(a), ToTuple(b))],
+ SemanticCornerNotchIr =>
+ [new LineArcLineSegment2D(ToTuple(a), ToTuple(new(a.X + v.X * operation.SetbackB, a.Y + v.Y * operation.SetbackB))),
+ new LineArcLineSegment2D(ToTuple(new(a.X + v.X * operation.SetbackB, a.Y + v.Y * operation.SetbackB)), ToTuple(b))],
+ _ => []
+ };
+ if (curves.Count == 0) return new(null, [$"semantic-corner-operation-unsupported:{operation.StableId}:{operation.Kind}"]);
+
+ var descendants = curves.Select((geometry, ordinal) => new ResolvedSemanticProfileCurveIr(
+ $"{operation.StableId}.curve{ordinal:D2}", ordinal, geometry, $"lowered-from:{operation.StableId};corner:{source.CornerPath};edges:{source.EdgeAPath},{source.EdgeBPath}")).ToArray();
+ clock.Stop();
+ var hashText = string.Join("|", descendants.Select(x => $"{x.StableId}:{x.Geometry}"));
+ var hash = Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(hashText))).ToLowerInvariant();
+ return new(new(source, a, b, descendants, hash, clock.Elapsed), []);
+ }
+
+ private static bool Positive(double value) => double.IsFinite(value) && value > Tolerance;
+ private static double Length(SemanticProfilePoint value) => Math.Sqrt(value.X * value.X + value.Y * value.Y);
+ private static SemanticProfilePoint Add(SemanticProfilePoint origin, SemanticProfilePoint direction, double distance) => new(origin.X + direction.X * distance, origin.Y + direction.Y * distance);
+ private static (double X, double Y) ToTuple(SemanticProfilePoint point) => (point.X, point.Y);
+}
diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/SemanticEdgeProfileIr.cs b/Aetheris.Kernel.Firmament/FirmamentV2/SemanticEdgeProfileIr.cs
index bfa30557..d788a564 100644
--- a/Aetheris.Kernel.Firmament/FirmamentV2/SemanticEdgeProfileIr.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentV2/SemanticEdgeProfileIr.cs
@@ -51,6 +51,12 @@ public sealed record SemanticEdgeProfileResolution(ResolvedSemanticEdgeProfileIr
public bool IsSuccess => Profile is not null && Diagnostics.Count == 0;
}
+public sealed record SemanticEdgeEndpointConsumptionIr(
+ double Start, double End, string? StartCornerPath = null, string? EndCornerPath = null)
+{
+ public static SemanticEdgeEndpointConsumptionIr None { get; } = new(0, 0);
+}
+
/// <summary>
/// Resolves independently anchored fragments in the owner's u/v frame and inserts every
/// untouched carrier span. It is intentionally bounded to baseline-returning fragments.
@@ -60,6 +66,9 @@ public static class SemanticEdgeProfileResolver
private const double Tolerance = 1e-8;
public static SemanticEdgeProfileResolution Resolve(SemanticEdgeProfileIr source)
+ => Resolve(source, SemanticEdgeEndpointConsumptionIr.None);
+
+ public static SemanticEdgeProfileResolution Resolve(SemanticEdgeProfileIr source, SemanticEdgeEndpointConsumptionIr consumption)
{
ArgumentNullException.ThrowIfNull(source);
var clock = Stopwatch.StartNew();
@@ -68,6 +77,8 @@ public static class SemanticEdgeProfileResolver
var length = Math.Sqrt(dx * dx + dy * dy);
if (!double.IsFinite(length) || length <= Tolerance)
return new(null, [$"semantic-edge-owner-degenerate:{source.OwnerPath}"]);
+ if (!double.IsFinite(consumption.Start) || !double.IsFinite(consumption.End) || consumption.Start < -Tolerance || consumption.End < -Tolerance || consumption.Start + consumption.End >= length - Tolerance)
+ return new(null, [$"semantic-edge-corner-consumption-invalid:{source.OwnerPath}:start={consumption.Start:R}:end={consumption.End:R}:length={length:R}"]);
var tx = dx / length; var ty = dy / length; var nx = -ty; var ny = tx;
var ids = new HashSet<string>(StringComparer.Ordinal);
var placed = new List<(SemanticEdgeFragmentIr Fragment, double Start, double End)>();
@@ -94,13 +105,20 @@ public static class SemanticEdgeProfileResolver
{ diagnostics.Add($"semantic-edge-fragment-out-of-bounds:{fragment.StableId}:{start:R}:{end:R}:owner={source.OwnerPath}:length={length:R}"); continue; }
placed.Add((fragment, Math.Max(0, start), Math.Min(length, end)));
}
+ foreach (var item in placed)
+ {
+ if (item.Start < consumption.Start - Tolerance)
+ diagnostics.Add($"semantic-corner-edge-fragment-conflict:{consumption.StartCornerPath ?? "<start-corner>"}:{item.Fragment.StableId}:owner={source.OwnerPath}");
+ if (item.End > length - consumption.End + Tolerance)
+ diagnostics.Add($"semantic-corner-edge-fragment-conflict:{consumption.EndCornerPath ?? "<end-corner>"}:{item.Fragment.StableId}:owner={source.OwnerPath}");
+ }
placed.Sort((a, b) => { var c = a.Start.CompareTo(b.Start); return c != 0 ? c : StringComparer.Ordinal.Compare(a.Fragment.StableId, b.Fragment.StableId); });
for (var i = 1; i < placed.Count; i++)
if (placed[i].Start < placed[i - 1].End - Tolerance)
diagnostics.Add($"semantic-edge-fragment-overlap:{source.OwnerPath}:{placed[i - 1].Fragment.StableId}:{placed[i].Fragment.StableId}");
if (diagnostics.Count > 0) return new(null, diagnostics);
- var result = new List<ResolvedSemanticEdgeMemberIr>(); var cursor = 0d; var carrier = 0;
+ var result = new List<ResolvedSemanticEdgeMemberIr>(); var cursor = Math.Max(0d, consumption.Start); var carrier = 0;
foreach (var item in placed)
{
if (item.Start > cursor + Tolerance)
@@ -109,9 +127,10 @@ public static class SemanticEdgeProfileResolver
result.Add(Fragment(item.Fragment, item.Start, item.End));
cursor = item.End;
}
- if (cursor < length - Tolerance)
- result.Add(Member($"Carrier{carrier++:D2}", $"{source.StableId}.Carrier{carrier - 1:D2}", "Carrier", cursor, length,
- [Line(cursor, 0, length, 0)], "generated:untouched-carrier", true));
+ var terminal = length - Math.Max(0d, consumption.End);
+ if (cursor < terminal - Tolerance)
+ result.Add(Member($"Carrier{carrier++:D2}", $"{source.StableId}.Carrier{carrier - 1:D2}", "Carrier", cursor, terminal,
+ [Line(cursor, 0, terminal, 0)], "generated:untouched-carrier", true));
clock.Stop();
var hashText = string.Join("|", result.SelectMany(x => x.CurveDescendants).Select(x => $"{x.StableId}:{x.Geometry}"));
var hash = Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(hashText))).ToLowerInvariant();
diff --git a/Aetheris.SheetMetal.Tests/SheetMetalM8Tests.cs b/Aetheris.SheetMetal.Tests/SheetMetalM8Tests.cs
index 1b2b51d4..26351ec0 100644
--- a/Aetheris.SheetMetal.Tests/SheetMetalM8Tests.cs
+++ b/Aetheris.SheetMetal.Tests/SheetMetalM8Tests.cs
@@ -30,12 +30,13 @@ public sealed class SheetMetalM8Tests
Assert.True(result.IsSuccess,string.Join('\n',result.Diagnostics.Select(x=>x.Message)));
Assert.Equal(15,result.Part!.Features.Count(x=>x.Kind==SheetFeatureKind.CircularHole));
Assert.Equal(2,result.Part.Features.Count(x=>x.Kind==SheetFeatureKind.Slot));
- Assert.Equal(9,result.Spec!.SemanticLayout.Patterns.Count);Assert.Single(result.Spec.SemanticLayout.Tabs);Assert.Equal(2,result.Spec.SemanticLayout.SteppedNotches!.Count);
+ Assert.Equal(9,result.Spec!.SemanticLayout.Patterns.Count);Assert.Single(result.Spec.SemanticLayout.Tabs);Assert.Equal(2,result.Spec.SemanticLayout.SteppedNotches!.Count);Assert.Equal(10,result.Spec.SemanticLayout.Corners!.Count);
Assert.Equal(127,result.Part.Regions.Single(x=>x.StableId=="AngledServiceFlangeBendRegion").Cylinder!.AxisLength,8);
Assert.NotNull(result.FlatPattern!.ExactBlankContour);Assert.Equal(17,result.FlatPattern.CutLoops.Count);
Assert.True(BrepExportPreflight.Validate(result.Part.FormedBody!).IsValid);
var paths=SheetMetalConceptPaths.Inspect(result.Spec,result.Part,result.FlatPattern).Select(x=>x.Path).ToArray();
Assert.Contains("Ctc03Layout.FrontConnectorRelief",paths);Assert.Contains("Flat.Ctc03Layout.FrontConnectorRelief",paths);
+ Assert.Contains("Ctc03Layout.LeftWall.OuterStart.RearEndTaper",paths);Assert.Contains("Flat.Ctc03Layout.LeftWall.OuterStart.RearEndTaper",paths);
}
finally{if(File.Exists(isolated))File.Delete(isolated);}
}
diff --git a/Aetheris.SheetMetal.Tests/SheetMetalProfileCornerM3Tests.cs b/Aetheris.SheetMetal.Tests/SheetMetalProfileCornerM3Tests.cs
new file mode 100644
index 00000000..8ad21d12
--- /dev/null
+++ b/Aetheris.SheetMetal.Tests/SheetMetalProfileCornerM3Tests.cs
@@ -0,0 +1,78 @@
+using Aetheris.Kernel.Core.Brep;
+using Xunit;
+
+namespace Aetheris.SheetMetal.Tests;
+
+public sealed class SheetMetalProfileCornerM3Tests
+{
+ [Fact]
+ public void GenericSheetFlange_UsesSharedProfileCornersInFormedAndFlatCorrespondence()
+ {
+ const string source = """
+ Concept Struct Layout {
+ CornerProfile Lip.OuterStart { Chamfer RightChamfer { Setback: 6mm; } }
+ CornerProfile Lip.OuterEnd { NotchCorner LeftStep { SetbackA: 5mm; SetbackB: 4mm; } }
+ }
+ SheetMetal Panel {
+ Thickness: 1mm;
+ Base Deck { Profile: Rectangle { Width: 100mm; Height: 60mm; }; }
+ Flange Lip { From: Deck.Front; Height: 20mm; Angle: 90deg; Radius: 2mm; Direction: Up; Relief: Auto; }
+ }
+ """;
+
+ var result = SheetMetalFirmament.Compile(source);
+
+ Assert.True(result.IsSuccess, string.Join('\n', result.Diagnostics.Select(x => x.Message)));
+ var lip = result.Part!.Regions.Single(x => x.StableId == "Lip");
+ Assert.Equal(7, lip.Boundary3D.Count);
+ Assert.True(BrepExportPreflight.Validate(result.Part.FormedBody!).IsValid);
+ var paths = SheetMetalConceptPaths.Inspect(result.Spec!, result.Part, result.FlatPattern).Select(x => x.Path).ToArray();
+ Assert.Contains("Layout.Lip.OuterStart", paths);
+ Assert.Contains("Layout.Lip.OuterStart.RightChamfer", paths);
+ Assert.Contains("Flat.Layout.Lip.OuterStart.RightChamfer", paths);
+ }
+
+ [Fact]
+ public void CornerAndOuterEdgeFragmentConflictNamesBothSemanticOwnersBeforeBrepConstruction()
+ {
+ const string source = """
+ Concept Struct Layout {
+ Tab EndTab { On: Lip.Outer; Center: 10mm; Width: 10mm; Extension: 3mm; }
+ CornerProfile Lip.OuterEnd { Chamfer EndChamfer { Setback: 20mm; } }
+ }
+ SheetMetal Panel {
+ Thickness: 1mm;
+ Base Deck { Profile: Rectangle { Width: 100mm; Height: 60mm; }; }
+ Flange Lip { From: Deck.Front; Height: 25mm; Angle: 90deg; Radius: 2mm; Direction: Up; Relief: Auto; }
+ }
+ """;
+
+ var result = SheetMetalFirmament.Compile(source);
+
+ Assert.False(result.IsSuccess);
+ Assert.Contains(result.Diagnostics, x => x.Code == "sheetmetal-edge-profile-invalid"
+ && x.Message.Contains("Layout.Lip.OuterEnd", StringComparison.Ordinal)
+ && x.Message.Contains("Layout.EndTab", StringComparison.Ordinal));
+ Assert.Null(result.Part);
+ }
+
+ [Fact]
+ public void Ctc03_ProfileCornersMateriallyImproveM2FormedAndFlatResidualsWithoutFeatureRegression()
+ {
+ var root = FindRepoRoot();
+ var step = Path.Combine(root, "testdata/step242/nist/CTC/nist_ctc_03_asme1_ap242-e2.stp");
+ var intent = Path.Combine(root, "docs/modules/sheetmetal/artifacts/m8/ctc03-final.firmament");
+ var source = SheetMetalRecognizer.RecognizeStep(step).Part!;
+ var authored = SheetMetalFirmament.CompileFile(intent);
+
+ Assert.True(authored.IsSuccess, string.Join('\n', authored.Diagnostics.Select(x => x.Message)));
+ Assert.Equal(10, authored.Spec!.SemanticLayout.Corners!.Count);
+ var comparison = SheetMetalIntentComparer.Compare(source, authored.Part!);
+ Assert.All(comparison.Bends, x => Assert.Equal(SheetMetalComparisonStatus.Pass, x.Status));
+ Assert.All(comparison.Features, x => Assert.Equal(SheetMetalComparisonStatus.Pass, x.Status));
+ Assert.True(comparison.SourceToIntent.Rms < 10.614040, $"formed RMS was {comparison.SourceToIntent.Rms:R}");
+ Assert.True(comparison.FlatPattern.Contour.Rms < 12.038486, $"flat RMS was {comparison.FlatPattern.Contour.Rms:R}");
+ }
+
+ private static string FindRepoRoot(){var dir=new DirectoryInfo(AppContext.BaseDirectory);while(dir is not null&&!File.Exists(Path.Combine(dir.FullName,"Aetheris.slnx")))dir=dir.Parent;return dir?.FullName??throw new InvalidOperationException("Repo root not found.");}
+}
diff --git a/Aetheris.SheetMetal/SheetMetalAuthoredLowering.cs b/Aetheris.SheetMetal/SheetMetalAuthoredLowering.cs
index caf7cdf2..9bf2ccb2 100644
--- a/Aetheris.SheetMetal/SheetMetalAuthoredLowering.cs
+++ b/Aetheris.SheetMetal/SheetMetalAuthoredLowering.cs
@@ -248,6 +248,14 @@ internal static class AuthoredSheetMetalLowering
var edgeLength = (edge.B - edge.A).Length;
var gapStart = flange is null || !atStart ? 0 : CornerGap(flange, spec.Flanges.First(f => f.ParentRegion.Equals(spec.Base.Name, StringComparison.OrdinalIgnoreCase) && f.EdgeName.Equals(previous, StringComparison.OrdinalIgnoreCase)), t);
var gapEnd = flange is null || !atEnd ? 0 : CornerGap(flange, spec.Flanges.First(f => f.ParentRegion.Equals(spec.Base.Name, StringComparison.OrdinalIgnoreCase) && f.EdgeName.Equals(next, StringComparison.OrdinalIgnoreCase)), t);
+ if(flange is not null)
+ {
+ // A child-region Profile corner owns its end outline explicitly. The
+ // generic manufacturing relief policy remains available at the shared
+ // base corner, but must not silently shorten this authored flange edge.
+ if((spec.SemanticLayout.Corners??[]).Any(c=>c.Region.Equals(flange.Name,StringComparison.OrdinalIgnoreCase)&&(c.Corner.Equals("OuterEnd",StringComparison.OrdinalIgnoreCase)||c.Corner.Equals("RootStart",StringComparison.OrdinalIgnoreCase))))gapStart=0;
+ if((spec.SemanticLayout.Corners??[]).Any(c=>c.Region.Equals(flange.Name,StringComparison.OrdinalIgnoreCase)&&(c.Corner.Equals("OuterStart",StringComparison.OrdinalIgnoreCase)||c.Corner.Equals("RootEnd",StringComparison.OrdinalIgnoreCase))))gapEnd=0;
+ }
if (gapStart + gapEnd >= edgeLength - 1e-8) return Failure($"Corner trims consume base edge {spec.Base.Name}.{edgeName}.", SheetMetalDiagnosticCodes.ImpossibleTopology);
var axis = Unit(edge.B - edge.A); var a = edge.A + axis * gapStart; var b = edge.B - axis * gapEnd;
if (baseBoundary.Count == 0 || !Same(baseBoundary[^1], edge.A)) baseBoundary.Add(edge.A);
@@ -286,31 +294,79 @@ internal static class AuthoredSheetMetalLowering
var direction = Unit(edge.Outward * Math.Cos(angle) + parentNormal * (sign * Math.Sin(angle)));
var normal = Unit(parentNormal * Math.Cos(angle) - edge.Outward * (sign * Math.Sin(angle)));
var frame = new RegionFrame(flange.Name, tangentA, tangentB, direction, normal, flange.Length); frames[flange.Name] = frame;
- IReadOnlyList<Point3D> boundary = [tangentA, tangentB, frame.OuterB, frame.OuterA];
var tabs=spec.SemanticLayout.Tabs.Where(x=>x.Region.Equals(flange.Name,StringComparison.OrdinalIgnoreCase)&&x.Edge.Equals("Outer",StringComparison.OrdinalIgnoreCase)).ToArray();
var steppedNotches=(spec.SemanticLayout.SteppedNotches??[]).Where(x=>x.Region.Equals(flange.Name,StringComparison.OrdinalIgnoreCase)&&x.Edge.Equals("Outer",StringComparison.OrdinalIgnoreCase)).ToArray();
- if(tabs.Length>0||steppedNotches.Length>0)
+ var cornerPrograms=(spec.SemanticLayout.Corners??[]).Where(x=>x.Region.Equals(flange.Name,StringComparison.OrdinalIgnoreCase)).ToArray();
+ var rootStartProgram=cornerPrograms.SingleOrDefault(x=>x.Corner.Equals("RootStart",StringComparison.OrdinalIgnoreCase));
+ var rootEndProgram=cornerPrograms.SingleOrDefault(x=>x.Corner.Equals("RootEnd",StringComparison.OrdinalIgnoreCase));
+ var outerStartProgram=cornerPrograms.SingleOrDefault(x=>x.Corner.Equals("OuterStart",StringComparison.OrdinalIgnoreCase));
+ var outerEndProgram=cornerPrograms.SingleOrDefault(x=>x.Corner.Equals("OuterEnd",StringComparison.OrdinalIgnoreCase));
+ ResolvedSemanticCornerProfileIr? ResolveCorner(SheetMetalSemanticCornerProfile? program)
{
- var ownerLength=(edge.B-edge.A).Length;
- var attachment=new SemanticEdgeProfileIr($"{flange.Name}.Outer",$"{flange.Name}.Outer",new(0,0),new(ownerLength,0),
- tabs.Select(tab=>(SemanticEdgeFragmentIr)new SemanticEdgeTabIr(tab.Path.Split('.').Last(),tab.Path,
- new(SemanticEdgeAnchorKind.CenteredAt,ownerLength-tab.Center),tab.Width,tab.Extension,1,"SheetMetalSemanticLayout"))
- .Concat(steppedNotches.Select(notch=>(SemanticEdgeFragmentIr)new SemanticEdgeSteppedNotchIr(notch.Path.Split('.').Last(),notch.Path,
- new(SemanticEdgeAnchorKind.CenteredAt,ownerLength-notch.Center),notch.Width,notch.Depth,notch.ShoulderDepth,notch.OuterChamfer,notch.InnerChamfer,notch.Side,"SheetMetalSemanticLayout"))).ToArray(),
- "SheetRegionLocal[u=OuterB->OuterA,v=flange-outward]","Sheet Metal semantic edge attachment");
- var composed=SemanticEdgeProfileResolver.Resolve(attachment);
- if(!composed.IsSuccess)return Failure($"Edge attachment '{flange.Name}.Outer' failed: {string.Join("; ",composed.Diagnostics)}","sheetmetal-edge-profile-invalid");
- var points=new List<Point3D>{tangentA,tangentB,frame.OuterB};
- foreach(var descendant in composed.Profile!.OrderedMembers.SelectMany(member=>member.CurveDescendants))
+ if(program is null)return null;
+ var length=(edge.B-edge.A).Length;var height=flange.Length;
+ SemanticCornerOperationIr operation=program.Operation.ToUpperInvariant() switch
{
- if(descendant.Geometry is not LineArcLineSegment2D line)return Failure($"Edge attachment '{flange.Name}.Outer' generated a non-line descendant.","sheetmetal-edge-profile-invalid");
- var mapped=frame.OuterB-axis*line.End.X+direction*line.End.Y;
- if(points.Count==0||(mapped-points[^1]).Length>1e-8)points.Add(mapped);
- }
- boundary=points;
- foreach(var fragment in composed.Profile.OrderedMembers.Where(member=>!member.IsGeneratedCarrier))
- correspondence.Add(new(fragment.StableId,"EdgeFragment",fragment.StableId,$"flat-{fragment.StableId}"));
+ "CHAMFER"=>new SemanticCornerChamferIr(program.OperationPath.Split('.').Last(),program.OperationPath,program.SetbackA,program.SetbackB,"SheetMetalSemanticLayout"),
+ "CUTBACK"=>new SemanticCornerCutbackIr(program.OperationPath.Split('.').Last(),program.OperationPath,program.SetbackA,program.SetbackB,"SheetMetalSemanticLayout"),
+ "TAPER"=>new SemanticCornerTaperIr(program.OperationPath.Split('.').Last(),program.OperationPath,program.SetbackA,program.SetbackB,"SheetMetalSemanticLayout"),
+ "NOTCHCORNER"=>new SemanticCornerNotchIr(program.OperationPath.Split('.').Last(),program.OperationPath,program.SetbackA,program.SetbackB,"SheetMetalSemanticLayout"),
+ _=>throw new InvalidOperationException()
+ };
+ var request=program.Corner.ToUpperInvariant() switch
+ {
+ "ROOTEND"=>new SemanticCornerProfileIr(program.CornerPath,program.CornerPath,$"{flange.Name}.Root",$"{flange.Name}.EndB",new(0,0),new(length,0),new(length,height),operation,$"{program.CornerPath}[u,v]","Sheet Metal Profile corner"),
+ "OUTERSTART"=>new SemanticCornerProfileIr(program.CornerPath,program.CornerPath,$"{flange.Name}.EndB",$"{flange.Name}.Outer",new(length,0),new(length,height),new(0,height),operation,$"{program.CornerPath}[u,v]","Sheet Metal Profile corner"),
+ "OUTEREND"=>new SemanticCornerProfileIr(program.CornerPath,program.CornerPath,$"{flange.Name}.Outer",$"{flange.Name}.EndA",new(length,height),new(0,height),new(0,0),operation,$"{program.CornerPath}[u,v]","Sheet Metal Profile corner"),
+ "ROOTSTART"=>new SemanticCornerProfileIr(program.CornerPath,program.CornerPath,$"{flange.Name}.EndA",$"{flange.Name}.Root",new(0,height),new(0,0),new(length,0),operation,$"{program.CornerPath}[u,v]","Sheet Metal Profile corner"),
+ _=>throw new InvalidOperationException()
+ };
+ var resolved=SemanticCornerProfileResolver.Resolve(request);
+ if(!resolved.IsSuccess)throw new InvalidOperationException($"CornerProfile '{program.CornerPath}' failed: {string.Join("; ",resolved.Diagnostics)}");
+ return resolved.Corner;
+ }
+ ResolvedSemanticCornerProfileIr? rootStartCorner;ResolvedSemanticCornerProfileIr? rootEndCorner;ResolvedSemanticCornerProfileIr? outerStartCorner;ResolvedSemanticCornerProfileIr? outerEndCorner;
+ try{rootStartCorner=ResolveCorner(rootStartProgram);rootEndCorner=ResolveCorner(rootEndProgram);outerStartCorner=ResolveCorner(outerStartProgram);outerEndCorner=ResolveCorner(outerEndProgram);}
+ catch(InvalidOperationException ex){return Failure(ex.Message,"sheetmetal-corner-profile-invalid");}
+ var ownerLength=(edge.B-edge.A).Length;
+ var outerAttachment=new SemanticEdgeProfileIr($"{flange.Name}.Outer",$"{flange.Name}.Outer",new(ownerLength,flange.Length),new(0,flange.Length),
+ tabs.Select(tab=>(SemanticEdgeFragmentIr)new SemanticEdgeTabIr(tab.Path.Split('.').Last(),tab.Path,
+ new(SemanticEdgeAnchorKind.CenteredAt,ownerLength-tab.Center),tab.Width,tab.Extension,-1,"SheetMetalSemanticLayout"))
+ .Concat(steppedNotches.Select(notch=>(SemanticEdgeFragmentIr)new SemanticEdgeSteppedNotchIr(notch.Path.Split('.').Last(),notch.Path,
+ new(SemanticEdgeAnchorKind.CenteredAt,ownerLength-notch.Center),notch.Width,notch.Depth,notch.ShoulderDepth,notch.OuterChamfer,notch.InnerChamfer,-notch.Side,"SheetMetalSemanticLayout"))).ToArray(),
+ "SheetRegionLocal[u=OuterB->OuterA,v=material-left]","Sheet Metal semantic edge attachment");
+ SemanticEdgeProfileResolution Edge(string edgeName,SemanticProfilePoint start,SemanticProfilePoint end,IReadOnlyList<SemanticEdgeFragmentIr> fragments,ResolvedSemanticCornerProfileIr? startCorner,ResolvedSemanticCornerProfileIr? endCorner)
+ =>SemanticEdgeProfileResolver.Resolve(new($"{flange.Name}.{edgeName}",$"{flange.Name}.{edgeName}",start,end,fragments,$"{flange.Name}.{edgeName}[u,v]","Sheet Metal profile edge"),
+ new(startCorner?.EdgeBConsumption??0,endCorner?.EdgeAConsumption??0,startCorner?.Source.CornerPath,endCorner?.Source.CornerPath));
+ var rootEdge=Edge("Root",new(0,0),new(ownerLength,0),[],rootStartCorner,rootEndCorner);
+ var endBEdge=Edge("EndB",new(ownerLength,0),new(ownerLength,flange.Length),[],rootEndCorner,outerStartCorner);
+ var composed=SemanticEdgeProfileResolver.Resolve(outerAttachment,new(outerStartCorner?.EdgeBConsumption??0,outerEndCorner?.EdgeAConsumption??0,outerStartCorner?.Source.CornerPath,outerEndCorner?.Source.CornerPath));
+ var endAEdge=Edge("EndA",new(0,flange.Length),new(0,0),[],outerEndCorner,rootStartCorner);
+ var edgeFailures=new[]{rootEdge,endBEdge,composed,endAEdge}.Where(x=>!x.IsSuccess).SelectMany(x=>x.Diagnostics).ToArray();
+ if(edgeFailures.Length>0)return Failure($"Profile edge composition for '{flange.Name}' failed: {string.Join("; ",edgeFailures)}","sheetmetal-edge-profile-invalid");
+ Point3D Map((double X,double Y) point)=>tangentA+axis*point.X+direction*point.Y;
+ var points=new List<Point3D>();
+ void Add(Point3D point){if(points.Count==0||(point-points[^1]).Length>1e-8)points.Add(point);}
+ void AddEdge(SemanticEdgeProfileResolution profile)
+ {
+ var descendants=profile.Profile!.OrderedMembers.SelectMany(member=>member.CurveDescendants).ToArray();
+ if(descendants.Length==0)return;
+ Add(Map(((LineArcLineSegment2D)descendants[0].Geometry).Start));
+ foreach(var descendant in descendants)Add(Map(((LineArcLineSegment2D)descendant.Geometry).End));
+ }
+ void AddCorner(ResolvedSemanticCornerProfileIr? corner)
+ {
+ if(corner is null)return;
+ Add(Map((corner.EdgeAEndpoint.X,corner.EdgeAEndpoint.Y)));
+ foreach(var descendant in corner.CurveDescendants)Add(Map(((LineArcLineSegment2D)descendant.Geometry).End));
}
+ AddEdge(rootEdge);AddCorner(rootEndCorner);AddEdge(endBEdge);AddCorner(outerStartCorner);AddEdge(composed);AddCorner(outerEndCorner);AddEdge(endAEdge);AddCorner(rootStartCorner);
+ if(points.Count>1&&(points[^1]-points[0]).Length<=1e-8)points.RemoveAt(points.Count-1);
+ IReadOnlyList<Point3D> boundary=points;
+ foreach(var fragment in composed.Profile!.OrderedMembers.Where(member=>!member.IsGeneratedCarrier))
+ correspondence.Add(new(fragment.StableId,"EdgeFragment",fragment.StableId,$"flat-{fragment.StableId}"));
+ foreach(var corner in new[]{rootStartCorner,rootEndCorner,outerStartCorner,outerEndCorner}.OfType<ResolvedSemanticCornerProfileIr>())
+ correspondence.Add(new(corner.Source.CornerPath,"ProfileCorner",corner.Source.CornerPath,$"flat-{corner.Source.CornerPath}"));
var plane = new SheetPlaneReference(tangentA, normal, axis, direction, true);
var flangeId=stableRegions[flange.Name];
var fragmentArea=tabs.Sum(x=>x.Width*x.Extension)-steppedNotches.Sum(x=>x.Width*x.Depth);
diff --git a/Aetheris.SheetMetal/SheetMetalConceptPaths.cs b/Aetheris.SheetMetal/SheetMetalConceptPaths.cs
index b0bf6fa1..fcedc0d0 100644
--- a/Aetheris.SheetMetal/SheetMetalConceptPaths.cs
+++ b/Aetheris.SheetMetal/SheetMetalConceptPaths.cs
@@ -45,6 +45,11 @@ public static class SheetMetalConceptPaths
Add(tab.Path,"SheetTab",tab.Path,tab.Region,$"flat-{tab.Region}","exact outer-edge contour extension","EdgeFeature","ManufacturingContour","StableSemanticIdentity");
foreach(var notch in spec.SemanticLayout.SteppedNotches??[])
Add(notch.Path,"SheetSteppedNotch",notch.Path,notch.Region,$"flat-{notch.Region}","semantic stepped edge removal","EdgeFeature","ManufacturingContour","StableSemanticIdentity");
+ foreach(var corner in spec.SemanticLayout.Corners??[])
+ {
+ Add(corner.CornerPath,"SheetProfileCorner",corner.CornerPath,corner.Region,$"flat-{corner.Region}","shared semantic corner consuming two adjacent profile edges","CornerFeature","ManufacturingContour","StableSemanticIdentity");
+ Add(corner.OperationPath,"SheetCorner"+corner.Operation,corner.OperationPath,corner.Region,$"flat-{corner.Region}","deterministic exact cross-edge corner lowering","CornerFeature","ManufacturingContour","StableSemanticIdentity");
+ }
foreach(var pattern in spec.SemanticLayout.Patterns)
Add(pattern.Path,"SheetPattern",pattern.Path,null,null,"compile-time semantic feature pattern","EqualPitch","EqualSize","StableSemanticIdentity");
foreach(var constraint in spec.SemanticLayout.Constraints)
diff --git a/Aetheris.SheetMetal/SheetMetalSemanticLayout.cs b/Aetheris.SheetMetal/SheetMetalSemanticLayout.cs
index 22ff307a..99b7ad33 100644
--- a/Aetheris.SheetMetal/SheetMetalSemanticLayout.cs
+++ b/Aetheris.SheetMetal/SheetMetalSemanticLayout.cs
@@ -11,6 +11,8 @@ public sealed record SheetMetalSemanticTab(string Path,string Region,string Edge
public sealed record SheetMetalSemanticSteppedNotch(
string Path,string Region,string Edge,double Center,double Width,double Depth,
double ShoulderDepth,double OuterChamfer,double InnerChamfer,int Side);
+public sealed record SheetMetalSemanticCornerProfile(
+ string CornerPath,string OperationPath,string Region,string Corner,string Operation,double SetbackA,double SetbackB);
public sealed record SheetMetalSemanticPattern(
string Path,string Name,string Region,SheetFeatureKind FeatureKind,int Count,double CenterX,double CenterY,
@@ -22,7 +24,8 @@ public sealed record SheetMetalSemanticConstraint(
public sealed record SheetMetalSemanticLayout(
IReadOnlyList<string> Structs,IReadOnlyList<SheetMetalSemanticDatum> Datums,IReadOnlyList<SheetMetalSemanticTab> Tabs,
IReadOnlyList<SheetMetalSemanticPattern> Patterns,IReadOnlyList<SheetMetalSemanticConstraint> Constraints,
- IReadOnlyList<SheetMetalSemanticSteppedNotch>? SteppedNotches = null)
+ IReadOnlyList<SheetMetalSemanticSteppedNotch>? SteppedNotches = null,
+ IReadOnlyList<SheetMetalSemanticCornerProfile>? Corners = null)
{
public static SheetMetalSemanticLayout Empty { get; } = new([],[],[],[],[]);
}
@@ -54,6 +57,7 @@ internal static class SheetMetalSemanticLayoutParser
var datums=new List<SheetMetalSemanticDatum>();
var tabs=new List<SheetMetalSemanticTab>();
var steppedNotches=new List<SheetMetalSemanticSteppedNotch>();
+ var corners=new List<SheetMetalSemanticCornerProfile>();
var patterns=new List<SheetMetalSemanticPattern>();
var generated=new List<AuthoredSheetCutSpec>();
var constraints=new List<SheetMetalSemanticConstraint>();
@@ -93,6 +97,22 @@ internal static class SheetMetalSemanticLayoutParser
steppedNotches.Add(new(Path(block),match.Groups["region"].Value,match.Groups["edge"].Value,center,width,depth,shoulder,outerChamfer,innerChamfer,side));
}
+ foreach(var block in CornerBlocks(source,structs))
+ {
+ var owner=Regex.Match(block.Name,@"^(?<region>[A-Za-z_][A-Za-z0-9_]*)\.(?<corner>RootStart|RootEnd|OuterStart|OuterEnd)$",Rx);
+ if(!owner.Success||!regionSizes.ContainsKey(owner.Groups["region"].Value))return Fail("sheetmetal-corner-owner",$"CornerProfile '{Path(block)}' requires <planar-region>.RootStart, .RootEnd, .OuterStart, or .OuterEnd.");
+ var operations=Regex.Matches(block.Body,@"\b(?<kind>Chamfer|Cutback|Taper|NotchCorner)\s+(?<name>[A-Za-z_][A-Za-z0-9_]*)\s*\{",Rx).Cast<Match>().ToArray();
+ if(operations.Length!=1)return Fail("sheetmetal-corner-operation",$"CornerProfile '{Path(block)}' requires exactly one Chamfer, Cutback, Taper, or NotchCorner operation.");
+ var operation=operations[0];var open=block.Body.IndexOf('{',operation.Index);var close=Close(block.Body,open);var operationBody=close>open?block.Body[(open+1)..close]:string.Empty;
+ var hasEqual=Scalar(operationBody,"Setback",out var equal);var hasA=Scalar(operationBody,"SetbackA",out var setbackA);var hasB=Scalar(operationBody,"SetbackB",out var setbackB);
+ if(!hasA){setbackA=equal;}if(!hasB){setbackB=equal;}
+ var cornerPath=Path(block);var operationPath=$"{cornerPath}.{operation.Groups["name"].Value}";
+ if((!hasEqual&&(!hasA||!hasB))||setbackA<=0||setbackB<=0)return Fail("sheetmetal-corner-setback",$"Corner operation '{operationPath}' requires positive Setback or SetbackA and SetbackB.");
+ if(corners.Any(x=>x.Region.Equals(owner.Groups["region"].Value,StringComparison.OrdinalIgnoreCase)&&x.Corner.Equals(owner.Groups["corner"].Value,StringComparison.OrdinalIgnoreCase)))
+ return Fail("sheetmetal-corner-duplicate",$"Corner '{owner.Groups["region"].Value}.{owner.Groups["corner"].Value}' is authored more than once.");
+ corners.Add(new(cornerPath,operationPath,owner.Groups["region"].Value,owner.Groups["corner"].Value,operation.Groups["kind"].Value,setbackA,setbackB));
+ }
+
foreach(var block in Blocks(source,"Pattern",structs))
{
var path=Path(block);var region=Token(block.Body,"On");
@@ -170,7 +190,7 @@ internal static class SheetMetalSemanticLayoutParser
constraints.Add(new(path,kind,members,"Satisfied",detail));
}
- return new(true,new(structNames,datums.OrderBy(x=>x.Path,StringComparer.Ordinal).ToArray(),tabs.OrderBy(x=>x.Path,StringComparer.Ordinal).ToArray(),patterns.OrderBy(x=>x.Path,StringComparer.Ordinal).ToArray(),constraints.OrderBy(x=>x.Path,StringComparer.Ordinal).ToArray(),steppedNotches.OrderBy(x=>x.Path,StringComparer.Ordinal).ToArray()),generated,diagnostics);
+ return new(true,new(structNames,datums.OrderBy(x=>x.Path,StringComparer.Ordinal).ToArray(),tabs.OrderBy(x=>x.Path,StringComparer.Ordinal).ToArray(),patterns.OrderBy(x=>x.Path,StringComparer.Ordinal).ToArray(),constraints.OrderBy(x=>x.Path,StringComparer.Ordinal).ToArray(),steppedNotches.OrderBy(x=>x.Path,StringComparer.Ordinal).ToArray(),corners.OrderBy(x=>x.CornerPath,StringComparer.Ordinal).ToArray()),generated,diagnostics);
SheetMetalSemanticLayoutParseResult Fail(string code,string message)=>new(false,SheetMetalSemanticLayout.Empty,[],[new(code,SheetMetalDiagnosticSeverity.Error,message)]);
}
@@ -228,6 +248,11 @@ internal static class SheetMetalSemanticLayoutParser
var result=new List<Block>();foreach(Match match in Regex.Matches(source,$@"\b{Regex.Escape(keyword)}\s+(?<name>[A-Za-z_][A-Za-z0-9_]*)\s*\{{",Rx))
{var open=source.IndexOf('{',match.Index);var close=Close(source,open);if(close<=open)continue;var owner=structs.Where(x=>match.Index>x.Index&&match.Index<x.Index+x.Body.Length+(source.IndexOf('{',x.Index)-x.Index)+2).OrderByDescending(x=>x.Index).FirstOrDefault()?.Name;result.Add(new(keyword,match.Groups["name"].Value,source[(open+1)..close],match.Index,owner));}return result;
}
+ private static IReadOnlyList<Block> CornerBlocks(string source,IReadOnlyList<Block> structs)
+ {
+ var result=new List<Block>();foreach(Match match in Regex.Matches(source,@"\bCornerProfile\s+(?<name>[A-Za-z_][A-Za-z0-9_]*\.[A-Za-z_][A-Za-z0-9_]*)\s*\{",Rx))
+ {var open=source.IndexOf('{',match.Index);var close=Close(source,open);if(close<=open)continue;var owner=structs.Where(x=>match.Index>x.Index&&match.Index<x.Index+x.Body.Length+(source.IndexOf('{',x.Index)-x.Index)+2).OrderByDescending(x=>x.Index).FirstOrDefault()?.Name;result.Add(new("CornerProfile",match.Groups["name"].Value,source[(open+1)..close],match.Index,owner));}return result;
+ }
private static int Close(string source,int open){var depth=0;for(var i=open;i<source.Length;i++){if(source[i]=='{')depth++;else if(source[i]=='}'&&--depth==0)return i;}return -1;}
private static string Path(Block block)=>block.Struct is null?block.Name:$"{block.Struct}.{block.Name}";
private static string? Token(string text,string name){var m=Regex.Match(text,$@"\b{Regex.Escape(name)}\s*:\s*(?<v>[A-Za-z_][A-Za-z0-9_]*)\s*;",Rx);return m.Success?m.Groups["v"].Value:null;}
diff --git a/docs/language/semantic-profile-corner-composition-m3.md b/docs/language/semantic-profile-corner-composition-m3.md
new file mode 100644
index 00000000..2db02ece
--- /dev/null
+++ b/docs/language/semantic-profile-corner-composition-m3.md
@@ -0,0 +1,105 @@
+# Semantic Profile shared-corner composition M3
+
+## Architecture and JudgmentEngine verdict
+
+M3 adds first-class ownership for the vertex shared by two directed Profile
+edges. `SemanticCornerProfileIr` names the corner, both adjacent owners, the
+authored operation, the bounded local frame, and provenance. It lowers above
+`ResolvedProfile2D` / `PlanarContour2`:
+
+```text
+EdgeA suffix --\
+ SemanticCorner operation -> exact replacement chain
+EdgeB prefix --/ -> repaired edge carriers
+```
+
+The evidence-based JudgmentEngine verdict is **Partial**. AIR edge finishing
+uses `JudgmentEngine` where several bounded route or analytic-surface families
+can be admissible. Its deterministic admissibility, scoring, tie-breaking, and
+rejection machinery is reusable for a future recovered/underspecified Profile
+corner. A fully authored Profile chamfer, cutback, taper, or corner notch has
+one declared topology and exact setbacks, however. M3 therefore applies hard
+constraints and deterministic construction directly; it does not manufacture
+a heuristic choice. This follows the AIR lesson that construction history
+should emit final topology directly, while retaining JudgmentEngine for a
+genuine competing-strategy layer.
+
+## Passing authoring syntax
+
+```firmament
+Rect2 PlateBase { Center: [0mm, 0mm]; Size: [100mm, 60mm] }
+EdgeProfile PlateBase.Bottom {
+ Tab MountTab { CenteredAt: 50mm; Width: 12mm; Extension: 6mm; Side: Right }
+}
+CornerProfile PlateBase.BottomRight {
+ Chamfer CableClearance { SetbackA: 8mm; SetbackB: 5mm; }
+}
+CornerProfile PlateBase.TopLeft {
+ NotchCorner LocatingStep { SetbackA: 7mm; SetbackB: 4mm; }
+}
+Profile Plate From PlateBase
+Extrude Solid { Profile: Plate; From: 0mm; To: 3mm }
+```
+
+At each corner, `u` points away from the vertex along EdgeA in reverse owner
+direction and `v` points away along EdgeB in owner direction. No orthogonality
+is assumed. `Chamfer`, `Cutback`, and `Taper` insert one exact line;
+`NotchCorner` inserts the two-line material-removal step through `u+v`.
+
+The resolver removes the requested suffix/prefix intervals before M2 carrier
+generation. A fragment entering either interval rejects before contour/BRep
+construction with
+`semantic-corner-edge-fragment-conflict:<corner>:<fragment>:owner=<edge>`.
+Generated zero-length carriers are omitted. Stable paths such as
+`PlateBase.BottomRight.CableClearance` identify semantics independently of
+curve ordinals.
+
+Sheet Metal consumes the same resolver for region-profile `OuterStart` and
+`OuterEnd` corners. Its manufacturing bend-corner relief policy remains a
+separate concern. Corner and operation paths are exposed in both formed and
+`Flat.*` inspection.
+
+## CTC-03 dogfood and honest status
+
+The source boundary audit identified and authored ten deterministic operations:
+four front/rear wall end steps, two left-wall 25.4 mm end tapers, and four
+front/rear mounting-flange 12.7 mm endpoint chamfers. The compiler now owns all
+adjacent-edge trimming and carrier repair; the Firmament source states only the
+engineering corner and setbacks. No source STEP is read during construction.
+
+| metric | Profile M2 | Profile M3 |
+|---|---:|---:|
+| formed source→generated RMS | 10.614040 mm | 8.500190 mm |
+| formed source→generated p95 | 19.071261 mm | 12.478269 mm |
+| formed source→generated max | 52.816066 mm | 52.816066 mm |
+| formed generated→source RMS | 6.750457 mm | 3.607855 mm |
+| formed generated→source p95 | 8.310053 mm | 8.940881 mm |
+| formed generated→source max | 19.071261 mm | 12.735724 mm |
+| flat width / height residual | 0.002447 / 0.007820 mm | 0.002447 / 0.007820 mm |
+| flat contour RMS | 12.038486 mm | 2.191367 mm |
+| flat contour p95 / max | 19.047460 / 19.047460 mm | 4.775200 / 4.775200 mm |
+
+All seven bends and all 17 openings remain passes. CTC-03 remains
+`NeedsReview`, not Complete. The unchanged formed maximum and remaining local
+residual are dominated by the right-wall service-attachment outline: it has a
+two-level, persistent stepped/tapered edge program between its endpoint
+chamfers and the partial 45-degree flange. That is no longer a cross-edge
+ownership problem and should not be forced into a corner primitive.
+
+A bounded nearest-vertex local audit after M3 (including the expected nominal
+thickness/reference-skin displacement) reports: FrontWall 0.95/0.95/0.95 mm,
+RearWall 0.96/0.96/0.96 mm, LeftWall 1.78/2.13/2.13 mm,
+FrontMountingFlange 0.95/0.95/0.95 mm, and RearMountingFlange
+0.95/0.95/0.95 mm RMS/p95/max. RightWall remains 64.78/115.48/115.48 mm in
+that deliberately coarse vertex-only audit because its persistent interior
+edge program is still missing.
+
+One measured run reported parse 27.6 ms, semantic resolve 17.3 ms, formed lower
+75.1 ms, exact authored-flat lower 62.6 ms, and flatten 8.8 ms (about 191 ms
+total). A 10,000-call caller-side micro-measurement averaged about 18 µs per
+single deterministic corner resolution; Judgment cost is not applicable.
+Two independent CTC runs produced flat hash
+`615aa6c549c55654a0bdafc9da0e07f4e3f983970f2f7acda6f5e4c305a41364`.
+
+The executable non-Sheet-Metal fixture is
+`fixtures/FirmamentV2/Canonical/valid/profile-shared-corners-plate.firmament`.
diff --git a/docs/modules/sheetmetal/artifacts/m8/ctc03-final.firmament b/docs/modules/sheetmetal/artifacts/m8/ctc03-final.firmament
index fad55735..24426bf6 100644
--- a/docs/modules/sheetmetal/artifacts/m8/ctc03-final.firmament
+++ b/docs/modules/sheetmetal/artifacts/m8/ctc03-final.firmament
@@ -15,8 +15,8 @@ Concept Ctc03ManufacturedIntent {
Concept Struct Ctc03Layout {
// Named local workpoints isolate measured formed coordinates from feature generation.
- Datum RearMountCenter { On: RearMountingFlange; At: (112.395mm, 25.40254mm); }
- Datum FrontMountCenter { On: FrontMountingFlange; At: (112.395mm, 24.43226mm); }
+ Datum RearMountCenter { On: RearMountingFlange; At: (120.65mm, 25.40254mm); }
+ Datum FrontMountCenter { On: FrontMountingFlange; At: (120.65mm, 24.43226mm); }
Datum ServiceHoleCenter { On: AngledServiceFlange; At: (63.5mm, 30.735796052mm); }
// Source contour: the 127 mm partial flange grows a centered 101.6 x 12.7 mm tab.
@@ -51,6 +51,21 @@ Concept Struct Ctc03Layout {
Side: Inward;
}
+ // Cross-edge region-profile corners. Each operation consumes the named
+ // side-edge endpoint and the adjacent Outer-edge endpoint as one feature.
+ CornerProfile FrontWall.RootEnd { NotchCorner RearEndStep { SetbackA: 8.89mm; SetbackB: 12.57046mm; } }
+ CornerProfile FrontWall.RootStart { NotchCorner FrontEndStep { SetbackA: 12.57046mm; SetbackB: 8.89mm; } }
+ CornerProfile RearWall.RootEnd { NotchCorner FrontEndStep { SetbackA: 8.89mm; SetbackB: 12.57046mm; } }
+ CornerProfile RearWall.RootStart { NotchCorner RearEndStep { SetbackA: 12.57046mm; SetbackB: 8.89mm; } }
+
+ CornerProfile LeftWall.OuterStart { Chamfer RearEndTaper { Setback: 25.4mm; } }
+ CornerProfile LeftWall.OuterEnd { Chamfer FrontEndTaper { Setback: 25.4mm; } }
+
+ CornerProfile FrontMountingFlange.OuterStart { Chamfer RightEndChamfer { Setback: 12.7mm; } }
+ CornerProfile FrontMountingFlange.OuterEnd { Chamfer LeftEndChamfer { Setback: 12.7mm; } }
+ CornerProfile RearMountingFlange.OuterStart { Chamfer LeftEndChamfer { Setback: 12.7mm; } }
+ CornerProfile RearMountingFlange.OuterEnd { Chamfer RightEndChamfer { Setback: 12.7mm; } }
+
// Four source-PMI Ø0.625 in holes at equal 1.75 in pitch.
Pattern BaseFastenerPattern {
On: MainDeck;
diff --git a/fixtures/FirmamentV2/Canonical/valid/profile-shared-corners-plate.firmament b/fixtures/FirmamentV2/Canonical/valid/profile-shared-corners-plate.firmament
new file mode 100644
index 00000000..4dd29a59
--- /dev/null
+++ b/fixtures/FirmamentV2/Canonical/valid/profile-shared-corners-plate.firmament
@@ -0,0 +1,21 @@
+Model SharedCornerPlate {
+Units: mm
+Concept Struct Layout On XY {
+Rect2 PlateBase { Center: [0mm, 0mm]; Size: [100mm, 60mm] }
+
+EdgeProfile PlateBase.Bottom {
+ Tab MountTab { CenteredAt: 50mm; Width: 12mm; Extension: 6mm; Side: Right }
+}
+
+CornerProfile PlateBase.BottomRight {
+ Chamfer CableClearance { SetbackA: 8mm; SetbackB: 5mm; }
+}
+
+CornerProfile PlateBase.TopLeft {
+ NotchCorner LocatingStep { SetbackA: 7mm; SetbackB: 4mm; }
+}
+}
+
+Profile Plate From PlateBase
+Struct Body { Extrude Solid { Profile: Plate; From: 0mm; To: 3mm } }
+}