Design fields to fabrication-ready geometry
Project description
XelToFab
A design field post-processing pipeline that transforms continuous scalar fields from optimization solvers and neural networks into clean, fabrication-ready triangle meshes (3D) and contour representations (2D). The pipeline handles thresholding, smoothing, mesh extraction, quality improvement, visualization, and multi-format export.
Installation
# From PyPI (stable)
pip install xeltofab
# With optional format support
pip install "xeltofab[vtk,hdf5]"
# From source (development)
git clone https://github.com/xarthurx/XelToFab.git
cd XelToFab
uv sync
Quick Start
# Process a 3D density field into an STL mesh
xtf process density.npy -o output.stl
# Process with custom parameters and save a comparison plot
xtf process density.npy -o output.stl --threshold 0.4 --sigma 1.5 --viz
# Visualize a 2D density field
xtf viz density_2d.npy -o comparison.png
Pipeline
Scalar Field → Preprocess → Extract → Smooth → Mesh/Contours
(.npy) threshold marching Taubin (.stl/.obj)
+ morphology cubes/sq. filter
- Preprocess — Gaussian smoothing, Heaviside thresholding, morphological cleanup, small component removal
- Extract — Marching cubes (3D) or marching squares (2D) via scikit-image
- Smooth — Taubin smoothing via trimesh (3D meshes only)
Python API
import numpy as np
from xeltofab.state import PipelineState, PipelineParams
from xeltofab.pipeline import process
from xeltofab.io import save_mesh
# Create a scalar field (e.g., a sphere)
z, y, x = np.mgrid[-1:1:50j, -1:1:50j, -1:1:50j]
field = (x**2 + y**2 + z**2 < 0.5**2).astype(float)
# Run the pipeline
params = PipelineParams(threshold=0.5, smooth_sigma=1.0)
state = PipelineState(field=field, params=params)
result = process(state)
# Export
save_mesh(result, "sphere.stl")
Using Example Data
Pre-computed topology optimization results are included in data/examples/ (sourced from IDEALLab EngiBench):
from xeltofab.io import load_field
from xeltofab.pipeline import process
state = load_field("data/examples/beams_2d_50x100_sample0.npy")
result = process(state)
Supported Input Formats
| Format | Extensions | Install |
|---|---|---|
| NumPy | .npy, .npz | Built-in |
| MATLAB | .mat | Built-in (via scipy) |
| CSV/Text | .csv, .txt | Built-in |
| VTK | .vtk, .vtr, .vti | pip install "xeltofab[vtk]" |
| HDF5/XDMF | .h5, .hdf5, .xdmf | pip install "xeltofab[hdf5]" |
| All formats | — | pip install "xeltofab[all-formats]" |
List available formats: xtf formats
Development
uv sync # Install deps
uv run pytest tests/ -v # Run tests
uv run ruff check src/ tests/ # Lint
uv run ruff format src/ tests/ # Format
uv run marimo edit notebooks/demo.py # Interactive demo
Project Structure
src/xeltofab/
├── state.py Pipeline state + parameter models
├── preprocess.py Field preprocessing
├── extract.py Mesh/contour extraction
├── smooth.py Taubin smoothing
├── pipeline.py Orchestrator
├── io.py File I/O (multi-format load, mesh export)
├── loaders/ Format-specific loaders (numpy, matlab, csv, vtk, hdf5)
├── field_plots.py Matplotlib visualization
└── cli.py CLI (xtf)
See docs/ARCHITECTURE.md for detailed architecture documentation.
Documentation
Full documentation is available at xel-to-fab.vercel.app.
Requirements
- Python 3.13+
- uv for development
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xeltofab-0.3.2.tar.gz.
File metadata
- Download URL: xeltofab-0.3.2.tar.gz
- Upload date:
- Size: 32.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52fc638b7da81410da4d2acca60cbfcd5ad54c1cb3f6072a02c6b10b8e0765f1
|
|
| MD5 |
ab4b6ce5ab3028908fcceadaa93d3f04
|
|
| BLAKE2b-256 |
c3feb5b84511d1b74c8c24527bccd1289e8f64c84d4aa441984c18e49130c964
|
Provenance
The following attestation bundles were made for xeltofab-0.3.2.tar.gz:
Publisher:
publish-pypi.yml on xarthurx/XelToFab
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xeltofab-0.3.2.tar.gz -
Subject digest:
52fc638b7da81410da4d2acca60cbfcd5ad54c1cb3f6072a02c6b10b8e0765f1 - Sigstore transparency entry: 1262387893
- Sigstore integration time:
-
Permalink:
xarthurx/XelToFab@c698994f93b64cf4946daf758295982a30929d8e -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/xarthurx
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@c698994f93b64cf4946daf758295982a30929d8e -
Trigger Event:
push
-
Statement type:
File details
Details for the file xeltofab-0.3.2-py3-none-any.whl.
File metadata
- Download URL: xeltofab-0.3.2-py3-none-any.whl
- Upload date:
- Size: 42.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7795df58980d593b44480686d8d0737b651c33cab31bb925402eb96f7c4e19b4
|
|
| MD5 |
c210b89cb3b023eb2e446e280bb28b44
|
|
| BLAKE2b-256 |
8b02307a24a267a27e2c40d8743195ca09b9630bb0a093991629d751bc006f3b
|
Provenance
The following attestation bundles were made for xeltofab-0.3.2-py3-none-any.whl:
Publisher:
publish-pypi.yml on xarthurx/XelToFab
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xeltofab-0.3.2-py3-none-any.whl -
Subject digest:
7795df58980d593b44480686d8d0737b651c33cab31bb925402eb96f7c4e19b4 - Sigstore transparency entry: 1262387896
- Sigstore integration time:
-
Permalink:
xarthurx/XelToFab@c698994f93b64cf4946daf758295982a30929d8e -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/xarthurx
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@c698994f93b64cf4946daf758295982a30929d8e -
Trigger Event:
push
-
Statement type: