MCPcopy Index your code
hub / github.com/InteractiveComputerGraphics/splashsurf / keep_cells

Method keep_cells

splashsurf_lib/src/mesh.rs:1262–1298  ·  view source on GitHub ↗

Returns a new mesh containing only the specified cells and removes all unreferenced vertices and attributes

(&self, cell_indices: &[usize], keep_all_vertices: bool)

Source from the content-addressed store, hash-verified

1260
1261 /// Returns a new mesh containing only the specified cells and removes all unreferenced vertices and attributes
1262 fn keep_cells(&self, cell_indices: &[usize], keep_all_vertices: bool) -> Self {
1263 // Filter internal mesh
1264 let mut new_mesh = if keep_all_vertices {
1265 let mut new_mesh = keep_cells_impl(self, cell_indices, &[]);
1266 new_mesh.point_attributes = self.point_attributes.clone();
1267 new_mesh
1268 } else {
1269 let vertex_keep_table = vertex_keep_table(self, cell_indices);
1270 let mut new_mesh = keep_cells_impl(self, cell_indices, &vertex_keep_table);
1271
1272 let vertex_indices = vertex_keep_table
1273 .iter()
1274 .copied()
1275 .enumerate()
1276 .filter_map(|(i, should_keep)| if should_keep { Some(i) } else { None })
1277 .collect::<Vec<_>>();
1278
1279 // Filter the point attributes
1280 new_mesh.point_attributes = self
1281 .point_attributes
1282 .iter()
1283 .map(|attr| attr.keep_indices(&vertex_indices))
1284 .collect();
1285
1286 new_mesh
1287 };
1288
1289 // Filter the cell attributes
1290 let cell_attributes = self
1291 .cell_attributes
1292 .iter()
1293 .map(|attr| attr.keep_indices(cell_indices))
1294 .collect();
1295 new_mesh.cell_attributes = cell_attributes;
1296
1297 new_mesh
1298 }
1299}
1300
1301/// Returns an mesh data wrapper with a default mesh and without attached attributes

Callers 1

par_clamp_with_aabbMethod · 0.45

Calls 6

keep_cells_implFunction · 0.85
vertex_keep_tableFunction · 0.85
cloneMethod · 0.80
collectMethod · 0.80
keep_indicesMethod · 0.80
iterMethod · 0.45

Tested by

no test coverage detected