Isosurface extraction¶
ferreus_rbf.isosurfacing.build_isosurface(seed_points, extents, resolution, isovalue, isosurface_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, to seed the isosurface extraction. The algorithm is most efficient when these points are on, or close to, the surface to be extacted, as it reduces the number of cells that need to be evaluated in order to extract the surface. |
required |
extents
|
NDArray[float64]
|
AABB extents as a 1D numpy array in order of [minx, miny, minz, maxx, maxy, maxz]. |
required |
resolution
|
float
|
The isosurfacing resolution. |
required |
isovalue
|
float
|
The value at which to extract the isosurface. |
required |
isosurface_fn
|
Callable[[NDArray[float64]], NDArray[float64]]
|
Callable function to evaluate the cell points at 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. |
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 for evaluating values and gradients during seed projection. It must
take a float64 array of point coordinates with shape (N, 3) and return a tuple of
|
None
|
cluster_method
|
Optional[ClusterMethod]
|
Vertex clustering method to use. If not provided, CurvatureWeighted will be used. |
CurvatureWeighted
|
boundary_closure
|
BoundaryClosure | None_
|
Boundary closure method to use. If None_, leaves clipped boundaries open. |
None_
|
progress_callback
|
Progress | None
|
Progress callback operator, by default None |
None
|
Returns:
| Type | Description |
|---|---|
Mesh
|
Extracted triangle mesh. |
ferreus_rbf.isosurfacing.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, to seed the isosurface extraction. The algorithm is most efficient when these points are on, or close to, the surface to be extacted, as it reduces the number of cells that need to be evaluated in order to extract the surface. |
required |
extents
|
NDArray[float64]
|
AABB extents as a 1D numpy array in order of [minx, miny, minz, maxx, maxy, maxz]. |
required |
resolution
|
float
|
The isosurfacing resolution. |
required |
isovalues
|
list[float]
|
List of values at which to extract isosurfaces. |
required |
isosurface_fn
|
Callable[[NDArray[float64]], NDArray[float64]]
|
Callable function to evaluate the cell points at 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. |
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 for evaluating values and gradients during seed projection. It must
take a float64 array of point coordinates with shape (N, 3) and return a tuple of
|
None
|
cluster_method
|
Optional[ClusterMethod]
|
Vertex clustering method to use. If not provided, CurvatureWeighted will be used. |
CurvatureWeighted
|
boundary_closure
|
BoundaryClosure | None_
|
Boundary closure method to use. If None_, leaves clipped boundaries open. |
None_
|
progress_callback
|
Progress | None
|
Progress callback operator, by default None |
None
|
Returns:
| Type | Description |
|---|---|
list[Mesh]
|
Extracted triangle meshes for each isovalue. |
ferreus_rbf.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. |