Skip to content

read_ma

read_ma(path)

Read a medial mesh from a .ma file.

A .ma file stores a medial mesh as plain text:

#V #E #F
v x y z r      (one line per medial sphere)
e i j          (one line per medial edge / cone)
f i j k        (one line per medial face / slab)

Parameters:

Name Type Description Default
path str

Path to the .ma file.

required

Returns:

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

Medial sphere centers.

R (n,) numpy double array

Medial sphere radii.

E (e,2) numpy int array

Medial edges (each one spans a medial cone).

F (f,3) numpy int array

Medial faces (each one spans a medial slab).

Raises:

Type Description
ValueError

If the file cannot be read or is malformed.

See Also

write_ma : write a medial mesh.

Notes

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

Examples:

import libmat
V, R, E, F = libmat.read_ma("data/bug.ma")
print(V.shape, E.shape, F.shape)   # (5826, 3) (19797, 2) (13972, 3)

C++

#include <libmat/read_ma.h>

// Read a medial mesh from a .ma file:
//
//   #V #E #F
//   v x y z r      (#V lines)
//   e i j          (#E lines)
//   f i j k        (#F lines)
//
// Inputs:
//   path  path to the .ma file
// Outputs:
//   V  #V by 3 medial sphere centers
//   R  #V medial sphere radii
//   E  #E by 2 medial edges (medial cones)
//   F  #F by 3 medial faces (medial slabs)
// Returns true on success.
bool read_ma(const std::string& path, Eigen::MatrixXd& V, Eigen::VectorXd& R,
             Eigen::MatrixXi& E, Eigen::MatrixXi& F);