pub struct FaceView<M, G>where
M: Reborrow,
M::Target: AsStorage<FacePayload<G>>,
G: Geometry,{ /* private fields */ }
Expand description
View of a face.
Provides traversals, queries, and mutations related to faces in a graph. See the module documentation for more information about topological views.
Implementations§
Source§impl<'a, M, G> FaceView<&'a mut M, G>
impl<'a, M, G> FaceView<&'a mut M, G>
Sourcepub fn into_orphan(self) -> OrphanFaceView<'a, G>
pub fn into_orphan(self) -> OrphanFaceView<'a, G>
Converts a mutable view into an orphan view.
Sourcepub fn into_ref(self) -> FaceView<&'a M, G>
pub fn into_ref(self) -> FaceView<&'a M, G>
Converts a mutable view into an immutable view.
This is useful when mutations are not (or no longer) needed and mutual access is desired.
§Examples
use nalgebra::Point3;
use plexus::graph::MeshGraph;
use plexus::prelude::*;
use plexus::primitive::cube::Cube;
let mut graph = Cube::new()
.polygons_with_position()
.collect::<MeshGraph<Point3<f32>>>();
let key = graph.faces().nth(0).unwrap().key();
let face = graph
.face_mut(key)
.unwrap()
.extrude(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();
Sourcepub fn with_ref<T, K, F>(self, f: F) -> Either<Result<T, GraphError>, Self>
pub fn with_ref<T, K, F>(self, f: F) -> Either<Result<T, GraphError>, Self>
Reborrows the view and constructs another mutable view from a given key.
This allows for fallible traversals from a mutable view without the
need for direct access to the source MeshGraph
. If the given function
emits a key, then that key will be used to convert this view into
another. If no key is emitted, then the original mutable view is
returned.
Source§impl<M, G> FaceView<M, G>where
M: Reborrow,
M::Target: AsStorage<FacePayload<G>>,
G: Geometry,
impl<M, G> FaceView<M, G>where
M: Reborrow,
M::Target: AsStorage<FacePayload<G>>,
G: Geometry,
Source§impl<M, G> FaceView<M, G>where
M: Reborrow,
M::Target: AsStorage<ArcPayload<G>> + AsStorage<FacePayload<G>> + Consistent,
G: Geometry,
impl<M, G> FaceView<M, G>where
M: Reborrow,
M::Target: AsStorage<ArcPayload<G>> + AsStorage<FacePayload<G>> + Consistent,
G: Geometry,
Sourcepub fn into_interior_path(self) -> InteriorPathView<M, G>
pub fn into_interior_path(self) -> InteriorPathView<M, G>
Converts the face into its interior path.
Sourcepub fn interior_path(&self) -> InteriorPathView<&M::Target, G>
pub fn interior_path(&self) -> InteriorPathView<&M::Target, G>
Gets the interior path of the face.
Sourcepub fn interior_arcs(
&self,
) -> impl Clone + Iterator<Item = ArcView<&M::Target, G>>
pub fn interior_arcs( &self, ) -> impl Clone + Iterator<Item = ArcView<&M::Target, G>>
Gets an iterator of views over the arcs in the face’s interior path.
Sourcepub fn neighboring_faces(
&self,
) -> impl Clone + Iterator<Item = FaceView<&M::Target, G>>
pub fn neighboring_faces( &self, ) -> impl Clone + Iterator<Item = FaceView<&M::Target, G>>
Gets an iterator of views over neighboring faces.
Source§impl<M, G> FaceView<M, G>where
M: Reborrow,
M::Target: AsStorage<ArcPayload<G>> + AsStorage<FacePayload<G>> + AsStorage<VertexPayload<G>> + Consistent,
G: Geometry,
impl<M, G> FaceView<M, G>where
M: Reborrow,
M::Target: AsStorage<ArcPayload<G>> + AsStorage<FacePayload<G>> + AsStorage<VertexPayload<G>> + Consistent,
G: Geometry,
pub fn neighborhood(&self) -> FaceNeighborhood
Sourcepub fn vertices(
&self,
) -> impl Clone + Iterator<Item = VertexView<&M::Target, G>>
pub fn vertices( &self, ) -> impl Clone + Iterator<Item = VertexView<&M::Target, G>>
Gets an iterator of views over the vertices that form the face.
Source§impl<M, G> FaceView<M, G>where
M: Reborrow + ReborrowMut,
M::Target: AsStorage<ArcPayload<G>> + AsStorageMut<ArcPayload<G>> + AsStorage<FacePayload<G>> + Consistent,
G: Geometry,
impl<M, G> FaceView<M, G>where
M: Reborrow + ReborrowMut,
M::Target: AsStorage<ArcPayload<G>> + AsStorageMut<ArcPayload<G>> + AsStorage<FacePayload<G>> + Consistent,
G: Geometry,
Sourcepub fn interior_orphan_arcs(
&mut self,
) -> impl Iterator<Item = OrphanArcView<'_, G>>
pub fn interior_orphan_arcs( &mut self, ) -> impl Iterator<Item = OrphanArcView<'_, G>>
Gets an iterator of orphan views over the arcs in the face’s interior path.
Source§impl<M, G> FaceView<M, G>where
M: Reborrow + ReborrowMut,
M::Target: AsStorage<ArcPayload<G>> + AsStorage<FacePayload<G>> + AsStorageMut<FacePayload<G>> + Consistent,
G: Geometry,
impl<M, G> FaceView<M, G>where
M: Reborrow + ReborrowMut,
M::Target: AsStorage<ArcPayload<G>> + AsStorage<FacePayload<G>> + AsStorageMut<FacePayload<G>> + Consistent,
G: Geometry,
Sourcepub fn neighboring_orphan_faces(
&mut self,
) -> impl Iterator<Item = OrphanFaceView<'_, G>>
pub fn neighboring_orphan_faces( &mut self, ) -> impl Iterator<Item = OrphanFaceView<'_, G>>
Gets an iterator of orphan views over neighboring faces.
Source§impl<M, G> FaceView<M, G>where
M: Reborrow + ReborrowMut,
M::Target: AsStorage<ArcPayload<G>> + AsStorage<FacePayload<G>> + AsStorage<VertexPayload<G>> + AsStorageMut<VertexPayload<G>> + Consistent,
G: Geometry,
impl<M, G> FaceView<M, G>where
M: Reborrow + ReborrowMut,
M::Target: AsStorage<ArcPayload<G>> + AsStorage<FacePayload<G>> + AsStorage<VertexPayload<G>> + AsStorageMut<VertexPayload<G>> + Consistent,
G: Geometry,
Sourcepub fn orphan_vertices(
&mut self,
) -> impl Iterator<Item = OrphanVertexView<'_, G>>
pub fn orphan_vertices( &mut self, ) -> impl Iterator<Item = OrphanVertexView<'_, G>>
Gets an iterator of orphan views over the vertices that form the face.
Source§impl<'a, M, G> FaceView<&'a mut M, G>where
M: AsStorage<ArcPayload<G>> + AsStorage<EdgePayload<G>> + AsStorage<FacePayload<G>> + AsStorage<VertexPayload<G>> + Default + Mutable<G>,
G: 'a + Geometry,
impl<'a, M, G> FaceView<&'a mut M, G>where
M: AsStorage<ArcPayload<G>> + AsStorage<EdgePayload<G>> + AsStorage<FacePayload<G>> + AsStorage<VertexPayload<G>> + Default + Mutable<G>,
G: 'a + Geometry,
Sourcepub fn split(
self,
source: Selector<VertexKey>,
destination: Selector<VertexKey>,
) -> Result<ArcView<&'a mut M, G>, GraphError>
pub fn split( self, source: Selector<VertexKey>, destination: Selector<VertexKey>, ) -> Result<ArcView<&'a mut M, G>, GraphError>
Splits the face by bisecting it with an edge (and arcs) inserted between two non-neighboring vertices within the face’s perimeter.
The vertices can be chosen by key or index, where index selects the nth vertex within the face’s interior path.
This can be thought of as the opposite of merge
.
Returns the inserted arc that spans from the source vertex to the destination vertex if successful.
§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 interior path is less than two.
§Examples
Splitting a quadrilateral face:
use nalgebra::Point2;
use plexus::graph::MeshGraph;
use plexus::prelude::*;
use plexus::primitive::Quad;
let mut graph = MeshGraph::<Point2<f64>>::from_raw_buffers(
vec![Quad::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();
Sourcepub fn merge(self, destination: Selector<FaceKey>) -> Result<Self, GraphError>
pub fn merge(self, destination: Selector<FaceKey>) -> Result<Self, GraphError>
Merges the face into a neighboring face over their shared edge (and arcs).
The neighboring face can be chosen by key or index, where index selects the nth neighbor of the face.
This can be thought of as the opposite of split
.
Returns the merged face if successful.
§Errors
Returns an error if the destination face cannot be found or is not a neighbor of the initiating face.
§Examples
Merging two neighboring quadrilateral faces:
use nalgebra::Point2;
use plexus::graph::MeshGraph;
use plexus::prelude::*;
use plexus::primitive::Quad;
let mut graph = MeshGraph::<Point2<f32>>::from_raw_buffers(
vec![Quad::new(0usize, 1, 2, 3), Quad::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();
Sourcepub fn bridge(self, destination: FaceKey) -> Result<(), GraphError>
pub fn bridge(self, destination: FaceKey) -> Result<(), GraphError>
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.
Sourcepub fn triangulate(self) -> Self
pub fn triangulate(self) -> Self
Decomposes the face into triangles. Does nothing if the face is triangular.
Returns the terminating face of the decomposition.
Sourcepub fn poke_with<F>(self, f: F) -> VertexView<&'a mut M, G>
pub fn poke_with<F>(self, f: F) -> VertexView<&'a mut M, G>
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 geometry provided by the given function.
Returns the inserted vertex.
Sourcepub fn poke_at_centroid(self) -> VertexView<&'a mut M, G>
pub fn poke_at_centroid(self) -> VertexView<&'a mut M, G>
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.
§Examples
Forming a baseless triangular pyramid from a face:
use nalgebra::Point3;
use plexus::geometry::convert::AsPosition;
use plexus::graph::MeshGraph;
use plexus::prelude::*;
use plexus::primitive::Triangle;
let mut graph = MeshGraph::<Point3<f64>>::from_raw_buffers(
vec![Triangle::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();
// Use the face's normal to translate the vertex from the centroid.
let normal = face.normal();
let mut vertex = face.poke_at_centroid();
let position = vertex.geometry.as_position() + (normal * 2.0);
*vertex.geometry.as_position_mut() = position;
pub fn extrude<T>(
self,
distance: T,
) -> Result<FaceView<&'a mut M, G>, GraphError>where
G: FaceNormal,
G::Normal: Mul<T>,
G::Vertex: AsPosition,
ScaledFaceNormal<G, T>: Clone,
VertexPosition<G>: Add<ScaledFaceNormal<G, T>, Output = VertexPosition<G>> + Clone,
Sourcepub fn remove(self) -> InteriorPathView<&'a mut M, G>
pub fn remove(self) -> InteriorPathView<&'a mut M, G>
Removes the face.
Returns the interior path of the face.
Source§impl<M, G> FaceView<M, G>where
M: Reborrow,
M::Target: AsStorage<ArcPayload<G>> + AsStorage<FacePayload<G>> + AsStorage<VertexPayload<G>> + Consistent,
G: FaceCentroid + Geometry,
impl<M, G> FaceView<M, G>where
M: Reborrow,
M::Target: AsStorage<ArcPayload<G>> + AsStorage<FacePayload<G>> + AsStorage<VertexPayload<G>> + Consistent,
G: FaceCentroid + Geometry,
Source§impl<M, G> FaceView<M, G>where
M: Reborrow,
M::Target: AsStorage<ArcPayload<G>> + AsStorage<FacePayload<G>> + AsStorage<VertexPayload<G>> + Consistent,
G: FaceNormal + Geometry,
impl<M, G> FaceView<M, G>where
M: Reborrow,
M::Target: AsStorage<ArcPayload<G>> + AsStorage<FacePayload<G>> + AsStorage<VertexPayload<G>> + Consistent,
G: FaceNormal + Geometry,
Trait Implementations§
Source§impl<M, G> Deref for FaceView<M, G>where
M: Reborrow,
M::Target: AsStorage<FacePayload<G>>,
G: Geometry,
impl<M, G> Deref for FaceView<M, G>where
M: Reborrow,
M::Target: AsStorage<FacePayload<G>>,
G: Geometry,
Source§impl<M, G> DerefMut for FaceView<M, G>where
M: Reborrow + ReborrowMut,
M::Target: AsStorage<FacePayload<G>> + AsStorageMut<FacePayload<G>>,
G: Geometry,
impl<M, G> DerefMut for FaceView<M, G>where
M: Reborrow + ReborrowMut,
M::Target: AsStorage<FacePayload<G>> + AsStorageMut<FacePayload<G>>,
G: Geometry,
Source§impl<M, G> From<FaceView<M, G>> for FaceNeighborhoodwhere
M: Reborrow,
M::Target: AsStorage<ArcPayload<G>> + AsStorage<FacePayload<G>> + AsStorage<VertexPayload<G>> + Consistent,
G: Geometry,
impl<M, G> From<FaceView<M, G>> for FaceNeighborhoodwhere
M: Reborrow,
M::Target: AsStorage<ArcPayload<G>> + AsStorage<FacePayload<G>> + AsStorage<VertexPayload<G>> + Consistent,
G: Geometry,
impl<M, G> Copy for FaceView<M, G>
Auto Trait Implementations§
impl<M, G> Freeze for FaceView<M, G>where
M: Freeze,
impl<M, G> RefUnwindSafe for FaceView<M, G>where
M: RefUnwindSafe,
G: RefUnwindSafe,
impl<M, G> Send for FaceView<M, G>
impl<M, G> Sync for FaceView<M, G>
impl<M, G> Unpin for FaceView<M, G>
impl<M, G> UnwindSafe for FaceView<M, G>where
M: UnwindSafe,
G: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FromGeometry<T> for T
impl<T> FromGeometry<T> for T
fn from_geometry(other: T) -> T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T, U> IntoGeometry<U> for Twhere
U: FromGeometry<T>,
impl<T, U> IntoGeometry<U> for Twhere
U: FromGeometry<T>,
fn into_geometry(self) -> U
Source§impl<T, U> IntoInteriorGeometry<U> for Twhere
U: FromInteriorGeometry<T>,
impl<T, U> IntoInteriorGeometry<U> for Twhere
U: FromInteriorGeometry<T>,
fn into_interior_geometry(self) -> U
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).Source§unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.