pub struct VolumeMesh { /* private fields */ }Expand description
A volume mesh structure (tetrahedral or hexahedral).
Cells are stored as arrays of 8 vertex indices. For tetrahedra,
only the first 4 indices are used (indices 4-7 are set to u32::MAX).
Implementations§
Source§impl VolumeMesh
impl VolumeMesh
Sourcepub fn new(
name: impl Into<String>,
vertices: Vec<Vec3>,
cells: Vec<[u32; 8]>,
) -> Self
pub fn new( name: impl Into<String>, vertices: Vec<Vec3>, cells: Vec<[u32; 8]>, ) -> Self
Creates a new volume mesh from vertices and cell indices.
§Arguments
name- The name of the meshvertices- Vertex positionscells- Cell indices, 8 per cell (unused indices should beu32::MAX)
Sourcepub fn new_tet_mesh(
name: impl Into<String>,
vertices: Vec<Vec3>,
tets: Vec<[u32; 4]>,
) -> Self
pub fn new_tet_mesh( name: impl Into<String>, vertices: Vec<Vec3>, tets: Vec<[u32; 4]>, ) -> Self
Creates a tetrahedral mesh.
Sourcepub fn new_hex_mesh(
name: impl Into<String>,
vertices: Vec<Vec3>,
hexes: Vec<[u32; 8]>,
) -> Self
pub fn new_hex_mesh( name: impl Into<String>, vertices: Vec<Vec3>, hexes: Vec<[u32; 8]>, ) -> Self
Creates a hexahedral mesh.
Sourcepub fn num_vertices(&self) -> usize
pub fn num_vertices(&self) -> usize
Returns the number of vertices.
Sourcepub fn cell_type(&self, cell_idx: usize) -> VolumeCellType
pub fn cell_type(&self, cell_idx: usize) -> VolumeCellType
Returns the cell type of the given cell.
Sourcepub fn interior_color(&self) -> Vec4
pub fn interior_color(&self) -> Vec4
Gets the interior color.
Sourcepub fn set_interior_color(&mut self, color: Vec3) -> &mut Self
pub fn set_interior_color(&mut self, color: Vec3) -> &mut Self
Sets the interior color.
Sourcepub fn edge_color(&self) -> Vec4
pub fn edge_color(&self) -> Vec4
Gets the edge color.
Sourcepub fn set_edge_color(&mut self, color: Vec3) -> &mut Self
pub fn set_edge_color(&mut self, color: Vec3) -> &mut Self
Sets the edge color.
Sourcepub fn edge_width(&self) -> f32
pub fn edge_width(&self) -> f32
Gets the edge width.
Sourcepub fn set_edge_width(&mut self, width: f32) -> &mut Self
pub fn set_edge_width(&mut self, width: f32) -> &mut Self
Sets the edge width.
Sourcepub fn decompose_to_tets(&self) -> Vec<[u32; 4]>
pub fn decompose_to_tets(&self) -> Vec<[u32; 4]>
Decomposes all cells into tetrahedra. Tets pass through unchanged, hexes are decomposed into 5 tets.
Sourcepub fn generate_render_geometry_with_quantities(
&self,
) -> VolumeMeshRenderGeometry
pub fn generate_render_geometry_with_quantities( &self, ) -> VolumeMeshRenderGeometry
Generates render geometry including any enabled quantity data.
Sourcepub fn init_render_data(
&mut self,
device: &Device,
bind_group_layout: &BindGroupLayout,
camera_buffer: &Buffer,
)
pub fn init_render_data( &mut self, device: &Device, bind_group_layout: &BindGroupLayout, camera_buffer: &Buffer, )
Initializes GPU render data.
Sourcepub fn update_render_data_with_culling(
&mut self,
device: &Device,
bind_group_layout: &BindGroupLayout,
camera_buffer: &Buffer,
planes: &[(Vec3, Vec3)],
)
pub fn update_render_data_with_culling( &mut self, device: &Device, bind_group_layout: &BindGroupLayout, camera_buffer: &Buffer, planes: &[(Vec3, Vec3)], )
Reinitializes render data with cell culling based on slice planes. Cells whose centroid is on the negative side of any plane are hidden. Uses caching to avoid regenerating geometry every frame.
Sourcepub fn reset_render_data(
&mut self,
device: &Device,
bind_group_layout: &BindGroupLayout,
camera_buffer: &Buffer,
)
pub fn reset_render_data( &mut self, device: &Device, bind_group_layout: &BindGroupLayout, camera_buffer: &Buffer, )
Resets render data to show all cells (no culling).
Sourcepub fn render_data(&self) -> Option<&SurfaceMeshRenderData>
pub fn render_data(&self) -> Option<&SurfaceMeshRenderData>
Returns the render data if available.
Sourcepub fn pick_triangles(
&self,
planes: &[(Vec3, Vec3)],
) -> (Vec<Vec3>, Vec<[u32; 3]>)
pub fn pick_triangles( &self, planes: &[(Vec3, Vec3)], ) -> (Vec<Vec3>, Vec<[u32; 3]>)
Generates triangulated exterior faces for picking. Uses current slice plane culling if provided.
Sourcepub fn init_pick_resources(
&mut self,
device: &Device,
mesh_pick_bind_group_layout: &BindGroupLayout,
camera_buffer: &Buffer,
global_start: u32,
)
pub fn init_pick_resources( &mut self, device: &Device, mesh_pick_bind_group_layout: &BindGroupLayout, camera_buffer: &Buffer, global_start: u32, )
Initializes GPU resources for pick rendering.
Creates the pick uniform buffer, cell index mapping buffer, and bind group. The cell index buffer maps each GPU triangle to its parent cell index.
Sourcepub fn pick_bind_group(&self) -> Option<&BindGroup>
pub fn pick_bind_group(&self) -> Option<&BindGroup>
Returns the pick bind group if initialized.
Sourcepub fn update_pick_uniforms(&self, queue: &Queue)
pub fn update_pick_uniforms(&self, queue: &Queue)
Updates pick uniforms (model transform) when the structure is moved.
Sourcepub fn num_render_vertices(&self) -> u32
pub fn num_render_vertices(&self) -> u32
Returns the total number of vertices in the rendered triangulation (for draw calls).
Sourcepub fn update_gpu_buffers(&self, queue: &Queue)
pub fn update_gpu_buffers(&self, queue: &Queue)
Updates GPU buffers.
Sourcepub fn update_slice_render_data(
&mut self,
device: &Device,
queue: &Queue,
bind_group_layout: &BindGroupLayout,
camera_buffer: &Buffer,
plane_origin: Vec3,
plane_normal: Vec3,
) -> bool
pub fn update_slice_render_data( &mut self, device: &Device, queue: &Queue, bind_group_layout: &BindGroupLayout, camera_buffer: &Buffer, plane_origin: Vec3, plane_normal: Vec3, ) -> bool
Updates or creates slice mesh render data for a given slice plane.
Returns true if the slice intersects this volume mesh.
Sourcepub fn slice_render_data(&self) -> Option<&SliceMeshRenderData>
pub fn slice_render_data(&self) -> Option<&SliceMeshRenderData>
Returns the slice render data if available.
Sourcepub fn clear_slice_render_data(&mut self)
pub fn clear_slice_render_data(&mut self)
Clears the slice render data cache.
Sourcepub fn build_egui_ui(&mut self, ui: &mut Ui)
pub fn build_egui_ui(&mut self, ui: &mut Ui)
Builds the egui UI for this volume mesh.
Sourcepub fn add_vertex_scalar_quantity(
&mut self,
name: impl Into<String>,
values: Vec<f32>,
) -> &mut Self
pub fn add_vertex_scalar_quantity( &mut self, name: impl Into<String>, values: Vec<f32>, ) -> &mut Self
Adds a vertex scalar quantity.
Sourcepub fn add_cell_scalar_quantity(
&mut self,
name: impl Into<String>,
values: Vec<f32>,
) -> &mut Self
pub fn add_cell_scalar_quantity( &mut self, name: impl Into<String>, values: Vec<f32>, ) -> &mut Self
Adds a cell scalar quantity.
Sourcepub fn add_vertex_color_quantity(
&mut self,
name: impl Into<String>,
colors: Vec<Vec3>,
) -> &mut Self
pub fn add_vertex_color_quantity( &mut self, name: impl Into<String>, colors: Vec<Vec3>, ) -> &mut Self
Adds a vertex color quantity.
Sourcepub fn add_cell_color_quantity(
&mut self,
name: impl Into<String>,
colors: Vec<Vec3>,
) -> &mut Self
pub fn add_cell_color_quantity( &mut self, name: impl Into<String>, colors: Vec<Vec3>, ) -> &mut Self
Adds a cell color quantity.
Sourcepub fn add_vertex_vector_quantity(
&mut self,
name: impl Into<String>,
vectors: Vec<Vec3>,
) -> &mut Self
pub fn add_vertex_vector_quantity( &mut self, name: impl Into<String>, vectors: Vec<Vec3>, ) -> &mut Self
Adds a vertex vector quantity.
Sourcepub fn add_cell_vector_quantity(
&mut self,
name: impl Into<String>,
vectors: Vec<Vec3>,
) -> &mut Self
pub fn add_cell_vector_quantity( &mut self, name: impl Into<String>, vectors: Vec<Vec3>, ) -> &mut Self
Adds a cell vector quantity.
Sourcepub fn generate_slice_geometry(
&self,
plane_origin: Vec3,
plane_normal: Vec3,
) -> Option<SliceMeshData>
pub fn generate_slice_geometry( &self, plane_origin: Vec3, plane_normal: Vec3, ) -> Option<SliceMeshData>
Generates mesh geometry for the cross-section created by a slice plane.
This computes the intersection of all cells with the plane and triangulates the resulting polygons for rendering. If a vertex color quantity is enabled, colors are interpolated at slice points.
§Arguments
plane_origin- A point on the slice planeplane_normal- The plane normal (points toward kept geometry)
§Returns
Some(SliceMeshData) if the plane intersects the mesh, None otherwise.
Trait Implementations§
Source§impl HasQuantities for VolumeMesh
impl HasQuantities for VolumeMesh
Source§fn add_quantity(&mut self, quantity: Box<dyn Quantity>)
fn add_quantity(&mut self, quantity: Box<dyn Quantity>)
Source§fn get_quantity_mut(&mut self, name: &str) -> Option<&mut Box<dyn Quantity>>
fn get_quantity_mut(&mut self, name: &str) -> Option<&mut Box<dyn Quantity>>
Source§fn remove_quantity(&mut self, name: &str) -> Option<Box<dyn Quantity>>
fn remove_quantity(&mut self, name: &str) -> Option<Box<dyn Quantity>>
Source§fn quantities(&self) -> &[Box<dyn Quantity>]
fn quantities(&self) -> &[Box<dyn Quantity>]
Source§fn num_quantities(&self) -> usize
fn num_quantities(&self) -> usize
Source§impl Structure for VolumeMesh
impl Structure for VolumeMesh
Source§fn as_any_mut(&mut self) -> &mut dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
Any for downcasting.Source§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
PointCloud”, “SurfaceMesh”).Source§fn bounding_box(&self) -> Option<(Vec3, Vec3)>
fn bounding_box(&self) -> Option<(Vec3, Vec3)>
Source§fn length_scale(&self) -> f32
fn length_scale(&self) -> f32
Source§fn set_transform(&mut self, transform: Mat4)
fn set_transform(&mut self, transform: Mat4)
Source§fn is_enabled(&self) -> bool
fn is_enabled(&self) -> bool
Source§fn set_enabled(&mut self, enabled: bool)
fn set_enabled(&mut self, enabled: bool)
Source§fn draw(&self, _ctx: &mut dyn RenderContext)
fn draw(&self, _ctx: &mut dyn RenderContext)
Source§fn draw_pick(&self, _ctx: &mut dyn RenderContext)
fn draw_pick(&self, _ctx: &mut dyn RenderContext)
Source§fn build_pick_ui(&self, _ui: &dyn Any, _pick: &PickResult)
fn build_pick_ui(&self, _ui: &dyn Any, _pick: &PickResult)
ImGui UI for a picked element.Source§fn clear_gpu_resources(&mut self)
fn clear_gpu_resources(&mut self)
Source§fn center_bounding_box(&mut self)
fn center_bounding_box(&mut self)
Source§fn reset_transform(&mut self)
fn reset_transform(&mut self)
Source§fn material(&self) -> &str
fn material(&self) -> &str
Source§fn set_material(&mut self, _material: &str)
fn set_material(&mut self, _material: &str)
Auto Trait Implementations§
impl Freeze for VolumeMesh
impl !RefUnwindSafe for VolumeMesh
impl Send for VolumeMesh
impl Sync for VolumeMesh
impl Unpin for VolumeMesh
impl !UnwindSafe for VolumeMesh
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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 more