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: u32Number 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
impl Mesh
pub fn vertex_count(&self) -> usize
pub fn triangle_count(&self) -> usize
pub fn is_point_cloud(&self) -> bool
Sourcepub fn append(&mut self, other: Mesh)
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).
Sourcepub fn append_placed(
&mut self,
other: &Mesh,
place: impl Fn([f64; 3]) -> [f64; 3],
)
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.
Sourcepub fn check(&self) -> Result<()>
pub fn check(&self) -> Result<()>
Validates the mesh: finite coordinates, indices in range, limits.
Sourcepub fn encode(&self) -> Vec<u8> ⓘ
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 fileViewers 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.
Sourcepub fn bake_colors(&mut self)
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.
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreimpl<T> Parallelizable for T
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
T, using the provided data to resolve any offsets.