Constructs the background grid for marching cubes based on the parameters supplied to the surface reconstruction
(
particle_positions: &[Vector3<R>],
particle_radius: R,
compact_support_radius: R,
cube_size: R,
particle_aabb: Option<&Aabb3d<R>>,
enable_multi_threading: bool,
)
| 474 | |
| 475 | /// Constructs the background grid for marching cubes based on the parameters supplied to the surface reconstruction |
| 476 | pub fn grid_for_reconstruction<I: Index, R: Real>( |
| 477 | particle_positions: &[Vector3<R>], |
| 478 | particle_radius: R, |
| 479 | compact_support_radius: R, |
| 480 | cube_size: R, |
| 481 | particle_aabb: Option<&Aabb3d<R>>, |
| 482 | enable_multi_threading: bool, |
| 483 | ) -> Result<UniformGrid<I, R>, ReconstructionError<I, R>> { |
| 484 | let mut particle_aabb = if let Some(particle_aabb) = particle_aabb { |
| 485 | particle_aabb.clone() |
| 486 | } else { |
| 487 | profile!("compute minimum enclosing aabb"); |
| 488 | |
| 489 | let particle_aabb = { |
| 490 | let mut aabb = if enable_multi_threading { |
| 491 | Aabb3d::par_from_points(particle_positions) |
| 492 | } else { |
| 493 | Aabb3d::from_points(particle_positions) |
| 494 | }; |
| 495 | // TODO: Is this really necessary? This seems unnecessary purely for the density map... |
| 496 | aabb.grow_uniformly(particle_radius); |
| 497 | aabb |
| 498 | }; |
| 499 | |
| 500 | info!( |
| 501 | "Bounding box of particles with margin for levelset evaluation: {:?} to {:?}", |
| 502 | particle_aabb.min().as_slice(), |
| 503 | particle_aabb.max().as_slice() |
| 504 | ); |
| 505 | |
| 506 | particle_aabb |
| 507 | }; |
| 508 | |
| 509 | // Ensure that we have enough margin around the particles such that the every particle's kernel support is completely in the domain |
| 510 | let kernel_margin = |
| 511 | density_map::compute_kernel_evaluation_radius::<I, R>(compact_support_radius, cube_size) |
| 512 | .kernel_evaluation_radius; |
| 513 | particle_aabb.grow_uniformly(kernel_margin); |
| 514 | |
| 515 | Ok(UniformGrid::from_aabb(&particle_aabb, cube_size)?) |
| 516 | } |
no test coverage detected