Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Route localized fillet junctions through the compiler
Yuechen Li1bd784dd1765
diff --git a/Aetheris.CLI.Tests/LocalizedTangentBlendFilletPipelineTests.cs b/Aetheris.CLI.Tests/LocalizedTangentBlendFilletPipelineTests.csindex 38be44a4..fe1c0226 100644--- a/Aetheris.CLI.Tests/LocalizedTangentBlendFilletPipelineTests.cs+++ b/Aetheris.CLI.Tests/LocalizedTangentBlendFilletPipelineTests.cs@@ -88,7 +88,7 @@ public sealed class LocalizedTangentBlendFilletPipelineTests}""");Assert.Equal(1, run.Exit);- Assert.Contains("localized-junction-unsupported-finish-combination:fillet-shared-patch-surface-required", run.Output, StringComparison.Ordinal);+ Assert.Contains("localized-fillet-junction-corner-patch-surface-required", run.Output, StringComparison.Ordinal);}private static (int Exit, string Output) Run(string source)diff --git a/Aetheris.Kernel.Core.Tests/Air/LocalizedEdgeJunctionFilletTests.cs b/Aetheris.Kernel.Core.Tests/Air/LocalizedEdgeJunctionFilletTests.csnew file mode 100644index 00000000..f3277cff--- /dev/null+++ b/Aetheris.Kernel.Core.Tests/Air/LocalizedEdgeJunctionFilletTests.cs@@ -0,0 +1,48 @@+using Aetheris.Kernel.Core.Air;++namespace Aetheris.Kernel.Core.Tests.Air;++/// <summary>Proof-carrying admission tests for AIR-FILLET-JUNCTION-M4 investigation.</summary>+public sealed class LocalizedEdgeJunctionFilletTests+{+ [Theory]+ [InlineData(10d, 8d, 6d, 1d)]+ [InlineData(10d, 8d, 6d, 2d)]+ [InlineData(12d, 5d, 7d, 1d)]+ public void EqualRadiusTwoEdgeCandidate_RejectsSphereBecauseItForcesTheThirdFillet(double width, double depth, double height, double radius)+ {+ var result = AirLocalizedEdgeJunctionFilletCompiler.Compile(Request(width, depth, height, radius, radius));++ Assert.False(result.Succeeded);+ Assert.Equal(FilletJunctionErrorKind.CornerPatchSurfaceRequired, result.Error?.Kind);+ Assert.Equal("localized-fillet-junction-corner-patch-surface-required", result.Error?.Code);+ var construction = Assert.IsType<LocalizedFilletJunctionConstruction>(result.Construction);+ var candidate = construction.Candidate;+ Assert.Equal(radius, candidate.Radius, 9);+ Assert.Equal(width / 2d - radius, candidate.Center.X, 9);+ Assert.Equal(depth / 2d - radius, candidate.Center.Y, 9);+ Assert.Equal(height / 2d - radius, candidate.Center.Z, 9);+ Assert.Equal(0d, candidate.CylinderTangencyDeviation, 12);+ Assert.Equal(System.Math.PI * radius / 2d, candidate.ThirdBoundaryLength, 9);+ Assert.Equal(0d, candidate.ThirdBoundaryTrim.Start, 12);+ Assert.Equal(System.Math.PI / 2d, candidate.ThirdBoundaryTrim.End, 12);+ Assert.Equal("CylindricalFillet(SharedEdge(+X,+Y))", candidate.RequiredAdjacentSurface);+ Assert.Contains(result.Diagnostics, d => d == "support-plane-intersections=three tangent points, not trim curves");+ }++ [Theory]+ [InlineData(1d, 2d, "localized-fillet-junction-radius-mismatch")]+ [InlineData(0d, 0d, "localized-fillet-junction-radius-must-be-positive")]+ [InlineData(6d, 6d, "localized-fillet-junction-radius-too-large")]+ public void JunctionAdmission_RejectsInvalidParametersBeforeAnyConstruction(double first, double second, string code)+ {+ var result = AirLocalizedEdgeJunctionFilletCompiler.Compile(Request(10, 8, 6, first, second));+ Assert.False(result.Succeeded);+ Assert.Null(result.Construction);+ Assert.Equal(code, result.Error?.Code);+ }++ private static AirLocalizedEdgeJunctionFilletCompileRequest Request(double width, double depth, double height, double first, double second) => new(+ "Base", "Base.First.Second", "First+Second", width, depth, height,+ "+X", "SharedEdgePlusZ", "+Y", "SharedEdgePlusZ", first, second, new AirSourceSpan(0, 1, "test"));+}diff --git a/Aetheris.Kernel.Core/Air/AirLocalizedEdgeJunctionFilletCompiler.cs b/Aetheris.Kernel.Core/Air/AirLocalizedEdgeJunctionFilletCompiler.csnew file mode 100644index 00000000..c98ca0b3--- /dev/null+++ b/Aetheris.Kernel.Core/Air/AirLocalizedEdgeJunctionFilletCompiler.cs@@ -0,0 +1,143 @@+using Aetheris.Kernel.Core.Geometry;+using Aetheris.Kernel.Core.Geometry.Curves;+using Aetheris.Kernel.Core.Geometry.Surfaces;+using Aetheris.Kernel.Core.Math;++namespace Aetheris.Kernel.Core.Air;++/// <summary>+/// Bounded geometric investigation for two adjacent constant-radius fillet intents.+/// This is deliberately a Construction-AIR admission stage: it never emits topology+/// unless a patch closes against the selected replacements and retained supports.+/// </summary>+internal sealed record AirLocalizedEdgeJunctionFilletCompileRequest(+ string BodyId, string FeatureId, string FeatureName, double Width, double Depth, double Height,+ string FaceA, string TargetA, string FaceB, string TargetB, double RadiusA, double RadiusB,+ AirSourceSpan SourceSpan, bool HistoryKnown = true);++internal enum FilletJunctionErrorKind+{+ EdgesDoNotShareEndpoint,+ UnsupportedJunctionValence,+ RadiusMismatch,+ RadiusTooLarge,+ UnsupportedSurfaceCombination,+ CornerPatchSurfaceRequired,+ CornerPatchConstructionFailed,+ ConstructionWitnessRequired,+}++internal sealed record FilletJunctionError(+ FilletJunctionErrorKind Kind, string Code, string Message, string Stage,+ IReadOnlyList<string> Evidence);++/// <summary>+/// Exact witness for the only simple analytic candidate. The third boundary is+/// retained as evidence because it proves why this candidate cannot be emitted as+/// a two-edge junction.+/// </summary>+internal sealed record SphericalFilletCornerCandidateWitness(+ Point3D Center,+ double Radius,+ SphereSurface Surface,+ CylinderSurface ReplacementACylinder,+ CylinderSurface ReplacementBCylinder,+ Circle3Curve ThirdBoundary,+ ParameterInterval ThirdBoundaryTrim,+ Point3D SupportTangentOnPlusX,+ Point3D SupportTangentOnPlusY,+ Point3D SupportTangentOnPlusZ,+ string RequiredAdjacentSurface,+ double CylinderTangencyDeviation,+ double ThirdBoundaryLength);++internal sealed record LocalizedFilletJunctionConstruction(+ string ConstructionId,+ AirEdgeFinishFeature ReplacementA,+ AirEdgeFinishFeature ReplacementB,+ Point3D SharedEndpoint,+ SphericalFilletCornerCandidateWitness Candidate,+ string MaterialSide,+ string Provenance);++internal sealed record AirLocalizedEdgeJunctionFilletCompileResult(+ bool Succeeded,+ LocalizedFilletJunctionConstruction? Construction,+ FilletJunctionError? Error,+ IReadOnlyList<string> Diagnostics);++internal static class AirLocalizedEdgeJunctionFilletCompiler+{+ private const double Tol = 1e-9;++ public static AirLocalizedEdgeJunctionFilletCompileResult Compile(AirLocalizedEdgeJunctionFilletCompileRequest input)+ {+ FilletJunctionError Fail(FilletJunctionErrorKind kind, string code, string message, params string[] evidence) =>+ new(kind, code, message, "FeatureAIR->ConstructionAIR", evidence);++ if (!input.HistoryKnown)+ return Rejected(Fail(FilletJunctionErrorKind.UnsupportedSurfaceCombination, "localized-fillet-junction-unsupported-history", "Localized fillet junctions require history-known axis-aligned box support planes.", "construction-history=imported/no-history"));+ if (!FinitePositive(input.Width) || !FinitePositive(input.Depth) || !FinitePositive(input.Height))+ return Rejected(Fail(FilletJunctionErrorKind.UnsupportedSurfaceCombination, "localized-fillet-junction-invalid-box-dimensions", "Box dimensions must be finite and positive."));+ if (!Matches(input.FaceA, input.TargetA, "+X") || !Matches(input.FaceB, input.TargetB, "+Y"))+ return Rejected(Fail(FilletJunctionErrorKind.EdgesDoNotShareEndpoint, "localized-fillet-junction-edges-do-not-share-canonical-endpoint", "M4 investigates SharedEdge(+X,+Z) and SharedEdge(+Y,+Z) only."));+ if (!FinitePositive(input.RadiusA) || !FinitePositive(input.RadiusB))+ return Rejected(Fail(FilletJunctionErrorKind.RadiusTooLarge, "localized-fillet-junction-radius-must-be-positive", "Both fillet radii must be finite and positive."));+ if (double.Abs(input.RadiusA - input.RadiusB) > Tol)+ return Rejected(Fail(FilletJunctionErrorKind.RadiusMismatch, "localized-fillet-junction-radius-mismatch", "The canonical candidate requires equal radii."));+ if (input.RadiusA >= input.Width - Tol || input.RadiusA >= input.Depth - Tol || input.RadiusA >= input.Height - Tol)+ return Rejected(Fail(FilletJunctionErrorKind.RadiusTooLarge, "localized-fillet-junction-radius-too-large", "The radius must remain within all three incident support extents."));++ var r = input.RadiusA;+ var hx = input.Width / 2d;+ var hy = input.Depth / 2d;+ var hz = input.Height / 2d;+ var center = new Point3D(hx - r, hy - r, hz - r);+ var x = Direction3D.Create(new Vector3D(1, 0, 0));+ var y = Direction3D.Create(new Vector3D(0, 1, 0));+ var z = Direction3D.Create(new Vector3D(0, 0, 1));+ var replacementA = new CylinderSurface(center, y, r, x);+ var replacementB = new CylinderSurface(center, x, r, y);+ var sphere = new SphereSurface(center, z, r, x);+ // This circle is the forced third spherical boundary. It is exactly the+ // radius-R cylinder about the +Z axis, i.e. a fillet of SharedEdge(+X,+Y).+ var thirdBoundary = new Circle3Curve(center, z, r, x);+ var tangentX = new Point3D(hx, hy - r, hz - r);+ var tangentY = new Point3D(hx - r, hy, hz - r);+ var tangentZ = new Point3D(hx - r, hy - r, hz);+ var candidate = new SphericalFilletCornerCandidateWitness(+ center, r, sphere, replacementA, replacementB, thirdBoundary, new ParameterInterval(0d, double.Pi / 2d), tangentX, tangentY, tangentZ,+ "CylindricalFillet(SharedEdge(+X,+Y))", 0d, (double.Pi * r) / 2d);+ var construction = new LocalizedFilletJunctionConstruction(+ $"construction:{input.FeatureId}:fillet-junction",+ Feature(input, "A", "+X", "SharedEdge(+X,+Z)"),+ Feature(input, "B", "+Y", "SharedEdge(+Y,+Z)"),+ new Point3D(hx, hy, hz), candidate,+ "inside:x<=max,y<=max,z<=max; convex exterior removal",+ "history-known-axis-aligned-rectangular-box; exact-spherical-candidate-derived");++ return Rejected(Fail(+ FilletJunctionErrorKind.CornerPatchSurfaceRequired,+ "localized-fillet-junction-corner-patch-surface-required",+ "The exact spherical candidate is tangent to the two selected cylinders, but its remaining boundary requires the unselected +X/+Y cylindrical fillet; it cannot close against retained +X, +Y, or +Z support regions.",+ $"sphere-center=({center.X:R},{center.Y:R},{center.Z:R});radius={r:R}",+ "candidate-cylinder-tangency-deviation=0",+ $"unowned-third-boundary-length={(double.Pi * r / 2d):R}",+ "required-adjacent-surface=CylindricalFillet(SharedEdge(+X,+Y))",+ "support-plane-intersections=three tangent points, not trim curves"), construction);+ }++ private static AirLocalizedEdgeJunctionFilletCompileResult Rejected(FilletJunctionError error, LocalizedFilletJunctionConstruction? construction = null) =>+ new(false, construction, error, [error.Code, .. error.Evidence]);++ private static AirEdgeFinishFeature Feature(AirLocalizedEdgeJunctionFilletCompileRequest input, string suffix, string face, string edge) => new(+ $"{input.FeatureId}.{suffix}", $"{input.FeatureName}.{suffix}", input.BodyId,+ new AirFaceBoundarySelection(face, edge, false), AirLocalizedEdgeFinishKind.Fillet,+ new AirConstantRadiusEdgeFinishRule(input.RadiusA), input.SourceSpan,+ "generated/history-known-axis-aligned-rectangular-prism", AirFeatureAdmissionStatus.Deferred,+ "localized-fillet-junction-corner-patch-surface-required");++ private static bool FinitePositive(double value) => double.IsFinite(value) && value > Tol;+ private static bool Matches(string face, string target, string expectedFace) =>+ string.Equals(face, expectedFace, StringComparison.Ordinal) && string.Equals(target, "SharedEdgePlusZ", StringComparison.Ordinal);+}diff --git a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.csindex 1d42382e..ba53c634 100644--- a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs+++ b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs@@ -168,7 +168,20 @@ public static class FirmamentBuildAndExportreturn ExportV2LocalizedEdgeJunctionChamfer(document, junctionSolid, finishes[0].Finish, finishes[1].Finish, junctionBox);}if (finishes.Length == 2 && finishes.All(x => string.Equals(x.Finish.Kind, "Fillet", StringComparison.Ordinal)))- return AirChamferFailure("localized-junction-unsupported-finish-combination:fillet-shared-patch-surface-required");+ {+ if (document.Solids.Count != 1 || document.ModifyBlocks!.Count != 1 || document.ModifyBlocks[0].Regions.Count != 0 || document.ModifyBlocks[0].SemanticHoles.Count != 0)+ return AirChamferFailure("localized-fillet-junction-production-route-requires-one-box-and-one-modify-block");+ var junctionSolid = document.Solids.SingleOrDefault(s => s.Name == finishes[0].Modify.TargetSolid);+ if (junctionSolid?.Primitive is not FirmamentV2BoxRecord junctionBox || junctionBox.Size.Count != 3)+ return AirChamferFailure("localized-fillet-junction-unsupported-history:expected-history-known-box");+ var filletInvestigation = AirLocalizedEdgeJunctionFilletCompiler.Compile(new(+ junctionSolid.Name, $"{junctionSolid.Name}.{finishes[0].Finish.Name}.{finishes[1].Finish.Name}", $"{finishes[0].Finish.Name}+{finishes[1].Finish.Name}",+ junctionBox.Size[0], junctionBox.Size[1], junctionBox.Size[2],+ finishes[0].Finish.FaceAxis, finishes[0].Finish.Target, finishes[1].Finish.FaceAxis, finishes[1].Finish.Target,+ finishes[0].Finish.Distance, finishes[1].Finish.Distance,+ new AirSourceSpan(finishes[0].Finish.SourceSpan.Start, finishes[0].Finish.SourceSpan.Length + finishes[1].Finish.SourceSpan.Length, document.ModelName)));+ return AirChamferFailure(filletInvestigation.Error?.Code ?? "localized-fillet-junction-construction-witness-required", filletInvestigation.Diagnostics);+ }if (finishes.Length == 2)return AirChamferFailure("localized-junction-unsupported-finish-combination:mixed-families");if (finishes.Length > 2)diff --git a/docs/air/air-fillet-junction-m4.md b/docs/air/air-fillet-junction-m4.mdnew file mode 100644index 00000000..1d8d62b4--- /dev/null+++ b/docs/air/air-fillet-junction-m4.md@@ -0,0 +1,78 @@+# AIR-FILLET-JUNCTION-M4 — two-edge equal-radius fillet investigation++## Result++M4 does **not** admit a two-edge fillet STEP route yet. It closes the former+implicit rejection with a typed Construction AIR investigation and an exact+geometric witness. No BRep, STEP, or legacy fallback is emitted for this case.++The investigated source domain is a history-known axis-aligned box with:++```text+SharedEdge(+X,+Z), SharedEdge(+Y,+Z), equal constant radius R, convex +X/+Y/+Z corner+```++It validates `10 x 8 x 6, R=1`, `10 x 8 x 6, R=2`, and `12 x 5 x 7, R=1`+up to shared-patch admission. Zero, oversized, unequal, non-sharing, and+no-history inputs are rejected before topology emission.++## Exact candidate derivation++Let the box's positive corner be `(hx, hy, hz)`. The two single-edge cylinders+have common radius `R` and axes through++```text+C = (hx-R, hy-R, hz-R)+axis A = +Y for SharedEdge(+X,+Z)+axis B = +X for SharedEdge(+Y,+Z)+```++The only simple equal-radius spherical candidate tangent to both cylinders is+the sphere centered at `C` with radius `R`. Its two shared seams have zero+positional and tangent-plane deviation from the selected cylinders.++However, its remaining exact boundary is the quarter circle in `z = hz-R`+between `(hx, hy-R, hz-R)` and `(hx-R, hy, hz-R)`. This is precisely the seam+of the unselected radius-`R` cylinder about `+Z` — the fillet for+`SharedEdge(+X,+Y)`. The sphere meets each retained support plane only at its+one tangency point, so it has no non-degenerate trim curve on `+X`, `+Y`, or+`+Z` with which to close the two-edge shell.++Consequently a spherical/octant patch would covertly materialize a third fillet+and is rejected. A torus cannot supply the forced spherical tangent seams, and+no other exact supported surface family has been proven to meet the two+cylinders and retained planes with G0/G1 closure. M4 returns the typed+`CornerPatchSurfaceRequired` error with the sphere center, radius, zero cylinder+tangency deviation, missing third-boundary length `pi*R/2`, and required third+surface as evidence.++## Construction AIR and policy++The compiler constructs the two semantic `AirEdgeFinishFeature` fillet intents+and the immutable spherical candidate witness before rejecting it. It uses no+topology identifiers in Firmament and produces no BRepPlan because no+hard-valid plan exists. Candidate count is zero hard-valid plans; utility+scoring is deliberately dormant.++The existing two-edge chamfer remains the sole authoritative+`LocalizedEdgeJunction` BRepPlan route. It must not be repurposed for fillets.++## Continuity, preflight, STEP, and volume++The rejected sphere candidate has exact G0/G1 cylinder seams (`0` measured+deviation). The unowned third seam has length `pi*R/2`, so there is no closed,+manifold two-edge shell to preflight or export. Accordingly no STEP hash,+reimport, CAD Assistant session, or volume claim is produced for M4; exporting+an analytically invalid shell would be false evidence. Existing sphere and+cylinder containment checks in `BrepExportPreflight` already cover a future+valid analytic plan, but no patch-specific preflight is added until a closing+surface is proven.++## Deferred scope and next milestone++This result does not claim rolling-ball, chain, three-edge, mixed, variable-+radius, concave, curved-support, or imported-body fillets. The next bounded+milestone should either admit the three equal-radius edges at this corner (where+the derived spherical patch has all three cylindrical seams), or derive and+prove a separate exact two-cylinder-to-support corner surface before adding a+two-edge emission path.