porescene.io module¶
Reading and writing of mesh and geometry files.¶
- porescene.io.mesh2obj(pth_obj, mesh)[source]¶
Writes one or more meshes to a Wavefront
.objfile in text format.- Parameters:
pth_obj (
Path) – Output path of the OBJ file.mesh (
Mesh|Mapping[int,Mesh] |Sequence[Mesh]) – The mesh(es) to write. Pass a singleMesh, or a collection of them to store as separate OBJ objects in one file – e.g. the{label: Mesh}mapping returned byvolume2mesh(..., per_label=True). A mapping is written in ascending key order; a sequence keeps its order. Each mesh’snamebecomes anorecord, and vertices are concatenated with the running index offset that OBJ’s shared, file-global vertex numbering requires. Faces hold 0-based vertex indices (as produced byvolume2mesh()); OBJ indices are 1-based, so the values are offset accordingly on write.
- Returns:
File path of the written OBJ file.
- Return type:
- porescene.io.mesh2ply(pth_ply, mesh, binary=True)[source]¶
Writes a mesh to a Stanford
.plyfile.- Parameters:
pth_ply (
Path) – Output path of the PLY file.mesh (
Mesh) – The mesh to write. Its faces hold 0-based vertex indices (e.g. fromporescene.utility.volume2mesh()); PLY indices are 0-based too, so they are written unchanged. The meshnameis written as a PLY comment.binary (
bool) – IfTrue(default), the vertex and face data are written as packed little-endian binary – far smaller and faster to load than theasciivariant produced whenFalse. Defaults toTrue.
- Returns:
File path of the written PLY file.
- Return type: