Struct cavalier_contours::polyline::Polyline
source · 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§
Trait Implementations§
source§impl<T> PlineCreation for Polyline<T>where
T: Real,
impl<T> PlineCreation for Polyline<T>where T: Real,
source§fn with_capacity(capacity: usize, is_closed: bool) -> Self
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) -> Selfwhere
I: Iterator<Item = PlineVertex<Self::Num>>,
fn from_iter<I>(iter: I, is_closed: bool) -> Selfwhere 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) -> Selfwhere
P: PlineSource<Num = Self::Num> + ?Sized,
fn create_from<P>(pline: &P) -> Selfwhere 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) -> Selfwhere
P: PlineSource<Num = Self::Num> + ?Sized,
fn create_from_remove_repeat<P>(pline: &P, pos_equal_eps: Self::Num) -> Selfwhere 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§impl<T> PlineSource for Polyline<T>where
T: Real,
impl<T> PlineSource for Polyline<T>where T: Real,
§type OutputPolyline = Polyline<T>
type OutputPolyline = Polyline<T>
Type used for output when invoking methods that return a new polyline.
source§fn vertex_count(&self) -> usize
fn vertex_count(&self) -> usize
Total number of vertexes.
source§fn get(&self, index: usize) -> Option<PlineVertex<Self::Num>>
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 iter_segments(&self) -> SegmentIter<'_, Self> ⓘ
fn iter_segments(&self) -> SegmentIter<'_, Self> ⓘ
Return iterator to iterate over all the polyline segments.
source§fn iter_vertexes(&self) -> VertexIter<'_, Self> ⓘ
fn iter_vertexes(&self) -> VertexIter<'_, Self> ⓘ
Return iterator to iterate over all the polyline vertexes.
source§fn fuzzy_eq_eps<P>(&self, other: &P, eps: Self::Num) -> boolwhere
P: PlineSource<Num = Self::Num> + ?Sized,
fn fuzzy_eq_eps<P>(&self, other: &P, eps: Self::Num) -> boolwhere 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) -> boolwhere
P: PlineSource<Num = Self::Num> + ?Sized,
fn fuzzy_eq<P>(&self, other: &P) -> boolwhere 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>>
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
fn segment_count(&self) -> usize
Total number of segments in the polyline.
source§fn iter_segment_indexes(&self) -> PlineSegIndexIterator ⓘ
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
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
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
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 extents(&self) -> Option<AABB<Self::Num>>
fn extents(&self) -> Option<AABB<Self::Num>>
Compute the XY extents of the polyline. Read more
source§fn path_length(&self) -> Self::Num
fn path_length(&self) -> Self::Num
Returns the total path length of the polyline. Read more
source§fn orientation(&self) -> PlineOrientation
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>
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>
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>
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 moresource§fn create_approx_aabb_index(&self) -> Option<StaticAABB2DIndex<Self::Num>>
fn create_approx_aabb_index(&self) -> Option<StaticAABB2DIndex<Self::Num>>
Creates a fast approximate spatial index of all the polyline segments. Read more
source§fn create_aabb_index(&self) -> Option<StaticAABB2DIndex<Self::Num>>
fn create_aabb_index(&self) -> Option<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>>
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 moresource§fn winding_number(&self, point: Vector2<Self::Num>) -> i32
fn winding_number(&self, point: Vector2<Self::Num>) -> i32
Calculate the winding number for a
point
relative to the polyline. Read moresource§fn arcs_to_approx_lines(
&self,
error_distance: Self::Num
) -> Option<Self::OutputPolyline>
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 T fails to cast to or from usize. Read moresource§fn visit_self_intersects<C, V>(&self, visitor: &mut V) -> Cwhere
C: ControlFlow,
V: PlineIntersectVisitor<Self::Num, C>,
fn visit_self_intersects<C, V>(&self, visitor: &mut V) -> Cwhere C: ControlFlow, V: PlineIntersectVisitor<Self::Num, C>,
Visit self intersects of the polyline using default options.
source§fn visit_self_intersects_opt<C, V>(
&self,
visitor: &mut V,
options: &PlineSelfIntersectOptions<'_, Self::Num>
) -> Cwhere
C: ControlFlow,
V: PlineIntersectVisitor<Self::Num, C>,
fn visit_self_intersects_opt<C, V>( &self, visitor: &mut V, options: &PlineSelfIntersectOptions<'_, Self::Num> ) -> Cwhere C: ControlFlow, V: PlineIntersectVisitor<Self::Num, C>,
Visit self intersects of the polyline using options provided.
source§fn find_intersects<P>(&self, other: &P) -> PlineIntersectsCollection<Self::Num>where
P: PlineSource<Num = Self::Num> + ?Sized,
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.
source§fn find_intersects_opt<P>(
&self,
other: &P,
options: &FindIntersectsOptions<'_, Self::Num>
) -> PlineIntersectsCollection<Self::Num>where
P: PlineSource<Num = Self::Num> + ?Sized,
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.
source§fn parallel_offset(&self, offset: Self::Num) -> Vec<Self::OutputPolyline>
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>
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,
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 moresource§fn boolean_opt<P>(
&self,
other: &P,
operation: BooleanOp,
options: &PlineBooleanOptions<'_, Self::Num>
) -> BooleanResult<Self::OutputPolyline>where
P: PlineSource<Num = Self::Num> + ?Sized,
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 moresource§impl<T> PlineSourceMut for Polyline<T>where
T: Real,
impl<T> PlineSourceMut for Polyline<T>where T: Real,
source§fn set_vertex(&mut self, index: usize, vertex: PlineVertex<Self::Num>)
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>)
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>
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>)
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)
fn reserve(&mut self, additional: usize)
Reserves capacity for at least
additional
more vertexes.source§fn set_is_closed(&mut self, is_closed: bool)
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 extend_vertexes<I>(&mut self, vertexes: I)where
I: IntoIterator<Item = PlineVertex<Self::Num>>,
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)
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>)
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)
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>
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)
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])
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,
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,
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
)
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
)
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)
fn scale_mut(&mut self, scale_factor: Self::Num)
Uniformly scale the polyline (mutably) in the xy plane by
scale_factor
. Read moresource§fn translate_mut(&mut self, x: Self::Num, y: Self::Num)
fn translate_mut(&mut self, x: Self::Num, y: Self::Num)
source§fn invert_direction_mut(&mut self)
fn invert_direction_mut(&mut self)
Invert/reverse the direction of the polyline in place (mutably). Read more