XelToFab
API Reference

process

Run the full XelToFab processing pipeline

Import

from xeltofab import process
# or
from xeltofab.pipeline import process

Signature

def process(state: PipelineState) -> PipelineState

Parameters

ParameterTypeDescription
statePipelineStateA state object containing the design field and pipeline parameters

Return value

Returns a new PipelineState with all pipeline stages applied. The returned state will have populated mesh data (vertices, faces for 3D; contours for 2D) and volume_fraction.

What it does

process chains six pipeline stages in order:

  1. Preprocess — Gaussian smoothing, Heaviside thresholding, and morphological cleanup. Produces the binary field on the state.
  2. Extract — Dispatch to configured extraction method (MC, DC, SurfNets, or manifold for 3D; marching squares for 2D). Produces vertices/faces or contours.
  3. Smooth — Taubin or bilateral filtering on the extracted mesh. DC/SurfNets auto-select bilateral with 5 iterations. Produces smoothed_vertices.
  4. Repair — Non-manifold fixing (skipped for manifold extraction).
  5. Remesh — Isotropic remeshing for FEA-quality elements.
  6. Decimate — QEM edge collapse to reduce face count.

When preprocessing is skipped

If params.direct_extraction is True, the preprocessing step is skipped entirely. Extraction operates directly on the continuous input field rather than a binarized version. This is the default behavior for SDF fields (where field_type="sdf").

Relationship with process_from_sdf

process_from_sdf() is a convenience wrapper that evaluates an SDF function on a grid and then calls process() internally. The two functions are alternatives, not sequential — use one or the other depending on your input:

Your inputUse
SDF function (neural model, analytical formula)process_from_sdf() — evaluates grid + runs full pipeline
Pre-loaded numpy array (.npy, .mat, .h5, or pre-evaluated grid)process() — runs pipeline directly on the field

Example

from xeltofab import load_field, process, save_mesh

# Load and process
state = load_field("design_field.npy")
result = process(state)

# Access results
print(f"Dimensions: {result.ndim}D")
print(f"Volume fraction: {result.volume_fraction:.3f}")

if result.ndim == 3:
    print(f"Vertices: {result.best_vertices.shape[0]}")
    print(f"Faces: {result.faces.shape[0]}")
    save_mesh(result, "output.stl")
else:
    print(f"Contours: {len(result.contours)} segments")

See also

Outline