Skip to main content

MeshReader

Struct MeshReader 

Source
pub struct MeshReader<'a> { /* private fields */ }
Expand description

A cursor over a mesh stream.

Implementations§

Source§

impl<'a> MeshReader<'a>

Source

pub fn new( data: &'a [u8], params: &'a MeshParams, space: &'a ColorSpace, functions: &'a [Arc<Function>], ) -> Self

A reader over data.

Source

pub fn can_read_flag(&self) -> bool

Whether a flag still fits.

Source

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.

Source

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.

Source

pub fn read_flag(&mut self) -> u8

Read an edge flag, masked to two bits.

Source

pub fn read_coords(&mut self) -> Point

Read one coordinate pair, x fully before y.

Source

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.

Source

pub fn read_vertex(&mut self) -> Option<(u8, Vertex)>

Read one flagged vertex: flag, coordinates, colour, then byte-align.

Source

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.

Source

pub fn read_free_form(&mut self) -> Vec<Triangle>

Decode a free-form Gouraud mesh (type 4).

Source

pub fn read_lattice(&mut self, per_row: usize) -> Vec<Triangle>

Decode a lattice-form Gouraud mesh (type 5).

Source

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.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for MeshReader<'a>

§

impl<'a> !UnwindSafe for MeshReader<'a>

§

impl<'a> Freeze for MeshReader<'a>

§

impl<'a> Send for MeshReader<'a>

§

impl<'a> Sync for MeshReader<'a>

§

impl<'a> Unpin for MeshReader<'a>

§

impl<'a> UnsafeUnpin for MeshReader<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.