Display mesh of a surface body
32-bit, display onlyThe triangles used to draw each surface body.
linear deflection = 2e-4 × diagonal; angular deflection = 2π ÷ 64
The vertex positions are copied from the kernel's memory as a Float32Array and are used to draw. The body's area in the same result comes from the exact faces, not from these triangles.
/** Display meshes of the surface bodies left after a rebuild: [{ feature, positions, indices }]. */
export function sheetMeshes(ctx) {
const out = [];
if (!ctx.sheets) return out;
const { oc, T } = ctx;
for (const [id, sh] of ctx.sheets) {
try {
const bb = ctx.bbox(sh.shape);
const diag = Math.max(1e-6, V.len(V.sub(bb.max, bb.min)));
const md = T(oc.ReplicadMeshExtractor.extract(sh.shape, diag * 2e-4, 2 * Math.PI / 64, false));
const mem = oc.wasmMemory.buffer;
const positions = new Float32Array(mem, md.getVerticesPtr(), md.getVerticesSize()).slice();
const indices = Uint32Array.from(new Int32Array(mem, md.getTrianglesPtr(), md.getTrianglesSize()));
oc.BRepTools.Clean(sh.shape, true);
let area = 0;
for (const f of explore(oc, T, sh.shape, 'FACE')) { const g = T(new oc.GProp_GProps()); oc.BRepGProp.SurfaceProperties(f, g, false, false); area += g.Mass(); }
out.push({ feature: id, positions, indices, area, faces: [...sh.names.entries()].length });
} catch { /* a sheet that cannot be meshed is left out of the view */ }
}
return out;
}