pub struct Triangulation<'a, V: IndexType> { /* private fields */ }Expand description
A triangulation of a polygon. Will borrow the index buffer and append new triangles to it. Most methods will only look at the indices that are added after the borrow startet. It’s fine to add triangles to the index buffer directly while it is borrowed.
Implementations§
Source§impl<'a, V: IndexType> Triangulation<'a, V>
impl<'a, V: IndexType> Triangulation<'a, V>
Sourcepub fn insert_triangle(&mut self, a: V, b: V, c: V)
pub fn insert_triangle(&mut self, a: V, b: V, c: V)
Insert a triangle into the triangulation using global indices
Sourcepub fn get_triangle(&self, i: usize) -> (V, V, V)
pub fn get_triangle(&self, i: usize) -> (V, V, V)
Get a triangle from the triangulation using the number of the triangle in the triangulation
Sourcepub fn get_triangle_area<Vec2: Vector2D>(
&self,
i: usize,
vec_hm: &HashMap<V, Vec2>,
) -> Vec2::S
pub fn get_triangle_area<Vec2: Vector2D>( &self, i: usize, vec_hm: &HashMap<V, Vec2>, ) -> Vec2::S
Get the area of a triangle in the triangulation
Sourcepub fn insert_triangle_local<Vec2: Vector2D>(
&mut self,
a: usize,
b: usize,
c: usize,
vec2s: &Vec<IndexedVertex2D<V, Vec2>>,
)
pub fn insert_triangle_local<Vec2: Vector2D>( &mut self, a: usize, b: usize, c: usize, vec2s: &Vec<IndexedVertex2D<V, Vec2>>, )
Insert a triangle into the triangulation using local indices
Sourcepub fn map_indices(&mut self, id_map: &HashMap<V, V>)
pub fn map_indices(&mut self, id_map: &HashMap<V, V>)
Map the indices in the triangulation using a hashmap
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Get the number of triangles inserted into the index buffer since the triangulation was created
Sourcepub fn flip_edge(
&mut self,
a: V,
b: V,
triangle_ab: usize,
triangle_ba: usize,
) -> Result<(), ()>
pub fn flip_edge( &mut self, a: V, b: V, triangle_ab: usize, triangle_ba: usize, ) -> Result<(), ()>
Flip the edge of the two triangles
Sourcepub fn verify_non_degenerate_triangle<Vec2: Vector2D>(
&self,
vec_hm: &HashMap<V, Vec2>,
)
pub fn verify_non_degenerate_triangle<Vec2: Vector2D>( &self, vec_hm: &HashMap<V, Vec2>, )
Check for non-degenerate triangles (no zero-area triangles)
Sourcepub fn verify_indices<Vec2: Vector2D>(&self, vec_hm: &HashMap<V, Vec2>)
pub fn verify_indices<Vec2: Vector2D>(&self, vec_hm: &HashMap<V, Vec2>)
Check for valid indices (i.e., they should be within the bounds of the vertices)
Sourcepub fn verify_no_intersections<Vec2: Vector2D>(&self, vec_hm: &HashMap<V, Vec2>)
pub fn verify_no_intersections<Vec2: Vector2D>(&self, vec_hm: &HashMap<V, Vec2>)
Check that no two triangles have intersecting edges
Sourcepub fn get_area<Vec2: Vector2D>(&self, vec_hm: &HashMap<V, Vec2>) -> Vec2::S
pub fn get_area<Vec2: Vector2D>(&self, vec_hm: &HashMap<V, Vec2>) -> Vec2::S
Sum the area of all triangles added to the index buffer since the triangulation was created
Sourcepub fn total_edge_weight<Vec2: Vector2D>(
&self,
vec_hm: &HashMap<V, Vec2>,
) -> Vec2::S
pub fn total_edge_weight<Vec2: Vector2D>( &self, vec_hm: &HashMap<V, Vec2>, ) -> Vec2::S
Calculate the total edge weight of the triangulation
Sourcepub fn verify_area<Vec2: Vector2D, Poly: Polygon<Vec2>>(
&self,
vec2s: &Vec<IndexedVertex2D<V, Vec2>>,
vec_hm: &HashMap<V, Vec2>,
)
pub fn verify_area<Vec2: Vector2D, Poly: Polygon<Vec2>>( &self, vec2s: &Vec<IndexedVertex2D<V, Vec2>>, vec_hm: &HashMap<V, Vec2>, )
Calculate the area of the polygon and check if it is the same as the sum of the areas of the triangles
Sourcepub fn verify_all_indices_used<Vec2: Vector2D>(
&self,
vec2s: &Vec<IndexedVertex2D<V, Vec2>>,
)
pub fn verify_all_indices_used<Vec2: Vector2D>( &self, vec2s: &Vec<IndexedVertex2D<V, Vec2>>, )
Check that the set of used indices exactly matches the set of indices in the triangulation
Sourcepub fn verify_full<Vec2: Vector2D, Poly: Polygon<Vec2>>(
&self,
vec2s: &Vec<IndexedVertex2D<V, Vec2>>,
)
pub fn verify_full<Vec2: Vector2D, Poly: Polygon<Vec2>>( &self, vec2s: &Vec<IndexedVertex2D<V, Vec2>>, )
Runs a large number of tests on the triangulation to verify that it is well-formed
Trait Implementations§
Auto Trait Implementations§
impl<'a, V> Freeze for Triangulation<'a, V>
impl<'a, V> RefUnwindSafe for Triangulation<'a, V>where
V: RefUnwindSafe,
impl<'a, V> Send for Triangulation<'a, V>where
V: Send,
impl<'a, V> Sync for Triangulation<'a, V>where
V: Sync,
impl<'a, V> Unpin for Triangulation<'a, V>
impl<'a, V> !UnwindSafe for Triangulation<'a, V>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.