Trait cavalier_contours::polyline::PlineSourceMut
source · pub trait PlineSourceMut: PlineSource {
Show 21 methods
// Required methods
fn set_vertex(&mut self, index: usize, vertex: PlineVertex<Self::Num>);
fn insert_vertex(&mut self, index: usize, vertex: PlineVertex<Self::Num>);
fn remove(&mut self, index: usize) -> PlineVertex<Self::Num>;
fn clear(&mut self);
fn add_vertex(&mut self, vertex: PlineVertex<Self::Num>);
fn extend_vertexes<I>(&mut self, vertexes: I)
where I: IntoIterator<Item = PlineVertex<Self::Num>>;
fn reserve(&mut self, additional: usize);
fn set_is_closed(&mut self, is_closed: bool);
// Provided methods
fn set(
&mut self,
index: usize,
x: Self::Num,
y: Self::Num,
bulge: Self::Num
) { ... }
fn set_last(&mut self, vertex: PlineVertex<Self::Num>) { ... }
fn insert(
&mut self,
index: usize,
x: Self::Num,
y: Self::Num,
bulge: Self::Num
) { ... }
fn remove_last(&mut self) -> PlineVertex<Self::Num> { ... }
fn add(&mut self, x: Self::Num, y: Self::Num, bulge: Self::Num) { ... }
fn add_from_array(&mut self, data: [Self::Num; 3]) { ... }
fn extend<P>(&mut self, other: &P)
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 { ... }
fn add_or_replace_vertex(
&mut self,
vertex: PlineVertex<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
) { ... }
fn scale_mut(&mut self, scale_factor: Self::Num) { ... }
fn translate_mut(&mut self, x: Self::Num, y: Self::Num) { ... }
fn invert_direction_mut(&mut self) { ... }
}
Expand description
Trait representing a mutable source of polyline data. This trait has all the methods and operations that can be performed on a mutable polyline.
See other core polyline traits: PlineSource and PlineCreation for more information.
Required Methods§
sourcefn 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.
sourcefn 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.
sourcefn 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.
sourcefn 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.
sourcefn extend_vertexes<I>(&mut self, vertexes: I)
fn extend_vertexes<I>(&mut self, vertexes: I)
Append all vertexes from an iterator to the end of this polyline.
sourcefn reserve(&mut self, additional: usize)
fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional
more vertexes.
sourcefn 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
).
Provided Methods§
sourcefn 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.
sourcefn set_last(&mut self, vertex: PlineVertex<Self::Num>)
fn set_last(&mut self, vertex: PlineVertex<Self::Num>)
sourcefn 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.
sourcefn remove_last(&mut self) -> PlineVertex<Self::Num>
fn remove_last(&mut self) -> PlineVertex<Self::Num>
sourcefn 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.
sourcefn 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.
sourcefn extend_remove_repeat<P>(&mut self, other: &P, pos_equal_eps: Self::Num)
fn extend_remove_repeat<P>(&mut self, other: &P, pos_equal_eps: Self::Num)
Same as PlineSourceMut::extend but removes any consecutive repeat position vertexes in the
process of copying (using pos_equal_eps
for compare).
sourcefn 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.
If the vertex position is fuzzy equal then just update the bulge of the last vertex with the bulge given.
sourcefn 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.
sourcefn 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
.
§Examples
let mut polyline = Polyline::new();
polyline.add(2.0, 2.0, 0.5);
polyline.add(4.0, 4.0, 1.0);
polyline.scale_mut(2.0);
let mut expected = Polyline::new();
expected.add(4.0, 4.0, 0.5);
expected.add(8.0, 8.0, 1.0);
assert!(polyline.fuzzy_eq(&expected));
sourcefn translate_mut(&mut self, x: Self::Num, y: Self::Num)
fn translate_mut(&mut self, x: Self::Num, y: Self::Num)
Translate the polyline (mutably) by some x_offset
and y_offset
.
§Examples
let mut polyline = Polyline::new();
polyline.add(2.0, 2.0, 0.5);
polyline.add(4.0, 4.0, 1.0);
polyline.translate_mut(-3.0, 1.0);
let mut expected = Polyline::new();
expected.add(-1.0, 3.0, 0.5);
expected.add(1.0, 5.0, 1.0);
assert!(polyline.fuzzy_eq(&expected));
sourcefn invert_direction_mut(&mut self)
fn invert_direction_mut(&mut self)
Invert/reverse the direction of the polyline in place (mutably).
This method works by simply reversing the order of the vertexes, shifting by 1 position all the vertexes, and inverting the sign of all the bulge values. E.g. after reversing the vertex the bulge at index 0 becomes negative bulge at index 1. The end result for a is_closed polyline is the direction will be changed from clockwise to counter clockwise or vice versa.