114. plugins.plyfile

114.1. Classes defined in module plugins.plyfile

class plugins.plyfile.PlyParseError[source]

Base class for PLY parsing errors.

class plugins.plyfile.PlyElementParseError(message, element=None, row=None, prop=None)[source]

Raised when a PLY element cannot be parsed.

The attributes element, row, property, and message give additional information.

class plugins.plyfile.PlyHeaderParseError(message, line=None)[source]

Raised when a PLY header cannot be parsed.

The attribute `line’ provides additional information.

class plugins.plyfile.PlyData(elements=[], text=False, byte_order='=', comments=[], obj_info=[])[source]

PLY file header and data.

A PlyData instance is created in one of two ways: by the static method PlyData.read (to read a PLY file), or directly from __init__ given a sequence of elements (which can then be written to a PLY file).

static read(stream, mmap=True)[source]

Read PLY data from a readable file-like object or filename.

mmap: whether to allow element data to be memory-mapped when

possible. The default is True, which allows memory mapping. Using False will prevent memory mapping.

write(stream)[source]

Write PLY data to a writeable file-like object or filename.

property header

Provide PLY-formatted metadata for the instance.

class plugins.plyfile.PlyElement(name, properties, count, comments=[])[source]

PLY file element.

A client of this library doesn’t normally need to instantiate this directly, so the following is only for the sake of documenting the internals.

Creating a PlyElement instance is generally done in one of two ways: as a byproduct of PlyData.read (when reading a PLY file) and by PlyElement.describe (before writing a PLY file).

dtype(byte_order='=')[source]

Return the numpy dtype of the in-memory representation of the data. (If there are no list properties, and the PLY format is binary, then this also accurately describes the on-disk representation of the element.)

static describe(data, name, len_types={}, val_types={}, comments=[])[source]

Construct a PlyElement from an array’s metadata.

len_types and val_types can be given as mappings from list property names to type strings (like ‘u1’, ‘f4’, etc., or ‘int8’, ‘float32’, etc.). These can be used to define the length and value types of list properties. List property lengths always default to type ‘u1’ (8-bit unsigned integer), and value types default to ‘i4’ (32-bit integer).

property header

Format this element’s metadata as it would appear in a PLY header.

class plugins.plyfile.PlyProperty(name, val_dtype)[source]

PLY property description. This class is pure metadata; the data itself is contained in PlyElement instances.

dtype(byte_order='=')[source]

Return the numpy dtype description for this property (as a tuple of strings).

class plugins.plyfile.PlyListProperty(name, len_dtype, val_dtype)[source]

PLY list property description.

dtype(byte_order='=')[source]

List properties always have a numpy dtype of “object”.

list_dtype(byte_order='=')[source]

Return the pair (len_dtype, val_dtype) (both numpy-friendly strings).

114.2. Functions defined in module plugins.plyfile

plugins.plyfile.make2d(array, cols=None, dtype=None)[source]

Make a 2D array from an array of arrays. The `cols’ and `dtype’ arguments can be omitted if the array is not empty.