pub struct Faces<V = StandardVertex> { /* private fields */ }Expand description
Faces of polygon mesh
To optimize for the case where the polygon mesh consists only triangles and quadrangle, there are vectors which consist by each triangles and quadrilaterals, internally.
Implementations§
Source§impl<V> Faces<V>where
V: Copy,
impl<V> Faces<V>where
V: Copy,
Sourcepub const fn from_tri_and_quad_faces(
tri_faces: Vec<[V; 3]>,
quad_faces: Vec<[V; 4]>,
) -> Faces<V>
pub const fn from_tri_and_quad_faces( tri_faces: Vec<[V; 3]>, quad_faces: Vec<[V; 4]>, ) -> Faces<V>
Creates faces of a polygon mesh by the vectors of triangle and quadrangle.
§Examples
// Creates faces consisis only triangles.
use truck_polymesh::*;
let tri_faces: Vec<[StandardVertex; 3]> = vec![
[[0, 0, 0].into(), [1, 1, 1].into(), [2, 2, 2].into()],
[[0, 0, 0].into(), [2, 2, 2].into(), [3, 3, 3].into()],
];
let faces = Faces::from_tri_and_quad_faces(tri_faces, Vec::new());Sourcepub fn push<U, T>(&mut self, face: T)
pub fn push<U, T>(&mut self, face: T)
Push a face to the faces.
If face.len() < 3, the face is ignored with warning.
§Examples
use truck_polymesh::*;
let mut faces = Faces::<StandardVertex>::default(); // empty faces
faces.push(&[[0, 0, 0], [1, 1, 1], [2, 2, 2]]);
faces.push(&[[3, 3, 3], [0, 0, 0], [2, 2, 2]]);
faces.push(&[[0, 0, 0], [4, 4, 4], [5, 5, 5], [1, 1, 1]]);
faces.push(&[[100, 1000, 10]]); // Wargning: ignored one vertex "face"Sourcepub fn tri_faces_mut(&mut self) -> &mut [[V; 3]]
pub fn tri_faces_mut(&mut self) -> &mut [[V; 3]]
Returns the mutable slice of triangles.
Sourcepub const fn quad_faces(&self) -> &Vec<[V; 4]>
pub const fn quad_faces(&self) -> &Vec<[V; 4]>
Returns the vector of quadrangles.
Sourcepub fn quad_faces_mut(&mut self) -> &mut [[V; 4]]
pub fn quad_faces_mut(&mut self) -> &mut [[V; 4]]
Returns the mutable slice of quadrangles.
Sourcepub const fn other_faces(&self) -> &Vec<Vec<V>>
pub const fn other_faces(&self) -> &Vec<Vec<V>>
Returns the vector of n-gons (n > 4).
Sourcepub fn other_faces_mut(&mut self) -> impl Iterator<Item = &mut [V]>
pub fn other_faces_mut(&mut self) -> impl Iterator<Item = &mut [V]>
Returns the mutable iterator of n-gons (n > 4).
Sourcepub fn face_iter(&self) -> impl Iterator<Item = &[V]>
pub fn face_iter(&self) -> impl Iterator<Item = &[V]>
Returns the iterator of the slice.
By the internal optimization, this iterator does not runs in the simple order in which they are registered, but runs order: triangle, square, and the others.
§Examples
use truck_polymesh::*;
let slice: &[&[usize]] = &[
&[0, 1, 2],
&[0, 4, 5, 1],
&[1, 2, 6, 7, 8, 9],
&[0, 2, 3],
];
let faces = Faces::<usize>::from_iter(slice);
let mut iter = faces.face_iter();
assert_eq!(iter.next(), Some([0, 1, 2].as_ref()));
assert_eq!(iter.next(), Some([0, 2, 3].as_ref()));
assert_eq!(iter.next(), Some([0, 4, 5, 1].as_ref()));
assert_eq!(iter.next(), Some([1, 2, 6, 7, 8, 9].as_ref()));
assert_eq!(iter.next(), None);Sourcepub fn face_iter_mut(&mut self) -> impl Iterator<Item = &mut [V]>
pub fn face_iter_mut(&mut self) -> impl Iterator<Item = &mut [V]>
Returns the iterator of the slice.
By the internal optimization, this iterator does not runs in the simple order
in which they are registered, but runs order: triangle, square, and the others.
cf: Faces:face_iter
Sourcepub fn naive_concat(&mut self, other: Faces<V>)
pub fn naive_concat(&mut self, other: Faces<V>)
Merges other into self.
Sourcepub fn triangle_iter(&self) -> TriangleIterator<'_, V> ⓘ
pub fn triangle_iter(&self) -> TriangleIterator<'_, V> ⓘ
Returns iterator with triangulation faces
§Examples
use truck_polymesh::*;
let slice: &[&[usize]] = &[
&[0, 1, 2],
&[0, 4, 5, 1],
&[1, 2, 6, 7, 8, 9],
&[1, 2, 4, 3],
&[0, 2, 3],
];
let faces = Faces::<usize>::from_iter(slice);
let mut iter = faces.triangle_iter();
assert_eq!(iter.len(), 10);
assert_eq!(iter.next(), Some([0, 1, 2]));
assert_eq!(iter.next(), Some([0, 2, 3]));
assert_eq!(iter.next(), Some([0, 4, 5]));
assert_eq!(iter.next(), Some([0, 5, 1]));
assert_eq!(iter.next(), Some([1, 2, 4]));
assert_eq!(iter.next(), Some([1, 4, 3]));
assert_eq!(iter.next(), Some([1, 2, 6]));
assert_eq!(iter.next(), Some([1, 6, 7]));
assert_eq!(iter.next(), Some([1, 7, 8]));
assert_eq!(iter.next(), Some([1, 8, 9]));
assert_eq!(iter.len(), 0);
assert_eq!(iter.next(), None);Trait Implementations§
Source§impl<'de, V> Deserialize<'de> for Faces<V>where
V: Deserialize<'de>,
impl<'de, V> Deserialize<'de> for Faces<V>where
V: Deserialize<'de>,
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Faces<V>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Faces<V>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl<S> FromIterator<S> for Faces<usize>
impl<S> FromIterator<S> for Faces<usize>
Source§impl<T> FromIterator<T> for Faceswhere
T: AsVertexSlice,
impl<T> FromIterator<T> for Faceswhere
T: AsVertexSlice,
Source§impl<V> Invertible for Faces<V>where
V: Copy,
impl<V> Invertible for Faces<V>where
V: Copy,
Source§impl<V> Serialize for Faces<V>where
V: Serialize,
impl<V> Serialize for Faces<V>where
V: Serialize,
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl<V> Eq for Faces<V>where
V: Eq,
impl<V> StructuralPartialEq for Faces<V>
Auto Trait Implementations§
impl<V> Freeze for Faces<V>
impl<V> RefUnwindSafe for Faces<V>where
V: RefUnwindSafe,
impl<V> Send for Faces<V>where
V: Send,
impl<V> Sync for Faces<V>where
V: Sync,
impl<V> Unpin for Faces<V>where
V: Unpin,
impl<V> UnwindSafe for Faces<V>where
V: UnwindSafe,
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)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>
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>
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)
&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)
&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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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>
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>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().