Struct truck_rendimpl::polymesh::PolygonMesh
source · [−]pub struct PolygonMesh<V = StandardVertex, A = StandardAttributes> { /* private fields */ }Expand description
Polygon mesh
The polygon data is held in a method compliant with wavefront obj. Position, uv (texture) coordinates, and normal vectors are held in separate arrays, and each face vertex accesses those values by an indices triple.
Implementations
sourceimpl<V, A> PolygonMesh<V, A> where
V: Copy + Hash + Debug + Eq,
A: Attributes<V>,
impl<V, A> PolygonMesh<V, A> where
V: Copy + Hash + Debug + Eq,
A: Attributes<V>,
sourcepub fn expands<T>(
&self,
contraction: impl Fn(<A as Attributes<V>>::Output) -> T
) -> PolygonMesh<usize, Vec<T, Global>> where
T: Copy,
pub fn expands<T>(
&self,
contraction: impl Fn(<A as Attributes<V>>::Output) -> T
) -> PolygonMesh<usize, Vec<T, Global>> where
T: Copy,
Contract attributes and expand polygon.
Examples
use truck_polymesh::*;
let polygon = PolygonMesh::new(
StandardAttributes {
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),
Point3::new(1.0, 1.0, 0.0),
],
normals: vec![
Vector3::new(0.0, 0.0, 1.0),
Vector3::new(0.0, 0.0, -1.0),
],
..Default::default()
},
Faces::from_iter(&[
&[(0, None, Some(0)), (1, None, Some(0)), (2, None, Some(0))],
&[(3, None, Some(1)), (1, None, Some(1)), (2, None, Some(1))],
])
);
let expands = polygon.expands(|attr| (attr.position, attr.normal.unwrap()));
assert_eq!(
expands,
PolygonMesh::<usize, Vec<(Point3, Vector3)>>::new(
vec![
(Point3::new(0.0, 0.0, 0.0), Vector3::new(0.0, 0.0, 1.0)),
(Point3::new(1.0, 0.0, 0.0), Vector3::new(0.0, 0.0, 1.0)),
(Point3::new(0.0, 1.0, 0.0), Vector3::new(0.0, 0.0, 1.0)),
(Point3::new(1.0, 1.0, 0.0), Vector3::new(0.0, 0.0, -1.0)),
(Point3::new(1.0, 0.0, 0.0), Vector3::new(0.0, 0.0, -1.0)),
(Point3::new(0.0, 1.0, 0.0), Vector3::new(0.0, 0.0, -1.0)),
],
Faces::from_iter(&[[0, 1, 2], [3, 4, 5]]),
)
);sourceimpl<V, A> PolygonMesh<V, A> where
V: Copy + Debug,
A: Attributes<V>,
impl<V, A> PolygonMesh<V, A> where
V: Copy + Debug,
A: Attributes<V>,
sourcepub fn new(attributes: A, faces: Faces<V>) -> PolygonMesh<V, A>
pub fn new(attributes: A, faces: Faces<V>) -> PolygonMesh<V, A>
sourcepub fn try_new(
attributes: A,
faces: Faces<V>
) -> Result<PolygonMesh<V, A>, Error<V>>
pub fn try_new(
attributes: A,
faces: Faces<V>
) -> Result<PolygonMesh<V, A>, Error<V>>
complete constructor
Errors
Returns Error::OutOfRange if there is an index is out of range.
Remarks
This method does not check whether the normal is normalized or not.
sourcepub fn new_unchecked(attributes: A, faces: Faces<V>) -> PolygonMesh<V, A>
pub fn new_unchecked(attributes: A, faces: Faces<V>) -> PolygonMesh<V, A>
constructor without boundary check
sourcepub fn debug_new(attributes: A, faces: Faces<V>) -> PolygonMesh<V, A>
pub fn debug_new(attributes: A, faces: Faces<V>) -> PolygonMesh<V, A>
constructor, boundary check is acrivated only in debug mode.
sourcepub fn attributes(&self) -> &A
pub fn attributes(&self) -> &A
Returns attributes
sourcepub fn tri_faces(&self) -> &Vec<[V; 3], Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn tri_faces(&self) -> &Vec<[V; 3], Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Returns the vector of all triangles of the polygon.
sourcepub fn quad_faces(&self) -> &Vec<[V; 4], Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn quad_faces(&self) -> &Vec<[V; 4], Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Returns the vector of all quadrangles.
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.
cf: Faces::face_iter
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 editor(&mut self) -> PolygonMeshEditor<'_, V, A>
pub fn editor(&mut self) -> PolygonMeshEditor<'_, V, A>
Creates an editor that performs boundary checking on dropped.
sourcepub fn uncheck_editor(&mut self) -> PolygonMeshEditor<'_, V, A>
pub fn uncheck_editor(&mut self) -> PolygonMeshEditor<'_, V, A>
Creates an editor that does NOT perform boundary checking on dropped.
sourcepub fn debug_editor(&mut self) -> PolygonMeshEditor<'_, V, A>
pub fn debug_editor(&mut self) -> PolygonMeshEditor<'_, V, A>
Creates an editor that performs boundary checking on dropped ONLY in debug build.
sourceimpl PolygonMesh<StandardVertex, StandardAttributes>
impl PolygonMesh<StandardVertex, StandardAttributes>
sourcepub fn merge(&mut self, mesh: PolygonMesh<StandardVertex, StandardAttributes>)
pub fn merge(&mut self, mesh: PolygonMesh<StandardVertex, StandardAttributes>)
Returns polygonmesh merged self and mesh.
sourcepub fn bounding_box(&self) -> BoundingBox<Point3<f64>>
pub fn bounding_box(&self) -> BoundingBox<Point3<f64>>
Creates the bounding box of the polygon mesh.
sourceimpl PolygonMesh<StandardVertex, StandardAttributes>
impl PolygonMesh<StandardVertex, StandardAttributes>
sourcepub fn positions(&self) -> &Vec<Point3<f64>, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn positions(&self) -> &Vec<Point3<f64>, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Returns the vector of all positions.
sourcepub fn positions_mut(&mut self) -> &mut [Point3<f64>]
pub fn positions_mut(&mut self) -> &mut [Point3<f64>]
Returns the mutable slice of all positions.
sourcepub fn push_position(&mut self, position: Point3<f64>)
pub fn push_position(&mut self, position: Point3<f64>)
Adds a position.
sourcepub fn extend_positions<I>(&mut self, iter: I) where
I: IntoIterator<Item = Point3<f64>>,
pub fn extend_positions<I>(&mut self, iter: I) where
I: IntoIterator<Item = Point3<f64>>,
Extend positions by iterator.
sourcepub fn uv_coords(&self) -> &Vec<Vector2<f64>, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn uv_coords(&self) -> &Vec<Vector2<f64>, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Returns the vector of all uv (texture) coordinates.
sourcepub fn uv_coords_mut(&mut self) -> &mut [Vector2<f64>]
pub fn uv_coords_mut(&mut self) -> &mut [Vector2<f64>]
Returns the mutable slice of all uv (texture) coordinates.
sourcepub fn push_uv_coord(&mut self, uv_coord: Vector2<f64>)
pub fn push_uv_coord(&mut self, uv_coord: Vector2<f64>)
Adds a uv (texture) coordinate.
sourcepub fn extend_uv_coords<I>(&mut self, iter: I) where
I: IntoIterator<Item = Vector2<f64>>,
pub fn extend_uv_coords<I>(&mut self, iter: I) where
I: IntoIterator<Item = Vector2<f64>>,
Extend uv (texture) coordinates by iterator.
sourcepub fn normals(&self) -> &Vec<Vector3<f64>, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn normals(&self) -> &Vec<Vector3<f64>, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Returns the vector of all normals.
sourcepub fn extend_normals<I>(&mut self, iter: I) where
I: IntoIterator<Item = Vector3<f64>>,
pub fn extend_normals<I>(&mut self, iter: I) where
I: IntoIterator<Item = Vector3<f64>>,
Extend normals by iterator
Trait Implementations
sourceimpl<V, A> Clone for PolygonMesh<V, A> where
V: Clone,
A: Clone,
impl<V, A> Clone for PolygonMesh<V, A> where
V: Clone,
A: Clone,
sourcefn clone(&self) -> PolygonMesh<V, A>
fn clone(&self) -> PolygonMesh<V, A>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl CreateBuffers for PolygonMesh
impl CreateBuffers for PolygonMesh
sourcefn buffers(
&self,
vertex_usage: BufferUsages,
index_usage: BufferUsages,
device: &Device
) -> (BufferHandler, BufferHandler)
fn buffers(
&self,
vertex_usage: BufferUsages,
index_usage: BufferUsages,
device: &Device
) -> (BufferHandler, BufferHandler)
Creates buffer handlers of attributes and indices.
sourceimpl<V, A> Debug for PolygonMesh<V, A> where
V: Debug,
A: Debug,
impl<V, A> Debug for PolygonMesh<V, A> where
V: Debug,
A: Debug,
sourceimpl<V, A> Default for PolygonMesh<V, A> where
A: Default,
impl<V, A> Default for PolygonMesh<V, A> where
A: Default,
sourcefn default() -> PolygonMesh<V, A>
fn default() -> PolygonMesh<V, A>
Returns the “default value” for a type. Read more
sourceimpl<'de, V, A> Deserialize<'de> for PolygonMesh<V, A> where
V: Deserialize<'de>,
A: Deserialize<'de>,
impl<'de, V, A> Deserialize<'de> for PolygonMesh<V, A> where
V: Deserialize<'de>,
A: Deserialize<'de>,
sourcefn deserialize<__D>(
__deserializer: __D
) -> Result<PolygonMesh<V, A>, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<PolygonMesh<V, A>, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl FromIterator<STLFace> for PolygonMesh<StandardVertex, StandardAttributes>
impl FromIterator<STLFace> for PolygonMesh<StandardVertex, StandardAttributes>
sourcefn from_iter<I>(iter: I) -> PolygonMesh<StandardVertex, StandardAttributes> where
I: IntoIterator<Item = STLFace>,
fn from_iter<I>(iter: I) -> PolygonMesh<StandardVertex, StandardAttributes> where
I: IntoIterator<Item = STLFace>,
Creates a value from an iterator. Read more
sourceimpl<'a> IntoSTLIterator for &'a PolygonMesh<StandardVertex, StandardAttributes>
impl<'a> IntoSTLIterator for &'a PolygonMesh<StandardVertex, StandardAttributes>
type IntoIter = PolygonMeshSTLFaceIterator<'a>
type IntoIter = PolygonMeshSTLFaceIterator<'a>
Which kind of iterator are we turning this into?
sourcefn into_iter(
self
) -> <&'a PolygonMesh<StandardVertex, StandardAttributes> as IntoSTLIterator>::IntoIter
fn into_iter(
self
) -> <&'a PolygonMesh<StandardVertex, StandardAttributes> as IntoSTLIterator>::IntoIter
Creates an iterator from a value.
sourceimpl Invertible for PolygonMesh<StandardVertex, StandardAttributes>
impl Invertible for PolygonMesh<StandardVertex, StandardAttributes>
sourcefn inverse(&self) -> PolygonMesh<StandardVertex, StandardAttributes>
fn inverse(&self) -> PolygonMesh<StandardVertex, StandardAttributes>
Returns the inverse.
sourceimpl<V, A> PartialEq<PolygonMesh<V, A>> for PolygonMesh<V, A> where
V: PartialEq<V>,
A: PartialEq<A>,
impl<V, A> PartialEq<PolygonMesh<V, A>> for PolygonMesh<V, A> where
V: PartialEq<V>,
A: PartialEq<A>,
sourcefn eq(&self, other: &PolygonMesh<V, A>) -> bool
fn eq(&self, other: &PolygonMesh<V, A>) -> bool
This method tests for self and other values to be equal, and is used
by ==. Read more
sourcefn ne(&self, other: &PolygonMesh<V, A>) -> bool
fn ne(&self, other: &PolygonMesh<V, A>) -> bool
This method tests for !=.
sourceimpl<V, A> Serialize for PolygonMesh<V, A> where
V: Serialize,
A: Serialize,
impl<V, A> Serialize for PolygonMesh<V, A> where
V: Serialize,
A: Serialize,
sourcefn 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,
Serialize this value into the given Serde serializer. Read more
sourceimpl ToInstance<PolygonInstance> for PolygonMesh
impl ToInstance<PolygonInstance> for PolygonMesh
type State = PolygonState
type State = PolygonState
Configuation deacriptor for instance.
sourcefn to_instance(
&self,
handler: &DeviceHandler,
shaders: &PolygonShaders,
state: &PolygonState
) -> PolygonInstance
fn to_instance(
&self,
handler: &DeviceHandler,
shaders: &PolygonShaders,
state: &PolygonState
) -> PolygonInstance
Creates Instance from self.
sourceimpl ToInstance<WireFrameInstance> for PolygonMesh
impl ToInstance<WireFrameInstance> for PolygonMesh
type State = WireFrameState
type State = WireFrameState
Configuation deacriptor for instance.
sourcefn to_instance(
&self,
handler: &DeviceHandler,
shaders: &WireShaders,
state: &WireFrameState
) -> WireFrameInstance
fn to_instance(
&self,
handler: &DeviceHandler,
shaders: &WireShaders,
state: &WireFrameState
) -> WireFrameInstance
Creates Instance from self.
impl<V, A> StructuralPartialEq for PolygonMesh<V, A>
Auto Trait Implementations
impl<V, A> RefUnwindSafe for PolygonMesh<V, A> where
A: RefUnwindSafe,
V: RefUnwindSafe,
impl<V, A> Send for PolygonMesh<V, A> where
A: Send,
V: Send,
impl<V, A> Sync for PolygonMesh<V, A> where
A: Sync,
V: Sync,
impl<V, A> Unpin for PolygonMesh<V, A> where
A: Unpin,
V: Unpin,
impl<V, A> UnwindSafe for PolygonMesh<V, A> where
A: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<R, P> ReadPrimitive<R> for P where
R: Read + ReadEndian<P>,
P: Default,
impl<R, P> ReadPrimitive<R> for P where
R: Read + ReadEndian<P>,
P: Default,
sourcefn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
sourcefn read_from_big_endian(read: &mut R) -> Result<Self, Error>
fn read_from_big_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
sourcefn read_from_native_endian(read: &mut R) -> Result<Self, Error>
fn read_from_native_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more