Replaces the mesh but keeps the data
(self, new_mesh: NewMeshT)
| 1317 | |
| 1318 | /// Replaces the mesh but keeps the data |
| 1319 | pub fn with_mesh<NewMeshT: Mesh3d<R>>(self, new_mesh: NewMeshT) -> MeshWithData<R, NewMeshT> { |
| 1320 | if !self.point_attributes.is_empty() { |
| 1321 | assert_eq!( |
| 1322 | self.mesh.vertices().len(), |
| 1323 | new_mesh.vertices().len(), |
| 1324 | "number of vertices should match if there are point attributes" |
| 1325 | ); |
| 1326 | } |
| 1327 | if !self.cell_attributes.is_empty() { |
| 1328 | assert_eq!( |
| 1329 | self.mesh.cells().len(), |
| 1330 | new_mesh.cells().len(), |
| 1331 | "number of cells should match if there are cell attributes" |
| 1332 | ) |
| 1333 | } |
| 1334 | MeshWithData { |
| 1335 | mesh: new_mesh, |
| 1336 | point_attributes: self.point_attributes, |
| 1337 | cell_attributes: self.cell_attributes, |
| 1338 | } |
| 1339 | } |
| 1340 | |
| 1341 | /// Attaches an attribute to the points of the mesh, panics if the length of the data does not match the mesh's number of points |
| 1342 | pub fn with_point_data(mut self, point_attribute: impl Into<OwnedMeshAttribute<R>>) -> Self { |
no test coverage detected