diff --git a/iTriangle/src/advanced/triangulation.rs b/iTriangle/src/advanced/triangulation.rs index 2bfd0a3..be665a6 100644 --- a/iTriangle/src/advanced/triangulation.rs +++ b/iTriangle/src/advanced/triangulation.rs @@ -4,11 +4,13 @@ use alloc::vec::Vec; use i_overlay::i_float::int::point::IntPoint; impl IntDelaunay { + /// Returns the vertex positions in the triangulation. #[inline] pub fn points(&self) -> &Vec { &self.points } + /// Returns indices forming counter-clockwise triangles. #[inline] pub fn triangle_indices(&self) -> Vec { let mut result = Vec::with_capacity(3 * self.triangles.len()); @@ -23,6 +25,15 @@ impl IntDelaunay { result } + /// Returns the indices of each triangle's neighboring triangles. + #[inline] + pub fn triangle_neighbors(&self) -> Vec<[usize; 3]> { + self.triangles + .iter() + .map(|triangle| triangle.neighbors) + .collect() + } + #[inline] pub fn into_triangulation(self) -> IntTriangulation { IntTriangulation { diff --git a/iTriangle/src/float/delaunay.rs b/iTriangle/src/float/delaunay.rs index 09d1c32..d1c7478 100644 --- a/iTriangle/src/float/delaunay.rs +++ b/iTriangle/src/float/delaunay.rs @@ -45,6 +45,12 @@ impl Delaunay

{ self.delaunay.triangle_indices() } + /// Returns the indices of each triangle's neighboring triangles. + #[inline] + pub fn triangle_neighbors(&self) -> Vec<[usize; 3]> { + self.delaunay.triangle_neighbors() + } + /// Converts this refined mesh into a flat float [`Triangulation`]. #[inline] pub fn to_triangulation(&self) -> Triangulation { diff --git a/iTriangle/src/int/triangulation.rs b/iTriangle/src/int/triangulation.rs index 0a0a051..68c7022 100644 --- a/iTriangle/src/int/triangulation.rs +++ b/iTriangle/src/int/triangulation.rs @@ -154,7 +154,6 @@ impl RawIntTriangulation { /// Returns a flat list of triangle vertex indices (ABC ordering). /// /// Each triangle contributes 3 indices into the `points` buffer. - /// #[inline] pub fn triangle_indices(&self) -> Vec { let mut indices = Vec::new(); @@ -162,6 +161,15 @@ impl RawIntTriangulation { indices } + /// Returns the indices of each triangle's neighboring triangles. + #[inline] + pub fn triangle_neighbors(&self) -> Vec<[usize; 3]> { + self.triangles + .iter() + .map(|triangle| triangle.neighbors) + .collect() + } + /// Converts the int triangulation into a simpler index-based mesh. /// /// Returns a [`IntTriangulation`] with separate index buffer and point list.