Enum truck_polymesh::errors::Error
source · pub enum Error<V: Debug = StandardVertex> {
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: Debug> Error for Error<V>
impl<V: Debug> 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> 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