conspire/geometry/mesh/read/
mod.rs1pub mod abaqus;
2#[cfg(feature = "netcdf")]
3pub mod exodus;
4pub mod medit;
5pub mod vtk;
6
7pub use self::abaqus::ReadAbaqus;
8#[cfg(feature = "netcdf")]
9pub use self::exodus::ReadExodus;
10pub use self::medit::ReadMedit;
11pub use self::vtk::{multi_block::ReadVtkMultiBlock, unstructured::ReadVtkUnstructured};
12
13use crate::geometry::mesh::Mesh;
14use std::{io::Error as ErrorIO, path::Path};
15
16pub enum Input<P>
17where
18 P: AsRef<Path>,
19{
20 Abaqus(P),
21 #[cfg(feature = "netcdf")]
22 Exodus(P),
23 Medit(P),
24 VtkUnstructured(P),
25 VtkMultiBlock(P),
26}
27
28impl<P> AsRef<Path> for Input<P>
29where
30 P: AsRef<Path>,
31{
32 fn as_ref(&self) -> &Path {
33 match self {
34 Input::Abaqus(path) => path.as_ref(),
35 #[cfg(feature = "netcdf")]
36 Input::Exodus(path) => path.as_ref(),
37 Input::Medit(path) => path.as_ref(),
38 Input::VtkUnstructured(path) => path.as_ref(),
39 Input::VtkMultiBlock(path) => path.as_ref(),
40 }
41 }
42}
43
44impl<const D: usize, P> TryFrom<Input<P>> for Mesh<D>
45where
46 P: AsRef<Path>,
47{
48 type Error = ErrorIO;
49 fn try_from(input: Input<P>) -> Result<Self, Self::Error> {
50 match input {
51 Input::Abaqus(path) => Ok(Mesh::read_abaqus(path)?),
52 #[cfg(feature = "netcdf")]
53 Input::Exodus(path) => Ok(Mesh::read_exodus(path)?),
54 Input::Medit(path) => Ok(Mesh::read_medit(path)?),
55 Input::VtkUnstructured(path) => Ok(Mesh::read_vtk_unstructured(path)?),
56 Input::VtkMultiBlock(path) => Ok(Mesh::read_vtk_multi_block(path)?),
57 }
58 }
59}