Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Measure volume from qualified exported hole boundaries

Yuechen Li2d81a532d7d1
diff --git a/Aetheris.CLI.Tests/FirmamentMeasureCliTests.cs b/Aetheris.CLI.Tests/FirmamentMeasureCliTests.cs
index 27d6be6d..78a746a6 100644
--- a/Aetheris.CLI.Tests/FirmamentMeasureCliTests.cs
+++ b/Aetheris.CLI.Tests/FirmamentMeasureCliTests.cs
@@ -95,6 +95,21 @@ public sealed class FirmamentMeasureCliTests
finally { Directory.Delete(scratch, true); }
}
+ [Fact]
+ public void SdfMeasuresTheExportedHolesAndExplainsItsCompleteBoundaryQualification()
+ {
+ var output = new StringWriter(); var error = new StringWriter();
+ Assert.Equal(0, CliRunner.Run(["measure", Fixture("through-hole-plate"), "--sdf", "--error", "20", "--json"], output, error));
+ using var json = JsonDocument.Parse(output.ToString());
+ var volume = json.RootElement.GetProperty("volume");
+ Assert.InRange(80 * 50 * 8 - Math.PI * 16 * 8,
+ volume.GetProperty("lowerBoundMm3").GetDouble(), volume.GetProperty("upperBoundMm3").GetDouble());
+ Assert.False(volume.GetProperty("budgetExhausted").GetBoolean());
+ Assert.Equal("CompleteFinalBrepRectangularStockThroughHoles", volume.GetProperty("fieldQualification").GetString());
+ Assert.Equal(7, volume.GetProperty("fieldCoveredFaceCount").GetInt32());
+ Assert.Equal(64, volume.GetProperty("fieldSourceStepSha256").GetString()!.Length);
+ }
+
[Fact]
public void SdfMeasurementCarriesUncertaintyAndKeepsMeshComparisonDiagnosticOnly()
{
diff --git a/Aetheris.Continuum.Tests/Aetheris.Continuum.Tests.csproj b/Aetheris.Continuum.Tests/Aetheris.Continuum.Tests.csproj
index c9ab741b..cba8644c 100644
--- a/Aetheris.Continuum.Tests/Aetheris.Continuum.Tests.csproj
+++ b/Aetheris.Continuum.Tests/Aetheris.Continuum.Tests.csproj
@@ -15,6 +15,7 @@
<ItemGroup>
<Using Include="Xunit" />
+ <Compile Include="..\Aetheris.Kernel.Core.Tests\Step242\Step242Corpus.cs" Link="Support\Step242Corpus.cs" />
</ItemGroup>
<ItemGroup>
diff --git a/Aetheris.Continuum.Tests/Backends/Sdf/BrepSdfVolumeLoweringTests.cs b/Aetheris.Continuum.Tests/Backends/Sdf/BrepSdfVolumeLoweringTests.cs
new file mode 100644
index 00000000..3a1b655e
--- /dev/null
+++ b/Aetheris.Continuum.Tests/Backends/Sdf/BrepSdfVolumeLoweringTests.cs
@@ -0,0 +1,35 @@
+using Aetheris.Continuum.Backends.Sdf;
+using Aetheris.Kernel.Core.Brep;
+using Aetheris.Kernel.Core.Tests.Step242;
+
+namespace Aetheris.Continuum.Tests.Backends.Sdf;
+
+public sealed class BrepSdfVolumeLoweringTests
+{
+ [Fact]
+ public void ABodyWithoutResolvedShellEvidenceCannotGrantVolumeAuthority()
+ {
+ var body = BrepPrimitives.CreateBox(10, 8, 6).Value;
+ Assert.Null(body.FaceOrientationReport);
+ Assert.False(BrepSdfVolumeLowering.TryLower(body, out var field, out var reason));
+ Assert.Null(field);
+ Assert.Contains("qualified closed material shell", reason);
+ }
+
+ [Fact]
+ [Trait("Category", "SlowCorpus")]
+ public void Ctc01IsAnUncoveredTrimmedSolidRatherThanAMissingAnalyticSurfaceRecovery()
+ {
+ var body = Step242Corpus.Body("testdata/step242/nist/CTC/nist_ctc_01_asme1_ap242-e1.stp");
+ Assert.Equal(117, body.Topology.Faces.Count());
+ Assert.All(body.Topology.Faces, face => Assert.True(body.GetFaceSurface(face.Id).Kind is
+ Aetheris.Kernel.Core.Geometry.SurfaceGeometryKind.Plane or
+ Aetheris.Kernel.Core.Geometry.SurfaceGeometryKind.Cylinder or
+ Aetheris.Kernel.Core.Geometry.SurfaceGeometryKind.Cone));
+ Assert.False(BrepSdfVolumeLowering.TryLower(body, out var field, out var reason));
+ Assert.Null(field); // Never return an admitted stock-only partial field.
+ Assert.Contains("Face ", reason);
+ Assert.True(reason.Contains("plane", StringComparison.OrdinalIgnoreCase)
+ || reason.Contains("support", StringComparison.OrdinalIgnoreCase), reason);
+ }
+}
diff --git a/Aetheris.Continuum/Backends/Sdf/BrepSdfVolumeLowering.cs b/Aetheris.Continuum/Backends/Sdf/BrepSdfVolumeLowering.cs
new file mode 100644
index 00000000..27247020
--- /dev/null
+++ b/Aetheris.Continuum/Backends/Sdf/BrepSdfVolumeLowering.cs
@@ -0,0 +1,52 @@
+using Aetheris.Kernel.Core.Brep;
+using Aetheris.Kernel.Core.Brep.Queries;
+using Aetheris.Kernel.Core.Math;
+using Aetheris.Kernel.Core.Topology;
+
+namespace Aetheris.Continuum.Backends.Sdf;
+
+/// <summary>A complete final-boundary recognition, not a construction-history mirror.</summary>
+public sealed record BrepSdfVolumeField(SdfNode Root, string Qualification, RectangularPlateDefinition Stock)
+{
+ public IReadOnlyList<FaceId> CoveredFaces => Stock.CoveredFaces;
+}
+
+public static class BrepSdfVolumeLowering
+{
+ /// <summary>Every admitted boundary belongs to the recognized stock or its
+ /// disjoint round through holes. Additional material, pockets, blends or
+ /// unsupported trims reject the entire lowering; no partial field escapes.</summary>
+ public static bool TryLower(BrepBody body, out BrepSdfVolumeField? field, out string reason)
+ {
+ ArgumentNullException.ThrowIfNull(body);
+ field = null;
+ if (body.FaceOrientationReport is not { } report || report.Shells.Count != 1
+ || report.Shells.Any(s => s.IsInnerVoid || !s.IsClosedManifold || s.Qualification != FaceOrientationQualification.DerivedQualified))
+ {
+ reason = "Final-body SDF requires one qualified closed material shell with resolved orientation.";
+ return false;
+ }
+ if (!BrepRectangularPlateQuery.TryDefine(body, out var plate, out reason)) return false;
+ var stock = plate!;
+ var center = new Vector3D(stock.Origin.X + stock.Width / 2,
+ stock.Origin.Y + stock.Height / 2, stock.Origin.Z + stock.Thickness / 2);
+ if (!double.IsFinite(stock.Thickness * 3))
+ {
+ reason = "Through-hole extension exceeds the finite field domain.";
+ return false;
+ }
+ SdfNode root = new SdfTransformNode(new SdfBoxNode(stock.Width, stock.Height, stock.Thickness),
+ Transform3D.CreateTranslation(center));
+ foreach (var hole in stock.Holes)
+ {
+ // Extend past both stock caps: a finite tool ending on a cap would
+ // leave a spurious zero-valued disk in the hole mouth.
+ var tool = new SdfTransformNode(new SdfCylinderNode(hole.Diameter / 2, stock.Thickness * 3),
+ Transform3D.CreateTranslation(new(hole.X, hole.Y, center.Z)));
+ root = new SdfSubtractNode(root, tool);
+ }
+ field = new(root, "CompleteFinalBrepRectangularStockThroughHoles", stock);
+ reason = "Every final face, loop and edge is covered by exact stock and through-hole recognition.";
+ return true;
+ }
+}
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242Corpus.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242Corpus.cs
index 5015ac83..632d16c9 100644
--- a/Aetheris.Kernel.Core.Tests/Step242/Step242Corpus.cs
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242Corpus.cs
@@ -32,7 +32,15 @@ internal static class Step242Corpus
/// <summary>Absolute path of a corpus file named relative to the repository root.</summary>
public static string Path(string relativePath) =>
- System.IO.Path.Combine(Step242CorpusManifestRunner.RepoRoot(), relativePath.Replace('/', System.IO.Path.DirectorySeparatorChar));
+ System.IO.Path.Combine(RepoRoot(), relativePath.Replace('/', System.IO.Path.DirectorySeparatorChar));
+
+ public static string RepoRoot()
+ {
+ var directory = new DirectoryInfo(AppContext.BaseDirectory);
+ while (directory is not null && !File.Exists(System.IO.Path.Combine(directory.FullName, "Aetheris.slnx")))
+ directory = directory.Parent;
+ return directory?.FullName ?? throw new InvalidOperationException("Unable to locate Aetheris repository root.");
+ }
/// <summary>The file's text, read at most once per path per test run.</summary>
public static string Text(string relativePath) =>
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242CorpusManifestRunner.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242CorpusManifestRunner.cs
index d38e23f6..78979f82 100644
--- a/Aetheris.Kernel.Core.Tests/Step242/Step242CorpusManifestRunner.cs
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242CorpusManifestRunner.cs
@@ -137,21 +137,7 @@ internal static class Step242CorpusManifestRunner
public static string NormalizeLf(string value) => value.Replace("\r\n", "\n", StringComparison.Ordinal).Replace("\r", "\n", StringComparison.Ordinal);
- public static string RepoRoot()
- {
- var directory = new DirectoryInfo(AppContext.BaseDirectory);
- while (directory is not null)
- {
- if (File.Exists(Path.Combine(directory.FullName, "Aetheris.slnx")))
- {
- return directory.FullName;
- }
-
- directory = directory.Parent;
- }
-
- throw new InvalidOperationException("Unable to locate repository root.");
- }
+ public static string RepoRoot() => Step242Corpus.RepoRoot();
private static string ComputeSha256LowerHex(string text)
{
diff --git a/Aetheris.Kernel.Core/Brep/Queries/BrepRectangularPlateQuery.cs b/Aetheris.Kernel.Core/Brep/Queries/BrepRectangularPlateQuery.cs
index b60fdd9b..acb2458d 100644
--- a/Aetheris.Kernel.Core/Brep/Queries/BrepRectangularPlateQuery.cs
+++ b/Aetheris.Kernel.Core/Brep/Queries/BrepRectangularPlateQuery.cs
@@ -35,17 +35,21 @@ public static class BrepRectangularPlateQuery
{
var n = plane.Normal.ToVector();
var axis = Axis(n);
- if (axis < 0) return false;
+ if (axis < 0)
+ { reason = $"Face {face.Id.Value} has a non-axis-aligned plane; complete rectangular-stock recognition requires axis-aligned stock planes."; return false; }
planes.Add((face, plane, axis));
}
else if (surface?.Cylinder is { } cylinder && Axis(cylinder.Axis.ToVector()) == 2)
{
- if (!body.Bindings.TryGetFaceBinding(face.Id, out var binding) || binding.Orientation.IsAlignedWithSurface) return false;
+ if (!body.Bindings.TryGetFaceBinding(face.Id, out var binding) || binding.Orientation.IsAlignedWithSurface)
+ { reason = $"Face {face.Id.Value} has cylindrical support without inward hole-wall orientation; stock cylinders and bosses are not rectangular-stock through holes."; return false; }
walls.Add((face, cylinder));
}
- else return false;
+ else
+ { reason = $"Face {face.Id.Value} has unsupported stock/hole support {surface?.Kind}; complete recognition admits stock planes and circular Z-through-hole walls."; return false; }
}
- if (planes.Count != 6 || Enumerable.Range(0, 3).Any(a => planes.Count(p => p.Axis == a) != 2)) return false;
+ if (planes.Count != 6 || Enumerable.Range(0, 3).Any(a => planes.Count(p => p.Axis == a) != 2))
+ { reason = $"Complete rectangular-stock recognition requires six stock planes (two per axis); found {planes.Count}."; return false; }
double Coordinate(Point3D p, int axis) => axis == 0 ? p.X : axis == 1 ? p.Y : p.Z;
var min = Enumerable.Range(0, 3).Select(a => planes.Where(p => p.Axis == a).Min(p => Coordinate(p.Plane.Origin, a))).ToArray();
var max = Enumerable.Range(0, 3).Select(a => planes.Where(p => p.Axis == a).Max(p => Coordinate(p.Plane.Origin, a))).ToArray();
diff --git a/Aetheris.Kernel.Firmament.Tests/FinalBodySdfVolumeTests.cs b/Aetheris.Kernel.Firmament.Tests/FinalBodySdfVolumeTests.cs
new file mode 100644
index 00000000..81d96664
--- /dev/null
+++ b/Aetheris.Kernel.Firmament.Tests/FinalBodySdfVolumeTests.cs
@@ -0,0 +1,97 @@
+using System.Security.Cryptography;
+using System.Text;
+using Aetheris.Continuum.Backends.Sdf;
+using Aetheris.Kernel.Firmament.Analysis;
+using Aetheris.Kernel.Firmament.Modules;
+
+namespace Aetheris.Kernel.Firmament.Tests;
+
+public sealed class FinalBodySdfVolumeTests
+{
+ private static string Source(string name) => File.ReadAllText(FirmamentCorpusHarness.ResolveFixtureFullPath(
+ "fixtures/Regression/Assertions/" + name + ".firmament"));
+
+ private static FirmamentStepExportResult Build(string name)
+ {
+ var result = FirmamentBuildAndExport.CompileSource(Source(name));
+ Assert.True(result.IsSuccess, string.Join("; ", result.Diagnostics.Select(d => d.Message)));
+ return result.Value;
+ }
+
+ [Fact]
+ public void FinalHoleGeometryOverridesAStaleStockMirrorAndCarriesBoundaryProvenance()
+ {
+ var plate = Build("through-hole-plate");
+ var stockMirror = Build("box").Cir;
+ Assert.NotNull(stockMirror);
+ var product = plate with { Cir = stockMirror };
+ var measurement = new FirmamentMeasurements(product);
+ var volume = measurement.Volume(20, forceSdf: true);
+ var expected = 80 * 50 * 8 - Math.PI * 4 * 4 * 8;
+ Assert.True(volume.Authoritative);
+ Assert.False(volume.BudgetExhausted);
+ Assert.InRange(expected, volume.LowerBoundMm3!.Value, volume.UpperBoundMm3!.Value);
+ Assert.True(volume.UpperBoundMm3 < 80 * 50 * 8);
+ Assert.Equal("CompleteFinalBrepRectangularStockThroughHoles", volume.FieldQualification);
+ Assert.Equal(measurement.Topology.Faces, volume.FieldCoveredFaceCount);
+ Assert.Equal(Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(plate.StepText))).ToLowerInvariant(), volume.FieldSourceStepSha256);
+ Assert.Equal(plate.StepText, product.StepText);
+
+ Assert.True(BrepSdfVolumeLowering.TryLower(measurement.Body, out var field, out var reason), reason);
+ var tape = SdfTapeLowerer.Lower(field!.Root);
+ Assert.True(tape.Evaluate(new(0, 0, 4)) > 0); // Empty bore.
+ Assert.True(tape.Evaluate(new(0, 0, 0)) > 0); // No spurious bottom cap disk.
+ Assert.True(tape.Evaluate(new(0, 0, 8)) > 0); // No spurious top cap disk.
+ Assert.True(tape.Evaluate(new(10, 0, 4)) < 0); // Retained material.
+ }
+
+ [Fact]
+ public void EveryFinalHoleContributesAndTwoHolesCannotReuseTheOneHoleField()
+ {
+ var one = Build("through-hole-plate");
+ var two = Build("two-through-holes");
+ var first = new FirmamentMeasurements(one).Volume(20, true);
+ var second = new FirmamentMeasurements(two with { Cir = one.Cir }).Volume(20, true);
+ Assert.False(second.BudgetExhausted);
+ Assert.InRange(80 * 50 * 8 - 2 * Math.PI * 16 * 8, second.LowerBoundMm3!.Value, second.UpperBoundMm3!.Value);
+ Assert.True(second.UpperBoundMm3 < first.LowerBoundMm3);
+ Assert.NotEqual(first.FieldSourceStepSha256, second.FieldSourceStepSha256);
+ Assert.Equal(first.FieldCoveredFaceCount + 1, second.FieldCoveredFaceCount);
+ }
+
+ [Fact]
+ public void UncoveredFilletsCannotBeMeasuredAsTheUneditedStock()
+ {
+ var source = File.ReadAllText(FirmamentCorpusHarness.ResolveFixtureFullPath(
+ "fixtures/Regression/CanonicalGeometry/profile-fillet-convex-two-segment-top.firmament"));
+ var built = FirmamentBuildAndExport.CompileSource(source);
+ Assert.True(built.IsSuccess, string.Join("; ", built.Diagnostics.Select(d => d.Message)));
+ var volume = new FirmamentMeasurements(built.Value).Volume(20, true);
+ Assert.False(volume.Authoritative);
+ Assert.Null(volume.ValueMm3);
+ Assert.Contains("No qualified final-body field", volume.Diagnostic);
+ }
+
+ [Fact]
+ public void ImportedStepPlateUsesItsFinalBoundaryWithoutAnyRetainedSourceField()
+ {
+ var native = Build("through-hole-plate");
+ var pin = Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(native.StepText))).ToLowerInvariant();
+ var imported = FirmamentBuildAndExport.CompileSource(Source("imported-plate"), "",
+ new Dictionary<string, string>
+ {
+ ["plate.step"] = native.StepText,
+ [FirmamentDependencyLock.FileName] = new FirmamentDependencyLock("imported-plate.firmament",
+ [new("plate.step", "step", "sha256-bytes", pin)]).ToToml()
+ });
+ Assert.True(imported.IsSuccess, string.Join("; ", imported.Diagnostics.Select(d => d.Message)));
+ Assert.Null(imported.Value.Cir);
+ var before = imported.Value.StepText;
+ var volume = new FirmamentMeasurements(imported.Value).Volume(20, true);
+ Assert.True(volume.Authoritative);
+ Assert.False(volume.BudgetExhausted);
+ Assert.InRange(80 * 50 * 8 - Math.PI * 16 * 8, volume.LowerBoundMm3!.Value, volume.UpperBoundMm3!.Value);
+ Assert.Equal("CompleteFinalBrepRectangularStockThroughHoles", volume.FieldQualification);
+ Assert.Equal(before, imported.Value.StepText);
+ }
+}
diff --git a/Aetheris.Kernel.Firmament/Analysis/FirmamentMeasurements.cs b/Aetheris.Kernel.Firmament/Analysis/FirmamentMeasurements.cs
index d083d217..6c236f77 100644
--- a/Aetheris.Kernel.Firmament/Analysis/FirmamentMeasurements.cs
+++ b/Aetheris.Kernel.Firmament/Analysis/FirmamentMeasurements.cs
@@ -6,6 +6,8 @@ using Aetheris.Kernel.Core.Geometry;
using Aetheris.Kernel.Core.Judgment;
using Aetheris.Kernel.Core.Step242;
using Aetheris.Kernel.Firmament.FirmamentV2;
+using System.Security.Cryptography;
+using System.Text;
namespace Aetheris.Kernel.Firmament.Analysis;
@@ -14,6 +16,9 @@ public sealed record FirmamentVolumeMeasurement(double? ValueMm3, double? LowerB
{
public int? AffineCutRegions { get; init; }
public int? IntervalFallbackRegions { get; init; }
+ public string? FieldQualification { get; init; }
+ public string? FieldSourceStepSha256 { get; init; }
+ public int? FieldCoveredFaceCount { get; init; }
public double? ErrorBoundMm3 => LowerBoundMm3 is { } lo && UpperBoundMm3 is { } hi ? (hi - lo) * .5 : null;
}
public sealed record FirmamentBoundsMeasurement(double[] MinimumMm, double[] MaximumMm, string Method);
@@ -25,6 +30,8 @@ public sealed class FirmamentMeasurements
{
private readonly FirmamentStepExportResult product;
private readonly RectangularPlateDefinition? rectangularPlate;
+ private readonly BrepSdfVolumeField? finalField;
+ private readonly string fieldRejection;
public BrepBody Body { get; }
public string? TargetBodyId { get; }
public FirmamentTopologyMeasurement Topology { get; }
@@ -47,10 +54,11 @@ public sealed class FirmamentMeasurements
TargetBodyId = new[] { product.RuntimeBodySourceName, product.RuntimeCorrespondence?.BodyStableId, product.ExportedFeatureId }
.FirstOrDefault(name => name is not null && candidates.Contains(name, StringComparer.Ordinal))
?? (candidates.Length == 1 ? candidates[0] : null);
- if (BrepRectangularPlateQuery.TryDefine(Body, out var plate, out _))
+ if (BrepSdfVolumeLowering.TryLower(Body, out finalField, out fieldRejection))
{
+ var plate = finalField!.Stock;
rectangularPlate = plate;
- Bounds = new([plate!.Origin.X, plate.Origin.Y, plate.Origin.Z],
+ Bounds = new([plate.Origin.X, plate.Origin.Y, plate.Origin.Z],
[plate.Origin.X + plate.Width, plate.Origin.Y + plate.Height, plate.Origin.Z + plate.Thickness], "ExactRectangularStockEnvelope");
}
else if (Body.Geometry.Surfaces.All(s => s.Value.Kind == SurfaceGeometryKind.Plane)
@@ -62,7 +70,7 @@ public sealed class FirmamentMeasurements
}
}
- private sealed record VolumeContext(BrepMassPropertiesResult? Exact, RectangularPlateDefinition? Plate, SdfNode? Root, bool ForceSdf);
+ private sealed record VolumeContext(BrepMassPropertiesResult? Exact, RectangularPlateDefinition? Plate, SdfNode? Root, bool ForceSdf, string FieldRejection);
private static readonly JudgmentEngine<VolumeContext> VolumePolicy = new();
private static readonly JudgmentCandidate<VolumeContext>[] VolumeStrategies =
[
@@ -71,15 +79,17 @@ public sealed class FirmamentMeasurements
new("ExactRectangularPlate", c => !c.ForceSdf && c.Plate is not null, _ => 2,
RejectionReason: _ => "The complete rectangular-stock/through-hole query did not admit this body, or SDF was explicitly requested.", TieBreakerPriority: 1),
new("BoundedSdf", c => c.Root is not null, _ => 1,
- RejectionReason: _ => "The compiler retained no analytic CIR field qualified to measure the exported primitive. Display-only or legacy Boolean mirrors are not volume authority.", TieBreakerPriority: 2)
+ RejectionReason: c => "No qualified final-body field is available. Display-only or legacy Boolean mirrors are not volume authority. " + c.FieldRejection, TieBreakerPriority: 2)
];
public FirmamentVolumeMeasurement Volume(double? absoluteErrorMm3 = null, bool forceSdf = false, int maximumRegions = 1_000_001)
{
BrepMassPropertiesResult? exact = null;
if (!forceSdf && BrepMassProperties.TryEvaluateExactVolume(Body, out var recognized)) exact = recognized;
- var root = product.Cir is { RuntimeRootIsExportedPrimitive: true } cir ? cir.RuntimeRoot : null;
- var decision = VolumePolicy.Evaluate(new(exact, rectangularPlate, root, forceSdf), VolumeStrategies);
+ // Inspect the exported boundary, including edits and imported geometry.
+ // Never grant volume authority merely because a display mirror exists.
+ var root = finalField?.Root ?? (product.Cir is { RuntimeRootIsExportedPrimitive: true } cir ? cir.RuntimeRoot : null);
+ var decision = VolumePolicy.Evaluate(new(exact, rectangularPlate, root, forceSdf, fieldRejection), VolumeStrategies);
if (!decision.IsSuccess) return new(null, null, null, "Unavailable", false, Diagnostic:
"firmament-v2-assert-volume-measurement-unavailable: " + string.Join(" ", decision.Rejections.Select(r => r.Reason)));
if (decision.Selection!.Value.Candidate.Name == "ExactBrep")
@@ -94,6 +104,11 @@ public sealed class FirmamentMeasurements
var error = absoluteErrorMm3 ?? bounds.SizeX * bounds.SizeY * bounds.SizeZ * .005;
var result = SdfAdaptiveVolumeEstimator.EstimateBounded(SdfTapeLowerer.Lower(root), bounds, error, maximumRegions);
return new(result.EstimatedVolume, result.LowerBound, result.UpperBound, "SdfAdaptiveOccupiedVolumeInterval", true, result.RegionsVisited, result.BudgetExhausted)
- { AffineCutRegions = result.AffineCutRegions, IntervalFallbackRegions = result.IntervalFallbackRegions };
+ {
+ AffineCutRegions = result.AffineCutRegions, IntervalFallbackRegions = result.IntervalFallbackRegions,
+ FieldQualification = finalField?.Qualification ?? "RetainedExportedPrimitive",
+ FieldSourceStepSha256 = Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(product.StepText))).ToLowerInvariant(),
+ FieldCoveredFaceCount = finalField?.CoveredFaces.Count ?? Body.Topology.Faces.Count()
+ };
}
}
diff --git a/docs/development/reports/2026-10/sdf-final-body-fields.md b/docs/development/reports/2026-10/sdf-final-body-fields.md
new file mode 100644
index 00000000..77844b2e
--- /dev/null
+++ b/docs/development/reports/2026-10/sdf-final-body-fields.md
@@ -0,0 +1,118 @@
+# Final-body SDF volume fields — 2026-10-28
+
+## What now works
+
+Native and imported rectangular plates with separated circular Z-through holes
+can use bounded SDF volume through the real compiler/CLI. Authority comes from
+complete recognition of the **final exported boundary**, rather than from a
+display mirror or a field describing the unedited stock.
+
+`BrepSdfVolumeLowering` reuses `BrepRectangularPlateQuery`; it does not duplicate
+its recognition schema. The existing query accounts for every face, loop and edge.
+The field contains the translated stock and every admitted through-hole subtraction.
+Tools extend past both stock caps so the field does not leave spurious zero-valued
+disks at hole mouths. One qualified closed outer material shell is required.
+Uncovered edits reject the complete field rather than producing a partial model.
+
+The existing query's numerical matching tolerances remain unchanged (1e-7 mm
+linear matching and 1e-12 axis alignment). Qualification is conditional on that
+analytic boundary-recognition contract and the integrator's floating-point guards;
+it is not a formally outward-rounded certificate for arbitrary noisy BReps.
+
+`FirmamentMeasurements` caches this recognition per measurement object and uses
+the existing JudgmentEngine volume policy. Exact measures retain precedence;
+`--sdf` requests the bounded field explicitly. Existing exported-primitive authority
+remains available where the compiler already qualifies it. No legacy Boolean mirror
+was promoted wholesale.
+
+JSON adds `fieldQualification`, `fieldCoveredFaceCount` and
+`fieldSourceStepSha256`. The hash identifies the exact UTF-8 final STEP artifact,
+including metadata; it is not advertised as a geometry-only identity.
+
+## Actual CLI evidence
+
+All cases request ±20 mm³ integration uncertainty and finish without exhaustion:
+
+| Case | Analytic volume mm³ | Reported interval mm³ | Regions | Covered faces |
+|---|---:|---|---:|---:|
+| Native 80×50×8 plate, one Ø8 hole | 31597.876 | [31561.277, 31601.270] | 57,373 | 7 |
+| Native plate, two Ø8 holes | 31195.752 | [31162.263, 31202.258] | 69,437 | 8 |
+| Re-imported one-hole STEP | 31597.876 | [31561.277, 31601.270] | 57,373 | 7 |
+
+The one/two-hole intervals are disjoint, so omission of the second hole cannot
+pass this comparison. Tests also supply a stale stock mirror and require the field
+to follow the final perforated body. Hole-center and cap-mouth point checks detect
+accidental retained material. Unsupported fillets remain unavailable.
+
+The imported specimen uses the existing dependency lock and geometry-only source
+pinning rules. The actual CLI `build → lock → measure --sdf` sequence succeeds;
+the input STEP hash remains unchanged. Tests retain the final STEP text before and
+after measurement and require equality. Reproduction is in
+`fixtures/Regression/Assertions/README.md`.
+
+## CTC-01: concrete remaining blocker
+
+The actual imported source builds. Explicit SDF measurement still exits 1 with
+`Unavailable`, identifying **face 4's cylindrical stock/boss support**, which cannot
+be treated as a through-hole wall by the complete rectangular-stock recognizer.
+No stock-only fallback is returned.
+
+Current CLI analysis reports 117 faces: 56 planes, 57 cylinders and four cones;
+there are no unrecovered spline surfaces. Fourteen edge curves are BSplines.
+This is not a recurrence of stricter surface-recovery admission.
+
+The qualification tool now runs the existing analytic ray-consensus point query
+with one reused query context. On a deterministic 5×5×5 probe:
+
+- 65 points return Outside, one Inside, and **59 Unknown**.
+- The point-query loop takes approximately 395 ms on this machine.
+- The output explicitly says `PointProbeNotVolumeQualification`.
+- Vertex extents choose the sample domain only; they are not certified enclosing
+ bounds. No sample-derived volume or independent sign-accuracy claim is made.
+
+Reproduce with:
+
+```powershell
+dotnet tools/Aetheris.SdfVolumeQualification/bin/Release/net10.0/Aetheris.SdfVolumeQualification.dll --imported-occupancy-probe testdata/step242/nist/CTC/nist_ctc_01_asme1_ap242-e1.stp
+```
+
+The smallest general imported-body prerequisite is in the existing spatial/trim
+query owner: resolve the unknown point cases, establish conservative trimmed-solid
+bounds, and provide conservative cell classification (including Unknown/Cut).
+Point consensus is not Euclidean distance, and it does not establish absence of a
+thin feature between samples. Once that capability is qualified, adapt the existing
+volume integrator to it. A fitted field built from the same suspect STL would not
+be an independent check and was not added.
+
+## Qualification and quality
+
+Final qualification:
+
+- Release solution build: zero errors (38 existing nullable/analyzer/WASM warnings).
+- Focused Continuum lane: 13 passed; focused compiler/assertion lane: 21 passed.
+- Fast Core lane: 1,168 passed; full Core corpus lane: 1,356 passed.
+- Full solution gate: **6,323 passed, zero failed, two optional external PDF-renderer
+ skips**, across twenty test assemblies. Existing canonical/interchange and
+ editable V8 qualification remain green.
+- Managed/WASM SDK rebuilt; all nineteen JavaScript SDK tests passed.
+- Production native/imported CLI measurements succeed; CTC-01 reports explicit
+ refusal; source STEP hash is unchanged; `git diff --check` passed.
+- Task-owned build, test and probe hosts exited; no .NET/test hosts remained.
+- Serial Release builds used `-m:1 -nr:false -p:UseSharedCompilation=false`;
+ the full test gate used `--no-build -m:1 -- RunConfiguration.MaxCpuCount=1`.
+
+Focused tests cover complete final-body provenance, stale mirrors, every hole, empty mouths,
+imported source preservation, unqualified shells, uncovered fillets and CTC-01
+refusal. CTC-01 tests reuse the existing memoized `Step242Corpus` helper; repository
+root discovery was made independent of the manifest runner so that helper can be
+linked into Continuum tests without pulling in the corpus-report implementation.
+
+No geometry builder, exporter, parser, display tessellator or public syntax changed.
+There is no new global cache, alternate volume engine or permissive admission flag.
+Generated CLI JSON, source STEP, dependency lock, point probe and test logs live
+under ignored `artifacts/local/sdf-final-body/`.
+
+**Verdict: Meaningful progression.** Complete final-boundary SDF admission now
+works for an edited and imported engineering family. General CTC-01 SDF volume
+remains explicitly unqualified, with measured point-query gaps and the missing
+conservative trimmed-cell capability identified.
diff --git a/docs/public/reference/language/checks.md b/docs/public/reference/language/checks.md
index e7b87345..569fe681 100644
--- a/docs/public/reference/language/checks.md
+++ b/docs/public/reference/language/checks.md
@@ -65,9 +65,14 @@ as **unverified**, including when the deterministic subdivision budget runs out.
The midpoint is an estimate, not an exact volume. Display-mesh mass estimates do
not gate an assertion. A part without an admitted exact recognizer or complete
SDF reports that limitation instead of silently accepting its volume assertion.
-The SDF assertion route currently covers single Box, Cylinder, Cone, Sphere and
-Torus primitives. A display-only or legacy Boolean mirror is insufficient evidence
-that the field matches exported material, and is not promoted to volume authority.
+The SDF assertion route covers qualified single Box, Cylinder, Cone, Sphere and
+Torus primitives, plus complete final-boundary recognition of axis-aligned
+rectangular stock with separated circular Z-through holes. This latter path works
+for native parts and imported STEP with the same admitted boundary. It requires
+one qualified closed material shell and accounts for every face, loop and edge;
+an additional unrecognized feature rejects the entire field lowering. A display-only
+or legacy Boolean mirror is insufficient evidence that the field matches exported
+material, and is not promoted to volume authority.
`Assert Bounds` compares exact world-space minima/maxima, using the optional
nonnegative length `tolerance` (default 0mm). Exact bounds currently cover qualified
@@ -125,9 +130,18 @@ estimate for diagnosis, never as a substitute assertion authority.
The default engineering volume path prefers admitted exact BRep formulas, then
bounded SDF integration when the compiler retains a field qualified to represent
the **final exported body**. `--sdf` requests that field path explicitly. A field
-for stock before holes or edits is insufficient. STEP imports without such a
-field report volume unavailable; display meshes and sampled point-cloud fields
-do not silently become volume authority.
+for stock before holes or edits is insufficient. Complete rectangular-stock/through-hole
+recognition derives its field from the final exported BRep, independently of feature
+history. Other STEP imports without a qualified complete field report volume
+unavailable; display meshes and sampled point-cloud fields do not silently become
+volume authority. This bounded recognizer does not admit slots, blind holes,
+counterbores, countersinks, side holes, ribs, blends or arbitrary rotated stock.
+
+For SDF measurements, `fieldQualification` names the evidence family,
+`fieldCoveredFaceCount` reports covered final faces, and `fieldSourceStepSha256`
+identifies the exact UTF-8 final STEP artifact used by the query. This is an artifact
+receipt, including its metadata, rather than a geometry-only identity. Qualification
+never comes from merely having a retained display field.
The integrator bounds partially occupied cells using analytic local field envelopes
and plane/box volume integrals. Curvature contributes to the uncertainty; it is not
diff --git a/fixtures/Regression/Assertions/README.md b/fixtures/Regression/Assertions/README.md
index 61c3ed4f..3918f5f7 100644
--- a/fixtures/Regression/Assertions/README.md
+++ b/fixtures/Regression/Assertions/README.md
@@ -5,6 +5,9 @@
| `box.firmament` | Accepted | Exact 480 mm³, world bounds [-5,-4,0]–[5,4,6] mm, 6/12/8/1 face/edge/vertex/shell counts |
| `through-hole-plate.firmament` | Accepted | 80×50×8 mm stock minus an 8 mm through-hole: 32000−128π mm³, unchanged outer bounds and one shell |
| `sphere.firmament` | Accepted | Analytic 4π·10³/3 mm³ lies inside the bounded SDF interval; ±200 mm³ assertion encloses it |
+| `sphere-tight.firmament` | Accepted | A ±4 mm³ assertion with bounded SDF integration |
+| `two-through-holes.firmament` | Accepted | Every final hole participates in the SDF: 32000−256π mm³ |
+| `imported-plate.firmament` | Harness asset required | Imports the exported plate and its dependency lock; has no retained construction field |
| `two-bodies.firmament` | Rejected | Existing multiple-material-body admission gate rejects independent outputs before assertion evaluation; never measure Second under First's name |
The tests mutate expected values, fields and topology to prove rejection without
@@ -16,4 +19,17 @@ Six historical curved-fillet specimens in `../CanonicalGeometry/` now use
assertions. They compile normally and retain their existing deterministic STEP,
topology and geometry regression checks. A separate negative test appends an
unprovable volume assertion and still requires `measurement-unavailable` rejection.
-See `docs/development/FIRMAMENT-ASSERTIONS-2026-10-19.md` for the earlier classification.
+Current behavior is documented in [checks](../../../docs/public/reference/language/checks.md).
+
+To reproduce the imported-plate measurement from the repository root:
+
+```powershell
+New-Item -ItemType Directory -Force artifacts/local/sdf-final-body | Out-Null
+aetheris build fixtures/Regression/Assertions/through-hole-plate.firmament --out artifacts/local/sdf-final-body/plate.step
+Copy-Item fixtures/Regression/Assertions/imported-plate.firmament artifacts/local/sdf-final-body/imported-plate.firmament
+aetheris lock artifacts/local/sdf-final-body/imported-plate.firmament --update
+aetheris measure artifacts/local/sdf-final-body/imported-plate.firmament --sdf --error 20 --json
+```
+
+The harness uses the same source through in-memory resources and supplies the
+matching lock. No pin or geometry-only import rule is bypassed.
diff --git a/fixtures/Regression/Assertions/imported-plate.firmament b/fixtures/Regression/Assertions/imported-plate.firmament
new file mode 100644
index 00000000..f8134ec9
--- /dev/null
+++ b/fixtures/Regression/Assertions/imported-plate.firmament
@@ -0,0 +1,5 @@
+// The qualification harness supplies plate.step and its dependency lock from the native plate's STEP export.
+Model ImportedPlate {
+ units: mm
+ InlineStep Source { path: "plate.step"; geometryOnly: true }
+}
diff --git a/fixtures/Regression/Assertions/two-through-holes.firmament b/fixtures/Regression/Assertions/two-through-holes.firmament
new file mode 100644
index 00000000..cfe7eb2f
--- /dev/null
+++ b/fixtures/Regression/Assertions/two-through-holes.firmament
@@ -0,0 +1,8 @@
+Model TwoHolePlate {
+ units: mm
+ Box Body { size: [80mm, 50mm, 8mm] }
+ Modify Body {
+ Hole<Shaft> Left { on: +Z; center: Point2(-15mm, 0mm); diameter: 8mm; end: ThroughAll }
+ Hole<Shaft> Right { on: +Z; center: Point2(15mm, 0mm); diameter: 8mm; end: ThroughAll }
+ }
+}
diff --git a/tools/Aetheris.SdfVolumeQualification/ImportedOccupancyProbe.cs b/tools/Aetheris.SdfVolumeQualification/ImportedOccupancyProbe.cs
new file mode 100644
index 00000000..34ecc9a0
--- /dev/null
+++ b/tools/Aetheris.SdfVolumeQualification/ImportedOccupancyProbe.cs
@@ -0,0 +1,56 @@
+using System.Diagnostics;
+using System.Security.Cryptography;
+using System.Text;
+using System.Text.Json;
+using Aetheris.Continuum.Backends.Sdf;
+using Aetheris.Kernel.Core.Brep.Queries;
+using Aetheris.Kernel.Core.Math;
+using Aetheris.Kernel.Core.Step242;
+
+internal static class ImportedOccupancyProbe
+{
+ public static int Run(string path)
+ {
+ var source = File.ReadAllText(path);
+ var imported = Step242Importer.ImportBody(source);
+ if (!imported.IsSuccess)
+ {
+ Console.WriteLine(JsonSerializer.Serialize(new { Status = "ImportRejected", imported.Diagnostics }));
+ return 1;
+ }
+ var body = imported.Value;
+ var vertices = body.Topology.Vertices.Select(v => body.TryGetVertexPoint(v.Id, out var p) ? p
+ : throw new InvalidOperationException("Probe requires explicit vertex coordinates.")).ToArray();
+ var min = new Point3D(vertices.Min(p => p.X), vertices.Min(p => p.Y), vertices.Min(p => p.Z));
+ var max = new Point3D(vertices.Max(p => p.X), vertices.Max(p => p.Y), vertices.Max(p => p.Z));
+ var query = BrepSpatialQueries.CreatePointContainmentQueryContext(body);
+ _ = BrepSpatialQueries.ClassifyPoint(body, min, null, query);
+ var rows = new List<object>();
+ var counts = new Dictionary<string, int>();
+ var watch = Stopwatch.StartNew();
+ for (var x = 0; x < 5; x++)
+ for (var y = 0; y < 5; y++)
+ for (var z = 0; z < 5; z++)
+ {
+ var point = new Point3D(min.X + (max.X - min.X) * (x + .37) / 5,
+ min.Y + (max.Y - min.Y) * (y + .37) / 5, min.Z + (max.Z - min.Z) * (z + .37) / 5);
+ var result = BrepSpatialQueries.ClassifyPoint(body, point, null, query);
+ var status = result.IsSuccess ? result.Value.ToString() : "QueryRejected";
+ counts[status] = counts.GetValueOrDefault(status) + 1;
+ rows.Add(new { Point = new[] { point.X, point.Y, point.Z }, Classification = status });
+ }
+ watch.Stop();
+ var admitted = BrepSdfVolumeLowering.TryLower(body, out _, out var reason);
+ Console.WriteLine(JsonSerializer.Serialize(new
+ {
+ Status = "PointProbeNotVolumeQualification",
+ SourceStepSha256 = Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(source))).ToLowerInvariant(),
+ FaceCount = body.Topology.Faces.Count(), Counts = counts, Milliseconds = watch.Elapsed.TotalMilliseconds,
+ CompleteFieldAdmitted = admitted, FieldAdmissionReason = reason,
+ SamplingDomain = new { Minimum = new[] { min.X, min.Y, min.Z }, Maximum = new[] { max.X, max.Y, max.Z },
+ Basis = "Vertex extents only; not certified enclosing bounds or a volume measure." },
+ Samples = rows
+ }, new JsonSerializerOptions { WriteIndented = true }));
+ return 0;
+ }
+}
diff --git a/tools/Aetheris.SdfVolumeQualification/Program.cs b/tools/Aetheris.SdfVolumeQualification/Program.cs
index 090f9154..9d16f868 100644
--- a/tools/Aetheris.SdfVolumeQualification/Program.cs
+++ b/tools/Aetheris.SdfVolumeQualification/Program.cs
@@ -3,6 +3,8 @@ using System.Text.Json;
using Aetheris.Continuum.Backends.Sdf;
using Aetheris.Kernel.Core.Math;
+if (args.Length == 2 && args[0] == "--imported-occupancy-probe") return ImportedOccupancyProbe.Run(args[1]);
+
var budget = args.Length > 0 ? int.Parse(args[0]) : 100001;
var relativeError = args.Length > 1 ? double.Parse(args[1], System.Globalization.CultureInfo.InvariantCulture) : .001;
var repetitions = args.Length > 2 ? int.Parse(args[2]) : 3;
diff --git a/tools/Aetheris.SdfVolumeQualification/README.md b/tools/Aetheris.SdfVolumeQualification/README.md
index 1b66be0f..f2420014 100644
--- a/tools/Aetheris.SdfVolumeQualification/README.md
+++ b/tools/Aetheris.SdfVolumeQualification/README.md
@@ -26,3 +26,9 @@ enclosure is not silently counted as meeting the requested uncertainty.
`IntervalOnlyControl.cs` freezes the former production estimator from `e1310ce2`
for a controlled comparison with identical tape intervals, bounds, error and budget.
It is executable qualification evidence, not another selectable production strategy.
+
+`--imported-occupancy-probe path.step` exercises the existing analytic ray-consensus
+query at 125 deterministic points, reusing one query context. It reports unknown
+classifications, runtime and complete-field admission separately. Vertex extents
+only choose a sampling domain; they are not certified bounds. This experiment
+never estimates a volume or grants authority from point samples.