MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/splashsurf / Mesh3d

Interface Mesh3d

splashsurf_lib/src/mesh.rs:269–372  ·  view source on GitHub ↗

Basic functionality that is provided by all meshes of the library Meshes consist of vertices and cells. Cells identify their associated vertices using indices into the mesh's slice of vertices.

Source from the content-addressed store, hash-verified

267/// Meshes consist of vertices and cells. Cells identify their associated vertices using indices
268/// into the mesh's slice of vertices.
269pub trait Mesh3d<R: Real>
270where
271 Self: Sized,
272{
273 /// The cell connectivity type of the mesh
274 type Cell: CellConnectivity + Clone;
275
276 /// Returns a slice of all vertices of the mesh
277 fn vertices(&self) -> &[Vector3<R>];
278 /// Returns a mutable slice of all vertices of the mesh
279 fn vertices_mut(&mut self) -> &mut [Vector3<R>];
280 /// Returns a slice of all cells of the mesh
281 fn cells(&self) -> &[Self::Cell];
282
283 /// Constructs a mesh from the given vertices and connectivity (does not check inputs for validity)
284 fn from_vertices_and_connectivity(
285 vertices: Vec<Vector3<R>>,
286 connectivity: Vec<Self::Cell>,
287 ) -> Self;
288
289 /// Returns a mapping of all mesh vertices to the set of their connected neighbor vertices
290 fn vertex_vertex_connectivity(&self) -> Vec<Vec<usize>> {
291 profile!("vertex_vertex_connectivity");
292
293 let mut connectivity_map: Vec<Vec<usize>> =
294 vec![Vec::with_capacity(4); self.vertices().len()];
295 for cell in self.cells() {
296 for &i in cell.vertices() {
297 for &j in cell.vertices() {
298 if i != j && !connectivity_map[i].contains(&j) {
299 connectivity_map[i].push(j);
300 }
301 }
302 }
303 }
304
305 connectivity_map
306 }
307
308 /// Returns a mapping of all mesh vertices to the set of the cells they belong to
309 fn vertex_cell_connectivity(&self) -> Vec<Vec<usize>> {
310 profile!("vertex_cell_connectivity");
311 let mut connectivity_map: Vec<Vec<usize>> = vec![Vec::new(); self.vertices().len()];
312 for (cell_idx, cell) in self.cells().iter().enumerate() {
313 for &v_i in cell.vertices() {
314 if !connectivity_map[v_i].contains(&cell_idx) {
315 connectivity_map[v_i].push(cell_idx);
316 }
317 }
318 }
319
320 connectivity_map
321 }
322
323 /// Returns a new mesh containing only the specified cells and removes all unreferenced vertices
324 fn keep_cells(&self, cell_indices: &[usize], keep_vertices: bool) -> Self {
325 if keep_vertices {
326 keep_cells_impl(self, cell_indices, &[])

Callers 8

test_half_edge_meshFunction · 0.45
test_halfedge_icoFunction · 0.45
test_halfedge_planeFunction · 0.45
reconstruction_pipelineFunction · 0.45
convert_tris_to_quadsFunction · 0.80
reconstruction_pipelineFunction · 0.80
reconstruction_pipelineFunction · 0.80

Implementers 1

mesh.rssplashsurf_lib/src/mesh.rs

Calls

no outgoing calls

Tested by

no test coverage detected