91a32c393f
- A sketch shape (or flat face) tapped: Extrude's arrow as before, and beside it in the column Revolve, Sweep and Loft from the same shape — drag the arrow for Extrude, tap one of them for that tool (the card's "Revolve instead / Sweep instead" are gone) - A freeform's face, edge or point picked: only what applies to it (Edit Freeform, Move/Rotate Body, Mirror, Patterns, Delete Body) — fillet, chamfer, offset face… were listed too - Every list of what can be done with what's picked has its groups apart with a dim line (picking, moving / patterns, making, combining, construction, colour, delete) - Cards: their own actions (Select all, Add detail…) in a row of their own inside the card — they shared the Cancel / Done row and were pushed out of it; the card's values, actions and Cancel / Done apart with a dim line - Freeform: two facing faces picked → Symmetry puts the mirror midway between them; the symmetry plane is kept with the shape (there again, and shown, the next time it's edited), with the symmetry mark at its corner - Freeform surface: points on its open border picked → Extend surface: a face beyond each border edge between them, outwards in the surface, as long as the edges; the new points are picked, ready to drag (tests/extendborder.test.ts) - Construction planes carry a mark at a corner for how they were made: offset ⇡, midplane ⇹, 3 points ∴, on curve ∿, perpendicular ⊥, at an angle ∠, parallel ∥ (older projects: told from the name) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
32 lines
2.4 KiB
TypeScript
32 lines
2.4 KiB
TypeScript
// Run: npx tsx tests/extendborder.test.ts
|
|
// Extending a freeform surface from points on its border: a face beyond each
|
|
// border edge with both ends picked, outwards in the surface, as long as the
|
|
// edges; and the result still builds as a clean sheet.
|
|
import opencascade from "replicad-opencascadejs";
|
|
import { setOC } from "replicad";
|
|
import { debugBodies, regenerate, shapeValid } from "../src/kernel/engine";
|
|
import { boundaryEdges, extendBorder, planeCage, boxCage } from "../src/freeform/cage";
|
|
|
|
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 sheet = planeCage([60, 40], 4, [0, 0, 0]);
|
|
const right = sheet.verts.flatMap((v, i) => (Math.abs(v[0] - 30) < 1e-9 ? [i] : []));
|
|
const r = extendBorder(sheet, right)!;
|
|
check("five points along the right edge: four new faces, five new points", !!r && r.cage.faces.length === sheet.faces.length + 4 && r.verts.length === 5, `${r?.cage.faces.length} faces`);
|
|
check("…out to the right by an edge's length (10), flat", r.verts.every((i) => Math.abs(r.cage.verts[i][0] - 40) < 1e-9 && Math.abs(r.cage.verts[i][2]) < 1e-9), r.verts.map((i) => r.cage.verts[i].join(",")).join(" "));
|
|
check("…the right edge is no longer a border; the new one is", !boundaryEdges(r.cage).some(([a, b]) => right.includes(a) && right.includes(b)) && boundaryEdges(r.cage).filter(([a, b]) => r.verts.includes(a) && r.verts.includes(b)).length === 4);
|
|
const corner = sheet.verts.findIndex((v) => Math.abs(v[0] - 30) < 1e-9 && Math.abs(v[1] - 20) < 1e-9);
|
|
const nextTo = sheet.verts.findIndex((v) => Math.abs(v[0] - 15) < 1e-9 && Math.abs(v[1] - 20) < 1e-9);
|
|
const two = extendBorder(sheet, [corner, nextTo])!;
|
|
check("two points round a corner (one border edge between them): one face", !!two && two.cage.faces.length === sheet.faces.length + 1);
|
|
check("points not on a border: nothing to extend", extendBorder(boxCage([20, 20, 20], 1), [0, 1, 2]) === null);
|
|
check("one point: nothing to extend", extendBorder(sheet, [corner]) === null);
|
|
const res: any = await regenerate([{ id: "s", name: "s", type: "freeform", surface: true, cage: r.cage }] as any);
|
|
check("the extended surface builds, a valid sheet", !res.errors.length && shapeValid(debugBodies().get("s") as any), res.errors.map((e: any) => e.message).join("; "));
|
|
process.exit(failed ? 1 : 0);
|