VisualGrid
Display a simple grid.
Displays a simple grid within a SOFA simulation scene, configurable by plane, size, subdivisions, color, and line thickness.
- module
- Sofa.Component.Visual
- namespace
- sofa::component::visual
- include
- sofa/component/visual/VisualGrid.h
- inherits
-
- VisualModel
- description
The VisualGrid component in the SOFA framework is designed to display a simple grid within a simulation scene for visualization purposes. It does not contribute directly to any governing equations, constitutive laws, or numerical methods related to continuum mechanics or finite element method (FEM) simulations. Instead, it serves as a purely visual aid that can be oriented along any plane (x, y, or z) and is configured through several parameters such as size, subdivisions, color, and thickness.
Key Features:
- Plane of the Grid: The grid can be oriented in one of three planes: x, y, or z. This orientation is specified by a
PlaneTypeenumeration with possible values 'x', 'y', or 'z'. - Size of the Grid: The size parameter defines the extent of the squared grid.
- Number of Subdivisions: This parameter determines how many subdivisions are made within the grid, which affects the density and detail of the grid lines. The minimum number of subdivisions is 2.
- Color of Lines: The color parameter specifies the RGB(A) values for the grid lines. Default value is (0.34, 0.34, 0.34, 1.0), representing a gray color with full opacity.
- Thickness of Lines: This parameter controls the thickness of the grid lines drawn on the screen.
Mathematical Description:
Although the VisualGrid component does not involve any significant mathematical or physical formulations relevant to FEM simulations, it still provides some structured data points for visualization purposes. Specifically, the buildGrid method calculates a set of points (m_drawnPoints) that represent the lines of the grid. These points are computed based on user-defined parameters and the chosen plane.
The following steps outline how these points are determined:
1. Initialization: The grid is initialized with specified size, subdivisions, color, and thickness values during the init() method call.
2. Grid Construction: In the buildGrid function, the grid lines are computed for each plane (x, y, or z) using a loop to generate equidistant points along the defined axis. The number of divisions (nbSubdiv) and size (d_size) parameters control these calculations.
3. Drawing Lines: During visualization, the doDrawVisual method uses the precomputed points from m_drawnPoints to draw lines on the screen using the specified thickness and color.
Role in FEM Pipeline:
- The VisualGrid component does not play any role in the core stages of the FEM pipeline (e.g., spatial discretization, time integration, nonlinear solve, linear solve). Instead, it is a visualization tool that complements the simulation by providing reference grids within the scene.
Numerical Methods and Discretization:
- No numerical methods or discretization choices are encoded in this component since its sole purpose is to aid visual understanding rather than contribute to the computational mechanics of the system.
In summary, the VisualGrid component serves as a simple yet effective visualization tool within the SOFA framework, enhancing user interaction and aiding in the interpretation of simulation results by providing grid references.
Data Fields
| Name | Type | Default | Help |
|---|---|---|---|
d_plane |
PlaneType | |
Plane of the grid\n |
d_size |
float | |
Size of the squared grid |
d_nbSubdiv |
int | |
Number of subdivisions |
d_color |
sofa::type::RGBAColor | |
Color of the lines in the grid. default=(0.34,0.34,0.34,1.0) |
d_thickness |
float | |
Thickness of the lines in the grid |
Methods
void
init
()
virtual
void
reinit
()
virtual
void
doDrawVisual
(const core::visual::VisualParams * )
virtual
void
doUpdateVisual
(const core::visual::VisualParams * )
virtual
void
updateGrid
()
void
buildGrid
()
{
"name": "VisualGrid",
"namespace": "sofa::component::visual",
"module": "Sofa.Component.Visual",
"include": "sofa/component/visual/VisualGrid.h",
"doc": "Display a simple grid.",
"inherits": [
"VisualModel"
],
"templates": [],
"data_fields": [
{
"name": "d_plane",
"type": "PlaneType",
"xmlname": "z",
"help": "Plane of the grid\\n"
},
{
"name": "d_size",
"type": "float",
"xmlname": "size",
"help": "Size of the squared grid"
},
{
"name": "d_nbSubdiv",
"type": "int",
"xmlname": "nbSubdiv",
"help": "Number of subdivisions"
},
{
"name": "d_color",
"type": "sofa::type::RGBAColor",
"xmlname": "color",
"help": "Color of the lines in the grid. default=(0.34,0.34,0.34,1.0)"
},
{
"name": "d_thickness",
"type": "float",
"xmlname": "thickness",
"help": "Thickness of the lines in the grid"
}
],
"links": [],
"methods": [
{
"name": "init",
"return_type": "void",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "reinit",
"return_type": "void",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "doDrawVisual",
"return_type": "void",
"params": [
{
"name": "",
"type": "const core::visual::VisualParams *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "doUpdateVisual",
"return_type": "void",
"params": [
{
"name": "",
"type": "const core::visual::VisualParams *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "updateGrid",
"return_type": "void",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "buildGrid",
"return_type": "void",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
}
],
"description": "The **VisualGrid** is a visual component in the SOFA framework designed to display a simple grid within a simulation scene. It inherits from `core::visual::VisualModel` and provides a configurable grid that can be oriented along any plane (x, y, or z). The grid's size, subdivisions, color, and thickness are user-defined parameters.\n\n**Interactions with Other Components:**\n- **Inheritance**: VisualGrid extends the `VisualModel`, allowing it to integrate seamlessly into SOFA’s scene graph for visualization purposes. This integration ensures that the grid is correctly rendered alongside other visual components in the simulation environment.\n- **Callbacks and Updates**: The component implements methods such as `init()`, `reinit()`, `doDrawVisual()`, and `doUpdateVisual()` to synchronize its state with other parts of the scene graph, ensuring proper rendering during each frame update.\n\n**Practical Usage Guidance:**\n- **Configuration Parameters:*\n - *plane*: Specifies the plane (x, y, or z) on which the grid is oriented. Default value is `z`.\n - *size*: Determines the size of the squared grid. Default value is `10.0f`.\n - *nbSubdiv*: Defines the number of subdivisions within the grid. Minimum value is `2`. \n - *color*: Sets the color of the grid lines, defaulting to `(0.34, 0.34, 0.34, 1.0)` (gray).\n - *thickness*: Specifies the thickness of the grid lines.\n- **Initialization and Updates**: The `init()` method initializes the grid, while `updateGrid()` and `buildGrid()` handle dynamic updates to ensure the grid remains consistent with user-defined parameters. These methods are called during scene initialization and when visual states need updating.",
"maths": "The **VisualGrid** component in the SOFA framework is designed to display a simple grid within a simulation scene for visualization purposes. It does not contribute directly to any governing equations, constitutive laws, or numerical methods related to continuum mechanics or finite element method (FEM) simulations. Instead, it serves as a purely visual aid that can be oriented along any plane (x, y, or z) and is configured through several parameters such as size, subdivisions, color, and thickness.\n\n### Key Features:\n- **Plane of the Grid:** The grid can be oriented in one of three planes: x, y, or z. This orientation is specified by a `PlaneType` enumeration with possible values 'x', 'y', or 'z'.\n- **Size of the Grid:** The size parameter defines the extent of the squared grid.\n- **Number of Subdivisions:** This parameter determines how many subdivisions are made within the grid, which affects the density and detail of the grid lines. The minimum number of subdivisions is 2.\n- **Color of Lines:** The color parameter specifies the RGB(A) values for the grid lines. Default value is (0.34, 0.34, 0.34, 1.0), representing a gray color with full opacity.\n- **Thickness of Lines:** This parameter controls the thickness of the grid lines drawn on the screen.\n\n### Mathematical Description:\nAlthough the VisualGrid component does not involve any significant mathematical or physical formulations relevant to FEM simulations, it still provides some structured data points for visualization purposes. Specifically, the `buildGrid` method calculates a set of points (`m_drawnPoints`) that represent the lines of the grid. These points are computed based on user-defined parameters and the chosen plane.\n\nThe following steps outline how these points are determined:\n1. **Initialization:** The grid is initialized with specified size, subdivisions, color, and thickness values during the `init()` method call.\n2. **Grid Construction:** In the `buildGrid` function, the grid lines are computed for each plane (x, y, or z) using a loop to generate equidistant points along the defined axis. The number of divisions (`nbSubdiv`) and size (`d_size`) parameters control these calculations.\n3. **Drawing Lines:** During visualization, the `doDrawVisual` method uses the precomputed points from `m_drawnPoints` to draw lines on the screen using the specified thickness and color.\n\n### Role in FEM Pipeline:\n- The VisualGrid component does not play any role in the core stages of the FEM pipeline (e.g., spatial discretization, time integration, nonlinear solve, linear solve). Instead, it is a visualization tool that complements the simulation by providing reference grids within the scene.\n\n### Numerical Methods and Discretization:\n- No numerical methods or discretization choices are encoded in this component since its sole purpose is to aid visual understanding rather than contribute to the computational mechanics of the system.\n\nIn summary, the VisualGrid component serves as a simple yet effective visualization tool within the SOFA framework, enhancing user interaction and aiding in the interpretation of simulation results by providing grid references.",
"abstract": "Displays a simple grid within a SOFA simulation scene, configurable by plane, size, subdivisions, color, and line thickness.",
"sheet": "# VisualGrid\n\n**Overview:**\nVisualGrid is a visual component in the SOFA framework that displays a simple grid within a simulation scene. It inherits from `core::visual::VisualModel` and provides parameters for configuring the grid's plane, size, subdivisions, color, and line thickness.\n\n**Parameters and Data:*\n- *plane*: Specifies the plane (x, y, or z) on which the grid is oriented. Default value is `z`.\n- *size*: Determines the size of the squared grid. Default value is `10.0f`.\n- *nbSubdiv*: Defines the number of subdivisions within the grid. Minimum value is `2`. \n- *color*: Sets the color of the grid lines, defaulting to `(0.34, 0.34, 0.34, 1.0)` (gray).\n- *thickness*: Specifies the thickness of the grid lines.\n\n**Practical Notes:**\nThe `init()` method initializes the grid, while `updateGrid()` and `buildGrid()` handle dynamic updates to ensure the grid remains consistent with user-defined parameters. These methods are called during scene initialization and when visual states need updating."
}