[−][src]Struct plexus::graph::MeshGraph
Half-edge graph representation of a mesh.
Provides topological data in the form of vertices, arcs, edges, and faces. An arc is directed from one vertex to another, with an opposing arc joining the vertices in the other direction.
MeshGraph
s expose topological views, which can be used to traverse and
manipulate topology and geometry in the graph.
See the module documentation for more details.
Methods
impl<G> MeshGraph<G> where
G: Geometry,
[src]
G: Geometry,
pub fn new() -> Self
[src]
Creates an empty MeshGraph
.
Examples
use plexus::graph::MeshGraph; let mut graph = MeshGraph::<()>::new();
pub fn empty() -> Self
[src]
Creates an empty MeshGraph
.
Underlying storage has zero capacity and does not allocate until the first insertion.
pub fn from_mesh_buffer<A, N, H>(
buffer: MeshBuffer<Flat<A, N>, H>
) -> Result<Self, GraphError> where
A: NonZero + Unsigned,
N: Copy + Integer + NumCast + Unsigned,
H: Clone + IntoGeometry<G::Vertex>,
[src]
buffer: MeshBuffer<Flat<A, N>, H>
) -> Result<Self, GraphError> where
A: NonZero + Unsigned,
N: Copy + Integer + NumCast + Unsigned,
H: Clone + IntoGeometry<G::Vertex>,
Creates a MeshGraph
from a MeshBuffer
. The arity of the polygons in
the index buffer must be known and constant.
MeshGraph
also implements From
for MeshBuffer
, but will yield an
empty graph if the conversion fails.
Examples
use nalgebra::Point2; use plexus::buffer::{Flat4, MeshBuffer}; use plexus::graph::MeshGraph; use plexus::prelude::*; let buffer = MeshBuffer::<Flat4, _>::from_raw_buffers( vec![0u64, 1, 2, 3], vec![(0.0f64, 0.0), (1.0, 0.0), (1.0, 1.0), (0.0, 1.0)], ) .unwrap(); let mut graph = MeshGraph::<Point2<f64>>::from_mesh_buffer(buffer).unwrap();
pub fn vertex_count(&self) -> usize
[src]
Gets the number of vertices in the graph.
pub fn vertex(&self, key: VertexKey) -> Option<VertexView<&Self, G>>
[src]
Gets an immutable view of the vertex with the given key.
pub fn vertex_mut(&mut self, key: VertexKey) -> Option<VertexView<&mut Self, G>>
[src]
Gets a mutable view of the vertex with the given key.
pub fn vertices(&self) -> impl Clone + Iterator<Item = VertexView<&Self, G>>
[src]
Gets an iterator of immutable views over the vertices in the graph.
pub fn orphan_vertices(&mut self) -> impl Iterator<Item = OrphanVertexView<G>>
[src]
Gets an iterator of orphan views over the vertices in the graph.
Because this only yields orphan views, only geometry can be mutated.
For topological mutations, collect the necessary keys and use
vertex_mut
instead.
pub fn arc_count(&self) -> usize
[src]
Gets the number of arcs in the graph.
pub fn arc(&self, key: ArcKey) -> Option<ArcView<&Self, G>>
[src]
Gets an immutable view of the arc with the given key.
pub fn arc_mut(&mut self, key: ArcKey) -> Option<ArcView<&mut Self, G>>
[src]
Gets a mutable view of the arc with the given key.
pub fn arcs(&self) -> impl Clone + Iterator<Item = ArcView<&Self, G>>
[src]
Gets an iterator of immutable views over the arcs in the graph.
pub fn orphan_arcs(&mut self) -> impl Iterator<Item = OrphanArcView<G>>
[src]
Gets an iterator of orphan views over the arcs in the graph.
Because this only yields orphan views, only geometry can be mutated.
For topological mutations, collect the necessary keys and use
arc_mut
instead.
pub fn edge_count(&self) -> usize
[src]
Gets the number of edges in the graph.
pub fn edge(&self, key: EdgeKey) -> Option<EdgeView<&Self, G>>
[src]
Gets an immutable view of the edge with the given key.
pub fn edge_mut(&mut self, key: EdgeKey) -> Option<EdgeView<&mut Self, G>>
[src]
Gets a mutable view of the edge with the given key.
pub fn edges(&self) -> impl Clone + Iterator<Item = EdgeView<&Self, G>>
[src]
Gets an iterator of immutable views over the edges in the graph.
pub fn orphan_edges(&mut self) -> impl Iterator<Item = OrphanEdgeView<G>>
[src]
Gets an iterator of orphan views over the edges in the graph.
Because this only yields orphan views, only geometry can be mutated.
For topological mutations, collect the necessary keys and use
edge_mut
instead.
pub fn face_count(&self) -> usize
[src]
Gets the number of faces in the graph.
pub fn face(&self, key: FaceKey) -> Option<FaceView<&Self, G>>
[src]
Gets an immutable view of the face with the given key.
pub fn face_mut(&mut self, key: FaceKey) -> Option<FaceView<&mut Self, G>>
[src]
Gets a mutable view of the face with the given key.
pub fn faces(&self) -> impl Clone + Iterator<Item = FaceView<&Self, G>>
[src]
Gets an iterator of immutable views over the faces in the graph.
pub fn orphan_faces(&mut self) -> impl Iterator<Item = OrphanFaceView<G>>
[src]
Gets an iterator of orphan views over the faces in the graph.
Because this only yields orphan views, only geometry can be mutated.
For topological mutations, collect the necessary keys and use
face_mut
instead.
pub fn arity(&self) -> GraphArity
[src]
Gets the arity of the graph.
If all faces in the graph have the same arity, then
GraphArity::Constant
is returned with the singular arity of the
graph. If the graph contains faces with differing arity, then
GraphArity::NonConstant
is returned with the minimum and maximum
arity.
GraphArity::Constant
is returned with zero if there are no faces in
the graph.
pub fn triangulate(&mut self)
[src]
Triangulates the mesh, tesselating all faces into triangles.
pub fn to_mesh_buffer_by_vertex<A, N, H>(
&self
) -> Result<MeshBuffer<Flat<A, N>, H>, GraphError> where
G::Vertex: IntoGeometry<H>,
A: NonZero + Unsigned,
N: Copy + Integer + NumCast + Unsigned,
[src]
&self
) -> Result<MeshBuffer<Flat<A, N>, H>, GraphError> where
G::Vertex: IntoGeometry<H>,
A: NonZero + Unsigned,
N: Copy + Integer + NumCast + Unsigned,
Creates a MeshBuffer
from the graph.
The buffer is created using the vertex geometry of each unique vertex.
Errors
Returns an error if the mesh does not have constant arity that is compatible with the index buffer. Typically, a mesh is triangulated before being converted to a mesh buffer.
pub fn to_mesh_buffer_by_vertex_with<A, N, H, F>(
&self,
f: F
) -> Result<MeshBuffer<Flat<A, N>, H>, GraphError> where
A: NonZero + Unsigned,
N: Copy + Integer + NumCast + Unsigned,
F: FnMut(VertexView<&Self, G>) -> H,
[src]
&self,
f: F
) -> Result<MeshBuffer<Flat<A, N>, H>, GraphError> where
A: NonZero + Unsigned,
N: Copy + Integer + NumCast + Unsigned,
F: FnMut(VertexView<&Self, G>) -> H,
Creates a MeshBuffer
from the graph.
The buffer is created using each unique vertex, which is converted into the buffer geometry by the given function.
Errors
Returns an error if the mesh does not have constant arity that is compatible with the index buffer. Typically, a mesh is triangulated before being converted to a mesh buffer.
pub fn to_mesh_buffer_by_face<A, N, H>(
&self
) -> Result<MeshBuffer<Flat<A, N>, H>, GraphError> where
G::Vertex: IntoGeometry<H>,
A: NonZero + Unsigned,
N: Copy + Integer + NumCast + Unsigned,
[src]
&self
) -> Result<MeshBuffer<Flat<A, N>, H>, GraphError> where
G::Vertex: IntoGeometry<H>,
A: NonZero + Unsigned,
N: Copy + Integer + NumCast + Unsigned,
Creates a MeshBuffer
from the graph.
The buffer is created using the vertex geometry of each face. Shared vertices are included for each face to which they belong.
Errors
Returns an error if the mesh does not have constant arity that is compatible with the index buffer. Typically, a mesh is triangulated before being converted to a mesh buffer.
pub fn to_mesh_buffer_by_face_with<A, N, H, F>(
&self,
f: F
) -> Result<MeshBuffer<Flat<A, N>, H>, GraphError> where
A: NonZero + Unsigned,
N: Copy + Integer + NumCast + Unsigned,
F: FnMut(FaceView<&Self, G>, VertexView<&Self, G>) -> H,
[src]
&self,
f: F
) -> Result<MeshBuffer<Flat<A, N>, H>, GraphError> where
A: NonZero + Unsigned,
N: Copy + Integer + NumCast + Unsigned,
F: FnMut(FaceView<&Self, G>, VertexView<&Self, G>) -> H,
Creates a MeshBuffer
from the graph.
The buffer is created from each face, which is converted into the buffer geometry by the given function.
Errors
Returns an error if the mesh does not have constant arity that is compatible with the index buffer. Typically, a mesh is triangulated before being converted to a mesh buffer.
Trait Implementations
impl<G, H> FromInteriorGeometry<MeshGraph<H>> for MeshGraph<G> where
G: Geometry,
G::Vertex: FromGeometry<H::Vertex>,
G::Arc: FromGeometry<H::Arc>,
G::Edge: FromGeometry<H::Edge>,
G::Face: FromGeometry<H::Face>,
H: Geometry,
[src]
G: Geometry,
G::Vertex: FromGeometry<H::Vertex>,
G::Arc: FromGeometry<H::Arc>,
G::Edge: FromGeometry<H::Edge>,
G::Face: FromGeometry<H::Face>,
H: Geometry,
fn from_interior_geometry(graph: MeshGraph<H>) -> Self
[src]
impl<G, P> FromIndexer<P, P> for MeshGraph<G> where
G: Geometry,
P: Map<usize> + Topological,
P::Output: IntoVertices,
P::Vertex: IntoGeometry<G::Vertex>,
[src]
G: Geometry,
P: Map<usize> + Topological,
P::Output: IntoVertices,
P::Vertex: IntoGeometry<G::Vertex>,
type Error = GraphError
fn from_indexer<I, N>(input: I, indexer: N) -> Result<Self, Self::Error> where
I: IntoIterator<Item = P>,
N: Indexer<P, P::Vertex>,
[src]
I: IntoIterator<Item = P>,
N: Indexer<P, P::Vertex>,
impl<P, G, H> FromRawBuffers<P, H> for MeshGraph<G> where
P: IntoVertices + Polygonal,
P::Vertex: Integer + ToPrimitive + Unsigned,
G: Geometry,
H: IntoGeometry<G::Vertex>,
[src]
P: IntoVertices + Polygonal,
P::Vertex: Integer + ToPrimitive + Unsigned,
G: Geometry,
H: IntoGeometry<G::Vertex>,
type Error = GraphError
fn from_raw_buffers<I, J>(indices: I, vertices: J) -> Result<Self, Self::Error> where
I: IntoIterator<Item = P>,
J: IntoIterator<Item = H>,
[src]
I: IntoIterator<Item = P>,
J: IntoIterator<Item = H>,
impl<N, G, H> FromRawBuffersWithArity<N, H> for MeshGraph<G> where
N: Integer + ToPrimitive + Unsigned,
G: Geometry,
H: IntoGeometry<G::Vertex>,
[src]
N: Integer + ToPrimitive + Unsigned,
G: Geometry,
H: IntoGeometry<G::Vertex>,
type Error = GraphError
fn from_raw_buffers_with_arity<I, J>(
indices: I,
vertices: J,
arity: usize
) -> Result<Self, Self::Error> where
I: IntoIterator<Item = N>,
J: IntoIterator<Item = H>,
[src]
indices: I,
vertices: J,
arity: usize
) -> Result<Self, Self::Error> where
I: IntoIterator<Item = N>,
J: IntoIterator<Item = H>,
Creates a MeshGraph
from raw index and vertex buffers. The arity of
the polygons in the index buffer must be known and constant.
Errors
Returns an error if the arity of the index buffer is not constant, any index is out of bounds, or there is an error inserting topology into the mesh.
Examples
use nalgebra::Point3; use plexus::graph::MeshGraph; use plexus::prelude::*; use plexus::primitive::index::LruIndexer; use plexus::primitive::sphere::UvSphere; let (indices, positions) = UvSphere::new(16, 16) .polygons_with_position() .triangulate() .flat_index_vertices(LruIndexer::with_capacity(256)); let mut graph = MeshGraph::<Point3<f64>>::from_raw_buffers_with_arity(indices, positions, 3).unwrap();
impl<A, N, H, G> From<MeshBuffer<Flat<A, N>, H>> for MeshGraph<G> where
A: NonZero + Unsigned,
N: Copy + Integer + NumCast + Unsigned,
H: Clone + IntoGeometry<G::Vertex>,
G: Geometry,
[src]
A: NonZero + Unsigned,
N: Copy + Integer + NumCast + Unsigned,
H: Clone + IntoGeometry<G::Vertex>,
G: Geometry,
fn from(buffer: MeshBuffer<Flat<A, N>, H>) -> Self
[src]
impl<G> Default for MeshGraph<G> where
G: Geometry,
[src]
G: Geometry,
impl<G, P> FromIterator<P> for MeshGraph<G> where
G: Geometry,
P: Map<usize> + Topological,
P::Output: IntoVertices,
P::Vertex: Clone + Eq + Hash + IntoGeometry<G::Vertex>,
[src]
G: Geometry,
P: Map<usize> + Topological,
P::Output: IntoVertices,
P::Vertex: Clone + Eq + Hash + IntoGeometry<G::Vertex>,
fn from_iter<I>(input: I) -> Self where
I: IntoIterator<Item = P>,
[src]
I: IntoIterator<Item = P>,
Auto Trait Implementations
impl<G> Send for MeshGraph<G> where
<G as Geometry>::Arc: Send,
<G as Geometry>::Edge: Send,
<G as Geometry>::Face: Send,
<G as Geometry>::Vertex: Send,
<G as Geometry>::Arc: Send,
<G as Geometry>::Edge: Send,
<G as Geometry>::Face: Send,
<G as Geometry>::Vertex: Send,
impl<G> Sync for MeshGraph<G> where
<G as Geometry>::Arc: Sync,
<G as Geometry>::Edge: Sync,
<G as Geometry>::Face: Sync,
<G as Geometry>::Vertex: Sync,
<G as Geometry>::Arc: Sync,
<G as Geometry>::Edge: Sync,
<G as Geometry>::Face: Sync,
<G as Geometry>::Vertex: Sync,
Blanket Implementations
impl<T> FromGeometry for T
[src]
fn from_geometry(T) -> T
[src]
impl<T, U> IntoGeometry for T where
U: FromGeometry<T>,
[src]
U: FromGeometry<T>,
fn into_geometry(Self) -> U
[src]
impl<T, U> IntoInteriorGeometry for T where
U: FromInteriorGeometry<T>,
[src]
U: FromInteriorGeometry<T>,
fn into_interior_geometry(Self) -> U
[src]
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Same for T
[src]
type Output = T
Should always be Self
impl<SS, SP> SupersetOf for SP where
SS: SubsetOf<SP>,
SS: SubsetOf<SP>,