Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Preserve trimmed B-spline curve intervals in STEP242

Yuechen Li9b0e76a84896
diff --git a/Aetheris.Kernel.Core.Tests/Brep/BrepDiametralCrossHoleTests.cs b/Aetheris.Kernel.Core.Tests/Brep/BrepDiametralCrossHoleTests.cs
new file mode 100644
index 00000000..c90ef2ca
--- /dev/null
+++ b/Aetheris.Kernel.Core.Tests/Brep/BrepDiametralCrossHoleTests.cs
@@ -0,0 +1,130 @@
+using Aetheris.Kernel.Core.Brep;
+using Aetheris.Kernel.Core.Brep.Features;
+using Aetheris.Kernel.Core.Brep.Tessellation;
+using Aetheris.Kernel.Core.Brep.Verification;
+using Aetheris.Kernel.Core.Geometry;
+using Aetheris.Kernel.Core.Geometry.Surfaces;
+using Aetheris.Kernel.Core.Math;
+using Aetheris.Kernel.Core.Step242;
+using Xunit;
+using Xunit.Abstractions;
+
+namespace Aetheris.Kernel.Core.Tests.Brep;
+
+public sealed class BrepDiametralCrossHoleTests
+{
+ private readonly ITestOutputHelper _output;
+
+ public BrepDiametralCrossHoleTests(ITestOutputHelper output) => _output = output;
+
+ [Theory]
+ [InlineData(2d, 0.2d)]
+ [InlineData(2d, 0.6d)]
+ [InlineData(2d, 1.8d)]
+ [InlineData(0.79375d, 0.5953125d)]
+ public void OneSolidCrossHole_BuildsQualifiedManifoldTopology(double radius, double holeRadius)
+ {
+ var z = Direction3D.Create(new Vector3D(0, 0, 1));
+ var x = Direction3D.Create(new Vector3D(1, 0, 0));
+ var stock = new CylinderSurface(new Point3D(0, 0, -5), z, radius, x);
+ var result = BrepDiametralCrossHole.Build(stock, 10d, x, holeRadius, 5d);
+ Assert.True(result.IsSuccess, string.Join("; ", result.Diagnostics.Select(d => d.Message)));
+ var body = result.Value;
+ Assert.Equal(4, body.Topology.Faces.Count());
+ Assert.Equal(8, body.Topology.Edges.Count());
+ Assert.Equal(6, body.Topology.Vertices.Count());
+ Assert.Equal(2, body.Bindings.FaceBoundaryRoleBindings.Count(binding => binding.Role == FaceBoundaryRole.Inner));
+ Assert.Equal(16, body.Topology.Coedges.Count());
+ Assert.All(body.Topology.Edges, edge => Assert.Equal(2,
+ body.Topology.Coedges.Count(coedge => coedge.EdgeId == edge.Id)));
+ var intersectionEdges = body.Bindings.EdgeBindings
+ .Where(binding => body.Geometry.GetCurve(binding.CurveGeometryId).CertifiedIntersection is not null)
+ .ToArray();
+ Assert.Equal(4, intersectionEdges.Length);
+ Assert.Equal(2, intersectionEdges.Select(binding => binding.CurveGeometryId).Distinct().Count());
+ Assert.True(BrepPcurveValidator.Validate(body, requireEveryCoedge: true).IsValid);
+ Assert.True(BrepExportPreflight.Validate(body).IsValid);
+ var mass = BrepMassProperties.Evaluate(body);
+ Assert.True(mass.IsEnclosed, string.Join("; ", mass.Topology.Messages));
+ Assert.True(mass.IsOrientationConsistent, string.Join("; ", mass.Topology.Messages));
+ Assert.True(mass.AbsoluteVolume > 0d);
+ Assert.True(mass.SignedVolume > 0d);
+ Assert.True(mass.AbsoluteVolume < double.Pi * radius * radius * 10d);
+ }
+
+ [Theory]
+ [InlineData(0d, 0d, 1d, 1d, 0d, 0d, 3d)]
+ [InlineData(0d, 0d, 1d, 0d, 1d, 0d, 7d)]
+ [InlineData(0d, 1d, 0d, 1d, 0d, 0d, 5d)]
+ public void AxialPositionRotationAndRigidFrame_StayClosed(
+ double zx, double zy, double zz, double xx, double xy, double xz, double position)
+ {
+ var axis = Direction3D.Create(new Vector3D(zx, zy, zz));
+ var cutter = Direction3D.Create(new Vector3D(xx, xy, xz));
+ var stock = new CylinderSurface(new Point3D(7, -3, 11), axis, 2d,
+ Direction3D.Create(axis.ToVector().Cross(cutter.ToVector())));
+ var result = BrepDiametralCrossHole.Build(stock, 10d, cutter, 0.6d, position);
+ Assert.True(result.IsSuccess, string.Join("; ", result.Diagnostics.Select(d => d.Message)));
+ var body = result.Value;
+ Assert.True(BrepPcurveValidator.Validate(body, requireEveryCoedge: true).IsValid);
+ Assert.True(BrepExportPreflight.Validate(body).IsValid);
+ var mass = BrepMassProperties.Evaluate(body);
+ Assert.True(mass.IsEnclosed && mass.IsOrientationConsistent);
+ Assert.True(mass.SignedVolume > 0d);
+ }
+
+ [Fact]
+ public void InvalidPlacement_FailsExplicitly()
+ {
+ var z = Direction3D.Create(new Vector3D(0, 0, 1));
+ var x = Direction3D.Create(new Vector3D(1, 0, 0));
+ var stock = new CylinderSurface(new Point3D(0, 0, -5), z, 2d, x);
+ Assert.Contains(BrepDiametralCrossHole.Build(stock, 10d, x, 0d, 5d).Diagnostics,
+ diagnostic => diagnostic.Source == "Brep.CrossHole.InvalidDimension");
+ Assert.Contains(BrepDiametralCrossHole.Build(stock, 10d, x, 0.6d, 0.6d).Diagnostics,
+ diagnostic => diagnostic.Source == "Brep.CrossHole.EndCollision");
+ Assert.Contains(BrepDiametralCrossHole.Build(stock, 10d,
+ Direction3D.Create(new Vector3D(1, 0, 1)), 0.6d, 5d).Diagnostics,
+ diagnostic => diagnostic.Source == "Brep.CrossHole.ObliqueAxis");
+ Assert.False(BrepDiametralCrossHole.Build(stock, 10d, x, 2d, 5d).IsSuccess);
+ Assert.False(BrepDiametralCrossHole.Build(stock, 10d, x, 2.1d, 5d).IsSuccess);
+ }
+
+ [Fact]
+ public void CanonicalBody_TessellatesAndExportsRoundTrip()
+ {
+ var z = Direction3D.Create(new Vector3D(0, 0, 1));
+ var x = Direction3D.Create(new Vector3D(1, 0, 0));
+ var body = BrepDiametralCrossHole.Build(
+ new CylinderSurface(new Point3D(0, 0, -5), z, 2d, x), 10d, x, 0.6d, 5d).Value;
+ var display = BrepDisplayTessellator.TessellateBounded(body, executionTimeout: TimeSpan.FromSeconds(10));
+ Assert.True(display.IsSuccess, string.Join("; ", display.Diagnostics.Select(d => d.Message)));
+ Assert.Equal(4, display.Value.FacePatches.Count);
+ Assert.All(display.Value.FacePatches, patch => Assert.NotEmpty(patch.TriangleIndices));
+ var step = Step242Exporter.ExportBody(body);
+ Assert.True(step.IsSuccess, string.Join("; ", step.Diagnostics.Select(d => d.Message)));
+ Assert.Equal(step.Value, Step242Exporter.ExportBody(body).Value);
+ var debugOutput = Environment.GetEnvironmentVariable("AETHERIS_CROSSHOLE_STEP_OUTPUT");
+ if (!string.IsNullOrWhiteSpace(debugOutput)) File.WriteAllText(debugOutput, step.Value);
+ var cylinderLoops = new List<Step242Importer.LoopRoleCylinderProjectionDiagnostic>();
+ using var diagnostics = Step242Importer.CaptureLoopRoleCylinderProjectionDiagnostics(cylinderLoops);
+ var imported = Step242Importer.ImportBody(step.Value);
+ foreach (var loop in cylinderLoops)
+ _output.WriteLine($"face={loop.FaceEntityId} loop={loop.LoopId} points={loop.PointCount} unique={loop.UniquePointCount} area={loop.SignedArea:G17} spanU={loop.AngularSpan:G17} spanV={loop.AxialSpan:G17} seam={loop.SeamCrossings} degenerate={loop.Degeneracy}");
+ Assert.True(imported.IsSuccess, string.Join("; ", imported.Diagnostics.Select(d => d.Message)));
+ var importedMass = BrepMassProperties.Evaluate(imported.Value);
+ Assert.True(importedMass.IsEnclosed);
+ Assert.True(importedMass.IsOrientationConsistent);
+ Assert.True(importedMass.SignedVolume > 0d);
+ Assert.True(BrepPcurveValidator.Validate(imported.Value, requireEveryCoedge: true).IsValid);
+ Assert.Equal(2, imported.Value.Bindings.FaceBoundaryRoleBindings.Count(binding => binding.Role == FaceBoundaryRole.Inner));
+ var cylinderRadii = imported.Value.Bindings.FaceBindings
+ .Select(binding => imported.Value.Geometry.GetSurface(binding.SurfaceGeometryId))
+ .Where(surface => surface.Kind == SurfaceGeometryKind.Cylinder)
+ .Select(surface => surface.Cylinder!.Value.Radius)
+ .OrderBy(radius => radius).ToArray();
+ Assert.Equal(2, cylinderRadii.Length);
+ Assert.Equal(0.6d, cylinderRadii[0], 10);
+ Assert.Equal(2d, cylinderRadii[1], 10);
+ }
+}
diff --git a/Aetheris.Kernel.Core.Tests/Geometry/CylinderCylinderIntersectionCurveTests.cs b/Aetheris.Kernel.Core.Tests/Geometry/CylinderCylinderIntersectionCurveTests.cs
new file mode 100644
index 00000000..216086cf
--- /dev/null
+++ b/Aetheris.Kernel.Core.Tests/Geometry/CylinderCylinderIntersectionCurveTests.cs
@@ -0,0 +1,181 @@
+using Aetheris.Kernel.Core.Geometry;
+using Aetheris.Kernel.Core.Brep;
+using Aetheris.Kernel.Core.Geometry.Curves;
+using Aetheris.Kernel.Core.Geometry.Surfaces;
+using Aetheris.Kernel.Core.Math;
+using Aetheris.Kernel.Core.Numerics;
+using Xunit;
+using Xunit.Abstractions;
+
+namespace Aetheris.Kernel.Core.Tests.Geometry;
+
+public sealed class CylinderCylinderIntersectionCurveTests
+{
+ private readonly ITestOutputHelper _output;
+
+ public CylinderCylinderIntersectionCurveTests(ITestOutputHelper output) => _output = output;
+
+ private static readonly Direction3D X = Direction3D.Create(new Vector3D(1, 0, 0));
+ private static readonly Direction3D Y = Direction3D.Create(new Vector3D(0, 1, 0));
+ private static readonly Direction3D Z = Direction3D.Create(new Vector3D(0, 0, 1));
+
+ [Theory]
+ [InlineData(CylinderIntersectionBranch.PositiveCutterAxis)]
+ [InlineData(CylinderIntersectionBranch.NegativeCutterAxis)]
+ public void ExactAuthority_SatisfiesBothCylindersAndBothPcurves(CylinderIntersectionBranch branch)
+ {
+ var intersection = Create(0.79375, 0.5953125, branch);
+ var priorHostU = intersection.EvaluateHostPcurve(0).U;
+ for (var i = 0; i <= 1024; i++)
+ {
+ var t = 2d * double.Pi * i / 1024d;
+ var point = intersection.Evaluate(t);
+ var hostUv = intersection.EvaluateHostPcurve(t);
+ var toolUv = intersection.EvaluateToolPcurve(t);
+ Assert.True(double.Abs(point.X * point.X + point.Y * point.Y - 0.79375d * 0.79375d) < 2e-15);
+ Assert.True(double.Abs(point.Y * point.Y + (point.Z - 3d) * (point.Z - 3d) - 0.5953125d * 0.5953125d) < 2e-15);
+ Assert.True((intersection.Host.Evaluate(hostUv.U, hostUv.V) - point).Length < 2e-15);
+ Assert.True((intersection.Tool.Evaluate(toolUv.U, toolUv.V) - point).Length < 2e-15);
+ Assert.True(double.Abs(hostUv.U - priorHostU) < 0.02d);
+ Assert.True(double.Abs(toolUv.U - t) < 2e-15);
+ priorHostU = hostUv.U;
+ }
+ }
+
+ [Fact]
+ public void Derivative_AgreesWithCenteredDifference()
+ {
+ var intersection = Create(2d, 0.8d, CylinderIntersectionBranch.PositiveCutterAxis);
+ const double h = 1e-6d;
+ foreach (var t in new[] { 0.1d, 0.8d, 2d, 3.4d, 5.9d })
+ {
+ var difference = (intersection.Evaluate(t + h) - intersection.Evaluate(t - h)) / (2d * h);
+ Assert.True((difference - intersection.Derivative(t)).Length < 1e-9d);
+ }
+ }
+
+ [Fact]
+ public void RotatedRadialCutter_PreservesBothSurfaceFrames()
+ {
+ const double angle = 1.1d;
+ var radial = Direction3D.Create(new Vector3D(double.Cos(angle), double.Sin(angle), 0d));
+ var host = new CylinderSurface(Point3D.Origin, Z, 2d, Y);
+ var tool = new CylinderSurface(new Point3D(0, 0, 3), radial, 0.5d, Z);
+ var intersection = CylinderCylinderIntersectionCurve.Create(host, tool, new Point3D(0, 0, 3),
+ CylinderIntersectionBranch.NegativeCutterAxis, new ParameterInterval(0d, 2d * double.Pi)).Value;
+ for (var i = 0; i <= 256; i++)
+ {
+ var t = 2d * double.Pi * i / 256d;
+ var point = intersection.Evaluate(t);
+ var hostUv = intersection.EvaluateHostPcurve(t);
+ var toolUv = intersection.EvaluateToolPcurve(t);
+ Assert.True((host.Evaluate(hostUv.U, hostUv.V) - point).Length < 3e-14d);
+ Assert.True((tool.Evaluate(toolUv.U, toolUv.V) - point).Length < 3e-14d);
+ }
+ }
+
+ [Theory]
+ [InlineData(0.1d)]
+ [InlineData(0.5953125d)]
+ [InlineData(0.75d)]
+ public void AdaptiveRealization_BoundsTheWholeCurveAndBothSurfaceResiduals(double cutterRadius)
+ {
+ var intersection = Create(0.79375d, cutterRadius, CylinderIntersectionBranch.PositiveCutterAxis);
+ var realized = CylinderIntersectionCurveRealizer.Realize(intersection, ToleranceContext.Default);
+ Assert.True(realized.IsSuccess, string.Join("; ", realized.Diagnostics.Select(d => d.Message)));
+ var result = realized.Value;
+ var observedMax = 0d;
+ var observedHostResidual = 0d;
+ var observedToolResidual = 0d;
+ Assert.True(result.CertifiedDeviationBoundMm <= ToleranceContext.Default.Linear);
+ Assert.Equal(result.SegmentCount * 4, result.Curve.ControlPoints.Count);
+ var stored = CurveGeometry.FromCertifiedIntersection(result);
+ Assert.Same(result, stored.CertifiedIntersection);
+ Assert.Equal(result.Curve, stored.BSpline3!.Value);
+ for (var i = 0; i <= 2048; i++)
+ {
+ var t = 2d * double.Pi * i / 2048d;
+ var finite = result.Curve.Evaluate(t);
+ var exact = intersection.Evaluate(t);
+ observedMax = double.Max(observedMax, (finite - exact).Length);
+ observedHostResidual = double.Max(observedHostResidual,
+ double.Abs(double.Sqrt(finite.X * finite.X + finite.Y * finite.Y) - intersection.Host.Radius));
+ observedToolResidual = double.Max(observedToolResidual,
+ double.Abs(double.Sqrt(finite.Y * finite.Y + (finite.Z - 3d) * (finite.Z - 3d)) - cutterRadius));
+ var hostUv = intersection.EvaluateHostPcurve(t);
+ var toolUv = intersection.EvaluateToolPcurve(t);
+ Assert.True((finite - exact).Length <= result.CertifiedDeviationBoundMm + 1e-12d);
+ Assert.True((finite - intersection.Host.Evaluate(hostUv.U, hostUv.V)).Length <= result.CertifiedDeviationBoundMm + 1e-12d);
+ Assert.True((finite - intersection.Tool.Evaluate(toolUv.U, toolUv.V)).Length <= result.CertifiedDeviationBoundMm + 1e-12d);
+ }
+ _output.WriteLine($"r={cutterRadius:G17} segments={result.SegmentCount} controls={result.Curve.ControlPoints.Count} analyticBoundMm={result.AnalyticErrorBoundMm:G17} totalBoundMm={result.CertifiedDeviationBoundMm:G17} sampledMaxMm={observedMax:G17} hostResidualMm={observedHostResidual:G17} toolResidualMm={observedToolResidual:G17}");
+ }
+
+ [Fact]
+ public void TighterTolerance_RefinesRepresentation()
+ {
+ var intersection = Create(0.79375d, 0.5953125d, CylinderIntersectionBranch.PositiveCutterAxis);
+ var loose = CylinderIntersectionCurveRealizer.Realize(intersection, new ToleranceContext(1e-4d, 1e-9d)).Value;
+ var tight = CylinderIntersectionCurveRealizer.Realize(intersection, new ToleranceContext(1e-7d, 1e-9d)).Value;
+ Assert.True(tight.SegmentCount > loose.SegmentCount);
+ Assert.True(tight.CertifiedDeviationBoundMm < loose.CertifiedDeviationBoundMm);
+ }
+
+ [Theory]
+ [InlineData(0.1d)]
+ [InlineData(0.5953125d)]
+ [InlineData(0.75d)]
+ public void FinitePcurves_LiftToQualified3dEdge(double cutterRadius)
+ {
+ var intersection = Create(0.79375d, cutterRadius, CylinderIntersectionBranch.NegativeCutterAxis);
+ var edge = CylinderIntersectionCurveRealizer.Realize(intersection).Value;
+ var pcurves = CylinderIntersectionPcurveRealizer.Realize(edge);
+ Assert.True(pcurves.IsSuccess, string.Join("; ", pcurves.Diagnostics.Select(d => d.Message)));
+ Assert.True(pcurves.Value.HostEdgeMismatchBoundMm <= ToleranceContext.Default.Linear);
+ Assert.True(pcurves.Value.ToolEdgeMismatchBoundMm <= ToleranceContext.Default.Linear);
+ var host = PcurveGeometry.Polynomial(intersection.Domain, pcurves.Value.Host);
+ var tool = PcurveGeometry.Polynomial(intersection.Domain, pcurves.Value.Tool);
+ var hostMax = 0d;
+ var toolMax = 0d;
+ for (var i = 0; i <= 2048; i++)
+ {
+ var t = 2d * double.Pi * i / 2048d;
+ var edgePoint = edge.Curve.Evaluate(t);
+ var h = host.Evaluate(t);
+ var c = tool.Evaluate(t);
+ hostMax = double.Max(hostMax, (intersection.Host.Evaluate(h.U, h.V) - edgePoint).Length);
+ toolMax = double.Max(toolMax, (intersection.Tool.Evaluate(c.U, c.V) - edgePoint).Length);
+ }
+ Assert.True(hostMax <= pcurves.Value.HostEdgeMismatchBoundMm + 1e-12d);
+ Assert.True(toolMax <= pcurves.Value.ToolEdgeMismatchBoundMm + 1e-12d);
+ _output.WriteLine($"r={cutterRadius:G17} hostSegments={pcurves.Value.HostSegmentCount} toolSegments={pcurves.Value.ToolSegmentCount} hostBoundMm={pcurves.Value.HostEdgeMismatchBoundMm:G17} toolBoundMm={pcurves.Value.ToolEdgeMismatchBoundMm:G17} sampledHostMm={hostMax:G17} sampledToolMm={toolMax:G17}");
+ }
+
+ [Fact]
+ public void UnsupportedAxesAndTangency_FailExplicitly()
+ {
+ var host = new CylinderSurface(Point3D.Origin, Z, 1d, X);
+ var oblique = new CylinderSurface(Point3D.Origin,
+ Direction3D.Create(new Vector3D(1, 0, 1)), 0.2d, Y);
+ var eccentric = new CylinderSurface(new Point3D(0, 0.1, 0), X, 0.2d, Y);
+ var almostEccentric = new CylinderSurface(new Point3D(0, 1e-8d, 0), X, 0.2d, Y);
+ var tangent = new CylinderSurface(Point3D.Origin, X, 1d, Y);
+ var domain = new ParameterInterval(0d, 2d * double.Pi);
+ Assert.Contains("ObliqueAxes", CylinderCylinderIntersectionCurve.Create(host, oblique,
+ Point3D.Origin, CylinderIntersectionBranch.PositiveCutterAxis, domain).Diagnostics[0].Source);
+ Assert.Contains("EccentricAxes", CylinderCylinderIntersectionCurve.Create(host, eccentric,
+ Point3D.Origin, CylinderIntersectionBranch.PositiveCutterAxis, domain).Diagnostics[0].Source);
+ Assert.Contains("EccentricAxes", CylinderCylinderIntersectionCurve.Create(host, almostEccentric,
+ Point3D.Origin, CylinderIntersectionBranch.PositiveCutterAxis, domain).Diagnostics[0].Source);
+ Assert.Contains("TangentOrOversize", CylinderCylinderIntersectionCurve.Create(host, tangent,
+ Point3D.Origin, CylinderIntersectionBranch.PositiveCutterAxis, domain).Diagnostics[0].Source);
+ }
+
+ private static CylinderCylinderIntersectionCurve Create(double hostRadius, double toolRadius, CylinderIntersectionBranch branch)
+ {
+ var host = new CylinderSurface(Point3D.Origin, Z, hostRadius, X);
+ var tool = new CylinderSurface(new Point3D(0, 0, 3), X, toolRadius, Y);
+ return CylinderCylinderIntersectionCurve.Create(host, tool, new Point3D(0, 0, 3), branch,
+ new ParameterInterval(0d, 2d * double.Pi)).Value;
+ }
+}
diff --git a/Aetheris.Kernel.Core/Brep/Features/BrepDiametralCrossHole.cs b/Aetheris.Kernel.Core/Brep/Features/BrepDiametralCrossHole.cs
new file mode 100644
index 00000000..1fabf537
--- /dev/null
+++ b/Aetheris.Kernel.Core/Brep/Features/BrepDiametralCrossHole.cs
@@ -0,0 +1,181 @@
+using Aetheris.Kernel.Core.Diagnostics;
+using Aetheris.Kernel.Core.Geometry;
+using Aetheris.Kernel.Core.Geometry.Curves;
+using Aetheris.Kernel.Core.Geometry.Surfaces;
+using Aetheris.Kernel.Core.Math;
+using Aetheris.Kernel.Core.Numerics;
+using Aetheris.Kernel.Core.Results;
+using Aetheris.Kernel.Core.Topology;
+
+namespace Aetheris.Kernel.Core.Brep.Features;
+
+/// <summary>
+/// Constructive solid-cylinder through-diameter hole. The host seam is relocated
+/// to the equidistant clear sector between openings; the cutter seam has two
+/// face-local UV uses on one geometric edge. Each opening is two half-branch
+/// edges because strict preflight does not admit a non-conic self-loop edge.
+/// </summary>
+public static class BrepDiametralCrossHole
+{
+ public static KernelResult<BrepBody> Build(
+ CylinderSurface stock, double length, Direction3D cutterAxis,
+ double cutterRadius, double axialPosition,
+ ToleranceContext? tolerance = null)
+ {
+ var tol = tolerance ?? ToleranceContext.Default;
+ if (!double.IsFinite(length) || length <= 0d || !double.IsFinite(cutterRadius) || cutterRadius <= 0d
+ || !double.IsFinite(axialPosition))
+ return Failure("Length, cutter radius and axial position must be finite; length and radius must be positive.",
+ "Brep.CrossHole.InvalidDimension");
+ if (axialPosition - cutterRadius <= tol.Linear || length - axialPosition - cutterRadius <= tol.Linear)
+ return Failure("The entire cross-hole must clear both stock ends.", "Brep.CrossHole.EndCollision");
+
+ var z = stock.Axis.ToVector();
+ var x = cutterAxis.ToVector();
+ if (double.Abs(z.Dot(x)) > tol.Angular)
+ return Failure("Cutter axis must be perpendicular to the stock axis.", "Brep.CrossHole.ObliqueAxis");
+ var seamDirection = Direction3D.Create(z.Cross(x));
+ var y = seamDirection.ToVector();
+ var bottom = stock.Origin;
+ var top = bottom + z * length;
+ var center = bottom + z * axialPosition;
+ var host = new CylinderSurface(bottom, stock.Axis, stock.Radius, seamDirection);
+ var tool = new CylinderSurface(center, cutterAxis, cutterRadius, seamDirection);
+ var full = new ParameterInterval(0d, 2d * double.Pi);
+ var first = new ParameterInterval(0d, double.Pi);
+ var second = new ParameterInterval(double.Pi, 2d * double.Pi);
+ var positive = CylinderCylinderIntersectionCurve.Create(host, tool, center,
+ CylinderIntersectionBranch.PositiveCutterAxis, full, tolerance: tol);
+ if (!positive.IsSuccess) return KernelResult<BrepBody>.Failure(positive.Diagnostics);
+ var negative = CylinderCylinderIntersectionCurve.Create(host, tool, center,
+ CylinderIntersectionBranch.NegativeCutterAxis, full, tolerance: tol);
+ if (!negative.IsSuccess) return KernelResult<BrepBody>.Failure(negative.Diagnostics);
+ var positiveEdge = CylinderIntersectionCurveRealizer.Realize(positive.Value, tol);
+ if (!positiveEdge.IsSuccess) return KernelResult<BrepBody>.Failure(positiveEdge.Diagnostics);
+ var negativeEdge = CylinderIntersectionCurveRealizer.Realize(negative.Value, tol);
+ if (!negativeEdge.IsSuccess) return KernelResult<BrepBody>.Failure(negativeEdge.Diagnostics);
+ var positiveUv = CylinderIntersectionPcurveRealizer.Realize(positiveEdge.Value, tol);
+ if (!positiveUv.IsSuccess) return KernelResult<BrepBody>.Failure(positiveUv.Diagnostics);
+ var negativeUv = CylinderIntersectionPcurveRealizer.Realize(negativeEdge.Value, tol);
+ if (!negativeUv.IsSuccess) return KernelResult<BrepBody>.Failure(negativeUv.Diagnostics);
+
+ var builder = new TopologyBuilder();
+ var points = new Dictionary<VertexId, Point3D>();
+ VertexId Vertex(Point3D point)
+ {
+ var id = builder.AddVertex();
+ points.Add(id, point);
+ return id;
+ }
+ var bottomSeamVertex = Vertex(bottom + y * stock.Radius);
+ var topSeamVertex = Vertex(top + y * stock.Radius);
+ var pos0 = Vertex(positive.Value.Evaluate(0d));
+ var posPi = Vertex(positive.Value.Evaluate(double.Pi));
+ var neg0 = Vertex(negative.Value.Evaluate(0d));
+ var negPi = Vertex(negative.Value.Evaluate(double.Pi));
+
+ var hostSeam = builder.AddEdge(bottomSeamVertex, topSeamVertex);
+ var bottomRim = builder.AddEdge(bottomSeamVertex, bottomSeamVertex);
+ var topRim = builder.AddEdge(topSeamVertex, topSeamVertex);
+ var posFirst = builder.AddEdge(pos0, posPi);
+ var posSecond = builder.AddEdge(posPi, pos0);
+ var negFirst = builder.AddEdge(neg0, negPi);
+ var negSecond = builder.AddEdge(negPi, neg0);
+ var toolSeam = builder.AddEdge(pos0, neg0);
+
+ var hostOuter = AddLoop(builder, [new(hostSeam), new(topRim), new(hostSeam, true), new(bottomRim, true)]);
+ var hostPositiveOpening = AddLoop(builder, [new(posSecond, true), new(posFirst, true)]);
+ var hostNegativeOpening = AddLoop(builder, [new(negFirst), new(negSecond)]);
+ var hostFace = builder.AddFace([hostOuter.Id, hostPositiveOpening.Id, hostNegativeOpening.Id]);
+ var bottomCap = AddLoop(builder, [new(bottomRim)]);
+ var bottomFace = builder.AddFace([bottomCap.Id]);
+ var topCap = AddLoop(builder, [new(topRim, true)]);
+ var topFace = builder.AddFace([topCap.Id]);
+ var wall = AddLoop(builder, [new(posFirst), new(posSecond), new(toolSeam),
+ new(negSecond, true), new(negFirst, true), new(toolSeam, true)]);
+ var wallFace = builder.AddFace([wall.Id]);
+ var shell = builder.AddShell([hostFace, bottomFace, topFace, wallFace]);
+ builder.AddBody([shell]);
+
+ var geometry = new BrepGeometryStore();
+ geometry.AddCurve(new CurveGeometryId(1), CurveGeometry.FromLine(new Line3Curve(points[bottomSeamVertex], stock.Axis)));
+ geometry.AddCurve(new CurveGeometryId(2), CurveGeometry.FromCircle(new Circle3Curve(bottom, stock.Axis, stock.Radius, seamDirection)));
+ geometry.AddCurve(new CurveGeometryId(3), CurveGeometry.FromCircle(new Circle3Curve(top, stock.Axis, stock.Radius, seamDirection)));
+ geometry.AddCurve(new CurveGeometryId(4), CurveGeometry.FromCertifiedIntersection(positiveEdge.Value));
+ geometry.AddCurve(new CurveGeometryId(5), CurveGeometry.FromCertifiedIntersection(negativeEdge.Value));
+ var seamLength = (points[neg0] - points[pos0]).Length;
+ geometry.AddCurve(new CurveGeometryId(6), CurveGeometry.FromLine(new Line3Curve(points[pos0], Direction3D.Create(points[neg0] - points[pos0]))));
+ geometry.AddSurface(new SurfaceGeometryId(1), SurfaceGeometry.FromCylinder(host));
+ geometry.AddSurface(new SurfaceGeometryId(2), SurfaceGeometry.FromPlane(new PlaneSurface(bottom, Direction3D.Create(-z), seamDirection)));
+ geometry.AddSurface(new SurfaceGeometryId(3), SurfaceGeometry.FromPlane(new PlaneSurface(top, stock.Axis, seamDirection)));
+ geometry.AddSurface(new SurfaceGeometryId(4), SurfaceGeometry.FromCylinder(tool));
+
+ var bindings = new BrepBindingModel();
+ bindings.AddEdgeBinding(new EdgeGeometryBinding(hostSeam, new CurveGeometryId(1), new ParameterInterval(0d, length)));
+ bindings.AddEdgeBinding(new EdgeGeometryBinding(bottomRim, new CurveGeometryId(2), full));
+ bindings.AddEdgeBinding(new EdgeGeometryBinding(topRim, new CurveGeometryId(3), full));
+ bindings.AddEdgeBinding(new EdgeGeometryBinding(posFirst, new CurveGeometryId(4), first));
+ bindings.AddEdgeBinding(new EdgeGeometryBinding(posSecond, new CurveGeometryId(4), second));
+ bindings.AddEdgeBinding(new EdgeGeometryBinding(negFirst, new CurveGeometryId(5), first));
+ bindings.AddEdgeBinding(new EdgeGeometryBinding(negSecond, new CurveGeometryId(5), second));
+ bindings.AddEdgeBinding(new EdgeGeometryBinding(toolSeam, new CurveGeometryId(6), new ParameterInterval(0d, seamLength)));
+ bindings.AddFaceBinding(new FaceGeometryBinding(hostFace, new SurfaceGeometryId(1)));
+ bindings.AddFaceBinding(new FaceGeometryBinding(bottomFace, new SurfaceGeometryId(2)));
+ bindings.AddFaceBinding(new FaceGeometryBinding(topFace, new SurfaceGeometryId(3)));
+ bindings.AddFaceBinding(new FaceGeometryBinding(wallFace, new SurfaceGeometryId(4), IsAlignedWithSurface: false));
+ bindings.AddFaceBoundaryRoleBinding(new FaceBoundaryRoleBinding(hostFace, hostOuter.Id, FaceBoundaryRole.Outer));
+ bindings.AddFaceBoundaryRoleBinding(new FaceBoundaryRoleBinding(hostFace, hostPositiveOpening.Id, FaceBoundaryRole.Inner));
+ bindings.AddFaceBoundaryRoleBinding(new FaceBoundaryRoleBinding(hostFace, hostNegativeOpening.Id, FaceBoundaryRole.Inner));
+ bindings.AddFaceBoundaryRoleBinding(new FaceBoundaryRoleBinding(bottomFace, bottomCap.Id, FaceBoundaryRole.Outer));
+ bindings.AddFaceBoundaryRoleBinding(new FaceBoundaryRoleBinding(topFace, topCap.Id, FaceBoundaryRole.Outer));
+ bindings.AddFaceBoundaryRoleBinding(new FaceBoundaryRoleBinding(wallFace, wall.Id, FaceBoundaryRole.Outer));
+
+ void Bind(CoedgeId id, FaceId face, SurfaceGeometryId surface, PcurveGeometry pcurve)
+ => bindings.AddPcurveBinding(new CoedgePcurveBinding(id, face, surface, pcurve));
+ Bind(hostOuter.Coedges[0], hostFace, new SurfaceGeometryId(1), PcurveGeometry.Line(new ParameterInterval(0d, length), new(0d, 0d), new(0d, length)));
+ Bind(hostOuter.Coedges[1], hostFace, new SurfaceGeometryId(1), PcurveGeometry.Line(full, new(0d, length), new(2d * double.Pi, length)));
+ Bind(hostOuter.Coedges[2], hostFace, new SurfaceGeometryId(1), PcurveGeometry.Line(new ParameterInterval(0d, length), new(2d * double.Pi, 0d), new(2d * double.Pi, length)));
+ Bind(hostOuter.Coedges[3], hostFace, new SurfaceGeometryId(1), PcurveGeometry.Line(full, new(0d, 0d), new(2d * double.Pi, 0d)));
+ Bind(hostPositiveOpening.Coedges[0], hostFace, new SurfaceGeometryId(1), PcurveGeometry.Polynomial(second, positiveUv.Value.Host));
+ Bind(hostPositiveOpening.Coedges[1], hostFace, new SurfaceGeometryId(1), PcurveGeometry.Polynomial(first, positiveUv.Value.Host));
+ Bind(hostNegativeOpening.Coedges[0], hostFace, new SurfaceGeometryId(1), PcurveGeometry.Polynomial(first, negativeUv.Value.Host));
+ Bind(hostNegativeOpening.Coedges[1], hostFace, new SurfaceGeometryId(1), PcurveGeometry.Polynomial(second, negativeUv.Value.Host));
+ Bind(bottomCap.Coedges[0], bottomFace, new SurfaceGeometryId(2), PcurveGeometry.Circle(full, new(0d, 0d), stock.Radius, -stock.Radius));
+ Bind(topCap.Coedges[0], topFace, new SurfaceGeometryId(3), PcurveGeometry.Circle(full, new(0d, 0d), stock.Radius, stock.Radius));
+ Bind(wall.Coedges[0], wallFace, new SurfaceGeometryId(4), PcurveGeometry.Polynomial(first, positiveUv.Value.Tool));
+ Bind(wall.Coedges[1], wallFace, new SurfaceGeometryId(4), PcurveGeometry.Polynomial(second, positiveUv.Value.Tool));
+ Bind(wall.Coedges[2], wallFace, new SurfaceGeometryId(4), PcurveGeometry.Line(new ParameterInterval(0d, seamLength), new(2d * double.Pi, (points[pos0] - center).Dot(x)), new(2d * double.Pi, (points[neg0] - center).Dot(x))));
+ Bind(wall.Coedges[3], wallFace, new SurfaceGeometryId(4), PcurveGeometry.Polynomial(second, negativeUv.Value.Tool));
+ Bind(wall.Coedges[4], wallFace, new SurfaceGeometryId(4), PcurveGeometry.Polynomial(first, negativeUv.Value.Tool));
+ Bind(wall.Coedges[5], wallFace, new SurfaceGeometryId(4), PcurveGeometry.Line(new ParameterInterval(0d, seamLength), new(0d, (points[pos0] - center).Dot(x)), new(0d, (points[neg0] - center).Dot(x))));
+
+ var body = new BrepBody(builder.Model, geometry, bindings, points);
+ var bindingValidation = BrepBindingValidator.Validate(body, requireAllEdgeAndFaceBindings: true);
+ if (!bindingValidation.IsSuccess) return KernelResult<BrepBody>.Failure(bindingValidation.Diagnostics);
+ var pcurveValidation = BrepPcurveValidator.Validate(body, tol.Linear, requireEveryCoedge: true, samples: 129);
+ if (!pcurveValidation.IsValid)
+ return Failure(string.Join("; ", pcurveValidation.Diagnostics), "Brep.CrossHole.PcurveValidation");
+ var preflight = BrepExportPreflight.Validate(body);
+ if (!preflight.IsValid)
+ return Failure(string.Join("; ", preflight.Diagnostics.Where(d => d.Severity == BrepExportPreflightSeverity.Error)
+ .Select(d => $"{d.Code}: {d.Message}")), "Brep.CrossHole.Preflight");
+ return KernelResult<BrepBody>.Success(body);
+ }
+
+ private static (LoopId Id, CoedgeId[] Coedges) AddLoop(TopologyBuilder builder, IReadOnlyList<Use> uses)
+ {
+ var loop = builder.AllocateLoopId();
+ var coedges = uses.Select(_ => builder.AllocateCoedgeId()).ToArray();
+ for (var i = 0; i < uses.Count; i++)
+ builder.AddCoedge(new Coedge(coedges[i], uses[i].Edge, loop,
+ coedges[(i + 1) % uses.Count], coedges[(i + uses.Count - 1) % uses.Count], uses[i].Reversed));
+ builder.AddLoop(new Loop(loop, coedges));
+ return (loop, coedges);
+ }
+
+ private static KernelResult<BrepBody> Failure(string message, string source)
+ => KernelResult<BrepBody>.Failure([
+ new KernelDiagnostic(KernelDiagnosticCode.ValidationFailed, KernelDiagnosticSeverity.Error, message, source)]);
+
+ private readonly record struct Use(EdgeId Edge, bool Reversed = false);
+}
diff --git a/Aetheris.Kernel.Core/Geometry/CurveGeometry.cs b/Aetheris.Kernel.Core/Geometry/CurveGeometry.cs
index 593a14e6..355e110e 100644
--- a/Aetheris.Kernel.Core/Geometry/CurveGeometry.cs
+++ b/Aetheris.Kernel.Core/Geometry/CurveGeometry.cs
@@ -17,7 +17,7 @@ public enum CurveGeometryKind
/// </summary>
public sealed record CurveGeometry
{
- private CurveGeometry(CurveGeometryKind kind, Line3Curve? line3, Circle3Curve? circle3, BSpline3Curve? bSpline3, Ellipse3Curve? ellipse3, Hyperbola3Curve? hyperbola3, string? unsupportedKind)
+ private CurveGeometry(CurveGeometryKind kind, Line3Curve? line3, Circle3Curve? circle3, BSpline3Curve? bSpline3, Ellipse3Curve? ellipse3, Hyperbola3Curve? hyperbola3, string? unsupportedKind, QualifiedCylinderIntersectionRepresentation? certifiedIntersection = null)
{
Kind = kind;
Line3 = line3;
@@ -26,6 +26,7 @@ public sealed record CurveGeometry
Ellipse3 = ellipse3;
Hyperbola3 = hyperbola3;
UnsupportedKind = unsupportedKind;
+ CertifiedIntersection = certifiedIntersection;
}
public CurveGeometryKind Kind { get; }
@@ -41,12 +42,24 @@ public sealed record CurveGeometry
public string? UnsupportedKind { get; }
+ /// <summary>
+ /// Exact parent-cylinder intersection and certified realization when this B-spline
+ /// is only a finite representation of an analytic surface-intersection edge.
+ /// </summary>
+ public QualifiedCylinderIntersectionRepresentation? CertifiedIntersection { get; }
+
public static CurveGeometry FromLine(Line3Curve line) => new(CurveGeometryKind.Line3, line, null, null, null, null, null);
public static CurveGeometry FromCircle(Circle3Curve circle) => new(CurveGeometryKind.Circle3, null, circle, null, null, null, null);
public static CurveGeometry FromBSpline(BSpline3Curve curve) => new(CurveGeometryKind.BSpline3, null, null, curve, null, null, null);
+ public static CurveGeometry FromCertifiedIntersection(QualifiedCylinderIntersectionRepresentation representation)
+ {
+ ArgumentNullException.ThrowIfNull(representation);
+ return new(CurveGeometryKind.BSpline3, null, null, representation.Curve, null, null, null, representation);
+ }
+
public static CurveGeometry FromEllipse(Ellipse3Curve ellipse) => new(CurveGeometryKind.Ellipse3, null, null, null, ellipse, null, null);
public static CurveGeometry FromHyperbola(Hyperbola3Curve hyperbola) => new(CurveGeometryKind.Hyperbola3, null, null, null, null, hyperbola, null);
diff --git a/Aetheris.Kernel.Core/Geometry/Curves/CylinderCylinderIntersectionCurve.cs b/Aetheris.Kernel.Core/Geometry/Curves/CylinderCylinderIntersectionCurve.cs
new file mode 100644
index 00000000..becec076
--- /dev/null
+++ b/Aetheris.Kernel.Core/Geometry/Curves/CylinderCylinderIntersectionCurve.cs
@@ -0,0 +1,153 @@
+using Aetheris.Kernel.Core.Diagnostics;
+using Aetheris.Kernel.Core.Geometry.Surfaces;
+using Aetheris.Kernel.Core.Math;
+using Aetheris.Kernel.Core.Numerics;
+using Aetheris.Kernel.Core.Results;
+
+namespace Aetheris.Kernel.Core.Geometry.Curves;
+
+public enum CylinderIntersectionBranch { PositiveCutterAxis, NegativeCutterAxis }
+
+public enum IntersectionCurveSense { Forward, Reverse }
+
+public readonly record struct CylinderIntersectionUv(double U, double V);
+
+/// <summary>
+/// Exact intersection of perpendicular, centerline-crossing cylinders with cutter radius
+/// strictly inside host radius. The parameter runs around the cutter cross-section;
+/// the branch selects the side of the host along the cutter axis. No BRep topology is implied.
+/// </summary>
+public sealed class CylinderCylinderIntersectionCurve
+{
+ private const double MachineEpsilon = 2.2204460492503131e-16d;
+ private readonly Vector3D _x;
+ private readonly Vector3D _y;
+ private readonly Vector3D _z;
+ private readonly double _hostAxialOffset;
+ private readonly double _toolAxialOffset;
+ private readonly double _hostUAtStart;
+ private readonly double _toolUAtStart;
+
+ private CylinderCylinderIntersectionCurve(
+ CylinderSurface host, CylinderSurface tool, Point3D center,
+ CylinderIntersectionBranch branch, ParameterInterval domain,
+ IntersectionCurveSense sense)
+ {
+ Host = host;
+ Tool = tool;
+ Center = center;
+ Branch = branch;
+ Domain = domain;
+ Sense = sense;
+ _x = tool.Axis.ToVector();
+ _z = host.Axis.ToVector();
+ _y = _z.Cross(_x);
+ _hostAxialOffset = (center - host.Origin).Dot(_z);
+ _toolAxialOffset = (center - tool.Origin).Dot(_x);
+ var start = Evaluate(domain.Start);
+ _hostUAtStart = PrincipalAngle(start - host.Origin, host.XAxis, host.YAxis);
+ _toolUAtStart = PrincipalAngle(start - tool.Origin, tool.XAxis, tool.YAxis);
+ }
+
+ public CylinderSurface Host { get; }
+ public CylinderSurface Tool { get; }
+ public Point3D Center { get; }
+ public CylinderIntersectionBranch Branch { get; }
+ public ParameterInterval Domain { get; }
+ public IntersectionCurveSense Sense { get; }
+
+ public static KernelResult<CylinderCylinderIntersectionCurve> Create(
+ CylinderSurface host, CylinderSurface tool, Point3D center,
+ CylinderIntersectionBranch branch, ParameterInterval domain,
+ IntersectionCurveSense sense = IntersectionCurveSense.Forward,
+ ToleranceContext? tolerance = null)
+ {
+ var tol = tolerance ?? ToleranceContext.Default;
+ if (!double.IsFinite(center.X) || !double.IsFinite(center.Y) || !double.IsFinite(center.Z))
+ return Failure("Intersection center must be finite.", "Geometry.CylinderIntersection.NonFiniteCenter");
+ if (domain.End <= domain.Start || domain.End - domain.Start > 2d * double.Pi + tol.Angular)
+ return Failure("Intersection domain must be nonempty and span no more than one revolution.", "Geometry.CylinderIntersection.InvalidDomain");
+ if (!Enum.IsDefined(branch) || !Enum.IsDefined(sense))
+ return Failure("Intersection branch and sense must be recognized values.", "Geometry.CylinderIntersection.InvalidOrientation");
+ var x = tool.Axis.ToVector();
+ var z = host.Axis.ToVector();
+ var scale = double.Max(1d, double.Max(
+ double.Max(double.Abs(center.X), double.Abs(center.Y)),
+ double.Max(double.Abs(center.Z), host.Radius + tool.Radius)));
+ // A model-scale tolerance is too loose for an authority asserting that its
+ // evaluated points lie on both exact surfaces. Admit only numeric alignment.
+ var angularAlignment = double.Min(tol.Angular, 64d * MachineEpsilon);
+ var linearAlignment = double.Min(tol.Linear, 64d * MachineEpsilon * scale);
+ if (double.Abs(x.Dot(z)) > angularAlignment)
+ return Failure("Only perpendicular cylinder axes are admitted.", "Geometry.CylinderIntersection.ObliqueAxes");
+ if (DistanceFromAxis(center, host.Origin, z) > linearAlignment
+ || DistanceFromAxis(center, tool.Origin, x) > linearAlignment)
+ return Failure("Cutter and host centerlines must cross at the declared intersection center.", "Geometry.CylinderIntersection.EccentricAxes");
+ if (tool.Radius >= host.Radius - tol.Linear)
+ return Failure("The cutter radius must remain strictly inside the host radius with linear clearance.", "Geometry.CylinderIntersection.TangentOrOversize");
+ return KernelResult<CylinderCylinderIntersectionCurve>.Success(
+ new CylinderCylinderIntersectionCurve(host, tool, center, branch, domain, sense));
+ }
+
+ public Point3D Evaluate(double t)
+ {
+ CheckParameter(t);
+ var r = Tool.Radius;
+ var y = r * double.Cos(t);
+ var z = r * double.Sin(t);
+ var x = BranchSign * double.Sqrt((Host.Radius * Host.Radius) - (y * y));
+ return Center + (_x * x) + (_y * y) + (_z * z);
+ }
+
+ public Vector3D Derivative(double t)
+ {
+ CheckParameter(t);
+ var r = Tool.Radius;
+ var sin = double.Sin(t);
+ var cos = double.Cos(t);
+ var root = double.Sqrt((Host.Radius * Host.Radius) - (r * r * cos * cos));
+ var dx = BranchSign * r * r * cos * sin / root;
+ return (_x * dx) - (_y * (r * sin)) + (_z * (r * cos));
+ }
+
+ public CylinderIntersectionUv EvaluateHostPcurve(double t)
+ {
+ var point = Evaluate(t);
+ var principal = PrincipalAngle(point - Host.Origin, Host.XAxis, Host.YAxis);
+ // On one branch r < R keeps the angular sweep below pi. Unwrap around the
+ // start point so crossing the host's chosen U seam does not split geometry.
+ var delta = principal - _hostUAtStart;
+ if (delta > double.Pi) delta -= 2d * double.Pi;
+ if (delta < -double.Pi) delta += 2d * double.Pi;
+ return new CylinderIntersectionUv(_hostUAtStart + delta,
+ _hostAxialOffset + Tool.Radius * double.Sin(t));
+ }
+
+ public CylinderIntersectionUv EvaluateToolPcurve(double t)
+ {
+ var point = Evaluate(t);
+ return new CylinderIntersectionUv(_toolUAtStart + (t - Domain.Start),
+ (point - Tool.Origin).Dot(_x));
+ }
+
+ private double BranchSign => Branch == CylinderIntersectionBranch.PositiveCutterAxis ? 1d : -1d;
+
+ private void CheckParameter(double t)
+ {
+ if (!double.IsFinite(t) || t < Domain.Start || t > Domain.End)
+ throw new ArgumentOutOfRangeException(nameof(t), "Parameter must lie in the intersection domain.");
+ }
+
+ private static double PrincipalAngle(Vector3D offset, Direction3D x, Direction3D y)
+ => double.Atan2(offset.Dot(y.ToVector()), offset.Dot(x.ToVector()));
+
+ private static double DistanceFromAxis(Point3D point, Point3D origin, Vector3D axis)
+ {
+ var offset = point - origin;
+ return (offset - axis * offset.Dot(axis)).Length;
+ }
+
+ private static KernelResult<CylinderCylinderIntersectionCurve> Failure(string message, string source)
+ => KernelResult<CylinderCylinderIntersectionCurve>.Failure([
+ new KernelDiagnostic(KernelDiagnosticCode.InvalidArgument, KernelDiagnosticSeverity.Error, message, source)]);
+}
diff --git a/Aetheris.Kernel.Core/Geometry/Curves/CylinderIntersectionCurveRealizer.cs b/Aetheris.Kernel.Core/Geometry/Curves/CylinderIntersectionCurveRealizer.cs
new file mode 100644
index 00000000..56ea8244
--- /dev/null
+++ b/Aetheris.Kernel.Core/Geometry/Curves/CylinderIntersectionCurveRealizer.cs
@@ -0,0 +1,128 @@
+using Aetheris.Kernel.Core.Diagnostics;
+using Aetheris.Kernel.Core.Math;
+using Aetheris.Kernel.Core.Numerics;
+using Aetheris.Kernel.Core.Results;
+
+namespace Aetheris.Kernel.Core.Geometry.Curves;
+
+/// <summary>
+/// Finite, non-rational representation subordinate to an exact cylinder intersection.
+/// The bound follows the cubic Hermite remainder on every adaptively selected span.
+/// It bounds distance to the exact curve, and therefore distance to each parent surface
+/// and mismatch with either exact lifted pcurve, in real arithmetic.
+/// </summary>
+public sealed record QualifiedCylinderIntersectionRepresentation(
+ CylinderCylinderIntersectionCurve Authority,
+ BSpline3Curve Curve,
+ double RequestedToleranceMm,
+ double AnalyticErrorBoundMm,
+ double NumericalAllowanceMm,
+ int SegmentCount)
+{
+ public double CertifiedDeviationBoundMm => AnalyticErrorBoundMm + NumericalAllowanceMm;
+}
+
+public static class CylinderIntersectionCurveRealizer
+{
+ private const int MaxSegments = 16_384;
+ private const double MachineEpsilon = 2.2204460492503131e-16d;
+
+ public static KernelResult<QualifiedCylinderIntersectionRepresentation> Realize(
+ CylinderCylinderIntersectionCurve authority, ToleranceContext? tolerance = null)
+ {
+ ArgumentNullException.ThrowIfNull(authority);
+ var tol = tolerance ?? ToleranceContext.Default;
+ var scale = double.Max(1d, double.Max(
+ double.Max(double.Abs(authority.Center.X), double.Abs(authority.Center.Y)),
+ double.Max(double.Abs(authority.Center.Z), authority.Host.Radius + authority.Tool.Radius)));
+ // Keep roundoff separate from the analytic Hermite remainder. Large coordinates
+ // whose floating-point allowance consumes the tolerance fail explicitly.
+ var numericalAllowance = 256d * MachineEpsilon * scale;
+ var interpolationBudget = tol.Linear - numericalAllowance;
+ if (interpolationBudget <= 0d)
+ return Failure("Coordinate scale consumes the linear tolerance before interpolation.",
+ "Geometry.CylinderIntersection.NumericToleranceExhausted");
+
+ var spans = new List<BezierSpan>();
+ var pending = new Stack<(double Start, double End)>();
+ pending.Push((authority.Domain.Start, authority.Domain.End));
+ while (pending.Count > 0)
+ {
+ var (start, end) = pending.Pop();
+ var bound = HermiteErrorBound(authority.Host.Radius, authority.Tool.Radius, start, end);
+ if (!double.IsFinite(bound))
+ return Failure("The intersection remainder bound is nonfinite.",
+ "Geometry.CylinderIntersection.NonFiniteBound");
+ if (bound > interpolationBudget)
+ {
+ if (spans.Count + pending.Count + 2 > MaxSegments || end - start <= 1e-12d)
+ return Failure("Adaptive realization exceeded its bounded segment budget.",
+ "Geometry.CylinderIntersection.RefinementLimit");
+ var mid = start + ((end - start) * 0.5d);
+ pending.Push((mid, end));
+ pending.Push((start, mid));
+ continue;
+ }
+
+ var h = end - start;
+ var p0 = authority.Evaluate(start);
+ var p3 = authority.Evaluate(end);
+ spans.Add(new BezierSpan(start, end, bound,
+ p0, p0 + authority.Derivative(start) * (h / 3d),
+ p3 - authority.Derivative(end) * (h / 3d), p3));
+ }
+
+ var controls = new List<Point3D>(spans.Count * 4);
+ var knots = new List<double>(spans.Count + 1);
+ var multiplicities = new List<int>(spans.Count + 1);
+ knots.Add(spans[0].Start);
+ multiplicities.Add(4);
+ foreach (var span in spans)
+ {
+ controls.Add(span.P0);
+ controls.Add(span.P1);
+ controls.Add(span.P2);
+ controls.Add(span.P3);
+ knots.Add(span.End);
+ multiplicities.Add(4);
+ }
+
+ var curve = new BSpline3Curve(3, controls, multiplicities, knots,
+ "UNSPECIFIED", false, false, "UNSPECIFIED");
+ return KernelResult<QualifiedCylinderIntersectionRepresentation>.Success(new(
+ authority, curve, tol.Linear, spans.Max(span => span.Bound),
+ numericalAllowance, spans.Count));
+ }
+
+ private static double HermiteErrorBound(double hostRadius, double toolRadius, double start, double end)
+ {
+ var r2 = toolRadius * toolRadius;
+ var maxCosSq = double.Max(double.Pow(double.Cos(start), 2d), double.Pow(double.Cos(end), 2d));
+ if (double.Ceiling(start / double.Pi) * double.Pi <= end)
+ maxCosSq = 1d;
+ var minG = hostRadius * hostRadius - r2 * maxCosSq;
+ if (minG <= 0d) return double.PositiveInfinity;
+ var sqrtG = double.Sqrt(minG);
+ var g3 = minG * sqrtG;
+ var g5 = minG * g3;
+ var g7 = minG * g5;
+ // For x=sqrt(g), g=R²-r²cos²(t):
+ // |g'|<=r², |g''|<=2r², |g'''|<=4r², |g''''|<=8r².
+ // The chain rule bounds |x''''| by the expression below. Both remaining
+ // coordinates are r*cos(t), r*sin(t), with fourth derivatives <=r.
+ var xFourth = (15d * double.Pow(r2, 4d) / (16d * g7))
+ + (4.5d * double.Pow(r2, 3d) / g5)
+ + (7d * r2 * r2 / g3)
+ + (4d * r2 / sqrtG);
+ var vectorFourth = double.Sqrt(xFourth * xFourth + 2d * toolRadius * toolRadius);
+ var h = end - start;
+ return vectorFourth * double.Pow(h, 4d) / 384d;
+ }
+
+ private static KernelResult<QualifiedCylinderIntersectionRepresentation> Failure(string message, string source)
+ => KernelResult<QualifiedCylinderIntersectionRepresentation>.Failure([
+ new KernelDiagnostic(KernelDiagnosticCode.InvalidArgument, KernelDiagnosticSeverity.Error, message, source)]);
+
+ private readonly record struct BezierSpan(double Start, double End, double Bound,
+ Point3D P0, Point3D P1, Point3D P2, Point3D P3);
+}
diff --git a/Aetheris.Kernel.Core/Geometry/Curves/CylinderIntersectionPcurveRealizer.cs b/Aetheris.Kernel.Core/Geometry/Curves/CylinderIntersectionPcurveRealizer.cs
new file mode 100644
index 00000000..4a5e033b
--- /dev/null
+++ b/Aetheris.Kernel.Core/Geometry/Curves/CylinderIntersectionPcurveRealizer.cs
@@ -0,0 +1,174 @@
+using Aetheris.Kernel.Core.Diagnostics;
+using Aetheris.Kernel.Core.Math;
+using Aetheris.Kernel.Core.Numerics;
+using Aetheris.Kernel.Core.Results;
+
+namespace Aetheris.Kernel.Core.Geometry.Curves;
+
+/// <summary>Finite UV representations subordinate to one exact cylinder intersection.</summary>
+public sealed record QualifiedCylinderIntersectionPcurves(
+ QualifiedCylinderIntersectionRepresentation Edge,
+ BSpline3Curve Host,
+ BSpline3Curve Tool,
+ double HostLiftBoundMm,
+ double ToolLiftBoundMm,
+ double NumericalAllowanceMm,
+ int HostSegmentCount,
+ int ToolSegmentCount)
+{
+ public double HostEdgeMismatchBoundMm => Edge.CertifiedDeviationBoundMm + HostLiftBoundMm + NumericalAllowanceMm;
+ public double ToolEdgeMismatchBoundMm => Edge.CertifiedDeviationBoundMm + ToolLiftBoundMm + NumericalAllowanceMm;
+}
+
+/// <summary>
+/// Adaptive cubic Hermite pcurves. The host angular fourth derivative is bounded
+/// using its rotated ±asin((r/R)cos(t)) form; the cutter angular coordinate is
+/// affine and its axial fourth derivative shares the exact 3D x-coordinate bound.
+/// </summary>
+public static class CylinderIntersectionPcurveRealizer
+{
+ private const int MaxSegments = 16_384;
+ private const double MachineEpsilon = 2.2204460492503131e-16d;
+
+ public static KernelResult<QualifiedCylinderIntersectionPcurves> Realize(
+ QualifiedCylinderIntersectionRepresentation edge, ToleranceContext? tolerance = null)
+ {
+ ArgumentNullException.ThrowIfNull(edge);
+ var tol = tolerance ?? ToleranceContext.Default;
+ var authority = edge.Authority;
+ var scale = double.Max(1d, double.Max(
+ double.Max(double.Abs(authority.Center.X), double.Abs(authority.Center.Y)),
+ double.Max(double.Abs(authority.Center.Z), authority.Host.Radius + authority.Tool.Radius)));
+ var numericalAllowance = 512d * MachineEpsilon * scale;
+ var budget = tol.Linear - edge.CertifiedDeviationBoundMm - numericalAllowance;
+ if (budget <= 0d)
+ return Failure("The certified 3D edge consumes the pcurve mismatch tolerance.",
+ "Geometry.CylinderIntersection.PcurveToleranceExhausted");
+
+ var host = Build(authority, host: true, budget);
+ if (!host.IsSuccess) return KernelResult<QualifiedCylinderIntersectionPcurves>.Failure(host.Diagnostics);
+ var tool = Build(authority, host: false, budget);
+ if (!tool.IsSuccess) return KernelResult<QualifiedCylinderIntersectionPcurves>.Failure(tool.Diagnostics);
+ return KernelResult<QualifiedCylinderIntersectionPcurves>.Success(new(
+ edge, host.Value.Curve, tool.Value.Curve, host.Value.LiftBound,
+ tool.Value.LiftBound, numericalAllowance, host.Value.Segments, tool.Value.Segments));
+ }
+
+ private static KernelResult<(BSpline3Curve Curve, double LiftBound, int Segments)> Build(
+ CylinderCylinderIntersectionCurve authority, bool host, double budget)
+ {
+ var spans = new List<Span>();
+ var pending = new Stack<(double Start, double End)>();
+ pending.Push((authority.Domain.Start, authority.Domain.End));
+ while (pending.Count > 0)
+ {
+ var (start, end) = pending.Pop();
+ var bound = host
+ ? HostLiftBound(authority.Host.Radius, authority.Tool.Radius, start, end)
+ : ToolLiftBound(authority.Host.Radius, authority.Tool.Radius, start, end);
+ if (!double.IsFinite(bound))
+ return FailureSpan("Pcurve lift bound is nonfinite.", "Geometry.CylinderIntersection.NonFinitePcurveBound");
+ if (bound > budget)
+ {
+ if (spans.Count + pending.Count + 2 > MaxSegments || end - start <= 1e-12d)
+ return FailureSpan("Pcurve refinement exceeded its bounded segment budget.",
+ "Geometry.CylinderIntersection.PcurveRefinementLimit");
+ var mid = start + (end - start) * 0.5d;
+ pending.Push((mid, end));
+ pending.Push((start, mid));
+ continue;
+ }
+ var a = Evaluate(authority, host, start);
+ var b = Evaluate(authority, host, end);
+ var h = (end - start) / 3d;
+ spans.Add(new Span(start, end, bound, a, a + Derivative(authority, host, start) * h,
+ b - Derivative(authority, host, end) * h, b));
+ }
+
+ var controls = new List<Point3D>(spans.Count * 4);
+ var knots = new List<double>(spans.Count + 1) { spans[0].Start };
+ var multiplicities = new List<int>(spans.Count + 1) { 4 };
+ foreach (var span in spans)
+ {
+ controls.AddRange([span.P0, span.P1, span.P2, span.P3]);
+ knots.Add(span.End);
+ multiplicities.Add(4);
+ }
+ return KernelResult<(BSpline3Curve, double, int)>.Success((
+ new BSpline3Curve(3, controls, multiplicities, knots,
+ "UNSPECIFIED", false, false, "UNSPECIFIED"),
+ spans.Max(span => span.Bound), spans.Count));
+ }
+
+ private static Point3D Evaluate(CylinderCylinderIntersectionCurve curve, bool host, double t)
+ {
+ var uv = host ? curve.EvaluateHostPcurve(t) : curve.EvaluateToolPcurve(t);
+ return new Point3D(uv.U, uv.V, 0d);
+ }
+
+ private static Vector3D Derivative(CylinderCylinderIntersectionCurve curve, bool host, double t)
+ {
+ var p = curve.Evaluate(t);
+ var dp = curve.Derivative(t);
+ if (!host)
+ return new Vector3D(1d, dp.Dot(curve.Tool.Axis.ToVector()), 0d);
+ var offset = p - curve.Host.Origin;
+ var x = curve.Host.XAxis.ToVector();
+ var y = curve.Host.YAxis.ToVector();
+ var a = offset.Dot(x);
+ var b = offset.Dot(y);
+ var da = dp.Dot(x);
+ var db = dp.Dot(y);
+ return new Vector3D((a * db - b * da) / (curve.Host.Radius * curve.Host.Radius),
+ dp.Dot(curve.Host.Axis.ToVector()), 0d);
+ }
+
+ private static double HostLiftBound(double radius, double toolRadius, double start, double end)
+ {
+ var q = toolRadius / radius;
+ var maxS = q * double.Sqrt(MaxCosSquared(start, end));
+ var oneMinus = 1d - maxS * maxS;
+ if (oneMinus <= 0d) return double.PositiveInfinity;
+ var sqrt = double.Sqrt(oneMinus);
+ var h1 = 1d / sqrt;
+ var h2 = maxS / (oneMinus * sqrt);
+ var h3 = (1d + 2d * maxS * maxS) / (oneMinus * oneMinus * sqrt);
+ var h4 = maxS * (9d + 6d * maxS * maxS) / (oneMinus * oneMinus * oneMinus * sqrt);
+ var uFourth = h4 * double.Pow(q, 4d) + 6d * h3 * double.Pow(q, 3d)
+ + 7d * h2 * q * q + h1 * q;
+ return (radius * uFourth + toolRadius) * double.Pow(end - start, 4d) / 384d;
+ }
+
+ private static double ToolLiftBound(double radius, double toolRadius, double start, double end)
+ {
+ var r2 = toolRadius * toolRadius;
+ var minG = radius * radius - r2 * MaxCosSquared(start, end);
+ if (minG <= 0d) return double.PositiveInfinity;
+ var sqrtG = double.Sqrt(minG);
+ var g3 = minG * sqrtG;
+ var g5 = minG * g3;
+ var g7 = minG * g5;
+ var fourth = (15d * double.Pow(r2, 4d) / (16d * g7))
+ + (4.5d * double.Pow(r2, 3d) / g5)
+ + (7d * r2 * r2 / g3)
+ + (4d * r2 / sqrtG);
+ return fourth * double.Pow(end - start, 4d) / 384d;
+ }
+
+ private static double MaxCosSquared(double start, double end)
+ {
+ var result = double.Max(double.Pow(double.Cos(start), 2d), double.Pow(double.Cos(end), 2d));
+ return double.Ceiling(start / double.Pi) * double.Pi <= end ? 1d : result;
+ }
+
+ private static KernelResult<QualifiedCylinderIntersectionPcurves> Failure(string message, string source)
+ => KernelResult<QualifiedCylinderIntersectionPcurves>.Failure([
+ new KernelDiagnostic(KernelDiagnosticCode.InvalidArgument, KernelDiagnosticSeverity.Error, message, source)]);
+
+ private static KernelResult<(BSpline3Curve, double, int)> FailureSpan(string message, string source)
+ => KernelResult<(BSpline3Curve, double, int)>.Failure([
+ new KernelDiagnostic(KernelDiagnosticCode.InvalidArgument, KernelDiagnosticSeverity.Error, message, source)]);
+
+ private readonly record struct Span(double Start, double End, double Bound,
+ Point3D P0, Point3D P1, Point3D P2, Point3D P3);
+}
diff --git a/Aetheris.Kernel.Core/Step242/Step242Exporter.cs b/Aetheris.Kernel.Core/Step242/Step242Exporter.cs
index 5d4ec413..6f70582c 100644
--- a/Aetheris.Kernel.Core/Step242/Step242Exporter.cs
+++ b/Aetheris.Kernel.Core/Step242/Step242Exporter.cs
@@ -1039,7 +1039,14 @@ public static class Step242Exporter
bsplineIds[edgeId] = bsplineId;
}
- geometryCurveId = bsplineId;
+ var trim = edgeBinding.TrimInterval.Value;
+ geometryCurveId = double.Abs(trim.Start - spline.DomainStart) <= 1e-12d
+ && double.Abs(trim.End - spline.DomainEnd) <= 1e-12d
+ ? bsplineId
+ : writer.AddEntity("TRIMMED_CURVE", "$", Step242TextWriter.Ref(bsplineId),
+ Step242TextWriter.List($"PARAMETER_VALUE({Step242TextWriter.Number(trim.Start)})"),
+ Step242TextWriter.List($"PARAMETER_VALUE({Step242TextWriter.Number(trim.End)})"),
+ Step242TextWriter.BooleanLogical(true), Step242TextWriter.Enum("PARAMETER"));
}
else if (curve.Kind == CurveGeometryKind.Ellipse3 && curve.Ellipse3 is Ellipse3Curve ellipse)
{
diff --git a/Aetheris.Kernel.Core/Step242/Step242Importer.cs b/Aetheris.Kernel.Core/Step242/Step242Importer.cs
index d010475e..250668af 100644
--- a/Aetheris.Kernel.Core/Step242/Step242Importer.cs
+++ b/Aetheris.Kernel.Core/Step242/Step242Importer.cs
@@ -1103,7 +1103,7 @@ public static class Step242Importer
return KernelResult<(CurveGeometry CurveGeometry, ParameterInterval TrimInterval)>.Success((
CurveGeometry.FromBSpline(splineResult.Value),
- new ParameterInterval(splineResult.Value.DomainStart, splineResult.Value.DomainEnd)));
+ explicitTrim ?? new ParameterInterval(splineResult.Value.DomainStart, splineResult.Value.DomainEnd)));
}
if (string.Equals(curveEntity.Name, "AETHERIS_PLANAR_UNSUPPORTED_CURVE", StringComparison.OrdinalIgnoreCase))
diff --git a/docs/release/BREP-CROSSHOLE-X1.md b/docs/release/BREP-CROSSHOLE-X1.md
new file mode 100644
index 00000000..38a65808
--- /dev/null
+++ b/docs/release/BREP-CROSSHOLE-X1.md
@@ -0,0 +1,42 @@
+# BREP-CROSSHOLE-X1 — seam-aware diametral cross-hole topology
+
+**Executive verdict: Accepted for one solid cylindrical stock cross-hole.** The kernel now builds a closed, oriented BRep from the qualified perpendicular cylinder-intersection authority. This is a bounded constructive operation for a finite solid cylinder with one through-diameter hole. It does not introduce a general Boolean, Firmament feature, Hollow support, pattern, or ClevisPin template.
+
+## Construction and admission
+
+`BrepDiametralCrossHole.Build` accepts an analytic host cylinder, finite axial length, perpendicular cutter direction, positive cutter radius strictly smaller than the host radius, and an axial hole-center distance from the host origin. It places the cutter axis through the host centerline. The full cutter circle must clear both stock ends. Invalid dimensions, end collisions, oblique axes, and tangent/oversize radii return explicit diagnostics. Eccentric placement is absent from this API, so it cannot accidentally be admitted.
+
+The builder uses the two existing `CylinderCylinderIntersectionCurve` branches. Each branch retains the exact evaluator and derivative beside a certified non-rational cubic B-spline 3D representation. Its finite host and tool pcurves are built by `CylinderIntersectionPcurveRealizer` from the exact pcurve evaluators. Cubic Hermite bounds are checked against the same linear tolerance, including the 3D edge deviation and numerical allowance. `BrepPcurveValidator` checks all 16 coedge uses at 129 samples; its sampling is validation, never topology construction.
+
+The host seam is chosen on the clear radial sector between the two openings, independent of the caller's cylinder X-axis. Consequently neither intersection branch crosses the host's resulting UV seam. The cutter seam is one geometric line edge with two face-local coedge pcurves at U=0 and U=2π. Each closed intersection branch is divided at t=π into two topological edges, because the export preflight rejects a non-conic self-loop edge. Both halves keep the same exact branch authority and certified 3D spline, with distinct trim intervals. No sampled vertices or duplicate edge geometry authority are introduced.
+
+## Face and loop topology
+
+The host cylindrical face has one outer loop and two inner loops for entry and exit. One cutter-cylinder wall face connects them; the planar end caps close the stock. The cutter wall face has the opposite surface sense to the tool cylinder, expressing the void. Every edge has exactly two coedge uses. The canonical and clevis-ratio fixtures each contain **4 faces, 8 edges, 6 vertices, 16 coedges, 2 opening loops, and 4 intersection edge segments**. There are no intersection seam splits after canonicalization; the cutter seam is represented once geometrically with two UV uses.
+
+The builder runs binding validation, full coedge pcurve validation, and strict export preflight before returning. Focused tests also check shell enclosure, orientation, positive signed volume, and that volume is less than the uncut cylinder's. The mass-property value is a tessellated sanity estimate, not an exact occupied-volume measurement. The dedicated BRep display tessellator produces nonempty patches for all four faces. SurfaceMeshIR still explicitly rejects trim topology on a cylindrical face; this separate rendering route is not claimed for the cross-hole.
+
+## Qualification witnesses
+
+The canonical fixture uses R=2 mm, r=0.6 mm, L=10 mm, and center position 5 mm. Small and large valid cutter radii of 0.2 and 1.8 mm pass the same topology checks. The clevis-ratio kernel fixture uses host R=0.79375 mm and cutter r=0.5953125 mm; it is the **hole ratio only**, not a reconstructed clevis pin. Tests also move the hole to 3 and 7 mm, rotate its direction around the host, and use a translated host with a world-Y axis. Invalid zero radius, end collision, oblique axis, tangent radius, and oversize radius fail.
+
+For the clevis ratio, the prior 3D realization has 128 cubic spans (512 control points) and a 2.293e-7 mm certified deviation bound. The finite pcurves use 160 host and 128 tool spans; total edge/host mismatch bound is 9.523e-7 mm and edge/tool mismatch bound is 4.582e-7 mm, each below the default 1e-6 mm tolerance. The measured sampled lift deviations were smaller; the bounds are the admission authority. The intersection remains exact in kernel metadata, while STEP carries its finite certified representation.
+
+## STEP and inspection
+
+The exporter now writes `TRIMMED_CURVE` for a B-spline edge whose trim interval is shorter than the underlying spline domain; the importer preserves that interval. Without this, the second half of each opening was exported as the first half and reimport failed cylindrical inner-loop containment. The canonical STEP now exports and reimports with two opening roles, two analytic cylindrical faces, positive oriented volume, and an enclosed shell.
+
+`Aetheris.CLI analyze` on the local generated STEP reports one enclosed manifold body, 4 faces, 8 edges, 6 vertices, 2 plane and 2 cylinder surfaces, 4 B-spline edges, 16 pcurves, and two seam pcurve pairs. The bounding box is [-2,2] × [-2,2] × [-5,5] mm. STEP import currently reports its unit basis as assumed, so the millimeter statement comes from the authored kernel fixture and exporter setup. The `wireframe` CLI projection visibly shows both circular openings connected by the transverse wall. Local ignored debug outputs are `artifacts/local/crosshole-x1/canonical.step`, `canonical.svg`, and a browser-rendered `canonical.png` in the same directory.
+
+Reproduce the focused checks:
+
+```text
+dotnet test Aetheris.Kernel.Core.Tests --no-restore --filter "FullyQualifiedName~BrepDiametralCrossHoleTests|FullyQualifiedName~CylinderCylinderIntersectionCurveTests" -m:1
+dotnet run --project Aetheris.CLI -- analyze artifacts/local/crosshole-x1/canonical.step --json
+```
+
+The STEP file is generated by the focused round-trip test when `AETHERIS_CROSSHOLE_STEP_OUTPUT` names the desired local file. No source STEP or mesh Boolean is used to construct the body.
+
+## Build and regression
+
+On the 2026-09-23 local Windows .NET 10 run, `dotnet build Aetheris.slnx --no-restore -m:1 --verbosity quiet` completed with zero errors and seven existing WebAssembly warnings. The focused intersection and cross-hole selection passed **21/21** after the final assertion edit. The serial full solution run passed **3,874** tests and failed one existing `SurfaceMeshIrTests.ThroughHolePlate_UsesMultiLoopPlanarBands_AndLowersToWatertightMesh` assertion: the planar box-hole tessellator produced 87 cells where the test expects 90. That test was already failing in the preceding geometry-only qualification; it does not exercise the new cross-hole path. The full suite is therefore not green.
diff --git a/docs/release/GEOM-CROSSHOLE-X0.md b/docs/release/GEOM-CROSSHOLE-X0.md
new file mode 100644
index 00000000..6a49d28a
--- /dev/null
+++ b/docs/release/GEOM-CROSSHOLE-X0.md
@@ -0,0 +1,62 @@
+# GEOM-CROSSHOLE-X0 — qualification record
+
+**Executive verdict: Blocked (honest stop).** Aetheris does not currently construct an exact diametral cylindrical cross-hole through solid or Hollow cylindrical stock. The supplied clevis pin is a valid reference, but importing it is not an authored reconstruction. No CrossHole feature, ClevisPin template, barrel-vent fixture, or STEP export is claimed by this record. A subsequent [intersection-curve qualification](GEOM-INTERSECTION-CURVE-X0.md) added exact curve authority and a certified finite 3D representation; BRep cutting and STEP qualification remain open.
+
+## Supported case requested
+
+The intended X0 primitive is a through-diameter cut by an analytic cylinder whose axis passes through and is perpendicular to the host cylinder axis. An admitted host needs an analytic axis, radius and axial bounds; a Hollow host also needs an analytic inner radius. The hole radius must be positive and smaller than the relevant host radius, with enough axial clearance from each end. Eccentric, tangent, oversize, end-intersecting and oblique placements require explicit diagnostics. Multiple radial holes may be admitted only after the one-hole topology and seams work.
+
+## Exact intersection and topology requirement
+
+For a host of radius `R` about `Z`, a perpendicular cutter of radius `r` about `X`, and hole center `z0`, the two surfaces meet where
+
+```text
+x² + y² = R²
+y² + (z - z0)² = r²
+```
+
+One exact parameterization of each side of the outer host wall is
+
+```text
+y(t) = r cos(t)
+z(t) = z0 + r sin(t)
+x(t) = ±sqrt(R² - r² cos²(t)), 0 ≤ t < 2π
+```
+
+The host pcurve is `(atan2(y,x), z)` in a compatible cylinder frame; the cutter pcurve follows from its own angular frame and `x(t)`. Both must preserve the same 3D edge, sense and periodic equivalence at seams. A Hollow tube additionally intersects the cutter with its inner cylinder, yielding separate inner and outer opening loops on both sides of the diameter. These are equations for the required construction, **not implemented BRep edges**.
+
+This unequal-radius intersection is not a line, circle, ellipse, hyperbola or finite polynomial B-spline segment. The reference has `R = 0.79375 mm` and `r = 0.5953125 mm`. Fitting sampled points to a spline, or tessellating the loops, would not meet the requested exactness. STEP's `intersection_curve` describes an intersection associated with two surfaces but still requires a `curve_3d` representation; naming that entity alone does not fill the missing exact curve representation. See the [ISO 10303-42 geometry schema](https://ap238.org/SMRL_v8_final/data/resource_docs/geometric_and_topological_representation/sys/4_schema.htm) and the [AP242 entity description](https://www.steptools.com/stds/stp_aim/html/t_intersection_curve.html).
+
+## Current Aetheris boundary
+
+`BrepBooleanSafeCompositionGraphValidator.TryValidateCylinderRootSubtract` admits only world-Z aligned root and tool cylinders, reporting `BrepBoolean.AnalyticHole.AxisNotAligned` for a transverse tool. `CurveGeometry` can now retain exact cylinder-intersection authority beside a certified finite B-spline, while `PcurveGeometryKind` still has no analytic cross-cylinder relation or certified finite realization. There is no builder for the required cross-hole topology, and `Step242Exporter` has no qualified cross-hole edge to serialize. The existing cylindrical Perforation lowering therefore reports `perforation-cylindrical-topology-unavailable`, consistently with `docs/public/firmament/perforation.md`.
+
+Making the bounded primitive real now requires integrating the exact intersection authority and its certified finite representation with BRep edges, finite pcurves on both analytic surfaces, seam-aware topology validation, STEP export/import and display tessellation. The current route cannot meet the requested exactness by changing only the Boolean admission check. Adding an unqualified feature or wrapping sampled curves in analytic cylindrical faces would create an invalid success signal, so no production CrossHole path exists.
+
+## Supplied clevis pin reference
+
+`Aetheris.CLI analyze` imported the user-supplied `98306A316_Carbon Steel Clevis Pin.STEP` as one enclosed manifold with 19 faces, 48 edges and 30 vertices. Analytic face inspection gives these dimensions in the imported millimeter coordinates:
+
+| Measurement | Reference |
+| --- | ---: |
+| Shank diameter | 1.5875 mm |
+| Head diameter | 3.175 mm |
+| Head thickness | 1.5875 mm |
+| Overall axial length | 30.95625 mm |
+| Tip-to-head underside | 29.36875 mm |
+| Transverse hole diameter | 1.190625 mm |
+| Hole center from shank tip | 1.7859375 mm |
+
+The reference also has 4 B-spline faces and 20 B-spline curves; its source topology is not an exact-construction substitute. The CLI reports millimeters but marks its STEP unit basis as assumed, because import does not yet preserve the source unit declaration. The STEP file declares inch units; the converted dimensions above are consistent with that declaration. These measurements would be suitable parameters for a **McMaster clevis pin witness**, but do not establish coverage of a clevis-pin standard family.
+
+Reproduce the read-only inspection with:
+
+```text
+dotnet run --project Aetheris.CLI -- analyze "<path to supplied clevis-pin STEP>" --json
+```
+
+## Qualification status
+
+There is no authored solid cross-hole, Hollow cross-hole, ClevisPin template, cylindrical Perforation witness, or cross-hole STEP round trip to test. The 1/8/32-hole performance measurements are consequently unavailable. Planar Perforation remains separately qualified in `GEOM-PERFORATION-X0.md`; that qualification does not imply cylindrical support. A future acceptance run must verify exact curves and pcurves on both surfaces, deterministic seam crossings, manifold topology, semantic wall/source identity, solid and Hollow cases, controlled invalid-placement diagnostics, production STEP reimport, and a dimensional comparison to this reference.
+
+On the 2026-09-23 local Windows .NET 10 run, `dotnet build Aetheris.slnx --no-restore -m:1` passed with seven WebAssembly warnings. The serial `dotnet test Aetheris.slnx --no-build --no-restore -m:1 --verbosity quiet` run passed every project suite except one existing kernel tessellation assertion. `SurfaceMeshIrTests.ThroughHolePlate_UsesMultiLoopPlanarBands_AndLowersToWatertightMesh` expected 90 planar cells and got 87; the isolated test reproduced the same failure. This was present in the prior `GEOM-PERFORATION-X0` qualification and does not exercise a cross-hole implementation. The full solution test result is therefore **not green**.
diff --git a/docs/release/GEOM-INTERSECTION-CURVE-X0.md b/docs/release/GEOM-INTERSECTION-CURVE-X0.md
new file mode 100644
index 00000000..ad6e6a8d
--- /dev/null
+++ b/docs/release/GEOM-INTERSECTION-CURVE-X0.md
@@ -0,0 +1,45 @@
+# GEOM-INTERSECTION-CURVE-X0 — qualification record
+
+**Downstream status (BREP-CROSSHOLE-X1):** The subsequent [solid cross-hole topology milestone](BREP-CROSSHOLE-X1.md) now realizes finite host/tool pcurves and builds one closed solid-cylinder cross-hole BRep with a STEP round trip. The historical X0 verdict and measurements below remain the record of the earlier geometry-only milestone. Hollow, semantic features, the full clevis witness, and cylindrical Perforation remain outside this topology milestone.
+
+**Executive verdict: Meaningful progression.** Aetheris now has a bounded first-class exact authority for the two branches of a perpendicular, diametral cylinder-cylinder intersection and an adaptively refined, non-rational cubic B-spline representation with an analytic deviation bound. The authority supplies 3D evaluation, derivative, and both analytic cylinder pcurves. It can be retained alongside the finite curve in `CurveGeometry`. Cross-hole BRep topology, finite pcurve serialization, STEP export of a cross-hole, Solid/Hollow construction, Firmament semantics, the clevis pin, and cylindrical Perforation are **not implemented**; the original CrossHole milestone is not accepted.
+
+## Exact authority and admission
+
+`CylinderCylinderIntersectionCurve` owns the host and tool `CylinderSurface` values, their centerline intersection, explicit positive/negative cutter-axis branch, parameter domain, and sense. The admitted axes must be perpendicular and meet at the declared center to numerical alignment. The cutter radius must stay inside the host radius with linear clearance. Oblique, eccentric, tangent/oversize and invalid-domain inputs fail with distinct diagnostics. This is the bounded diametral case, not a general surface-intersection solver.
+
+In the host/cutter orthonormal frame the exact evaluator uses `y=r cos(t)`, `z=r sin(t)`, `x=±sqrt(R²-r² cos²(t))`. Its derivative is analytic. The host pcurve takes the host cylinder's angular coordinate and axial coordinate, unwrapping relative to the domain start; a branch sweeps less than π while `r<R`, so this is deterministic across the chosen host seam. The cutter pcurve advances its angular coordinate by `t-start` and uses the evaluated cutter-axis coordinate. Both lift to the same exact 3D locus within floating-point tolerance. The two branch identities do not depend on BRep face order.
+
+## Finite representation and error contract
+
+`CylinderIntersectionCurveRealizer` builds cubic Hermite Bézier spans from exact endpoint positions and derivatives, then stores them as a degree-3 non-rational `BSpline3Curve`. It subdivides a span only when its bound exceeds the remaining linear-tolerance budget; refinement has an explicit segment cap and controlled failure. The exact authority is retained in `QualifiedCylinderIntersectionRepresentation` and by `CurveGeometry.FromCertifiedIntersection`; the spline remains a representation, not the geometric authority.
+
+The cubic Hermite remainder on a span of width `h` is at most `M₄ h⁴/384`, where `M₄` bounds the fourth derivative of the exact 3D curve. The implementation bounds derivatives of `g(t)=R²-r²cos²(t)` and `sqrt(g)` using the minimum `g` over that span. It combines the analytic remainder with a separate, scale-dependent floating-point allowance of `256 ε scale`, where `ε=2.2204460492503131e-16`. Admission requires their sum to fit the requested `ToleranceContext.Linear` (default **1e-6 mm**). The analytic term is a mathematical bound in real arithmetic; the floating-point allowance is an engineering safeguard, not interval-arithmetic proof of every machine operation. Because the exact curve lies on both cylinders and is the lift of both analytic pcurves, the same positional bound applies to surface distance and 3D/exact-pcurve mismatch. Finite BRep pcurves have not yet been realized.
+
+## Focused measurements
+
+The focused tests use a host radius of `0.79375 mm`, including the supplied McMaster clevis-pin hole radius `0.5953125 mm`. Each row samples 2,049 parameters after constructing the analytic bound. Values below are millimeters except counts.
+
+| Cutter radius | Bézier spans | 3D controls | Bound incl. numeric allowance | Sampled 3D deviation | Host residual | Tool residual |
+| ---: | ---: | ---: | ---: | ---: | ---: | ---: |
+| 0.1 | 32 | 128 | 5.836e-7 | 4.330e-7 | 1.892e-7 | 3.868e-7 |
+| 0.5953125 | 128 | 512 | 2.293e-7 | 8.012e-8 | 4.593e-8 | 9.001e-9 |
+| 0.75 | 204 | 816 | 9.822e-7 | 7.420e-8 | 5.372e-8 | 1.134e-8 |
+
+The two exact branches were sampled at 1,025 parameters for both cylinder equations and lifted pcurves. A rotated radial cutter checked frame independence. A centered-difference test checked the analytic tangent. Host seam unwrapping was checked across the negative cutter-axis branch, and tightening tolerance increased segment count. This is geometric qualification of the curve authority and finite 3D representation, **not** qualification of a solid cut.
+
+Reproduce the focused tests:
+
+```text
+dotnet test Aetheris.Kernel.Core.Tests --no-restore --filter FullyQualifiedName~CylinderCylinderIntersectionCurveTests --logger "console;verbosity=detailed" --verbosity quiet
+```
+
+## Remaining topology and STEP boundary
+
+The BRep model can hold a `CurveGeometry` with its exact intersection authority and certified 3D spline, but there is no cross-hole face/edge builder or finite host/tool pcurve realization. `BrepBooleanSafeCompositionGraphValidator` still rejects a transverse cutter. Thus no manifold solid or Hollow body, semantic `CrossHole.Wall`, source map, seam-split edge identity, or production STEP round trip exists. `Step242Exporter` can serialize the ordinary non-rational B-spline type, but no cross-hole topology has been wired to it; STEP support for this operation is **unqualified**. The supplied clevis STEP remains dimensional evidence only. No authored clevis or barrel-vent witness was generated. Accordingly, 1/8/32-hole BRep, export and tessellation timings are unavailable.
+
+The next bounded construction must realize both pcurves with qualified 3D-lift error, bind them to seam-aware coedges, form the outer (and for Hollow, inner) trims and cutter wall, then pass manifold/preflight/export/reimport checks. Only then should Firmament `CrossHole`, the McMaster witness, and cylindrical Perforation lower through this path. No mesh or voxel Boolean has been introduced.
+
+## Build and regression
+
+The focused intersection tests passed 9/9, including the rotated-frame case added after the serial run. `dotnet build Aetheris.slnx --no-restore -m:1 --verbosity quiet` passed; the first full build reported seven existing WebAssembly warnings, and the final incremental build reported two. The serial `dotnet test Aetheris.slnx --no-build --no-restore -m:1 --verbosity quiet` run passed every project suite except one assertion in Kernel.Core (1,078 passed, 1 failed, including the first eight intersection tests). The previously recorded `SurfaceMeshIrTests.ThroughHolePlate_UsesMultiLoopPlanarBands_AndLowersToWatertightMesh` expects 90 planar cells and obtains 87; it exercises a planar box/cylinder hole and is isolated from the new intersection code. The failure reproduced in isolation. Its expected count was not rewritten, so the full solution test result is **not green**.