Resources Numerical accuracy Calculation policy

Freeform bodies: display mesh

Makes the triangles the Form workspace draws for the smooth surface.

How the precision is kept

The limit positions are computed in 64-bit and stored in a Float32Array for the graphics buffers. The function's own comment says it is the surface for display; the conversion to a solid uses the Bézier patches, which stay 64-bit.

Calculations under this policy

1 calculation in 1 source file. The code is read from the released app when this page loads. It is the calculation people run, not a copy kept for this page.

form.js PartCraft 0.8.1 32-bit, display only 1 calculation Reviewed

Tests tools/partcraft-test/test-form.mjs

Smooth surface for display

32-bit, display only

The limit positions of the refined cage as a triangle mesh.

Each limit point is computed in 64-bit and written into a Float32Array. ws-form.js draws this mesh; form-brep.js builds the solid from patches() instead.

  • form.js
  • lines 400 to 410
  • PartCraft 0.8.1
/** The smooth surface for display: limit positions of the cage refined `level` (≥ 1) times, as triangles. */
export function limitMesh(form, level = 2) {
  if (!form.faces.length) return { positions: new Float32Array(0), indices: new Uint32Array(0), triFace: [] };
  const m = refine(form, Math.max(1, level), { track: true });
  const t = topo(m);
  const positions = new Float32Array(m.P.length * 3);
  m.P.forEach((_, v) => { if (!t.ve[v].length) return; const p = limitPoint(m, t, v); positions.set(p, v * 3); });
  const idx = [], triFace = [];
  m.F.forEach((f, fi) => { idx.push(f[0], f[1], f[2], f[0], f[2], f[3]); triFace.push(m.track[fi].root, m.track[fi].root); });
  return { positions, indices: Uint32Array.from(idx), triFace };
}

In detail

Method
Limit positions of the cage refined at least once, two triangles per quad.
Number types
Float32Array positions, Uint32Array indexes.

Approach: Display only

Computed to draw the screen, often in 32-bit on the graphics processor. No number a person reads, saves or exports comes from it.

Every policy that takes this approach