Skip to main content

read_3mf

Function read_3mf 

Source
pub fn read_3mf(bytes: &[u8], tol: Tolerances) -> OgeomResult<ThreeMfImport>
Expand description

Read a 3MF package into placed meshes.

The start part is the one _rels/.rels names as the 3D model. Its objects are meshes or assemblies of components; a component, or a build item, may name an object in another model part of the package through the production extension’s path, as slicers write every object to its own part. Each build item comes back as one mesh, its components flattened and every transform applied, scaled from the model’s unit to millimetres. A transform that mirrors has its triangles rewound, so every mesh keeps its outward winding. Vertices the flattening brings together within the confusion tolerance are welded.

A uniform object colour is kept, from a base material or a colour group. Colours that vary across the triangles are read into ThreeMfObject::colours where every triangle has one: from colour groups and base materials, and from textures (PNG or JPEG parts of the package) sampled by the nearest texel at each corner’s coordinates, tiled as the texture’s tilestyleu and tilestylev say (none read as clamp). Composite materials and multi-properties are passed over with a warning, and so is a texture that cannot be decoded.

The roles of objects and volumes (modifiers, support blockers and enforcers, negative volumes) are read from the metadata of the package as ObjectRole lays out, and each object’s ThreeMfObject::volumes says which of its triangles each volume is. A configuration part that cannot be read is a warning.

§Errors

OgeomError::Construction if the archive cannot be read (see read_package), a model part is not well-formed, a reference names an object that is not there or contains itself, a triangle names a vertex that is not there, or the model requires the secure-content extension.