pub struct Segments<F: Float> { /* private fields */ }Expand description
An arena of line segments.
Segments are indexed by SegIdx and can be retrieved by indexing (i.e. with square brackets).
Implementations§
Source§impl<F: Float> Segments<F>
impl<F: Float> Segments<F>
Sourcepub fn indices(&self) -> impl Iterator<Item = SegIdx>
pub fn indices(&self) -> impl Iterator<Item = SegIdx>
Iterate over all indices that can be used to index into this arena.
Sourcepub fn segments(&self) -> impl Iterator<Item = &Segment<F>>
pub fn segments(&self) -> impl Iterator<Item = &Segment<F>>
Iterate over all segments in this arena.
Sourcepub fn oriented_start(&self, idx: SegIdx) -> &Point<F>
pub fn oriented_start(&self, idx: SegIdx) -> &Point<F>
Returns the starting point of the segment at idx, relative to the segment’s original orientation.
The start and end points of the segment itself are stored in sweep-line
order (i.e. start has the smaller y coordinate), regardless of the
original orientation of the segment. Use this method to retrieve the
segment’s original start point.
Sourcepub fn oriented_end(&self, idx: SegIdx) -> &Point<F>
pub fn oriented_end(&self, idx: SegIdx) -> &Point<F>
Returns the ending point of the segment at idx, relative to the segment’s original orientation.
The start and end points of the segment itself are stored in sweep-line
order (i.e. start has the smaller y coordinate), regardless of the
original orientation of the segment. Use this method to retrieve the
segment’s original end point.
Sourcepub fn contour_next(&self, idx: SegIdx) -> Option<SegIdx>
pub fn contour_next(&self, idx: SegIdx) -> Option<SegIdx>
Returns the index of the segment following idx.
If idx is part of a non-closed polyline and it is the last segment,
this returns None. If idx is part of a closed polyline, this will
always return Some, and you might need to be careful to avoid looping
infinitely.
Sourcepub fn contour_prev(&self, idx: SegIdx) -> Option<SegIdx>
pub fn contour_prev(&self, idx: SegIdx) -> Option<SegIdx>
Returns the index of the segment preceding idx.
If idx is part of a non-closed polyline and it is the first segment,
this returns None. If idx is part of a closed polyline, this will
always return Some, and you might need to be careful to avoid looping
infinitely.
Sourcepub fn positively_oriented(&self, idx: SegIdx) -> bool
pub fn positively_oriented(&self, idx: SegIdx) -> bool
Does the sweep-line orientation of idx agree with its original orientation?
Sourcepub fn add_points<P: Into<Point<F>>>(&mut self, ps: impl IntoIterator<Item = P>)
pub fn add_points<P: Into<Point<F>>>(&mut self, ps: impl IntoIterator<Item = P>)
Add a (non-closed) polyline to this arena.
Sourcepub fn add_cycle<P: Into<Point<F>>>(&mut self, ps: impl IntoIterator<Item = P>)
pub fn add_cycle<P: Into<Point<F>>>(&mut self, ps: impl IntoIterator<Item = P>)
Add a closed polyline to this arena.
Sourcepub fn from_closed_cycle<P: Into<Point<F>>>(
ps: impl IntoIterator<Item = P>,
) -> Self
pub fn from_closed_cycle<P: Into<Point<F>>>( ps: impl IntoIterator<Item = P>, ) -> Self
Construct a segment arena from a single closed polyline.
Trait Implementations§
Auto Trait Implementations§
impl<F> Freeze for Segments<F>
impl<F> RefUnwindSafe for Segments<F>where
F: RefUnwindSafe,
impl<F> Send for Segments<F>where
F: Send,
impl<F> Sync for Segments<F>where
F: Sync,
impl<F> Unpin for Segments<F>where
F: Unpin,
impl<F> UnwindSafe for Segments<F>where
F: UnwindSafe,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 more