Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Complete bounded auto-hole PMI validation coverage
Yuechen Li0c739e80aae2
diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentPmiTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentPmiTests.csindex 6bdf3128..b8f1d8c9 100644--- a/Aetheris.Kernel.Firmament.Tests/FirmamentPmiTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentPmiTests.cs@@ -142,6 +142,71 @@ public sealed class FirmamentPmiTestsAssert.DoesNotContain(export.Value.DimensionInspection!, d => string.Equals(d.SourceTag, "auto-hole-pmi:simple_hole_callout", StringComparison.Ordinal));}++ [Fact]+ public void AutoPmi_Counterbore_SubtractStack_EmitsBoundedCounterboreDimensions()+ {+ var export = ExportFixture("testdata/firmament/fixtures/m0e-auto-pmi-counterbore-success.firmament");+ Assert.True(export.IsSuccess, string.Join(Environment.NewLine, export.Diagnostics.Select(d => d.Message)));++ Assert.NotNull(export.Value.DimensionInspection);+ var autoDimensions = export.Value.DimensionInspection!+ .Where(d => string.Equals(d.SourceTag, "auto-hole-pmi:counterbore_callout", StringComparison.Ordinal))+ .ToArray();++ Assert.Equal(2, autoDimensions.Length);+ Assert.All(autoDimensions, dimension =>+ {+ Assert.Equal(nameof(PmiDimensionKind.Diameter), dimension.Kind);+ Assert.Equal("counterbore_through", dimension.Target);+ Assert.Equal("counterbore_callout", dimension.CandidateName);+ });++ Assert.Contains(autoDimensions, d => Math.Abs(d.Value - 14d) < 1e-9d);+ Assert.Contains(autoDimensions, d => Math.Abs(d.Value - 7d) < 1e-9d);+ }++ [Fact]+ public void AutoPmi_Countersink_SubtractStack_EmitsBoundedCountersinkDimensions()+ {+ var export = ExportFixture("testdata/firmament/fixtures/m0e-auto-pmi-countersink-success.firmament");+ Assert.True(export.IsSuccess, string.Join(Environment.NewLine, export.Diagnostics.Select(d => d.Message)));++ Assert.NotNull(export.Value.DimensionInspection);+ var autoDimensions = export.Value.DimensionInspection!+ .Where(d => string.Equals(d.SourceTag, "auto-hole-pmi:countersink_callout", StringComparison.Ordinal))+ .ToArray();++ var dimension = Assert.Single(autoDimensions);+ Assert.Equal(nameof(PmiDimensionKind.Diameter), dimension.Kind);+ Assert.Equal("countersink_through", dimension.Target);+ Assert.Equal("countersink_callout", dimension.CandidateName);+ Assert.True(dimension.Value > 0d);+ }++ [Fact]+ public void AutoPmi_CounterboreLikePartialCylinderSubtract_IsRejected()+ {+ var export = ExportFixture("testdata/firmament/fixtures/m0d-cylinder-root-cylindrical-subtract.firmament");+ Assert.True(export.IsSuccess, string.Join(Environment.NewLine, export.Diagnostics.Select(d => d.Message)));++ Assert.NotNull(export.Value.DimensionInspection);+ Assert.DoesNotContain(export.Value.DimensionInspection!, dimension =>+ !string.IsNullOrWhiteSpace(dimension.SourceTag)+ && dimension.SourceTag.StartsWith("auto-hole-pmi:", StringComparison.Ordinal));+ }++ [Fact]+ public void AutoPmi_CountersinkLikeConeOnlySubtract_IsRejected()+ {+ var export = ExportFixture("testdata/firmament/fixtures/m0e-auto-pmi-countersink-reject-cone-only.firmament");+ Assert.True(export.IsSuccess, string.Join(Environment.NewLine, export.Diagnostics.Select(d => d.Message)));++ Assert.NotNull(export.Value.DimensionInspection);+ Assert.DoesNotContain(export.Value.DimensionInspection!, dimension =>+ !string.IsNullOrWhiteSpace(dimension.SourceTag)+ && dimension.SourceTag.StartsWith("auto-hole-pmi:", StringComparison.Ordinal));+ }[Fact]public void AutoPmi_ExplicitPmiSuppressesEquivalentAutoDimension(){diff --git a/Aetheris.Kernel.Firmament/FirmamentStepExporter.cs b/Aetheris.Kernel.Firmament/FirmamentStepExporter.csindex 77d2e789..1e0c8878 100644--- a/Aetheris.Kernel.Firmament/FirmamentStepExporter.cs+++ b/Aetheris.Kernel.Firmament/FirmamentStepExporter.cs@@ -465,10 +465,31 @@ public static class FirmamentStepExporterif (string.Equals(candidateName, "countersink_callout", StringComparison.Ordinal)){- yield return CreateAutoDiameterDimension(recognition.FeatureId, "countersink", recognition.PrimaryHole.TopRadius * 2d, candidateName);+ var countersinkDiameter = ResolveCountersinkEntryDiameter(recognition) * 2d;+ yield return CreateAutoDiameterDimension(recognition.FeatureId, "countersink", countersinkDiameter, candidateName);}}+ private static double ResolveCountersinkEntryDiameter(HoleFeatureRecognition recognition)+ {+ static double ResolveEntryRadius(in SupportedBooleanHole hole)+ => hole.Surface.Kind == AnalyticSurfaceKind.Cone+ ? System.Math.Max(hole.TopRadius, hole.BottomRadius)+ : hole.TopRadius;++ if (recognition.PrimaryHole.Surface.Kind == AnalyticSurfaceKind.Cone)+ {+ return ResolveEntryRadius(recognition.PrimaryHole);+ }++ if (recognition.SecondaryHole is { } secondary)+ {+ return ResolveEntryRadius(secondary);+ }++ return ResolveEntryRadius(recognition.PrimaryHole);+ }+private static PmiDimension CreateAutoDiameterDimension(string featureId, string semanticFamily, double diameter, string candidateName)=> new($"auto-diameter:{featureId}:{semanticFamily}",diff --git a/testdata/firmament/fixtures/m0e-auto-pmi-counterbore-success.firmament b/testdata/firmament/fixtures/m0e-auto-pmi-counterbore-success.firmamentnew file mode 100644index 00000000..9ca6c7d8--- /dev/null+++ b/testdata/firmament/fixtures/m0e-auto-pmi-counterbore-success.firmament@@ -0,0 +1,45 @@+firmament:+ version: 1++model:+ name: m0e_auto_pmi_counterbore_success+ units: mm++ops[3]:+ -+ op: box+ id: plate+ size[3]:+ 70+ 40+ 16+ place:+ on: origin+ offset[3]:+ 0+ 0+ -5++ -+ op: subtract+ id: counterbore_pocket+ from: plate+ with:+ op: cylinder+ radius: 7+ height: 6++ -+ op: subtract+ id: counterbore_through+ from: counterbore_pocket+ with:+ op: cylinder+ radius: 3.5+ height: 26+ place:+ on: origin+ offset[3]:+ 0+ 0+ -10diff --git a/testdata/firmament/fixtures/m0e-auto-pmi-countersink-reject-cone-only.firmament b/testdata/firmament/fixtures/m0e-auto-pmi-countersink-reject-cone-only.firmamentnew file mode 100644index 00000000..554c2f55--- /dev/null+++ b/testdata/firmament/fixtures/m0e-auto-pmi-countersink-reject-cone-only.firmament@@ -0,0 +1,25 @@+firmament:+ version: 1++model:+ name: m0e_auto_pmi_countersink_reject_cone_only+ units: mm++ops[2]:+ -+ op: box+ id: plate+ size[3]:+ 40+ 30+ 12++ -+ op: subtract+ id: cone_hole+ from: plate+ with:+ op: cone+ bottom_radius: 3+ top_radius: 5+ height: 20diff --git a/testdata/firmament/fixtures/m0e-auto-pmi-countersink-success.firmament b/testdata/firmament/fixtures/m0e-auto-pmi-countersink-success.firmamentnew file mode 100644index 00000000..04ebe2e4--- /dev/null+++ b/testdata/firmament/fixtures/m0e-auto-pmi-countersink-success.firmament@@ -0,0 +1,46 @@+firmament:+ version: 1++model:+ name: m0e_auto_pmi_countersink_success+ units: mm++ops[3]:+ -+ op: box+ id: plate+ size[3]:+ 70+ 40+ 16+ place:+ on: origin+ offset[3]:+ 0+ 0+ -2++ -+ op: subtract+ id: countersink_entry+ from: plate+ with:+ op: cone+ bottom_radius: 1.75+ top_radius: 3.5+ height: 4+ place:+ on: origin+ offset[3]:+ 0+ 0+ 6++ -+ op: subtract+ id: countersink_through+ from: countersink_entry+ with:+ op: cylinder+ radius: 1.75+ height: 26