logo
pub struct FaceView<B> where
    B: Reborrow,
    B::Target: AsStorage<Face<<B as Parametric>::Data>> + Parametric, 
{ /* private fields */ }
Expand description

View of a face entity.

Faces are notated by the path of their associated ring. A triangular face with a perimeter formed by vertices $A$, $B$, and $C$ is notated $\overrightarrow{\{A,B,C\}}$. While the precise ordering of vertices is determined by a face’s leading arc, the same face may be notated using rotations of this set, such as $\overrightarrow{\{B,C,A\}}$.

See the graph module documentation for more information about views.

Implementations

Examples
use decorum::R64;
use nalgebra::Point3;
use plexus::graph::MeshGraph;
use plexus::prelude::*;
use plexus::primitive::cube::Cube;
use plexus::primitive::generate::Position;

type E3 = Point3<R64>;

let mut graph: MeshGraph<E3> = Cube::new().polygons::<Position<E3>>().collect();
let key = graph.faces().nth(0).unwrap().key();
let face = graph
    .face_mut(key)
    .unwrap()
    .extrude_with_offset(1.0)
    .unwrap()
    .into_ref();

// This would not be possible without conversion into an immutable view.
let _ = face.into_arc();
let _ = face.into_arc().into_next_arc();
This impl block contains no items.

Reachable API.

Converts the face into its ring.

Converts the face into its leading arc.

Gets the ring of the face.

Gets the leading arc of the face.

Flattens the face by translating the positions of all vertices into a best-fit plane.

Errors

Returns an error if a best-fit plane could not be computed or positions could not be translated into the plane.

Gets an iterator of views over the arcs in the face’s ring.

Gets an iterator of views over adjacent faces.

Gets an iterator of views over the vertices that form the face.

Gets an iterator of orphan views over the arcs in the face’s ring.

Gets an iterator of orphan views over adjacent faces.

Gets an iterator of orphan views over the vertices that form the face.

Gets an iterator that traverses adjacent faces by breadth.

The traversal moves from the face to its adjacent faces and so on. If there are disjoint sub-graphs in the graph, then a traversal will not reach every face in the graph.

Gets an iterator that traverses adjacent faces by depth.

The traversal moves from the face to its adjacent faces and so on. If there are disjoint sub-graphs in the graph, then a traversal will not reach every face in the graph.

Splits the face by bisecting it with a composite edge inserted between two non-adjacent vertices within the face’s perimeter.

The vertices can be chosen by key or index, where index selects the $n^\text{th}$ vertex within the face’s ring.

Returns the arc inserted from the source vertex to the destination vertex. If a face $\overrightarrow{\{A,B, C,D\}}$ is split from $A$ to $C$, then it will be decomposed into faces in the rings $\overrightarrow{\{A,B,C\}}$ and $\overrightarrow{\{C,D,A\}}$ and the arc $\overrightarrow{AC}$ will be returned.

Errors

Returns an error if either of the given vertices cannot be found, are not within the face’s perimeter, or the distance between the vertices along the ring is less than two.

Examples

Splitting a quadrilateral face:

use nalgebra::Point2;
use plexus::graph::MeshGraph;
use plexus::prelude::*;
use plexus::primitive::Tetragon;

let mut graph = MeshGraph::<Point2<f64>>::from_raw_buffers(
    vec![Tetragon::new(0usize, 1, 2, 3)],
    vec![(0.0, 0.0), (1.0, 0.0), (1.0, 1.0), (0.0, 1.0)],
)
.unwrap();
let key = graph.faces().nth(0).unwrap().key();
let arc = graph
    .face_mut(key)
    .unwrap()
    .split(ByIndex(0), ByIndex(2))
    .unwrap()
    .into_ref();

Merges the face into an adjacent face over a shared edge.

The adjacent face can be chosen by key or index, where index selects the $n^\text{th}$ adjacent face.

Returns the merged face.

Errors

Returns an error if the destination face cannot be found or is not adjacent to the initiating face.

Examples

Merging two adjacent quadrilateral faces:

use nalgebra::Point2;
use plexus::graph::MeshGraph;
use plexus::prelude::*;
use plexus::primitive::Tetragon;

let mut graph = MeshGraph::<Point2<f64>>::from_raw_buffers(
    vec![Tetragon::new(0usize, 1, 2, 3), Tetragon::new(0, 3, 4, 5)],
    vec![
        (0.0, 0.0),  // 0
        (1.0, 0.0),  // 1
        (1.0, 1.0),  // 2
        (0.0, 1.0),  // 3
        (-1.0, 1.0), // 4
        (-1.0, 0.0), // 5
    ],
)
.unwrap();

let key = graph.faces().nth(0).unwrap().key();
let face = graph
    .face_mut(key)
    .unwrap()
    .merge(ByIndex(0))
    .unwrap()
    .into_ref();

Connects faces with equal arity with faces inserted along their perimeters.

The inserted faces are always quadrilateral. Both the initiating face and destination face are removed.

Errors

Returns an error if the destination face cannot be found or the arity of the face and its destination are not the same.

Decomposes the face into triangles. Does nothing if the face is triangular.

Returns the terminating face of the decomposition.

Subdivides the face about a vertex. A triangle fan is formed from each arc in the face’s perimeter and the vertex.

Poking inserts a new vertex with data provided by the given function.

Returns the inserted vertex.

Examples

Forming a pyramid from a triangular face:

use nalgebra::Point3;
use plexus::geometry::{AsPosition, AsPositionMut};
use plexus::graph::MeshGraph;
use plexus::prelude::*;
use plexus::primitive::Trigon;

let mut graph = MeshGraph::<Point3<f64>>::from_raw_buffers(
    vec![Trigon::new(0usize, 1, 2)],
    vec![(-1.0, 0.0, 0.0), (1.0, 0.0, 0.0), (0.0, 2.0, 0.0)],
)
.unwrap();
let key = graph.faces().nth(0).unwrap().key();
let mut face = graph.face_mut(key).unwrap();

// See also `poke_with_offset`, which provides this functionality.
let position = face.centroid() + face.normal().unwrap();
face.poke_with(move || position);

Subdivides the face about its centroid. A triangle fan is formed from each arc in the face’s perimeter and a vertex inserted at the centroid.

Returns the inserted vertex.

Subdivides the face about its centroid. A triangle fan is formed from each arc in the face’s perimeter and a vertex inserted at the centroid. The inserted vertex is then translated along the initiating face’s normal by the given offset.

Returns the inserted vertex.

Errors

Returns an error if the geometry could not be computed.

Examples

Constructing a “spikey” sphere:

use decorum::R64;
use nalgebra::Point3;
use plexus::graph::MeshGraph;
use plexus::prelude::*;
use plexus::primitive::generate::Position;
use plexus::primitive::sphere::UvSphere;

type E3 = Point3<R64>;

let mut graph: MeshGraph<E3> = UvSphere::new(16, 8).polygons::<Position<E3>>().collect();
let keys = graph.faces().map(|face| face.key()).collect::<Vec<_>>();
for key in keys {
    graph.face_mut(key).unwrap().poke_with_offset(0.5).unwrap();
}

Extrudes the face along its normal.

Returns the extruded face.

Errors

Returns an error if the geometry could not be computed.

Extrudes the face along a translation.

Returns the extruded face.

Extrudes a face using the given vertex data.

Returns the extruded face.

Removes the face.

Returns the remaining ring of the face if it is not entirely disjoint, otherwise None.

Trait Implementations

Immutably borrows from an owned value. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Gets the key for the face.

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

Gets the arity of the face. This is the number of arcs that form the face’s ring.

Converts to this type from the input type.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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.

Should always be Self

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

Checks if self is actually part of its subset T (and can be converted to it).

Use with care! Same as self.to_subset but without any property checks. Always succeeds.

The inclusion map: converts self to the equivalent element of its superset.

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.