Skip to main content

Mesh

Struct Mesh 

Source
pub struct Mesh {
    pub positions: Vec<f32>,
    pub indices: Vec<u32>,
    pub colors: Vec<u8>,
    pub parts: u32,
    pub fields: Vec<Field>,
    pub faces: Option<(u32, u32)>,
}
Expand description

Triangles (or points when indices is empty) in model coordinates.

Fields§

§positions: Vec<f32>

x, y, z per vertex.

§indices: Vec<u32>

Three vertex indices per triangle; empty for a point cloud.

§colors: Vec<u8>

r, g, b per vertex – empty, or three bytes for every vertex.

§parts: u32

Number of bodies / objects (for the status line of the viewer).

§fields: Vec<Field>

Scalar result fields, one value per vertex (simulation results).

§faces: Option<(u32, u32)>

A partial preview: (faces shown, faces in the file) – STEP files whose B-rep the kernel could tessellate only in part.

Implementations§

Source§

impl Mesh

Source

pub fn vertex_count(&self) -> usize

Source

pub fn triangle_count(&self) -> usize

Source

pub fn is_point_cloud(&self) -> bool

Source

pub fn append(&mut self, other: Mesh)

Appends other (indices are shifted; colours are filled in so that either every vertex or none has a colour).

Source

pub fn append_placed( &mut self, other: &Mesh, place: impl Fn([f64; 3]) -> [f64; 3], )

Appends the geometry of other with every vertex moved by place: what Mesh::append does with a placed copy of other, without making that copy first (an assembly places the same part many times). Indices are shifted and colours filled in the same way; result fields and the partial-preview note belong to one file and are not carried over.

Source

pub fn check(&self) -> Result<()>

Validates the mesh: finite coordinates, indices in range, limits.

Source

pub fn bounds(&self) -> [f32; 6]

Bounding box [min x, min y, min z, max x, max y, max z].

Source

pub fn encode(&self) -> Vec<u8> ⓘ

The binary form read by shared/js/viewer.js:

0   "TCMESH01"
8   u32 vertices   12  u32 indices   16  u32 parts
20  u32 flags (1 = colours, 2 = fields, 4 = partial preview)
24  f32 × 6 bounding box
48  f32 × 3·vertices, u32 × indices, u8 × 3·vertices (colours, padded to 4 bytes)
    only with flag 2, after that:
    u32 field count, then per field
    u32 n, n bytes name (UTF-8), u32 m, m bytes unit, padding to 4 bytes,
    f32 min, f32 max, f32 × vertices (NaN = no value)
with flag 4, the last 8 bytes of the file: u32 faces shown, u32 faces in the file

Viewers that do not know flag 2 ignore the field section; meshes with fields also carry the first field as colours for them. The face count sits at the very end, so viewers that do not know flag 4 – and the field section in between – are not affected.

Source

pub fn bake_colors(&mut self)

Sets the colours from the first field (for viewers that do not know fields); vertices without a value are neutral.

Source

pub fn decode(data: &[u8]) -> Result<Mesh>

Reads Mesh::encode output (tests, tools). Every size is checked, so a damaged cache file is an error, not a panic.

Trait Implementations§

Source§

impl Clone for Mesh

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Mesh

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Mesh

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Mesh

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Mesh

Auto Trait Implementations§

§

impl Freeze for Mesh

§

impl RefUnwindSafe for Mesh

§

impl Send for Mesh

§

impl Sync for Mesh

§

impl Unpin for Mesh

§

impl UnsafeUnpin for Mesh

§

impl UnwindSafe for Mesh

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Parallelizable for T
where T: Send + Sync,

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<U, T> ToOwnedObj<U> for T
where U: FromObjRef<T>,

§

fn to_owned_obj(&self, data: FontData<'_>) -> U

Convert this type into T, using the provided data to resolve any offsets.
§

impl<U, T> ToOwnedTable<U> for T
where U: FromTableRef<T>,

§

fn to_owned_table(&self) -> U

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more