[−][src]Struct nannou::geom::graph::Graph
A composition of geometry described by an acyclic directed graph.
The Node
s within a graph may describe some primitive geometry (e.g. Line
, Cuboid
, etc) or
may contain other Graph
s. This allows graphs to be composed of other graphs, which may then
be composed with other graphs, etc.
The Edge
s within a graph describe the relationships between the nodes. They allow for
describing the position, orientation and scale of nodes relative to others.
All Node
s other than the graph's "origin" node must have at least one parent, but may never
have more than one parent of each edge::Kind
.
Methods
impl<S> Graph<S> where
S: BaseFloat,
[src]
S: BaseFloat,
pub fn new() -> Self
[src]
Construct a new empty Graph
with a single "origin" node.
The "origin" is the "parent-most" of all nodes. Its transform is always equal to
Transform::default()
.
Calling this is the same as calling Graph::default()
.
pub fn origin(&self) -> Index
[src]
The node::Index of the origin node.
pub fn with_capacity(nodes: usize, edges: usize) -> Self
[src]
Construct the graph with pre-allocated buffers for the given nodes
, edges
and
vertices
capacities.
pub fn node_count(&self) -> usize
[src]
The total number of Nodes in the Graph.
pub fn edge_count(&self) -> usize
[src]
The total number of Edges in the Graph.
pub fn node(&self, idx: Index) -> Option<&Node<S>>
[src]
Borrow the node at the given node::Index if there is one.
pub fn node_transform(&self, idx: Index) -> Option<Transform<S>>
[src]
Determine the full Transform for the Node.
Returns None if the node does not exist.
pub fn node_vertices<I>(
&self,
idx: Index,
vertices: I
) -> Option<TransformedVertices<I::IntoIter, S>> where
I: IntoIterator,
I::Item: ApplyTransform<S>,
[src]
&self,
idx: Index,
vertices: I
) -> Option<TransformedVertices<I::IntoIter, S>> where
I: IntoIterator,
I::Item: ApplyTransform<S>,
Transform the given vertices with the given node's Transform.
This method uses the node_transform method internally.
Returns None if the node does not exist.
pub fn node_triangles<I, V>(
&self,
idx: Index,
triangles: I
) -> Option<TransformedTriangles<I::IntoIter, V, S>> where
I: IntoIterator<Item = Tri<V>>,
V: Vertex + ApplyTransform<S>,
[src]
&self,
idx: Index,
triangles: I
) -> Option<TransformedTriangles<I::IntoIter, V, S>> where
I: IntoIterator<Item = Tri<V>>,
V: Vertex + ApplyTransform<S>,
Transform the given triangles with the given node's Transform.
This method uses the node_transform method internally.
Returns None if the node does not exist.
pub fn edge(&self, idx: Index) -> Option<&Edge<S>>
[src]
Borrow the edge at the given edge::Index if there is one.
pub fn raw_nodes(&self) -> RawNodes<S>
[src]
The slice containing all nodes.
pub fn raw_edges(&self) -> RawEdges<S>
[src]
The slice containing all edges.
pub fn clear(&mut self)
[src]
Removes all Nodes, Edges and vertices from the Graph and resets the origin node.
This does not de-allocate any buffers and should retain capacity. To drop all inner
buffers, use mem::replace
with a new empty Graph.
pub fn edge_endpoints(&self, idx: Index) -> Option<(Index, Index)>
[src]
Return the parent and child nodes on either end of the Edge at the given index.
pub fn recursive_walk<F>(
&self,
start: Index,
recursive_fn: F
) -> RecursiveWalk<F, S> where
F: FnMut(&Self, Index) -> Option<(Index, Index)>,
[src]
&self,
start: Index,
recursive_fn: F
) -> RecursiveWalk<F, S> where
F: FnMut(&Self, Index) -> Option<(Index, Index)>,
A Walker type that recursively walks the Graph using the given recursive_fn
.
Panics If the given start index does not exist within the Graph.
pub fn dag(&self) -> &Dag<S>
[src]
Borrow the inner daggy::Dag
(directed acyclic graph) upon which Graph
is built.
Can be useful/necessary for utilising some of the daggy::Walker
types.
pub fn add_node(&mut self, node: Node<S>) -> Index
[src]
Add the given Node to the graph.
The created node will be a child of the graph's origin node.
Returns the index of the new node.
pub fn set_edge(
&mut self,
a: Index,
b: Index,
edge: Edge<S>
) -> Result<Index, WouldCycle<S>>
[src]
&mut self,
a: Index,
b: Index,
edge: Edge<S>
) -> Result<Index, WouldCycle<S>>
Set the given Edge within the graph.
The added edge will be in the direction a
-> b
There may only ever be one Edge of the given variant between a
-> b
.
Checks if the edge would create a cycle in the Graph.
If adding the edge would not cause the graph to cycle, the edge will be added and its
edge::Index
returned.
If adding the edge would cause the graph to cycle, the edge will not be added and
instead a WouldCycle
error with the given weight will be returned.
Panics if either a
or b
do not exist within the Graph.
Panics if the Graph is at the maximum number of nodes for its index type.
pub fn add_child<E>(
&mut self,
parent: Index,
edges: E,
node: Node<S>
) -> (Indices, Index) where
E: IntoIterator<Item = Edge<S>>,
[src]
&mut self,
parent: Index,
edges: E,
node: Node<S>
) -> (Indices, Index) where
E: IntoIterator<Item = Edge<S>>,
Add the given node as a child to the given parent
connected via the given edges.
There may only ever be one Edge of the given variant between a
-> b
.
Panics if:
parent
does not exist within the Graph.edges
does not contain at least one Edge.- the Graph is at the maximum number of nodes for its index type.
pub fn add_children<C, E>(
&mut self,
parent: Index,
children: C
) -> Vec<(Indices, Index)> where
C: IntoIterator<Item = (E, Node<S>)>,
E: IntoIterator<Item = Edge<S>>,
[src]
&mut self,
parent: Index,
children: C
) -> Vec<(Indices, Index)> where
C: IntoIterator<Item = (E, Node<S>)>,
E: IntoIterator<Item = Edge<S>>,
Add the given children to the given parent
connected via the given edges for each child.
Returns an iterator yielding the node and edge indices for each child that was added.
There may only ever be one Edge of the given variant between a
-> b
.
Panics if:
parent
does not exist within the Graph.- any of the child
edges
iterators do not contain at least one Edge. - the Graph is at the maximum number of nodes for its index type.
pub fn walk_vertices<'a, F, I>(
&self,
dfs: &'a mut Dfs<S>,
vertices_fn: F
) -> WalkVertices<'a, F, I, S> where
F: Fn(&Index) -> I,
I: IntoIterator,
I::Item: ApplyTransform<S>,
[src]
&self,
dfs: &'a mut Dfs<S>,
vertices_fn: F
) -> WalkVertices<'a, F, I, S> where
F: Fn(&Index) -> I,
I: IntoIterator,
I::Item: ApplyTransform<S>,
Produce a walker yielding all vertices from all nodes within the graph in order of discovery within a depth-first-search.
pub fn walk_triangles<'a, F, I, V>(
&self,
dfs: &'a mut Dfs<S>,
triangles_fn: F
) -> WalkTriangles<'a, F, I, V, S> where
F: Fn(&Index) -> I,
I: IntoIterator<Item = Tri<V>>,
V: Vertex + ApplyTransform<S>,
[src]
&self,
dfs: &'a mut Dfs<S>,
triangles_fn: F
) -> WalkTriangles<'a, F, I, V, S> where
F: Fn(&Index) -> I,
I: IntoIterator<Item = Tri<V>>,
V: Vertex + ApplyTransform<S>,
Produce a walker yielding all vertices from all nodes within the graph in order of discovery within a depth-first-search.
pub fn vertices<'a, 'b, F, I>(
&'a self,
dfs: &'b mut Dfs<S>,
vertices_fn: F
) -> Vertices<'a, 'b, F, I, S> where
F: Fn(&Index) -> I,
I: IntoIterator,
I::Item: ApplyTransform<S>,
[src]
&'a self,
dfs: &'b mut Dfs<S>,
vertices_fn: F
) -> Vertices<'a, 'b, F, I, S> where
F: Fn(&Index) -> I,
I: IntoIterator,
I::Item: ApplyTransform<S>,
Produce an iterator yielding all vertices from all nodes within the graph in order of discovery within a depth-first-search.
pub fn triangles<'a, 'b, F, I, V>(
&'a self,
dfs: &'b mut Dfs<S>,
triangles_fn: F
) -> Triangles<'a, 'b, F, I, V, S> where
F: Fn(&Index) -> I,
I: IntoIterator<Item = Tri<V>>,
V: Vertex + ApplyTransform<S>,
[src]
&'a self,
dfs: &'b mut Dfs<S>,
triangles_fn: F
) -> Triangles<'a, 'b, F, I, V, S> where
F: Fn(&Index) -> I,
I: IntoIterator<Item = Tri<V>>,
V: Vertex + ApplyTransform<S>,
Produce an iterator yielding all triangles from all nodes within the graph in order of discovery within a depth-first-search.
pub fn bounding_cuboid<F, I>(
&self,
dfs: &mut Dfs<S>,
vertices_fn: F
) -> Option<Cuboid<S>> where
F: Fn(&Index) -> I,
I: IntoIterator<Item = Point3<S>>,
[src]
&self,
dfs: &mut Dfs<S>,
vertices_fn: F
) -> Option<Cuboid<S>> where
F: Fn(&Index) -> I,
I: IntoIterator<Item = Point3<S>>,
The Cuboid
that bounds all nodes within the geometry graph.
Returns None
if the graph contains no vertices.
- Iterates over all nodes.
- Expands a cuboid to the max bounds of each node.
- Returns the resulting cuboid.
pub fn parents(&self, child: Index) -> Parents<S>
[src]
A Walker type that may be used to step through the parents of the given child node.
pub fn edge_parent(&self, idx: Index, edge: Kind) -> Option<Index>
[src]
If the Node at the given index has some parent along an Edge of the given variant, return an index to it.
pub fn position_parent(&self, idx: Index, axis: Axis) -> Option<Index>
[src]
Return the index of the parent along the given node's Position Edge.
pub fn x_position_parent(&self, idx: Index) -> Option<Index>
[src]
Return the index of the parent along the given node's Position Edge.
pub fn y_position_parent(&self, idx: Index) -> Option<Index>
[src]
Return the index of the parent along the given node's Position Edge.
pub fn z_position_parent(&self, idx: Index) -> Option<Index>
[src]
Return the index of the parent along the given node's Position Edge.
pub fn position_parents(&self, idx: Index) -> PositionParents
[src]
Produce an Iterator yielding the Position parents to the given node.
Parents are always yielded in order of axis, e.g. X, Y then Z.
pub fn orientation_parent(&self, idx: Index, axis: Axis) -> Option<Index>
[src]
Return the index of the parent along the given node's Orientation Edge.
pub fn x_orientation_parent(&self, idx: Index) -> Option<Index>
[src]
Return the index of the parent along the given node's Orientation Edge.
pub fn y_orientation_parent(&self, idx: Index) -> Option<Index>
[src]
Return the index of the parent along the given node's Orientation Edge.
pub fn z_orientation_parent(&self, idx: Index) -> Option<Index>
[src]
Return the index of the parent along the given node's Orientation Edge.
pub fn orientation_parents(&self, idx: Index) -> OrientationParents
[src]
Produce an Iterator yielding the Orientation parents to the given node.
Parents are always yielded in order of axis, e.g. X, Y then Z.
pub fn scale_parent(&self, idx: Index, axis: Axis) -> Option<Index>
[src]
Return the index of the parent along the given node's Scale Edge.
pub fn x_scale_parent(&self, idx: Index) -> Option<Index>
[src]
Return the index of the parent along the given node's Scale Edge.
pub fn y_scale_parent(&self, idx: Index) -> Option<Index>
[src]
Return the index of the parent along the given node's Scale Edge.
pub fn z_scale_parent(&self, idx: Index) -> Option<Index>
[src]
Return the index of the parent along the given node's Scale Edge.
pub fn scale_parents(&self, idx: Index) -> ScaleParents
[src]
Produce an Iterator yielding the Scale parents to the given node.
Parents are always yielded in order of axis, e.g. X, Y then Z.
pub fn x_parents(&self, idx: Index) -> XParents
[src]
Produce an Iterator yielding the X parents to the given node.
Parents are always yielded in order of Position, Orientation and Scale.
pub fn y_parents(&self, idx: Index) -> YParents
[src]
Produce an Iterator yielding the Y parents to the given node.
Parents are always yielded in order of Position, Orientation and Scale.
pub fn z_parents(&self, idx: Index) -> ZParents
[src]
Produce an Iterator yielding the Z parents to the given node.
Parents are always yielded in order of Position, Orientation and Scale.
pub fn children(&self, parent: Index) -> Children<S>
[src]
A Walker type that may be used to step through the children of the given parent node.
Trait Implementations
impl<S: Clone> Clone for Graph<S> where
S: BaseFloat,
[src]
S: BaseFloat,
impl<S: Debug> Debug for Graph<S> where
S: BaseFloat,
[src]
S: BaseFloat,
impl<S> Default for Graph<S> where
S: BaseFloat,
[src]
S: BaseFloat,
impl<S> GraphBase for Graph<S> where
S: BaseFloat,
[src]
S: BaseFloat,
impl<S> Index<EdgeIndex<usize>> for Graph<S> where
S: BaseFloat,
[src]
S: BaseFloat,
type Output = Edge<S>
The returned type after indexing.
fn index<'a>(&'a self, idx: Index) -> &'a Self::Output
[src]
impl<S> Index<NodeIndex<usize>> for Graph<S> where
S: BaseFloat,
[src]
S: BaseFloat,
type Output = Node<S>
The returned type after indexing.
fn index<'a>(&'a self, id: Index) -> &'a Self::Output
[src]
impl<'a, S> IntoNeighbors for &'a Graph<S> where
S: BaseFloat,
[src]
S: BaseFloat,
type Neighbors = <&'a Dag<S> as IntoNeighbors>::Neighbors
fn neighbors(self, n: Self::NodeId) -> Self::Neighbors
[src]
impl<S> Visitable for Graph<S> where
S: BaseFloat,
[src]
S: BaseFloat,
type Map = <Dag<S> as Visitable>::Map
The associated map type
fn visit_map(&self) -> Self::Map
[src]
fn reset_map(&self, map: &mut Self::Map)
[src]
impl<'a, S> Walker<&'a Graph<S>> for Dfs<S> where
S: BaseFloat,
[src]
S: BaseFloat,
type Item = (Index, Transform<S>)
fn walk_next(&mut self, graph: &'a Graph<S>) -> Option<Self::Item>
[src]
fn iter(self, context: Context) -> WalkerIter<Self, Context> where
Context: Clone,
[src]
Context: Clone,
impl<'a, S> Walker<&'a Graph<S>> for Children<S> where
S: BaseFloat,
[src]
S: BaseFloat,
type Item = (Index, Index)
fn walk_next(&mut self, graph: &'a Graph<S>) -> Option<Self::Item>
[src]
fn iter(self, context: Context) -> WalkerIter<Self, Context> where
Context: Clone,
[src]
Context: Clone,
impl<'a, S> Walker<&'a Graph<S>> for Parents<S> where
S: BaseFloat,
[src]
S: BaseFloat,
Auto Trait Implementations
impl<S> RefUnwindSafe for Graph<S> where
S: RefUnwindSafe,
S: RefUnwindSafe,
impl<S> Send for Graph<S> where
S: Send,
S: Send,
impl<S> Sync for Graph<S> where
S: Sync,
S: Sync,
impl<S> Unpin for Graph<S> where
S: Unpin,
S: Unpin,
impl<S> UnwindSafe for Graph<S> where
S: UnwindSafe,
S: UnwindSafe,
Blanket Implementations
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S where
D: AdaptFrom<S, Swp, Dwp, T>,
Dwp: WhitePoint,
Swp: WhitePoint,
T: Component + Float,
[src]
D: AdaptFrom<S, Swp, Dwp, T>,
Dwp: WhitePoint,
Swp: WhitePoint,
T: Component + Float,
fn adapt_into_using<M>(self, method: M) -> D where
M: TransformMatrix<Swp, Dwp, T>,
[src]
M: TransformMatrix<Swp, Dwp, T>,
fn adapt_into(self) -> D
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> ConvertInto<U> for T where
U: ConvertFrom<T>,
[src]
U: ConvertFrom<T>,
fn convert_into(self) -> U
[src]
fn convert_unclamped_into(self) -> U
[src]
fn try_convert_into(self) -> Result<U, OutOfBounds<U>>
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
T: Parameter<Self>,
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
T: Parameter<Self>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> 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, U> TryInto<U> 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<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,