Skip to content

Add pytetwild (fTetWild) tetrahedralization node for FEM / volumetric workflows #46

@antoinebou12

Description

@antoinebou12

Hi! First off—GeometryPack is already super useful for getting “clean” surface meshes inside ComfyUI (repair/remesh/unwrap/preview). I’m trying to push the pipeline one step further into simulation, and I’m missing one key building block:

Please add a tetrahedralization (“tet mesher”) node based on pytetwild (Python wrapper of fTetWild / TetWild).

  • Node name idea: Tetrahedralize (TetWild / fTetWild)
  • Input: triangle surface mesh (watertight preferred; optionally auto-fix using existing repair nodes)
  • Output: tetrahedral volume mesh (vertices + tet connectivity), plus optional surface extraction

Why this matters (FEM / physics sim)

Most FEM solvers (soft-body, stress/strain, heat, modal analysis, etc.) need a volumetric tetra mesh, not just a surface triangle mesh. Having tetrahedralization inside GeometryPack would make ComfyUI a complete mesh-to-sim-ready preprocessing graph:

Example workflow

  1. Load mesh
  2. Repair / make watertight
  3. Remesh / simplify
  4. ✅ Tetrahedralize (TetWild)
  5. Export to solver format (or visualize quality)

That’s a big win for anyone doing FEM in external tools (Gmsh/FEniCS/SOFA/CalculiX/Abaqus/etc.) or future in-Comfy physics nodes.

Suggested backend: pytetwild

pytetwild is a Python wrapper around fTetWild and ships wheels on PyPI (so users don’t need to compile C++ locally in most cases).

Refs:

  • PyPI: https://pypi.org/project/pytetwild/
  • fTetWild repo: https://github.com/wildmeshing/fTetWild
  • Paper (SIGGRAPH 2020): https://doi.org/10.1145/3386569.3392385

Parameters to expose (matching pytetwild)

These map cleanly to a ComfyUI node UI and are already documented in pytetwild:

  • edge_length_fac (default ~0.05 of bbox diagonal)
  • edge_length_abs (override)
  • optimize (quality vs speed)
  • simplify (preprocess surface)
  • epsilon (envelope / feature fidelity)
  • stop_energy, num_opt_iter
  • coarsen
  • num_threads
  • quiet/loglevel (optional)

Output / interop

For FEM users, exports matter as much as generating tets. Any of these would be awesome:

  • Export .msh (Gmsh) or .vtu/.vtk (ParaView) or .xdmf
  • At minimum: provide raw arrays (V, T) + a “save” node later

Implementation notes (high level)

  • Convert GeometryPack mesh representation → (vertices, faces) numpy arrays
  • Call pytetwild.tetrahedralize(vertices, faces, ...)
  • Return a new “tet mesh” object type (or a dict payload) that downstream nodes can consume
  • Optional: surface extraction node (tet boundary triangles) for preview

Dependency / env note

If you’d rather isolate this dependency: GeometryPack already uses comfy-env patterns for dependency management and isolation, so this could be added either in the main env or as an isolated sub-env if needed.


If this is something you’d accept, I can help test on a few nasty meshes (non-manifold, holes, self-intersections) and share expected outputs + solver compatibility notes.
Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions