Skip to main content

Module io

Module io 

Source
Expand description

Mesh file formats, selected by file extension: STL (binary and ASCII), OBJ, PLY (ASCII and binary little-endian) and binary glTF (.glb), as input and output.

Parsers take the whole file as bytes and return an error, never a panic, on anything malformed or truncated. A count in a file is never trusted: it is checked against the bytes actually there before anything is allocated from it, so a small file cannot ask for a huge allocation.

Structs§

Error
A file could not be read, parsed or written; the message says why.
MeshData
An indexed triangle mesh in file coordinates.

Enums§

Format
A file format.

Functions§

atomic_write
Writes a file so that it appears whole or not at all: into a temporary file beside it, then renamed over path (through a symbolic link, to its target). A failure removes the temporary file and leaves path as it was.
parse
Parses a whole file. The result has at least one triangle, finite positions and every index below the vertex count.
write_mesh
Writes data as a whole file, dropping vertices no triangle uses. ascii picks the text form of a format that has both (Format::has_ascii_form) and is ignored by the others. STL, binary PLY and GLB hold 32-bit floats; OBJ and ASCII PLY keep the full double precision.

Type Aliases§

Result
Result with Error as the error type.