Enum truck_topology::errors::Error
source · pub enum Error {
SameVertex,
EmptyWire,
NotClosedWire,
NotSimpleWire,
NotDisjointWires,
EmptyShell,
NotConnected,
NotClosedShell,
NotManifold,
}
Expand description
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 construct 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;
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§
source§impl Error for Error
impl Error for Error
1.30.0 · source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
1.0.0 · source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()