mod box_geometry;
mod cylinder_geometry;
mod geometry_shape_data;
mod mesh_geometry;
use nalgebra::Matrix3;
mod sphere_geometry;
pub use box_geometry::BoxGeometry;
pub use cylinder_geometry::CylinderGeometry;
pub use mesh_geometry::MeshGeometry;
pub use sphere_geometry::SphereGeometry;
pub use geometry_shape_data::GeometryShapeData;
pub use geometry_shape_data::GeometryShapeContainer;
use std::fmt::Debug;
use crate::transform::Mirror;
pub trait BoxedMirror {
fn boxed_mirrored(
&self,
mirror_matrix: &Matrix3<f32>,
) -> Box<dyn GeometryInterface + Sync + Send>;
}
impl<Geometry> BoxedMirror for Geometry
where
Geometry: GeometryInterface + Mirror + Sync + Send,
{
fn boxed_mirrored(
&self,
mirror_matrix: &Matrix3<f32>,
) -> Box<dyn GeometryInterface + Sync + Send> {
self.mirrored(mirror_matrix).boxed_clone()
}
}
pub trait GeometryInterface: Debug + BoxedMirror {
fn volume(&self) -> f32;
fn surface_area(&self) -> f32;
fn boxed_clone(&self) -> Box<dyn GeometryInterface + Sync + Send>;
fn bounding_box(&self) -> (f32, f32, f32);
fn shape_container(&self) -> GeometryShapeContainer;
}
impl Mirror for Box<dyn GeometryInterface + Sync + Send> {
fn mirrored(&self, mirror_matrix: &Matrix3<f32>) -> Self {
self.boxed_mirrored(mirror_matrix)
}
}
impl PartialEq for (dyn GeometryInterface + Sync + Send) {
fn eq(&self, other: &Self) -> bool {
self.volume() == other.volume()
&& self.surface_area() == other.surface_area()
&& self.bounding_box() == other.bounding_box()
}
}
impl From<&(dyn GeometryInterface + Sync + Send)> for Box<dyn GeometryInterface + Sync + Send> {
fn from(value: &(dyn GeometryInterface + Sync + Send)) -> Self {
value.boxed_clone()
}
}