Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/kernel-mcp/kernelMcp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,19 @@ describe('kernel MCP server', () => {
expect(summary.bodies[0].volume).toBeCloseTo(12 - Math.PI * 0.41, 3);
});

it('reads a cylinder\'s caps and side at their true areas', async () => {
const made = await ok('make_cylinder', { body: 'drum', center: [20, 0, 0], radius: 1, height: 2 });
const faces = await ok('list_faces', { body: 'drum' });
expect(faces.faces).toHaveLength(made.created.faces.length);
const areas = faces.faces.map((f: { area: number }) => f.area).sort((x: number, y: number) => x - y);
expect(areas[0]).toBeCloseTo(Math.PI, 2);
expect(areas[1]).toBeCloseTo(Math.PI, 2);
expect(areas.at(-1)).toBeCloseTo(4 * Math.PI, 1);
const caps = faces.faces.filter((f: { flat: boolean }) => f.flat);
expect(caps.map((f: { normal: number[] }) => Math.abs(f.normal[2]))).toEqual([1, 1]);
await ok('delete_body', { body: 'drum' });
});

it('leaves the model unchanged when the kernel refuses', async () => {
const before = await ok('model_summary');
const r = await call('fillet', { edgeId: 'no-such-edge', radius: 0.1 });
Expand Down
7 changes: 2 additions & 5 deletions src/kernel-mcp/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,12 @@ export function facesOfRaw(mesh: HalfEdgeMesh, ids?: readonly string[]): FaceInf
const f = q.face(fid);
if (!f) continue;
const g = faceGeometry(mesh, fid);
// The record's area reads the outline's corners, and a face bounded by one closed curve (a disc)
// has no outline polygon, so a face with any curved side reads its triangles instead.
const straight = f.edgeIds.every((e) => q.edge(e)?.curve === 'line');
out.push({
id: fid,
surface: q.faceSurface(fid)?.kind ?? f.surface,
flat: f.flat,
normal: !f.flat ? null : straight && f.normal ? unit(f.normal) : g ? g.normal : null,
area: straight && f.area ? f.area : g?.area ?? f.area ?? 0,
normal: f.flat && f.normal ? unit(f.normal) : null,
area: f.area ?? g?.area ?? 0,
center: g ? [...g.center] : [],
edges: f.edgeIds.length,
holes: f.holes.length,
Expand Down
Loading