Struct libreda_pnr::db::PointString [−]
A point string is a finite sequence of points.
TODO: Implement Deref
for accessing the list of points.
Fields
points: Vec<Point<T>, Global>
The points defining this point string.
Implementations
impl<T> PointString<T> where
T: CoordinateType,
T: CoordinateType,
pub fn new<I>(i: I) -> PointString<T> where
I: Into<PointString<T>>,
I: Into<PointString<T>>,
Create new point string by taking vertices from a type that implements Into<PointString<T>>
.
pub fn len(&self) -> usize
Get the number of vertices.
pub fn iter(&self) -> Iter<'_, Point<T>>
Shortcut for self.points.iter()
.
pub fn edges(&self) -> impl Iterator<Item = Edge<T>>
Get the sequence of edges of the point string starting from the first point to the last.
Examples
use iron_shapes::point_string::PointString; use iron_shapes::edge::Edge; let coords = vec![(0, 0), (1, 0), (2, 0)]; let point_string = PointString::new(coords); let edges: Vec<_> = point_string.edges().collect(); assert_eq!(edges, vec![Edge::new((0, 0), (1, 0)), Edge::new((1, 0), (2, 0))]);
pub fn edges_reversed(&self) -> impl Iterator<Item = Edge<T>>
Same as edges
but in reverse order.
Get the sequence of edges of the point string starting from the last point to the first.
Examples
use iron_shapes::point_string::PointString; use iron_shapes::edge::Edge; let coords = vec![(0, 0), (1, 0), (2, 0)]; let point_string = PointString::new(coords); let edges: Vec<_> = point_string.edges_reversed().collect(); assert_eq!(edges, vec![Edge::new((2, 0), (1, 0)), Edge::new((1, 0), (0, 0))]);
impl<T> PointString<T> where
T: CoordinateType + NumCast,
T: CoordinateType + NumCast,
pub fn path_length<F>(&self) -> F where
F: Float,
F: Float,
Compute geometrical length of the path defined by the point string.
Examples
use iron_shapes::point_string::PointString; let coords = vec![(0, 0), (1, 0), (2, 0)]; let point_string = PointString::new(coords); assert_eq!(point_string.path_length::<f64>(), 2.0);
Trait Implementations
impl<T> Clone for PointString<T> where
T: CoordinateType + Clone,
T: CoordinateType + Clone,
pub fn clone(&self) -> PointString<T>
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T> Debug for PointString<T> where
T: CoordinateType + Debug,
T: CoordinateType + Debug,
impl<T> Eq for PointString<T> where
T: CoordinateType + Eq,
T: CoordinateType + Eq,
impl<I, T, P> From<I> for PointString<T> where
T: CoordinateType,
I: IntoIterator<Item = P>,
Point<T>: From<P>,
T: CoordinateType,
I: IntoIterator<Item = P>,
Point<T>: From<P>,
Create a point string from something that can be turned into an iterator of values convertible to Point
s.
pub fn from(iter: I) -> PointString<T>
impl<T, P> FromIterator<P> for PointString<T> where
T: CoordinateType,
P: Into<Point<T>>,
T: CoordinateType,
P: Into<Point<T>>,
Create a point string from a iterator of values convertible to Point
s.
pub fn from_iter<I>(iter: I) -> PointString<T> where
I: IntoIterator<Item = P>,
I: IntoIterator<Item = P>,
impl<T> Hash for PointString<T> where
T: CoordinateType + Hash,
T: CoordinateType + Hash,
pub fn hash<__H>(&self, state: &mut __H) where
__H: Hasher,
__H: Hasher,
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T> MapPointwise<T> for PointString<T> where
T: CoordinateType,
T: CoordinateType,
pub fn transform<F>(&self, tf: F) -> PointString<T> where
F: Fn(Point<T>) -> Point<T>,
F: Fn(Point<T>) -> Point<T>,
impl<T> PartialEq<PointString<T>> for PointString<T> where
T: CoordinateType + PartialEq<T>,
T: CoordinateType + PartialEq<T>,
pub fn eq(&self, other: &PointString<T>) -> bool
pub fn ne(&self, other: &PointString<T>) -> bool
impl<T> StructuralEq for PointString<T> where
T: CoordinateType,
T: CoordinateType,
impl<T> StructuralPartialEq for PointString<T> where
T: CoordinateType,
T: CoordinateType,
impl<T> TryBoundingBox<T> for PointString<T> where
T: CoordinateType,
T: CoordinateType,
pub fn try_bounding_box(&self) -> Option<Rect<T>>
Compute the bounding box of all the points in this string.
Returns None
if the string is empty.
Examples
use iron_shapes::point_string::PointString; use iron_shapes::traits::TryBoundingBox; use iron_shapes::rect::Rect; let coords = vec![(0, 0), (1, 0), (2, 1), (-1, -3)]; let point_string = PointString::new(coords); assert_eq!(point_string.try_bounding_box(), Some(Rect::new((2, 1), (-1, -3))));
impl<T, Dst> TryCastCoord<T, Dst> for PointString<T> where
T: CoordinateType + NumCast,
Dst: CoordinateType + NumCast,
T: CoordinateType + NumCast,
Dst: CoordinateType + NumCast,
type Output = PointString<Dst>
Output type of the cast. This is likely the same geometrical type just with other coordinate types. Read more
pub fn try_cast(
&self
) -> Option<<PointString<T> as TryCastCoord<T, Dst>>::Output>
&self
) -> Option<<PointString<T> as TryCastCoord<T, Dst>>::Output>
pub fn cast(&self) -> Self::Output
Auto Trait Implementations
impl<T> RefUnwindSafe for PointString<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for PointString<T> where
T: Send,
T: Send,
impl<T> Sync for PointString<T> where
T: Sync,
T: Sync,
impl<T> Unpin for PointString<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for PointString<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<S, T> Mirror<T> for S where
S: MapPointwise<T>,
T: CoordinateType,
S: MapPointwise<T>,
T: CoordinateType,
pub fn mirror_x(&self) -> S
Return the geometrical object mirrored at the x
axis.
pub fn mirror_y(&self) -> S
Return the geometrical object mirrored at the y
axis.
impl<S, T> RotateOrtho<T> for S where
S: MapPointwise<T>,
T: CoordinateType,
S: MapPointwise<T>,
T: CoordinateType,
pub fn rotate_ortho(&self, a: Angle) -> S
impl<S, T> Scale<T> for S where
S: MapPointwise<T>,
T: CoordinateType,
S: MapPointwise<T>,
T: CoordinateType,
pub fn scale(&self, factor: T) -> S
impl<T> TextType for T where
T: Clone + Eq + Debug + Hash,
T: Clone + Eq + Debug + Hash,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<S, T> Translate<T> for S where
S: MapPointwise<T>,
T: CoordinateType,
S: MapPointwise<T>,
T: CoordinateType,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,