Skip to content

Isosurface extraction

ferreus_rmt.build_isosurface(seed_points, extents, resolution, isovalue, surface_fn, *, 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
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, surface_fn, *, 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
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
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.