Triply Periodic Meshing for Triply Periodic Minimal Surfaces
pip install -r requirements.txt- numpy – for numerical operations
- libigl – for mesh cleaning and processing
- meshio – for reading and writing meshes
- pygalmesh – for mesh generation
- polyscope – for visualization
- PyMCubes – for surface mesh generation
NOTE: We use a custom fork of
pygalmesh(zfergus/pygalmesh). Install it with:pip install git+https://github.com/zfergus/pygalmesh.gitrather than
pip install pygalmesh.
We use a C++ backend to accelerate implicit function evaluations. To build it, you need to have a C++ compiler and CMake installed. Then run:
pip install -e .This uses nanobind to create a _tpms module that provides the C++ functionality for evaluating TPMS implicit functions.
NOTE: The
_tpmsmodule is included in theTPMeShpackage, so you don't need to import it separately.
This will also install the Python package TPMeSh and provides a command-line interface for generating TPMS meshes of the same name.
$ TPMeSh -h
usage: mesh_tpms.py [-h] [-x X X X X X X X X] [-i I] [-s] [-p] [-o OUTPUT] [-t THICKNESS]
[-n ELEMENTS_IN_THICKNESS] [-r REPEATS REPEATS REPEATS] [-v]
Generate a TPMS mesh with given design parameters.
options:
-h, --help show this help message and exit
-x X X X X X X X X design parameters
-i I Generate a canonical TPMS with the given index
-s, --surface generate surface mesh
-p, --periodic generate periodic mesh
-o, --output OUTPUT output mesh name (.stl for surface mesh, .msh for volume mesh)
-t, --thickness THICKNESS thickness of the TPMS mesh walls (default: 0.5)
-n, --elements-in-thickness ELEMENTS_IN_THICKNESS
Number of elements in the thickness of the mesh (default: 2)
-r, --repeats REPEATS REPEATS REPEATS
Number of repeats in each direction (default: 4 2 4 for full mesh,
1 1 1 for periodic mesh)
-v, --visualize visualize the mesh
To generate a mesh for a specific TPMS primitive, use the -i option with an integer index.
TPMeSh -i <primitive_index>where <primitive_index> is an integer from 0 to 7, corresponding to the following TPMS primitives:
| (0) Schoen Gyroid | (1) Schwarz Diamond | (2) Schwarz Primitive | (3) Schoen IWP |
|---|---|---|---|
![]() |
![]() |
![]() |
![]() |
| (4) Neovius | (5) Fischer Koch S | (6) Schoen FRD | (7) PMY |
![]() |
![]() |
![]() |
![]() |
TPMeSh -i 2 -r 2 2 2 -o "2.msh"TPMeSh -i 2 -r 2 2 2 -s -o "2.stl"TPMeSh -i 2 -r 1 1 1 -p -o "2p.msh"To interpolate TPMS shapes, you can use the -x option with the design parameters. For example:
TPMeSh -x 0.4 0 0.6 0 0 0 0 0 -o "interpolation_a.msh"
TPMeSh -x 0 0 0.24 0.2 0 0 0 0.56 -o "interpolation_b.msh"
TPMeSh -x 0 0 0 0.4 0 0 0.4 0.2 -o "interpolation_c.msh"This project is licensed under the GPL v3.0 License - see the LICENSE file for details. This is in compliance with the original CGAL/pygalmesh licenses, which are also GPL v3.0.











