[−][src]Struct truck_topology::Edge
Edge, which consists two vertices.
The constructors Edge::new()
, Edge::try_new()
, and Edge::new_unchecked()
create a different edge each time, even if the end vertices are the same one.
An edge is uniquely identified by their id
.
let v = Vertex::news(&[(), ()]); let edge0 = Edge::new(&v[0], &v[1], ()); let edge1 = Edge::new(&v[0], &v[1], ()); assert_ne!(edge0.id(), edge1.id());
Implementations
impl<P, C> Edge<P, C>
[src]
pub fn try_new(
front: &Vertex<P>,
back: &Vertex<P>,
curve: C
) -> Result<Edge<P, C>>
[src]
front: &Vertex<P>,
back: &Vertex<P>,
curve: C
) -> Result<Edge<P, C>>
Generates the edge from front
to back
.
Failures
If front == back
, then returns Error::SameVertex
.
let v = Vertex::news(&[(), ()]); assert!(Edge::try_new(&v[0], &v[1], ()).is_ok()); assert_eq!(Edge::try_new(&v[0], &v[0], ()), Err(Error::SameVertex));
pub fn new(front: &Vertex<P>, back: &Vertex<P>, curve: C) -> Edge<P, C>
[src]
Generates the edge from front
to back
.
Panic
The condition front == back
is not allowed.
use truck_topology::*; let v = Vertex::new(()); Edge::new(&v, &v, ()); // panic occurs
pub fn new_unchecked(
front: &Vertex<P>,
back: &Vertex<P>,
curve: C
) -> Edge<P, C>
[src]
front: &Vertex<P>,
back: &Vertex<P>,
curve: C
) -> Edge<P, C>
Generates the edge from front
to back
.
Remarks
This method is prepared only for performance-critical development and is not recommended.
This method does NOT check the condition front == back
.
The programmer must guarantee this condition before using this method.
pub fn debug_new(front: &Vertex<P>, back: &Vertex<P>, curve: C) -> Edge<P, C>
[src]
Generates the edge from front
to back
.
Remarks
This method check the condition front == back
in the debug mode.
The programmer must guarantee this condition before using this method.
pub fn orientation(&self) -> bool
[src]
Returns the orientation of the curve.
Examples
use truck_topology::*; let v = Vertex::news(&[(), ()]); let edge0 = Edge::new(&v[0], &v[1], ()); let edge1 = edge0.inverse(); assert!(edge0.orientation()); assert!(!edge1.orientation());
pub fn invert(&mut self) -> &mut Self
[src]
Inverts the direction of edge.
use truck_topology::*; let v = Vertex::news(&[(), ()]); let edge = Edge::new(&v[0], &v[1], ()); let mut inv_edge = edge.clone(); inv_edge.invert(); // Two edges are the same edge. edge.is_same(&inv_edge); // the front and back are exchanged. assert_eq!(edge.front(), inv_edge.back()); assert_eq!(edge.back(), inv_edge.front());
pub fn inverse(&self) -> Edge<P, C>
[src]
Creates the inverse oriented edge.
let v = Vertex::news(&[(), ()]); let edge = Edge::new(&v[0], &v[1], ()); let inv_edge = edge.inverse(); // Two edges are the same edge. assert!(edge.is_same(&inv_edge)); // Two edges has the same id. assert_eq!(edge.id(), inv_edge.id()); // the front and back are exchanged. assert_eq!(edge.front(), inv_edge.back()); assert_eq!(edge.back(), inv_edge.front());
pub fn front(&self) -> &Vertex<P>
[src]
Returns the front vertex
let v = Vertex::news(&[(), ()]); let edge = Edge::new(&v[0], &v[1], ()); assert_eq!(edge.front(), &v[0]);
pub fn back(&self) -> &Vertex<P>
[src]
Returns the back vertex
let v = Vertex::news(&[(), ()]); let edge = Edge::new(&v[0], &v[1], ()); assert_eq!(edge.back(), &v[1]);
pub fn ends(&self) -> (&Vertex<P>, &Vertex<P>)
[src]
Returns the vertices at both ends.
let v = Vertex::news(&[(), ()]); let edge = Edge::new(&v[0], &v[1], ()); assert_eq!(edge.ends(), (&v[0], &v[1]));
pub fn absolute_front(&self) -> &Vertex<P>
[src]
Returns the front vertex which is generated by constructor
let v = Vertex::news(&[(), ()]); let edge = Edge::new(&v[0], &v[1], ()).inverse(); assert_eq!(edge.front(), &v[1]); assert_eq!(edge.absolute_front(), &v[0]);
pub fn absolute_back(&self) -> &Vertex<P>
[src]
Returns the back vertex which is generated by constructor
let v = Vertex::news(&[(), ()]); let edge = Edge::new(&v[0], &v[1], ()).inverse(); assert_eq!(edge.back(), &v[0]); assert_eq!(edge.absolute_back(), &v[1]);
pub fn absolute_ends(&self) -> (&Vertex<P>, &Vertex<P>)
[src]
Returns the vertices at both absolute ends.
let v = Vertex::news(&[(), ()]); let mut edge = Edge::new(&v[0], &v[1], ()); edge.invert(); assert_eq!(edge.ends(), (&v[1], &v[0])); assert_eq!(edge.absolute_ends(), (&v[0], &v[1]));
pub fn is_same(&self, other: &Edge<P, C>) -> bool
[src]
Returns whether two edges are the same. Returns true
even if the orientaions are different.
use truck_topology::{Vertex, Edge}; let v = Vertex::news(&[(), ()]); let edge0 = Edge::new(&v[0], &v[1], ()); let edge1 = Edge::new(&v[0], &v[1], ()); let edge2 = edge0.clone(); let edge3 = edge0.inverse(); assert!(!edge0.is_same(&edge1)); // edges whose ids are different are not the same. assert!(edge0.is_same(&edge2)); // The cloned edge is the same edge. assert!(edge0.is_same(&edge3)); // The inversed edge is the "same" edge
pub fn try_lock_curve(&self) -> TryLockResult<MutexGuard<'_, C>>
[src]
Tries to lock the mutex of the contained curve. The thread will not blocked.
Examples
use truck_topology::*; let v = Vertex::news(&[(), ()]); let edge0 = Edge::new(&v[0], &v[1], 0); let edge1 = edge0.clone(); // Two vertices have the same content. assert_eq!(*edge0.try_lock_curve().unwrap(), 0); assert_eq!(*edge1.try_lock_curve().unwrap(), 0); { let mut curve = edge0.try_lock_curve().unwrap(); *curve = 1; } // The contents of two vertices are synchronized. assert_eq!(*edge0.try_lock_curve().unwrap(), 1); assert_eq!(*edge1.try_lock_curve().unwrap(), 1); // The thread is not blocked even if the curve is already locked. let lock = edge0.try_lock_curve(); assert!(edge1.try_lock_curve().is_err());
pub fn lock_curve(&self) -> LockResult<MutexGuard<'_, C>>
[src]
Acquires the mutex of the contained curve, blocking the current thread until it is able to do so.
Examples
use truck_topology::*; let v = Vertex::news(&[(), ()]); let edge0 = Edge::new(&v[0], &v[1], 0); let edge1 = edge0.clone(); // Two edges have the same content. assert_eq!(*edge0.lock_curve().unwrap(), 0); assert_eq!(*edge1.lock_curve().unwrap(), 0); { let mut curve = edge0.lock_curve().unwrap(); *curve = 1; } // The contents of two edges are synchronized. assert_eq!(*edge0.lock_curve().unwrap(), 1); assert_eq!(*edge1.lock_curve().unwrap(), 1); // Check the behavior of `lock`. std::thread::spawn(move || { *edge0.lock_curve().unwrap() = 2; }).join().expect("thread::spawn failed"); assert_eq!(*edge1.lock_curve().unwrap(), 2);
pub fn id(&self) -> EdgeID<C>
[src]
Returns the id that does not depend on the direction of the edge.
Examples
use truck_topology::*; let v = Vertex::news(&[(), ()]); let edge0 = Edge::new(&v[0], &v[1], ()); let edge1 = edge0.inverse(); assert_ne!(edge0, edge1); assert_eq!(edge0.id(), edge1.id());
impl<P, C: Curve<Point = P>> Edge<P, C>
[src]
pub fn oriented_curve(&self) -> C
[src]
Returns the cloned curve in edge. If edge is inverted, then the returned curve is also inverted.
pub fn is_geometric_consistent(&self) -> bool where
P: Tolerance,
[src]
P: Tolerance,
Returns the consistence of the geometry of end vertices and the geometry of edge.
Trait Implementations
impl<P, C> Clone for Edge<P, C>
[src]
impl<P: Debug, C: Debug> Debug for Edge<P, C>
[src]
impl<P, C> Eq for Edge<P, C>
[src]
impl<P, C> Extend<Edge<P, C>> for Wire<P, C>
[src]
pub fn extend<T: IntoIterator<Item = Edge<P, C>>>(&mut self, iter: T)
[src]
pub fn extend_one(&mut self, item: A)
[src]
pub fn extend_reserve(&mut self, additional: usize)
[src]
impl<'a, P, C> FromIterator<&'a Edge<P, C>> for Wire<P, C>
[src]
pub fn from_iter<I: IntoIterator<Item = &'a Edge<P, C>>>(iter: I) -> Wire<P, C>
[src]
impl<P, C> FromIterator<Edge<P, C>> for Wire<P, C>
[src]
pub fn from_iter<I: IntoIterator<Item = Edge<P, C>>>(iter: I) -> Wire<P, C>
[src]
impl<P, C> Hash for Edge<P, C>
[src]
pub fn hash<H: Hasher>(&self, state: &mut H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<P, C> PartialEq<Edge<P, C>> for Edge<P, C>
[src]
Auto Trait Implementations
impl<P, C> RefUnwindSafe for Edge<P, C>
[src]
impl<P, C> Send for Edge<P, C> where
C: Send,
P: Send,
[src]
C: Send,
P: Send,
impl<P, C> Sync for Edge<P, C> where
C: Send,
P: Send,
[src]
C: Send,
P: Send,
impl<P, C> Unpin for Edge<P, C>
[src]
impl<P, C> UnwindSafe for Edge<P, C>
[src]
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<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<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>,