Skip to content

Loading and Saving

copy(mesh, copy_attributes=False, copy_connectivity=False)

Makes a copy of the input mesh

Parameters:

Name Type Description Default
mesh Mesh

input mesh

required
copy_attributes bool

whether to also copy attributes data. Defaults to False.

False
copy_connectivity bool

whether to also copy the connectivity data. Defaults to False.

False

Returns: Mesh: a hard copy of the given mesh

from_arrays(V, E=None, F=None, C=None, raw=False)

Creates a mesh object from numpy arrays.

Parameters:

Name Type Description Default
V ndarray

vertex coordinates. SHould have shape |V|3 or |V|2. If shape |V|*2, the array is padded so that z=0.

required
E ndarray

Edge indices (shape |E|*2). Defaults to None.

None
F ndarray

Face indices (shape |F|*n for n-regular faces). Defaults to None.

None
C ndarray

Cell indices (shape |C|*n for n-regular cells). Defaults to None.

None
raw bool

Returns the RawMeshData object instead of a fully prepared Mesh object. Defaults to False

False

Returns:

Name Type Description
Mesh Mesh

a mesh object (PointCloud to VolumeMesh depending on the data provided)

load(filename, dim=None, raw=False)

Loads a Mesh object from a file on the disk.

Supported file formats are:

  • wavefront (.obj)

  • medit (.mesh)

  • geogram (.geogram_ascii)

  • .ply

  • .stl

  • .off

  • .tet

  • .xyz (point clouds only)

Parameters:

Name Type Description Default
filename str

the path of the file

required
dim int

Override for the dimensionality of the resulting mesh. Depending on this value, returns a PointCloud, LineMesh, SurfaceMesh or VolumeMesh. If not specified, computed from the data read in the file.

None
raw bool

Returns the RawMeshData object instead of a fully prepared Mesh object. Defaults to False

False

Returns:

Name Type Description
Mesh Mesh

A new mesh object (PointCloud, LineMesh, SurfaceMesh or VolumeMesh)

merge(mesh_list)

Merges a list of independents meshes as a unique mesh.

Parameters:

Name Type Description Default
mesh_list list

a list of meshes. If empty, this function returns None

required

Returns:

Name Type Description
Mesh Mesh

the merged mesh. Takes the type of the mesh with the largest dimensionality in the list (ie merging a Polyline with a Volume mesh returns a Volume mesh)

save(mesh, filename, ignore_elements=None)

Saves the mesh data into a file.

Supported file formats are:

  • wavefront (.obj)

  • medit (.mesh)

  • geogram (.geogram_ascii)

  • .ply

  • .stl

  • .off

  • .tet

  • .xyz (point clouds only)

Parameters:

Name Type Description Default
filename str

The output file path

required

Raises:

Type Description
Exception

Unsupported file extension