[−][src]Struct triangulation::dcel::TrianglesDCEL
Doubly connected edge list (a.k.a. half-edge data structure) of triangles
Fields
vertices: Vec<usize>
Maps edge id to start point id
halfedges: Vec<OptionIndex>
Maps edge id to the opposite edge id in the adjacent triangle, if it exists
Methods
impl TrianglesDCEL
[src]
pub fn with_capacity(cap: usize) -> TrianglesDCEL
[src]
Constructs a new DCEL with specified capacity.
The DCEL will be able to hold at most cap
triangles.
pub fn num_triangles(&self) -> usize
[src]
Returns the number of triangles in the triangulation
pub fn triangles<'a, 'b: 'a>(
&'a self,
points: &'b [Point]
) -> impl Iterator<Item = Triangle> + 'a
[src]
&'a self,
points: &'b [Point]
) -> impl Iterator<Item = Triangle> + 'a
Returns the iterator over all triangles in the triangulation
pub fn add_triangle(&mut self, points: [usize; 3]) -> usize
[src]
Adds a new triangle from given point ids to the DCEL and returns its id
.
Triangles id + 1
and id + 2
will reference to the same triangle
viewed from different points.
Make sure points is ordered in counter-clockwise order.
pub fn triangle_points(&self, t: usize) -> [usize; 3]
[src]
Returns point ids of the given triangle.
Examples
let mut dcel = TrianglesDCEL::with_capacity(3); let t = dcel.add_triangle([0, 1, 2]); assert_eq!(dcel.triangle_points(t), [0, 1, 2]); assert_eq!(dcel.triangle_points(t + 1), [1, 2, 0]); assert_eq!(dcel.triangle_points(t + 2), [2, 0, 1]);
pub fn triangle(&self, t: usize, points: &[Point]) -> Triangle
[src]
Returns the actual triangle associated with the given id.
Examples
let points = &[Point::new(10.0, 10.0), Point::new(10.0, 100.0), Point::new(100.0, 10.0)]; let mut dcel = TrianglesDCEL::with_capacity(3); let t = dcel.add_triangle([0, 1, 2]); assert_eq!(dcel.triangle(t, points), Triangle(points[0], points[1], points[2]));
pub fn triangle_first_edge(&self, t: usize) -> usize
[src]
Returns id of the first triangle edge (e.g. the value returned from
add_triangle
).
Examples
let mut dcel = TrianglesDCEL::with_capacity(3); let t = dcel.add_triangle([0, 1, 2]); assert_eq!(dcel.triangle_first_edge(t), t); assert_eq!(dcel.triangle_first_edge(t + 1), t); assert_eq!(dcel.triangle_first_edge(t + 2), t);
pub fn next_edge(&self, edge: usize) -> usize
[src]
Returns the edge next to the specified one (counter-clockwise order).
Examples
let mut dcel = TrianglesDCEL::with_capacity(3); assert_eq!(dcel.next_edge(0), 1); assert_eq!(dcel.next_edge(1), 2); assert_eq!(dcel.next_edge(2), 0);
pub fn prev_edge(&self, edge: usize) -> usize
[src]
Returns the edge next previous for the specified one (counter-clockwise order).
Examples
let mut dcel = TrianglesDCEL::with_capacity(3); assert_eq!(dcel.prev_edge(0), 2); assert_eq!(dcel.prev_edge(1), 0); assert_eq!(dcel.prev_edge(2), 1);
pub fn twin(&self, edge: usize) -> Option<usize>
[src]
Returns the twin edge id, if it exists.
pub fn link(&mut self, a: usize, b: usize)
[src]
Mark two given edges as twins.
Examples
let mut dcel = TrianglesDCEL::with_capacity(6); let a = dcel.add_triangle([0, 1, 2]); let b = dcel.add_triangle([2, 1, 3]); dcel.link(a + 1, b); assert_eq!(dcel.twin(a + 1), Some(b)); assert_eq!(dcel.twin(b), Some(a + 1));
pub fn unlink(&mut self, a: usize)
[src]
Removes twin of the given edge.
pub fn link_option(&mut self, a: usize, b: Option<usize>)
[src]
If b
is Some
works like link
,
otherwise removes the twin of a
.
ⓘImportant traits for TrianglesAroundPoint<'a>pub fn triangles_around_point<'a>(
&'a self,
p: usize
) -> TrianglesAroundPoint<'a>
[src]
&'a self,
p: usize
) -> TrianglesAroundPoint<'a>
Returns the iterator of triangles around the given point.
init_revmap
must be called beforehand
to initialize the point-to-triangle map.
pub fn init_revmap(&mut self)
[src]
Initializes the point-to-triangle map.
Trait Implementations
impl Clone for TrianglesDCEL
[src]
fn clone(&self) -> TrianglesDCEL
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for TrianglesDCEL
[src]
Auto Trait Implementations
impl Send for TrianglesDCEL
impl Sync for TrianglesDCEL
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,