Struct truck_polymesh::Faces [−][src]
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
impl Faces
[src]
pub fn from_iter<V: Copy + Into<Vertex>, T: AsRef<[V]>, I: IntoIterator<Item = T>>(
iter: I
) -> Faces
[src]
iter: I
) -> Faces
Creates faces of a polygon by iterator of slice.
If face.len() < 3
, the face is ignored.
Examples
use truck_polymesh::*; let slice: &[&[[usize; 3]]] = &[ &[[0, 0, 0], [1, 1, 1], [2, 2, 2]], &[[0, 0, 0], [2, 2, 2], [3, 3, 3]], &[[0, 0, 0], [4, 4, 4], [5, 5, 5], [1, 1, 1]], ]; let faces = Faces::from_iter(slice);
pub fn extend<V: Copy + Into<Vertex>, T: AsRef<[V]>, I: IntoIterator<Item = T>>(
&mut self,
iter: I
)
[src]
&mut self,
iter: I
)
Extends faces by an iterator.
pub fn from_tri_and_quad_faces(
tri_faces: Vec<[Vertex; 3]>,
quad_faces: Vec<[Vertex; 4]>
) -> Faces
[src]
tri_faces: Vec<[Vertex; 3]>,
quad_faces: Vec<[Vertex; 4]>
) -> Faces
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<[Vertex; 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());
pub fn push<V: Copy + Into<Vertex>, T: AsRef<[V]>>(&mut self, face: T)
[src]
Push a face to the faces.
If face.len() < 3
, the face is ignored with warning.
Examples
use truck_polymesh::*; let mut faces = Faces::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"
pub fn tri_faces(&self) -> &Vec<[Vertex; 3]>
[src]
Returns the vector of triangles.
pub fn tri_faces_mut(&mut self) -> &mut [[Vertex; 3]]
[src]
Returns the mutable slice of triangles.
pub fn quad_faces(&self) -> &Vec<[Vertex; 4]>
[src]
Returns the vector of quadrangles.
pub fn quad_faces_mut(&mut self) -> &mut [[Vertex; 4]]
[src]
Returns the mutable slice of quadrangles.
pub fn other_faces(&self) -> &Vec<Vec<Vertex>>
[src]
Returns the vector of n-gons (n > 4).
pub fn other_faces_mut(&mut self) -> impl Iterator<Item = &mut [Vertex]>
[src]
Returns the mutable iterator of n-gons (n > 4).
pub fn face_iter<'a>(&'a self) -> impl Iterator<Item = &'a [Vertex]>
[src]
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::from_iter(slice); let mut iter = faces.face_iter(); assert_eq!(iter.next(), Some([ Vertex { pos: 0, uv: None, nor: None }, Vertex { pos: 1, uv: None, nor: None }, Vertex { pos: 2, uv: None, nor: None }, ].as_ref())); assert_eq!(iter.next(), Some([ Vertex { pos: 0, uv: None, nor: None }, Vertex { pos: 2, uv: None, nor: None }, Vertex { pos: 3, uv: None, nor: None }, ].as_ref())); assert_eq!(iter.next(), Some([ Vertex { pos: 0, uv: None, nor: None }, Vertex { pos: 4, uv: None, nor: None }, Vertex { pos: 5, uv: None, nor: None }, Vertex { pos: 1, uv: None, nor: None }, ].as_ref())); assert_eq!(iter.next(), Some([ Vertex { pos: 1, uv: None, nor: None }, Vertex { pos: 2, uv: None, nor: None }, Vertex { pos: 6, uv: None, nor: None }, Vertex { pos: 7, uv: None, nor: None }, Vertex { pos: 8, uv: None, nor: None }, Vertex { pos: 9, uv: None, nor: None }, ].as_ref())); assert_eq!(iter.next(), None);
pub fn face_iter_mut<'a>(&'a mut self) -> impl Iterator<Item = &'a mut [Vertex]>
[src]
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
pub fn len(&self) -> usize
[src]
Returns the number of faces.
pub fn naive_concat(&mut self, other: Self)
[src]
Merges other
into self
.
Trait Implementations
impl Clone for Faces
[src]
impl Debug for Faces
[src]
impl Default for Faces
[src]
impl<'de> Deserialize<'de> for Faces
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Index<usize> for Faces
[src]
type Output = [Vertex]
The returned type after indexing.
fn index(&self, idx: usize) -> &Self::Output
[src]
impl IndexMut<usize> for Faces
[src]
impl PartialEq<Faces> for Faces
[src]
impl Serialize for Faces
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl StructuralPartialEq for Faces
[src]
Auto Trait Implementations
impl RefUnwindSafe for Faces
impl Send for Faces
impl Sync for Faces
impl Unpin for Faces
impl UnwindSafe for Faces
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,