Skip to main content

Crate bread_format

Crate bread_format 

Source
Expand description

Reads and writes .bread files: triangle meshes and the scene that places them, stored small and without losing anything. The format is described in SPEC.md, in the repository.

read_file and write_file read and write a whole file as a BreadFile: the scene, its meshes, and the documents programs keep about them, such as editable supports.

A .bread file is a short header followed by chunks. Each chunk has a four-byte tag, its own version, and a payload compressed with zstd and guarded by a CRC-32. container reads and writes chunks without knowing what they hold; scene and mesh are the codecs of the scene chunk and of the mesh chunks it places, app carries the documents of the application chunks, preview the meshes that show supports to readers that do not rebuild them, surface the paint on the faces of models, and role which leaves are supports or a raft rather than models. metadata says who made a file and how it may be used, and gives its parts lasting ids. stl reads STL files into meshes, to be written as .bread.

Re-exports§

pub use app::DecodeDocumentsError;
pub use app::EncodeDocumentsError;
pub use app::HOLLOWS_TAG;
pub use app::HOLLOWS_VERSION;
pub use app::HollowEntry;
pub use app::SETTINGS_TAG;
pub use app::SETTINGS_VERSION;
pub use app::SUPPORTS_TAG;
pub use app::SUPPORTS_VERSION;
pub use app::SupportEntry;
pub use app::decode_hollows;
pub use app::decode_supports;
pub use app::encode_hollows;
pub use app::encode_supports;
pub use container::BreadReader;
pub use container::BreadWriter;
pub use container::Chunk;
pub use container::ChunkTag;
pub use container::ReadBreadError;
pub use file::BreadFile;
pub use file::ReadFileError;
pub use file::THUMBNAIL_TAG;
pub use file::THUMBNAIL_VERSION;
pub use file::WriteFileError;
pub use file::read_file;
pub use file::supported_version;
pub use file::write_file;
pub use mesh::DecodeMeshError;
pub use mesh::EncodeMeshError;
pub use mesh::MESH_TAG;
pub use mesh::MESH_VERSION;
pub use mesh::Mesh;
pub use mesh::decode_mesh;
pub use mesh::encode_mesh;
pub use mesh_v2::Connectivity;
pub use mesh_v2::MeshCoding;
pub use mesh_v2::VertexCoding;
pub use mesh_v2::decode_mesh_v2;
pub use mesh_v2::encode_mesh_v2;
pub use mesh_v2::encode_mesh_v2_with;
pub use metadata::EncodeMetadataError;
pub use metadata::METADATA_TAG;
pub use metadata::METADATA_VERSION;
pub use metadata::MetadataEntry;
pub use metadata::TEXT_KEYS;
pub use metadata::UUID_KEY;
pub use metadata::decode_metadata;
pub use metadata::encode_metadata;
pub use preview::DecodePreviewsError;
pub use preview::EncodePreviewsError;
pub use preview::SUPPORT_PREVIEW_TAG;
pub use preview::SUPPORT_PREVIEW_VERSION;
pub use preview::SupportPreview;
pub use preview::decode_previews;
pub use preview::encode_previews;
pub use role::DecodeRolesError;
pub use role::EncodeRolesError;
pub use role::ROLE_RAFT;
pub use role::ROLE_SUPPORTS;
pub use role::ROLE_TAG;
pub use role::ROLE_VERSION;
pub use role::RoleEntry;
pub use role::decode_roles;
pub use role::encode_roles;
pub use scene::DecodeSceneError;
pub use scene::EncodeSceneError;
pub use scene::Node;
pub use scene::NodeKind;
pub use scene::SCENE_TAG;
pub use scene::SCENE_VERSION;
pub use scene::Scene;
pub use scene::Transform;
pub use scene::decode_scene;
pub use scene::encode_scene;
pub use stl::ReadStlError;
pub use stl::read_stl;
pub use surface::DecodeSurfaceError;
pub use surface::EncodeSurfaceError;
pub use surface::SURFACE_TAG;
pub use surface::SURFACE_VERSION;
pub use surface::SurfaceEntry;
pub use surface::decode_surface;
pub use surface::encode_surface;

Modules§

app
The application chunks (SPEC.md, section 7.3): documents that belong to one program, carried without being read.
container
The chunked container.
file
A whole .bread file: the thumbnail when there is one, the scene chunk, the metadata when there is any, the project settings, the supports, the hollows and the surface paint when there are any, the roles of leaves that are not models, then one mesh chunk per mesh of the scene, in its order, and last the support previews when there are any.
mesh
The mesh chunk: one triangle mesh, lossless (SPEC.md, section 6).
mesh_v2
Mesh chunk version 2 (SPEC.md, sections 6.6 to 6.9): the same mesh as version 1, kept as exactly, in fewer bytes.
metadata
The metadata chunk (SPEC.md, section 12): who made a file, how it may be used, and lasting ids for its parts, as entries of a subject, a key and a value.
preview
The support preview chunk (SPEC.md, section 9): for support leaves, which are stored with an empty mesh, the mesh of the supports as they were when the file was written, so that any reader can show them.
role
The role chunk (SPEC.md, section 11): which leaves are not models, but supports or a raft.
scene
The scene chunk: the tree of nodes that places the meshes (SPEC.md, section 5).
stl
STL in: binary and ASCII STL files read into a Mesh, to be written as .bread.
surface
The surface paint chunk (SPEC.md, section 10): what a person painted on the faces of models, one mask per leaf and kind.

Structs§

Meta
A name, and free text that came with it, such as an STL header.