use crate::advanced::delaunay::IntDelaunay;
use crate::float::triangulation::{RawTriangulation, Triangulation};
use crate::int::triangulation::IndexType;
use alloc::vec::Vec;
use i_overlay::i_float::adapter::FloatPointAdapter;
use i_overlay::i_float::float::compatible::FloatPointCompatible;
use i_overlay::i_float::float::number::FloatNumber;
use i_overlay::i_shape::float::adapter::PathToFloat;
pub struct Delaunay<P: FloatPointCompatible<T>, T: FloatNumber> {
pub(super) delaunay: IntDelaunay,
pub(super) adapter: FloatPointAdapter<P, T>,
}
impl<P: FloatPointCompatible<T>, T: FloatNumber> RawTriangulation<P, T> {
#[inline]
pub fn into_delaunay(self) -> Delaunay<P, T> {
Delaunay {
delaunay: self.raw.into_delaunay(),
adapter: self.adapter,
}
}
}
impl<P: FloatPointCompatible<T>, T: FloatNumber> Delaunay<P, T> {
#[inline]
pub fn points(&self) -> Vec<P> {
self.delaunay.points.to_float(&self.adapter)
}
#[inline]
pub fn triangle_indices<I: IndexType>(&self) -> Vec<I> {
self.delaunay.triangle_indices()
}
#[inline]
pub fn to_triangulation<I: IndexType>(&self) -> Triangulation<P, I> {
Triangulation {
indices: self.triangle_indices(),
points: self.points(),
}
}
}