BaseContext
- abstract
- BaseContext manages shared variables and parameters for a group of simulation objects, providing methods to access mechanical states, topology, and other components within the scene graph hierarchy.
- sheet
- # BaseContext ## Overview BaseContext is a foundational class in SOFA that stores shared variables and parameters for a group of simulation objects. It provides methods to access various components such as mechanical states, topology, and other objects within the scene graph hierarchy. ## Parameters and Data BaseContext does not expose any significant data fields directly; its functionality revolves around managing dependencies and interactions between different parts of the simulation. ## Dependencies and Connections BaseContext typically requires or exchanges data with other SOFA components such as mechanical states, topology, and various objects within the scene graph. It fits into the scene graph by providing a context for these components to interact efficiently.
No description data.
- maths
- The provided code snippet is part of the Simulation Open Framework Application (SOFA) library, which is used for physics-based simulation in computer graphics and biomechanics. The `BaseContext` class within the `core::objectmodel` namespace serves as a foundational context object that holds various components of a simulation such as mechanical states, topology, and other objects. This class implements methods to access these components through different means like direction (up or down) from the current context, by tag, or using a path string. The mathematical and physical descriptions are derived primarily from how this class interacts with the physics engine and manages dependencies between simulation entities. ### Mathematical and Physical Description: #### Generic Object Access: The `BaseContext` class provides several methods for accessing objects within its hierarchical structure. These include generic template wrappers like `T* get(SearchDirection dir = SearchUp) const`, which allows retrieving an object of type `T` based on a search direction (up or down). The search direction is critical because it determines the traversal path through the simulation's graph, which can be thought of as a directed acyclic graph (DAG). #### Topology and Mechanical States: The class has methods such as `setTopology(BaseObject*)`, `getMechanicalState()`, indicating that these entities are managed within this context. The topology represents the connectivity between elements in the simulation, which can be described mathematically using adjacency matrices or graphs. Each element’s state (position, velocity, acceleration) is part of the mechanical state and evolves over time based on physical laws such as Newton's equations. #### Event Propagation: The `propagateEvent` method demonstrates how events are handled within SOFA. Events can represent changes in state due to external forces or internal dynamics. The propagation mechanism involves distributing these changes across the simulation graph, which is often modeled using numerical methods for partial differential equations (PDEs) that govern physical interactions. #### Graph Traversal and Search: The class implements functionality to search through its hierarchy with methods such as `hasAncestor`, which checks if one context is an ancestor of another. This traversal is vital for maintaining consistency across the simulation, where changes in one part may affect other interconnected components. The graph structure allows for efficient management of dependencies between objects. #### Tag-based Access: The use of tags to identify specific objects or groups of objects within the context provides a flexible way to manage complex simulations with multiple interacting parts. Tags can be used to filter objects by type, state, or any other property that is relevant to the simulation. ### Conclusion: The `BaseContext` class plays an essential role in SOFA’s architecture by providing mechanisms for accessing and managing simulation components efficiently. The methods within this class are designed to work seamlessly with the underlying mathematical models of physical systems, ensuring accurate and consistent simulations across various contexts.
{
"name": "BaseContext",
"main": {
"name": "BaseContext",
"namespace": "sofa::core::objectmodel",
"module": "Sofa.framework.Core",
"include": "sofa/core/objectmodel/BaseContext.h",
"doc": "Base class for Context classes, storing shared variables and parameters.\n A Context contains values or pointers to variables and parameters shared\n by a group of objects, typically referring to the same simulated body.\n Derived classes can defined simple isolated contexts or more powerful\n hierarchical representations (scene-graphs), in which case the context also\n implements the BaseNode interface.\n\\author Jeremie Allard",
"inherits": [
"Base"
],
"templates": [],
"data_fields": [],
"links": [],
"methods": [
{
"name": "toBaseContext",
"return_type": "const BaseContext *",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getDefault",
"return_type": "BaseContext *",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": true,
"access": "public"
},
{
"name": "isActive",
"return_type": "bool",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setActive",
"return_type": "void",
"params": [
{
"name": "",
"type": "bool"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "isSleeping",
"return_type": "bool",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "canChangeSleepingState",
"return_type": "bool",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getTime",
"return_type": "SReal",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getDt",
"return_type": "SReal",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getAnimate",
"return_type": "bool",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getGravity",
"return_type": "const Vec3 &",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setGravity",
"return_type": "void",
"params": [
{
"name": "",
"type": "const Vec3 &"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getRootContext",
"return_type": "BaseContext *",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getState",
"return_type": "core::BaseState *",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getMechanicalState",
"return_type": "behavior::BaseMechanicalState *",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getTopology",
"return_type": "core::topology::Topology *",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getMeshTopology",
"return_type": "core::topology::BaseMeshTopology *",
"params": [
{
"name": "dir",
"type": "SearchDirection"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getMeshTopologyLink",
"return_type": "core::topology::BaseMeshTopology *",
"params": [
{
"name": "dir",
"type": "SearchDirection"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getMass",
"return_type": "core::behavior::BaseMass *",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getShader",
"return_type": "core::visual::Shader *",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getObject",
"return_type": "void *",
"params": [
{
"name": "class_info",
"type": "const ClassInfo &"
},
{
"name": "dir",
"type": "SearchDirection"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getObject",
"return_type": "void *",
"params": [
{
"name": "class_info",
"type": "const ClassInfo &"
},
{
"name": "tags",
"type": "const TagSet &"
},
{
"name": "dir",
"type": "SearchDirection"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getObject",
"return_type": "void *",
"params": [
{
"name": "class_info",
"type": "const ClassInfo &"
},
{
"name": "path",
"type": "const int &"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getObjects",
"return_type": "void",
"params": [
{
"name": "class_info",
"type": "const ClassInfo &"
},
{
"name": "container",
"type": "GetObjectsCallBack &"
},
{
"name": "dir",
"type": "SearchDirection"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getObjects",
"return_type": "void",
"params": [
{
"name": "class_info",
"type": "const ClassInfo &"
},
{
"name": "container",
"type": "GetObjectsCallBack &"
},
{
"name": "tags",
"type": "const TagSet &"
},
{
"name": "dir",
"type": "SearchDirection"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getObjects",
"return_type": "void",
"params": [
{
"name": "list",
"type": "Container *"
},
{
"name": "dir",
"type": "SearchDirection"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getObjects",
"return_type": "Container &",
"params": [
{
"name": "result",
"type": "Container &"
},
{
"name": "dir",
"type": "SearchDirection"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getObjects",
"return_type": "int",
"params": [
{
"name": "dir",
"type": "SearchDirection"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "get",
"return_type": "T *",
"params": [
{
"name": "dir",
"type": "SearchDirection"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "get",
"return_type": "void",
"params": [
{
"name": "ptr",
"type": "T *&"
},
{
"name": "dir",
"type": "SearchDirection"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "get",
"return_type": "void",
"params": [
{
"name": "ptr",
"type": "int &"
},
{
"name": "dir",
"type": "SearchDirection"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "get",
"return_type": "T *",
"params": [
{
"name": "tag",
"type": "const Tag &"
},
{
"name": "dir",
"type": "SearchDirection"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "get",
"return_type": "void",
"params": [
{
"name": "ptr",
"type": "T *&"
},
{
"name": "tag",
"type": "const Tag &"
},
{
"name": "dir",
"type": "SearchDirection"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "get",
"return_type": "void",
"params": [
{
"name": "ptr",
"type": "int &"
},
{
"name": "tag",
"type": "const Tag &"
},
{
"name": "dir",
"type": "SearchDirection"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "get",
"return_type": "T *",
"params": [
{
"name": "tags",
"type": "const TagSet &"
},
{
"name": "dir",
"type": "SearchDirection"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "get",
"return_type": "void",
"params": [
{
"name": "ptr",
"type": "T *&"
},
{
"name": "tags",
"type": "const TagSet &"
},
{
"name": "dir",
"type": "SearchDirection"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "get",
"return_type": "void",
"params": [
{
"name": "ptr",
"type": "int &"
},
{
"name": "tags",
"type": "const TagSet &"
},
{
"name": "dir",
"type": "SearchDirection"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "get",
"return_type": "T *",
"params": [
{
"name": "path",
"type": "const int &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "get",
"return_type": "void",
"params": [
{
"name": "ptr",
"type": "T *&"
},
{
"name": "path",
"type": "const int &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "get",
"return_type": "void",
"params": [
{
"name": "ptr",
"type": "int &"
},
{
"name": "path",
"type": "const int &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "get",
"return_type": "void",
"params": [
{
"name": "list",
"type": "Container *"
},
{
"name": "dir",
"type": "SearchDirection"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "get",
"return_type": "void",
"params": [
{
"name": "list",
"type": "Container *"
},
{
"name": "tag",
"type": "const Tag &"
},
{
"name": "dir",
"type": "SearchDirection"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "get",
"return_type": "void",
"params": [
{
"name": "list",
"type": "Container *"
},
{
"name": "tags",
"type": "const TagSet &"
},
{
"name": "dir",
"type": "SearchDirection"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setDt",
"return_type": "void",
"params": [
{
"name": "",
"type": "SReal"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setAnimate",
"return_type": "void",
"params": [
{
"name": "",
"type": "bool"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setSleeping",
"return_type": "void",
"params": [
{
"name": "",
"type": "bool"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setChangeSleepingState",
"return_type": "void",
"params": [
{
"name": "",
"type": "bool"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setMechanicalState",
"return_type": "void",
"params": [
{
"name": "",
"type": "BaseObject *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setTopology",
"return_type": "void",
"params": [
{
"name": "",
"type": "BaseObject *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "hasAncestor",
"return_type": "bool",
"params": [
{
"name": "",
"type": "const BaseContext *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "addObject",
"return_type": "bool",
"params": [
{
"name": "",
"type": "int"
},
{
"name": "",
"type": "TypeOfInsertion"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "removeObject",
"return_type": "bool",
"params": [
{
"name": "",
"type": "int"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getNameHelper",
"return_type": "ComponentNameHelper &",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "executeVisitor",
"return_type": "void",
"params": [
{
"name": "",
"type": "simulation::Visitor *"
},
{
"name": "precomputedOrder",
"type": "bool"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "propagateEvent",
"return_type": "void",
"params": [
{
"name": "params",
"type": "const core::ExecParams *"
},
{
"name": "",
"type": "Event *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "notifyAddSlave",
"return_type": "void",
"params": [
{
"name": "master",
"type": "core::objectmodel::BaseObject *"
},
{
"name": "slave",
"type": "core::objectmodel::BaseObject *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "notifyRemoveSlave",
"return_type": "void",
"params": [
{
"name": "master",
"type": "core::objectmodel::BaseObject *"
},
{
"name": "slave",
"type": "core::objectmodel::BaseObject *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "notifyMoveSlave",
"return_type": "void",
"params": [
{
"name": "previousMaster",
"type": "core::objectmodel::BaseObject *"
},
{
"name": "master",
"type": "core::objectmodel::BaseObject *"
},
{
"name": "slave",
"type": "core::objectmodel::BaseObject *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
}
]
},
"desc": {},
"maths": {
"maths": "The provided code snippet is part of the Simulation Open Framework Application (SOFA) library, which is used for physics-based simulation in computer graphics and biomechanics. The `BaseContext` class within the `core::objectmodel` namespace serves as a foundational context object that holds various components of a simulation such as mechanical states, topology, and other objects. This class implements methods to access these components through different means like direction (up or down) from the current context, by tag, or using a path string. The mathematical and physical descriptions are derived primarily from how this class interacts with the physics engine and manages dependencies between simulation entities.\n\n### Mathematical and Physical Description:\n\n#### Generic Object Access:\nThe `BaseContext` class provides several methods for accessing objects within its hierarchical structure. These include generic template wrappers like `T* get(SearchDirection dir = SearchUp) const`, which allows retrieving an object of type `T` based on a search direction (up or down). The search direction is critical because it determines the traversal path through the simulation's graph, which can be thought of as a directed acyclic graph (DAG).\n\n#### Topology and Mechanical States:\nThe class has methods such as `setTopology(BaseObject*)`, `getMechanicalState()`, indicating that these entities are managed within this context. The topology represents the connectivity between elements in the simulation, which can be described mathematically using adjacency matrices or graphs. Each element’s state (position, velocity, acceleration) is part of the mechanical state and evolves over time based on physical laws such as Newton's equations.\n\n#### Event Propagation:\nThe `propagateEvent` method demonstrates how events are handled within SOFA. Events can represent changes in state due to external forces or internal dynamics. The propagation mechanism involves distributing these changes across the simulation graph, which is often modeled using numerical methods for partial differential equations (PDEs) that govern physical interactions.\n\n#### Graph Traversal and Search:\nThe class implements functionality to search through its hierarchy with methods such as `hasAncestor`, which checks if one context is an ancestor of another. This traversal is vital for maintaining consistency across the simulation, where changes in one part may affect other interconnected components. The graph structure allows for efficient management of dependencies between objects.\n\n#### Tag-based Access:\nThe use of tags to identify specific objects or groups of objects within the context provides a flexible way to manage complex simulations with multiple interacting parts. Tags can be used to filter objects by type, state, or any other property that is relevant to the simulation.\n\n### Conclusion:\nThe `BaseContext` class plays an essential role in SOFA’s architecture by providing mechanisms for accessing and managing simulation components efficiently. The methods within this class are designed to work seamlessly with the underlying mathematical models of physical systems, ensuring accurate and consistent simulations across various contexts."
},
"summary": {
"abstract": "BaseContext manages shared variables and parameters for a group of simulation objects, providing methods to access mechanical states, topology, and other components within the scene graph hierarchy.",
"sheet": "# BaseContext\n\n## Overview\nBaseContext is a foundational class in SOFA that stores shared variables and parameters for a group of simulation objects. It provides methods to access various components such as mechanical states, topology, and other objects within the scene graph hierarchy.\n\n## Parameters and Data\nBaseContext does not expose any significant data fields directly; its functionality revolves around managing dependencies and interactions between different parts of the simulation.\n\n## Dependencies and Connections\nBaseContext typically requires or exchanges data with other SOFA components such as mechanical states, topology, and various objects within the scene graph. It fits into the scene graph by providing a context for these components to interact efficiently."
}
}