Struct gut::mesh::polymesh::PolyMesh[][src]

pub struct PolyMesh<T: Real> {
    pub vertex_positions: IntrinsicAttribute<[T; 3], VertexIndex>,
    pub indices: Vec<usize>,
    pub offsets: Vec<usize>,
    pub vertex_attributes: AttribDict<VertexIndex>,
    pub face_attributes: AttribDict<FaceIndex>,
    pub face_vertex_attributes: AttribDict<FaceVertexIndex>,
    pub face_edge_attributes: AttribDict<FaceEdgeIndex>,
    pub attribute_value_cache: AttribValueCache,
}

Mesh with arbitrarily shaped faces. It could have polygons with any number of sides. All faces are assumed to be closed polygons.

Fields

vertex_positions: IntrinsicAttribute<[T; 3], VertexIndex>

Vertex positions intrinsic attribute.

indices: Vec<usize>

Indices into vertices representing face vertices.

offsets: Vec<usize>

Offsets into indices representing individual faces. The last element in this Vec is always the length of indices for convenience.

vertex_attributes: AttribDict<VertexIndex>

Vertex attributes.

face_attributes: AttribDict<FaceIndex>

Polygon attributes.

face_vertex_attributes: AttribDict<FaceVertexIndex>

Polygon vertex attributes.

face_edge_attributes: AttribDict<FaceEdgeIndex>

Polygon edge attributes.

attribute_value_cache: AttribValueCache

Indirect attribute value cache

Implementations

impl<T: Real> PolyMesh<T>[src]

impl<T: Real> PolyMesh<T>[src]

pub fn merge_with_vertex_source<'a, I>(
    meshes: I,
    source_attrib: &str
) -> Result<Self, Error> where
    I: IntoIterator<Item = &'a Self>, 
[src]

Merge a iterator of meshes into a single distinct mesh.

This version of merge accepts an attribute name for the source index on vertices.

The mesh vertices will be merged in the order given by the source attribute. This is useful when merging previously split up meshes. The source attribute needs to have type usize.

If the source attribute does not exist in at least one of the given meshes, then None is returned and the merge is aborted.

This is a non-destructive merge --- both original meshes remain intact. This also means that this way of merging is somewhat more expensive than a merge without any source indices.

impl<T: Real> PolyMesh<T>[src]

pub fn split_vertices_by_face_vertex_attrib<U: PartialOrd + PartialEq + Copy + 'static>(
    &mut self,
    attrib: &str
)
[src]

Split vertices by a given face-vertex attribute.

If a pair of face-vertices have different values for the same vertex, then they will be split into distinct vertices. New vertex positions are appended at the end of the vertex position array.

If the given attribute doesn't exist, then nothing is changed.

impl<T: Real> PolyMesh<T>[src]

pub fn new(verts: Vec<[T; 3]>, faces: &[usize]) -> PolyMesh<T>[src]

Construct a PolyMesh from an array of vertices and an array of sizes and indices.

The faces array contains the indices into the vertex array for each face preceeded by the number of vertices in the corresponding face. I.e. faces is expected to be structured as a contiguous array of a number (corresponding to the number of vertices in the face) followed by the vertex indices (in the same face):

    n i_1 i_2 ... i_n m j_1 j_2 ... j_m ...

Examples

use gut::mesh::PolyMesh;
let points = vec![
    [0.0, 0.0, 0.0],
    [1.0, 0.0, 0.0],
    [0.0, 1.0, 0.0],
    [1.0, 1.0, 0.0],
    [0.0, 0.0, 1.0],
    [1.0, 0.0, 1.0]];
let faces = vec![3, 0, 1, 2, // first triangle
                 3, 1, 3, 2, // second triangle
                 4, 0, 1, 5, 4]; // quadrilateral

let polymesh = PolyMesh::new(points, &faces);

assert_eq!(polymesh.indices, [0, 1, 2, 1, 3, 2, 0, 1, 5, 4]);
assert_eq!(polymesh.offsets, [0, 3, 6, 10]);

pub fn face_iter(&self) -> DynamicIndexSliceIter<'_>

Notable traits for DynamicIndexSliceIter<'a>

impl<'a> Iterator for DynamicIndexSliceIter<'a> type Item = &'a [usize];
[src]

pub fn face_iter_mut(&mut self) -> DynamicIndexSliceIterMut<'_>

Notable traits for DynamicIndexSliceIterMut<'a>

impl<'a> Iterator for DynamicIndexSliceIterMut<'a> type Item = &'a mut [usize];
[src]

pub fn reverse(&mut self)[src]

Reverse the order of each polygon in this mesh.

pub fn reversed(mut self: Self) -> PolyMesh<T>[src]

Reverse the order of each polygon in this mesh. This is the consuming version of the reverse method.

Trait Implementations

impl<T: Real> Attrib for PolyMesh<T>[src]

impl<T: Clone + Real> Clone for PolyMesh<T>[src]

impl<T: Debug + Real> Debug for PolyMesh<T>[src]

impl<T: Real> Default for PolyMesh<T>[src]

fn default() -> Self[src]

Produce an empty mesh. This is not particularly useful on its own, however it can be used as a null case for various mesh algorithms.

impl<T: Real> FaceAttrib for PolyMesh<T>[src]

impl<T: Real> FaceEdge for PolyMesh<T>[src]

impl<T: Real> FaceEdgeAttrib for PolyMesh<T>[src]

impl<T: Real> FaceVertex for PolyMesh<T>[src]

impl<T: Real> FaceVertexAttrib for PolyMesh<T>[src]

impl<T: Real> From<PointCloud<T>> for PolyMesh<T>[src]

Convert a point cloud into a polygon mesh.

impl<T: Real> From<PolyMesh<T>> for PointCloud<T>[src]

Convert a polygon mesh to a point cloud by erasing all polygon data.

impl<T: Real> From<PolyMesh<T>> for TriMeshExt<T>[src]

Convert a triangle mesh to a polygon mesh.

impl<T: Real> From<PolyMesh<T>> for TriMesh<T>[src]

Convert a triangle mesh to a polygon mesh.

impl<T: Real> From<QuadMesh<T>> for PolyMesh<T>[src]

Convert a quad mesh into a polygon mesh.

impl<T: Real> From<TetMesh<T>> for PolyMesh<T>[src]

impl<T: Real> From<TriMesh<T>> for PolyMesh<T>[src]

Convert a triangle mesh into a polygon mesh.

impl<T: Real> Merge for PolyMesh<T>[src]

fn merge(&mut self, other: Self) -> &mut Self[src]

Attributes with the same name but different types won't be merged.

impl<T: Real> NumFaces for PolyMesh<T>[src]

impl<T: Real> NumVertices for PolyMesh<T>[src]

impl<T: PartialEq + Real> PartialEq<PolyMesh<T>> for PolyMesh<T>[src]

impl<T: Real> Split<VertexIndex> for PolyMesh<T>[src]

impl<T: Real> SplitIntoConnectedComponents<VertexIndex, FaceIndex> for PolyMesh<T>[src]

impl<T: Real> StructuralPartialEq for PolyMesh<T>[src]

impl<T: Real> VertexAttrib for PolyMesh<T>[src]

impl<T: Real> VertexPositions for PolyMesh<T>[src]

type Element = [T; 3]

Auto Trait Implementations

impl<T> RefUnwindSafe for PolyMesh<T> where
    T: RefUnwindSafe
[src]

impl<T> Send for PolyMesh<T>[src]

impl<T> Sync for PolyMesh<T>[src]

impl<T> Unpin for PolyMesh<T> where
    T: Unpin
[src]

impl<T> UnwindSafe for PolyMesh<T> where
    T: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> AsSlice<T> for T[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<M, T> BoundingBox<T> for M where
    T: Real,
    M: VertexPositions<Element = [T; 3]>, 
[src]

pub fn bounding_box(&Self) -> BBox<T>[src]

Compute the bounding box of this object.

impl<T> CloneBytes for T where
    T: 'static + Clone
[src]

impl<M> Connectivity<FaceVertexIndex, VertexIndex> for M where
    M: NumVertices + NumFaces + FaceVertex
[src]

type Topo = (Vec<usize, Global>, Vec<usize, Global>)

Additional topology that may aid in computing connectivity. Read more

impl<M> Connectivity<VertexIndex, FaceIndex> for M where
    M: NumVertices + NumFaces + FaceVertex
[src]

type Topo = (Vec<usize, Global>, Vec<usize, Global>)

Additional topology that may aid in computing connectivity. Read more

impl<T> DebugBytes for T where
    T: 'static + Debug
[src]

impl<T> Downcast for T where
    T: Any

impl<T> DowncastSync for T where
    T: Send + Sync + Any

impl<T> DropBytes for T where
    T: 'static, 
[src]

impl<T> Elem for T where
    T: Any + DropBytes
[src]

impl<T> From<T> for T[src]

impl<'a, S, I> Get<'a, I> for S where
    I: GetIndex<'a, S>, 
[src]

type Output = <I as GetIndex<'a, S>>::Output

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<S, I> Isolate<I> for S where
    I: IsolateIndex<S>, 
[src]

type Output = <I as IsolateIndex<S>>::Output

impl<T> PartialEqBytes for T where
    T: 'static + PartialEq<T>, 
[src]

impl<M> Partition for M where
    M: Attrib
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T, N> PushArrayToVec<N> for T where
    T: Clone,
    N: Array<T>, 
[src]

impl<T, M> Rotate<T> for M where
    T: BaseFloat,
    M: VertexPositions<Element = [T; 3]>, 
[src]

pub fn rotate_by_matrix(&mut Self, [[T; 3]; 3])[src]

Rotate the mesh using the given column-major rotation matrix.

impl<S, T> Rotated<T> for S where
    T: BaseFloat,
    S: Rotate<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, M> Scale<T> for M where
    T: BaseFloat,
    M: VertexPositions<Element = [T; 3]>, 
[src]

pub fn scale(&mut Self, [T; 3])[src]

Scale a mesh in 3D by a given vector of scale factors. s = [1.0; 3] corresponds to a noop.

impl<S, T> Scaled<T> for S where
    T: Copy,
    S: Scale<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, M> Translate<T> for M where
    T: BaseFloat,
    M: VertexPositions<Element = [T; 3]>, 
[src]

pub fn translate(&mut Self, [T; 3])[src]

Translate the mesh by the given translation vector (displacement) t.

impl<S, T> Translated<T> for S where
    S: Translate<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<M, T> VertexMesh<T> for M where
    T: Real,
    M: Attrib + VertexAttrib + NumVertices + VertexPositions<Element = [T; 3]>, 
[src]