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.
| 267 | /// Meshes consist of vertices and cells. Cells identify their associated vertices using indices |
| 268 | /// into the mesh's slice of vertices. |
| 269 | pub trait Mesh3d<R: Real> |
| 270 | where |
| 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, &[]) |
no outgoing calls
no test coverage detected