Test: STEP-Roundtrip auf Wand+Zylinder; Import-Toleranz feiner (Fremd-STEP aus FreeCAD/OCC verifiziert)

This commit is contained in:
karim committed 2026-10-23 13:23:24 +02:00
1 parent cf608b4438
commit 3c7589269d
2 files changed
+12 -7

No files matched your search

+11 -6
View File
@@ -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
});
});
+1 -1
View File
@@ -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<ExtrudedMesh[]> {
export async function importStepMeshes(text: string, relTol = 0.0005): Promise<ExtrudedMesh[]> {
const m = await getModule();
return JSON.parse(m.import_step(text, relTol)) as ExtrudedMesh[];
}