pub struct Polyline<T = f64> {
    pub vertex_data: Vec<PlineVertex<T>>,
    pub is_closed: bool,
}
Expand description

Basic polyline data representation that implements the core polyline traits: PlineSource, PlineSourceMut, and PlineCreation. See the traits documentation for all the polyline methods/operations available.

Fields§

§vertex_data: Vec<PlineVertex<T>>

Contiguous sequence of vertexes.

§is_closed: bool

Bool to indicate whether the polyline is closed or open.

Implementations§

source§

impl<T> Polyline<T>
where T: Real,

source

pub fn new() -> Self

Create a new empty Polyline with is_closed set to false.

source

pub fn new_closed() -> Self

Create a new empty Polyline with is_closed set to true.

Trait Implementations§

source§

impl<T: Clone> Clone for Polyline<T>

source§

fn clone(&self) -> Polyline<T>

Returns a copy 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<T: Debug> Debug for Polyline<T>

source§

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

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

impl<T> Default for Polyline<T>
where T: Real,

source§

fn default() -> Self

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

impl<T> Index<usize> for Polyline<T>

§

type Output = PlineVertex<T>

The returned type after indexing.
source§

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

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

impl<T> IndexMut<usize> for Polyline<T>

source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

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

impl<T> PlineCreation for Polyline<T>
where T: Real,

source§

fn with_capacity(capacity: usize, is_closed: bool) -> Self

Create a new empty polyline with capacity given and is_closed indicating whether it is a closed or open polyline.
source§

fn from_iter<I>(iter: I, is_closed: bool) -> Self
where I: Iterator<Item = PlineVertex<Self::Num>>,

Create a new polyline by constructing from vertexes given by an iterator, is_closed sets whether the created polyline is closed or open.
source§

fn create_from<P>(pline: &P) -> Self
where P: PlineSource<Num = Self::Num> + ?Sized,

Create a new polyline by cloning from an existing polyline.
source§

fn create_from_remove_repeat<P>(pline: &P, pos_equal_eps: Self::Num) -> Self
where P: PlineSource<Num = Self::Num> + ?Sized,

Same as PlineCreation::create_from but removes any repeat position vertexes in the process using pos_equal_eps for positional comparisons.
source§

fn empty() -> Self

Create empty polyline with is_closed set to false.
source§

impl<T> PlineSource for Polyline<T>
where T: Real,

§

type Num = T

Numeric type used for the polyline.
§

type OutputPolyline = Polyline<T>

Type used for output when invoking methods that return a new polyline.
source§

fn vertex_count(&self) -> usize

Total number of vertexes.
source§

fn is_closed(&self) -> bool

Whether the polyline is closed (true) or open (false).
source§

fn get(&self, index: usize) -> Option<PlineVertex<Self::Num>>

Get the vertex at given index position. Returns None if index out of bounds.
source§

fn at(&self, index: usize) -> PlineVertex<Self::Num>

Same as PlineSource::get but panics if index is out of bounds. Read more
source§

fn iter_segments(&self) -> SegmentIter<'_, Self>

Return iterator to iterate over all the polyline segments.
source§

fn iter_vertexes(&self) -> VertexIter<'_, Self>

Return iterator to iterate over all the polyline vertexes.
source§

fn is_empty(&self) -> bool

Returns true if vertex count is 0.
source§

fn fuzzy_eq_eps<P>(&self, other: &P, eps: Self::Num) -> bool
where P: PlineSource<Num = Self::Num> + ?Sized,

Fuzzy compare with another polyline using eps epsilon value for fuzzy comparison of vertexes.
source§

fn fuzzy_eq<P>(&self, other: &P) -> bool
where P: PlineSource<Num = Self::Num> + ?Sized,

Same as PlineSource::fuzzy_eq_eps but uses default Self::Num::fuzzy_epsilon().
source§

fn last(&self) -> Option<PlineVertex<Self::Num>>

Get the last vertex of the polyline or None if polyline is empty.
source§

fn segment_count(&self) -> usize

Total number of segments in the polyline.
source§

fn iter_segment_indexes(&self) -> PlineSegIndexIterator

Iterate through all the polyline segment vertex positional indexes. Read more
source§

fn next_wrapping_index(&self, i: usize) -> usize

Returns the next wrapping vertex index for the polyline. Read more
source§

fn prev_wrapping_index(&self, i: usize) -> usize

Returns the previous wrapping vertex index for the polyline. Read more
source§

fn fwd_wrapping_dist(&self, start_index: usize, end_index: usize) -> usize

Returns the forward wrapping distance between two vertex indexes. Read more
source§

fn fwd_wrapping_index(&self, start_index: usize, offset: usize) -> usize

Returns the vertex index after applying offset to start_index in a wrapping manner. Read more
source§

fn extents(&self) -> Option<AABB<Self::Num>>

Compute the XY extents of the polyline. Read more
source§

fn path_length(&self) -> Self::Num

Returns the total path length of the polyline. Read more
source§

fn area(&self) -> Self::Num

Compute the closed signed area of the polyline. Read more
source§

fn orientation(&self) -> PlineOrientation

Returns the orientation of the polyline. Read more
source§

fn remove_repeat_pos( &self, pos_equal_eps: Self::Num ) -> Option<Self::OutputPolyline>

Remove all repeat position vertexes from the polyline. Read more
source§

fn remove_redundant( &self, pos_equal_eps: Self::Num ) -> Option<Self::OutputPolyline>

Remove all redundant vertexes from the polyline. Read more
source§

fn rotate_start( &self, start_index: usize, point: Vector2<Self::Num>, pos_equal_eps: Self::Num ) -> Option<Self::OutputPolyline>

Rotates the vertexes in a closed polyline such that the first vertex’s position is at point. start_index indicates which segment point lies on before rotation. This does not change the shape of the polyline curve. pos_equal_eps is epsilon value used for comparing the positions of points. None is returned if the polyline is not closed, the polyline length is less than 2, or the start_index is out of bounds. Read more
source§

fn create_approx_aabb_index(&self) -> StaticAABB2DIndex<Self::Num>

Creates a fast approximate spatial index of all the polyline segments. Read more
source§

fn create_aabb_index(&self) -> StaticAABB2DIndex<Self::Num>

Creates a spatial index of all the polyline segments. Read more
source§

fn closest_point( &self, point: Vector2<Self::Num>, pos_equal_eps: Self::Num ) -> Option<ClosestPointResult<Self::Num>>

Find the closest segment point on a polyline to a point given. Read more
source§

fn winding_number(&self, point: Vector2<Self::Num>) -> i32

Calculate the winding number for a point relative to the polyline. Read more
source§

fn arcs_to_approx_lines( &self, error_distance: Self::Num ) -> Option<Self::OutputPolyline>

Returns a new polyline with all arc segments converted to line segments with some error_distance or None if Self::Num fails to cast to or from usize. Read more
source§

fn visit_self_intersects<C, V>(&self, visitor: &mut V) -> C
where C: ControlFlow, V: PlineIntersectVisitor<Self::Num, C>,

Visit self intersects of the polyline using default options. Read more
source§

fn visit_self_intersects_opt<C, V>( &self, visitor: &mut V, options: &PlineSelfIntersectOptions<'_, Self::Num> ) -> C
where C: ControlFlow, V: PlineIntersectVisitor<Self::Num, C>,

Visit self intersects of the polyline using options provided. Read more
source§

fn find_intersects<P>(&self, other: &P) -> PlineIntersectsCollection<Self::Num>
where P: PlineSource<Num = Self::Num> + ?Sized,

Find all intersects between two polylines using default options. Read more
source§

fn find_intersects_opt<P>( &self, other: &P, options: &FindIntersectsOptions<'_, Self::Num> ) -> PlineIntersectsCollection<Self::Num>
where P: PlineSource<Num = Self::Num> + ?Sized,

Find all intersects between two polylines using the options provided. Read more
source§

fn parallel_offset(&self, offset: Self::Num) -> Vec<Self::OutputPolyline>

Compute the parallel offset polylines of the polyline using default options. Read more
source§

fn parallel_offset_opt( &self, offset: Self::Num, options: &PlineOffsetOptions<'_, Self::Num> ) -> Vec<Self::OutputPolyline>

Compute the parallel offset polylines of the polyline with options given. Read more
source§

fn boolean<P>( &self, other: &P, operation: BooleanOp ) -> BooleanResult<Self::OutputPolyline>
where P: PlineSource<Num = Self::Num> + ?Sized,

Perform a boolean operation between this polyline and another using default options. Read more
source§

fn boolean_opt<P>( &self, other: &P, operation: BooleanOp, options: &PlineBooleanOptions<'_, Self::Num> ) -> BooleanResult<Self::OutputPolyline>
where P: PlineSource<Num = Self::Num> + ?Sized,

Perform a boolean operation between this polyline and another with options provided. Read more
source§

fn find_point_at_path_length( &self, target_path_length: Self::Num ) -> Result<(usize, Vector2<Self::Num>), Self::Num>

Find the segment index and point on the polyline corresponding to the path length given. Read more
source§

impl<T> PlineSourceMut for Polyline<T>
where T: Real,

source§

fn set_vertex(&mut self, index: usize, vertex: PlineVertex<Self::Num>)

Set the vertex data at the given index position of the polyline.
source§

fn insert_vertex(&mut self, index: usize, vertex: PlineVertex<Self::Num>)

Insert a new vertex into the polyline at the given index position.
source§

fn remove(&mut self, index: usize) -> PlineVertex<Self::Num>

Remove vertex at the given index position and return it.
source§

fn add_vertex(&mut self, vertex: PlineVertex<Self::Num>)

Add a vertex to the end of the polyline.
source§

fn reserve(&mut self, additional: usize)

Reserves capacity for at least additional more vertexes.
source§

fn set_is_closed(&mut self, is_closed: bool)

Set whether the polyline is closed (is_closed = true) or open (is_closed = false).
source§

fn clear(&mut self)

Clear all vertexes of the polyline.
source§

fn extend_vertexes<I>(&mut self, vertexes: I)
where I: IntoIterator<Item = PlineVertex<Self::Num>>,

Append all vertexes from an iterator to the end of this polyline.
source§

fn set(&mut self, index: usize, x: Self::Num, y: Self::Num, bulge: Self::Num)

Same as PlineSourceMut::set_vertex but accepts each component of the vertex rather than a vertex structure.
source§

fn set_last(&mut self, vertex: PlineVertex<Self::Num>)

Set the last vertex of the polyline. Read more
source§

fn insert(&mut self, index: usize, x: Self::Num, y: Self::Num, bulge: Self::Num)

Same as PlineSourceMut::insert_vertex but accepts each component of the vertex rather than a vertex structure.
source§

fn remove_last(&mut self) -> PlineVertex<Self::Num>

Remove the last vertex from the polyline and return it. Read more
source§

fn add(&mut self, x: Self::Num, y: Self::Num, bulge: Self::Num)

Same as PlineSourceMut::add_vertex but accepts each component of the vertex rather than a vertex structure.
source§

fn add_from_array(&mut self, data: [Self::Num; 3])

Same as PlineSourceMut::add_vertex but accepts each component as elements in an array, 0 = x, 1 = y, 2 = bulge.
source§

fn extend<P>(&mut self, other: &P)
where P: PlineSource<Num = Self::Num> + ?Sized,

Copy all vertexes from other to the end of this polyline.
source§

fn extend_remove_repeat<P>(&mut self, other: &P, pos_equal_eps: Self::Num)
where P: PlineSource<Num = Self::Num> + ?Sized,

Same as PlineSourceMut::extend but removes any consecutive repeat position vertexes in the process of copying (using pos_equal_eps for compare).
source§

fn add_or_replace_vertex( &mut self, vertex: PlineVertex<Self::Num>, pos_equal_eps: Self::Num )

Add a vertex if it’s position is not fuzzy equal to the last vertex in the polyline. Read more
source§

fn add_or_replace( &mut self, x: Self::Num, y: Self::Num, bulge: Self::Num, pos_equal_eps: Self::Num )

Same as PlineSourceMut::add_or_replace_vertex but accepts each component of the vertex rather than a vertex structure.
source§

fn scale_mut(&mut self, scale_factor: Self::Num)

Uniformly scale the polyline (mutably) in the xy plane by scale_factor. Read more
source§

fn translate_mut(&mut self, x: Self::Num, y: Self::Num)

Translate the polyline (mutably) by some x_offset and y_offset. Read more
source§

fn invert_direction_mut(&mut self)

Invert/reverse the direction of the polyline in place (mutably). Read more

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for Polyline<T>
where T: RefUnwindSafe,

§

impl<T> Send for Polyline<T>
where T: Send,

§

impl<T> Sync for Polyline<T>
where T: Sync,

§

impl<T> Unpin for Polyline<T>
where T: Unpin,

§

impl<T> UnwindSafe for Polyline<T>
where T: UnwindSafe,

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> 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,

§

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>,

§

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>,

§

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.