3fe7285e86
- Offset Face on a sweep's end, pushed in again and again (a user's S-curve tube, 19 pushes): pushes on the bend failed. The end's plane cuts an S-shaped path in more than one place and only the first crossing was tried; and the disc cut along the path was far wider than the tube, so on a tight bend it folded over itself ("could not compute") or bit into the tube's next turn ("break into pieces"). The crossing at the face is taken, and the disc is just wider than the tube. The 19 pushes rebuild in 3.6 s (17 s). Test: tests/sweeppushes.test.ts
- Move Face tilting the rim a Shell leaves round its opening (a flat face with a hole) failed at any angle: its region was cut into 11 cells by every neighbour's surface, and joining them failed. Now its outline's region less its hole's. Test: tests/rimtilt.test.ts
- A fillet that ends on a face being moved, and can't be taken off alone (one link of a fillet chain): its cylinder was carried on as an endless one, which carved a groove and left a scrap of the old face standing (the stray-cylinder bug). It now carries on along its own corner, between the two faces it rounds, and ends on the moved face. Test: tests/movefillet.test.ts (a user's part)
- About: no "On GitHub" button
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
37 lines
2.6 KiB
TypeScript
37 lines
2.6 KiB
TypeScript
// Run: npx tsx tests/movefillet.test.ts - a user's part (tests/fixtures/
|
|
// movefillet.json): a box with faces tilted, an edge moved, a fillet and a
|
|
// chain of R3 fillets, then the left wall tilted 18° (Move Face 05). The R3
|
|
// fillet ends on that wall and can't be taken off alone (it's one link of a
|
|
// chain), so the wall's region was made with the fillet's cylinder as an
|
|
// endless one: it carved a groove and left a scrap of the old wall standing
|
|
// (12 faces: an inside-out cylinder and a 28 mm² patch at x = -60). Now the
|
|
// fillet carries on along its own corner and simply ends on the tilted wall.
|
|
import opencascade from "replicad-opencascadejs";
|
|
import { measureArea, setOC } from "replicad";
|
|
import { readFileSync } from "node:fs";
|
|
import { debugBodies, regenerate } from "../src/kernel/engine";
|
|
import { healthOf, isHealthy } from "../src/kernel/repair";
|
|
|
|
setOC(await (opencascade as unknown as () => Promise<any>)());
|
|
let failed = 0;
|
|
const check = (name: string, ok: boolean, info = "") => {
|
|
if (!ok) failed++;
|
|
console.log(ok ? "ok " : "FAIL", name, info);
|
|
};
|
|
const doc = JSON.parse(readFileSync(new URL("./fixtures/movefillet.json", import.meta.url), "utf8"));
|
|
const B = "extrude-mw56abf8-v8l2";
|
|
const r: any = await regenerate(doc.features);
|
|
const name = (id: string) => doc.features.find((f: any) => f.id === id)?.name;
|
|
check("only Move Face 04 is refused (a fillet chain runs along that face), with a clear reason", r.errors.length === 1 && name(r.errors[0].featureId) === "Move Face 04" && /fillet/.test(r.errors[0].message), r.errors.map((e: any) => `${name(e.featureId)}: ${e.message}`).join("; "));
|
|
const s = debugBodies().get(B)!;
|
|
check("one clean solid", isHealthy(healthOf(s)));
|
|
const n = (f: any) => f.normalAt().toTuple();
|
|
const oldWall = s.faces.filter((f) => f.geomType === "PLANE" && Math.abs(n(f)[0] + 1) < 1e-6);
|
|
check("no scrap of the old left wall left standing", oldWall.length === 0, oldWall.map((f) => measureArea(f).toFixed(1)).join(", "));
|
|
const wall = s.faces.filter((f) => f.geomType === "PLANE" && Math.abs(n(f)[0] + Math.cos(Math.PI / 10)) < 1e-6 && Math.abs(n(f)[2] - Math.sin(Math.PI / 10)) < 1e-6);
|
|
check("the left wall is one face, tilted 18°", wall.length === 1, wall.map((f) => measureArea(f).toFixed(1)).join(", "));
|
|
const cyl = s.faces.filter((f) => f.geomType === "CYLINDRE");
|
|
check("the same three rounded faces as before the tilt (no groove)", s.faces.length === 10 && cyl.length === 3, `${s.faces.length} faces, round: ${cyl.map((f) => measureArea(f).toFixed(1)).join(", ")}`);
|
|
console.log(failed ? `${failed} FAILED` : "all passed");
|
|
process.exit(failed ? 1 : 0);
|