Skip to content

Python API

All functions take and return numpy arrays, and are available directly from the libmat module:

import libmat
V, F = libmat.read_surface_mesh("data/mesh_69058.obj")
C, R, types = libmat.shrink_spheres(V, F)

Every function has a C++ counterpart with the same name in namespace libmat, declared in <libmat/<name>.h>.

Input / output

function description
read_tet_mesh Read a tet mesh (.msh, .tet, .vtk)
read_surface_mesh Read a triangle mesh (.obj, .off, .ply, .stl, ...)
read_ma Read a medial mesh (.ma)
write_ma Write a medial mesh (.ma)

Mesh processing

function description
normalize_vertices Normalize into [0, 1000]^3, the internal frame
extract_surface Boundary surface of a tet mesh
detect_sharp_features Sharp / concave edges, feature lines and corners

Medial spheres

function description
shrink_spheres Medial spheres with the ball-shrinking algorithm
regular_triangulation Power diagram neighbors of spheres (CGAL)

Medial mesh

function description
slab_tangent_triangles Triangles tangent to medial slabs
distance_to_medial_mesh Signed distance to a medial mesh (CPU / CUDA)
thin_medial_mesh Topology-preserving thinning
medial_mesh_from_spheres Medial mesh from spheres via the RPD (CUDA)

Utilities

function description
libmat.has_cuda() True if libmat was built with CUDA
libmat.set_verbose(bool) print the log of the C++ modules (silenced by default)
libmat.SPHERE_TYPES names of the sphere types returned by shrink_spheres
libmat.__version__ version string