Input/output

PMesh provides only few basic I/O capabilities by read and write. Instead, we plan to rely on FileIO.jl and GeomeytryBasics.jl, see also Interoperability.

Note

The current implementation does not provide dynamic creation of attributes, e.g. by read!

mesh = read(:off, "path-to/input.off"; exceptions=false)
write(:off, "path/to/output.off"; exceptions=false)

# format from file extension
mesh = read("path-to/input.off")
write("path/to/output.off")

See also FileIO and GeometryBasics

Base.readFunction
mesh = read([format,] filename, template::Mesh[;
            position=Val(:x), uv=:nothing, exceptions=false])

Read a polygonal mesh from file filename assuming format, where template defines the concrete type of mesh (e.g., which attributes exist) and state of attributes (i.e., which attributes are enabled).

In case read fails, the optional argument exceptions determines whether an exception is thrown or read return nothing.

The following formats are currently supported

  • :off OFF file, only vertex positions
  • :obj OBJ file, vertex positions and texture coordinates (optional)

See also write

source
Base.writeFunction
success = write([format,] filename, mesh::Mesh[;
                position=Val(:x), uv=nothing, exceptions=false])

Write a polygonal mesh to file filename using format. Returns true on success.

In case write fails, the optional argument exceptions determines whether an exception is thrown orwritereturnsfalse`.

The following formats are currently supported

  • :off OFF file, only vertex positions
  • :obj OBJ file, vertex positions and texture coordinates (optional)

See also read

source