Segments

Struct Segments 

Source
pub struct Segments { /* private fields */ }
Expand description

An arena of segments, each of which is a cubic Bézier.

Segments are indexed by SegIdx and can be retrieved by indexing (i.e. with square brackets).

Implementations§

Source§

impl Segments

Source

pub fn len(&self) -> usize

The number of segments in this arena.

Source

pub fn indices(&self) -> impl Iterator<Item = SegIdx>

Iterate over all indices that can be used to index into this arena.

Source

pub fn segments(&self) -> impl Iterator<Item = &Segment>

Iterate over all segments in this arena.

Source

pub fn oriented_start(&self, idx: SegIdx) -> Point

Returns the starting point of the segment at idx, relative to the segment’s original orientation.

The segment itself is stored in sweep-line order (i.e. its starting point has the smaller y coordinate) regardless of the original orientation of the segment. Use this method to retrieve the segment’s original start point.

Source

pub fn oriented_end(&self, idx: SegIdx) -> Point

Returns the ending point of the segment at idx, relative to the segment’s original orientation.

The segment itself is stored in sweep-line order (i.e. its starting point has the smaller y coordinate) regardless of the original orientation of the segment. Use this method to retrieve the segment’s original end point.

Source

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 path and it is the last segment, this returns None. If idx is part of a closed path, this will always return Some, and you might need to be careful to avoid looping infinitely.

Source

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 path and it is the first segment, this returns None. If idx is part of a closed path, this will always return Some, and you might need to be careful to avoid looping infinitely.

Source

pub fn positively_oriented(&self, idx: SegIdx) -> bool

Does the sweep-line orientation of idx agree with its original orientation?

Source

pub fn add_points<P: Into<Point>>(&mut self, ps: impl IntoIterator<Item = P>)

Add a (non-closed) polyline to this arena.

Source

pub fn add_closed_polylines<P: Into<Point>>( &mut self, ps: impl IntoIterator<Item = impl IntoIterator<Item = P>>, )

Add a collection of closed polylines to this arena.

This can be much faster than calling add_cycles repeatedly.

Source

pub fn add_closed_polyline<P: Into<Point>>( &mut self, ps: impl IntoIterator<Item = P>, )

Add a closed polyline to this arena.

Source

pub fn add_bez_path(&mut self, p: &BezPath) -> Result<(), NonClosedPath>

Add a Bézier path to this arena.

The path can contain multiple subpaths, and each of them must be closed.

Source

pub fn add_non_closed_bez_path( &mut self, p: &BezPath, ) -> Result<(), NonClosedPath>

Add a Bézier path to this arena.

The path can contain multiple subpaths, and each of them may or may not be closed.

Source

pub fn from_closed_polyline<P: Into<Point>>( ps: impl IntoIterator<Item = P>, ) -> Self

Construct a segment arena from a single closed polyline.

Source

pub fn entrances(&self) -> &[(f64, SegIdx)]

All the entrance heights of segments, ordered by height.

Includes horizontal segments.

Source

pub fn exits(&self) -> &[(f64, SegIdx)]

All the exit heights of segments, ordered by height.

Does not include horizontal segments.

Source

pub fn check_invariants(&self)

Checks that we satisfy our internal invariants. For testing only.

Trait Implementations§

Source§

impl Clone for Segments

Source§

fn clone(&self) -> Segments

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Segments

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Segments

Source§

fn default() -> Segments

Returns the “default value” for a type. Read more
Source§

impl Index<SegIdx> for Segments

Source§

type Output = Segment

The returned type after indexing.
Source§

fn index(&self, index: SegIdx) -> &Self::Output

Performs the indexing (container[index]) operation. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.