pub enum Error<V = StandardVertex>where
V: Debug,{
OutOfRange(V),
NoNormal,
DifferentLengthArrays,
IrregularArray,
UnsortedDivision,
FromIO(Error),
}Expand description
Errors occurred by polygon mesh handling
Variants§
OutOfRange(V)
There is an index in out of range.
§Examples
use truck_polymesh::*;
use errors::Error;
let positions = vec![
Point3::new(0.0, 0.0, 0.0),
Point3::new(1.0, 0.0, 0.0),
Point3::new(0.0, 1.0, 0.0),
];
let faces = Faces::from_iter(&[
&[0, 1, 2],
&[1, 2, 4],
]);
let res = PolygonMesh::try_new(
StandardAttributes {
positions,
..Default::default()
},
faces,
);
match res {
Err(Error::OutOfRange(vertex)) => {
assert_eq!(vertex.pos, 4);
}
_ => panic!("wrong result!"),
}NoNormal
There are no normal in polygon mesh.
DifferentLengthArrays
The length of arrays of StructuredMesh is incorrect.
IrregularArray
The length of arrays of StructuredMesh is incorrect.
§Examples
use truck_polymesh::*;
use errors::Error;
let positions = vec![
vec![Point3::new(0.0, 0.0, 0.0), Point3::new(1.0, 0.0, 0.0)],
vec![Point3::new(0.0, 1.0, 0.0)],
];
match StructuredMesh::try_from_positions(positions) {
Err(Error::IrregularArray) => {}
_ => panic!("wrong result!"),
}UnsortedDivision
The division of uv coords of StructuredMesh is not sorted.
§Examples
use truck_polymesh::*;
use errors::Error;
let positions = vec![
vec![Point3::new(0.0, 0.0, 0.0), Point3::new(0.0, 1.0, 0.0)],
vec![Point3::new(1.0, 0.0, 0.0), Point3::new(1.0, 1.0, 0.0)],
];
let udiv = vec![1.0, 0.0];
let vdiv = vec![0.0, 1.0];
match StructuredMesh::try_from_positions_and_uvs(positions, (udiv, vdiv)) {
Err(Error::UnsortedDivision) => {}
_ => panic!("wrong result!"),
}FromIO(Error)
Errors caused by obj files I/O.
Trait Implementations§
Source§impl<V> Error for Error<V>
impl<V> Error for Error<V>
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns 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()
Source§impl From<ParseFloatError> for Error
impl From<ParseFloatError> for Error
Source§fn from(error: ParseFloatError) -> Error
fn from(error: ParseFloatError) -> Error
Converts to this type from the input type.
Source§impl From<ParseIntError> for Error
impl From<ParseIntError> for Error
Source§fn from(error: ParseIntError) -> Error
fn from(error: ParseIntError) -> Error
Converts to this type from the input type.
Auto Trait Implementations§
impl<V> Freeze for Error<V>where
V: Freeze,
impl<V = StandardVertex> !RefUnwindSafe for Error<V>
impl<V> Send for Error<V>where
V: Send,
impl<V> Sync for Error<V>where
V: Sync,
impl<V> Unpin for Error<V>where
V: Unpin,
impl<V = StandardVertex> !UnwindSafe for Error<V>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more