Skip to content

read_surface_mesh

read_surface_mesh(path)

Read a triangle mesh from a file.

Any format supported by geogram can be read (.obj, .off, .ply, .stl, .mesh, .geogram, ...). Polygonal faces are triangulated.

Parameters:

Name Type Description Default
path str

Path to the surface mesh file.

required

Returns:

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

Vertex positions.

F (m,3) numpy int array

Triangles, as 0-based indices into V.

Raises:

Type Description
ValueError

If the file cannot be read.

Notes

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

Examples:

import libmat
V, F = libmat.read_surface_mesh("data/mesh_69058.obj")
print(V.shape, F.shape)   # (66, 3) (128, 3)

C++

#include <libmat/read_surface_mesh.h>

// Read a triangle mesh from any format supported by geogram
// (.obj, .off, .ply, .stl, .mesh, .geogram, ...). Polygonal faces are
// triangulated.
//
// Inputs:
//   path  path to the surface mesh file
// Outputs:
//   V  #V by 3 vertex positions
//   F  #F by 3 triangles (0-based vertex indices)
// Returns true on success.
bool read_surface_mesh(const std::string& path, Eigen::MatrixXd& V,
                       Eigen::MatrixXi& F);