Skip to content

Commit 3e9e5ed

Browse files
committed
Make it possible to get neighbors list from float Delaunay triangulation
1 parent ee8cc14 commit 3e9e5ed

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

iTriangle/src/advanced/triangulation.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ use alloc::vec::Vec;
44
use i_overlay::i_float::int::point::IntPoint;
55

66
impl IntDelaunay {
7+
/// Returns the vertex positions in the triangulation.
78
#[inline]
89
pub fn points(&self) -> &Vec<IntPoint> {
910
&self.points
1011
}
1112

13+
/// Returns indices forming counter-clockwise triangles.
1214
#[inline]
1315
pub fn triangle_indices<I: IndexType>(&self) -> Vec<I> {
1416
let mut result = Vec::with_capacity(3 * self.triangles.len());
@@ -23,6 +25,15 @@ impl IntDelaunay {
2325
result
2426
}
2527

28+
/// Returns the indices of each triangle's neighboring triangles.
29+
#[inline]
30+
pub fn triangle_neighbors(&self) -> Vec<[usize; 3]> {
31+
self.triangles
32+
.iter()
33+
.map(|triangle| triangle.neighbors)
34+
.collect()
35+
}
36+
2637
#[inline]
2738
pub fn into_triangulation<I: IndexType>(self) -> IntTriangulation<I> {
2839
IntTriangulation {

iTriangle/src/float/delaunay.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ impl<P: FloatPointCompatible> Delaunay<P> {
4545
self.delaunay.triangle_indices()
4646
}
4747

48+
/// Returns the indices of each triangle's neighboring triangles.
49+
pub fn triangle_neighbors(&self) -> Vec<[usize; 3]> {
50+
self.delaunay.triangle_neighbors()
51+
}
52+
4853
/// Converts this refined mesh into a flat float [`Triangulation`].
4954
#[inline]
5055
pub fn to_triangulation<I: IndexType>(&self) -> Triangulation<P, I> {

0 commit comments

Comments
 (0)