Skip to content

read_tet_mesh

read_tet_mesh(path)

Read a tetrahedral mesh from a .msh, .tet or .vtk file.

Supports gmsh .msh files (e.g. produced by fTetWild), the plain-text .tet format and legacy .vtk unstructured grids.

Parameters:

Name Type Description Default
path str

Path to the tet mesh file.

required

Returns:

Name Type Description
V (n,3) numpy double array

Vertex positions.

T (m,4) numpy int array

Tetrahedra, as 0-based indices into V.

Raises:

Type Description
ValueError

If the file cannot be read.

See Also

extract_surface : boundary triangle mesh of a tet mesh.

Notes

C++: bool libmat::read_tet_mesh(path, V, T) in <libmat/read_tet_mesh.h>.

Examples:

import libmat
V, T = libmat.read_tet_mesh("data/lblock.tet")
print(V.shape, T.shape)   # (3751, 3) (18000, 4)

C++

#include <libmat/read_tet_mesh.h>

// Read a tetrahedral mesh from a .msh (gmsh v2/v4, e.g. from fTetWild),
// .tet or .vtk file.
//
// Inputs:
//   path  path to the tet mesh file
// Outputs:
//   V  #V by 3 vertex positions
//   T  #T by 4 tetrahedra (0-based vertex indices)
// Returns true on success.
bool read_tet_mesh(const std::string& path, Eigen::MatrixXd& V,
                   Eigen::MatrixXi& T);