Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

M17f widen analytic lane to sphere and torus rendering

Yuechen Li2f5c5a1df643
diff --git a/Aetheris.Server.Tests/KernelApiIntegrationTests.cs b/Aetheris.Server.Tests/KernelApiIntegrationTests.cs
index d2b86a2b..f406093c 100644
--- a/Aetheris.Server.Tests/KernelApiIntegrationTests.cs
+++ b/Aetheris.Server.Tests/KernelApiIntegrationTests.cs
@@ -122,6 +122,33 @@ public sealed class KernelApiIntegrationTests : IClassFixture<WebApplicationFact
Assert.Null(prepared.Data.TessellationFallback);
}
+ [Fact]
+ public async Task DisplayPrepare_SpherePrimitive_UsesAnalyticLaneWithSphereGeometry()
+ {
+ var document = await CreateDocumentAsync("/api/v1/documents");
+ var response = await _client.PostAsJsonAsync(
+ $"/api/v1/documents/{document.Data!.DocumentId}/bodies/primitives/sphere",
+ new SphereCreateRequestDto(5));
+ response.EnsureSuccessStatusCode();
+ var sphere = await response.Content.ReadFromJsonAsync<ApiResponseDto<BodyCreatedResponseDto>>();
+ Assert.NotNull(sphere);
+ Assert.True(sphere!.Success);
+
+ var prepared = await PrepareDisplayAsync(document.Data.DocumentId, sphere.Data!.BodyId);
+
+ Assert.Equal("analytic-only", prepared.Data!.Lane);
+ Assert.NotEmpty(prepared.Data.AnalyticPacket.AnalyticFaces);
+ Assert.Contains(prepared.Data.AnalyticPacket.AnalyticFaces, face =>
+ face.SurfaceKind == "Sphere"
+ && face.SphereGeometry is not null
+ && face.PlaneGeometry is null
+ && face.CylinderGeometry is null
+ && face.ConeGeometry is null
+ && face.TorusGeometry is null);
+ Assert.Empty(prepared.Data.AnalyticPacket.FallbackFaces);
+ Assert.Null(prepared.Data.TessellationFallback);
+ }
+
[Fact]
public async Task DisplayPrepare_ImportedUnsupportedBody_PreservesFallbackRouting()
{
diff --git a/Aetheris.Server/Api/ApiMappings.cs b/Aetheris.Server/Api/ApiMappings.cs
index b291dd27..8f976ffe 100644
--- a/Aetheris.Server/Api/ApiMappings.cs
+++ b/Aetheris.Server/Api/ApiMappings.cs
@@ -90,7 +90,20 @@ public static class ApiMappings
ToVectorDto(cylinder.XAxis.ToVector()),
ToVectorDto(cylinder.YAxis.ToVector()),
cylinder.Radius) : null,
- face.SurfaceGeometry.Cone is { } cone ? ToConeGeometryDto(cone) : null)).ToArray(),
+ face.SurfaceGeometry.Cone is { } cone ? ToConeGeometryDto(cone) : null,
+ face.SurfaceGeometry.Sphere is { } sphere ? new AnalyticDisplaySphereGeometryDto(
+ ToPointDto(sphere.Center),
+ ToVectorDto(sphere.Axis.ToVector()),
+ ToVectorDto(sphere.XAxis.ToVector()),
+ ToVectorDto(sphere.YAxis.ToVector()),
+ sphere.Radius) : null,
+ face.SurfaceGeometry.Torus is { } torus ? new AnalyticDisplayTorusGeometryDto(
+ ToPointDto(torus.Center),
+ ToVectorDto(torus.Axis.ToVector()),
+ ToVectorDto(torus.XAxis.ToVector()),
+ ToVectorDto(torus.YAxis.ToVector()),
+ torus.MajorRadius,
+ torus.MinorRadius) : null)).ToArray(),
packet.FallbackFaces.Select(face => new AnalyticDisplayFallbackFaceDto(
face.FaceId.Value,
face.ShellId.Value,
diff --git a/Aetheris.Server/Contracts/ApiContracts.cs b/Aetheris.Server/Contracts/ApiContracts.cs
index 0a7dc39f..eb3609da 100644
--- a/Aetheris.Server/Contracts/ApiContracts.cs
+++ b/Aetheris.Server/Contracts/ApiContracts.cs
@@ -96,6 +96,21 @@ public sealed record AnalyticDisplayConeGeometryDto(
Vector3Dto YAxis,
double SemiAngleRadians);
+public sealed record AnalyticDisplaySphereGeometryDto(
+ Point3Dto Center,
+ Vector3Dto Axis,
+ Vector3Dto XAxis,
+ Vector3Dto YAxis,
+ double Radius);
+
+public sealed record AnalyticDisplayTorusGeometryDto(
+ Point3Dto Center,
+ Vector3Dto Axis,
+ Vector3Dto XAxis,
+ Vector3Dto YAxis,
+ double MajorRadius,
+ double MinorRadius);
+
public sealed record AnalyticDisplayFaceDto(
int FaceId,
int ShellId,
@@ -106,7 +121,9 @@ public sealed record AnalyticDisplayFaceDto(
AnalyticDisplayFaceDomainHintDto? DomainHint,
AnalyticDisplayPlaneGeometryDto? PlaneGeometry,
AnalyticDisplayCylinderGeometryDto? CylinderGeometry,
- AnalyticDisplayConeGeometryDto? ConeGeometry);
+ AnalyticDisplayConeGeometryDto? ConeGeometry,
+ AnalyticDisplaySphereGeometryDto? SphereGeometry,
+ AnalyticDisplayTorusGeometryDto? TorusGeometry);
public sealed record AnalyticDisplayFallbackFaceDto(
int FaceId,
diff --git a/aetheris.client/src/__tests__/displaySceneBuilder.test.ts b/aetheris.client/src/__tests__/displaySceneBuilder.test.ts
index d0dd5322..a7a7479c 100644
--- a/aetheris.client/src/__tests__/displaySceneBuilder.test.ts
+++ b/aetheris.client/src/__tests__/displaySceneBuilder.test.ts
@@ -25,6 +25,8 @@ const analyticPreparation: DisplayPreparationResponseDto = {
radius: 0.5,
},
coneGeometry: null,
+ sphereGeometry: null,
+ torusGeometry: null,
},
],
fallbackFaces: [],
@@ -91,6 +93,85 @@ describe('buildDisplaySceneData', () => {
expect(mapFallback).not.toHaveBeenCalled();
});
+ it('keeps analytic-only lane for sphere packets and does not call fallback mapping', () => {
+ const spherePreparation: DisplayPreparationResponseDto = {
+ ...analyticPreparation,
+ analyticPacket: {
+ ...analyticPreparation.analyticPacket,
+ analyticFaces: [
+ {
+ faceId: 21,
+ shellId: 1,
+ shellRole: 'Outer',
+ surfaceGeometryId: 210,
+ surfaceKind: 'Sphere',
+ loopCount: 0,
+ domainHint: null,
+ planeGeometry: null,
+ cylinderGeometry: null,
+ coneGeometry: null,
+ sphereGeometry: {
+ center: { x: 0, y: 0, z: 0 },
+ axis: { x: 0, y: 0, z: 1 },
+ xAxis: { x: 1, y: 0, z: 0 },
+ yAxis: { x: 0, y: 1, z: 0 },
+ radius: 2,
+ },
+ torusGeometry: null,
+ },
+ ],
+ },
+ };
+ const mapAnalytic = vi.fn().mockReturnValue({ faces: [], edges: [] });
+ const mapFallback = vi.fn().mockReturnValue({ faces: [], edges: [] });
+
+ const result = buildDisplaySceneData(spherePreparation, { mapAnalytic, mapFallback });
+
+ expect(result.renderPath).toBe('analytic-only');
+ expect(mapAnalytic).toHaveBeenCalledOnce();
+ expect(mapFallback).not.toHaveBeenCalled();
+ });
+
+ it('keeps analytic-only lane for torus packets and does not call fallback mapping', () => {
+ const torusPreparation: DisplayPreparationResponseDto = {
+ ...analyticPreparation,
+ analyticPacket: {
+ ...analyticPreparation.analyticPacket,
+ analyticFaces: [
+ {
+ faceId: 22,
+ shellId: 1,
+ shellRole: 'Outer',
+ surfaceGeometryId: 220,
+ surfaceKind: 'Torus',
+ loopCount: 0,
+ domainHint: null,
+ planeGeometry: null,
+ cylinderGeometry: null,
+ coneGeometry: null,
+ sphereGeometry: null,
+ torusGeometry: {
+ center: { x: 0, y: 0, z: 0 },
+ axis: { x: 0, y: 0, z: 1 },
+ xAxis: { x: 1, y: 0, z: 0 },
+ yAxis: { x: 0, y: 1, z: 0 },
+ majorRadius: 5,
+ minorRadius: 1.5,
+ },
+ },
+ ],
+ },
+ };
+ const mapAnalytic = vi.fn().mockReturnValue({ faces: [], edges: [] });
+ const mapFallback = vi.fn().mockReturnValue({ faces: [], edges: [] });
+
+ const result = buildDisplaySceneData(torusPreparation, { mapAnalytic, mapFallback });
+
+ expect(result.renderPath).toBe('analytic-only');
+ expect(mapAnalytic).toHaveBeenCalledOnce();
+ expect(mapFallback).not.toHaveBeenCalled();
+ });
+
it('routes fallback-only lane to tessellation fallback mapping', () => {
const mapAnalytic = vi.fn().mockReturnValue({ faces: [], edges: [] });
const mapFallback = vi.fn().mockReturnValue({ faces: [], edges: [] });
@@ -115,6 +196,87 @@ describe('buildDisplaySceneData', () => {
});
describe('mapAnalyticPacketToRenderData', () => {
+ it('maps sphere packet faces deterministically', () => {
+ const spherePacket = {
+ bodyId: 2,
+ analyticFaces: [
+ {
+ faceId: 200,
+ shellId: 1,
+ shellRole: 'Outer' as const,
+ surfaceGeometryId: 2000,
+ surfaceKind: 'Sphere',
+ loopCount: 0,
+ domainHint: null,
+ planeGeometry: null,
+ cylinderGeometry: null,
+ coneGeometry: null,
+ sphereGeometry: {
+ center: { x: 1, y: 2, z: 3 },
+ axis: { x: 0, y: 0, z: 1 },
+ xAxis: { x: 1, y: 0, z: 0 },
+ yAxis: { x: 0, y: 1, z: 0 },
+ radius: 4,
+ },
+ torusGeometry: null,
+ },
+ ],
+ fallbackFaces: [],
+ };
+
+ const first = mapAnalyticPacketToRenderData(spherePacket);
+ const second = mapAnalyticPacketToRenderData(spherePacket);
+
+ expect(first.faces).toHaveLength(1);
+ expect(first.faces[0].positions.length).toBeGreaterThan(0);
+ expect(first.faces[0].normals.length).toBe(first.faces[0].positions.length);
+ expect(first.faces[0].indices.length).toBeGreaterThan(0);
+ expect(Array.from(first.faces[0].positions)).toEqual(Array.from(second.faces[0].positions));
+ expect(Array.from(first.faces[0].normals)).toEqual(Array.from(second.faces[0].normals));
+ expect(Array.from(first.faces[0].indices)).toEqual(Array.from(second.faces[0].indices));
+ });
+
+ it('maps torus packet faces deterministically', () => {
+ const torusPacket = {
+ bodyId: 3,
+ analyticFaces: [
+ {
+ faceId: 300,
+ shellId: 1,
+ shellRole: 'Outer' as const,
+ surfaceGeometryId: 3000,
+ surfaceKind: 'Torus',
+ loopCount: 0,
+ domainHint: null,
+ planeGeometry: null,
+ cylinderGeometry: null,
+ coneGeometry: null,
+ sphereGeometry: null,
+ torusGeometry: {
+ center: { x: 0, y: 0, z: 0 },
+ axis: { x: 0, y: 0, z: 1 },
+ xAxis: { x: 1, y: 0, z: 0 },
+ yAxis: { x: 0, y: 1, z: 0 },
+ majorRadius: 6,
+ minorRadius: 1,
+ },
+ },
+ ],
+ fallbackFaces: [],
+ };
+
+ const first = mapAnalyticPacketToRenderData(torusPacket);
+ const second = mapAnalyticPacketToRenderData(torusPacket);
+
+ expect(first.faces).toHaveLength(1);
+ expect(first.faces[0].positions.length).toBeGreaterThan(0);
+ expect(first.faces[0].normals.length).toBe(first.faces[0].positions.length);
+ expect(first.faces[0].indices.length).toBeGreaterThan(0);
+ expect(Array.from(first.faces[0].positions)).toEqual(Array.from(second.faces[0].positions));
+ expect(Array.from(first.faces[0].normals)).toEqual(Array.from(second.faces[0].normals));
+ expect(Array.from(first.faces[0].indices)).toEqual(Array.from(second.faces[0].indices));
+ });
+
it('is deterministic for the same analytic packet input', () => {
const first = mapAnalyticPacketToRenderData(analyticPreparation.analyticPacket);
const second = mapAnalyticPacketToRenderData(analyticPreparation.analyticPacket);
diff --git a/aetheris.client/src/api/aetherisApi.ts b/aetheris.client/src/api/aetherisApi.ts
index f481083b..19f2d30f 100644
--- a/aetheris.client/src/api/aetherisApi.ts
+++ b/aetheris.client/src/api/aetherisApi.ts
@@ -131,6 +131,23 @@ export interface AnalyticDisplayConeGeometryDto {
semiAngleRadians: number;
}
+export interface AnalyticDisplaySphereGeometryDto {
+ center: Point3Dto;
+ axis: Vector3Dto;
+ xAxis: Vector3Dto;
+ yAxis: Vector3Dto;
+ radius: number;
+}
+
+export interface AnalyticDisplayTorusGeometryDto {
+ center: Point3Dto;
+ axis: Vector3Dto;
+ xAxis: Vector3Dto;
+ yAxis: Vector3Dto;
+ majorRadius: number;
+ minorRadius: number;
+}
+
export interface AnalyticDisplayFaceDto {
faceId: number;
shellId: number;
@@ -142,6 +159,8 @@ export interface AnalyticDisplayFaceDto {
planeGeometry: AnalyticDisplayPlaneGeometryDto | null;
cylinderGeometry: AnalyticDisplayCylinderGeometryDto | null;
coneGeometry: AnalyticDisplayConeGeometryDto | null;
+ sphereGeometry: AnalyticDisplaySphereGeometryDto | null;
+ torusGeometry: AnalyticDisplayTorusGeometryDto | null;
}
export interface AnalyticDisplayFallbackFaceDto {
diff --git a/aetheris.client/src/viewer/analyticMapper.ts b/aetheris.client/src/viewer/analyticMapper.ts
index 37539185..008f35f4 100644
--- a/aetheris.client/src/viewer/analyticMapper.ts
+++ b/aetheris.client/src/viewer/analyticMapper.ts
@@ -159,6 +159,111 @@ function buildConePatch(face: AnalyticDisplayFaceDto): RenderFacePatch | null {
};
}
+function buildSpherePatch(face: AnalyticDisplayFaceDto): RenderFacePatch | null {
+ if (!face.sphereGeometry) {
+ return null;
+ }
+
+ const center = toArray(face.sphereGeometry.center);
+ const axis = toArray(face.sphereGeometry.axis);
+ const xAxis = toArray(face.sphereGeometry.xAxis);
+ const yAxis = toArray(face.sphereGeometry.yAxis);
+ const radius = face.sphereGeometry.radius;
+ const longitudinalSegments = 32;
+ const latitudinalSegments = 16;
+
+ const positions: number[] = [];
+ const normals: number[] = [];
+ const indices: number[] = [];
+
+ for (let i = 0; i <= longitudinalSegments; i += 1) {
+ const u = (i / longitudinalSegments) * TAU;
+ const cosU = Math.cos(u);
+ const sinU = Math.sin(u);
+
+ for (let j = 0; j <= latitudinalSegments; j += 1) {
+ const v = ((j / latitudinalSegments) * Math.PI) - (Math.PI * 0.5);
+ const cosV = Math.cos(v);
+ const sinV = Math.sin(v);
+
+ const normal = normalize(add(add(mul(xAxis, cosV * cosU), mul(yAxis, cosV * sinU)), mul(axis, sinV)));
+ const point = add(center, mul(normal, radius));
+ positions.push(...point);
+ normals.push(...normal);
+
+ if (i < longitudinalSegments && j < latitudinalSegments) {
+ const stride = latitudinalSegments + 1;
+ const a = (i * stride) + j;
+ const b = a + 1;
+ const c = a + stride;
+ const d = c + 1;
+ indices.push(a, c, d, a, d, b);
+ }
+ }
+ }
+
+ return {
+ faceId: face.faceId,
+ positions: new Float32Array(positions),
+ normals: new Float32Array(normals),
+ indices: new Uint32Array(indices),
+ };
+}
+
+function buildTorusPatch(face: AnalyticDisplayFaceDto): RenderFacePatch | null {
+ if (!face.torusGeometry) {
+ return null;
+ }
+
+ const center = toArray(face.torusGeometry.center);
+ const axis = toArray(face.torusGeometry.axis);
+ const xAxis = toArray(face.torusGeometry.xAxis);
+ const yAxis = toArray(face.torusGeometry.yAxis);
+ const majorRadius = face.torusGeometry.majorRadius;
+ const minorRadius = face.torusGeometry.minorRadius;
+ const majorSegments = 32;
+ const minorSegments = 16;
+
+ const positions: number[] = [];
+ const normals: number[] = [];
+ const indices: number[] = [];
+
+ for (let i = 0; i <= majorSegments; i += 1) {
+ const u = (i / majorSegments) * TAU;
+ const cosU = Math.cos(u);
+ const sinU = Math.sin(u);
+ const majorDirection = normalize(add(mul(xAxis, cosU), mul(yAxis, sinU)));
+
+ for (let j = 0; j <= minorSegments; j += 1) {
+ const v = (j / minorSegments) * TAU;
+ const cosV = Math.cos(v);
+ const sinV = Math.sin(v);
+
+ const normal = normalize(add(mul(majorDirection, cosV), mul(axis, sinV)));
+ const ringCenter = add(center, mul(majorDirection, majorRadius));
+ const point = add(ringCenter, mul(normal, minorRadius));
+ positions.push(...point);
+ normals.push(...normal);
+
+ if (i < majorSegments && j < minorSegments) {
+ const stride = minorSegments + 1;
+ const a = (i * stride) + j;
+ const b = a + 1;
+ const c = a + stride;
+ const d = c + 1;
+ indices.push(a, c, d, a, d, b);
+ }
+ }
+ }
+
+ return {
+ faceId: face.faceId,
+ positions: new Float32Array(positions),
+ normals: new Float32Array(normals),
+ indices: new Uint32Array(indices),
+ };
+}
+
function mapFace(face: AnalyticDisplayFaceDto): RenderFacePatch | null {
if (face.surfaceKind === 'Plane') {
return buildPlanePatch(face);
@@ -172,6 +277,14 @@ function mapFace(face: AnalyticDisplayFaceDto): RenderFacePatch | null {
return buildConePatch(face);
}
+ if (face.surfaceKind === 'Sphere') {
+ return buildSpherePatch(face);
+ }
+
+ if (face.surfaceKind === 'Torus') {
+ return buildTorusPatch(face);
+ }
+
return null;
}