Enum truck_topology::errors::Error[][src]

pub enum Error {
    SameVertex,
    EmptyWire,
    NotClosedWire,
    NotSimpleWire,
    NotDisjointWires,
    EmptyShell,
    NotConnected,
    NotClosedShell,
    NotManifold,
}

Topological Errors

Variants

SameVertex

Two same vertices cannot construct an edge.

Examples

use truck_topology::*;
use truck_topology::errors::Error;
let v = Vertex::new(());
assert_eq!(Edge::try_new(&v, &v, ()), Err(Error::SameVertex));
EmptyWire

The empty wire cannot contruct a face.

Examples

use truck_topology::*;
use truck_topology::errors::Error;
assert_eq!(Face::try_new(vec![Wire::<(), ()>::new()], ()), Err(Error::EmptyWire));
NotClosedWire

The boundary of a face must be closed.

Examples

use truck_topology::*;
use truck_topology::errors::Error;
let v = Vertex::news(&[(), ()]);
let wire: Wire<(), ()> = vec![Edge::new(&v[0], &v[1], ())].into();
assert_eq!(Face::try_new(vec![wire], ()), Err(Error::NotClosedWire));
NotSimpleWire

The boundary of a face must be simple.

Examples

use truck_topology::*;
use truck_topology::errors::Error;
let v = Vertex::news(&[(); 4]);
let wire: Wire<(), ()> = vec![
    Edge::new(&v[0], &v[1], ()),
    Edge::new(&v[1], &v[2], ()),
    Edge::new(&v[2], &v[3], ()),
    Edge::new(&v[3], &v[1], ()),
    Edge::new(&v[1], &v[0], ()),
].into();
assert_eq!(Face::try_new(vec![wire], ()), Err(Error::NotSimpleWire));
NotDisjointWires

Some boundaries has a shared vertex.

EmptyShell

The empty shell cannot construct a solid.

Examples

use truck_topology::*;
use truck_topology::errors::Error;
assert_eq!(Solid::try_new(vec![Shell::<(), (), ()>::new()]), Err(Error::EmptyShell));
NotConnected

The vector of boundaries of the solid must consist connected shells.

Examples

use truck_topology::*;
use truck_topology::errors::Error;
let v = Vertex::news(&[(), (), (), ()]);
let wire = vec![
    Wire::from(vec![Edge::new(&v[0], &v[1], ()), Edge::new(&v[1], &v[0], ())]),
    Wire::from(vec![Edge::new(&v[2], &v[3], ()), Edge::new(&v[3], &v[2], ())]),
];
let shell: Shell<(), (), ()> = wire.into_iter().map(|w| Face::new(vec![w], ())).collect();
assert_eq!(Solid::try_new(vec![shell]), Err(Error::NotConnected));
NotClosedShell

The boundary of the solid must be closed.

Examples

use truck_topology::*;
use truck_topology::errors::Error;
let v = Vertex::news(&[(), ()]);
let wire = Wire::from(vec![Edge::new(&v[0], &v[1], ()), Edge::new(&v[1], &v[0], ())]);
let shell: Shell<(), (), ()> = vec![Face::new(vec![wire], ())].into();
assert_eq!(Solid::try_new(vec![shell]), Err(Error::NotClosedShell));
NotManifold

The boundary of the solid must be a manifold.

Examples

// the wedge sum of two spheres
use truck_topology::*;
use truck_topology::errors::Error;
use std::iter::FromIterator;
let v = Vertex::news(&[(), (), ()]);
let edge = [
    Edge::new(&v[0], &v[1], ()),
    Edge::new(&v[1], &v[0], ()),
    Edge::new(&v[1], &v[2], ()),
    Edge::new(&v[2], &v[1], ()),
];
let wire = vec![
    Wire::from_iter(vec![&edge[0], &edge[1]]),
    Wire::from_iter(vec![&edge[1].inverse(), &edge[0].inverse()]),
    Wire::from_iter(vec![&edge[2], &edge[3]]),
    Wire::from_iter(vec![&edge[3].inverse(), &edge[2].inverse()]),
];
let shell: Shell<(), (), ()> = wire.into_iter().map(|w| Face::new(vec![w], ())).collect();
assert_eq!(Solid::try_new(vec![shell]), Err(Error::NotManifold));

Trait Implementations

impl Debug for Error[src]

impl Display for Error[src]

impl Error for Error[src]

impl PartialEq<Error> for Error[src]

impl StructuralPartialEq for Error[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.