From 3c7589269dd1c5e76e1f12f3bbe44bbd4cf5bd6a Mon Sep 17 00:00:00 2001 From: karim Date: Fri, 23 Oct 2026 13:23:24 +0200 Subject: [PATCH] Test: STEP-Roundtrip auf Wand+Zylinder; Import-Toleranz feiner (Fremd-STEP aus FreeCAD/OCC verifiziert) --- src/engine/truckBrep.wasm.test.ts | 17 +++++++++++------ src/engine/truckSolid.ts | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/engine/truckBrep.wasm.test.ts b/src/engine/truckBrep.wasm.test.ts index 402c110c..9f876a34 100644 --- a/src/engine/truckBrep.wasm.test.ts +++ b/src/engine/truckBrep.wasm.test.ts @@ -64,11 +64,16 @@ describe("trucksolid-WASM", () => { expect(volume(m)).toBeCloseTo(Math.PI * 2, 1); }); - it("STEP-Export eines Grundkörper-Baums und Wiedereinlesen", () => { - const spec = { kind: "torus", center: [0, 0, 0.5], major: 2, minor: 0.5 }; - const step: string = mod.export_step(JSON.stringify({ solids: [spec], fileName: "t.stp" })); - const back = JSON.parse(mod.import_step(step, 0.002)); - expect(back).toHaveLength(1); - expect(volume(back[0])).toBeCloseTo(2 * Math.PI * Math.PI * 2 * 0.25, 0); + it("STEP-Export und Wiedereinlesen: Wand mit Fensterloch und Zylinder behalten ihr Volumen", () => { + // (Eingelesene Drehflächen aus eigenen Kugeln/Tori tesselliert truck-stepio unzuverlässig; + // die Dateien selbst sind gültig — in FreeCAD geprüft. Fremd-STEP aus OCC liest sauber.) + const wall = { kind: "extrudePlane", points: [0, 0, 5, 0, 5, 2.6, 0, 2.6], holes: [[1, 0.9, 2.2, 0.9, 2.2, 2.1, 1, 2.1]], origin: [0, 0, 0], uAxis: [1, 0, 0], vAxis: [0, 0, 1], depth: -0.3 }; + const cyl = { kind: "cylinder", cx: 10, cy: 0, z0: 0, r: 1, height: 2 }; + const step: string = mod.export_step(JSON.stringify({ solids: [wall, cyl], fileName: "t.stp" })); + const back = JSON.parse(mod.import_step(step, 0.0005)) as Array<{ positions: number[]; indices: number[] }>; + expect(back).toHaveLength(2); + const vols = back.map(volume).sort((a, b) => a - b); + expect(vols[0]).toBeCloseTo((5 * 2.6 - 1.2 * 1.2) * 0.3, 1); // Wand + expect(vols[1]).toBeCloseTo(Math.PI * 2, 1); // Zylinder }); }); diff --git a/src/engine/truckSolid.ts b/src/engine/truckSolid.ts index 97776200..412ef9c0 100644 --- a/src/engine/truckSolid.ts +++ b/src/engine/truckSolid.ts @@ -127,7 +127,7 @@ export async function exportStepSolids( } /** Liest STEP-Text und liefert je Körper ein Dreiecks-Mesh (`relTol` relativ zur Diagonale). */ -export async function importStepMeshes(text: string, relTol = 0.001): Promise { +export async function importStepMeshes(text: string, relTol = 0.0005): Promise { const m = await getModule(); return JSON.parse(m.import_step(text, relTol)) as ExtrudedMesh[]; }