Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Expand Aetheris capabilities and improve reliability

Yuechen Li4ffff9a1f6ac
diff --git a/Aetheris.Kernel.Core.Tests/Brep/Tessellation/SurfaceMeshIrTests.cs b/Aetheris.Kernel.Core.Tests/Brep/Tessellation/SurfaceMeshIrTests.cs
index df8020e5..6a32b5fc 100644
--- a/Aetheris.Kernel.Core.Tests/Brep/Tessellation/SurfaceMeshIrTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Brep/Tessellation/SurfaceMeshIrTests.cs
@@ -1,7 +1,9 @@
using Aetheris.Kernel.Core.Brep;
using Aetheris.Kernel.Core.Brep.Boolean;
+using Aetheris.Kernel.Core.Brep.Features;
using Aetheris.Kernel.Core.Brep.Tessellation;
using Aetheris.Kernel.Core.Geometry;
+using Aetheris.Kernel.Core.Math;
namespace Aetheris.Kernel.Core.Tests.Brep.Tessellation;
@@ -70,6 +72,72 @@ public sealed class SurfaceMeshIrTests
}
}
+ [Fact]
+ public void Cone_UsesSharedCircularRings_AndAngularGeneratorQuadStrip()
+ {
+ var body = BrepRevolve.Create(
+ [new ProfilePoint2D(4d, -2d), new ProfilePoint2D(2d, 2d)],
+ new ExtrudeFrame3D(Point3D.Origin, Direction3D.Create(new Vector3D(0d, 0d, 1d)), Direction3D.Create(new Vector3D(1d, 0d, 0d))),
+ new RevolveAxis3D(Point3D.Origin, new Vector3D(0d, 0d, 1d))).Value;
+
+ Assert.True(SurfaceMeshIrTessellator.TryBuild(body, SurfaceMeshPolicy.FromDisplayOptions(DisplayTessellationOptions.Default), out var document));
+ var side = Assert.Single(document.Patches, patch => patch.Support.Kind == SurfaceMeshSupportKind.Cone);
+ Assert.True(side.HasPeriodicUSeam);
+ Assert.All(side.Cells, cell => Assert.IsType<QuadCell>(cell));
+ Assert.Equal(36, side.Cells.Count);
+ Assert.True(SurfaceMeshIrTessellator.TryLowerToTriangleMesh(document, out _, out var topology));
+ Assert.True(topology.IsWatertight);
+ }
+
+ [Fact]
+ public void Sphere_UsesSixStructuredCharts_WithSharedSeamVertices_AndExactNormals()
+ {
+ var body = BrepPrimitives.CreateSphere(3d).Value;
+ Assert.True(SurfaceMeshIrTessellator.TryBuild(body, SurfaceMeshPolicy.FromDisplayOptions(DisplayTessellationOptions.Default), out var document));
+ var charts = document.Patches.Where(patch => patch.Support.Kind == SurfaceMeshSupportKind.Sphere).ToArray();
+ Assert.Equal(6, charts.Length);
+ Assert.All(charts, chart => Assert.All(chart.Cells, cell => Assert.IsType<QuadCell>(cell)));
+ Assert.Contains(charts.SelectMany(chart => chart.Cells).SelectMany(cell => cell.VertexIds).GroupBy(id => id), group => group.Count() >= 4);
+ Assert.True(SurfaceMeshIrTessellator.TryLowerToTriangleMesh(document, out var mesh, out var topology));
+ Assert.True(topology.IsWatertight);
+ Assert.All(mesh.Normals, normal => Assert.True(double.Abs(normal.Length - 1d) < 1e-9d));
+ }
+
+ [Fact]
+ public void Torus_UsesDoublyPeriodicStructuredQuads_AndReusesBrepSeamSamples()
+ {
+ var body = BrepPrimitives.CreateTorus(6d, 1.5d).Value;
+ Assert.True(SurfaceMeshIrTessellator.TryBuild(body, SurfaceMeshPolicy.FromDisplayOptions(DisplayTessellationOptions.Default), out var document));
+ var patch = Assert.Single(document.Patches, candidate => candidate.Support.Kind == SurfaceMeshSupportKind.Torus);
+ Assert.True(patch.HasPeriodicUSeam);
+ Assert.True(patch.HasPeriodicVSeam);
+ Assert.All(patch.Cells, cell => Assert.IsType<QuadCell>(cell));
+ var patchIds = patch.Cells.SelectMany(cell => cell.VertexIds).ToHashSet();
+ Assert.All(document.SharedBoundaries.SelectMany(boundary => boundary.Samples), sample => Assert.Contains(sample.Id, patchIds));
+ Assert.True(SurfaceMeshIrTessellator.TryLowerToTriangleMesh(document, out _, out var topology));
+ Assert.True(topology.IsWatertight);
+ }
+
+ [Theory]
+ [InlineData("sphere")]
+ [InlineData("torus")]
+ public void M3Primitive_DisplayRoute_IsSurfaceMeshIr_AndDeterministic(string fixture)
+ {
+ var body = fixture == "sphere"
+ ? BrepPrimitives.CreateSphere(2d).Value
+ : BrepPrimitives.CreateTorus(5d, 1d).Value;
+ var first = BrepDisplayTessellator.TessellateSurfaceMeshIr(body);
+ var second = BrepDisplayTessellator.TessellateSurfaceMeshIr(body);
+
+ Assert.True(first.IsSuccess);
+ Assert.True(second.IsSuccess);
+ Assert.Equal(DisplayMeshPipeline.SurfaceMeshIr, first.Value.MeshPipeline);
+ Assert.Equal(first.Value.SurfaceMeshMetrics!.DeterministicHash, second.Value.SurfaceMeshMetrics!.DeterministicHash);
+ Assert.Equal(
+ first.Value.FacePatches.SelectMany(patch => patch.TriangleIndices),
+ second.Value.FacePatches.SelectMany(patch => patch.TriangleIndices));
+ }
+
[Fact]
public void ThroughHolePlate_UsesMultiLoopPlanarBands_AndLowersToWatertightMesh()
{
diff --git a/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.cs b/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.cs
index 0f6e3424..22a51a0b 100644
--- a/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.cs
+++ b/Aetheris.Kernel.Core/Brep/Tessellation/BrepDisplayTessellator.cs
@@ -41,13 +41,13 @@ public static class BrepDisplayTessellator
internal static KernelResult<DisplayTessellationResult> TessellateLegacyForComparison(BrepBody body, DisplayTessellationOptions? options = null)
=> TessellateCore(body, options, null);
- /// <summary>Explicit M2 SurfaceMeshIR route; unsupported trim families are reported rather than silently downgraded.</summary>
+ /// <summary>Explicit M3 SurfaceMeshIR route; unsupported trim families are reported rather than silently downgraded.</summary>
public static KernelResult<DisplayTessellationResult> TessellateSurfaceMeshIr(BrepBody body, DisplayTessellationOptions? options = null)
{
var effectiveOptions = options ?? DisplayTessellationOptions.Default;
return SurfaceMeshIrTessellator.TryTessellate(body, effectiveOptions, out var result)
? KernelResult<DisplayTessellationResult>.Success(result)
- : KernelResult<DisplayTessellationResult>.Failure([CreateNotImplemented("SurfaceMeshIR M2 supports Plane/Cylinder faces including bounded rectangular through-hole trims; use the legacy route for remaining families.", "Viewer.SurfaceMeshIr.Unsupported")]);
+ : KernelResult<DisplayTessellationResult>.Failure([CreateNotImplemented("SurfaceMeshIR M3 supports Plane/Cylinder, full circular-trim Cone strips, closed cube-chart Spheres, and doubly-periodic Toruses. General conic and arbitrary trimmed-patch remeshing remains on the explicit legacy route.", "Viewer.SurfaceMeshIr.Unsupported")]);
}
public static KernelResult<DisplayTessellationResult> TessellateBounded(
diff --git a/Aetheris.Kernel.Core/Brep/Tessellation/SurfaceMeshIr.cs b/Aetheris.Kernel.Core/Brep/Tessellation/SurfaceMeshIr.cs
index 97cf5472..8fb848f9 100644
--- a/Aetheris.Kernel.Core/Brep/Tessellation/SurfaceMeshIr.cs
+++ b/Aetheris.Kernel.Core/Brep/Tessellation/SurfaceMeshIr.cs
@@ -41,9 +41,15 @@ public sealed record SharedEdgeSamplePlan(
bool IsClosed,
double MaxChordalDeviation);
-public enum SurfaceMeshSupportKind { Plane, Cylinder }
+public enum SurfaceMeshSupportKind { Plane, Cylinder, Cone, Sphere, Torus }
public enum SurfaceMeshCellKind { Quad, Triangle, BoundaryPolygon, Singular }
-public sealed record SurfaceMeshSupport(SurfaceMeshSupportKind Kind, PlaneSurface? Plane = null, CylinderSurface? Cylinder = null);
+public sealed record SurfaceMeshSupport(
+ SurfaceMeshSupportKind Kind,
+ PlaneSurface? Plane = null,
+ CylinderSurface? Cylinder = null,
+ ConeSurface? Cone = null,
+ SphereSurface? Sphere = null,
+ TorusSurface? Torus = null);
public abstract record SurfaceMeshCell(SurfaceMeshCellKind Kind, IReadOnlyList<int> VertexIds, int RefinementLevel = 0, int? ParentCellId = null);
public sealed record QuadCell(IReadOnlyList<int> VertexIds, int RefinementLevel = 0, int? ParentCellId = null)
@@ -63,8 +69,10 @@ public sealed record SurfacePatch(
bool SameSense,
string? SemanticOwner = null,
bool HasPeriodicUSeam = false,
+ bool HasPeriodicVSeam = false,
int MaxRefinementLevel = 0,
- IReadOnlyList<SurfaceMeshTrimLoop>? TrimLoopData = null);
+ IReadOnlyList<SurfaceMeshTrimLoop>? TrimLoopData = null,
+ string? ChartId = null);
public enum SurfaceMeshDownstreamIntent { Presentation, Manufacturing, Fea }
@@ -98,9 +106,9 @@ public static class SurfaceMeshIrDebug
}
/// <summary>
-/// M1 planner/lowerer for closed Plane/Cylinder solids with line/circle trims.
-/// It intentionally returns false for more general trimming so the named legacy
-/// display tessellator remains a visible migration fallback.
+/// Planner/lowerer for the analytic surface subset with explicit support topology.
+/// General trim remeshing remains a visible legacy fallback; supported patches retain
+/// quads until the final deterministic triangle lowering step.
/// </summary>
public static class SurfaceMeshIrTessellator
{
@@ -174,7 +182,11 @@ public static class SurfaceMeshIrTessellator
private static IReadOnlySet<(int A, int B)> BuildHardEdges(SurfaceMeshDocument document, IReadOnlyDictionary<int, int> indexById)
{
- var supportByFace = document.Patches.ToDictionary(p => p.FaceId, p => p.Support.Kind);
+ // Multi-chart supports such as a sphere legitimately contribute several
+ // patches for one B-rep face; all charts share the same smooth support.
+ var supportByFace = document.Patches
+ .GroupBy(patch => patch.FaceId)
+ .ToDictionary(group => group.Key, group => group.First().Support.Kind);
var hard = new HashSet<(int A, int B)>();
foreach (var boundary in document.SharedBoundaries)
{
@@ -209,13 +221,35 @@ public static class SurfaceMeshIrTessellator
foreach (var face in body.Topology.Faces.OrderBy(f => f.Id.Value))
{
if (!body.TryGetFaceSurfaceGeometry(face.Id, out var surface) || surface is null ||
- surface.Kind is not (SurfaceGeometryKind.Plane or SurfaceGeometryKind.Cylinder) ||
+ surface.Kind is not (SurfaceGeometryKind.Plane or SurfaceGeometryKind.Cylinder or SurfaceGeometryKind.Cone or SurfaceGeometryKind.Sphere or SurfaceGeometryKind.Torus) ||
!body.Bindings.TryGetFaceBinding(face.Id, out var faceBinding)) return false;
- var patch = surface.Kind == SurfaceGeometryKind.Plane
- ? TryBuildPlanePatch(body, face.Id, faceBinding.SameSense, surface.Plane!.Value, byEdge, vertices, ref nextVertexId)
- : TryBuildCylinderPatch(body, face.Id, faceBinding.SameSense, surface.Cylinder!.Value, byEdge);
- if (patch is null) return false;
- patches.Add(patch);
+ switch (surface.Kind)
+ {
+ case SurfaceGeometryKind.Plane:
+ var planePatch = TryBuildPlanePatch(body, face.Id, faceBinding.SameSense, surface.Plane!.Value, byEdge, vertices, ref nextVertexId);
+ if (planePatch is null) return false;
+ patches.Add(planePatch);
+ break;
+ case SurfaceGeometryKind.Cylinder:
+ var cylinderPatch = TryBuildCylinderPatch(body, face.Id, faceBinding.SameSense, surface.Cylinder!.Value, byEdge);
+ if (cylinderPatch is null) return false;
+ patches.Add(cylinderPatch);
+ break;
+ case SurfaceGeometryKind.Cone:
+ var conePatch = TryBuildConePatch(body, face.Id, faceBinding.SameSense, surface.Cone!.Value, byEdge);
+ if (conePatch is null) return false;
+ patches.Add(conePatch);
+ break;
+ case SurfaceGeometryKind.Sphere:
+ if (!TryBuildSphereCharts(body, face.Id, faceBinding.SameSense, surface.Sphere!.Value, vertices, ref nextVertexId, out var spherePatches)) return false;
+ patches.AddRange(spherePatches);
+ break;
+ case SurfaceGeometryKind.Torus:
+ var torusPatch = TryBuildTorusPatch(body, face.Id, faceBinding.SameSense, surface.Torus!.Value, byEdge, policy, vertices, ref nextVertexId);
+ if (torusPatch is null) return false;
+ patches.Add(torusPatch);
+ break;
+ }
}
vertices = vertices.GroupBy(v => v.Id).Select(g => g.First()).OrderBy(v => v.Id).ToList();
@@ -256,6 +290,11 @@ public static class SurfaceMeshIrTessellator
closed = double.Abs(double.Abs(span) - (2d * double.Pi)) <= Epsilon;
chordError = circle.Radius * (1d - double.Cos(double.Abs(span) / (2d * segments)));
break;
+ case CurveGeometryKind.Hyperbola3 when curve.Hyperbola3 is { } hyperbola:
+ sampled = SampleHyperbola(hyperbola, interval, policy);
+ closed = false;
+ chordError = ComputePolylineChordDeviation(hyperbola.Evaluate, sampled);
+ break;
default: return false;
}
if (!body.TryGetEdgeVertices(edgeId, out var startVertex, out var endVertex)) return false;
@@ -290,6 +329,53 @@ public static class SurfaceMeshIrTessellator
return int.Max(baseline, int.Max(1, int.Max(chord, normal)));
}
+ private static List<(double Parameter, Point3D Point)> SampleHyperbola(Hyperbola3Curve hyperbola, ParameterInterval interval, SurfaceMeshPolicy policy)
+ {
+ var samples = new List<(double Parameter, Point3D Point)> { (interval.Start, hyperbola.Evaluate(interval.Start)) };
+ AppendHyperbolaSegment(hyperbola, interval.Start, interval.End, samples[0].Point, hyperbola.Evaluate(interval.End), policy, samples, 0);
+ return samples;
+ }
+
+ private static void AppendHyperbolaSegment(
+ Hyperbola3Curve hyperbola,
+ double start,
+ double end,
+ Point3D startPoint,
+ Point3D endPoint,
+ SurfaceMeshPolicy policy,
+ List<(double Parameter, Point3D Point)> samples,
+ int depth)
+ {
+ var middle = (start + end) * 0.5d;
+ var middlePoint = hyperbola.Evaluate(middle);
+ var chordMidpoint = new Point3D((startPoint.X + endPoint.X) * 0.5d, (startPoint.Y + endPoint.Y) * 0.5d, (startPoint.Z + endPoint.Z) * 0.5d);
+ var deviation = (middlePoint - chordMidpoint).Length;
+ if (depth >= policy.MaxRefinementDepth || samples.Count + 1 >= policy.MaxBoundarySamples || deviation <= policy.TargetChordalError)
+ {
+ samples.Add((end, endPoint));
+ return;
+ }
+
+ AppendHyperbolaSegment(hyperbola, start, middle, startPoint, middlePoint, policy, samples, depth + 1);
+ AppendHyperbolaSegment(hyperbola, middle, end, middlePoint, endPoint, policy, samples, depth + 1);
+ }
+
+ private static double ComputePolylineChordDeviation(Func<double, Point3D> evaluate, IReadOnlyList<(double Parameter, Point3D Point)> samples)
+ {
+ var worst = 0d;
+ for (var index = 0; index + 1 < samples.Count; index++)
+ {
+ var middle = (samples[index].Parameter + samples[index + 1].Parameter) * 0.5d;
+ var midpoint = evaluate(middle);
+ var chordMidpoint = new Point3D(
+ (samples[index].Point.X + samples[index + 1].Point.X) * 0.5d,
+ (samples[index].Point.Y + samples[index + 1].Point.Y) * 0.5d,
+ (samples[index].Point.Z + samples[index + 1].Point.Z) * 0.5d);
+ worst = double.Max(worst, (midpoint - chordMidpoint).Length);
+ }
+ return worst;
+ }
+
private static SurfacePatch? TryBuildPlanePatch(BrepBody body, FaceId faceId, bool sameSense, PlaneSurface plane, IReadOnlyDictionary<EdgeId, SharedEdgeSamplePlan> plans, List<SurfaceMeshVertex> vertices, ref int nextVertexId)
{
var loops = body.GetLoopIds(faceId);
@@ -374,6 +460,251 @@ public static class SurfaceMeshIrTessellator
return new SurfacePatch(faceId, new SurfaceMeshSupport(SurfaceMeshSupportKind.Cylinder, Cylinder: cylinder), loops, cells, sameSense, HasPeriodicUSeam: true);
}
+ private static SurfacePatch? TryBuildConePatch(BrepBody body, FaceId faceId, bool sameSense, ConeSurface cone, IReadOnlyDictionary<EdgeId, SharedEdgeSamplePlan> plans)
+ {
+ var loops = body.GetLoopIds(faceId);
+ var circles = loops
+ .SelectMany(loop => body.GetCoedgeIds(loop).Select(body.Topology.GetCoedge))
+ .Select(coedge => plans[coedge.EdgeId])
+ .Where(plan => plan.CurveKind == CurveGeometryKind.Circle3 && plan.IsClosed)
+ .DistinctBy(plan => plan.EdgeId)
+ .ToArray();
+ if (circles.Length != 2 || circles[0].Samples.Count != circles[1].Samples.Count)
+ {
+ return null;
+ }
+
+ var rings = circles.Select(plan => plan.Samples.Take(plan.Samples.Count - 1).ToArray()).ToArray();
+ if (rings[0].Length < 3)
+ {
+ return null;
+ }
+
+ var v0 = cone.AxialParameterFromPoint(rings[0][0].Position);
+ var v1 = cone.AxialParameterFromPoint(rings[1][0].Position);
+ if (!double.IsFinite(v0) || !double.IsFinite(v1) || double.Abs(v1 - v0) <= Epsilon)
+ {
+ return null;
+ }
+
+ var lower = v0 <= v1 ? rings[0] : rings[1];
+ var upper = v0 <= v1 ? rings[1] : rings[0];
+ var cells = new List<SurfaceMeshCell>(lower.Length);
+ for (var i = 0; i < lower.Length; i++)
+ {
+ var next = (i + 1) % lower.Length;
+ cells.Add(new QuadCell(Orient([lower[i].Id, lower[next].Id, upper[next].Id, upper[i].Id], sameSense)));
+ }
+
+ return new SurfacePatch(
+ faceId,
+ new SurfaceMeshSupport(SurfaceMeshSupportKind.Cone, Cone: cone),
+ loops,
+ cells,
+ sameSense,
+ HasPeriodicUSeam: true);
+ }
+
+ private static bool TryBuildSphereCharts(
+ BrepBody body,
+ FaceId faceId,
+ bool sameSense,
+ SphereSurface sphere,
+ List<SurfaceMeshVertex> vertices,
+ ref int nextVertexId,
+ out IReadOnlyList<SurfacePatch> patches)
+ {
+ // A six-chart cube sphere has no pole fan. Integer cube-grid coordinates
+ // are the seam identity: neighboring charts literally reuse vertex IDs.
+ if (body.GetLoopIds(faceId).Count != 0)
+ {
+ patches = [];
+ return false;
+ }
+
+ const int subdivisions = 6;
+ var seamVertices = new Dictionary<(int X, int Y, int Z), int>();
+ var byId = vertices.ToDictionary(vertex => vertex.Id);
+ var chartDefinitions = new[]
+ {
+ new CubeChart("+X", (1, 0, 0), (0, 1, 0), (0, 0, 1)),
+ new CubeChart("-X", (-1, 0, 0), (0, 0, 1), (0, 1, 0)),
+ new CubeChart("+Y", (0, 1, 0), (0, 0, 1), (1, 0, 0)),
+ new CubeChart("-Y", (0, -1, 0), (1, 0, 0), (0, 0, 1)),
+ new CubeChart("+Z", (0, 0, 1), (1, 0, 0), (0, 1, 0)),
+ new CubeChart("-Z", (0, 0, -1), (0, 1, 0), (1, 0, 0)),
+ };
+ var result = new List<SurfacePatch>(chartDefinitions.Length);
+ foreach (var chart in chartDefinitions)
+ {
+ var grid = new int[subdivisions + 1, subdivisions + 1];
+ for (var row = 0; row <= subdivisions; row++)
+ {
+ for (var column = 0; column <= subdivisions; column++)
+ {
+ var numeratorX = (chart.Normal.X * subdivisions) + (chart.U.X * ((2 * column) - subdivisions)) + (chart.V.X * ((2 * row) - subdivisions));
+ var numeratorY = (chart.Normal.Y * subdivisions) + (chart.U.Y * ((2 * column) - subdivisions)) + (chart.V.Y * ((2 * row) - subdivisions));
+ var numeratorZ = (chart.Normal.Z * subdivisions) + (chart.U.Z * ((2 * column) - subdivisions)) + (chart.V.Z * ((2 * row) - subdivisions));
+ var key = (numeratorX, numeratorY, numeratorZ);
+ if (!seamVertices.TryGetValue(key, out var id))
+ {
+ var cube = new Vector3D(numeratorX, numeratorY, numeratorZ);
+ var unit = cube / cube.Length;
+ var position = sphere.Center
+ + (sphere.XAxis.ToVector() * (sphere.Radius * unit.X))
+ + (sphere.YAxis.ToVector() * (sphere.Radius * unit.Y))
+ + (sphere.Axis.ToVector() * (sphere.Radius * unit.Z));
+ id = nextVertexId++;
+ var vertex = new SurfaceMeshVertex(id, position, column / (double)subdivisions, row / (double)subdivisions);
+ vertices.Add(vertex);
+ byId.Add(id, vertex);
+ seamVertices.Add(key, id);
+ }
+ grid[row, column] = id;
+ }
+ }
+
+ var cells = new List<SurfaceMeshCell>(subdivisions * subdivisions);
+ for (var row = 0; row < subdivisions; row++)
+ {
+ for (var column = 0; column < subdivisions; column++)
+ {
+ cells.Add(new QuadCell(Orient([grid[row, column], grid[row, column + 1], grid[row + 1, column + 1], grid[row + 1, column]], sameSense)));
+ }
+ }
+ result.Add(new SurfacePatch(faceId, new SurfaceMeshSupport(SurfaceMeshSupportKind.Sphere, Sphere: sphere), [], cells, sameSense, ChartId: chart.Name));
+ }
+
+ patches = result;
+ return true;
+ }
+
+ private static SurfacePatch? TryBuildTorusPatch(
+ BrepBody body,
+ FaceId faceId,
+ bool sameSense,
+ TorusSurface torus,
+ IReadOnlyDictionary<EdgeId, SharedEdgeSamplePlan> plans,
+ SurfaceMeshPolicy policy,
+ List<SurfaceMeshVertex> vertices,
+ ref int nextVertexId)
+ {
+ if (body.GetLoopIds(faceId).Count != 1)
+ {
+ return null;
+ }
+
+ var seamPlans = body.GetCoedgeIds(body.GetLoopIds(faceId)[0])
+ .Select(body.Topology.GetCoedge)
+ .Select(coedge => plans[coedge.EdgeId])
+ .Where(plan => plan.CurveKind == CurveGeometryKind.Circle3 && plan.IsClosed)
+ .DistinctBy(plan => plan.EdgeId)
+ .ToArray();
+ if (seamPlans.Length != 2)
+ {
+ return null;
+ }
+
+ var parameters = seamPlans
+ .Select(plan => (Plan: plan, Samples: plan.Samples.Take(plan.Samples.Count - 1).Select(sample => (Sample: sample, Uv: TryProjectPointToTorusUv(torus, sample.Position))).ToArray()))
+ .ToArray();
+ if (parameters.Any(entry => entry.Samples.Any(sample => sample.Uv is null)))
+ {
+ return null;
+ }
+
+ var major = parameters.OrderByDescending(entry => CircularSpan(entry.Samples.Select(sample => sample.Uv!.Value.U))).First();
+ var minor = parameters.Single(entry => entry.Plan.EdgeId != major.Plan.EdgeId);
+ var uSegments = System.Math.Max(major.Samples.Length, ResolveCircleSegments(torus.MajorRadius + torus.MinorRadius, 2d * double.Pi, policy));
+ var vSegments = System.Math.Max(minor.Samples.Length, ResolveCircleSegments(torus.MinorRadius, 2d * double.Pi, policy));
+ var seamIds = new Dictionary<(int U, int V), SurfaceMeshVertex>();
+ AddTorusSeamSamples(major.Samples, uSegments, vSegments, seamIds);
+ AddTorusSeamSamples(minor.Samples, uSegments, vSegments, seamIds);
+
+ var grid = new int[uSegments, vSegments];
+ for (var uIndex = 0; uIndex < uSegments; uIndex++)
+ {
+ for (var vIndex = 0; vIndex < vSegments; vIndex++)
+ {
+ if (seamIds.TryGetValue((uIndex, vIndex), out var sampled))
+ {
+ grid[uIndex, vIndex] = sampled.Id;
+ continue;
+ }
+
+ var u = (2d * double.Pi * uIndex) / uSegments;
+ var v = (2d * double.Pi * vIndex) / vSegments;
+ var vertex = new SurfaceMeshVertex(nextVertexId++, torus.Evaluate(u, v), u, v);
+ vertices.Add(vertex);
+ grid[uIndex, vIndex] = vertex.Id;
+ }
+ }
+
+ var cells = new List<SurfaceMeshCell>(uSegments * vSegments);
+ for (var uIndex = 0; uIndex < uSegments; uIndex++)
+ {
+ for (var vIndex = 0; vIndex < vSegments; vIndex++)
+ {
+ var nextU = (uIndex + 1) % uSegments;
+ var nextV = (vIndex + 1) % vSegments;
+ cells.Add(new QuadCell(Orient([grid[uIndex, vIndex], grid[nextU, vIndex], grid[nextU, nextV], grid[uIndex, nextV]], sameSense)));
+ }
+ }
+ return new SurfacePatch(faceId, new SurfaceMeshSupport(SurfaceMeshSupportKind.Torus, Torus: torus), body.GetLoopIds(faceId), cells, sameSense, HasPeriodicUSeam: true, HasPeriodicVSeam: true);
+ }
+
+ private static void AddTorusSeamSamples(
+ IReadOnlyList<(SurfaceMeshVertex Sample, (double U, double V)? Uv)> samples,
+ int uSegments,
+ int vSegments,
+ IDictionary<(int U, int V), SurfaceMeshVertex> seamIds)
+ {
+ foreach (var (sample, uv) in samples)
+ {
+ if (uv is not { } value)
+ {
+ continue;
+ }
+ var u = ((int)System.Math.Round(value.U / (2d * double.Pi) * uSegments)) % uSegments;
+ var v = ((int)System.Math.Round(value.V / (2d * double.Pi) * vSegments)) % vSegments;
+ seamIds.TryAdd((U: u, V: v), sample);
+ }
+ }
+
+ private static (double U, double V)? TryProjectPointToTorusUv(TorusSurface torus, Point3D point)
+ {
+ var axis = torus.Axis.ToVector();
+ var offset = point - torus.Center;
+ var axial = offset.Dot(axis);
+ var planar = offset - (axis * axial);
+ var planarLength = planar.Length;
+ if (planarLength <= Epsilon)
+ {
+ return null;
+ }
+ var u = NormalizeAngle(double.Atan2(planar.Dot(torus.YAxis.ToVector()), planar.Dot(torus.XAxis.ToVector())));
+ var v = NormalizeAngle(double.Atan2(axial, planarLength - torus.MajorRadius));
+ return (u, v);
+ }
+
+ private static double CircularSpan(IEnumerable<double> angles)
+ {
+ var values = angles.OrderBy(value => value).ToArray();
+ if (values.Length < 2)
+ {
+ return 0d;
+ }
+ return values.Zip(values.Skip(1), (a, b) => b - a).DefaultIfEmpty().Max();
+ }
+
+ private static double NormalizeAngle(double angle)
+ {
+ var normalized = angle % (2d * double.Pi);
+ return normalized < 0d ? normalized + (2d * double.Pi) : normalized;
+ }
+
+ private readonly record struct CubeChart(string Name, (int X, int Y, int Z) Normal, (int X, int Y, int Z) U, (int X, int Y, int Z) V);
+
private static IReadOnlyList<int> FlattenLoop(IReadOnlyList<Coedge> coedges, IReadOnlyDictionary<EdgeId, SharedEdgeSamplePlan> plans)
{
var output = new List<int>();
@@ -481,6 +812,29 @@ public static class SurfaceMeshIrTessellator
var exact = cylinder.Normal(angle).ToVector();
return patch.SameSense ? exact : -exact;
},
+ SurfaceMeshSupportKind.Cone when patch.Support.Cone is { } cone => p =>
+ {
+ var offset = p - cone.Apex;
+ var axis = cone.Axis.ToVector();
+ var radial = offset - (axis * offset.Dot(axis));
+ var reference = cone.ReferenceAxis.ToVector();
+ var xAxis = reference - (axis * reference.Dot(axis));
+ var yAxis = axis.Cross(xAxis);
+ var angle = radial.Length <= Epsilon ? 0d : double.Atan2(radial.Dot(yAxis), radial.Dot(xAxis));
+ var exact = cone.Normal(angle).ToVector();
+ return patch.SameSense ? exact : -exact;
+ },
+ SurfaceMeshSupportKind.Sphere when patch.Support.Sphere is { } sphere => p =>
+ {
+ var exact = Direction3D.Create(p - sphere.Center).ToVector();
+ return patch.SameSense ? exact : -exact;
+ },
+ SurfaceMeshSupportKind.Torus when patch.Support.Torus is { } torus => p =>
+ {
+ var uv = TryProjectPointToTorusUv(torus, p) ?? throw new InvalidOperationException("Torus mesh vertex is not on its exact support.");
+ var exact = torus.Normal(uv.U, uv.V).ToVector();
+ return patch.SameSense ? exact : -exact;
+ },
_ => throw new InvalidOperationException($"Patch {patch.FaceId.Value} has no exact support evaluator."),
};
}
diff --git a/aetheris.client/src/App.css b/aetheris.client/src/App.css
index bb3ef18a..1f127737 100644
--- a/aetheris.client/src/App.css
+++ b/aetheris.client/src/App.css
@@ -478,12 +478,50 @@ strong {
vertical-align: top;
}
-.semantic-tree { max-height: 300px; overflow: auto; border: 1px solid color-mix(in srgb, var(--shell-border) 60%, transparent); padding: 4px; }
-.semantic-tree ul { list-style: none; padding-left: 0; margin: 0; }
-.semantic-tree__item { width: 100%; min-height: 28px; text-align: left; border: 0; background: transparent; font-size: var(--ui-small); }
-.semantic-provenance { margin-top: 8px !important; padding: 7px; border-left: 2px solid var(--shell-accent); background: color-mix(in srgb, var(--shell-panel) 75%, transparent); font-size: var(--ui-small); }
-.pmi-callout { display: grid; gap: 2px; min-width: 66px; padding: 4px 7px; border: 1px solid; border-radius: 3px; box-shadow: 0 2px 8px rgb(0 0 0 / 35%); font-family: Inter, ui-sans-serif, system-ui, sans-serif; font-size: 13px; line-height: 1.1; white-space: nowrap; cursor: pointer; }
-.pmi-callout small { font-size: 10px; opacity: .85; }
+.semantic-tree {
+ max-height: 300px;
+ overflow: auto;
+ border: 1px solid color-mix(in srgb, var(--shell-border) 60%, transparent);
+ padding: 4px;
+}
+.semantic-tree ul {
+ list-style: none;
+ padding-left: 0;
+ margin: 0;
+}
+.semantic-tree__item {
+ width: 100%;
+ min-height: 28px;
+ text-align: left;
+ border: 0;
+ background: transparent;
+ font-size: var(--ui-small);
+}
+.semantic-provenance {
+ margin-top: 8px !important;
+ padding: 7px;
+ border-left: 2px solid var(--shell-accent);
+ background: color-mix(in srgb, var(--shell-panel) 75%, transparent);
+ font-size: var(--ui-small);
+}
+.pmi-callout {
+ display: grid;
+ gap: 2px;
+ min-width: 66px;
+ padding: 4px 7px;
+ border: 1px solid;
+ border-radius: 3px;
+ box-shadow: 0 2px 8px rgb(0 0 0 / 35%);
+ font-family: Inter, ui-sans-serif, system-ui, sans-serif;
+ font-size: 13px;
+ line-height: 1.1;
+ white-space: nowrap;
+ cursor: pointer;
+}
+.pmi-callout small {
+ font-size: 10px;
+ opacity: 0.85;
+}
.property-table th {
width: 46%;
diff --git a/aetheris.client/src/App.tsx b/aetheris.client/src/App.tsx
index b3765fc4..d1537b4d 100644
--- a/aetheris.client/src/App.tsx
+++ b/aetheris.client/src/App.tsx
@@ -686,7 +686,11 @@ function App() {
setPickHits(pickResponse.hits);
const hit = pickResponse.hits[0];
if (hit && cadmataArtifact) {
- const published = resolvePublishedBrepEntity(cadmataArtifact, hit.entityKind, hit.entityKind === "Face" ? hit.faceId! : hit.edgeId!);
+ const published = resolvePublishedBrepEntity(
+ cadmataArtifact,
+ hit.entityKind,
+ hit.entityKind === "Face" ? hit.faceId! : hit.edgeId!,
+ );
if (published) setSelectedCadmataId(published.stableId);
}
setPickMessage(
@@ -941,7 +945,18 @@ function App() {
>
SEMANTIC
</button>
- <button type="button" className={isPmiVisible ? "viewport-segmented__button is-active" : "viewport-segmented__button"} onClick={() => setIsPmiVisible((value) => !value)} aria-pressed={isPmiVisible}>PMI</button>
+ <button
+ type="button"
+ className={
+ isPmiVisible
+ ? "viewport-segmented__button is-active"
+ : "viewport-segmented__button"
+ }
+ onClick={() => setIsPmiVisible((value) => !value)}
+ aria-pressed={isPmiVisible}
+ >
+ PMI
+ </button>
<button
type="button"
className={
@@ -1024,7 +1039,11 @@ function App() {
</div>
{cadmataArtifact ? (
<>
- <SemanticInspector artifact={cadmataArtifact} selectedId={selectedCadmataId} onSelect={setSelectedCadmataId} />
+ <SemanticInspector
+ artifact={cadmataArtifact}
+ selectedId={selectedCadmataId}
+ onSelect={setSelectedCadmataId}
+ />
<p>
<strong>{cadmataArtifact.fixtureId}</strong> ·{" "}
{cadmataArtifact.metrics?.entityCount ?? 0} evidence entities
@@ -1078,7 +1097,11 @@ function App() {
: null}
</>
) : (
- <SemanticInspector artifact={cadmataArtifact} selectedId={selectedCadmataId} onSelect={setSelectedCadmataId} />
+ <SemanticInspector
+ artifact={cadmataArtifact}
+ selectedId={selectedCadmataId}
+ onSelect={setSelectedCadmataId}
+ />
)}
</section>
<section className="tool-section tool-section--import">
diff --git a/aetheris.client/src/__tests__/semanticInspection.test.ts b/aetheris.client/src/__tests__/semanticInspection.test.ts
index 7f961a68..1d7b69f5 100644
--- a/aetheris.client/src/__tests__/semanticInspection.test.ts
+++ b/aetheris.client/src/__tests__/semanticInspection.test.ts
@@ -1,20 +1,63 @@
import { describe, expect, it } from "vitest";
-import { formatPmiLabel, indexSemanticInspection, resolvePublishedBrepEntity, semanticTree } from "../viewer/semanticInspection";
+import {
+ formatPmiLabel,
+ indexSemanticInspection,
+ resolvePublishedBrepEntity,
+ semanticTree,
+} from "../viewer/semanticInspection";
import type { CadmataVisualizationArtifact } from "../viewer/conceptVisualization";
-const artifact: CadmataVisualizationArtifact = { schemaVersion: "cadmata-concept-viz-x1", fixtureId: "semantic", sourcePath: "fixture", selections: [], entities: [
- { stableId: "body", kind: "Body", label: "Bracket", layer: "material", childIds: ["hole"] },
- { stableId: "hole", kind: "HoleFeature", label: "Mount", layer: "conceptAxes", parentIds: ["body"], topology: { faceIds: [17] } },
- { stableId: "face-17", kind: "BRepFace", label: "Face 17", layer: "selections", parentIds: ["hole"], topology: { faceIds: [17] } },
- { stableId: "pmi", kind: "HoleDiameter", label: "MountDiameter", layer: "conceptPoints", geometry: { type: "circle", center: { x: 1, y: 2, z: 3 }, radius: 4 }, metadata: { targetSemanticId: "hole", nominal: "8 mm", tolerancePlus: "0.05 mm", toleranceMinus: "0.02 mm" } },
-] };
+const artifact: CadmataVisualizationArtifact = {
+ schemaVersion: "cadmata-concept-viz-x1",
+ fixtureId: "semantic",
+ sourcePath: "fixture",
+ selections: [],
+ entities: [
+ { stableId: "body", kind: "Body", label: "Bracket", layer: "material", childIds: ["hole"] },
+ {
+ stableId: "hole",
+ kind: "HoleFeature",
+ label: "Mount",
+ layer: "conceptAxes",
+ parentIds: ["body"],
+ topology: { faceIds: [17] },
+ },
+ {
+ stableId: "face-17",
+ kind: "BRepFace",
+ label: "Face 17",
+ layer: "selections",
+ parentIds: ["hole"],
+ topology: { faceIds: [17] },
+ },
+ {
+ stableId: "pmi",
+ kind: "HoleDiameter",
+ label: "MountDiameter",
+ layer: "conceptPoints",
+ geometry: { type: "circle", center: { x: 1, y: 2, z: 3 }, radius: 4 },
+ metadata: {
+ targetSemanticId: "hole",
+ nominal: "8 mm",
+ tolerancePlus: "0.05 mm",
+ toleranceMinus: "0.02 mm",
+ },
+ },
+ ],
+};
describe("semantic inspection index", () => {
it("keeps compiler-published face owners and deterministic hierarchy", () => {
- expect(indexSemanticInspection(artifact).faceOwners.get(17)?.map((entity) => entity.label)).toEqual(["Mount"]);
+ expect(
+ indexSemanticInspection(artifact)
+ .faceOwners.get(17)
+ ?.map((entity) => entity.label),
+ ).toEqual(["Mount"]);
expect(semanticTree(artifact)[0].children[0].entity.stableId).toBe("hole");
expect(resolvePublishedBrepEntity(artifact, "Face", 17)?.stableId).toBe("face-17");
- expect(indexSemanticInspection(artifact).pmiByTarget.get("hole")?.[0].label).toBe("MountDiameter");
+ expect(indexSemanticInspection(artifact).pmiByTarget.get("hole")?.[0].label).toBe(
+ "MountDiameter",
+ );
});
it("formats an asymmetric HoleDiameter callout", () => {
expect(formatPmiLabel(artifact.entities[3])).toBe("⌀8 mm +0.05 mm/-0.02 mm");
diff --git a/aetheris.client/src/components/SemanticInspector.tsx b/aetheris.client/src/components/SemanticInspector.tsx
index 5be47193..845c0300 100644
--- a/aetheris.client/src/components/SemanticInspector.tsx
+++ b/aetheris.client/src/components/SemanticInspector.tsx
@@ -3,38 +3,242 @@ import { Table } from "machinalayout/table";
import { useMemo } from "react";
import type { ReactNode } from "react";
import { PropertyTable, type PropertyRecord } from "./PropertyTable";
-import { indexSemanticInspection, semanticTree, type SemanticTreeNode } from "../viewer/semanticInspection";
+import {
+ indexSemanticInspection,
+ semanticTree,
+ type SemanticTreeNode,
+} from "../viewer/semanticInspection";
import type { CadmataEntity, CadmataVisualizationArtifact } from "../viewer/conceptVisualization";
-function TreeNode({ node, selectedId, onSelect, depth = 0 }: { node: SemanticTreeNode; selectedId: string | null; onSelect: (id: string) => void; depth?: number }) {
- return <li><button type="button" className={node.entity.stableId === selectedId ? "semantic-tree__item active-row" : "semantic-tree__item"} style={{ paddingLeft: 8 + depth * 12 }} onClick={() => onSelect(node.entity.stableId)}>{node.entity.kind.replace("Feature", "")} {node.entity.label}</button>{node.children.length ? <ul>{node.children.map((child) => <TreeNode key={child.entity.stableId} node={child} selectedId={selectedId} onSelect={onSelect} depth={depth + 1} />)}</ul> : null}</li>;
+function TreeNode({
+ node,
+ selectedId,
+ onSelect,
+ depth = 0,
+}: {
+ node: SemanticTreeNode;
+ selectedId: string | null;
+ onSelect: (id: string) => void;
+ depth?: number;
+}) {
+ return (
+ <li>
+ <button
+ type="button"
+ className={
+ node.entity.stableId === selectedId
+ ? "semantic-tree__item active-row"
+ : "semantic-tree__item"
+ }
+ style={{ paddingLeft: 8 + depth * 12 }}
+ onClick={() => onSelect(node.entity.stableId)}
+ >
+ {node.entity.kind.replace("Feature", "")} {node.entity.label}
+ </button>
+ {node.children.length ? (
+ <ul>
+ {node.children.map((child) => (
+ <TreeNode
+ key={child.entity.stableId}
+ node={child}
+ selectedId={selectedId}
+ onSelect={onSelect}
+ depth={depth + 1}
+ />
+ ))}
+ </ul>
+ ) : null}
+ </li>
+ );
}
-function rows(entity: CadmataEntity): PropertyRecord[] { return [{ property: "Kind", value: entity.kind }, { property: "Stable ID", value: entity.stableId }, ...(entity.sourceSpan ? [{ property: "Source", value: entity.sourceSpan }] : []), ...(entity.topology?.faceIds?.length ? [{ property: "Faces", value: entity.topology.faceIds.join(", ") }] : []), ...(entity.topology?.edgeIds?.length ? [{ property: "Edges", value: entity.topology.edgeIds.join(", ") }] : []), ...Object.entries(entity.metadata ?? {}).map(([property, value]) => ({ property, value: String(value) }))]; }
-function PmiDetails({ entity }: { entity: CadmataEntity }) { return <><PropertyTable id={`pmi-${entity.stableId}`} rows={rows(entity)} />{entity.metadata?.require ? <p className="semantic-provenance"><strong>From:</strong> {String(entity.metadata.require)}<br /><strong>Subject:</strong> {String(entity.metadata.subject ?? "not published")}<br /><strong>Expected:</strong> {String(entity.metadata.expected ?? "not published")}</p> : null}</>; }
-function BrepDetails({ entity, artifact }: { entity: CadmataEntity; artifact: CadmataVisualizationArtifact }) {
+function rows(entity: CadmataEntity): PropertyRecord[] {
+ return [
+ { property: "Kind", value: entity.kind },
+ { property: "Stable ID", value: entity.stableId },
+ ...(entity.sourceSpan ? [{ property: "Source", value: entity.sourceSpan }] : []),
+ ...(entity.topology?.faceIds?.length
+ ? [{ property: "Faces", value: entity.topology.faceIds.join(", ") }]
+ : []),
+ ...(entity.topology?.edgeIds?.length
+ ? [{ property: "Edges", value: entity.topology.edgeIds.join(", ") }]
+ : []),
+ ...Object.entries(entity.metadata ?? {}).map(([property, value]) => ({
+ property,
+ value: String(value),
+ })),
+ ];
+}
+function PmiDetails({ entity }: { entity: CadmataEntity }) {
+ return (
+ <>
+ <PropertyTable id={`pmi-${entity.stableId}`} rows={rows(entity)} />
+ {entity.metadata?.require ? (
+ <p className="semantic-provenance">
+ <strong>From:</strong> {String(entity.metadata.require)}
+ <br />
+ <strong>Subject:</strong> {String(entity.metadata.subject ?? "not published")}
+ <br />
+ <strong>Expected:</strong> {String(entity.metadata.expected ?? "not published")}
+ </p>
+ ) : null}
+ </>
+ );
+}
+function BrepDetails({
+ entity,
+ artifact,
+}: {
+ entity: CadmataEntity;
+ artifact: CadmataVisualizationArtifact;
+}) {
const index = indexSemanticInspection(artifact);
- const owners = [...(entity.topology?.faceIds ?? []).flatMap((id) => index.faceOwners.get(id) ?? []), ...(entity.topology?.edgeIds ?? []).flatMap((id) => index.edgeOwners.get(id) ?? [])].filter((owner, position, all) => all.findIndex((item) => item.stableId === owner.stableId) === position);
- const pmi = owners.flatMap((owner) => index.pmiByTarget.get(owner.stableId) ?? []).filter((item, position, all) => all.findIndex((candidate) => candidate.stableId === item.stableId) === position);
- return <><PropertyTable id={`brep-${entity.stableId}`} rows={rows(entity)} /><p className="semantic-provenance"><strong>Semantic owner(s):</strong> {owners.length ? owners.map((owner) => `${owner.kind} ${owner.label}${owner.sourceSpan ? ` · ${owner.sourceSpan}` : ""}`).join("; ") : "None published"}<br /><strong>Associated PMI:</strong> {pmi.length ? pmi.map((item) => item.label).join(", ") : "None"}</p><p className="semantic-provenance">Advanced traceability: Aetheris topology IDs are shown above. STEP entity IDs are not yet published by this fixture channel.</p></>;
+ const owners = [
+ ...(entity.topology?.faceIds ?? []).flatMap((id) => index.faceOwners.get(id) ?? []),
+ ...(entity.topology?.edgeIds ?? []).flatMap((id) => index.edgeOwners.get(id) ?? []),
+ ].filter(
+ (owner, position, all) =>
+ all.findIndex((item) => item.stableId === owner.stableId) === position,
+ );
+ const pmi = owners
+ .flatMap((owner) => index.pmiByTarget.get(owner.stableId) ?? [])
+ .filter(
+ (item, position, all) =>
+ all.findIndex((candidate) => candidate.stableId === item.stableId) === position,
+ );
+ return (
+ <>
+ <PropertyTable id={`brep-${entity.stableId}`} rows={rows(entity)} />
+ <p className="semantic-provenance">
+ <strong>Semantic owner(s):</strong>{" "}
+ {owners.length
+ ? owners
+ .map(
+ (owner) =>
+ `${owner.kind} ${owner.label}${owner.sourceSpan ? ` · ${owner.sourceSpan}` : ""}`,
+ )
+ .join("; ")
+ : "None published"}
+ <br />
+ <strong>Associated PMI:</strong>{" "}
+ {pmi.length ? pmi.map((item) => item.label).join(", ") : "None"}
+ </p>
+ <p className="semantic-provenance">
+ Advanced traceability: Aetheris topology IDs are shown above. STEP entity IDs are not yet
+ published by this fixture channel.
+ </p>
+ </>
+ );
}
function TemplateParameterTable({ entity }: { entity: CadmataEntity }) {
const records = useMemo(() => {
const metadata = entity.metadata ?? {};
- const names = Object.keys(metadata).filter((key) => key.startsWith("parameter.")).map((key) => key.slice("parameter.".length)).sort();
- return Table.toObjects(Table.define({ id: `template-parameters-${entity.stableId}`, columns: {
- parameter: names,
- type: names.map((name) => String(metadata[`parameterType.${name}`] ?? "Unknown")),
- value: names.map((name) => String(metadata[`parameter.${name}`] ?? "")),
- source: names.map((name) => `${String(metadata[`parameterSource.${name}`] ?? "Authored")} · ${String(metadata[`parameterStatus.${name}`] ?? "Bound")}`),
- } }));
+ const names = Object.keys(metadata)
+ .filter((key) => key.startsWith("parameter."))
+ .map((key) => key.slice("parameter.".length))
+ .sort();
+ return Table.toObjects(
+ Table.define({
+ id: `template-parameters-${entity.stableId}`,
+ columns: {
+ parameter: names,
+ type: names.map((name) => String(metadata[`parameterType.${name}`] ?? "Unknown")),
+ value: names.map((name) => String(metadata[`parameter.${name}`] ?? "")),
+ source: names.map(
+ (name) =>
+ `${String(metadata[`parameterSource.${name}`] ?? "Authored")} · ${String(metadata[`parameterStatus.${name}`] ?? "Bound")}`,
+ ),
+ },
+ }),
+ );
}, [entity]);
if (!records.length) return null;
- return <><h4>Template parameters</h4><table className="property-table"><thead><tr><th>Parameter</th><th>Type</th><th>Value</th><th>Source</th></tr></thead><tbody>{records.map((record) => <tr key={String(record.parameter)}><th scope="row">{record.parameter}</th><td>{record.type}</td><td>{record.value}</td><td>{record.source}</td></tr>)}</tbody></table></>;
+ return (
+ <>
+ <h4>Template parameters</h4>
+ <table className="property-table">
+ <thead>
+ <tr>
+ <th>Parameter</th>
+ <th>Type</th>
+ <th>Value</th>
+ <th>Source</th>
+ </tr>
+ </thead>
+ <tbody>
+ {records.map((record) => (
+ <tr key={String(record.parameter)}>
+ <th scope="row">{record.parameter}</th>
+ <td>{record.type}</td>
+ <td>{record.value}</td>
+ <td>{record.source}</td>
+ </tr>
+ ))}
+ </tbody>
+ </table>
+ </>
+ );
+}
+function GenericDetails({ entity }: { entity: CadmataEntity }) {
+ return (
+ <>
+ <PropertyTable
+ id={`semantic-${entity.stableId}`}
+ rows={rows(entity).filter((row) => !row.property.startsWith("parameter"))}
+ />
+ {entity.kind === "TemplateInstance" ? <TemplateParameterTable entity={entity} /> : null}
+ </>
+ );
}
-function GenericDetails({ entity }: { entity: CadmataEntity }) { return <><PropertyTable id={`semantic-${entity.stableId}`} rows={rows(entity).filter((row) => !row.property.startsWith("parameter"))} />{entity.kind === "TemplateInstance" ? <TemplateParameterTable entity={entity} /> : null}</>; }
-export function SemanticInspector({ artifact, selectedId, onSelect }: { artifact: CadmataVisualizationArtifact | null; selectedId: string | null; onSelect: (id: string) => void }) {
- if (!artifact) return <p>Load a real Firmament fixture to inspect compiler-published semantic structure.</p>;
+export function SemanticInspector({
+ artifact,
+ selectedId,
+ onSelect,
+}: {
+ artifact: CadmataVisualizationArtifact | null;
+ selectedId: string | null;
+ onSelect: (id: string) => void;
+}) {
+ if (!artifact)
+ return <p>Load a real Firmament fixture to inspect compiler-published semantic structure.</p>;
const entity = artifact.entities.find((candidate) => candidate.stableId === selectedId) ?? null;
- const details: ReactNode = entity ? matchKind((entity.kind.startsWith("BRep") ? { kind: "BRep" as const, entity } : entity.kind === "HoleDiameter" || entity.kind === "Datum" ? { kind: "Pmi" as const, entity } : { kind: "Generic" as const, entity }), { Pmi: ({ entity: item }) => <PmiDetails entity={item} />, BRep: ({ entity: item }) => <BrepDetails entity={item} artifact={artifact} />, Generic: ({ entity: item }) => <GenericDetails entity={item} /> }) as ReactNode : null;
- return <div className="semantic-inspector"><p><strong>{artifact.fixtureId}</strong> · {artifact.metrics?.entityCount ?? 0} published entities</p><div className="semantic-tree"><ul>{semanticTree(artifact).map((node) => <TreeNode key={node.entity.stableId} node={node} selectedId={selectedId} onSelect={onSelect} />)}</ul></div>{entity ? <div className="cadmata-inspector__details"><h3>{entity.label}</h3>{details}</div> : null}</div>;
+ const details: ReactNode = entity
+ ? (matchKind(
+ entity.kind.startsWith("BRep")
+ ? { kind: "BRep" as const, entity }
+ : entity.kind === "HoleDiameter" || entity.kind === "Datum"
+ ? { kind: "Pmi" as const, entity }
+ : { kind: "Generic" as const, entity },
+ {
+ Pmi: ({ entity: item }) => <PmiDetails entity={item} />,
+ BRep: ({ entity: item }) => <BrepDetails entity={item} artifact={artifact} />,
+ Generic: ({ entity: item }) => <GenericDetails entity={item} />,
+ },
+ ) as ReactNode)
+ : null;
+ return (
+ <div className="semantic-inspector">
+ <p>
+ <strong>{artifact.fixtureId}</strong> · {artifact.metrics?.entityCount ?? 0} published
+ entities
+ </p>
+ <div className="semantic-tree">
+ <ul>
+ {semanticTree(artifact).map((node) => (
+ <TreeNode
+ key={node.entity.stableId}
+ node={node}
+ selectedId={selectedId}
+ onSelect={onSelect}
+ />
+ ))}
+ </ul>
+ </div>
+ {entity ? (
+ <div className="cadmata-inspector__details">
+ <h3>{entity.label}</h3>
+ {details}
+ </div>
+ ) : null}
+ </div>
+ );
}
diff --git a/aetheris.client/src/viewer/AetherisViewport.tsx b/aetheris.client/src/viewer/AetherisViewport.tsx
index e5489828..3249ff22 100644
--- a/aetheris.client/src/viewer/AetherisViewport.tsx
+++ b/aetheris.client/src/viewer/AetherisViewport.tsx
@@ -571,7 +571,13 @@ export function AetherisViewport({
onSelect={onCadmataSelect}
/>
) : null}
- <PmiAnnotationLayer artifact={cadmataArtifact} visible={showPmi} selectedIds={selectedCadmataIds} onSelect={onCadmataSelect} theme={theme} />
+ <PmiAnnotationLayer
+ artifact={cadmataArtifact}
+ visible={showPmi}
+ selectedIds={selectedCadmataIds}
+ onSelect={onCadmataSelect}
+ theme={theme}
+ />
<PickRayCapture onPickRay={onPickRay} />
<OrbitControls makeDefault enablePan enableZoom />
</Canvas>
diff --git a/aetheris.client/src/viewer/PmiAnnotationLayer.tsx b/aetheris.client/src/viewer/PmiAnnotationLayer.tsx
index ac733541..ce9e7ff7 100644
--- a/aetheris.client/src/viewer/PmiAnnotationLayer.tsx
+++ b/aetheris.client/src/viewer/PmiAnnotationLayer.tsx
@@ -7,19 +7,73 @@ function anchor(entity: CadmataEntity): [number, number, number] | null {
const geometry = entity.geometry;
if (geometry?.type === "circle") return [geometry.center.x, geometry.center.y, geometry.center.z];
if (geometry?.type === "point") return [geometry.point.x, geometry.point.y, geometry.point.z];
- if (geometry?.type === "polyline" && geometry.points.length) { const p = geometry.points[geometry.points.length - 1]; return [p.x, p.y, p.z]; }
+ if (geometry?.type === "polyline" && geometry.points.length) {
+ const p = geometry.points[geometry.points.length - 1];
+ return [p.x, p.y, p.z];
+ }
return null;
}
-export function PmiAnnotationLayer({ artifact, visible, selectedIds, onSelect, theme }: { artifact: CadmataVisualizationArtifact | null; visible: boolean; selectedIds: Set<string>; onSelect: (id: string) => void; theme: ViewportTheme }) {
+export function PmiAnnotationLayer({
+ artifact,
+ visible,
+ selectedIds,
+ onSelect,
+ theme,
+}: {
+ artifact: CadmataVisualizationArtifact | null;
+ visible: boolean;
+ selectedIds: Set<string>;
+ onSelect: (id: string) => void;
+ theme: ViewportTheme;
+}) {
if (!visible || !artifact) return null;
- return <group name="semantic-pmi-annotations">{artifact.entities.filter((entity) => entity.kind === "HoleDiameter" || entity.kind === "Datum").map((entity) => {
- const target = anchor(entity); if (!target) return null;
- const isDatum = entity.kind === "Datum"; const selected = selectedIds.has(entity.stableId);
- const offset: [number, number, number] = [target[0] + (isDatum ? -12 : 12), target[1] + 2.4, target[2] + 0.2];
- const color = selected ? theme.annotation.selected : isDatum ? theme.annotation.datum : theme.annotation.dimension;
- return <group key={entity.stableId}><Line points={[target, offset]} color={theme.annotation.leader} lineWidth={selected ? 2.5 : 1.3} />
- <Html position={offset} center style={{ pointerEvents: "auto" }}><button className="pmi-callout" type="button" onClick={(event) => { event.stopPropagation(); onSelect(entity.stableId); }} style={{ color, background: theme.annotation.background, borderColor: color }} aria-label={`Inspect ${entity.label}`}><span>{isDatum ? `DATUM ${entity.label}` : formatPmiLabel(entity)}</span>{!isDatum && entity.metadata?.datumRefs ? <small>{String(entity.metadata.datumRefs)}</small> : null}</button></Html>
- </group>;
- })}</group>;
+ return (
+ <group name="semantic-pmi-annotations">
+ {artifact.entities
+ .filter((entity) => entity.kind === "HoleDiameter" || entity.kind === "Datum")
+ .map((entity) => {
+ const target = anchor(entity);
+ if (!target) return null;
+ const isDatum = entity.kind === "Datum";
+ const selected = selectedIds.has(entity.stableId);
+ const offset: [number, number, number] = [
+ target[0] + (isDatum ? -12 : 12),
+ target[1] + 2.4,
+ target[2] + 0.2,
+ ];
+ const color = selected
+ ? theme.annotation.selected
+ : isDatum
+ ? theme.annotation.datum
+ : theme.annotation.dimension;
+ return (
+ <group key={entity.stableId}>
+ <Line
+ points={[target, offset]}
+ color={theme.annotation.leader}
+ lineWidth={selected ? 2.5 : 1.3}
+ />
+ <Html position={offset} center style={{ pointerEvents: "auto" }}>
+ <button
+ className="pmi-callout"
+ type="button"
+ onClick={(event) => {
+ event.stopPropagation();
+ onSelect(entity.stableId);
+ }}
+ style={{ color, background: theme.annotation.background, borderColor: color }}
+ aria-label={`Inspect ${entity.label}`}
+ >
+ <span>{isDatum ? `DATUM ${entity.label}` : formatPmiLabel(entity)}</span>
+ {!isDatum && entity.metadata?.datumRefs ? (
+ <small>{String(entity.metadata.datumRefs)}</small>
+ ) : null}
+ </button>
+ </Html>
+ </group>
+ );
+ })}
+ </group>
+ );
}
diff --git a/aetheris.client/src/viewer/semanticInspection.ts b/aetheris.client/src/viewer/semanticInspection.ts
index 77685329..b02fe6c5 100644
--- a/aetheris.client/src/viewer/semanticInspection.ts
+++ b/aetheris.client/src/viewer/semanticInspection.ts
@@ -2,7 +2,19 @@ import type { CadmataEntity, CadmataVisualizationArtifact } from "./conceptVisua
export type SemanticTreeNode = { entity: CadmataEntity; children: SemanticTreeNode[] };
-const KIND_ORDER = ["Body", "Profile", "Pattern", "HoleFeature", "Counterbore", "EdgeFinish", "SlotFeature", "ConstructionPlane", "Datum", "HoleDiameter", "PMI"];
+const KIND_ORDER = [
+ "Body",
+ "Profile",
+ "Pattern",
+ "HoleFeature",
+ "Counterbore",
+ "EdgeFinish",
+ "SlotFeature",
+ "ConstructionPlane",
+ "Datum",
+ "HoleDiameter",
+ "PMI",
+];
/** Document-scoped index: all correspondence is published by Aetheris; no ownership is inferred here. */
export function indexSemanticInspection(artifact: CadmataVisualizationArtifact) {
@@ -12,29 +24,60 @@ export function indexSemanticInspection(artifact: CadmataVisualizationArtifact)
const pmiByTarget = new Map<string, CadmataEntity[]>();
for (const entity of artifact.entities) {
const publishedOwners = entity.kind.startsWith("BRep")
- ? (entity.parentIds ?? []).map((id) => byId.get(id)).filter((item): item is CadmataEntity => Boolean(item))
+ ? (entity.parentIds ?? [])
+ .map((id) => byId.get(id))
+ .filter((item): item is CadmataEntity => Boolean(item))
: [entity];
for (const faceId of entity.topology?.faceIds ?? []) {
const owners = faceOwners.get(faceId) ?? [];
- for (const owner of publishedOwners) if (!owner.kind.startsWith("BRep") && !owners.some((item) => item.stableId === owner.stableId)) owners.push(owner);
+ for (const owner of publishedOwners)
+ if (
+ !owner.kind.startsWith("BRep") &&
+ !owners.some((item) => item.stableId === owner.stableId)
+ )
+ owners.push(owner);
faceOwners.set(faceId, owners);
}
for (const edgeId of entity.topology?.edgeIds ?? []) {
const owners = edgeOwners.get(edgeId) ?? [];
- for (const owner of publishedOwners) if (!owner.kind.startsWith("BRep") && !owners.some((item) => item.stableId === owner.stableId)) owners.push(owner);
+ for (const owner of publishedOwners)
+ if (
+ !owner.kind.startsWith("BRep") &&
+ !owners.some((item) => item.stableId === owner.stableId)
+ )
+ owners.push(owner);
edgeOwners.set(edgeId, owners);
}
const target = entity.metadata?.targetSemanticId;
- if ((entity.kind === "Datum" || entity.kind === "HoleDiameter") && typeof target === "string") (pmiByTarget.get(target) ?? pmiByTarget.set(target, []).get(target)!).push(entity);
+ if ((entity.kind === "Datum" || entity.kind === "HoleDiameter") && typeof target === "string")
+ (pmiByTarget.get(target) ?? pmiByTarget.set(target, []).get(target)!).push(entity);
}
- const brepFaceById = new Map(artifact.entities.flatMap((entity) => entity.kind === "BRepFace" ? (entity.topology?.faceIds ?? []).map((id) => [id, entity] as const) : []));
- const brepEdgeById = new Map(artifact.entities.flatMap((entity) => entity.kind === "BRepEdge" ? (entity.topology?.edgeIds ?? []).map((id) => [id, entity] as const) : []));
+ const brepFaceById = new Map(
+ artifact.entities.flatMap((entity) =>
+ entity.kind === "BRepFace"
+ ? (entity.topology?.faceIds ?? []).map((id) => [id, entity] as const)
+ : [],
+ ),
+ );
+ const brepEdgeById = new Map(
+ artifact.entities.flatMap((entity) =>
+ entity.kind === "BRepEdge"
+ ? (entity.topology?.edgeIds ?? []).map((id) => [id, entity] as const)
+ : [],
+ ),
+ );
return { byId, faceOwners, edgeOwners, pmiByTarget, brepFaceById, brepEdgeById };
}
-export function resolvePublishedBrepEntity(artifact: CadmataVisualizationArtifact, kind: "Face" | "Edge", id: number) {
+export function resolvePublishedBrepEntity(
+ artifact: CadmataVisualizationArtifact,
+ kind: "Face" | "Edge",
+ id: number,
+) {
const index = indexSemanticInspection(artifact);
- return kind === "Face" ? index.brepFaceById.get(id) ?? null : index.brepEdgeById.get(id) ?? null;
+ return kind === "Face"
+ ? (index.brepFaceById.get(id) ?? null)
+ : (index.brepEdgeById.get(id) ?? null);
}
export function semanticTree(artifact: CadmataVisualizationArtifact): SemanticTreeNode[] {
@@ -43,10 +86,18 @@ export function semanticTree(artifact: CadmataVisualizationArtifact): SemanticTr
const roots: CadmataEntity[] = [];
for (const entity of artifact.entities.filter((item) => !item.kind.startsWith("BRep"))) {
const parent = entity.parentIds?.find((id) => byId.has(id));
- if (!parent) roots.push(entity); else (children.get(parent) ?? children.set(parent, []).get(parent)!).push(entity);
+ if (!parent) roots.push(entity);
+ else (children.get(parent) ?? children.set(parent, []).get(parent)!).push(entity);
}
- const sort = (items: CadmataEntity[]) => items.sort((a, b) => (KIND_ORDER.indexOf(a.kind) - KIND_ORDER.indexOf(b.kind)) || a.label.localeCompare(b.label));
- const build = (entity: CadmataEntity): SemanticTreeNode => ({ entity, children: sort(children.get(entity.stableId) ?? []).map(build) });
+ const sort = (items: CadmataEntity[]) =>
+ items.sort(
+ (a, b) =>
+ KIND_ORDER.indexOf(a.kind) - KIND_ORDER.indexOf(b.kind) || a.label.localeCompare(b.label),
+ );
+ const build = (entity: CadmataEntity): SemanticTreeNode => ({
+ entity,
+ children: sort(children.get(entity.stableId) ?? []).map(build),
+ });
return sort(roots).map(build);
}
diff --git a/aetheris.client/src/viewer/viewportTheme.ts b/aetheris.client/src/viewer/viewportTheme.ts
index e185cd28..8e7dd0ef 100644
--- a/aetheris.client/src/viewer/viewportTheme.ts
+++ b/aetheris.client/src/viewer/viewportTheme.ts
@@ -34,7 +34,14 @@ export interface ViewportTheme {
postProcess: { outline: boolean; colorGrade: "neutral" | "pastel" };
cameraPresentation: { position: readonly [number, number, number]; zoom: number };
axis: { x: string; y: string; z: string; label: string };
- annotation: { text: string; background: string; leader: string; datum: string; dimension: string; selected: string };
+ annotation: {
+ text: string;
+ background: string;
+ leader: string;
+ datum: string;
+ dimension: string;
+ selected: string;
+ };
}
export const ATELIER_VIEWPORT_THEME: ViewportTheme = {
@@ -73,7 +80,14 @@ export const ATELIER_VIEWPORT_THEME: ViewportTheme = {
postProcess: { outline: false, colorGrade: "neutral" },
cameraPresentation: { position: [6, 6, 6], zoom: 90 },
axis: { x: "#a46757", y: "#6f8b64", z: "#b39b62", label: "#cbc7ba" },
- annotation: { text: "#fff9e8", background: "#1b1d1b", leader: "#e8d8a2", datum: "#8ec8d2", dimension: "#f0cf68", selected: "#ffffff" },
+ annotation: {
+ text: "#fff9e8",
+ background: "#1b1d1b",
+ leader: "#e8d8a2",
+ datum: "#8ec8d2",
+ dimension: "#f0cf68",
+ selected: "#ffffff",
+ },
};
export const MONUMENT_VIEWPORT_THEME: ViewportTheme = {
@@ -105,7 +119,14 @@ export const MONUMENT_VIEWPORT_THEME: ViewportTheme = {
fog: { enabled: true, color: "#d9cfbd", near: 34, far: 115 },
postProcess: { outline: false, colorGrade: "pastel" },
axis: { x: "#a2535c", y: "#528378", z: "#9e7d45", label: "#5f554c" },
- annotation: { text: "#302b26", background: "#fff6df", leader: "#5d6d6c", datum: "#246e79", dimension: "#915642", selected: "#000000" },
+ annotation: {
+ text: "#302b26",
+ background: "#fff6df",
+ leader: "#5d6d6c",
+ datum: "#246e79",
+ dimension: "#915642",
+ selected: "#000000",
+ },
};
export const VIEWPORT_THEMES = [ATELIER_VIEWPORT_THEME, MONUMENT_VIEWPORT_THEME] as const;
diff --git a/docs/preview2/surface-mesh-ir-m1.md b/docs/preview2/surface-mesh-ir-m1.md
index 19aaa8ef..365374b9 100644
--- a/docs/preview2/surface-mesh-ir-m1.md
+++ b/docs/preview2/surface-mesh-ir-m1.md
@@ -41,3 +41,12 @@ On the Debug `net10.0` build, a 100-iteration in-process comparison (not a bench
Multi-loop planar trims (including the through-hole plate fixture), arbitrary clipped boundary cells, Cone, Sphere, Torus, and B-spline patches remain on `LegacyTessellator`. That fallback is intentional and observable through `meshPipeline`; it is not a new mesh authority. Therefore this M1 slice should be treated as an architectural migration baseline, not a global replacement or an FEA/printing certification. Cadmata remains triangle-facing and receives the lowered `DisplayFaceMeshPatch` contract unchanged.
Recommended next milestone: **P2-SURFACE-MESH-IR-M2 — Cone/Sphere/Torus and harder trimmed analytic patches**, beginning with multi-loop planar clipping/through-hole ownership and true deterministic quad subdivision.
+
+## Migration status update
+
+M2 subsequently added the multi-loop through-hole plate and validated STL path.
+M3 now extends the common IR to full circular-trim Cone strips, six-chart Sphere
+primitives, and doubly-periodic Torus primitives. See
+[surface-mesh-ir-m2.md](surface-mesh-ir-m2.md) and
+[surface-mesh-ir-m3.md](surface-mesh-ir-m3.md); general conic trim bands and
+arbitrary trimmed curved patches remain deliberate legacy fallbacks.
diff --git a/docs/preview2/surface-mesh-ir-m2.md b/docs/preview2/surface-mesh-ir-m2.md
index eaaca0a8..0d6688bf 100644
--- a/docs/preview2/surface-mesh-ir-m2.md
+++ b/docs/preview2/surface-mesh-ir-m2.md
@@ -62,4 +62,7 @@ The trim rings are cyclically phase-aligned before band construction. Orientatio
- Cadmata has not yet been migrated to render the validated final mesh directly; its established STEP display route remains intact.
- No runtime LOD, streaming refinement, mesh repair, glTF, 3MF, or volumetric meshing was introduced.
-Recommended next tooling milestone: **P2-TSPACK-STABILIZE-M1**, before returning to **P2-SURFACE-MESH-IR-M3** (Cone, Sphere, Torus, and harder trims).
+M3 has now added full circular-trim Cone strips, cube-chart Sphere primitives,
+and doubly-periodic Torus primitives to the common IR. See
+[surface-mesh-ir-m3.md](surface-mesh-ir-m3.md) for the supported boundary and
+trim subset; general conic trim bands and HexBolt remain explicit follow-up work.
diff --git a/docs/preview2/surface-mesh-ir-m3.md b/docs/preview2/surface-mesh-ir-m3.md
new file mode 100644
index 00000000..141cd7a1
--- /dev/null
+++ b/docs/preview2/surface-mesh-ir-m3.md
@@ -0,0 +1,73 @@
+# P2-SURFACE-MESH-IR-M3
+
+M3 extends the derived `SurfaceMeshDocument` path from Plane/Cylinder to the
+currently representable exact analytic supports: Cone, Sphere, and Torus. The
+B-rep remains authoritative for topology, trim curves, volume, and mass.
+Triangles remain a deterministic lowering/export representation.
+
+## Audit and boundary authority
+
+The legacy `BrepDisplayTessellator` is still the broad fallback. Its curved
+paths project trim loops into support UV, normalize periodic seams, and emit
+triangles directly. Projection and periodic trim topology are genuine geometric
+work; choosing grid diagonals inside the same triangle-native routine is legacy
+output complexity. M3 keeps the former in the exact B-rep/IR contract and keeps
+cells structured until final lowering.
+
+Each B-rep edge has one `SharedEdgeSamplePlan`, ordered by exact curve parameter
+and consumed in coedge orientation. M3 adds bounded deterministic `Hyperbola3`
+sampling: parameter intervals split at their midpoint while mid-chord deviation
+exceeds policy. Lines remain minimal; circle density remains chordal/normal-error
+driven. Hyperbola samples are one shared boundary authority, though arbitrary
+cone/plane conic trim-band covering remains an explicit legacy case.
+
+## Support topology
+
+| Support | M3 topology | Seam/normal policy |
+| --- | --- | --- |
+| Cone | Full circular-trim frusta use one angular × generator quad strip. | Circular trim rings are shared B-rep samples; angular closure is explicit; `ConeSurface.Normal` is used. |
+| Sphere | Six cube charts, each a 6 × 6 structured quad grid. | Integer cube-grid coordinates reuse IDs at chart seams; no latitude/longitude pole fan; normal is exact radial support normal. |
+| Torus | Major-angle × minor-angle periodic quad grid. | Both wraps reuse grid IDs; B-rep seam plans are injected into matching grid locations; `TorusSurface.Normal` is used. |
+
+Sphere chart seams are implementation seams, not B-rep cracks: they use the
+same `SurfaceMeshVertex` IDs and analytic support, so lowering has no duplicate
+visible seam or hard edge. Torus resolution is directional: major loops use
+`R+r` as chord radius while minor loops use `r`, rather than applying a single
+isotropic density rule.
+
+## Validation and evidence
+
+`SurfaceMeshIrValidator` rejects invalid shared boundaries, missing/repeated
+cell vertices, and zero-area cells. `TriangleMeshValidator` then verifies
+closed incidence, duplicates, zero-area triangles, connectedness, and outward
+orientation. Exact support normals now cover Plane, Cylinder, Cone, Sphere,
+and Torus; normals are never averaged from triangle faces.
+
+Focused `SurfaceMeshIrTests` prove a 36-cell all-quad Cone strip with watertight
+planar caps, a watertight six-chart Sphere with shared seam IDs and unit analytic
+normals, and a watertight all-quad doubly-periodic Torus that consumes both B-rep
+seam identities. Existing M2 through-hole/STL coverage remains in the suite.
+
+The IR reports patch/cell/quad/exception counts, pre-lowering triangle count,
+maximum sampled chord deviation, and a deterministic hash. It does not yet
+compute curved-cell aspect/sliver histograms, per-stage timing, or a Cadmata
+pre-triangulation debug overlay. Vertices retain parameter coordinates and exact
+normal support; future DCC export still needs explicit material-group metadata.
+
+## Limits and next work
+
+The default Cadmata/display route remains the legacy display packet. The new
+route is explicitly selectable through `TessellateSurfaceMeshIr`; it succeeds
+only for the documented complete subset and otherwise reports fallback rather
+than silently mixing pipelines. Binary STL continues to consume validated final
+`TriangleMesh`.
+
+M3 does not claim general conic trimming, root-fillet/whole-HexBolt migration,
+arbitrary spherical/toroidal trims, runtime LOD, Blender/glTF export, or FEA
+volume meshing. The structured surface patches are nevertheless a viable seam
+for future boundary-conforming/cut-cell FEA and DCC polygon export without
+making either future consumer the present mesh authority.
+
+Recommended next milestone: **P2-SURFACE-MESH-IR-M4** for bounded conic trim
+bands (Cone/Plane Hyperbola, root fillet, HexBolt), then
+**P2-MESH-DCC-EXPORT-M1** once quad/polygon metadata is complete.