Struct ArcView

Source
pub struct ArcView<M, G>
where M: Reborrow, M::Target: AsStorage<ArcPayload<G>>, G: Geometry,
{ /* private fields */ }
Expand description

View of an arc.

Provides traversals, queries, and mutations related to arcs in a graph. See the module documentation for more information about topological views.

Arcs provide the connectivity information within a MeshGraph and are the primary mechanism for traversing its topology. Moreover, most edge-like operations are exposed by arcs, because they are directed and therefore can emit deterministic results (unlike true edges).

§Examples

Traversing a graph of a cube via its arcs to find an opposing face:

use plexus::graph::MeshGraph;
use plexus::prelude::*;
use plexus::primitive::cube::Cube;
use plexus::primitive::index::HashIndexer;

let mut graph = Cube::new()
    .polygons_with_position()
    .collect_with_indexer::<MeshGraph<Triplet<_>>, _>(HashIndexer::default())
    .unwrap();

let face = graph.faces().nth(0).unwrap();
let opposite = face
    .into_arc()
    .into_opposite_arc()
    .into_next_arc()
    .into_next_arc()
    .into_opposite_arc()
    .into_face()
    .unwrap();

Implementations§

Source§

impl<'a, M, G> ArcView<&'a mut M, G>
where M: 'a + AsStorage<ArcPayload<G>> + AsStorageMut<ArcPayload<G>>, G: 'a + Geometry,

Source

pub fn into_orphan(self) -> OrphanArcView<'a, G>

Converts a mutable view into an orphan view.

Source

pub fn into_ref(self) -> ArcView<&'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::Point2;
use plexus::graph::MeshGraph;
use plexus::prelude::*;

let mut graph = MeshGraph::<Point2<f32>>::from_raw_buffers_with_arity(
    vec![0u32, 1, 2, 3],
    vec![(0.0, 0.0), (1.0, 0.0), (1.0, 1.0), (0.0, 1.0)],
    4,
)
.unwrap();
let key = graph
    .arcs()
    .find(|arc| arc.is_boundary_arc())
    .unwrap()
    .key();
let arc = graph.arc_mut(key).unwrap().extrude(1.0).unwrap().into_ref();

// This would not be possible without conversion into an immutable view.
let _ = arc.into_next_arc().into_next_arc().into_face();
let _ = arc.into_opposite_arc().into_face();
Source

pub fn with_ref<T, K, F>(self, f: F) -> Either<Result<T, GraphError>, Self>
where T: FromKeyedSource<(K, &'a mut M)>, F: FnOnce(ArcView<&M, G>) -> Option<K>,

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> ArcView<M, G>
where M: Reborrow, M::Target: AsStorage<ArcPayload<G>>, G: Geometry,

Source

pub fn key(&self) -> ArcKey

Gets the key for the arc.

Source

pub fn is_boundary_arc(&self) -> bool

Returns true if this is a boundary arc.

A boundary arc has no associated face.

Source§

impl<M, G> ArcView<M, G>
where M: Reborrow, M::Target: AsStorage<ArcPayload<G>> + Consistent, G: Geometry,

Source

pub fn into_interior_path(self) -> InteriorPathView<M, G>

Converts the arc into its interior path.

Source

pub fn into_boundary_arc(self) -> Option<Self>

Returns the arc if it is a boundary arc, otherwise None.

Source

pub fn into_opposite_arc(self) -> Self

Converts the arc into its opposite arc.

Source

pub fn into_next_arc(self) -> Self

Converts the arc into its next arc.

Source

pub fn into_previous_arc(self) -> Self

Converts the arc into its previous arc.

Source

pub fn interior_path(&self) -> InteriorPathView<&M::Target, G>

Gets the interior path of the arc.

Source

pub fn boundary_arc(&self) -> Option<ArcView<&M::Target, G>>

Returns the same arc if it is a boundary arc, otherwise None.

Source

pub fn opposite_arc(&self) -> ArcView<&M::Target, G>

Gets the opposite arc.

Source

pub fn next_arc(&self) -> ArcView<&M::Target, G>

Gets the next arc.

Source

pub fn previous_arc(&self) -> ArcView<&M::Target, G>

Gets the previous arc.

Source§

impl<M, G> ArcView<M, G>
where M: Reborrow, M::Target: AsStorage<ArcPayload<G>> + AsStorage<VertexPayload<G>> + Consistent, G: Geometry,

Source

pub fn neighborhood(&self) -> ArcNeighborhood

Gets the nieghborhood of the arc.

Source

pub fn into_source_vertex(self) -> VertexView<M, G>

Converts the arc into its source vertex.

Source

pub fn into_destination_vertex(self) -> VertexView<M, G>

Converts the arc into its destination vertex.

Source

pub fn source_vertex(&self) -> VertexView<&M::Target, G>

Gets the source vertex of the arc.

Source

pub fn destination_vertex(&self) -> VertexView<&M::Target, G>

Gets the destination vertex of the arc.

Source§

impl<M, G> ArcView<M, G>
where M: Reborrow, M::Target: AsStorage<ArcPayload<G>> + AsStorage<EdgePayload<G>> + Consistent, G: Geometry,

Source

pub fn into_edge(self) -> EdgeView<M, G>

Converts the arc into its edge.

Source

pub fn edge(&self) -> EdgeView<&M::Target, G>

Gets the edge of the arc.

Source§

impl<M, G> ArcView<M, G>
where M: Reborrow, M::Target: AsStorage<ArcPayload<G>> + AsStorage<FacePayload<G>> + Consistent, G: Geometry,

Source

pub fn into_face(self) -> Option<FaceView<M, G>>

Converts the arc into its face.

If this is a boundary arc, then None is returned.

Source

pub fn face(&self) -> Option<FaceView<&M::Target, G>>

Gets the face of this arc.

If this is a boundary arc, then None is returned.

Source§

impl<M, G> ArcView<M, G>
where M: Reborrow, M::Target: AsStorage<ArcPayload<G>> + AsStorage<VertexPayload<G>> + Consistent, G: Geometry,

Source

pub fn vertices( &self, ) -> impl Clone + Iterator<Item = VertexView<&M::Target, G>>

Gets an iterator of views over the vertices connected by the arc.

Source§

impl<M, G> ArcView<M, G>
where M: Reborrow + ReborrowMut, M::Target: AsStorage<ArcPayload<G>> + AsStorage<VertexPayload<G>> + AsStorageMut<VertexPayload<G>> + Consistent, G: Geometry,

Source

pub fn orphan_vertices( &mut self, ) -> impl Iterator<Item = OrphanVertexView<'_, G>>

Gets an iterator of orphan views over the vertices connected by the arc.

Source§

impl<M, G> ArcView<M, G>
where M: Reborrow, M::Target: AsStorage<ArcPayload<G>> + AsStorage<FacePayload<G>> + Consistent, G: Geometry,

Source

pub fn faces(&self) -> impl Clone + Iterator<Item = FaceView<&M::Target, G>>

Gets an iterator of views over the faces connected to the arc.

Source§

impl<M, G> ArcView<M, G>
where M: Reborrow + ReborrowMut, M::Target: AsStorage<ArcPayload<G>> + AsStorage<FacePayload<G>> + AsStorageMut<FacePayload<G>> + Consistent, G: Geometry,

Source

pub fn orphan_faces(&mut self) -> impl Iterator<Item = OrphanFaceView<'_, G>>

Gets an iterator of orphan views over the faces connected to the arc.

Source§

impl<'a, M, G> ArcView<&'a mut M, G>
where M: AsStorage<ArcPayload<G>> + AsStorage<EdgePayload<G>> + AsStorage<FacePayload<G>> + AsStorage<VertexPayload<G>> + Default + Mutable<G>, G: 'a + Geometry,

Source

pub fn split_with<F>(self, f: F) -> VertexView<&'a mut M, G>
where F: FnOnce() -> G::Vertex,

Splits an edge (and its arcs) into two neighboring edges that share a vertex.

Splitting inserts a new vertex with the geometry provided by the given function. The leading arc of the inserted vertex will be one half of the arc that initiated the split and therefore will be part of the same interior path.

Returns the inserted vertex.

§Examples

Split an edge in a graph with weighted vertices:

use plexus::geometry::Geometry;
use plexus::graph::MeshGraph;
use plexus::prelude::*;
use plexus::primitive::Triangle;

pub enum Weight {}

impl Geometry for Weight {
    type Vertex = f64;
    type Arc = ();
    type Edge = ();
    type Face = ();
}

let mut graph = MeshGraph::<Weight>::from_raw_buffers(
    vec![Triangle::new(0usize, 1, 2)],
    vec![1.0, 2.0, 0.5],
)
.unwrap();
let key = graph.arcs().nth(0).unwrap().key();
let vertex = graph.arc_mut(key).unwrap().split_with(|| 0.1);
Source

pub fn split_at_midpoint(self) -> VertexView<&'a mut M, G>
where G: EdgeMidpoint<Midpoint = VertexPosition<G>>, G::Vertex: AsPosition,

Splits an edge (and its arcs) at the midpoint of the arc’s vertices.

Splitting inserts a new vertex with the geometry of the arc’s source vertex but modified such that the positional data of the vertex is the computed midpoint of both of the arc’s vertices. The leading arc of the inserted vertex will be one half of the arc that initiated the split and therefore will be part of the same interior path.

This function is only available if a graph’s geometry exposes positional data in its vertices and that data supports interpolation. See the geometry module.

Returns the inserted vertex.

§Examples

Split an edge in a triangle at its midpoint:

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

let mut graph = MeshGraph::<Point2<f64>>::from_raw_buffers(
    vec![Triangle::new(0usize, 1, 2)],
    vec![(0.0, 0.0), (1.0, 0.0), (0.0, 1.0)],
)
.unwrap();
let key = graph.arcs().nth(0).unwrap().key();
let vertex = graph.arc_mut(key).unwrap().split_at_midpoint();
Source

pub fn bridge( self, destination: Selector<ArcKey>, ) -> Result<FaceView<&'a mut M, G>, GraphError>

Connects a boundary arc to another boundary arc with a face.

Bridging arcs inserts a new face and, as needed, new arcs and edges. The inserted face is always a quadrilateral. The bridged arcs must be boundary arcs with an orientation that allows them to form an interior path.

Arcs can be bridged within an interior path. The destination arc can be chosen by key or index, where an index selects the nth arc from the source arc within the interior path.

Returns the inserted face if successful.

§Errors

Returns an error if the destination arc cannot be found, either arc is not a boundary arc, or the orientation of the destination arc is incompatible.

§Examples

Bridging two disjoint quadrilaterals together:

use nalgebra::Point2;
use plexus::geometry::convert::IntoGeometry;
use plexus::geometry::Geometry;
use plexus::graph::{MeshGraph, VertexKey, VertexView};
use plexus::prelude::*;
use plexus::primitive::Quad;

fn find<'a, I, T, G>(input: I, geometry: T) -> Option<VertexKey>
where
    I: IntoIterator<Item = VertexView<&'a MeshGraph<G>, G>>,
    T: Copy + IntoGeometry<G::Vertex>,
    G: 'a + Geometry,
    G::Vertex: PartialEq,
{
    input
        .into_iter()
        .find(|vertex| vertex.geometry == geometry.into_geometry())
        .map(|vertex| vertex.key())
}

let mut graph = MeshGraph::<Point2<f64>>::from_raw_buffers(
    vec![Quad::new(0usize, 1, 2, 3), Quad::new(4, 5, 6, 7)],
    vec![
        (-2.0, 0.0),
        (-1.0, 0.0), // b
        (-1.0, 1.0), // a
        (-2.0, 1.0),
        (1.0, 0.0), // c
        (2.0, 0.0),
        (2.0, 1.0),
        (1.0, 1.0), // d
    ],
)
.unwrap();
let a = find(graph.vertices(), (-1.0, 1.0)).unwrap();
let b = find(graph.vertices(), (-1.0, 0.0)).unwrap();
let c = find(graph.vertices(), (1.0, 0.0)).unwrap();
let d = find(graph.vertices(), (1.0, 1.0)).unwrap();
let face = graph
    .arc_mut((a, b).into())
    .unwrap()
    .bridge(ByKey((c, d).into()))
    .unwrap();
Source

pub fn extrude<T>( self, distance: T, ) -> Result<ArcView<&'a mut M, G>, GraphError>

Extrudes a boundary arc along its normal.

Extrusion inserts a new edge (and arcs) with the same geometry as the initiating arc, but modifies the positional geometry of the new edge’s vertices such that they extend geometrically along the normal of the originating arc. The originating arc is then bridged with an arc in the opposing edge. This inserts a quadrilateral face. See bridge.

An arc’s normal is perpendicular to the arc and also coplanar with the arc and one of its neighbors. This is computed via a projection.

Returns the opposing arc. This is the arc in the destination edge that is within the same interior path as the initiating arc.

§Errors

Returns an error if the arc is not a boundary arc.

§Examples

Extrude an exterior arc of a quadrilateral.

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

let mut graph = MeshGraph::<Point2<f64>>::from_raw_buffers_with_arity(
    vec![0usize, 1, 2, 3],
    vec![(0.0, 0.0), (1.0, 0.0), (1.0, 1.0), (0.0, 1.0)],
    4,
)
.unwrap();
let key = graph
    .arcs()
    .find(|arc| arc.is_boundary_arc())
    .map(|arc| arc.key())
    .unwrap();
graph.arc_mut(key).unwrap().extrude(1.0).unwrap();
Source

pub fn remove(self) -> VertexView<&'a mut M, G>

Removes the arc, its opposite arc, and edge.

Any and all dependent topology is also removed, such as connected faces, vertices with no remaining leading arc, etc.

Returns the source vertex of the initiating arc.

Source§

impl<M, G> ArcView<M, G>
where M: Reborrow, M::Target: AsStorage<ArcPayload<G>> + AsStorage<FacePayload<G>> + AsStorage<VertexPayload<G>> + Consistent, G: Geometry + ArcNormal,

Source

pub fn normal(&self) -> Result<G::Normal, GraphError>

Trait Implementations§

Source§

impl<M, G> Clone for ArcView<M, G>
where M: Clone + Reborrow, M::Target: AsStorage<ArcPayload<G>>, G: Geometry,

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<M, G> Deref for ArcView<M, G>
where M: Reborrow, M::Target: AsStorage<ArcPayload<G>>, G: Geometry,

Source§

type Target = ArcPayload<G>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<M, G> DerefMut for ArcView<M, G>
where M: Reborrow + ReborrowMut, M::Target: AsStorage<ArcPayload<G>> + AsStorageMut<ArcPayload<G>>, G: Geometry,

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<M, G> From<ArcView<M, G>> for ArcNeighborhood
where M: Reborrow, M::Target: AsStorage<ArcPayload<G>> + AsStorage<VertexPayload<G>> + Consistent, G: Geometry,

Source§

fn from(arc: ArcView<M, G>) -> Self

Converts to this type from the input type.
Source§

impl<M, G> Copy for ArcView<M, G>
where M: Copy + Reborrow, M::Target: AsStorage<ArcPayload<G>>, G: Geometry,

Auto Trait Implementations§

§

impl<M, G> Freeze for ArcView<M, G>
where M: Freeze,

§

impl<M, G> RefUnwindSafe for ArcView<M, G>

§

impl<M, G> Send for ArcView<M, G>
where M: Send, G: Send,

§

impl<M, G> Sync for ArcView<M, G>
where M: Sync, G: Sync,

§

impl<M, G> Unpin for ArcView<M, G>
where M: Unpin, G: Unpin,

§

impl<M, G> UnwindSafe for ArcView<M, G>
where M: UnwindSafe, G: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromGeometry<T> for T

Source§

fn from_geometry(other: T) -> T

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T, U> IntoGeometry<U> for T
where U: FromGeometry<T>,

Source§

fn into_geometry(self) -> U

Source§

impl<T, U> IntoInteriorGeometry<U> for T

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

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

fn is_in_subset(&self) -> bool

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

unsafe fn to_subset_unchecked(&self) -> SS

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

fn from_subset(element: &SS) -> SP

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

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.