XelToFab
CLI Reference

xtf extrude

Extrude a 2D scalar field into a 3D triangle mesh

Usage

xtf extrude [OPTIONS] INPUT_PATH

Load a 2D scalar field, build a watertight prism by marching-squares contour tracing and polygon triangulation, and write the result to an STL, OBJ, or PLY file.

Arguments

ArgumentDescription
INPUT_PATHPath to the input 2D scalar field file (must exist). Must resolve to a 2D array.

Options

OptionTypeDefaultDescription
-o, --outputPATH(required)Output mesh file path. Format determined by extension (.stl, .obj, .ply).
-t, --thicknessFLOAT(required)Extrusion height in grid units. Must be > 0.
-f, --field-nameTEXTNoneVariable name inside container formats (.npz, .mat, .h5, .vtk).
--shapeTEXTNoneGrid shape for flat data, e.g. 25x50 (for CSV/TXT).
--field-typedensity|sdfdensityInput field type. sdf flips the threshold direction and shifts the default --level to 0.0.
--levelFLOAT(auto)Iso-level override. Default: 0.5 for density, 0.0 for SDF.
--min-component-areaINT0Drop connected components smaller than N pixels.
--smooth-sigmaFLOAT0.0Pre-threshold Gaussian sigma. 0 disables.
--fill-holesflagFalseMorphologically close single-pixel pinholes before tracing.

Examples

Basic density → STL

xtf extrude density_2d.npy -o part.stl --thickness 10

SDF input

xtf extrude sdf_field.npy -o part.stl -t 10 --field-type sdf

The --level default becomes 0.0 automatically under --field-type sdf.

Printability cleanup

xtf extrude beam.npy -o beam.stl -t 15 \
    --smooth-sigma 0.8 \
    --fill-holes \
    --min-component-area 20

Smooths noise, closes pinholes, and drops disconnected specks smaller than 20 pixels.

MATLAB input with named variable

xtf extrude result.mat -o mesh.stl -t 5 -f xPhys

If -f is omitted, the loader auto-detects common topology-optimization variable names (xPhys, densities, x, rho, dc, density).

Flat CSV with explicit shape

xtf extrude field_25x50.csv -o mesh.stl -t 8 --shape 25x50

Custom iso-level

xtf extrude density.npy -o mesh.stl -t 10 --level 0.4

Lowering the level includes more material in the binarized mask — useful when the optimizer output has gray regions you want to retain.

See also

Outline