File I/O

ObjFile

class meshpy.ObjFile(filepath)

Bases: object

A Wavefront .obj file reader and writer.

filepath

str – The full path to the .obj file associated with this reader/writer.

__init__(filepath)

Construct and initialize a .obj file reader and writer.

Parameters:filepath (str) – The full path to the desired .obj file
Raises:ValueError – If the file extension is not .obj.
filepath

Returns the full path to the .obj file associated with this reader/writer.

Returns:The full path to the .obj file associated with this reader/writer.
Return type:str
read()

Reads in the .obj file and returns a Mesh3D representation of that mesh.

Returns:A Mesh3D created from the data in the .obj file.
Return type:Mesh3D
write(mesh)

Writes a Mesh3D object out to a .obj file format

Parameters:mesh (Mesh3D) – The Mesh3D object to write to the .obj file.

Note

Does not support material files or texture coordinates.

OffFile

class meshpy.OffFile(filepath)

A .off file reader and writer.

filepath

str – The full path to the .off file associated with this reader/writer.

__init__(filepath)

Set the path to the file to open

filepath

Returns the full path to the .off file associated with this reader/writer.

Returns:The full path to the .ff file associated with this reader/writer.
Return type:str
read()

Reads in the .off file and returns a Mesh3D representation of that mesh.

Returns:A Mesh3D created from the data in the .off file.
Return type:Mesh3D
write(mesh)

Writes a Mesh3D object out to a .off file format

Parameters:mesh (Mesh3D) – The Mesh3D object to write to the .obj file.

Note

Does not support material files or texture coordinates.

SdfFile

class meshpy.SdfFile(filepath)

A Signed Distance Field .sdf file reader and writer.

filepath

str – The full path to the .sdf or .csv file associated with this reader/writer.

__init__(filepath)

Construct and initialize a .sdf file reader and writer.

Parameters:filepath (str) – The full path to the desired .sdf or .csv file
Raises:ValueError – If the file extension is not .sdf of .csv.
filepath

Returns the full path to the file associated with this reader/writer.

Returns:The full path to the file associated with this reader/writer.
Return type:str
read()

Reads in the SDF file and returns a Sdf object.

Returns:A Sdf created from the data in the file.
Return type:Sdf
write(sdf)

Writes an SDF to a file.

Parameters:sdf (Sdf) – An Sdf object to write out.

Note

This is not currently implemented or supported.

StablePoseFile

class meshpy.StablePoseFile(filepath)

A Stable Pose .stp file reader and writer.

filepath

str – The full path to the .stp file associated with this reader/writer.

__init__(filepath)

Construct and initialize a .stp file reader and writer.

Parameters:filepath (str) – The full path to the desired .stp file
Raises:ValueError – If the file extension is not .stp.
filepath

Returns the full path to the .stp file associated with this reader/writer.

Returns:The full path to the .stp file associated with this reader/writer.
Return type:str
read()

Reads in the .stp file and returns a list of StablePose objects.

Returns::obj:`list` of – A list of StablePose objects read from the .stp file.
Return type:obj`StablePose`
write(stable_poses, min_prob=0)

Writes out the stable poses for a mesh with a minimum probability filter.

Parameters:
  • stable_poses (list of StablePose) – List of stable poses that should be written to the file.
  • min_prob (float) – The minimum probability for a pose to actually be written to the file.