MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/splashsurf / particles_from_file

Function particles_from_file

splashsurf_lib/src/io.rs:17–43  ·  view source on GitHub ↗

Tries to load particles from the given file path, automatically detecting supported file extensions

(
    input_file: P,
)

Source from the content-addressed store, hash-verified

15
16/// Tries to load particles from the given file path, automatically detecting supported file extensions
17pub fn particles_from_file<R: Real, P: AsRef<Path>>(
18 input_file: P,
19) -> Result<Vec<Vector3<R>>, anyhow::Error> {
20 let input_file = input_file.as_ref();
21 if let Some(extension) = input_file.extension() {
22 let extension = extension
23 .to_str()
24 .ok_or(anyhow!("Invalid extension of input file"))?;
25
26 match extension.to_lowercase().as_str() {
27 "vtk" => vtk_format::particles_from_vtk(input_file),
28 "vtu" => vtk_format::particles_from_vtk(input_file),
29 "xyz" => xyz_format::particles_from_xyz(input_file),
30 "ply" => ply_format::particles_from_ply(input_file),
31 "bgeo" => bgeo_format::particles_from_bgeo(input_file),
32 "json" => json_format::particles_from_json(input_file),
33 _ => Err(anyhow!(
34 "Unsupported file format extension \"{}\" for reading particles",
35 extension
36 )),
37 }
38 } else {
39 Err(anyhow!(
40 "Unable to detect file format of particle input file (file name has to end with supported extension)",
41 ))
42 }
43}

Calls 5

particles_from_vtkFunction · 0.85
particles_from_xyzFunction · 0.85
particles_from_plyFunction · 0.85
particles_from_bgeoFunction · 0.85
particles_from_jsonFunction · 0.85