Struct fdg_sim::Simulation
source · [−]Expand description
A simulation for managing the main event loop and forces.
Implementations
sourceimpl<N: Clone, E: Clone> Simulation<N, E>
impl<N: Clone, E: Clone> Simulation<N, E>
sourcepub fn from_graph(
graph: &ForceGraph<N, E>,
parameters: SimulationParameters<N, E>
) -> Self
pub fn from_graph(
graph: &ForceGraph<N, E>,
parameters: SimulationParameters<N, E>
) -> Self
Create a simulation from a ForceGraph
.
sourcepub fn reset_node_placement(&mut self)
pub fn reset_node_placement(&mut self)
Randomly place the nodes within the starting square. In practice, this restarts the simulation.
sourcepub fn update_custom(&mut self, force: &Force<N, E>, dt: f32)
pub fn update_custom(&mut self, force: &Force<N, E>, dt: f32)
Update the graph’s node’s positions for a given interval with a custom Force
.
sourcepub fn visit_nodes(&self, cb: &mut impl Fn(&Node<N>))
pub fn visit_nodes(&self, cb: &mut impl Fn(&Node<N>))
Run a callback on all the nodes.
sourcepub fn visit_edges(&self, cb: &mut impl Fn(&Node<N>, &Node<N>))
pub fn visit_edges(&self, cb: &mut impl Fn(&Node<N>, &Node<N>))
Run a callback on all of the edges.
sourcepub fn get_graph(&self) -> &ForceGraph<N, E>
pub fn get_graph(&self) -> &ForceGraph<N, E>
Retrieve a reference to the internal ForceGraph
.
sourcepub fn get_graph_mut(&mut self) -> &mut ForceGraph<N, E>
pub fn get_graph_mut(&mut self) -> &mut ForceGraph<N, E>
Retrieve a mutable reference to the internal ForceGraph
.
sourcepub fn set_graph(&mut self, graph: &ForceGraph<N, E>)
pub fn set_graph(&mut self, graph: &ForceGraph<N, E>)
Set the internal ForceGraph
.
sourcepub fn parameters(&self) -> &SimulationParameters<N, E>
pub fn parameters(&self) -> &SimulationParameters<N, E>
Retrieve a reference to the internal SimulationParameters
.
sourcepub fn parameters_mut(&mut self) -> &mut SimulationParameters<N, E>
pub fn parameters_mut(&mut self) -> &mut SimulationParameters<N, E>
Retreive a mutable reference to the internal SimulationParameters
.
Trait Implementations
sourceimpl<N: Clone + Clone, E: Clone + Clone> Clone for Simulation<N, E>
impl<N: Clone + Clone, E: Clone + Clone> Clone for Simulation<N, E>
sourcefn clone(&self) -> Simulation<N, E>
fn clone(&self) -> Simulation<N, E>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl<N, E> RefUnwindSafe for Simulation<N, E> where
E: RefUnwindSafe,
N: RefUnwindSafe,
impl<N, E> Send for Simulation<N, E> where
E: Send,
N: Send,
impl<N, E> Sync for Simulation<N, E> where
E: Sync,
N: Sync,
impl<N, E> Unpin for Simulation<N, E> where
E: Unpin,
N: Unpin,
impl<N, E> UnwindSafe for Simulation<N, E> where
E: UnwindSafe,
N: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more