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§

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]]),
    )
);

complete constructor

Panics

Panic occurs if there is an index is out of range.

Remarks

This method does not check whether the normal is normalized or not.

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.

constructor without boundary check

constructor, boundary check is acrivated only in debug mode.

Returns attributes

Returns the faces of the polygon.

Returns the vector of all triangles of the polygon.

Returns the vector of all quadrangles.

Returns the vector of n-gons (n > 4).

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

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

Creates an editor that performs boundary checking on dropped.

Creates an editor that does NOT perform boundary checking on dropped.

Creates an editor that performs boundary checking on dropped ONLY in debug build.

Returns polygonmesh merged self and mesh.

Creates the bounding box of the polygon mesh.

Returns the vector of all positions.

Returns the mutable slice of all positions.

Adds a position.

Extend positions by iterator.

Returns the vector of all uv (texture) coordinates.

Returns the mutable slice of all uv (texture) coordinates.

Adds a uv (texture) coordinate.

Extend uv (texture) coordinates by iterator.

Returns the vector of all normals.

Returns the mutable slice of all normals.

Extend normals by iterator

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
If self and other collide, then returns only one interference line. Otherwise, returns None.
Extract all interference lines between self and other. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Deserialize this value from the given Serde deserializer. Read more
Creates a value from an iterator. Read more
Count signed number of faces crossing ray with origin point and direction ray_direction. Counter increase if the dot product of the ray and the normal of a face is positive, and decrease if it is negative. Read more
whether point is in a domain rounded by a closed polygon. Read more
Which kind of iterator are we turning this into?
Creates an iterator from a value.
Inverts self
Returns the inverse.
Normalize all normals and assign None to the nor index of the vertices that has irregular normals. Read more
Makes the orientation of faces compatible to the normal vectors. Read more
Makes the orientation of faces compatible to the normal vectors. Read more
Adds face normals to each vertices. Read more
add the smooth normal vectors to the mesh. Read more
remove all unused position, texture coordinates, and normal vectors. Read more
Removes degenerate polygons. Read more
Gives the same indices to the same positions, texture coordinate, and normal vectors, respectively. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Serialize this value into the given Serde serializer. Read more
Creates a sub mesh by the face indices. Read more
Extracts polygons such that there exists its normal is the same as its face normal. Read more
Splits into the components. Read more
triangulate all n-gons Read more
join two triangles into one quadrangle. Read more
Extended Loop method Read more
Returns a vector of all boundaries as line strip.
Determines the shell conditions: non-regular, regular, oriented, or closed.
The complexity increases in proportion to the number of edges. Read more
Whether all faces of the polygon mesh self has intersection with the neighborhood of point_cloud. Read more
Whether the polygon mesh self and point_cloud collides. Read more
Whether the neighborhood of the polygon mesh self includes point_cloud. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.