(cmd_args: &ConvertSubcommandArgs)
| 73 | } |
| 74 | |
| 75 | fn convert_particles(cmd_args: &ConvertSubcommandArgs) -> Result<(), anyhow::Error> { |
| 76 | profile!("particle file conversion cli"); |
| 77 | |
| 78 | let io_params = io::FormatParameters::default(); |
| 79 | let input_file = cmd_args.input_particles.as_ref().unwrap(); |
| 80 | let output_file = &cmd_args.output_file; |
| 81 | |
| 82 | // Read particles |
| 83 | let particle_positions: Vec<Vector3<f32>> = |
| 84 | io::read_particle_positions(input_file.as_path(), &io_params.input).with_context(|| { |
| 85 | format!( |
| 86 | "Failed to load particle positions from file \"{}\"", |
| 87 | input_file.as_path().display() |
| 88 | ) |
| 89 | })?; |
| 90 | |
| 91 | // Filter particles by user specified domain |
| 92 | let particle_positions = if let (Some(min), Some(max)) = |
| 93 | (cmd_args.domain_min.clone(), cmd_args.domain_max.clone()) |
| 94 | { |
| 95 | let min = nalgebra::convert(Vector3::from_iterator(min)); |
| 96 | let max = nalgebra::convert(Vector3::from_iterator(max)); |
| 97 | let aabb = Aabb3d::new(min, max); |
| 98 | info!("Filtering out particles outside of {:?}", aabb); |
| 99 | |
| 100 | particle_positions |
| 101 | .into_iter() |
| 102 | .filter(|p| aabb.contains_point(p)) |
| 103 | .collect() |
| 104 | } else { |
| 105 | particle_positions |
| 106 | }; |
| 107 | |
| 108 | // Write particles |
| 109 | io::write_particle_positions( |
| 110 | particle_positions.as_slice(), |
| 111 | output_file.as_path(), |
| 112 | &io_params.output, |
| 113 | )?; |
| 114 | |
| 115 | Ok(()) |
| 116 | } |
| 117 | |
| 118 | fn convert_mesh(cmd_args: &ConvertSubcommandArgs) -> Result<(), anyhow::Error> { |
| 119 | profile!("mesh file conversion cli"); |
no test coverage detected