diff --git a/src/geometry.rs b/src/geometry.rs index 0cce49e..f2f6d89 100644 --- a/src/geometry.rs +++ b/src/geometry.rs @@ -5,7 +5,7 @@ use geo::{Polygon, LineString, Point, point, Closest}; use geo::algorithm::closest_point::ClosestPoint; ///Trait for a Geometry object - all forms of geometry must implement these traits to be used -pub trait Geometry: GeometryInput { +pub trait Geometry { type InputFileFormat: InputFile + Clone; @@ -45,15 +45,11 @@ pub struct Mesh0D { pub energy_barrier_thickness: f64, } -impl GeometryInput for Mesh0D { - type GeometryInput = Mesh0DInput; -} - impl Geometry for Mesh0D { type InputFileFormat = Input0D; - fn new(input: &::GeometryInput) -> Mesh0D { + fn new(input: &<::InputFileFormat as GeometryInput>::GeometryInput) -> Mesh0D { let length_unit: f64 = match input.length_unit.as_str() { "MICRON" => MICRON, @@ -139,10 +135,6 @@ pub struct Mesh1D { pub bottom_energy_barrier_thickness: f64, } -impl GeometryInput for Mesh1D { - type GeometryInput = Mesh1DInput; -} - impl Geometry for Mesh1D { type InputFileFormat = input::Input1D; @@ -326,16 +318,12 @@ impl Mesh2D { } } -impl GeometryInput for Mesh2D { - type GeometryInput = Mesh2DInput; -} - impl Geometry for Mesh2D { type InputFileFormat = Input2D; /// Constructor for Mesh2D object from geometry_input. - fn new(geometry_input: &::GeometryInput) -> Mesh2D { + fn new(geometry_input: &<::InputFileFormat as GeometryInput>::GeometryInput) -> Mesh2D { let triangles = geometry_input.triangles.clone(); let material_boundary_points = geometry_input.material_boundary_points.clone(); diff --git a/src/input.rs b/src/input.rs index fe88e06..561d03c 100644 --- a/src/input.rs +++ b/src/input.rs @@ -172,7 +172,7 @@ pub struct Options { } pub fn input(input_file: String) -> (Vec, material::Material, Options, OutputUnits) -where ::InputFileFormat: Deserialize<'static> + 'static, ::GeometryInput: Clone { +where ::InputFileFormat: Deserialize<'static> + 'static { //Read input file, convert to string, and open with toml let mut input_toml = String::new(); diff --git a/src/material.rs b/src/material.rs index 0afbcda..a448e40 100644 --- a/src/material.rs +++ b/src/material.rs @@ -27,7 +27,7 @@ pub struct Material { pub surface_binding_model: SurfaceBindingModel, pub bulk_binding_model: BulkBindingModel } -impl Material { +impl Material { pub fn new(material_parameters: &MaterialParameters, geometry_input: &<::InputFileFormat as GeometryInput>::GeometryInput) -> Material { diff --git a/src/parry.rs b/src/parry.rs index 39748d7..b69617a 100644 --- a/src/parry.rs +++ b/src/parry.rs @@ -12,10 +12,6 @@ pub struct InputParryBall { pub geometry_input: ParryBallInput, } -impl GeometryInput for InputParryBall { - type GeometryInput = ParryBallInput; -} - impl InputFile for InputParryBall { fn new(string: &str) -> InputParryBall { @@ -54,7 +50,7 @@ pub struct ParryBall { pub ball: Ball, } -impl GeometryInput for ParryBall { +impl GeometryInput for InputParryBall { type GeometryInput = ParryBallInput; } @@ -62,7 +58,7 @@ impl Geometry for ParryBall { type InputFileFormat = InputParryBall; - fn new(input: &::GeometryInput) -> ParryBall { + fn new(input: &<::InputFileFormat as GeometryInput>::GeometryInput) -> ParryBall { let length_unit: f64 = match input.length_unit.as_str() { "MICRON" => MICRON, @@ -144,10 +140,6 @@ pub struct InputParryTriMesh { pub geometry_input: ParryTriMeshInput, } -impl GeometryInput for InputParryTriMesh { - type GeometryInput = ParryTriMeshInput; -} - impl InputFile for InputParryTriMesh { fn new(string: &str) -> InputParryTriMesh { @@ -187,7 +179,7 @@ pub struct ParryTriMesh { pub boundary: AABB, } -impl GeometryInput for ParryTriMesh { +impl GeometryInput for InputParryTriMesh { type GeometryInput = ParryTriMeshInput; } @@ -195,7 +187,7 @@ impl Geometry for ParryTriMesh { type InputFileFormat = InputParryTriMesh; - fn new(input: &::GeometryInput) -> ParryTriMesh { + fn new(input: &<::InputFileFormat as GeometryInput>::GeometryInput) -> ParryTriMesh { let length_unit: f64 = match input.length_unit.as_str() { "MICRON" => MICRON, diff --git a/src/sphere.rs b/src/sphere.rs index 621df69..7617788 100644 --- a/src/sphere.rs +++ b/src/sphere.rs @@ -8,10 +8,6 @@ pub struct InputSphere { pub geometry_input: sphere::SphereInput, } -impl GeometryInput for InputSphere { - type GeometryInput = sphere::SphereInput; -} - impl InputFile for InputSphere { fn new(string: &str) -> InputSphere { @@ -49,7 +45,7 @@ pub struct Sphere { pub energy_barrier_thickness: f64, } -impl GeometryInput for Sphere { +impl GeometryInput for InputSphere { type GeometryInput = SphereInput; } @@ -57,7 +53,7 @@ impl Geometry for Sphere { type InputFileFormat = InputSphere; - fn new(input: &::GeometryInput) -> Sphere { + fn new(input: &<::InputFileFormat as GeometryInput>::GeometryInput) -> Sphere { let length_unit: f64 = match input.length_unit.as_str() { "MICRON" => MICRON,