pub struct MeshReader<'a> { /* private fields */ }Expand description
A cursor over a mesh stream.
Implementations§
Source§impl<'a> MeshReader<'a>
impl<'a> MeshReader<'a>
Sourcepub fn new(
data: &'a [u8],
params: &'a MeshParams,
space: &'a ColorSpace,
functions: &'a [Arc<Function>],
) -> Self
pub fn new( data: &'a [u8], params: &'a MeshParams, space: &'a ColorSpace, functions: &'a [Arc<Function>], ) -> Self
A reader over data.
Sourcepub fn can_read_flag(&self) -> bool
pub fn can_read_flag(&self) -> bool
Whether a flag still fits.
Sourcepub fn can_read_coords(&self) -> bool
pub fn can_read_coords(&self) -> bool
Whether a coordinate pair still fits.
Note the formulation: the halved remainder is compared against one coordinate’s width, which is the C++’s way of asking for two.
Sourcepub fn can_read_color(&self) -> bool
pub fn can_read_color(&self) -> bool
Whether a colour still fits.
The C++ divides the remainder by the component width and compares
against the component count, which is a different question from
“components * width bits remain” only when the division truncates.
Reproduced, with a guard the C++ does not need because its zero case
is unreachable.
Sourcepub fn read_coords(&mut self) -> Point
pub fn read_coords(&mut self) -> Point
Read one coordinate pair, x fully before y.
Sourcepub fn read_color(&mut self) -> Rgb
pub fn read_color(&mut self) -> Rgb
Read one colour.
With functions present the result is not a colour: the single parametric value lands in the red slot and the rest are zero.
Sourcepub fn read_vertex(&mut self) -> Option<(u8, Vertex)>
pub fn read_vertex(&mut self) -> Option<(u8, Vertex)>
Read one flagged vertex: flag, coordinates, colour, then byte-align.
Sourcepub fn read_vertex_row(&mut self, count: usize) -> Vec<Vertex>
pub fn read_vertex_row(&mut self, count: usize) -> Vec<Vertex>
Read one lattice row of count vertices — no flags.
Any failure discards the whole row, which callers treat as the end of the mesh.
Sourcepub fn read_free_form(&mut self) -> Vec<Triangle>
pub fn read_free_form(&mut self) -> Vec<Triangle>
Decode a free-form Gouraud mesh (type 4).
Sourcepub fn read_lattice(&mut self, per_row: usize) -> Vec<Triangle>
pub fn read_lattice(&mut self, per_row: usize) -> Vec<Triangle>
Decode a lattice-form Gouraud mesh (type 5).
Sourcepub fn read_patches(&mut self, kind: ShadingKind) -> Vec<Patch>
pub fn read_patches(&mut self, kind: ShadingKind) -> Vec<Patch>
Decode a Coons (type 6) or tensor (type 7) patch mesh.
point_count is a loop invariant: a flagged patch reuses four
points and two colours from its predecessor, which moves where this
patch starts reading, never how many records the format has.