#include <MappingGraph.h>
Represents the overall mechanical simulation graph structure (Mapping Graph). More...
Represents the overall mechanical simulation graph structure (Mapping Graph).
This class builds and manages a dependency graph connecting all major components (MechanicalStates, Mappings, ForceFields, Masses) within an SOFA scene. It allows for systematic traversal (Top-down/Bottom-up) to determine the correct order of calculation required during simulation initialization or execution.
Classes | |
| struct | InputLists |
| Container struct holding lists of all potential input components collected from a scene context. More... | |
Public Attributes | |
| MappingGraphAlgorithms | algorithms { this } |
Public Member Functions | |
| MappingGraph ()=default | |
| Default constructor initializes an empty graph. More... | |
| MappingGraph (const InputLists &input) | |
| Constructs the graph using pre-collected input lists. More... | |
| MappingGraph (core::objectmodel::BaseContext *node) | |
| Constructs the graph by traversing a starting node in the SOFA object model context. More... | |
| void | clear () |
| core::objectmodel::BaseContext * | getRootNode () const |
| Returns the root node used during the initial construction of the graph. More... | |
| const sofa::type::vector< core::behavior::BaseMechanicalState * > & | getMainMechanicalStates () const |
| Gets the list of all main mechanical states that are not used as outputs in any mapping (i.e., they are root inputs). More... | |
| MappingInputs | getTopMostMechanicalStates (core::behavior::BaseMechanicalState *state) const |
| Recursively finds top-most mechanical states that are unmapped but serve as inputs to a mapping involving the provided state. More... | |
| MappingInputs | getTopMostMechanicalStates (core::behavior::StateAccessor *stateAccessor) const |
| Recursively finds top-most mechanical states that are unmapped but serve as inputs to a mapping involving the mechanical states associated with a given accessor. More... | |
| bool | hasAnyMapping () const |
| Checks if any mapping exists anywhere in the graph structure. More... | |
| bool | hasAnyMappingInput (core::behavior::BaseMechanicalState *mstate) const |
| Determines if a specific mechanical state is an output of any mapping node connected to the graph. More... | |
| bool | hasAnyMappingInput (core::behavior::StateAccessor *stateAccessor) const |
| Determines if the mechanical states associated with a component are outputs of any mapping node connected to the graph. More... | |
| sofa::Size | getTotalNbMainDofs () const |
| Calculates the total number of degrees of freedom (DoF) contributed by all main mechanical states in the graph. More... | |
| type::Vec2u | getPositionInGlobalMatrix (core::behavior::BaseMechanicalState *mstate) const |
| Finds the global matrix indices (row/column) where a specific state contributes its degrees of freedom. More... | |
| type::Vec2u | getPositionInGlobalMatrix (core::behavior::BaseMechanicalState *a, core::behavior::BaseMechanicalState *b) const |
| Finds the global matrix indices where two specified states contribute their degrees of freedom. (Used for cross-axis checks). More... | |
| sofa::type::vector< core::BaseMapping * > | getBottomUpMappingsFrom (core::behavior::BaseMechanicalState *) const |
| Retrieves all mapping components that depend on (receive input from) the provided mechanical state. This is used for bottom-up dependency checks. More... | |
| bool | isBuilt () const |
| Checks if the graph has been successfully built and analyzed. More... | |
| void | build (const InputLists &input) |
| Builds the mapping graph using a provided set of input components. More... | |
| void | build (core::objectmodel::BaseContext *rootNode) |
| Builds the mapping graph by traversing and collecting components starting from a specific root node in the object model hierarchy. More... | |
| const sofa::type::vector< BaseMappingGraphNode::SPtr > & | getAllNodes () const |
Friends | |
| struct | MappingGraphAlgorithms |
| MappingGraphAlgorithms sofa::simulation::MappingGraph::algorithms { this } |
|
default |
Default constructor initializes an empty graph.
|
explicit |
Constructs the graph using pre-collected input lists.
| input | The list of all components found in the scene. |
|
explicit |
Constructs the graph by traversing a starting node in the SOFA object model context.
| node | The root context node from which to build the graph. |
| void sofa::simulation::MappingGraph::build | ( | const InputLists & | input | ) |
Builds the mapping graph using a provided set of input components.
| input | The collected list of all potential SOFA components. |
| void sofa::simulation::MappingGraph::build | ( | core::objectmodel::BaseContext * | rootNode | ) |
Builds the mapping graph by traversing and collecting components starting from a specific root node in the object model hierarchy.
| rootNode | The starting context node. |
| void sofa::simulation::MappingGraph::clear | ( | ) |
|
inline |
| sofa::type::vector< core::BaseMapping * > sofa::simulation::MappingGraph::getBottomUpMappingsFrom | ( | core::behavior::BaseMechanicalState * | state | ) | const |
Retrieves all mapping components that depend on (receive input from) the provided mechanical state. This is used for bottom-up dependency checks.
| mstate | The mechanical state acting as an input source. |
| const sofa::type::vector< core::behavior::BaseMechanicalState * > & sofa::simulation::MappingGraph::getMainMechanicalStates | ( | ) | const |
Gets the list of all main mechanical states that are not used as outputs in any mapping (i.e., they are root inputs).
| type::Vec2u sofa::simulation::MappingGraph::getPositionInGlobalMatrix | ( | core::behavior::BaseMechanicalState * | a, |
| core::behavior::BaseMechanicalState * | b | ||
| ) | const |
Finds the global matrix indices where two specified states contribute their degrees of freedom. (Used for cross-axis checks).
| a | The first mechanical state. |
| b | The second mechanical state. |
| type::Vec2u sofa::simulation::MappingGraph::getPositionInGlobalMatrix | ( | core::behavior::BaseMechanicalState * | mstate | ) | const |
Finds the global matrix indices (row/column) where a specific state contributes its degrees of freedom.
| mstate | The mechanical state. |
| core::objectmodel::BaseContext * sofa::simulation::MappingGraph::getRootNode | ( | ) | const |
Returns the root node used during the initial construction of the graph.
| MappingGraph::MappingInputs sofa::simulation::MappingGraph::getTopMostMechanicalStates | ( | core::behavior::BaseMechanicalState * | state | ) | const |
Recursively finds top-most mechanical states that are unmapped but serve as inputs to a mapping involving the provided state.
This search is recursive, handling multiple levels of dependencies.
| state | The starting mechanical state for dependency checking. |
state. | MappingGraph::MappingInputs sofa::simulation::MappingGraph::getTopMostMechanicalStates | ( | core::behavior::StateAccessor * | stateAccessor | ) | const |
Recursively finds top-most mechanical states that are unmapped but serve as inputs to a mapping involving the mechanical states associated with a given accessor.
This search is recursive, handling multiple levels of dependencies.
| stateAccessor | The starting state accessor for dependency checking. |
stateAccessor. | sofa::Size sofa::simulation::MappingGraph::getTotalNbMainDofs | ( | ) | const |
Calculates the total number of degrees of freedom (DoF) contributed by all main mechanical states in the graph.
| bool sofa::simulation::MappingGraph::hasAnyMapping | ( | ) | const |
Checks if any mapping exists anywhere in the graph structure.
| bool sofa::simulation::MappingGraph::hasAnyMappingInput | ( | core::behavior::BaseMechanicalState * | mstate | ) | const |
Determines if a specific mechanical state is an output of any mapping node connected to the graph.
| mstate | The mechanical state to check. |
mstate is an output, false otherwise. | bool sofa::simulation::MappingGraph::hasAnyMappingInput | ( | core::behavior::StateAccessor * | stateAccessor | ) | const |
Determines if the mechanical states associated with a component are outputs of any mapping node connected to the graph.
| stateAccessor | The state accessor for the component to check. |
| bool sofa::simulation::MappingGraph::isBuilt | ( | ) | const |
Checks if the graph has been successfully built and analyzed.
|
friend |