Modules | TS
Iso
Scalar field isocontours and isobands.
The Iso module is the scalar field pipeline. It is driven by field crossings rather than by polygon intersections, so it is a tier of its own: the curves a field traces on a mesh, and the mesh recut so those curves are edges.
import * as tf from "@polydera/trueform";
Isocontours
Extract isocontour curves from scalar fields on meshes.
Single Isocontour
const scalars = tf.distance(tf.point(mesh.points), plane);
const curves = tf.isocontours(mesh, scalars, 0.0);
Multiple Isocontours
const thresholds = new Float32Array([0.0, 0.5, 1.0]);
const curves = tf.isocontours(mesh, scalars, thresholds);
Curves are returned as Curves objects with paths (an OffsetBlockedBuffer of index sequences) and points (an NDArrayFloat32 of coordinates).
Isobands
Extract regions between consecutive threshold values from scalar fields:
const cutValues = new Float32Array([-1.0, 0.0, 1.0]);
const { mesh, labels, faceLabels } = tf.isobands(mesh, scalars, cutValues);
// Select specific bands
const { mesh, labels, faceLabels } = tf.isobands(mesh, scalars, cutValues, {
selectedBands: [1, 3],
});
// With curves
const { mesh, labels, faceLabels, curves } = tf.isobands(mesh, scalars, cutValues, {
returnCurves: true,
});
labels is the band each output face lies in, faceLabels the index of the original face it came from.
Async
Both functions are available as async variants via tf.async, with the same overloads:
const curves = await tf.async.isocontours(mesh, scalars, 0.0);
const { mesh: banded, labels, faceLabels } = await tf.async.isobands(mesh, scalars, cutValues);
For implementation details, see the C++ Iso documentation.
