Struct truck_meshalgo::rexport_polymesh::Faces
source · 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 fn extend<U, T, I>(&mut self, iter: I)where
U: Copy + Into<V>,
T: AsRef<[U]>,
I: IntoIterator<Item = T>,
pub fn extend<U, T, I>(&mut self, iter: I)where
U: Copy + Into<V>,
T: AsRef<[U]>,
I: IntoIterator<Item = T>,
Extends faces by an iterator.
sourcepub const fn from_tri_and_quad_faces(
tri_faces: Vec<[V; 3], Global>,
quad_faces: Vec<[V; 4], Global>
) -> Faces<V>
pub const fn from_tri_and_quad_faces(
tri_faces: Vec<[V; 3], Global>,
quad_faces: Vec<[V; 4], Global>
) -> 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)where
U: Copy + Into<V>,
T: AsRef<[U]>,
pub fn push<U, T>(&mut self, face: T)where
U: Copy + Into<V>,
T: AsRef<[U]>,
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 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, Global>, Global> ⓘ
pub const fn other_faces(&self) -> &Vec<Vec<V, Global>, Global> ⓘ
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<T> FromIterator<T> for Faces<StandardVertex>where
T: AsVertexSlice,
impl<T> FromIterator<T> for Faces<StandardVertex>where
T: AsVertexSlice,
source§fn from_iter<I>(iter: I) -> Faces<StandardVertex>where
I: IntoIterator<Item = T>,
fn from_iter<I>(iter: I) -> Faces<StandardVertex>where
I: IntoIterator<Item = T>,
source§impl<V> Invertible for Faces<V>where
V: Copy,
impl<V> Invertible for Faces<V>where
V: Copy,
source§impl<V> PartialEq<Faces<V>> for Faces<V>where
V: PartialEq<V>,
impl<V> PartialEq<Faces<V>> for Faces<V>where
V: PartialEq<V>,
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,
source§impl Topology for Faces
impl Topology for Faces
source§fn extract_boundaries(&self) -> Vec<Vec<usize>> ⓘ
fn extract_boundaries(&self) -> Vec<Vec<usize>> ⓘ
source§fn shell_condition(&self) -> ShellCondition
fn shell_condition(&self) -> ShellCondition
The complexity increases in proportion to the number of edges. Read more