Back

BaseState

The `BaseState` class in the SOFA framework is an abstract base class that stores position and velocity vectors. It defines the interface for components used as sources and destinations of regular (non-mechanical) mappings within the scene graph. This class can be specialized into more specific types like `MechanicalState`, which handles additional mechanical data, or `MappedModel`, which deals with non-mechanical models such as visual representations. `BaseState` inherits from `BaseObject`, making it part of the SOFA object model. Its primary role is to provide a consistent interface for accessing and manipulating state vectors (positions and velocities) that are essential for simulation components like force fields, constraints, and mappings. The class defines several virtual methods such as `getSize()`, `resize()`, `baseWrite()`, and `baseRead()` that need to be implemented by derived classes. The `insertInNode` and `removeInNode` methods manage the insertion and removal of the state object from a node in the scene graph. The `addToTotalForces` and `removeFromTotalForces` methods are used for managing force accumulation, allowing simulation components to track total forces acting on objects. Practically, this class is foundational for any component that needs to interact with or manipulate position and velocity data within a SOFA simulation.

abstract
`BaseState` stores position and velocity vectors, providing an interface for managing state data in SOFA simulations.
sheet
# BaseState **Overview** The `BaseState` class is an abstract base component in the SOFA framework that manages position and velocity vectors. It defines methods for resizing, reading, writing, and force management, serving as a foundational interface for simulation components. **Dependencies and Connections** `BaseState` typically requires derived classes such as `MechanicalState` or `MappedModel`. These derived classes implement the virtual methods defined in `BaseState`, allowing them to interact with position and velocity data within the scene graph. The class is part of the SOFA object model, inheriting from `BaseObject`, and interacts with other components through the scene graph. **Practical Notes** Derived classes must implement pure virtual methods such as `resize()` and `baseWrite()`. Proper implementation ensures consistent data management across different simulation components. The class is essential for maintaining the integrity of state variables in SOFA simulations.
description
The `BaseState` class in the SOFA framework is an abstract base class that stores position and velocity vectors. It defines the interface for components used as sources and destinations of regular (non-mechanical) mappings within the scene graph. This class can be specialized into more specific types like `MechanicalState`, which handles additional mechanical data, or `MappedModel`, which deals with non-mechanical models such as visual representations. `BaseState` inherits from `BaseObject`, making it part of the SOFA object model. Its primary role is to provide a consistent interface for accessing and manipulating state vectors (positions and velocities) that are essential for simulation components like force fields, constraints, and mappings. The class defines several virtual methods such as `getSize()`, `resize()`, `baseWrite()`, and `baseRead()` that need to be implemented by derived classes. The `insertInNode` and `removeInNode` methods manage the insertion and removal of the state object from a node in the scene graph. The `addToTotalForces` and `removeFromTotalForces` methods are used for managing force accumulation, allowing simulation components to track total forces acting on objects. Practically, this class is foundational for any component that needs to interact with or manipulate position and velocity data within a SOFA simulation.
maths
The `BaseState` class in the SOFA framework is an abstract base class designed to store position and velocity vectors. It acts as a foundational interface for components that need to interact with or manipulate these state variables during simulation. ### Mathematical Description: - **Position Vectors**: The positions of particles or elements are represented by vectors, denoted here as \(\mathbf{p}\). - **Velocity Vectors**: The velocities of particles or elements are also represented by vectors, denoted as \(\mathbf{v}\). ### Role in Simulation: 1. **Data Storage**: - `BaseState` provides a consistent interface for storing and manipulating state data such as position (\(\mathbf{p}\)) and velocity (\(\mathbf{v}\)). - The size of these vectors is managed through the methods `getSize()` and `resize(Size vsize)`. 2. **Data Access**: - Methods like `baseWrite(VecId v)` and `baseRead(ConstVecId v)` allow derived classes to access and modify the state data in a standardized manner. ```cpp objectmodel::BaseData* baseWrite(VecId v) = 0; const objectmodel::BaseData* baseRead(ConstVecId v) const = 0; ``` - These methods are crucial for ensuring that different components can consistently interact with the state data. 3. **Force Management**: - `addToTotalForces(core::ConstVecDerivId forceId)` and `removeFromTotalForces(core::ConstVecDerivId forceId)` are used to manage forces acting on objects within the simulation. These methods help in accumulating forces from different sources, such as force fields and constraints. ```cpp void addToTotalForces(core::ConstVecDerivId forceId); void removeFromTotalForces(core::ConstVecDerivId forceId); `` - This functionality is essential for accurate simulation dynamics, where the net forces need to be tracked and applied correctly. 4. **Scene Graph Management**: - Methods like `insertInNode(objectmodel::BaseNode* node)` and `removeInNode(objectmodel::BaseNode* node)` manage the insertion and removal of state objects from a node in the scene graph, allowing for dynamic simulation setups. ```cpp bool insertInNode( objectmodel::BaseNode* node ) override; bool removeInNode( objectmodel::BaseNode* node ) override; `` - This is important for maintaining the hierarchical structure of the SOFA scene graph and ensuring that state data is correctly associated with simulation nodes. ### Physical Context: - The `BaseState` class is a fundamental building block in the physical simulation process, as it provides the necessary infrastructure to manage the position and velocity vectors that describe the kinematic state of objects within the simulation. - It serves as an abstract base for more specific classes such as `MechanicalState`, which can handle additional mechanical data required for physically-based simulations. ### Summary: The `BaseState` class is essential for maintaining the consistency and correctness of position and velocity data in SOFA simulations. Its methods provide a robust interface for accessing, modifying, and managing state variables, ensuring that various simulation components can interact with these critical data structures seamlessly.
{
  "name": "BaseState",
  "main": {
    "name": "BaseState",
    "namespace": "sofa::core",
    "module": "Sofa.framework.Core",
    "include": "sofa/core/BaseState.h",
    "doc": "Component storing position and velocity vectors.\n This class define the interface of components used as source and\n destination of regular (non mechanical) mapping. It is then specialized as\n MechanicalState (storing other mechanical data) or MappedModel (if no\n mechanical data is used, such as for VisualModel).",
    "inherits": [
      "BaseObject"
    ],
    "templates": [],
    "data_fields": [],
    "links": [],
    "methods": [
      {
        "name": "toBaseState",
        "return_type": "const BaseState *",
        "params": [],
        "is_virtual": true,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "getSize",
        "return_type": "int",
        "params": [],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "resize",
        "return_type": "void",
        "params": [
          {
            "name": "vsize",
            "type": "int"
          }
        ],
        "is_virtual": true,
        "is_pure_virtual": true,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "baseWrite",
        "return_type": "objectmodel::BaseData *",
        "params": [
          {
            "name": "v",
            "type": "VecId"
          }
        ],
        "is_virtual": true,
        "is_pure_virtual": true,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "baseRead",
        "return_type": "const objectmodel::BaseData *",
        "params": [
          {
            "name": "v",
            "type": "ConstVecId"
          }
        ],
        "is_virtual": true,
        "is_pure_virtual": true,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "insertInNode",
        "return_type": "bool",
        "params": [
          {
            "name": "node",
            "type": "objectmodel::BaseNode *"
          }
        ],
        "is_virtual": true,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "removeInNode",
        "return_type": "bool",
        "params": [
          {
            "name": "node",
            "type": "objectmodel::BaseNode *"
          }
        ],
        "is_virtual": true,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "addToTotalForces",
        "return_type": "void",
        "params": [
          {
            "name": "forceId",
            "type": "core::ConstVecDerivId"
          }
        ],
        "is_virtual": true,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "removeFromTotalForces",
        "return_type": "void",
        "params": [
          {
            "name": "forceId",
            "type": "core::ConstVecDerivId"
          }
        ],
        "is_virtual": true,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      }
    ]
  },
  "desc": {
    "description": "The `BaseState` class in the SOFA framework is an abstract base class that stores position and velocity vectors. It defines the interface for components used as sources and destinations of regular (non-mechanical) mappings within the scene graph. This class can be specialized into more specific types like `MechanicalState`, which handles additional mechanical data, or `MappedModel`, which deals with non-mechanical models such as visual representations.\n\n`BaseState` inherits from `BaseObject`, making it part of the SOFA object model. Its primary role is to provide a consistent interface for accessing and manipulating state vectors (positions and velocities) that are essential for simulation components like force fields, constraints, and mappings. The class defines several virtual methods such as `getSize()`, `resize()`, `baseWrite()`, and `baseRead()` that need to be implemented by derived classes.\n\nThe `insertInNode` and `removeInNode` methods manage the insertion and removal of the state object from a node in the scene graph. The `addToTotalForces` and `removeFromTotalForces` methods are used for managing force accumulation, allowing simulation components to track total forces acting on objects.\n\nPractically, this class is foundational for any component that needs to interact with or manipulate position and velocity data within a SOFA simulation."
  },
  "maths": {
    "maths": "The `BaseState` class in the SOFA framework is an abstract base class designed to store position and velocity vectors. It acts as a foundational interface for components that need to interact with or manipulate these state variables during simulation.\n\n### Mathematical Description:\n- **Position Vectors**: The positions of particles or elements are represented by vectors, denoted here as \\(\\mathbf{p}\\).\n- **Velocity Vectors**: The velocities of particles or elements are also represented by vectors, denoted as \\(\\mathbf{v}\\).\n\n### Role in Simulation:\n1. **Data Storage**:\n   - `BaseState` provides a consistent interface for storing and manipulating state data such as position (\\(\\mathbf{p}\\)) and velocity (\\(\\mathbf{v}\\)).\n   - The size of these vectors is managed through the methods `getSize()` and `resize(Size vsize)`.\n\n2. **Data Access**:\n   - Methods like `baseWrite(VecId v)` and `baseRead(ConstVecId v)` allow derived classes to access and modify the state data in a standardized manner.\n     ```cpp\n     objectmodel::BaseData* baseWrite(VecId v) = 0;\n     const objectmodel::BaseData* baseRead(ConstVecId v) const = 0;\n     ```\n   - These methods are crucial for ensuring that different components can consistently interact with the state data.\n\n3. **Force Management**:\n   - `addToTotalForces(core::ConstVecDerivId forceId)` and `removeFromTotalForces(core::ConstVecDerivId forceId)` are used to manage forces acting on objects within the simulation. These methods help in accumulating forces from different sources, such as force fields and constraints.\n     ```cpp\n     void addToTotalForces(core::ConstVecDerivId forceId);\n     void removeFromTotalForces(core::ConstVecDerivId forceId);\n     ``\n   - This functionality is essential for accurate simulation dynamics, where the net forces need to be tracked and applied correctly.\n\n4. **Scene Graph Management**:\n   - Methods like `insertInNode(objectmodel::BaseNode* node)` and `removeInNode(objectmodel::BaseNode* node)` manage the insertion and removal of state objects from a node in the scene graph, allowing for dynamic simulation setups.\n     ```cpp\n     bool insertInNode( objectmodel::BaseNode* node ) override;\n     bool removeInNode( objectmodel::BaseNode* node ) override;\n     ``\n   - This is important for maintaining the hierarchical structure of the SOFA scene graph and ensuring that state data is correctly associated with simulation nodes.\n\n### Physical Context:\n- The `BaseState` class is a fundamental building block in the physical simulation process, as it provides the necessary infrastructure to manage the position and velocity vectors that describe the kinematic state of objects within the simulation.\n- It serves as an abstract base for more specific classes such as `MechanicalState`, which can handle additional mechanical data required for physically-based simulations.\n\n### Summary:\nThe `BaseState` class is essential for maintaining the consistency and correctness of position and velocity data in SOFA simulations. Its methods provide a robust interface for accessing, modifying, and managing state variables, ensuring that various simulation components can interact with these critical data structures seamlessly."
  },
  "summary": {
    "abstract": "`BaseState` stores position and velocity vectors, providing an interface for managing state data in SOFA simulations.",
    "sheet": "# BaseState\n\n**Overview**\n\nThe `BaseState` class is an abstract base component in the SOFA framework that manages position and velocity vectors. It defines methods for resizing, reading, writing, and force management, serving as a foundational interface for simulation components.\n\n**Dependencies and Connections**\n\n`BaseState` typically requires derived classes such as `MechanicalState` or `MappedModel`. These derived classes implement the virtual methods defined in `BaseState`, allowing them to interact with position and velocity data within the scene graph. The class is part of the SOFA object model, inheriting from `BaseObject`, and interacts with other components through the scene graph.\n\n**Practical Notes**\n\nDerived classes must implement pure virtual methods such as `resize()` and `baseWrite()`. Proper implementation ensures consistent data management across different simulation components. The class is essential for maintaining the integrity of state variables in SOFA simulations."
  }
}