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

pub struct ArcView<B> where
    B: Reborrow,
    B::Target: AsStorage<Arc<<B as Geometric>::Geometry>> + Geometric, 
{ /* fields omitted */ }

View of an arc entity.

Exposes references to an arc entity and provides the primary arc API. An arc from a vertex $A$ to a vertex $B$ is notated $\overrightarrow{AB}$. This is shorthand for the path notation $\overrightarrow{(A,B)}$.

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 emit deterministic results.

See the module documentation for more information about views.

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

Implementations

impl<B, M> ArcView<B> where
    B: Reborrow<Target = M>,
    M: AsStorage<Arc<<B as Geometric>::Geometry>> + Geometric, 
[src]

pub fn to_ref(&self) -> ArcView<&M>[src]

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, B, M, G> ArcView<B> where
    B: ReborrowInto<'a, Target = M>,
    M: AsStorage<Arc<G>> + Geometric<Geometry = G>,
    G: GraphGeometry
[src]

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

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_with_offset(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<B, M, G> ArcView<B> where
    B: Reborrow<Target = M>,
    M: AsStorage<Arc<G>> + Consistent + Geometric<Geometry = G>,
    G: GraphGeometry
[src]

pub fn into_ring(self) -> Ring<B>[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) -> Ring<&M>[src]

Gets the ring of the arc.

pub fn boundary_arc(&self) -> Option<ArcView<&M>>[src]

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

pub fn opposite_arc(&self) -> ArcView<&M>[src]

Gets the opposite arc.

pub fn next_arc(&self) -> ArcView<&M>[src]

Gets the next arc.

pub fn previous_arc(&self) -> ArcView<&M>[src]

Gets the previous arc.

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

pub fn into_path(self) -> Path<B>[src]

pub fn path(&self) -> Path<&M>[src]

pub fn into_source_vertex(self) -> VertexView<B>[src]

Converts the arc into its source vertex.

pub fn into_destination_vertex(self) -> VertexView<B>[src]

Converts the arc into its destination vertex.

pub fn source_vertex(&self) -> VertexView<&M>[src]

Gets the source vertex of the arc.

pub fn destination_vertex(&self) -> VertexView<&M>[src]

Gets the destination vertex of the arc.

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

pub fn into_edge(self) -> EdgeView<B>[src]

Converts the arc into its edge.

pub fn edge(&self) -> EdgeView<&M>[src]

Gets the edge of the arc.

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

pub fn into_face(self) -> Option<FaceView<B>>[src]

Converts the arc into its face.

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

pub fn face(&self) -> Option<FaceView<&M>>[src]

Gets the face of this arc.

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

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

pub fn normal(&self) -> Vector<VertexPosition<G>> where
    G: ArcNormal,
    G::Vertex: AsPosition
[src]

impl<B, M, G> ArcView<B> where
    B: Reborrow<Target = M>,
    M: AsStorage<Arc<G>> + AsStorage<Edge<G>> + AsStorage<Vertex<G>> + Consistent + Geometric<Geometry = G>,
    G: GraphGeometry
[src]

pub fn midpoint(&self) -> VertexPosition<G> where
    G: EdgeMidpoint,
    G::Vertex: AsPosition
[src]

impl<'a, B, M, G> ArcView<B> where
    B: ReborrowInto<'a, Target = M>,
    M: 'a + AsStorage<Arc<G>> + AsStorage<Vertex<G>> + Consistent + Geometric<Geometry = G>,
    G: GraphGeometry
[src]

pub fn into_adjacent_vertices(
    self
) -> impl Clone + ExactSizeIterator<Item = VertexView<&'a M>>
[src]

impl<B, G> ArcView<B> where
    B: Reborrow,
    B::Target: AsStorage<Arc<G>> + AsStorage<Vertex<G>> + Consistent + Geometric<Geometry = G>,
    G: GraphGeometry
[src]

pub fn adjacent_vertices(
    &self
) -> impl Clone + ExactSizeIterator<Item = VertexView<&B::Target>>
[src]

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

impl<'a, B, M, G> ArcView<B> where
    B: ReborrowInto<'a, Target = M>,
    M: 'a + AsStorage<Arc<G>> + AsStorage<Face<G>> + Consistent + Geometric<Geometry = G>,
    G: GraphGeometry
[src]

pub fn into_adjacent_faces(
    self
) -> impl Clone + ExactSizeIterator<Item = FaceView<&'a M>>
[src]

impl<B, G> ArcView<B> where
    B: Reborrow,
    B::Target: AsStorage<Arc<G>> + AsStorage<Face<G>> + Consistent + Geometric<Geometry = G>,
    G: GraphGeometry
[src]

pub fn adjacent_faces(
    &self
) -> impl Clone + ExactSizeIterator<Item = FaceView<&B::Target>>
[src]

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

impl<'a, M, G> ArcView<&'a mut M> where
    M: AsStorage<Arc<G>> + AsStorageMut<Vertex<G>> + Consistent + Geometric<Geometry = G>,
    G: 'a + GraphGeometry
[src]

pub fn into_adjacent_vertex_orphans(
    self
) -> impl ExactSizeIterator<Item = VertexOrphan<'a, G>>
[src]

impl<B> ArcView<B> where
    B: ReborrowMut,
    B::Target: AsStorage<Arc<<B as Geometric>::Geometry>> + AsStorageMut<Vertex<<B as Geometric>::Geometry>> + Consistent + Geometric, 
[src]

pub fn adjacent_vertex_orphans(
    &mut self
) -> impl ExactSizeIterator<Item = VertexOrphan<<B as Geometric>::Geometry>>
[src]

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

impl<'a, M, G> ArcView<&'a mut M> where
    M: AsStorage<Arc<G>> + AsStorageMut<Face<G>> + Consistent + Geometric<Geometry = G>,
    G: 'a + GraphGeometry
[src]

pub fn into_adjacent_face_orphans(
    self
) -> impl ExactSizeIterator<Item = FaceOrphan<'a, G>>
[src]

impl<B> ArcView<B> where
    B: ReborrowMut,
    B::Target: AsStorage<Arc<<B as Geometric>::Geometry>> + AsStorageMut<Face<<B as Geometric>::Geometry>> + Consistent + Geometric, 
[src]

pub fn adjacent_face_orphans(
    &mut self
) -> impl ExactSizeIterator<Item = FaceOrphan<<B as Geometric>::Geometry>>
[src]

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

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

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

Splits the composite edge of the arc into two adjacent 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> where
    G: EdgeMidpoint,
    G::Vertex: AsPosition
[src]

Splits the composite edge of the arc at its midpoint.

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>, GraphError>
[src]

Connects the arc to another arc by forming a new ring and 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

Bridging two disjoint quadrilaterals together:

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>>>,
    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_with_offset<T>(
    self,
    offset: T
) -> Result<ArcView<&'a mut M>, GraphError> where
    T: Into<Scalar<VertexPosition<G>>>,
    G: ArcNormal,
    G::Vertex: AsPosition,
    VertexPosition<G>: EuclideanSpace
[src]

Extrudes the arc along its normal.

The positional geometry of each extruded vertex is translated along the arc's normal by the given offset.

An arc's normal is perpendicular to the arc and also coplanar with the arc and one of its adjacent arcs. This is computed via a projection and supports both 2D and 3D geometries.

Returns the extruded arc, which is in 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_with_offset(1.0)
    .unwrap();

pub fn extrude_with_translation(
    self,
    translation: Vector<VertexPosition<G>>
) -> Result<ArcView<&'a mut M>, GraphError> where
    G::Vertex: AsPosition,
    VertexPosition<G>: EuclideanSpace
[src]

Extrudes the arc along a translation.

The positional geometry of each extruded vertex is translated by the given translation (vector).

Returns the extruded arc, which is in the same ring as the initiating arc.

Errors

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

pub fn extrude_with<F>(self, f: F) -> Result<ArcView<&'a mut M>, GraphError> where
    F: Fn(G::Vertex) -> G::Vertex
[src]

Extrudes the arc using the given vertex geometry.

The geometry of each extruded vertex is determined by the given function, which maps the geometry of each source vertex into the geometry of the corresponding destination vertex.

Returns the extruded arc, which is in the same ring as the initiating arc.

Errors

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

pub fn remove(self) -> Option<VertexView<&'a mut M>>[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<B, M, G> Clone for ArcView<B> where
    B: Reborrow<Target = M>,
    M: AsStorage<Arc<G>> + Geometric<Geometry = G>,
    G: GraphGeometry,
    View<B, Arc<G>>: Clone
[src]

impl<B, M, G> ClosedView for ArcView<B> where
    B: Reborrow<Target = M>,
    M: AsStorage<Arc<G>> + Geometric<Geometry = G>,
    G: GraphGeometry
[src]

type Key = ArcKey

type Entity = Arc<G>

fn key(&self) -> Self::Key[src]

Gets the key for the arc.

impl<B, M, G> Copy for ArcView<B> where
    B: Reborrow<Target = M>,
    M: AsStorage<Arc<G>> + Geometric<Geometry = G>,
    G: GraphGeometry,
    View<B, Arc<G>>: Copy
[src]

impl<B, M, G> Deref for ArcView<B> where
    B: Reborrow<Target = M>,
    M: AsStorage<Arc<G>> + Geometric<Geometry = G>,
    G: GraphGeometry
[src]

type Target = Arc<G>

The resulting type after dereferencing.

impl<B, M, G> DerefMut for ArcView<B> where
    B: ReborrowMut<Target = M>,
    M: AsStorageMut<Arc<G>> + Geometric<Geometry = G>,
    G: GraphGeometry
[src]

impl<'a, M, G> From<ArcView<&'a mut M>> for ArcOrphan<'a, G> where
    M: AsStorageMut<Arc<G>> + Geometric<Geometry = G>,
    G: GraphGeometry
[src]

impl<B, M, G> From<ArcView<B>> for Ring<B> where
    B: Reborrow<Target = M>,
    M: AsStorage<Arc<G>> + Consistent + Geometric<Geometry = G>,
    G: GraphGeometry
[src]

impl<B, M, G> From<Ring<B>> for ArcView<B> where
    B: Reborrow<Target = M>,
    M: AsStorage<Arc<G>> + Consistent + Geometric<Geometry = G>,
    G: GraphGeometry
[src]

impl<B, M, G> PartialEq<ArcView<B>> for ArcView<B> where
    B: Reborrow<Target = M>,
    M: AsStorage<Arc<G>> + Consistent + Geometric<Geometry = G>,
    G: GraphGeometry
[src]

impl<B, M, G> ToArc<B> for ArcView<B> where
    B: Reborrow<Target = M>,
    M: AsStorage<Arc<G>> + AsStorage<Edge<G>> + Consistent + Geometric<Geometry = G>,
    G: GraphGeometry
[src]

Auto Trait Implementations

impl<B> RefUnwindSafe for ArcView<B> where
    B: RefUnwindSafe,
    <<B as Reborrow>::Target as Geometric>::Geometry: GraphGeometry

impl<B> Send for ArcView<B> where
    B: Send,
    <<B as Reborrow>::Target as Geometric>::Geometry: GraphGeometry

impl<B> Sync for ArcView<B> where
    B: Sync,
    <<B as Reborrow>::Target as Geometric>::Geometry: GraphGeometry

impl<B> Unpin for ArcView<B> where
    B: Unpin,
    <<B as Reborrow>::Target as Geometric>::Geometry: GraphGeometry

impl<B> UnwindSafe for ArcView<B> where
    B: UnwindSafe,
    <<B as Reborrow>::Target as Geometric>::Geometry: GraphGeometry

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> FromGeometry<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> IntoGeometry<U> for T where
    U: FromGeometry<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Slottable for T where
    T: Copy
[src]

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

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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,