pub struct Mesh {
pub vertices: Vec<Vertex>,
pub triangles: Vec<Triangle>,
pub beam_lattice: Option<BeamLattice>,
}Expand description
A triangle mesh representing 3D geometry.
A mesh is the fundamental geometry container in 3MF, consisting of vertices (3D points) and triangles that connect those vertices. Meshes can optionally include beam lattice structures for lightweight, high-strength geometry.
§Examples
use lib3mf_core::model::Mesh;
let mut mesh = Mesh::new();
let v1 = mesh.add_vertex(0.0, 0.0, 0.0);
let v2 = mesh.add_vertex(1.0, 0.0, 0.0);
let v3 = mesh.add_vertex(0.0, 1.0, 0.0);
mesh.add_triangle(v1, v2, v3);
assert_eq!(mesh.triangles.len(), 1);Fields§
§vertices: Vec<Vertex>List of vertices (points in 3D space).
triangles: Vec<Triangle>List of triangles connecting vertices by their indices.
beam_lattice: Option<BeamLattice>Beam Lattice extension data for structural lattice geometry (optional).
Implementations§
Source§impl Mesh
impl Mesh
Sourcepub fn add_triangle(&mut self, v1: u32, v2: u32, v3: u32)
pub fn add_triangle(&mut self, v1: u32, v2: u32, v3: u32)
Adds a triangle to the mesh connecting three vertices.
§Arguments
v1- Index of the first vertexv2- Index of the second vertexv3- Index of the third vertex
The vertex indices should be in counter-clockwise order when viewed from outside the mesh for correct normal orientation.
Sourcepub fn compute_aabb(&self) -> Option<BoundingBox>
pub fn compute_aabb(&self) -> Option<BoundingBox>
Computes the axis-aligned bounding box (AABB) of the mesh.
Returns None if the mesh has no vertices.
Sourcepub fn compute_area_and_volume(&self) -> (f64, f64)
pub fn compute_area_and_volume(&self) -> (f64, f64)
Computes the total surface area and volume of the mesh.
Uses triangle area calculation and signed tetrahedron volumes. Returns (0.0, 0.0) if the mesh has no triangles.
§Returns
A tuple of (surface_area, volume) in square and cubic model units respectively.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Mesh
impl<'de> Deserialize<'de> for Mesh
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl MeshRepair for Mesh
impl MeshRepair for Mesh
Source§fn repair(&mut self, options: RepairOptions) -> RepairStats
fn repair(&mut self, options: RepairOptions) -> RepairStats
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 UnwindSafe for Mesh
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 more