Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions iTriangle/src/advanced/triangulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<IntPoint> {
&self.points
}

/// Returns indices forming counter-clockwise triangles.
#[inline]
pub fn triangle_indices<I: IndexType>(&self) -> Vec<I> {
let mut result = Vec::with_capacity(3 * self.triangles.len());
Expand All @@ -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<I: IndexType>(self) -> IntTriangulation<I> {
IntTriangulation {
Expand Down
6 changes: 6 additions & 0 deletions iTriangle/src/float/delaunay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ impl<P: FloatPointCompatible> Delaunay<P> {
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<I: IndexType>(&self) -> Triangulation<P, I> {
Expand Down
10 changes: 9 additions & 1 deletion iTriangle/src/int/triangulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,22 @@ 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<I: IndexType>(&self) -> Vec<I> {
let mut indices = Vec::new();
self.triangles.feed_indices(self.points.len(), &mut indices);
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.
Expand Down
Loading