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