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

View of an arc entity.

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.

See the graph module documentation for more information about views.

Examples

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

use decorum::R64;
use nalgebra::Point3;
use plexus::graph::MeshGraph;
use plexus::index::HashIndexer;
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_with_indexer(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

Returns true if this is a boundary arc.

A boundary arc has no associated face.

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();
This impl block contains no items.

Reachable API.

Converts the arc into its ring.

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

Converts the arc into its opposite arc.

Converts the arc into its next arc.

Converts the arc into its previous arc.

Gets the ring of the arc.

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

Gets the opposite arc.

Gets the next arc.

Gets the previous arc.

This impl block contains no items.

Reachable API.

Converts the arc into its source vertex.

Converts the arc into its destination vertex.

Gets the source vertex of the arc.

Gets the destination vertex of the arc.

This impl block contains no items.

Reachable API.

Converts the arc into its edge.

Gets the edge of the arc.

This impl block contains no items.

Reachable API.

Converts the arc into its face.

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

Gets the face of this arc.

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

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

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

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

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

Splits the composite edge of the arc into two adjacent edges that share a vertex.

Splitting inserts a new vertex with data 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

Splitting an edge in a MeshGraph with weighted vertices:

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

pub enum Weight {}

impl GraphData 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);

Splits the composite edge of the arc at its midpoint.

Splitting inserts a new vertex with the data of the arc’s source vertex but modified such that the position of the vertex is the computed midpoint of both of the arc’s vertices.

Splitting inserts a new vertex with data 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 MeshGraph exposes positional data in its vertices and that data supports interpolation. See the EdgeMidpoint trait.

Returns the inserted vertex.

Examples

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

Connects the arc to another arc by inserting 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.

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::geometry::FromGeometry;
use plexus::graph::{ArcKey, GraphData, MeshGraph, VertexKey, VertexView};
use plexus::prelude::*;
use plexus::primitive::NGon;

fn find<'a, I, T, G>(input: I, data: T) -> Option<VertexKey>
where
    I: IntoIterator<Item = VertexView<&'a MeshGraph<G>>>,
    G: 'a + GraphData,
    G::Vertex: FromGeometry<T> + PartialEq,
{
    let data = data.into_geometry();
    input
        .into_iter()
        .find(|vertex| *vertex.get() == data)
        .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(ArcKey::from((a, b)))
    .unwrap()
    .bridge(ArcKey::from((c, d)))
    .unwrap();

Extrudes the arc along its normal.

The positions of each extruded vertex are 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();

Extrudes the arc along a translation.

The positions of each extruded vertex are translated by the given 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.

Extrudes the arc using the given vertex data.

The data of each extruded vertex is determined by the given function, which maps the data of each source vertex into the data 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.

Removes the arc and its composite edge.

Any and all dependent entities are 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

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

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

Converts to this type from the input type.

Converts to this type from the input type.

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.