# [−][src]Struct plexus::graph::ArcView

pub struct ArcView<M, G> where    M: Reborrow,    M::Target: AsStorage<Arc<G>>,    G: GraphGeometry,  { /* fields omitted */ }

View of an arc in a graph.

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 (this is not true of edges).

An arc from a vertex $A$ to a vertex $B$ is notated $\overrightarrow{AB}$. This is shorthand for the path notation $\overrightarrow{\{A,B\}}$.

# Examples

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

use decorum::N64;
use nalgebra::Point3;
use plexus::graph::MeshGraph;
use plexus::index::HashIndexer;
use plexus::prelude::*;
use plexus::primitive::cube::Cube;
use plexus::primitive::generate::Position;

let mut graph = Cube::new()
.polygons::<Position<Point3<N64>>>()
.collect_with_indexer::<MeshGraph<Point3<N64>>, _>(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();

## Methods

### impl<M, G> ArcView<M, G> where    M: Reborrow,    M::Target: AsStorage<Arc<G>>,    G: GraphGeometry, [src]

#### pub fn key(&self) -> ArcKey[src]

Gets the key for the arc.

#### pub fn is_boundary_arc(&self) -> bool[src]

Returns true if this is a boundary arc.

A boundary arc has no associated face.

### impl<'a, M, G> ArcView<&'a mut M, G> where    M: 'a + AsStorageMut<Arc<G>>,    G: 'a + GraphGeometry, [src]

#### pub fn into_orphan(self) -> ArcOrphan<'a, G>[src]

Converts a mutable view into an orphan view.

#### pub fn into_ref(self) -> ArcView<&'a M, G>[src]

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<f64>>::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();

### impl<M, G> ArcView<M, G> where    M: Reborrow,    M::Target: AsStorage<Arc<G>> + Consistent,    G: GraphGeometry, [src]

#### pub fn into_ring(self) -> RingView<M, G>[src]

Converts the arc into its ring.

#### pub fn into_boundary_arc(self) -> Option<Self>[src]

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

#### pub fn into_opposite_arc(self) -> Self[src]

Converts the arc into its opposite arc.

#### pub fn into_next_arc(self) -> Self[src]

Converts the arc into its next arc.

#### pub fn into_previous_arc(self) -> Self[src]

Converts the arc into its previous arc.

#### pub fn ring(&self) -> RingView<&M::Target, G>[src]

Gets the ring of the arc.

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

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

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

Gets the opposite arc.

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

Gets the next arc.

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

Gets the previous arc.

### impl<M, G> ArcView<M, G> where    M: Reborrow,    M::Target: AsStorage<Arc<G>> + AsStorage<Vertex<G>> + Consistent,    G: GraphGeometry, [src]

#### pub fn into_source_vertex(self) -> VertexView<M, G>[src]

Converts the arc into its source vertex.

#### pub fn into_destination_vertex(self) -> VertexView<M, G>[src]

Converts the arc into its destination vertex.

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

Gets the source vertex of the arc.

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

Gets the destination vertex of the arc.

### impl<M, G> ArcView<M, G> where    M: Reborrow,    M::Target: AsStorage<Arc<G>> + AsStorage<Edge<G>> + Consistent,    G: GraphGeometry, [src]

#### pub fn into_edge(self) -> EdgeView<M, G>[src]

Converts the arc into its edge.

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

Gets the edge of the arc.

### impl<M, G> ArcView<M, G> where    M: Reborrow,    M::Target: AsStorage<Arc<G>> + AsStorage<Face<G>> + Consistent,    G: GraphGeometry, [src]

#### pub fn into_face(self) -> Option<FaceView<M, G>>[src]

Converts the arc into its face.

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

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

Gets the face of this arc.

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

### impl<M, G> ArcView<M, G> where    M: Reborrow,    M::Target: AsStorage<Arc<G>> + AsStorage<Vertex<G>> + Consistent,    G: GraphGeometry, [src]

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

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

### impl<M, G> ArcView<M, G> where    M: ReborrowMut,    M::Target: AsStorage<Arc<G>> + AsStorageMut<Vertex<G>> + Consistent,    G: GraphGeometry, [src]

#### pub fn vertex_orphans(&mut self) -> impl Iterator<Item = VertexOrphan<G>>[src]

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

### impl<M, G> ArcView<M, G> where    M: Reborrow,    M::Target: AsStorage<Arc<G>> + AsStorage<Face<G>> + Consistent,    G: GraphGeometry, [src]

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

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

### impl<M, G> ArcView<M, G> where    M: ReborrowMut,    M::Target: AsStorage<Arc<G>> + AsStorageMut<Face<G>> + Consistent,    G: GraphGeometry, [src]

#### pub fn face_orphans(&mut self) -> impl Iterator<Item = FaceOrphan<G>>[src]

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

### impl<'a, M, G> ArcView<&'a mut M, G> where    M: AsStorage<Arc<G>> + AsStorage<Edge<G>> + AsStorage<Face<G>> + AsStorage<Vertex<G>> + Default + Mutable<G>,    G: 'a + GraphGeometry, [src]

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

Splits a composite edge into two neighboring edges that share a vertex.

Splitting inserts a new vertex with the geometry provided by the given function. Splitting an arc $\overrightarrow{AB}$ returns a vertex $M$ that subdivides the composite edge. The leading arc of $M$ is $\overrightarrow{MB}$ and is a part of the same ring as the initiating arc.

Returns the inserted vertex.

# Examples

Split an edge in a graph with weighted vertices:

use plexus::graph::{GraphGeometry, MeshGraph};
use plexus::prelude::*;
use plexus::primitive::NGon;

pub enum Weight {}

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

let mut graph =
MeshGraph::<Weight>::from_raw_buffers(vec![NGon([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);

#### pub fn split_at_midpoint(self) -> VertexView<&'a mut M, G> where    G: EdgeMidpoint,    G::Vertex: AsPosition, [src]

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.

Splitting inserts a new vertex with the geometry provided by the given function. Splitting an arc $\overrightarrow{AB}$ returns a vertex $M$ that subdivides the composite edge. The leading arc of $M$ is $\overrightarrow{MB}$ and is a part of the same ring as the initiating arc.

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::Trigon;

let mut graph = MeshGraph::<Point2<f64>>::from_raw_buffers(
vec![Trigon::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();

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

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 a ring.

Bridging two compatible arcs $\overrightarrow{AB}$ and $\overrightarrow{CD}$ will result in a ring $\overrightarrow{\{A,B, C,D\}}$.

Arcs can be bridged within a ring. The destination arc can be chosen by key or index, where an index selects the $n^\text{th}$ arc from the source arc within the ring.

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 with the initiating arc.

# Examples

use nalgebra::Point2;
use plexus::graph::{GraphGeometry, MeshGraph, VertexKey, VertexView};
use plexus::prelude::*;
use plexus::primitive::NGon;
use plexus::IntoGeometry;

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 + GraphGeometry,
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![NGon([0usize, 1, 2, 3]), NGon([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();

#### pub fn extrude<T>(self, offset: T) -> Result<ArcView<&'a mut M, G>, GraphError> where    T: Into<Scalar<VertexPosition<G>>>,    G: ArcNormal,    G::Vertex: AsPosition,    VertexPosition<G>: EuclideanSpace, [src]

Extrudes a boundary arc along its normal into a composite edge.

Extrusion inserts a new composite edge with the same geometry as the initiating arc and its composite edge, 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 and supports both 2D and 3D geometries.

Returns the opposing arc. This is the arc in the destination edge that is within the same ring 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();

#### pub fn remove(self) -> Option<VertexView<&'a mut M, G>>[src]

Removes the arc and its composite edge.

Any and all dependent topology is also removed, such as connected faces, disjoint vertices, etc.

Returns the source vertex of the initiating arc or None if that vertex becomes disjoint and is also removed. If an arc $\overrightarrow{AB}$ is removed and its source vertex is not disjoint, then $A$ is returned.

## Trait Implementations

### impl<M, G> Deref for ArcView<M, G> where    M: Reborrow,    M::Target: AsStorage<Arc<G>>,    G: GraphGeometry, [src]

#### type Target = Arc<G>

The resulting type after dereferencing.

## Blanket Implementations

### impl<T> Same<T> for T

#### type Output = T

Should always be Self

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

#### type Owned = T

The resulting type after obtaining ownership.

### 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.