Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Expose authored surface patches for geometry predicates
Yuechen Li1d3a4b5dec87
diff --git a/Aetheris.Forge.KernelSDK/Aetheris.Forge.KernelSDK.csproj b/Aetheris.Forge.KernelSDK/Aetheris.Forge.KernelSDK.csprojindex b0d22aa6..6bf81aad 100644--- a/Aetheris.Forge.KernelSDK/Aetheris.Forge.KernelSDK.csproj+++ b/Aetheris.Forge.KernelSDK/Aetheris.Forge.KernelSDK.csproj@@ -8,5 +8,6 @@<ItemGroup><ProjectReference Include="..\Aetheris.Forge\Aetheris.Forge.csproj" /><ProjectReference Include="..\Aetheris.Forge.Host\Aetheris.Forge.Host.csproj" />+ <ProjectReference Include="..\Aetheris.Geometry\Aetheris.Geometry.csproj" /></ItemGroup></Project>diff --git a/Aetheris.Forge.KernelSDK/KernelSdk.cs b/Aetheris.Forge.KernelSDK/KernelSdk.csindex a797e35b..448f3dff 100644--- a/Aetheris.Forge.KernelSDK/KernelSdk.cs+++ b/Aetheris.Forge.KernelSDK/KernelSdk.cs@@ -8,4 +8,11 @@ namespace Aetheris.Forge.KernelSDK;public static class KernelSdk{public const string MigrationFrom = "Aetheris.Forge.Sdk";++ /// <summary>Extension-author convenience over the public, independently owned geometry query.</summary>+ public static Aetheris.Geometry.SignedSideResult QuerySignedSide(+ Aetheris.Geometry.BoundedParametricPatch3 patch,+ Aetheris.Geometry.Plane3 plane,+ Aetheris.Geometry.SignedSidePolicy policy) =>+ Aetheris.Geometry.SignedSideQuery.Query(patch, plane, policy);}diff --git a/Aetheris.Geometry.Tests/Aetheris.Geometry.Tests.csproj b/Aetheris.Geometry.Tests/Aetheris.Geometry.Tests.csprojnew file mode 100644index 00000000..491d1579--- /dev/null+++ b/Aetheris.Geometry.Tests/Aetheris.Geometry.Tests.csproj@@ -0,0 +1,12 @@+<Project Sdk="Microsoft.NET.Sdk">+ <PropertyGroup><TargetFramework>net10.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable><IsPackable>false</IsPackable></PropertyGroup>+ <ItemGroup>+ <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />+ <PackageReference Include="xunit" Version="2.9.3" />+ <PackageReference Include="xunit.runner.visualstudio" Version="3.1.4"><PrivateAssets>all</PrivateAssets></PackageReference>+ </ItemGroup>+ <ItemGroup>+ <ProjectReference Include="..\Aetheris.Geometry\Aetheris.Geometry.csproj" />+ <ProjectReference Include="..\Aetheris.Surfacing\Aetheris.Surfacing.csproj" />+ </ItemGroup>+</Project>diff --git a/Aetheris.Geometry.Tests/SignedSideQueryTests.cs b/Aetheris.Geometry.Tests/SignedSideQueryTests.csnew file mode 100644index 00000000..0934036d--- /dev/null+++ b/Aetheris.Geometry.Tests/SignedSideQueryTests.cs@@ -0,0 +1,146 @@+using System.Text.Json;+using Aetheris.Geometry;+using Aetheris.Kernel.Core.Math;+using Aetheris.Surfacing;+using Xunit;++namespace Aetheris.Geometry.Tests;++public sealed class SignedSideQueryTests+{+ private static readonly Plane3 ToolingPlane = new(Point3D.Origin, Direction3D.Create(new Vector3D(0, 0, 1)));++ [Fact]+ public void DomainFirstJetNormalIdentityAndProvenanceArePublic()+ {+ var invalid = Assert.Throws<GeometryDefinitionException>(() => new ParameterInterval2(1, 1));+ Assert.Equal(GeometryQueryDiagnosticCode.InvalidParameterDomain, invalid.Code);+ var patch = Graph("jet", SurfaceExpression.Add(SurfaceExpression.Length(3), SurfaceExpression.Multiply(SurfaceExpression.Length(2), SurfaceExpression.U)));+ var jet = patch.Evaluate(.25, -.5);+ Assert.Equal(new Point3D(.25, -.5, 3.5), jet.Point);+ Assert.Equal(new Vector3D(1, 0, 2), jet.Du);+ Assert.Equal(new Vector3D(0, 1, 0), jet.Dv);+ Assert.False(jet.IsSingular); Assert.NotNull(jet.Normal);+ Assert.Equal("jet", patch.StableId); Assert.Equal("fixture:jet", patch.Provenance);+ Assert.Equal(GeometryRepresentationKind.AnalyticExpression, patch.Representation);+ }++ [Fact]+ public void InvalidPlaneIsATypedUnknownResult()+ {+ var result = SignedSideQuery.Query(Graph("invalid-plane", SurfaceExpression.Length(1)), default, SignedSidePolicy.Sampled());+ Assert.Equal(SignedSideClassification.Unknown, result.Classification);+ Assert.Equal(PredicateEvidenceKind.Unknown, result.EvidenceKind);+ Assert.Contains(result.Diagnostics, diagnostic => diagnostic.Code == GeometryQueryDiagnosticCode.InvalidPlane);+ }++ [Fact]+ public void SampledPolicyClassifiesStrictSidesAndCrossingButNeverCertifies()+ {+ var positive = SignedSideQuery.Query(Graph("positive", SurfaceExpression.Length(2)), ToolingPlane, SignedSidePolicy.Sampled(samplesU: 5, samplesV: 7));+ var negative = SignedSideQuery.Query(Graph("negative", SurfaceExpression.Length(-2)), ToolingPlane, SignedSidePolicy.Sampled());+ var crossing = SignedSideQuery.Query(Graph("crossing", SurfaceExpression.Multiply(SurfaceExpression.Length(2), SurfaceExpression.U)), ToolingPlane, SignedSidePolicy.Sampled());+ Assert.Equal(SignedSideClassification.Positive, positive.Classification);+ Assert.Equal(SignedSideClassification.Negative, negative.Classification);+ Assert.Equal(SignedSideClassification.Crossing, crossing.Classification);+ Assert.All(new[] { positive, negative, crossing }, result => Assert.Equal(PredicateEvidenceKind.Sampled, result.EvidenceKind));+ Assert.Equal(35, positive.Statistics.SampleCount); Assert.Equal(-2, crossing.ObservedMinimum); Assert.Equal(2, crossing.ObservedMaximum);+ }++ [Fact]+ public void NearContactSamplingIsUnknownWithContactCandidate()+ {+ var tangent = Graph("tangent", SurfaceExpression.Multiply(SurfaceExpression.Length(2), SurfaceExpression.Power(SurfaceExpression.U, 2)));+ var result = SignedSideQuery.Query(tangent, ToolingPlane, SignedSidePolicy.Sampled(1e-12, 9, 9));+ Assert.Equal(SignedSideClassification.Unknown, result.Classification);+ Assert.Equal(PredicateEvidenceKind.Sampled, result.EvidenceKind);+ Assert.Contains(result.Witnesses, witness => witness.Kind == "contact-candidate");+ }++ [Fact]+ public void IntervalPolicyCertifiesPositiveNegativeAndCrossing()+ {+ var squared = SurfaceExpression.Multiply(SurfaceExpression.Length(1), SurfaceExpression.Power(SurfaceExpression.U, 2));+ var positive = SignedSideQuery.Query(Graph("safe", SurfaceExpression.Add(SurfaceExpression.Length(1), squared)), ToolingPlane, SignedSidePolicy.Certified());+ var negative = SignedSideQuery.Query(Graph("below", SurfaceExpression.Subtract(SurfaceExpression.Length(-1), squared)), ToolingPlane, SignedSidePolicy.Certified());+ var crossing = SignedSideQuery.Query(Graph("failing", SurfaceExpression.Multiply(SurfaceExpression.Length(2), SurfaceExpression.U)), ToolingPlane, SignedSidePolicy.Certified(maximumSubdivisionDepth: 4));+ Assert.Equal((SignedSideClassification.Positive, PredicateEvidenceKind.Certified), (positive.Classification, positive.EvidenceKind));+ Assert.Equal((SignedSideClassification.Negative, PredicateEvidenceKind.Certified), (negative.Classification, negative.EvidenceKind));+ Assert.Equal((SignedSideClassification.Crossing, PredicateEvidenceKind.Certified), (crossing.Classification, crossing.EvidenceKind));+ Assert.True(crossing.Statistics.ResolvedLeaves > 0);+ }++ [Fact]+ public void TangencyAndBudgetExhaustionRemainUnknown()+ {+ var tangent = Graph("tangent", SurfaceExpression.Multiply(SurfaceExpression.Length(2), SurfaceExpression.Power(SurfaceExpression.U, 2)));+ var result = SignedSideQuery.Query(tangent, ToolingPlane, SignedSidePolicy.Certified(maximumSubdivisionDepth: 2, maximumLeafCount: 16));+ Assert.Equal(SignedSideClassification.Unknown, result.Classification);+ Assert.Equal(PredicateEvidenceKind.Unknown, result.EvidenceKind);+ Assert.Contains(result.Diagnostics, diagnostic => diagnostic.Code == GeometryQueryDiagnosticCode.SubdivisionBudgetExhausted);+ }++ [Fact]+ public void SinCosAndDivisionUseSoundBoundedEvaluation()+ {+ var trig = SurfaceExpression.Add(SurfaceExpression.Length(3), SurfaceExpression.Multiply(SurfaceExpression.Length(1),+ SurfaceExpression.Add(SurfaceExpression.Sin(SurfaceExpression.U), SurfaceExpression.Cos(SurfaceExpression.V))));+ var result = SignedSideQuery.Query(Graph("trig", trig), ToolingPlane, SignedSidePolicy.Certified());+ Assert.Equal(SignedSideClassification.Positive, result.Classification);+ Assert.Equal(PredicateEvidenceKind.Certified, result.EvidenceKind);++ var singularDivision = SurfaceExpression.Divide(SurfaceExpression.Length(1), SurfaceExpression.U);+ var unsupported = SignedSideQuery.Query(Graph("division", singularDivision), ToolingPlane, SignedSidePolicy.Certified());+ Assert.Equal(SignedSideClassification.Unknown, unsupported.Classification);+ Assert.Contains(unsupported.Diagnostics, item => item.Code == GeometryQueryDiagnosticCode.UnsupportedCertifiedExpression);+ }++ [Fact]+ public void ProceduralPatchCertificationDoesNotSilentlySample()+ {+ var domain = new ParametricDomain(new(-1, 1), new(-1, 1));+ var patch = BoundedParametricPatch3.Procedural("procedural", domain, (u, v) =>+ new(new(u, v, 2), new(1, 0, 0), new(0, 1, 0), Direction3D.Create(new Vector3D(0, 0, 1)), false), "fixture");+ var result = SignedSideQuery.Query(patch, ToolingPlane, SignedSidePolicy.Certified());+ Assert.Equal(SignedSideClassification.Unknown, result.Classification);+ Assert.Equal(PredicateEvidenceKind.Unknown, result.EvidenceKind);+ Assert.Equal(0, result.Statistics.SampleCount);+ }++ [Fact]+ public void PanelAdapterUsesAuthoredPatchForOrdinaryToolingClearance()+ {+ var surface = new ParametricSurfaceIr("tool-clearance", SurfaceConstructionKind.ParametricSurface,+ new(new(-1, 1), new(-1, 1)), GraphExpression(SurfaceExpression.Length(5)), "cad:tooling-clearance-panel");+ var panel = PanelFactory.FromParametric(surface).Panel!;+ Assert.Same(surface.Patch, panel.AuthoredPatch);+ var result = SignedSideQuery.Query(panel.AuthoredPatch, ToolingPlane, SignedSidePolicy.Certified());+ Assert.Equal((SignedSideClassification.Positive, PredicateEvidenceKind.Certified), (result.Classification, result.EvidenceKind));+ Assert.Equal("cad:tooling-clearance-panel", result.Provenance);+ }++ [Fact]+ public void IdenticalQueriesSerializeDeterministically()+ {+ var patch = Graph("determinism", SurfaceExpression.Add(SurfaceExpression.Length(1), SurfaceExpression.Multiply(SurfaceExpression.Length(1), SurfaceExpression.U)));+ var policy = SignedSidePolicy.Sampled(1e-9, 7, 7);+ var first = JsonSerializer.Serialize(SignedSideQuery.Query(patch, ToolingPlane, policy));+ var second = JsonSerializer.Serialize(SignedSideQuery.Query(patch, ToolingPlane, policy));+ Assert.Equal(first, second);+ }++ [Fact]+ public void SignedSideExpectationIsAnEvidenceObligationNotMaterialization()+ {+ var result = SignedSideQuery.Query(Graph("obligation", SurfaceExpression.Length(2)), ToolingPlane, SignedSidePolicy.Sampled());+ Assert.True(new SignedSideExpectation(SignedSideClassification.Positive, PredicateEvidenceKind.Sampled).Evaluate(result).Satisfied);+ var rejected = new SignedSideExpectation(SignedSideClassification.Positive, PredicateEvidenceKind.Certified).Evaluate(result);+ Assert.False(rejected.Satisfied); Assert.Contains("Certified", rejected.RejectionReason);+ }++ private static BoundedParametricPatch3 Graph(string id, SurfaceScalarExpression z) =>+ new(id, new(new(-1, 1), new(-1, 1)), GraphExpression(z), "fixture:" + id);+ private static SurfacePointExpression GraphExpression(SurfaceScalarExpression z) =>+ new(SurfaceExpression.Multiply(SurfaceExpression.Length(1), SurfaceExpression.U),+ SurfaceExpression.Multiply(SurfaceExpression.Length(1), SurfaceExpression.V), z);+}diff --git a/Aetheris.Geometry/Aetheris.Geometry.csproj b/Aetheris.Geometry/Aetheris.Geometry.csprojnew file mode 100644index 00000000..6c98f329--- /dev/null+++ b/Aetheris.Geometry/Aetheris.Geometry.csproj@@ -0,0 +1,11 @@+<Project Sdk="Microsoft.NET.Sdk">+ <PropertyGroup>+ <TargetFramework>net10.0</TargetFramework>+ <ImplicitUsings>enable</ImplicitUsings>+ <Nullable>enable</Nullable>+ <Description>Public authored parametric geometry and evidence-aware geometric predicates for Aetheris.</Description>+ </PropertyGroup>+ <ItemGroup>+ <ProjectReference Include="..\Aetheris.Kernel.Core\Aetheris.Kernel.Core.csproj" />+ </ItemGroup>+</Project>diff --git a/Aetheris.Geometry/ParametricGeometry.cs b/Aetheris.Geometry/ParametricGeometry.csnew file mode 100644index 00000000..2fa920dd--- /dev/null+++ b/Aetheris.Geometry/ParametricGeometry.cs@@ -0,0 +1,153 @@+using Aetheris.Kernel.Core.Math;++namespace Aetheris.Geometry;++public readonly record struct ParameterInterval2+{+ public ParameterInterval2(double minimum, double maximum)+ {+ if (!double.IsFinite(minimum) || !double.IsFinite(maximum) || maximum <= minimum)+ throw new GeometryDefinitionException(GeometryQueryDiagnosticCode.InvalidParameterDomain, "A parameter interval must be finite and increasing.");+ Minimum = minimum;+ Maximum = maximum;+ }++ public double Minimum { get; }+ public double Maximum { get; }+ public double Map(double normalized) => Minimum + double.Clamp(normalized, 0d, 1d) * (Maximum - Minimum);+}++public sealed class GeometryDefinitionException : ArgumentException+{+ public GeometryDefinitionException(GeometryQueryDiagnosticCode code, string message) : base(message) => Code = code;+ public GeometryQueryDiagnosticCode Code { get; }+}++public sealed record ParametricDomain(ParameterInterval2 U, ParameterInterval2 V);++public enum GeometryRepresentationKind+{+ AnalyticExpression,+ ProceduralParametric,+ CertifiedApproximation,+ SampledApproximation,+ MaterializedBRep,+ ImportedGeometry+}++public readonly record struct UnitDimension(int LengthPower)+{+ public static UnitDimension Dimensionless => new(0);+ public static UnitDimension Length => new(1);+ public static UnitDimension operator *(UnitDimension a, UnitDimension b) => new(a.LengthPower + b.LengthPower);+ public static UnitDimension operator /(UnitDimension a, UnitDimension b) => new(a.LengthPower - b.LengthPower);+}++public readonly record struct ScalarJet(double Value, double Du, double Dv);++/// <summary>A deliberately small, unit-aware expression tree with forward automatic differentiation.</summary>+public abstract record SurfaceScalarExpression(UnitDimension Unit)+{+ public abstract ScalarJet Evaluate(double u, double v);++ public sealed record Constant(double ConstantValue, UnitDimension ConstantUnit) : SurfaceScalarExpression(ConstantUnit)+ { public override ScalarJet Evaluate(double u, double v) => new(ConstantValue, 0d, 0d); }+ public sealed record Parameter(bool IsU) : SurfaceScalarExpression(UnitDimension.Dimensionless)+ { public override ScalarJet Evaluate(double u, double v) => IsU ? new(u, 1d, 0d) : new(v, 0d, 1d); }+ public sealed record Sum(SurfaceScalarExpression Left, SurfaceScalarExpression Right) : SurfaceScalarExpression(RequireSame(Left, Right))+ { public override ScalarJet Evaluate(double u, double v) { var a = Left.Evaluate(u, v); var b = Right.Evaluate(u, v); return new(a.Value + b.Value, a.Du + b.Du, a.Dv + b.Dv); } }+ public sealed record Difference(SurfaceScalarExpression Left, SurfaceScalarExpression Right) : SurfaceScalarExpression(RequireSame(Left, Right))+ { public override ScalarJet Evaluate(double u, double v) { var a = Left.Evaluate(u, v); var b = Right.Evaluate(u, v); return new(a.Value - b.Value, a.Du - b.Du, a.Dv - b.Dv); } }+ public sealed record Product(SurfaceScalarExpression Left, SurfaceScalarExpression Right) : SurfaceScalarExpression(Left.Unit * Right.Unit)+ { public override ScalarJet Evaluate(double u, double v) { var a = Left.Evaluate(u, v); var b = Right.Evaluate(u, v); return new(a.Value * b.Value, a.Du * b.Value + a.Value * b.Du, a.Dv * b.Value + a.Value * b.Dv); } }+ public sealed record Quotient(SurfaceScalarExpression Left, SurfaceScalarExpression Right) : SurfaceScalarExpression(Left.Unit / Right.Unit)+ { public override ScalarJet Evaluate(double u, double v) { var a = Left.Evaluate(u, v); var b = Right.Evaluate(u, v); if (double.Abs(b.Value) <= 1e-15) throw new DivideByZeroException("Parametric expression divisor is zero."); var q = b.Value * b.Value; return new(a.Value / b.Value, (a.Du * b.Value - a.Value * b.Du) / q, (a.Dv * b.Value - a.Value * b.Dv) / q); } }+ public sealed record IntegerPower(SurfaceScalarExpression Operand, int Exponent) : SurfaceScalarExpression(new UnitDimension(Operand.Unit.LengthPower * Exponent))+ { public override ScalarJet Evaluate(double u, double v) { var a = Operand.Evaluate(u, v); var value = double.Pow(a.Value, Exponent); var scale = Exponent == 0 ? 0d : Exponent * double.Pow(a.Value, Exponent - 1); return new(value, scale * a.Du, scale * a.Dv); } }+ public sealed record Sine(SurfaceScalarExpression Operand) : SurfaceScalarExpression(RequireDimensionless(Operand))+ { public override ScalarJet Evaluate(double u, double v) { var a = Operand.Evaluate(u, v); var c = double.Cos(a.Value); return new(double.Sin(a.Value), c * a.Du, c * a.Dv); } }+ public sealed record Cosine(SurfaceScalarExpression Operand) : SurfaceScalarExpression(RequireDimensionless(Operand))+ { public override ScalarJet Evaluate(double u, double v) { var a = Operand.Evaluate(u, v); var s = -double.Sin(a.Value); return new(double.Cos(a.Value), s * a.Du, s * a.Dv); } }++ private static UnitDimension RequireSame(SurfaceScalarExpression a, SurfaceScalarExpression b) =>+ a.Unit == b.Unit ? a.Unit : throw new ArgumentException($"Cannot add/subtract dimensions L^{a.Unit.LengthPower} and L^{b.Unit.LengthPower}.");+ private static UnitDimension RequireDimensionless(SurfaceScalarExpression expression) =>+ expression.Unit == UnitDimension.Dimensionless ? UnitDimension.Dimensionless : throw new ArgumentException("Trigonometric operands must be dimensionless.");+}++public static class SurfaceExpression+{+ public static SurfaceScalarExpression U { get; } = new SurfaceScalarExpression.Parameter(true);+ public static SurfaceScalarExpression V { get; } = new SurfaceScalarExpression.Parameter(false);+ public static SurfaceScalarExpression Number(double value) => new SurfaceScalarExpression.Constant(value, UnitDimension.Dimensionless);+ public static SurfaceScalarExpression Length(double millimetres) => new SurfaceScalarExpression.Constant(millimetres, UnitDimension.Length);+ public static SurfaceScalarExpression Add(SurfaceScalarExpression a, SurfaceScalarExpression b) => new SurfaceScalarExpression.Sum(a, b);+ public static SurfaceScalarExpression Subtract(SurfaceScalarExpression a, SurfaceScalarExpression b) => new SurfaceScalarExpression.Difference(a, b);+ public static SurfaceScalarExpression Multiply(SurfaceScalarExpression a, SurfaceScalarExpression b) => new SurfaceScalarExpression.Product(a, b);+ public static SurfaceScalarExpression Divide(SurfaceScalarExpression a, SurfaceScalarExpression b) => new SurfaceScalarExpression.Quotient(a, b);+ public static SurfaceScalarExpression Power(SurfaceScalarExpression a, int exponent) => new SurfaceScalarExpression.IntegerPower(a, exponent);+ public static SurfaceScalarExpression Sin(SurfaceScalarExpression a) => new SurfaceScalarExpression.Sine(a);+ public static SurfaceScalarExpression Cos(SurfaceScalarExpression a) => new SurfaceScalarExpression.Cosine(a);+}++public sealed record SurfacePointExpression(SurfaceScalarExpression X, SurfaceScalarExpression Y, SurfaceScalarExpression Z)+{+ public void ValidateLengthOutput()+ {+ if (X.Unit != UnitDimension.Length || Y.Unit != UnitDimension.Length || Z.Unit != UnitDimension.Length)+ throw new ArgumentException("Parametric surface point components must all have Length dimension.");+ }+}++public sealed record SurfaceDifferential(Point3D Point, Vector3D Du, Vector3D Dv, Direction3D? Normal, bool IsSingular);++/// <summary>Authored rectangular parametric geometry, independent of CAD realization and topology.</summary>+public sealed class BoundedParametricPatch3+{+ private readonly Func<double, double, SurfaceDifferential>? _proceduralEvaluator;++ public BoundedParametricPatch3(string stableId, ParametricDomain domain, SurfacePointExpression pointExpression,+ string provenance, GeometryRepresentationKind representation = GeometryRepresentationKind.AnalyticExpression)+ {+ ArgumentException.ThrowIfNullOrWhiteSpace(stableId);+ ArgumentException.ThrowIfNullOrWhiteSpace(provenance);+ ArgumentNullException.ThrowIfNull(domain);+ ArgumentNullException.ThrowIfNull(pointExpression);+ pointExpression.ValidateLengthOutput();+ StableId = stableId; Domain = domain; PointExpression = pointExpression; Provenance = provenance; Representation = representation;+ }++ private BoundedParametricPatch3(string stableId, ParametricDomain domain, Func<double, double, SurfaceDifferential> evaluator,+ string provenance, GeometryRepresentationKind representation)+ {+ ArgumentException.ThrowIfNullOrWhiteSpace(stableId);+ ArgumentException.ThrowIfNullOrWhiteSpace(provenance);+ StableId = stableId; Domain = domain; Provenance = provenance; Representation = representation; _proceduralEvaluator = evaluator;+ }++ public string StableId { get; }+ public ParametricDomain Domain { get; }+ public SurfacePointExpression? PointExpression { get; }+ public string Provenance { get; }+ public GeometryRepresentationKind Representation { get; }+ public bool HasExpressionTree => PointExpression is not null;++ public static BoundedParametricPatch3 Procedural(string stableId, ParametricDomain domain,+ Func<double, double, SurfaceDifferential> evaluator, string provenance) =>+ new(stableId, domain, evaluator ?? throw new ArgumentNullException(nameof(evaluator)), provenance, GeometryRepresentationKind.ProceduralParametric);++ public SurfaceDifferential Evaluate(double u, double v)+ {+ if (!double.IsFinite(u) || !double.IsFinite(v)) throw new ArgumentOutOfRangeException(nameof(u), "Parameters must be finite.");+ if (u < Domain.U.Minimum || u > Domain.U.Maximum || v < Domain.V.Minimum || v > Domain.V.Maximum)+ throw new ArgumentOutOfRangeException(nameof(u), "Parameters must lie inside the authored rectangular domain.");+ if (_proceduralEvaluator is not null) return _proceduralEvaluator(u, v);+ var expression = PointExpression!;+ var x = expression.X.Evaluate(u, v); var y = expression.Y.Evaluate(u, v); var z = expression.Z.Evaluate(u, v);+ if (!new[] { x.Value, x.Du, x.Dv, y.Value, y.Du, y.Dv, z.Value, z.Du, z.Dv }.All(double.IsFinite))+ throw new ArithmeticException("Parametric patch evaluation produced a non-finite value.");+ var du = new Vector3D(x.Du, y.Du, z.Du); var dv = new Vector3D(x.Dv, y.Dv, z.Dv); var cross = du.Cross(dv);+ var singular = !cross.TryNormalize(out var normalized);+ return new(new(x.Value, y.Value, z.Value), du, dv, singular ? null : Direction3D.Create(normalized), singular);+ }+}diff --git a/Aetheris.Geometry/SignedSideQuery.cs b/Aetheris.Geometry/SignedSideQuery.csnew file mode 100644index 00000000..2f4344d8--- /dev/null+++ b/Aetheris.Geometry/SignedSideQuery.cs@@ -0,0 +1,279 @@+using Aetheris.Kernel.Core.Math;++namespace Aetheris.Geometry;++public readonly record struct Plane3(Point3D Origin, Direction3D Normal)+{+ public double SignedDistance(Point3D point) => Normal.ToVector().Dot(point - Origin);+}++public enum SignedSideClassification { Positive, Negative, Touching, Crossing, Unknown }+public enum PredicateEvidenceKind { Structural, Certified, ToleranceBounded, Sampled, Heuristic, Unknown }+public enum SignedSideQueryMethod { Sampled, CertifiedInterval }+public enum GeometryQueryDiagnosticCode+{+ InvalidParameterDomain,+ SingularPatchEvaluation,+ InvalidPlane,+ UnsupportedCertifiedExpression,+ SubdivisionBudgetExhausted,+ NonFiniteEvaluation,+ EvidenceUnavailable+}++public sealed record GeometryQueryDiagnostic(GeometryQueryDiagnosticCode Code, string Message);+public sealed record SignedSideWitness(double U, double V, Point3D Point, double SignedDistance, string Kind);+public sealed record SignedSidePolicy+{+ public SignedSidePolicy(SignedSideQueryMethod method, double tolerance = 1e-9, int samplesU = 9, int samplesV = 9,+ int maximumSubdivisionDepth = 10, int maximumLeafCount = 4096)+ {+ if (!double.IsFinite(tolerance) || tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance));+ if (samplesU < 2 || samplesV < 2) throw new ArgumentOutOfRangeException(nameof(samplesU));+ if (maximumSubdivisionDepth < 0 || maximumLeafCount < 1) throw new ArgumentOutOfRangeException(nameof(maximumSubdivisionDepth));+ Method = method; Tolerance = tolerance; SamplesU = samplesU; SamplesV = samplesV;+ MaximumSubdivisionDepth = maximumSubdivisionDepth; MaximumLeafCount = maximumLeafCount;+ }++ public SignedSideQueryMethod Method { get; }+ public double Tolerance { get; }+ public int SamplesU { get; }+ public int SamplesV { get; }+ public int MaximumSubdivisionDepth { get; }+ public int MaximumLeafCount { get; }+ public static SignedSidePolicy Sampled(double tolerance = 1e-9, int samplesU = 9, int samplesV = 9) => new(SignedSideQueryMethod.Sampled, tolerance, samplesU, samplesV);+ public static SignedSidePolicy Certified(double tolerance = 1e-9, int maximumSubdivisionDepth = 10, int maximumLeafCount = 4096) => new(SignedSideQueryMethod.CertifiedInterval, tolerance, maximumSubdivisionDepth: maximumSubdivisionDepth, maximumLeafCount: maximumLeafCount);+}++public sealed record SignedSideStatistics(int SampleCount, int LeafCount, int ResolvedLeaves, int UnresolvedLeaves, int MaximumDepthReached);+public sealed record SignedSideResult(+ SignedSideClassification Classification,+ PredicateEvidenceKind EvidenceKind,+ SignedSidePolicy Policy,+ ParametricDomain Domain,+ string PatchIdentity,+ string Provenance,+ GeometryRepresentationKind Representation,+ double? ObservedMinimum,+ double? ObservedMaximum,+ double? CertifiedLowerBound,+ double? CertifiedUpperBound,+ IReadOnlyList<SignedSideWitness> Witnesses,+ SignedSideStatistics Statistics,+ IReadOnlyList<GeometryQueryDiagnostic> Diagnostics);++/// <summary>A compile-time geometric obligation. It validates evidence and never requests topology construction.</summary>+public sealed record SignedSideExpectation(+ SignedSideClassification ExpectedClassification,+ PredicateEvidenceKind MinimumEvidence = PredicateEvidenceKind.Sampled)+{+ public SignedSideExpectationResult Evaluate(SignedSideResult result)+ {+ ArgumentNullException.ThrowIfNull(result);+ var classificationSatisfied = result.Classification == ExpectedClassification;+ var evidenceSatisfied = EvidenceRank(result.EvidenceKind) >= EvidenceRank(MinimumEvidence);+ return new(this, result, classificationSatisfied && evidenceSatisfied,+ classificationSatisfied ? (evidenceSatisfied ? null : $"Expected at least {MinimumEvidence} evidence; observed {result.EvidenceKind}.")+ : $"Expected {ExpectedClassification}; observed {result.Classification}.");+ }++ private static int EvidenceRank(PredicateEvidenceKind kind) => kind switch+ {+ PredicateEvidenceKind.Structural => 5,+ PredicateEvidenceKind.Certified => 4,+ PredicateEvidenceKind.ToleranceBounded => 3,+ PredicateEvidenceKind.Sampled => 2,+ PredicateEvidenceKind.Heuristic => 1,+ _ => 0+ };+}++public sealed record SignedSideExpectationResult(+ SignedSideExpectation Expectation,+ SignedSideResult QueryResult,+ bool Satisfied,+ string? RejectionReason);++public static class SignedSideQuery+{+ public static SignedSideResult Query(BoundedParametricPatch3 patch, Plane3 plane, SignedSidePolicy policy)+ {+ ArgumentNullException.ThrowIfNull(patch); ArgumentNullException.ThrowIfNull(policy);+ var normal = plane.Normal.ToVector();+ if (!double.IsFinite(normal.X) || !double.IsFinite(normal.Y) || !double.IsFinite(normal.Z) || normal.LengthSquared < .5d)+ return Result(SignedSideClassification.Unknown, PredicateEvidenceKind.Unknown, patch, policy, null, null, null, null, [],+ new(0, 0, 0, 1, 0), [new(GeometryQueryDiagnosticCode.InvalidPlane, "Plane normal must be finite and non-zero.")]);+ return policy.Method == SignedSideQueryMethod.Sampled ? Sample(patch, plane, policy) : Certify(patch, plane, policy);+ }++ private static SignedSideResult Sample(BoundedParametricPatch3 patch, Plane3 plane, SignedSidePolicy policy)+ {+ var witnesses = new List<SignedSideWitness>(); var diagnostics = new List<GeometryQueryDiagnostic>();+ var minimum = double.PositiveInfinity; var maximum = double.NegativeInfinity;+ SignedSideWitness? positive = null, negative = null, contact = null;+ for (var i = 0; i < policy.SamplesU; i++)+ for (var j = 0; j < policy.SamplesV; j++)+ {+ var u = patch.Domain.U.Map(i / (double)(policy.SamplesU - 1)); var v = patch.Domain.V.Map(j / (double)(policy.SamplesV - 1));+ try+ {+ var evaluated = patch.Evaluate(u, v); var distance = plane.SignedDistance(evaluated.Point);+ if (!double.IsFinite(distance)) { diagnostics.Add(new(GeometryQueryDiagnosticCode.NonFiniteEvaluation, $"Non-finite signed distance at ({u:R}, {v:R}).")); continue; }+ minimum = double.Min(minimum, distance); maximum = double.Max(maximum, distance);+ var witness = new SignedSideWitness(u, v, evaluated.Point, distance,+ distance > policy.Tolerance ? "positive" : distance < -policy.Tolerance ? "negative" : "contact-candidate");+ if (distance > policy.Tolerance && (positive is null || distance > positive.SignedDistance)) positive = witness;+ else if (distance < -policy.Tolerance && (negative is null || distance < negative.SignedDistance)) negative = witness;+ else if (double.Abs(distance) <= policy.Tolerance && (contact is null || double.Abs(distance) < double.Abs(contact.SignedDistance))) contact = witness;+ if (evaluated.IsSingular) diagnostics.Add(new(GeometryQueryDiagnosticCode.SingularPatchEvaluation, $"Singular first jet observed at ({u:R}, {v:R})."));+ }+ catch (ArithmeticException ex) { diagnostics.Add(new(GeometryQueryDiagnosticCode.NonFiniteEvaluation, ex.Message)); }+ }+ if (negative is not null) witnesses.Add(negative); if (contact is not null) witnesses.Add(contact); if (positive is not null) witnesses.Add(positive);+ var classification = positive is not null && negative is not null ? SignedSideClassification.Crossing+ : positive is not null && contact is null ? SignedSideClassification.Positive+ : negative is not null && contact is null ? SignedSideClassification.Negative+ : SignedSideClassification.Unknown;+ if (!double.IsFinite(minimum)) { minimum = double.NaN; maximum = double.NaN; diagnostics.Add(new(GeometryQueryDiagnosticCode.EvidenceUnavailable, "No finite samples were available.")); classification = SignedSideClassification.Unknown; }+ return Result(classification, PredicateEvidenceKind.Sampled, patch, policy,+ double.IsFinite(minimum) ? minimum : null, double.IsFinite(maximum) ? maximum : null, null, null, witnesses,+ new(policy.SamplesU * policy.SamplesV, 0, 0, 0, 0), diagnostics);+ }++ private static SignedSideResult Certify(BoundedParametricPatch3 patch, Plane3 plane, SignedSidePolicy policy)+ {+ if (patch.PointExpression is null)+ return Result(SignedSideClassification.Unknown, PredicateEvidenceKind.Unknown, patch, policy, null, null, null, null, [], new(0, 0, 0, 1, 0),+ [new(GeometryQueryDiagnosticCode.UnsupportedCertifiedExpression, "Certified interval evaluation requires an authored expression tree; no sampled fallback was performed.")]);+ var n = plane.Normal.ToVector(); var p = patch.PointExpression;+ var scalar = SurfaceExpression.Subtract(+ SurfaceExpression.Add(SurfaceExpression.Add(Scale(p.X, n.X), Scale(p.Y, n.Y)), Scale(p.Z, n.Z)),+ SurfaceExpression.Length(n.Dot(plane.Origin - Point3D.Origin)));+ var queue = new Queue<Cell>(); queue.Enqueue(new(patch.Domain, 0));+ var resolved = 0; var unresolved = 0; var leaves = 0; var maxDepth = 0; var globalLower = double.PositiveInfinity; var globalUpper = double.NegativeInfinity;+ var hasPositive = false; var hasNegative = false; var budgetExhausted = false; var unsupported = false;+ SignedSideWitness? positiveWitness = null, negativeWitness = null;+ while (queue.Count > 0)+ {+ var cell = queue.Dequeue(); maxDepth = int.Max(maxDepth, cell.Depth);+ if (!IntervalEvaluator.TryEvaluate(scalar, cell.Domain, out var range)) { unsupported = true; unresolved++; break; }+ globalLower = double.Min(globalLower, range.Lower); globalUpper = double.Max(globalUpper, range.Upper);+ if (range.Lower > policy.Tolerance)+ {+ hasPositive = true; resolved++; leaves++;+ positiveWitness ??= CertifiedWitness(patch, plane, cell.Domain, "certified-positive-region");+ if (hasNegative) break;+ continue;+ }+ if (range.Upper < -policy.Tolerance)+ {+ hasNegative = true; resolved++; leaves++;+ negativeWitness ??= CertifiedWitness(patch, plane, cell.Domain, "certified-negative-region");+ if (hasPositive) break;+ continue;+ }+ if (cell.Depth >= policy.MaximumSubdivisionDepth || leaves + queue.Count + 4 > policy.MaximumLeafCount)+ { unresolved++; leaves++; budgetExhausted = true; continue; }+ foreach (var child in Subdivide(cell)) queue.Enqueue(child);+ }+ var classification = hasPositive && hasNegative ? SignedSideClassification.Crossing+ : unresolved == 0 && hasPositive ? SignedSideClassification.Positive+ : unresolved == 0 && hasNegative ? SignedSideClassification.Negative+ : SignedSideClassification.Unknown;+ var diagnostics = new List<GeometryQueryDiagnostic>();+ if (unsupported) diagnostics.Add(new(GeometryQueryDiagnosticCode.UnsupportedCertifiedExpression, "The authored scalar expression is outside the bounded interval evaluator or has an undefined interval operation."));+ if (budgetExhausted && classification == SignedSideClassification.Unknown) diagnostics.Add(new(GeometryQueryDiagnosticCode.SubdivisionBudgetExhausted, $"Certification remained inconclusive at depth {maxDepth} with leaf budget {policy.MaximumLeafCount}."));+ var evidence = classification == SignedSideClassification.Unknown ? PredicateEvidenceKind.Unknown : PredicateEvidenceKind.Certified;+ var witnesses = new List<SignedSideWitness>();+ if (negativeWitness is not null) witnesses.Add(negativeWitness);+ if (positiveWitness is not null) witnesses.Add(positiveWitness);+ return Result(classification, evidence, patch, policy, null, null,+ double.IsFinite(globalLower) ? globalLower : null, double.IsFinite(globalUpper) ? globalUpper : null, witnesses,+ new(0, leaves, resolved, unresolved, maxDepth), diagnostics);+ }++ private static SurfaceScalarExpression Scale(SurfaceScalarExpression value, double factor) =>+ SurfaceExpression.Multiply(value, SurfaceExpression.Number(factor));++ private static SignedSideWitness CertifiedWitness(BoundedParametricPatch3 patch, Plane3 plane, ParametricDomain domain, string kind)+ {+ var u = (domain.U.Minimum + domain.U.Maximum) / 2d; var v = (domain.V.Minimum + domain.V.Maximum) / 2d;+ var point = patch.Evaluate(u, v);+ return new(u, v, point.Point, plane.SignedDistance(point.Point), kind);+ }++ private static IEnumerable<Cell> Subdivide(Cell parent)+ {+ var u0 = parent.Domain.U.Minimum; var u1 = parent.Domain.U.Maximum; var um = (u0 + u1) / 2d;+ var v0 = parent.Domain.V.Minimum; var v1 = parent.Domain.V.Maximum; var vm = (v0 + v1) / 2d; var depth = parent.Depth + 1;+ yield return new(new(new(u0, um), new(v0, vm)), depth);+ yield return new(new(new(um, u1), new(v0, vm)), depth);+ yield return new(new(new(u0, um), new(vm, v1)), depth);+ yield return new(new(new(um, u1), new(vm, v1)), depth);+ }++ private static SignedSideResult Result(SignedSideClassification classification, PredicateEvidenceKind evidence, BoundedParametricPatch3 patch,+ SignedSidePolicy policy, double? observedMin, double? observedMax, double? certifiedMin, double? certifiedMax,+ IReadOnlyList<SignedSideWitness> witnesses, SignedSideStatistics statistics, IReadOnlyList<GeometryQueryDiagnostic> diagnostics) =>+ new(classification, evidence, policy, patch.Domain, patch.StableId, patch.Provenance, patch.Representation,+ observedMin, observedMax, certifiedMin, certifiedMax, witnesses, statistics, diagnostics);++ private sealed record Cell(ParametricDomain Domain, int Depth);+}++internal readonly record struct Interval(double Lower, double Upper)+{+ public static Interval Point(double value) => new(value, value);+ public static Interval Add(Interval a, Interval b) => Out(a.Lower + b.Lower, a.Upper + b.Upper);+ public static Interval Subtract(Interval a, Interval b) => Out(a.Lower - b.Upper, a.Upper - b.Lower);+ public static Interval Multiply(Interval a, Interval b)+ {+ var values = new[] { a.Lower * b.Lower, a.Lower * b.Upper, a.Upper * b.Lower, a.Upper * b.Upper };+ return Out(values.Min(), values.Max());+ }+ public static Interval Out(double lower, double upper) => new(double.BitDecrement(lower), double.BitIncrement(upper));+}++internal static class IntervalEvaluator+{+ public static bool TryEvaluate(SurfaceScalarExpression expression, ParametricDomain domain, out Interval result)+ {+ switch (expression)+ {+ case SurfaceScalarExpression.Constant c: result = Interval.Point(c.ConstantValue); return double.IsFinite(c.ConstantValue);+ case SurfaceScalarExpression.Parameter p: result = p.IsU ? new(domain.U.Minimum, domain.U.Maximum) : new(domain.V.Minimum, domain.V.Maximum); return true;+ case SurfaceScalarExpression.Sum s when TryEvaluate(s.Left, domain, out var sl) && TryEvaluate(s.Right, domain, out var sr): result = Interval.Add(sl, sr); return true;+ case SurfaceScalarExpression.Difference d when TryEvaluate(d.Left, domain, out var dl) && TryEvaluate(d.Right, domain, out var dr): result = Interval.Subtract(dl, dr); return true;+ case SurfaceScalarExpression.Product p when TryEvaluate(p.Left, domain, out var pl) && TryEvaluate(p.Right, domain, out var pr): result = Interval.Multiply(pl, pr); return Finite(result);+ case SurfaceScalarExpression.Quotient q when TryEvaluate(q.Left, domain, out var ql) && TryEvaluate(q.Right, domain, out var qr) && (qr.Lower > 0 || qr.Upper < 0):+ result = Interval.Multiply(ql, Interval.Out(1d / qr.Upper, 1d / qr.Lower)); return Finite(result);+ case SurfaceScalarExpression.IntegerPower p when TryEvaluate(p.Operand, domain, out var operand) && TryPower(operand, p.Exponent, out result): return true;+ case SurfaceScalarExpression.Sine s when TryEvaluate(s.Operand, domain, out var sinInput): result = Trig(sinInput, true); return true;+ case SurfaceScalarExpression.Cosine c when TryEvaluate(c.Operand, domain, out var cosInput): result = Trig(cosInput, false); return true;+ default: result = default; return false;+ }+ }++ private static bool TryPower(Interval value, int exponent, out Interval result)+ {+ if (exponent < 0 && value.Lower <= 0 && value.Upper >= 0) { result = default; return false; }+ if (exponent == 0) { result = Interval.Point(1); return true; }+ if (exponent < 0 && TryPower(value, -exponent, out var positive)) { result = Interval.Out(1d / positive.Upper, 1d / positive.Lower); return Finite(result); }+ var a = double.Pow(value.Lower, exponent); var b = double.Pow(value.Upper, exponent);+ var lower = double.Min(a, b); var upper = double.Max(a, b);+ if (exponent % 2 == 0 && value.Lower <= 0 && value.Upper >= 0) lower = 0;+ result = Interval.Out(lower, upper); return Finite(result);+ }++ private static Interval Trig(Interval value, bool sine)+ {+ if (value.Upper - value.Lower >= 2d * double.Pi) return new(-1, 1);+ var values = new List<double> { sine ? double.Sin(value.Lower) : double.Cos(value.Lower), sine ? double.Sin(value.Upper) : double.Cos(value.Upper) };+ var offset = sine ? double.Pi / 2d : 0d;+ var first = (int)double.Ceiling((value.Lower - offset) / double.Pi); var last = (int)double.Floor((value.Upper - offset) / double.Pi);+ for (var k = first; k <= last; k++) values.Add((k & 1) == 0 ? 1d : -1d);+ return Interval.Out(values.Min(), values.Max());+ }++ private static bool Finite(Interval value) => double.IsFinite(value.Lower) && double.IsFinite(value.Upper) && value.Lower <= value.Upper;+}diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentPanelOnlyBuildTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentPanelOnlyBuildTests.csnew file mode 100644index 00000000..47545d97--- /dev/null+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentPanelOnlyBuildTests.cs@@ -0,0 +1,22 @@+using Aetheris.Kernel.Core.Diagnostics;+using Xunit;++namespace Aetheris.Kernel.Firmament.Tests;++public sealed class FirmamentPanelOnlyBuildTests+{+ [Fact]+ public void PanelOnlyBuildReturnsTypedUnsupportedResultInsteadOfCrashing()+ {+ var result = FirmamentBuildAndExport.CompileSource("""+ Model PanelOnly {+ Units: mm;+ Panel P { Surface: HyperbolicParaboloid { Width: 40mm; Depth: 30mm; Rise: 6mm; } }+ }+ """);+ Assert.False(result.IsSuccess);+ var diagnostic = Assert.Single(result.Diagnostics);+ Assert.Equal(KernelDiagnosticCode.NotImplemented, diagnostic.Code);+ Assert.Contains("firmament-panel-only-step-materialization-unsupported", diagnostic.Message);+ }+}diff --git a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.csindex 503ed345..4eeba6fc 100644--- a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs+++ b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs@@ -196,6 +196,15 @@ public static class FirmamentBuildAndExport}if (v2Parse.IsSuccess && v2Parse.Document is not null){+ if (v2Parse.Document.Solids.Count == 0 && v2Parse.Document.Panels is { Count: > 0 })+ {+ return KernelResult<FirmamentStepExportResult>.Failure([new Kernel.Core.Diagnostics.KernelDiagnostic(+ Kernel.Core.Diagnostics.KernelDiagnosticCode.NotImplemented,+ Kernel.Core.Diagnostics.KernelDiagnosticSeverity.Error,+ "firmament-panel-only-step-materialization-unsupported: the document contains authored Panels but no solid body. Panel geometry remains available to public pre-realization predicates; the ordinary STEP build route does not yet define a shell/product export contract.",+ "FirmamentV2.Panel")]);+ }+var dfm = FirmamentV2DfmEnforcement.Validate(v2Parse.Document);if (!dfm.IsSuccess){diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentPanelCompiler.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentPanelCompiler.csindex de395926..de095df7 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentPanelCompiler.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentPanelCompiler.cs@@ -2,6 +2,7 @@ using System.Diagnostics;using System.Globalization;using System.Text.RegularExpressions;using Aetheris.Kernel.Core.Math;+using Aetheris.Geometry;using Aetheris.Surfacing;namespace Aetheris.Kernel.Firmament.FirmamentV2;diff --git a/Aetheris.Modules.Tests/Aetheris.Modules.Tests.csproj b/Aetheris.Modules.Tests/Aetheris.Modules.Tests.csprojindex d8a7c64d..e6c2c2a0 100644--- a/Aetheris.Modules.Tests/Aetheris.Modules.Tests.csproj+++ b/Aetheris.Modules.Tests/Aetheris.Modules.Tests.csproj@@ -3,6 +3,7 @@<ItemGroup><PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" /><PackageReference Include="xunit" Version="2.9.3" /><PackageReference Include="xunit.runner.visualstudio" Version="3.1.4"><PrivateAssets>all</PrivateAssets></PackageReference></ItemGroup><ItemGroup><ProjectReference Include="..\Aetheris.Modules.BuiltIn\Aetheris.Modules.BuiltIn.csproj" />+ <ProjectReference Include="..\Aetheris.Geometry\Aetheris.Geometry.csproj" /><ProjectReference Include="..\Aetheris.Forge.Host\Aetheris.Forge.Host.csproj" /></ItemGroup></Project>diff --git a/Aetheris.Modules.Tests/SurfacingM1Tests.cs b/Aetheris.Modules.Tests/SurfacingM1Tests.csindex e95b2418..d5d83bd9 100644--- a/Aetheris.Modules.Tests/SurfacingM1Tests.cs+++ b/Aetheris.Modules.Tests/SurfacingM1Tests.cs@@ -1,3 +1,4 @@+using Aetheris.Geometry;using Aetheris.Kernel.Core.Geometry.Curves;using Aetheris.Kernel.Core.Geometry.Surfaces;using Aetheris.Kernel.Core.Math;diff --git a/Aetheris.Surfacing/Aetheris.Surfacing.csproj b/Aetheris.Surfacing/Aetheris.Surfacing.csprojindex 6931e3bb..0539739a 100644--- a/Aetheris.Surfacing/Aetheris.Surfacing.csproj+++ b/Aetheris.Surfacing/Aetheris.Surfacing.csproj@@ -3,6 +3,7 @@<ItemGroup><ProjectReference Include="..\Aetheris.Modules\Aetheris.Modules.csproj" /><ProjectReference Include="..\Aetheris.Kernel.Core\Aetheris.Kernel.Core.csproj" />+ <ProjectReference Include="..\Aetheris.Geometry\Aetheris.Geometry.csproj" /><ProjectReference Include="..\Aetheris.Semantics\Aetheris.Semantics.csproj" /></ItemGroup></Project>diff --git a/Aetheris.Surfacing/Panels.cs b/Aetheris.Surfacing/Panels.csindex c9c2651c..6b434b58 100644--- a/Aetheris.Surfacing/Panels.cs+++ b/Aetheris.Surfacing/Panels.cs@@ -1,3 +1,4 @@+using Aetheris.Geometry;using Aetheris.Kernel.Core.Brep;using Aetheris.Kernel.Core.Geometry;using Aetheris.Kernel.Core.Geometry.Curves;@@ -27,6 +28,7 @@ public sealed record PanelConstruction(ParametricDomain ParameterDomain,SurfaceGeometry Support,Func<double, double, Point3D> Evaluate,+ BoundedParametricPatch3 AuthoredPatch,SurfaceMaterializationKind MaterializationKind,ApproximationCertificate? Approximation,DevelopabilityEvidence Developability,@@ -79,6 +81,7 @@ public sealed record PanelIr(string? Material,SemanticValue SemanticValue){+ public BoundedParametricPatch3 AuthoredPatch => SurfaceConstruction.AuthoredPatch;public ParametricDomain ParameterDomain => SurfaceConstruction.ParameterDomain;public DevelopabilityEvidence Developability => SurfaceConstruction.Developability;public ApproximationCertificate? ApproximationStatus => SurfaceConstruction.Approximation;@@ -141,6 +144,7 @@ public static class PanelFactoryvar construction = new PanelConstruction(source.StableId, source.ConstructionKind, source.Domain,SurfaceGeometry.FromBSplineSurfaceWithKnots(materialized.Surface),(u, v) => source.Evaluate(source.Domain.U.Map(u), source.Domain.V.Map(v)).Point,+ source.Patch,materialized.Kind, materialized.Certificate,new(DevelopabilityKind.Indeterminate, "parametric curvature classification", null, 0, "A bounded parametric panel is not assumed developable."),[new(source.StableId, source.Provenance, "surface-construction")]);@@ -158,7 +162,9 @@ public static class PanelFactoryvar patch = lowered.Patch!;var construction = new PanelConstruction(source.StableId,source.Kind == RuledConstructionKind.RuledTransition ? SurfaceConstructionKind.RuledTransition : SurfaceConstructionKind.RuledSurface,- patch.Domain, patch.ExactSurface, patch.Evaluate, patch.MaterializationKind, patch.ApproximationCertificate,+ patch.Domain, patch.ExactSurface, patch.Evaluate,+ ProceduralPatch(source.StableId, patch.Domain, patch.Evaluate, string.Join(";", patch.BoundaryProvenance.Select(item => item.BoundaryStableId))),+ patch.MaterializationKind, patch.ApproximationCertificate,patch.Developability, patch.BoundaryProvenance);var curves = new[]{@@ -205,8 +211,24 @@ public static class PanelFactoryprivate static PanelConstruction FromPatch(ConstructedSurfacePatch patch) => new(patch.StableId, patch.ConstructionKind, patch.Domain, patch.Support, patch.Evaluate,+ ProceduralPatch(patch.StableId, patch.Domain, patch.Evaluate, string.Join(";", patch.Provenance.Select(item => item.BoundaryStableId))),patch.MaterializationKind, patch.ApproximationCertificate, patch.Developability, patch.Provenance);+ private static BoundedParametricPatch3 ProceduralPatch(string stableId, ParametricDomain domain,+ Func<double, double, Point3D> evaluate, string provenance) =>+ BoundedParametricPatch3.Procedural(stableId, domain, (u, v) =>+ {+ var hu = (domain.U.Maximum - domain.U.Minimum) * 1e-6;+ var hv = (domain.V.Maximum - domain.V.Minimum) * 1e-6;+ var u0 = double.Max(domain.U.Minimum, u - hu); var u1 = double.Min(domain.U.Maximum, u + hu);+ var v0 = double.Max(domain.V.Minimum, v - hv); var v1 = double.Min(domain.V.Maximum, v + hv);+ var point = evaluate(u, v);+ var du = (evaluate(u1, v) - evaluate(u0, v)) / (u1 - u0);+ var dv = (evaluate(u, v1) - evaluate(u, v0)) / (v1 - v0);+ var singular = !du.Cross(dv).TryNormalize(out var normal);+ return new(point, du, dv, singular ? null : Direction3D.Create(normal), singular);+ }, provenance);+private static PanelResult Create(PanelConstruction construction,PanelOrientation? orientation,diff --git a/Aetheris.Surfacing/ParametricSurfaces.cs b/Aetheris.Surfacing/ParametricSurfaces.csindex dff5647c..8b0bd888 100644--- a/Aetheris.Surfacing/ParametricSurfaces.cs+++ b/Aetheris.Surfacing/ParametricSurfaces.cs@@ -1,89 +1,11 @@+using Aetheris.Geometry;using Aetheris.Kernel.Core.Geometry.Surfaces;using Aetheris.Kernel.Core.Math;namespace Aetheris.Surfacing;-public readonly record struct ParameterInterval2-{- public ParameterInterval2(double minimum,double maximum)- {- if (!double.IsFinite(minimum) || !double.IsFinite(maximum) || maximum <= minimum)- throw new ArgumentException("A parameter interval must be finite and increasing.");- Minimum=minimum;Maximum=maximum;- }- public double Minimum { get; }- public double Maximum { get; }- public double Map(double normalized) => Minimum + System.Math.Clamp(normalized, 0d, 1d) * (Maximum - Minimum);-}--public sealed record ParametricDomain(ParameterInterval2 U, ParameterInterval2 V);public enum SurfaceConstructionKind { ParametricSurface, HyperbolicParaboloid, ParabolicCylinder, EllipticParaboloid, Helicoid, RuledSurface, RuledTransition, SectionSurface, BoundaryPatch }public enum SurfaceMaterializationKind { ExactAnalytic, ExactPolynomialBSpline, ApproximatedNonRationalBSpline }-public readonly record struct UnitDimension(int LengthPower)-{- public static UnitDimension Dimensionless => new(0);- public static UnitDimension Length => new(1);- public static UnitDimension operator *(UnitDimension a, UnitDimension b) => new(a.LengthPower + b.LengthPower);- public static UnitDimension operator /(UnitDimension a, UnitDimension b) => new(a.LengthPower - b.LengthPower);-}--public readonly record struct ScalarJet(double Value, double Du, double Dv);--/// <summary>A deliberately small, unit-aware expression tree with forward automatic differentiation.</summary>-public abstract record SurfaceScalarExpression(UnitDimension Unit)-{- internal abstract ScalarJet Evaluate(double u, double v);-- public sealed record Constant(double ConstantValue, UnitDimension ConstantUnit) : SurfaceScalarExpression(ConstantUnit)- { internal override ScalarJet Evaluate(double u, double v) => new(ConstantValue, 0d, 0d); }- public sealed record Parameter(bool IsU) : SurfaceScalarExpression(UnitDimension.Dimensionless)- { internal override ScalarJet Evaluate(double u, double v) => IsU ? new(u, 1d, 0d) : new(v, 0d, 1d); }- public sealed record Sum(SurfaceScalarExpression Left, SurfaceScalarExpression Right) : SurfaceScalarExpression(RequireSame(Left, Right))- { internal override ScalarJet Evaluate(double u, double v) { var a=Left.Evaluate(u,v);var b=Right.Evaluate(u,v);return new(a.Value+b.Value,a.Du+b.Du,a.Dv+b.Dv); } }- public sealed record Difference(SurfaceScalarExpression Left, SurfaceScalarExpression Right) : SurfaceScalarExpression(RequireSame(Left, Right))- { internal override ScalarJet Evaluate(double u, double v) { var a=Left.Evaluate(u,v);var b=Right.Evaluate(u,v);return new(a.Value-b.Value,a.Du-b.Du,a.Dv-b.Dv); } }- public sealed record Product(SurfaceScalarExpression Left, SurfaceScalarExpression Right) : SurfaceScalarExpression(Left.Unit * Right.Unit)- { internal override ScalarJet Evaluate(double u, double v) { var a=Left.Evaluate(u,v);var b=Right.Evaluate(u,v);return new(a.Value*b.Value,a.Du*b.Value+a.Value*b.Du,a.Dv*b.Value+a.Value*b.Dv); } }- public sealed record Quotient(SurfaceScalarExpression Left, SurfaceScalarExpression Right) : SurfaceScalarExpression(Left.Unit / Right.Unit)- { internal override ScalarJet Evaluate(double u, double v) { var a=Left.Evaluate(u,v);var b=Right.Evaluate(u,v);if(double.Abs(b.Value)<=1e-15)throw new DivideByZeroException("Parametric expression divisor is zero.");var q=b.Value*b.Value;return new(a.Value/b.Value,(a.Du*b.Value-a.Value*b.Du)/q,(a.Dv*b.Value-a.Value*b.Dv)/q); } }- public sealed record IntegerPower(SurfaceScalarExpression Operand, int Exponent) : SurfaceScalarExpression(new UnitDimension(Operand.Unit.LengthPower * Exponent))- { internal override ScalarJet Evaluate(double u, double v) { var a=Operand.Evaluate(u,v);var value=double.Pow(a.Value,Exponent);var scale=Exponent==0?0d:Exponent*double.Pow(a.Value,Exponent-1);return new(value,scale*a.Du,scale*a.Dv); } }- public sealed record Sine(SurfaceScalarExpression Operand) : SurfaceScalarExpression(RequireDimensionless(Operand))- { internal override ScalarJet Evaluate(double u,double v){var a=Operand.Evaluate(u,v);var c=double.Cos(a.Value);return new(double.Sin(a.Value),c*a.Du,c*a.Dv);} }- public sealed record Cosine(SurfaceScalarExpression Operand) : SurfaceScalarExpression(RequireDimensionless(Operand))- { internal override ScalarJet Evaluate(double u,double v){var a=Operand.Evaluate(u,v);var s=-double.Sin(a.Value);return new(double.Cos(a.Value),s*a.Du,s*a.Dv);} }-- private static UnitDimension RequireSame(SurfaceScalarExpression a, SurfaceScalarExpression b) =>- a.Unit == b.Unit ? a.Unit : throw new ArgumentException($"Cannot add/subtract dimensions L^{a.Unit.LengthPower} and L^{b.Unit.LengthPower}.");- private static UnitDimension RequireDimensionless(SurfaceScalarExpression expression) =>- expression.Unit == UnitDimension.Dimensionless ? UnitDimension.Dimensionless : throw new ArgumentException("Trigonometric operands must be dimensionless.");-}--public static class SurfaceExpression-{- public static SurfaceScalarExpression U { get; } = new SurfaceScalarExpression.Parameter(true);- public static SurfaceScalarExpression V { get; } = new SurfaceScalarExpression.Parameter(false);- public static SurfaceScalarExpression Number(double value) => new SurfaceScalarExpression.Constant(value, UnitDimension.Dimensionless);- public static SurfaceScalarExpression Length(double millimetres) => new SurfaceScalarExpression.Constant(millimetres, UnitDimension.Length);- public static SurfaceScalarExpression Add(SurfaceScalarExpression a, SurfaceScalarExpression b) => new SurfaceScalarExpression.Sum(a,b);- public static SurfaceScalarExpression Subtract(SurfaceScalarExpression a, SurfaceScalarExpression b) => new SurfaceScalarExpression.Difference(a,b);- public static SurfaceScalarExpression Multiply(SurfaceScalarExpression a, SurfaceScalarExpression b) => new SurfaceScalarExpression.Product(a,b);- public static SurfaceScalarExpression Divide(SurfaceScalarExpression a, SurfaceScalarExpression b) => new SurfaceScalarExpression.Quotient(a,b);- public static SurfaceScalarExpression Power(SurfaceScalarExpression a, int exponent) => new SurfaceScalarExpression.IntegerPower(a,exponent);- public static SurfaceScalarExpression Sin(SurfaceScalarExpression a) => new SurfaceScalarExpression.Sine(a);- public static SurfaceScalarExpression Cos(SurfaceScalarExpression a) => new SurfaceScalarExpression.Cosine(a);-}--public sealed record SurfacePointExpression(SurfaceScalarExpression X, SurfaceScalarExpression Y, SurfaceScalarExpression Z)-{- public void ValidateLengthOutput()- {- if (X.Unit != UnitDimension.Length || Y.Unit != UnitDimension.Length || Z.Unit != UnitDimension.Length)- throw new ArgumentException("Parametric surface point components must all have Length dimension.");- }-}--public sealed record SurfaceDifferential(Point3D Point, Vector3D Du, Vector3D Dv, Direction3D? Normal, bool IsSingular);public sealed record ApproximationCertificate(double RequestedTolerance, double MaximumSampledPositionResidual,double? MaximumNormalDeviationDegrees, int ControlCountU, int ControlCountV, string SamplingPolicy, string SourceIdentity);@@ -93,23 +15,17 @@ public sealed record ParametricSurfaceIrSurfacePointExpression pointExpression,string provenance){ArgumentException.ThrowIfNullOrWhiteSpace(stableId);ArgumentException.ThrowIfNullOrWhiteSpace(provenance);- pointExpression.ValidateLengthOutput();StableId=stableId;ConstructionKind=constructionKind;Domain=domain;PointExpression=pointExpression;Provenance=provenance;+ Patch=new BoundedParametricPatch3(stableId,domain,pointExpression,provenance);+ StableId=stableId;ConstructionKind=constructionKind;Domain=domain;PointExpression=pointExpression;Provenance=provenance;}public string StableId { get; }public SurfaceConstructionKind ConstructionKind { get; }public ParametricDomain Domain { get; }public SurfacePointExpression PointExpression { get; }public string Provenance { get; }+ public BoundedParametricPatch3 Patch { get; }- public SurfaceDifferential Evaluate(double u, double v)- {- if (!double.IsFinite(u) || !double.IsFinite(v)) throw new ArgumentOutOfRangeException(nameof(u), "Parameters must be finite.");- if(u<Domain.U.Minimum||u>Domain.U.Maximum||v<Domain.V.Minimum||v>Domain.V.Maximum)throw new ArgumentOutOfRangeException(nameof(u),"Parameters must lie inside the authored rectangular domain.");- var x=PointExpression.X.Evaluate(u,v);var y=PointExpression.Y.Evaluate(u,v);var z=PointExpression.Z.Evaluate(u,v);- var du=new Vector3D(x.Du,y.Du,z.Du);var dv=new Vector3D(x.Dv,y.Dv,z.Dv);var cross=du.Cross(dv);- var singular=!cross.TryNormalize(out var normalized);- return new(new(x.Value,y.Value,z.Value),du,dv,singular?null:Direction3D.Create(normalized),singular);- }+ public SurfaceDifferential Evaluate(double u, double v) => Patch.Evaluate(u,v);}public sealed record ParametricMaterialization(BSplineSurfaceWithKnots Surface, ApproximationCertificate Certificate,diff --git a/Aetheris.Surfacing/RuledSurfaceLowering.cs b/Aetheris.Surfacing/RuledSurfaceLowering.csindex 30908111..9505089a 100644--- a/Aetheris.Surfacing/RuledSurfaceLowering.cs+++ b/Aetheris.Surfacing/RuledSurfaceLowering.cs@@ -1,4 +1,5 @@using Aetheris.Kernel.Core.Brep;+using Aetheris.Geometry;using Aetheris.Kernel.Core.Geometry;using Aetheris.Kernel.Core.Geometry.Curves;using Aetheris.Kernel.Core.Geometry.Surfaces;diff --git a/Aetheris.Surfacing/SectionAndBoundarySurfaces.cs b/Aetheris.Surfacing/SectionAndBoundarySurfaces.csindex 28ffc9e6..cc5f1bac 100644--- a/Aetheris.Surfacing/SectionAndBoundarySurfaces.cs+++ b/Aetheris.Surfacing/SectionAndBoundarySurfaces.cs@@ -1,3 +1,4 @@+using Aetheris.Geometry;using Aetheris.Kernel.Core.Geometry;using Aetheris.Kernel.Core.Geometry.Surfaces;using Aetheris.Kernel.Core.Math;diff --git a/Aetheris.Surfacing/SurfacePatchBrepMaterializer.cs b/Aetheris.Surfacing/SurfacePatchBrepMaterializer.csindex 94879fef..ab790bdd 100644--- a/Aetheris.Surfacing/SurfacePatchBrepMaterializer.cs+++ b/Aetheris.Surfacing/SurfacePatchBrepMaterializer.cs@@ -1,3 +1,4 @@+using Aetheris.Geometry;using Aetheris.Kernel.Core.Brep;using Aetheris.Kernel.Core.Geometry;using Aetheris.Kernel.Core.Geometry.Curves;diff --git a/Aetheris.slnx b/Aetheris.slnxindex 056b8ac7..0b7d6323 100644--- a/Aetheris.slnx+++ b/Aetheris.slnx@@ -2,6 +2,8 @@<Project Path="Aetheris.Server/Aetheris.Server.csproj" /><Project Path="Aetheris.Server.Tests/Aetheris.Server.Tests.csproj" /><Project Path="Aetheris.Kernel.Core/Aetheris.Kernel.Core.csproj" />+ <Project Path="Aetheris.Geometry/Aetheris.Geometry.csproj" />+ <Project Path="Aetheris.Geometry.Tests/Aetheris.Geometry.Tests.csproj" /><Project Path="Aetheris.Semantics/Aetheris.Semantics.csproj" /><Project Path="Aetheris.Semantics.Tests/Aetheris.Semantics.Tests.csproj" /><Project Path="Aetheris.Modules/Aetheris.Modules.csproj" />@@ -23,6 +25,7 @@<Project Path="tools/Aetheris.Continuum.M4B/Aetheris.Continuum.M4B.csproj" /><Project Path="tools/Aetheris.Continuum.M4C/Aetheris.Continuum.M4C.csproj" /><Project Path="tools/Aetheris.Forge.M1Evidence/Aetheris.Forge.M1Evidence.csproj" />+ <Project Path="tools/Aetheris.Geometry.M0Evidence/Aetheris.Geometry.M0Evidence.csproj" /><Project Path="tools/Aetheris.Continuum.AttentionE0/Aetheris.Continuum.AttentionE0.csproj" /><Project Path="tools/Aetheris.Continuum.AttentionE1/Aetheris.Continuum.AttentionE1.csproj" /><Project Path="Aetheris.Forge/Aetheris.Forge.csproj" />diff --git a/docs/geometry/artifacts/reasoning-m0/cad-panel-clearance.json b/docs/geometry/artifacts/reasoning-m0/cad-panel-clearance.jsonnew file mode 100644index 00000000..85dc60fc--- /dev/null+++ b/docs/geometry/artifacts/reasoning-m0/cad-panel-clearance.json@@ -0,0 +1,141 @@+{+ "milestone": "AETHERIS-GEOMETRY-REASONING-M0",+ "fixture": "cad-panel-clearance",+ "authoredGeometry": {+ "stableId": "cad:mold-clearance-panel",+ "provenance": "cad:mold-tooling-clearance",+ "representation": "AnalyticExpression",+ "domain": {+ "u": {+ "minimum": -1,+ "maximum": 1+ },+ "v": {+ "minimum": -1,+ "maximum": 1+ }+ }+ },+ "plane": {+ "origin": {+ "x": 0,+ "y": 0,+ "z": 0+ },+ "normal": {+ "x": 0,+ "y": 0,+ "z": 1+ }+ },+ "sampled": {+ "classification": "Positive",+ "evidenceKind": "Sampled",+ "policy": {+ "method": "Sampled",+ "tolerance": 1E-09,+ "samplesU": 17,+ "samplesV": 17,+ "maximumSubdivisionDepth": 10,+ "maximumLeafCount": 4096+ },+ "domain": {+ "u": {+ "minimum": -1,+ "maximum": 1+ },+ "v": {+ "minimum": -1,+ "maximum": 1+ }+ },+ "patchIdentity": "cad:mold-clearance-panel",+ "provenance": "cad:mold-tooling-clearance",+ "representation": "AnalyticExpression",+ "observedMinimum": 8,+ "observedMaximum": 9,+ "certifiedLowerBound": null,+ "certifiedUpperBound": null,+ "witnesses": [+ {+ "u": -1,+ "v": -1,+ "point": {+ "x": -50,+ "y": -30,+ "z": 9+ },+ "signedDistance": 9,+ "kind": "positive"+ }+ ],+ "statistics": {+ "sampleCount": 289,+ "leafCount": 0,+ "resolvedLeaves": 0,+ "unresolvedLeaves": 0,+ "maximumDepthReached": 0+ },+ "diagnostics": []+ },+ "certified": {+ "classification": "Positive",+ "evidenceKind": "Certified",+ "policy": {+ "method": "CertifiedInterval",+ "tolerance": 1E-09,+ "samplesU": 9,+ "samplesV": 9,+ "maximumSubdivisionDepth": 10,+ "maximumLeafCount": 4096+ },+ "domain": {+ "u": {+ "minimum": -1,+ "maximum": 1+ },+ "v": {+ "minimum": -1,+ "maximum": 1+ }+ },+ "patchIdentity": "cad:mold-clearance-panel",+ "provenance": "cad:mold-tooling-clearance",+ "representation": "AnalyticExpression",+ "observedMinimum": null,+ "observedMaximum": null,+ "certifiedLowerBound": 7.9999999999999964,+ "certifiedUpperBound": 9.000000000000007,+ "witnesses": [+ {+ "u": 0,+ "v": 0,+ "point": {+ "x": 0,+ "y": 0,+ "z": 8+ },+ "signedDistance": 8,+ "kind": "certified-positive-region"+ }+ ],+ "statistics": {+ "sampleCount": 0,+ "leafCount": 1,+ "resolvedLeaves": 1,+ "unresolvedLeaves": 0,+ "maximumDepthReached": 0+ },+ "diagnostics": []+ },+ "performance": {+ "sampledMilliseconds": 0.2584,+ "certifiedMilliseconds": 0.0053+ },+ "determinism": {+ "stable": true,+ "certifiedQuerySha256": "03780db056562c9e463f6086aa4d76176b6f1aa13e05dd0cb1697aa47ae31a48",+ "repeatQuerySha256": "03780db056562c9e463f6086aa4d76176b6f1aa13e05dd0cb1697aa47ae31a48",+ "sampledQuerySha256": "d5b20b1b44a06817f05da6f03540f7f3d7c46be2d220cfc3041dfe4a9fcfe81d"+ }+}\ No newline at end of filediff --git a/docs/geometry/artifacts/reasoning-m0/failing.json b/docs/geometry/artifacts/reasoning-m0/failing.jsonnew file mode 100644index 00000000..e607971f--- /dev/null+++ b/docs/geometry/artifacts/reasoning-m0/failing.json@@ -0,0 +1,174 @@+{+ "milestone": "AETHERIS-GEOMETRY-REASONING-M0",+ "fixture": "failing",+ "authoredGeometry": {+ "stableId": "calibration:crossing",+ "provenance": "geometry-m0:calibration",+ "representation": "AnalyticExpression",+ "domain": {+ "u": {+ "minimum": -1,+ "maximum": 1+ },+ "v": {+ "minimum": -1,+ "maximum": 1+ }+ }+ },+ "plane": {+ "origin": {+ "x": 0,+ "y": 0,+ "z": 0+ },+ "normal": {+ "x": 0,+ "y": 0,+ "z": 1+ }+ },+ "sampled": {+ "classification": "Crossing",+ "evidenceKind": "Sampled",+ "policy": {+ "method": "Sampled",+ "tolerance": 1E-09,+ "samplesU": 17,+ "samplesV": 17,+ "maximumSubdivisionDepth": 10,+ "maximumLeafCount": 4096+ },+ "domain": {+ "u": {+ "minimum": -1,+ "maximum": 1+ },+ "v": {+ "minimum": -1,+ "maximum": 1+ }+ },+ "patchIdentity": "calibration:crossing",+ "provenance": "geometry-m0:calibration",+ "representation": "AnalyticExpression",+ "observedMinimum": -3,+ "observedMaximum": 3,+ "certifiedLowerBound": null,+ "certifiedUpperBound": null,+ "witnesses": [+ {+ "u": -1,+ "v": -1,+ "point": {+ "x": -20,+ "y": -15,+ "z": -3+ },+ "signedDistance": -3,+ "kind": "negative"+ },+ {+ "u": 0,+ "v": -1,+ "point": {+ "x": 0,+ "y": -15,+ "z": 0+ },+ "signedDistance": 0,+ "kind": "contact-candidate"+ },+ {+ "u": 1,+ "v": -1,+ "point": {+ "x": 20,+ "y": -15,+ "z": 3+ },+ "signedDistance": 3,+ "kind": "positive"+ }+ ],+ "statistics": {+ "sampleCount": 289,+ "leafCount": 0,+ "resolvedLeaves": 0,+ "unresolvedLeaves": 0,+ "maximumDepthReached": 0+ },+ "diagnostics": []+ },+ "certified": {+ "classification": "Crossing",+ "evidenceKind": "Certified",+ "policy": {+ "method": "CertifiedInterval",+ "tolerance": 1E-09,+ "samplesU": 9,+ "samplesV": 9,+ "maximumSubdivisionDepth": 10,+ "maximumLeafCount": 4096+ },+ "domain": {+ "u": {+ "minimum": -1,+ "maximum": 1+ },+ "v": {+ "minimum": -1,+ "maximum": 1+ }+ },+ "patchIdentity": "calibration:crossing",+ "provenance": "geometry-m0:calibration",+ "representation": "AnalyticExpression",+ "observedMinimum": null,+ "observedMaximum": null,+ "certifiedLowerBound": -3.0000000000000018,+ "certifiedUpperBound": 3.0000000000000018,+ "witnesses": [+ {+ "u": -0.75,+ "v": -0.75,+ "point": {+ "x": -15,+ "y": -11.25,+ "z": -2.25+ },+ "signedDistance": -2.25,+ "kind": "certified-negative-region"+ },+ {+ "u": 0.75,+ "v": -0.75,+ "point": {+ "x": 15,+ "y": -11.25,+ "z": 2.25+ },+ "signedDistance": 2.25,+ "kind": "certified-positive-region"+ }+ ],+ "statistics": {+ "sampleCount": 0,+ "leafCount": 3,+ "resolvedLeaves": 3,+ "unresolvedLeaves": 0,+ "maximumDepthReached": 2+ },+ "diagnostics": []+ },+ "performance": {+ "sampledMilliseconds": 0.2356,+ "certifiedMilliseconds": 0.0233+ },+ "determinism": {+ "stable": true,+ "certifiedQuerySha256": "390906d67446891c34299cc279ca386aded853b14f78b888be7a7b6dcac1e376",+ "repeatQuerySha256": "390906d67446891c34299cc279ca386aded853b14f78b888be7a7b6dcac1e376",+ "sampledQuerySha256": "88792082b0c9df4d2e992c7b8f794071ea8fb31656847f1dc0077388fc1a9c72"+ }+}\ No newline at end of filediff --git a/docs/geometry/artifacts/reasoning-m0/historical-audit.json b/docs/geometry/artifacts/reasoning-m0/historical-audit.jsonnew file mode 100644index 00000000..35b5b8ca--- /dev/null+++ b/docs/geometry/artifacts/reasoning-m0/historical-audit.json@@ -0,0 +1,17 @@+{+ "milestone": "AETHERIS-GEOMETRY-REASONING-M0",+ "panelOnlyBuild": {+ "preChange": "still-present-index-out-of-range",+ "postChange": "typed-unsupported-shell-export",+ "diagnostic": "firmament-panel-only-step-materialization-unsupported"+ },+ "assemblyPanelLinkage": {+ "status": "changed-architecture-partially-applicable",+ "programmaticPanelOccurrences": "linked-through-semantic-edges-and-provenance",+ "textualOccurrenceIdentity": "product-definition-identity-not-PanelIr-object-reference"+ },+ "publicParametricApi": {+ "preChange": "public-but-surfacing-owned-and-materialization-coupled",+ "postChange": "public-domain-neutral-Aetheris.Geometry"+ }+}diff --git a/docs/geometry/artifacts/reasoning-m0/historical-panel-only.firmament b/docs/geometry/artifacts/reasoning-m0/historical-panel-only.firmamentnew file mode 100644index 00000000..8cd53c13--- /dev/null+++ b/docs/geometry/artifacts/reasoning-m0/historical-panel-only.firmament@@ -0,0 +1,10 @@+Model HistoricalPanelOnly {+ Units: mm;+ Panel Saddle {+ Surface: ParametricSurface {+ DomainU: [-1, 1]; DomainV: [-1, 1];+ X: 40mm * u; Y: 30mm * v; Z: 12mm * u * v;+ }+ Orientation: Front; Thickness: 1.2mm; Material: "Aluminum";+ }+}diff --git a/docs/geometry/artifacts/reasoning-m0/intersection-authority-audit.md b/docs/geometry/artifacts/reasoning-m0/intersection-authority-audit.mdnew file mode 100644index 00000000..3e3c1c11--- /dev/null+++ b/docs/geometry/artifacts/reasoning-m0/intersection-authority-audit.md@@ -0,0 +1,12 @@+# Bounded intersection-authority audit++Scope: `Aetheris.Kernel.Core`, `Aetheris.Kernel.Firmament`, and `Aetheris.Surfacing`; this is not a kernel-wide refactor.++| Path | Classification | Evidence |+|---|---|---|+| `TransverseConePlaneIntersection.IntersectWorldZ` | Bounded constructive / healthy | Accepts only signed-permutation transverse cones and world-Z sections, rejects the apex degeneracy, and returns the construction-known positive hyperbola branch. Its source documentation explicitly rejects a general surface/surface role. |+| Primitive Boolean `Intersect` | Bounded topology operation / healthy | Operates on already-authored BRep solids through the Boolean subsystem; it is not a numerical parametric-surface curve discovery route. |+| `RestrictedFieldGridSampler` -> marching squares -> contour stitching/snap | Legacy experiment but contained | `NumericalOnly` carries `NumericalOnlyNotExportable`; analytic line/circle snaps are candidate-only. `TieredTrimRepresentationBuilder` records `ExactStepExported=false` and `BRepTopologyEmitted=false`. |+| General planar/cylinder, planar/cone, and planar/torus source-surface capability table | Future risk explicitly deferred | Capability records distinguish exact, special-case, and deferred families. General conic/algebraic intersection is not admitted as topology authority. |++No code change was needed in these paths. The architecture rule is now explicit in `docs/geometry/reasoning.md` and the new public query does not call any BRep or trim materializer.diff --git a/docs/geometry/artifacts/reasoning-m0/post-preview-2-audit.md b/docs/geometry/artifacts/reasoning-m0/post-preview-2-audit.mdnew file mode 100644index 00000000..e6a1beaa--- /dev/null+++ b/docs/geometry/artifacts/reasoning-m0/post-preview-2-audit.md@@ -0,0 +1,18 @@+# Post-Preview-2 historical-gap audit++The historical findings were re-tested before changes.++| Finding | Pre-change result | M0 disposition |+|---|---|---|+| Panel-only `validate` succeeds but `build` indexes an empty solid list | Still present. CLI validation returned valid with two warnings; CLI build threw `Index was out of range`. | Fixed as a current defect. Build now returns typed `NotImplemented` diagnostic `firmament-panel-only-step-materialization-unsupported`. It does not emit a misleading solid STEP file. |+| Assembly `<Panel>` identity is not linked to compiled `PanelIr` | Changed architecture, partially applicable. `AssemblyInstanceKind.Panel` exists and programmatic assembly members carry Panel semantic edges/provenance; textual assembly occurrence identity remains a product/definition identity rather than an automatic cross-document `PanelIr` object reference. | No brittle cross-compiler object link added. Public patch identity/provenance now gives future assembly integration a stable contract. Existing Panel mate tests remain the ground truth for linked programmatic occurrences. |+| Public parametric surface types are reachable only through unstable/internal paths | The expression tree and `ParametricSurfaceIr` were public but owned by `Aetheris.Surfacing` and coupled to materialization semantics. | Fixed by deliberate ownership. Domain-neutral domain/expression/first-jet/patch/query/evidence contracts now live in the public `Aetheris.Geometry` assembly. `ParametricSurfaceIr` is a Surfacing wrapper over the public patch. |++Evidence fixture: `historical-panel-only.firmament`. The CLI commands used were:++```text+dotnet run --project Aetheris.CLI -- validate docs/geometry/artifacts/reasoning-m0/historical-panel-only.firmament+dotnet run --project Aetheris.CLI -- build docs/geometry/artifacts/reasoning-m0/historical-panel-only.firmament --out docs/geometry/artifacts/reasoning-m0/historical-panel-only.step+```++The first post-fix command remains valid; the second exits cleanly with the typed unsupported-shell-export diagnostic. No STEP artifact is authored because a Panel is not silently redefined as a solid.diff --git a/docs/geometry/artifacts/reasoning-m0/safe.json b/docs/geometry/artifacts/reasoning-m0/safe.jsonnew file mode 100644index 00000000..cabcb903--- /dev/null+++ b/docs/geometry/artifacts/reasoning-m0/safe.json@@ -0,0 +1,141 @@+{+ "milestone": "AETHERIS-GEOMETRY-REASONING-M0",+ "fixture": "safe",+ "authoredGeometry": {+ "stableId": "calibration:safe-clearance",+ "provenance": "geometry-m0:calibration",+ "representation": "AnalyticExpression",+ "domain": {+ "u": {+ "minimum": -1,+ "maximum": 1+ },+ "v": {+ "minimum": -1,+ "maximum": 1+ }+ }+ },+ "plane": {+ "origin": {+ "x": 0,+ "y": 0,+ "z": 0+ },+ "normal": {+ "x": 0,+ "y": 0,+ "z": 1+ }+ },+ "sampled": {+ "classification": "Positive",+ "evidenceKind": "Sampled",+ "policy": {+ "method": "Sampled",+ "tolerance": 1E-09,+ "samplesU": 17,+ "samplesV": 17,+ "maximumSubdivisionDepth": 10,+ "maximumLeafCount": 4096+ },+ "domain": {+ "u": {+ "minimum": -1,+ "maximum": 1+ },+ "v": {+ "minimum": -1,+ "maximum": 1+ }+ },+ "patchIdentity": "calibration:safe-clearance",+ "provenance": "geometry-m0:calibration",+ "representation": "AnalyticExpression",+ "observedMinimum": 1,+ "observedMaximum": 3,+ "certifiedLowerBound": null,+ "certifiedUpperBound": null,+ "witnesses": [+ {+ "u": -1,+ "v": -1,+ "point": {+ "x": -20,+ "y": -15,+ "z": 3+ },+ "signedDistance": 3,+ "kind": "positive"+ }+ ],+ "statistics": {+ "sampleCount": 289,+ "leafCount": 0,+ "resolvedLeaves": 0,+ "unresolvedLeaves": 0,+ "maximumDepthReached": 0+ },+ "diagnostics": []+ },+ "certified": {+ "classification": "Positive",+ "evidenceKind": "Certified",+ "policy": {+ "method": "CertifiedInterval",+ "tolerance": 1E-09,+ "samplesU": 9,+ "samplesV": 9,+ "maximumSubdivisionDepth": 10,+ "maximumLeafCount": 4096+ },+ "domain": {+ "u": {+ "minimum": -1,+ "maximum": 1+ },+ "v": {+ "minimum": -1,+ "maximum": 1+ }+ },+ "patchIdentity": "calibration:safe-clearance",+ "provenance": "geometry-m0:calibration",+ "representation": "AnalyticExpression",+ "observedMinimum": null,+ "observedMaximum": null,+ "certifiedLowerBound": 0.9999999999999996,+ "certifiedUpperBound": 3.0000000000000027,+ "witnesses": [+ {+ "u": 0,+ "v": 0,+ "point": {+ "x": 0,+ "y": 0,+ "z": 1+ },+ "signedDistance": 1,+ "kind": "certified-positive-region"+ }+ ],+ "statistics": {+ "sampleCount": 0,+ "leafCount": 1,+ "resolvedLeaves": 1,+ "unresolvedLeaves": 0,+ "maximumDepthReached": 0+ },+ "diagnostics": []+ },+ "performance": {+ "sampledMilliseconds": 1.8537,+ "certifiedMilliseconds": 2.4863+ },+ "determinism": {+ "stable": true,+ "certifiedQuerySha256": "943c6de754afa2d54d014274c87f8c92ef39f6f6a26460248a61f345cc72a4a1",+ "repeatQuerySha256": "943c6de754afa2d54d014274c87f8c92ef39f6f6a26460248a61f345cc72a4a1",+ "sampledQuerySha256": "429e19f8d2452b92a7eb077496019bd9d439d9a10c72d143f76caee807dde877"+ }+}\ No newline at end of filediff --git a/docs/geometry/artifacts/reasoning-m0/tangent.json b/docs/geometry/artifacts/reasoning-m0/tangent.jsonnew file mode 100644index 00000000..b7e9cd19--- /dev/null+++ b/docs/geometry/artifacts/reasoning-m0/tangent.json@@ -0,0 +1,157 @@+{+ "milestone": "AETHERIS-GEOMETRY-REASONING-M0",+ "fixture": "tangent",+ "authoredGeometry": {+ "stableId": "calibration:tangent-contact",+ "provenance": "geometry-m0:calibration",+ "representation": "AnalyticExpression",+ "domain": {+ "u": {+ "minimum": -1,+ "maximum": 1+ },+ "v": {+ "minimum": -1,+ "maximum": 1+ }+ }+ },+ "plane": {+ "origin": {+ "x": 0,+ "y": 0,+ "z": 0+ },+ "normal": {+ "x": 0,+ "y": 0,+ "z": 1+ }+ },+ "sampled": {+ "classification": "Unknown",+ "evidenceKind": "Sampled",+ "policy": {+ "method": "Sampled",+ "tolerance": 1E-09,+ "samplesU": 17,+ "samplesV": 17,+ "maximumSubdivisionDepth": 10,+ "maximumLeafCount": 4096+ },+ "domain": {+ "u": {+ "minimum": -1,+ "maximum": 1+ },+ "v": {+ "minimum": -1,+ "maximum": 1+ }+ },+ "patchIdentity": "calibration:tangent-contact",+ "provenance": "geometry-m0:calibration",+ "representation": "AnalyticExpression",+ "observedMinimum": 0,+ "observedMaximum": 2,+ "certifiedLowerBound": null,+ "certifiedUpperBound": null,+ "witnesses": [+ {+ "u": 0,+ "v": -1,+ "point": {+ "x": 0,+ "y": -15,+ "z": 0+ },+ "signedDistance": 0,+ "kind": "contact-candidate"+ },+ {+ "u": -1,+ "v": -1,+ "point": {+ "x": -20,+ "y": -15,+ "z": 2+ },+ "signedDistance": 2,+ "kind": "positive"+ }+ ],+ "statistics": {+ "sampleCount": 289,+ "leafCount": 0,+ "resolvedLeaves": 0,+ "unresolvedLeaves": 0,+ "maximumDepthReached": 0+ },+ "diagnostics": []+ },+ "certified": {+ "classification": "Unknown",+ "evidenceKind": "Unknown",+ "policy": {+ "method": "CertifiedInterval",+ "tolerance": 1E-09,+ "samplesU": 9,+ "samplesV": 9,+ "maximumSubdivisionDepth": 10,+ "maximumLeafCount": 4096+ },+ "domain": {+ "u": {+ "minimum": -1,+ "maximum": 1+ },+ "v": {+ "minimum": -1,+ "maximum": 1+ }+ },+ "patchIdentity": "calibration:tangent-contact",+ "provenance": "geometry-m0:calibration",+ "representation": "AnalyticExpression",+ "observedMinimum": null,+ "observedMaximum": null,+ "certifiedLowerBound": -4.4E-323,+ "certifiedUpperBound": 2.000000000000002,+ "witnesses": [+ {+ "u": -0.75,+ "v": -0.75,+ "point": {+ "x": -15,+ "y": -11.25,+ "z": 1.125+ },+ "signedDistance": 1.125,+ "kind": "certified-positive-region"+ }+ ],+ "statistics": {+ "sampleCount": 0,+ "leafCount": 4096,+ "resolvedLeaves": 2728,+ "unresolvedLeaves": 1368,+ "maximumDepthReached": 10+ },+ "diagnostics": [+ {+ "code": "SubdivisionBudgetExhausted",+ "message": "Certification remained inconclusive at depth 10 with leaf budget 4096."+ }+ ]+ },+ "performance": {+ "sampledMilliseconds": 0.2519,+ "certifiedMilliseconds": 8.9127+ },+ "determinism": {+ "stable": true,+ "certifiedQuerySha256": "ec4edab23865d349a3704317dc5bf2bc48c4d1176d7caaeb48bf8c7fce1ecd13",+ "repeatQuerySha256": "ec4edab23865d349a3704317dc5bf2bc48c4d1176d7caaeb48bf8c7fce1ecd13",+ "sampledQuerySha256": "40222cbaa6c525942a072ee4b0179d095dd0a77aee6613d6d9537857c6a78d70"+ }+}\ No newline at end of filediff --git a/docs/geometry/artifacts/reasoning-m0/validation-report.md b/docs/geometry/artifacts/reasoning-m0/validation-report.mdnew file mode 100644index 00000000..4b5d4421--- /dev/null+++ b/docs/geometry/artifacts/reasoning-m0/validation-report.md@@ -0,0 +1,12 @@+# M0 validation report++- .NET SDK: 10.0.302.+- Restore: `dotnet restore Aetheris.slnx` succeeded.+- Build: `dotnet build Aetheris.slnx -f net10.0 --no-restore /m:1` succeeded with 0 warnings and 0 errors.+- Full solution tests: 2,708 passed, 0 failed, 0 skipped. `Aetheris.FrictionLab.Tests` contains no discoverable tests and did not fail the run.+- Geometry-focused tests: 11 passed, covering typed domain/plane validation, public evaluation/first jets/normals, identity/provenance, sampled strict sides/crossing/contact candidate, certified polynomial sides/crossing, tangent budget exhaustion, sine/cosine/division intervals, unsupported procedural certification, Panel adapter/CAD clearance, semantic expectations, and deterministic serialization.+- Historical Panel-only CLI fixture: validation is valid (0 fatal, 2 warnings); build now returns a typed unsupported-shell-export diagnostic and emits no STEP artifact.+- Calibration generation: `dotnet run --project tools/Aetheris.Geometry.M0Evidence -- docs/geometry/artifacts/reasoning-m0` succeeded.+- Every calibration's certified-query JSON was serialized twice and produced identical SHA-256 hashes. Sampling and subdivision contain no random choices.++Measured calibration performance is persisted in each fixture JSON. These wall-clock measurements are observational and machine-dependent; classifications, bounds, witness order, statistics, diagnostics, and query hashes are the deterministic contract.diff --git a/docs/geometry/artifacts/reasoning-m0/validation.json b/docs/geometry/artifacts/reasoning-m0/validation.jsonnew file mode 100644index 00000000..4acfc37d--- /dev/null+++ b/docs/geometry/artifacts/reasoning-m0/validation.json@@ -0,0 +1,45 @@+{+ "milestone": "AETHERIS-GEOMETRY-REASONING-M0",+ "sdk": "10.0.302",+ "restore": {+ "command": "dotnet restore Aetheris.slnx",+ "succeeded": true+ },+ "build": {+ "command": "dotnet build Aetheris.slnx -f net10.0 --no-restore /m:1",+ "succeeded": true,+ "warnings": 0,+ "errors": 0+ },+ "tests": {+ "command": "dotnet test Aetheris.slnx -f net10.0 --no-restore --no-build",+ "succeeded": true,+ "passed": 2708,+ "failed": 0,+ "skipped": 0,+ "assemblies": {+ "Aetheris.CLI.Tests": 362,+ "Aetheris.Collaboration.Tests": 5,+ "Aetheris.Continuum.Tests": 148,+ "Aetheris.FEA.Tests": 12,+ "Aetheris.Forge.Host.Tests": 10,+ "Aetheris.Geometry.Tests": 11,+ "Aetheris.Kernel.Core.Tests": 940,+ "Aetheris.Kernel.Firmament.Tests": 1112,+ "Aetheris.Modules.Tests": 37,+ "Aetheris.Semantics.Tests": 9,+ "Aetheris.Server.Tests": 54,+ "Aetheris.Samples.DatabaseDrivenCad.Tests": 8+ },+ "emptyTestAssemblies": ["Aetheris.FrictionLab.Tests"]+ },+ "cliAudit": {+ "panelOnlyValidate": "valid-0-fatal-2-warning",+ "panelOnlyBuild": "typed-unsupported-no-step-emitted"+ },+ "determinism": {+ "allCalibrationQueryHashesStableOnImmediateRepeat": true,+ "samplingRandomized": false,+ "subdivisionOrder": "southwest-southeast-northwest-northeast"+ }+}diff --git a/docs/geometry/reasoning.md b/docs/geometry/reasoning.mdnew file mode 100644index 00000000..a558cfe2--- /dev/null+++ b/docs/geometry/reasoning.md@@ -0,0 +1,92 @@+# Authored geometry reasoning++Status: AETHERIS-GEOMETRY-REASONING-M0++## Architecture and authority++Aetheris separates four layers:++1. authored bounded geometry, including parameter domain, evaluation, first jet, identity, and provenance;+2. predicates that inspect that geometry and return explicit evidence;+3. optional realization into a supported surface representation;+4. BRep topology and STEP serialization.++`Aetheris.Geometry.BoundedParametricPatch3` is the public object at layer 1. It is not a Panel and carries no material, thickness, fabrication, or material-side meaning. `Aetheris.Surfacing.PanelIr` remains the manufacturing/CAD wrapper and exposes its source through `AuthoredPatch`. Expression-authored patches evaluate `P(u,v)`, `dP/du`, `dP/dv`, and a normal where the first jet is non-singular. The derivatives come from forward automatic differentiation; users do not author them independently.++The M0 domain is rectangular: `u in [u0,u1]` and `v in [v0,v1]`, with finite, strictly increasing limits. Arbitrary trim-domain topology and second jets are deferred.++## Representation is not evidence++`GeometryRepresentationKind` describes the object being evaluated: `AnalyticExpression`, `ProceduralParametric`, `CertifiedApproximation`, `SampledApproximation`, `MaterializedBRep`, or `ImportedGeometry`.++`PredicateEvidenceKind` describes one conclusion: `Structural`, `Certified`, `ToleranceBounded`, `Sampled`, `Heuristic`, or `Unknown`.++These are deliberately separate. `AnalyticExpression` means a finite-numerical expression representation, not algebraically exact arithmetic. `Certified` is reserved for a conclusion supported by conservative, outward-rounded interval bounds. A procedural patch can in principle receive certified evidence from a future certified evaluator; its representation does not predetermine the evidence class.++## SignedSideQuery++`SignedSideQuery.Query(patch, plane, policy)` reduces the question to++```text+g(u,v) = dot(plane.normal, P(u,v) - plane.origin)+```++and returns a `SignedSideResult` containing classification, evidence kind, policy/tolerance, queried domain, identity and provenance, observed or certified bounds, ordered witnesses, subdivision/sample statistics, and typed diagnostics.++The classifications mean:++- `Positive`: the reported evidence supports the whole domain being strictly above the tolerance band.+- `Negative`: the analogous whole-domain negative conclusion.+- `Crossing`: strict positive and strict negative points or certified regions have been established. The authored expression patch is continuous, so the intermediate value theorem establishes a zero between them. The evidence kind states how the strict-side facts were obtained.+- `Touching`: contact without crossing has been established. M0 exposes the contract but does not manufacture this conclusion from samples and does not certify tangency.+- `Unknown`: valid geometry did not yield enough evidence. This is a normal result, not malformed geometry.++### Sampled policy++The sampled policy uses a deterministic row-major tensor grid including all domain boundaries. It reports observed minimum/maximum distance and at most one ordered negative, contact-candidate, and positive witness. A near-zero sample is only a `contact-candidate`; without both strict signs the classification remains `Unknown`. This policy always returns `Sampled` evidence and can never return `Certified`.++### Certified interval policy++The bounded evaluator supports constants, parameters, addition, subtraction, multiplication, division whose denominator excludes zero, integer powers, sine, and cosine. Arithmetic bounds are expanded with adjacent floating-point values. Trigonometric bounds include every enclosed extremum.++The query evaluates the whole root domain, then subdivides each inconclusive rectangle into four children in deterministic southwest, southeast, northwest, northeast order. It stops at explicit depth and leaf budgets. All resolved positive leaves certify `Positive`; all resolved negative leaves certify `Negative`. One strict positive region plus one strict negative region certifies `Crossing` by continuity. Unsupported expressions and exhausted budgets return `Unknown`; the certified policy never silently samples.++M0 does not certify touching. A tangent patch therefore normally returns `Unknown` with a budget diagnostic, while a separate sampled query can locate a contact candidate.++## Semantic obligations++`SignedSideExpectation` is a generic compile-time-style obligation over a query result and minimum evidence strength. It validates the result and reports a rejection reason. It is not a realization request and cannot create trims, curves, faces, or BRep topology.++## Intersection authority rule++Generic numerical intersection is a query/evidence operation. Its numerical points or curves do not author semantic topology, trimming authority, or a surprise engineering object.++Constructive intersection is allowed inside an admitted materializer only when authored construction intent already fixes the construction family, expected topology, and expected analytic intersection family. Numerical work may validate that topology; it does not invent it.++This distinction preserves bounded routes such as the signed-permutation transverse cone/world-Z plane hyperbola. The restricted-field/marching-squares prototype remains contained: numerical contours are explicitly `NumericalOnlyNotExportable`, analytic snaps are candidate-only, and its records state that STEP export and BRep topology emission were not performed.++## Public use++```csharp+using Aetheris.Geometry;+using Aetheris.Kernel.Core.Math;++var patch = new BoundedParametricPatch3(+ "fixture-clearance",+ new ParametricDomain(new(-1, 1), new(-1, 1)),+ new SurfacePointExpression(+ SurfaceExpression.Multiply(SurfaceExpression.Length(50), SurfaceExpression.U),+ SurfaceExpression.Multiply(SurfaceExpression.Length(30), SurfaceExpression.V),+ SurfaceExpression.Add(SurfaceExpression.Length(8),+ SurfaceExpression.Multiply(SurfaceExpression.Length(1), SurfaceExpression.Power(SurfaceExpression.U, 2)))),+ "cad:mold-tooling-clearance");++var plane = new Plane3(Point3D.Origin, Direction3D.Create(new Vector3D(0, 0, 1)));+var result = SignedSideQuery.Query(patch, plane, SignedSidePolicy.Certified());+```++Normal Aetheris code references `Aetheris.Geometry` directly. Forge extension authors may do the same or call `Aetheris.Forge.KernelSDK.KernelSdk.QuerySignedSide`; KernelSDK is an exposure surface, not the owner.++## Limitations++M0 has no second jets, curvature, contact order, generic tangency certificate, arbitrary trimmed parameter domains, generic curve/surface intersection, CAS, or theorem-specific vocabulary. Procedural patches have public first-jet evaluation but require a future certified evaluator before the interval policy can certify them. No generic predicate materializes intersection curves or mutates topology.diff --git a/tools/Aetheris.Geometry.M0Evidence/Aetheris.Geometry.M0Evidence.csproj b/tools/Aetheris.Geometry.M0Evidence/Aetheris.Geometry.M0Evidence.csprojnew file mode 100644index 00000000..d3e71ae3--- /dev/null+++ b/tools/Aetheris.Geometry.M0Evidence/Aetheris.Geometry.M0Evidence.csproj@@ -0,0 +1,7 @@+<Project Sdk="Microsoft.NET.Sdk">+ <PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net10.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup>+ <ItemGroup>+ <ProjectReference Include="..\..\Aetheris.Geometry\Aetheris.Geometry.csproj" />+ <ProjectReference Include="..\..\Aetheris.Surfacing\Aetheris.Surfacing.csproj" />+ </ItemGroup>+</Project>diff --git a/tools/Aetheris.Geometry.M0Evidence/Program.cs b/tools/Aetheris.Geometry.M0Evidence/Program.csnew file mode 100644index 00000000..2dd8a68a--- /dev/null+++ b/tools/Aetheris.Geometry.M0Evidence/Program.cs@@ -0,0 +1,65 @@+using System.Diagnostics;+using System.Security.Cryptography;+using System.Text;+using System.Text.Json;+using System.Text.Json.Serialization;+using Aetheris.Geometry;+using Aetheris.Kernel.Core.Math;+using Aetheris.Surfacing;++var output = args.Length == 1 ? Path.GetFullPath(args[0]) : Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "..", "..", "..", "..", "..", "docs", "geometry", "artifacts", "reasoning-m0"));+Directory.CreateDirectory(output);+var options = new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase, WriteIndented = true };+options.Converters.Add(new JsonStringEnumConverter());+var plane = new Plane3(Point3D.Origin, Direction3D.Create(new Vector3D(0, 0, 1)));++BoundedParametricPatch3 Graph(string id, SurfaceScalarExpression z, string provenance = "geometry-m0:calibration") =>+ new(id, new(new(-1, 1), new(-1, 1)), new(+ SurfaceExpression.Multiply(SurfaceExpression.Length(20), SurfaceExpression.U),+ SurfaceExpression.Multiply(SurfaceExpression.Length(15), SurfaceExpression.V), z), provenance);++var square = SurfaceExpression.Multiply(SurfaceExpression.Length(2), SurfaceExpression.Power(SurfaceExpression.U, 2));+var safe = Graph("calibration:safe-clearance", SurfaceExpression.Add(SurfaceExpression.Length(1), square));+var tangent = Graph("calibration:tangent-contact", square);+var failing = Graph("calibration:crossing", SurfaceExpression.Multiply(SurfaceExpression.Length(3), SurfaceExpression.U));+var cadSource = new ParametricSurfaceIr("cad:mold-clearance-panel", SurfaceConstructionKind.ParametricSurface,+ new(new(-1, 1), new(-1, 1)), new(+ SurfaceExpression.Multiply(SurfaceExpression.Length(50), SurfaceExpression.U),+ SurfaceExpression.Multiply(SurfaceExpression.Length(30), SurfaceExpression.V),+ SurfaceExpression.Add(SurfaceExpression.Length(8), SurfaceExpression.Multiply(SurfaceExpression.Length(1), SurfaceExpression.Power(SurfaceExpression.U, 2)))),+ "cad:mold-tooling-clearance");+var cadPanel = PanelFactory.FromParametric(cadSource).Panel ?? throw new InvalidOperationException("CAD calibration Panel failed to construct.");++Run("safe", safe);+Run("tangent", tangent);+Run("failing", failing);+Run("cad-panel-clearance", cadPanel.AuthoredPatch);++void Run(string name, BoundedParametricPatch3 patch)+{+ var sampled = Measure(() => SignedSideQuery.Query(patch, plane, SignedSidePolicy.Sampled(1e-9, 17, 17)));+ var certified = Measure(() => SignedSideQuery.Query(patch, plane, SignedSidePolicy.Certified(1e-9, 10, 4096)));+ var repeat = SignedSideQuery.Query(patch, plane, SignedSidePolicy.Certified(1e-9, 10, 4096));+ var sampledJson = JsonSerializer.Serialize(sampled.Result, options);+ var certifiedJson = JsonSerializer.Serialize(certified.Result, options);+ var repeatJson = JsonSerializer.Serialize(repeat, options);+ var report = new+ {+ milestone = "AETHERIS-GEOMETRY-REASONING-M0",+ fixture = name,+ authoredGeometry = new { patch.StableId, patch.Provenance, representation = patch.Representation.ToString(), patch.Domain },+ plane,+ sampled = sampled.Result,+ certified = certified.Result,+ performance = new { sampledMilliseconds = sampled.Elapsed.TotalMilliseconds, certifiedMilliseconds = certified.Elapsed.TotalMilliseconds },+ determinism = new { stable = certifiedJson == repeatJson, certifiedQuerySha256 = Hash(certifiedJson), repeatQuerySha256 = Hash(repeatJson), sampledQuerySha256 = Hash(sampledJson) }+ };+ File.WriteAllText(Path.Combine(output, name + ".json"), JsonSerializer.Serialize(report, options).Replace("\r\n", "\n"), new UTF8Encoding(false));+}++static (T Result, TimeSpan Elapsed) Measure<T>(Func<T> action)+{+ var watch = Stopwatch.StartNew(); var result = action(); watch.Stop(); return (result, watch.Elapsed);+}++static string Hash(string value) => Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(value))).ToLowerInvariant();