use crate::DType;
use numr::error::Result;
use numr::runtime::Runtime;
use numr::tensor::Tensor;
#[derive(Debug, Clone)]
pub struct Mesh<R: Runtime<DType = DType>> {
pub vertices: Tensor<R>,
pub triangles: Tensor<R>,
pub normals: Option<Tensor<R>>,
}
#[derive(Debug, Clone, Copy)]
pub enum SimplificationMethod {
QuadricError,
}
#[derive(Debug, Clone, Copy)]
pub enum SmoothingMethod {
Laplacian {
lambda: f64,
},
Taubin {
lambda: f64,
mu: f64,
},
}
pub trait MeshAlgorithms<R: Runtime<DType = DType>> {
fn triangulate_polygon(&self, vertices: &Tensor<R>) -> Result<Mesh<R>>;
fn mesh_simplify(
&self,
mesh: &Mesh<R>,
target_faces: usize,
method: SimplificationMethod,
) -> Result<Mesh<R>>;
fn mesh_smooth(
&self,
mesh: &Mesh<R>,
iterations: usize,
method: SmoothingMethod,
) -> Result<Mesh<R>>;
}