TetWild - Tetrahedral Meshing in the Wild
Here is pre-generated tetmeshes and the extracted surface meshes for research-purpose usage.
Figures in the paper: Input/output & scripts
Our code was originally developed on MacOS and has been tested on Linux and Windows.
- Clone the repository into your local machine:
git clone https://github.com/Yixin-Hu/TetWild
- Compile the code using cmake (default in Release mode):
You need to install CGAL before compiling the code.
cd TetWild mkdir build cd build cmake .. make
-DTETWILD_WITH_HUNTER=ON. This will let CMake use Hunter to download and configure Boost automatically. Other options include installing Boost via Conda, compile from source, etc.
Could not find Matlab or
Could not find Mosek in the output of cmake, it does not matter since they are not used.
The inputs of our software are triangle surface meshes in
.mesh/.msh format output. The default output format is
.msh with minimum dihedral angle recorded as element scalar field, which can be visualized by software Gmsh. You can use
pymesh/ for read and write
.obj format if the
is_quiet flag is not turned on.
Our software is quite easy to use. Basically, users only need to provide a surface triangle mesh as input and our mesher would output a tetrahedral mesh by using default settings. If you want to customize your own tetmeshes, we also provide some options.
- Envelope of size epsilon
Using smaller envelope preserves features better but also takes longer time. The default value of epsilon is b/1000, where b is the length of the diagonal of the bounding box.
- Ideal edge length
Using smaller ideal edge length gives a denser mesh but also takes longer time. The default ideal edge length is b/20
- Filtering energy
Our mesher stops optimizing the mesh when maximum energy is smaller than filtering energy. Thus, larger filtering energy means less optimization and sooner stopping. If you do not care about quality, then give a larger filtering energy would let you get the result earlier. The energy we used here is conformal AMIPS whose range is from 3 to +inf. The default filtering energy is 10.
- Maximum number of optimization passes
Our mesher stops optimizing the mesh when the maximum number of passes is reached. The default number is 80.
- Targeted number of vertices
We allow users to input the targeted number of vertices and the mesher would try its best to match that number with 5% error. When the targeted number of vertices is unrealistically small, then the output tetmesh may not have number of vertices matched.
- Sizing field
Users can provide a background tetmesh in .msh format with vertex scalar field
values stored. The scalar field
values is used for controlling edge length. The scalars inside an element of the background mesh are linearly interpolated.
- Smoothing open regions
Our method can fill gaps and holes but the tetmesh faces on those parts could be bumpy. We provide users an option to do Lapacian smoothing on those faces to get a smoother surface.
- With out winding number
Command Line Switches
Our software supports usage via command line or via a C++ function wrapper. Here is an overview of all command line switches:
RobustTetMeshing Usage: ./TetWild [OPTIONS] input [output] Positionals: input TEXT REQUIRED Input surface mesh INPUT in .off/.obj/.stl/.ply format. (string, required) output TEXT Output tetmesh OUTPUT in .msh format. (string, optional, default: input_file+postfix+'.msh') Options: -h,--help Print this help message and exit --input TEXT REQUIRED Input surface mesh INPUT in .off/.obj/.stl/.ply format. (string, required) --output TEXT Output tetmesh OUTPUT in .msh format. (string, optional, default: input_file+postfix+'.msh') --postfix TEXT Postfix P for output files. (string, optional, default: '_') -l,--ideal-edge-length FLOAT ideal_edge_length = diag_of_bbox * L. (double, optional, default: 0.05) -e,--epsilon FLOAT epsilon = diag_of_bbox * EPS. (double, optional, default: 1e-3) --stage INT Run pipeline in stage STAGE. (integer, optional, default: 1) --filter-energy FLOAT Stop mesh improvement when the maximum energy is smaller than ENERGY. (double, optional, default: 10) --max-pass INT Do PASS mesh improvement passes in maximum. (integer, optional, default: 80) --is-laplacian Do Laplacian smoothing for the surface of output on the holes of input (optional) --targeted-num-v INT Output tetmesh that contains TV vertices. (integer, optional, tolerance: 5%) --bg-mesh TEXT Background tetmesh BGMESH in .msh format for applying sizing field. (string, optional) --save-mid-result 0: save result before optimization, 1: save mid-results during optimization, 2: save result without winding number. -q,--is-quiet Mute console output. (optional) --log TEXT Log info to given file. --level INT Log level (0 = most verbose, 6 = off).
We provide a wrapper for TetWild in
tetwild.h, allowing users do the tetrahedaliztion without read/write data from/to files. One can use it in the following way:
Include the header file
Set parameters through a struct variable
tetwild::Args args. The following table provides the correspondence between parameters and command line switches.
Switch Parameter --input N/A --postfix
--output N/A --ideal-edge-length
tetwild::tetrahedralization(v_in, f_in, v_out, t_out, a_out, args). The input/output arguments are described in the function docstring, and use libigl-style matrices for representing a mesh.
TetWild is MPL2 licensed. But it contains CGAL code under GPL license.
TetWild is free for both commercial and non-commercial usage. However, you have to cite our work in your paper or put a reference of TetWild in your software. Whenever you fix bugs or make some improvement of TetWild, you should contribute back.
We used several useful libraries in our implement, testing, and rendering listed as follows. We would like to especially thank their authors for their great work and publishing the code.