Skip to content

Isosurface extraction

ferreus_rmt.build_isosurface(seed_points, extents, resolution, isovalue, surface_fn, *, sampling_transform=None, gradient_fn=None, cluster_method=ClusterMethod.CurvatureWeighted, boundary_closure=BoundaryClosure.None_, progress_callback=None)

Extract an isosurface using regularised marching tetrahedra.

Parameters:

Name Type Description Default
seed_points NDArray[float64]

Numpy array of points of shape (N, 3), where N is the number of seed points used to initialise the surface-following extraction.

required
extents NDArray[float64]

Axis-aligned bounding box limiting the extracted mesh, with shape (6,) and order [xmin, ymin, zmin, xmax, ymax, zmax].

required
resolution float

Sampling resolution used by the extraction lattice.

required
isovalue float

The value at which to extract the isosurface.

required
surface_fn Callable[[NDArray[float64]], NDArray[float64]]

Callable function to evaluate lattice sample points during isosurface extraction. Must take in a 2D numpy array of float64 3D point coordinates of shape (N, 3) and return a float64 values array of shape (N,) or (N, 1), where N is the number of points being evaluated. Single-column scalar values are returned to Python as shape (N,).

required
sampling_transform NDArray[float64] | None

Optional affine transform applied to the sampling lattice to control its orientation and relative spacing. Provide the 3 x 3 linear part of the transform from world coordinates to sampling coordinates. If None, the default lattice is used. The resolution controls the overall sampling distance, so uniform scaling of the transform has no effect.

This is useful for surfaces with a strong directional trend. Aligning the lattice with the structure allows finer sampling across thin features and coarser sampling along smoother directions.

None
gradient_fn Callable | None

Optional callable function to evaluate values and gradients for seed projection. Values may have shape (N,) or (N, 1); gradients must have shape (N, 3).

None
cluster_method ClusterMethod

ClusterMethod used to combine local vertex candidates.

CurvatureWeighted
boundary_closure BoundaryClosure

BoundaryClosure mode for the extracted mesh.

None_
progress_callback Progress | None

Optional callback for reporting extraction progress.

None

Returns:

Type Description
Mesh

Extracted triangle mesh.

ferreus_rmt.build_isosurfaces(seed_points, extents, resolution, isovalues, isosurface_fn, *, sampling_transform=None, gradient_fn=None, cluster_method=ClusterMethod.CurvatureWeighted, boundary_closure=BoundaryClosure.None_, progress_callback=None)

Convenience wrapper for build_isosurface that can extract multiple meshes from a list of isovalues at once.

Parameters:

Name Type Description Default
seed_points NDArray[float64]

Numpy array of points of shape (N, 3), where N is the number of seed points used to initialise the surface-following extraction.

required
extents NDArray[float64]

Axis-aligned bounding box limiting the extracted mesh, with shape (6,) and order [xmin, ymin, zmin, xmax, ymax, zmax].

required
resolution float

Sampling resolution used by the extraction lattice.

required
isovalues list[float]

List of values at which to extract isosurfaces.

required
isosurface_fn Callable[[NDArray[float64]], NDArray[float64]]

Callable function to evaluate lattice sample points during isosurface extraction. Must take in a 2D numpy array of float64 3D point coordinates of shape (N, 3) and return a float64 values array of shape (N,) or (N, 1), where N is the number of points being evaluated. Single-column scalar values are returned to Python as shape (N,).

required
sampling_transform NDArray[float64] | None

Optional affine transform applied to the sampling lattice to control its orientation and relative spacing. Provide the 3 x 3 linear part of the transform from world coordinates to sampling coordinates. If None, the default lattice is used. The resolution controls the overall sampling distance, so uniform scaling of the transform has no effect.

This is useful for surfaces with a strong directional trend. Aligning the lattice with the structure allows finer sampling across thin features and coarser sampling along smoother directions.

None
gradient_fn Callable | None

Optional callable function to evaluate values and gradients for seed projection. Values may have shape (N,) or (N, 1); gradients must have shape (N, 3).

None
cluster_method ClusterMethod

ClusterMethod to use. If not provided, CurvatureWeighted will be used.

CurvatureWeighted
boundary_closure BoundaryClosure | None_

BoundaryClosure mode to use. If None_, leaves clipped boundaries open.

None_
progress_callback Progress | None

Optional callback for reporting extraction progress.

None

Returns:

Type Description
list[Mesh]

Extracted triangle mesh.

ferreus_rmt.get_evaluation_extents(extents, resolution, *, sampling_transform=None)

Return world-coordinate bounds covering all lattice evaluation points.

Parameters:

Name Type Description Default
extents NDArray[float64]

Finite clipping bounds [xmin, ymin, zmin, xmax, ymax, zmax], shape (6,).

required
resolution float

Finite, positive world-space sampling resolution.

required
sampling_transform NDArray[float64] | None

Optional affine transform applied to the sampling lattice to control its orientation and relative spacing. Provide the 3 x 3 linear part of the transform from world coordinates to sampling coordinates. If None, the default lattice is used. The resolution controls the overall sampling distance, so uniform scaling of the transform has no effect.

This is useful for surfaces with a strong directional trend. Aligning the lattice with the structure allows finer sampling across thin features and coarser sampling along smoother directions.

None

Returns:

Type Description
list[float]

Six world-coordinate bounds covering the lattice points sampled during extraction, which can extend beyond the clipping bounds. Use these bounds when preparing an evaluator for the same resolution and transform.

Raises:

Type Description
ValueError

If the bounds, resolution, or sampling transform are invalid.