OglColorMap
Provides color palette and support for conversion of numbers to colors.
The `OglColorMap` component provides color palettes and supports conversion of numerical values to colors for visualization purposes in SOFA simulations.
- module
- Sofa.GL.Component.Rendering2D
- namespace
- sofa::gl::component::rendering2d
- include
- sofa/gl/component/rendering2d/OglColorMap.h
- inherits
-
- VisualModel
- description
The Visitor class in the SOFA framework is not directly involved with the mathematical or physical models used for simulating deformable systems. Instead, it serves as a foundational mechanism to propagate behaviors and operations throughout the scene graph hierarchy. This class does not contribute any specific governing equations, constitutive laws, or discretization methods on its own but rather provides the infrastructure through which these aspects can be applied consistently across the simulation environment.
Role in the Global FEM Pipeline:
-
Assembly Phase: The
class facilitates the traversal of the scene graph to assemble contributions from various mechanical objects and components. It enables the execution of tasks that might involve assembling global matrices (like mass, stiffness) or computing internal forces.
-
Time Integration: While not directly involved in time integration methods like implicit Euler or Newmark schemes,
Visitorcan be used to execute custom logic that may influence how these steps are carried out. For example, operations performed during the traversal might affect state variables (positions, velocities) before and after each time step.
-
Nonlinear Solution: During nonlinear solution phases, visitors can help manage complex interactions by applying constraints or projecting forces between different components of the scene graph.
Numerical Methods:
class facilitates the traversal of the scene graph to assemble contributions from various mechanical objects and components. It enables the execution of tasks that might involve assembling global matrices (like mass, stiffness) or computing internal forces.
The Visitor class itself does not implement any specific numerical methods. However, it enables the use of such methods through its traversal mechanisms. For instance, operations like matrix assembly or force computation can be applied consistently across nodes and objects during a visitation process.
Constraint Handling:
While not directly managing constraints, visitors can be used to apply constraint-related logic during their traversal. Methods like begin and end, along with optional debugging methods (debug_write_state_before, debug_write_state_after), allow for the tracking of state changes that might include enforcing constraints.
Mapping:
The visitor mechanism does not directly handle mappings, but it can be used to apply logic related to mappings during traversal. For example, visitors can manage operations involving multi-resolution coupling or force consistency through various components in the scene graph.
Variational / Lagrangian Mechanics Framework:
The Visitor class supports the variational and Lagrangian mechanics framework by providing a means to consistently apply operations that contribute to the overall simulation. It ensures that all relevant nodes and objects are processed correctly, supporting the consistent application of physical laws and numerical methods throughout the scene graph.
Summary:
The Visitor is primarily an infrastructure component in SOFA, designed to enable recursive traversal of the scenegraph for applying various operations uniformly across different components. It does not directly contribute any mathematical or physical content but provides a robust framework within which these aspects can be effectively managed and applied.
Data Fields
| Name | Type | Default | Help |
|---|---|---|---|
d_paletteSize |
unsigned int | |
How many colors to use |
d_colorScheme |
sofa::helper::OptionsGroup | |
Color scheme to use |
d_showLegend |
bool | |
Activate rendering of color scale legend on the side |
d_legendOffset |
type::Vec2f | |
Draw the legend on screen with an x,y offset |
d_legendSize |
unsigned int | |
Font size of the legend (if any) |
d_min |
float | |
min value for drawing the legend without the need to actually use the range with getEvaluator method which sets the min |
d_max |
float | |
max value for drawing the legend without the need to actually use the range with getEvaluator method which sets the max |
d_legendRangeScale |
float | |
to change the unit of the min/max value of the legend |
Methods
void
init
()
virtual
void
reinit
()
virtual
void
doDrawVisual
(const core::visual::VisualParams * vparams)
virtual
unsigned int
getNbColors
()
Color
getColor
(unsigned int i)
OglColorMap *
getDefault
()
helper::ColorMap::evaluator<Real>
getEvaluator
(Real vmin, Real vmax)
{
"name": "OglColorMap",
"namespace": "sofa::gl::component::rendering2d",
"module": "Sofa.GL.Component.Rendering2D",
"include": "sofa/gl/component/rendering2d/OglColorMap.h",
"doc": "Provides color palette and support for conversion of numbers to colors.",
"inherits": [
"VisualModel"
],
"templates": [],
"data_fields": [
{
"name": "d_paletteSize",
"type": "unsigned int",
"xmlname": "paletteSize",
"help": "How many colors to use"
},
{
"name": "d_colorScheme",
"type": "sofa::helper::OptionsGroup",
"xmlname": "colorScheme",
"help": "Color scheme to use"
},
{
"name": "d_showLegend",
"type": "bool",
"xmlname": "showLegend",
"help": "Activate rendering of color scale legend on the side"
},
{
"name": "d_legendOffset",
"type": "type::Vec2f",
"xmlname": "legendOffset",
"help": "Draw the legend on screen with an x,y offset"
},
{
"name": "d_legendSize",
"type": "unsigned int",
"xmlname": "legendSize",
"help": "Font size of the legend (if any)"
},
{
"name": "d_min",
"type": "float",
"xmlname": "min",
"help": "min value for drawing the legend without the need to actually use the range with getEvaluator method which sets the min"
},
{
"name": "d_max",
"type": "float",
"xmlname": "max",
"help": "max value for drawing the legend without the need to actually use the range with getEvaluator method which sets the max"
},
{
"name": "d_legendRangeScale",
"type": "float",
"xmlname": "legendRangeScale",
"help": "to change the unit of the min/max value of the legend"
}
],
"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": "vparams",
"type": "const core::visual::VisualParams *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getNbColors",
"return_type": "unsigned int",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getColor",
"return_type": "Color",
"params": [
{
"name": "i",
"type": "unsigned int"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getDefault",
"return_type": "OglColorMap *",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": true,
"access": "public"
},
{
"name": "getEvaluator",
"return_type": "helper::ColorMap::evaluator<Real>",
"params": [
{
"name": "vmin",
"type": "Real"
},
{
"name": "vmax",
"type": "Real"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
}
],
"description": "The `OglColorMap` is a component in the SOFA framework designed to provide color palettes and support for converting numerical values into colors. It inherits from the `VisualModel` class, indicating its role in visual rendering within simulations. The component includes data fields to configure the size of the palette (`paletteSize`), the color scheme (`colorScheme`), and options for displaying a color legend (`showLegend`, `legendOffset`, `legendSize`). Additionally, it offers methods like `getNbColors()` and `getColor(unsigned int i)` to retrieve the number of colors in the palette and specific color values. The `getEvaluator(Real vmin, Real vmax)` method provides a means to evaluate colors within a specified value range. This component interacts with other SOFA components by being integrated into the visual rendering pipeline and may be used in conjunction with other visualization or data representation components.",
"maths": "The `OglColorMap` component in the SOFA framework serves primarily as a visual aid for representing scalar fields or numerical values through color mapping. This component does not contribute to any governing equations, constitutive laws, or kinematic formulations typical of FEM simulations. Instead, it focuses on rendering and visualization aspects by converting numerical data into visually interpretable colors. Here is a detailed description of its role and mathematical content:\n\n1. **Governing Equations / Operators**\n - The `OglColorMap` does not implement or contribute to any governing equations such as the mass matrix $M$, stiffness matrix $K$, internal force $\textbf{f}_{int}$, residual $R$, etc., that are central to FEM simulations. Its primary function is to provide a mapping from numerical values to colors.\n\n2. **Constitutive or Kinematic Laws**\n - The component does not involve any constitutive laws (such as stress-strain relationships) or kinematic laws (like strain measures). It simply defines mappings for color schemes, which are predefined or user-defined palettes of colors used to represent scalar values.\n\n3. **Role in the FEM Pipeline**\n - The `OglColorMap` is integrated into the visual rendering pipeline of SOFA simulations. It does not participate directly in the assembly phase (e.g., constructing global mass and force matrices), time integration, nonlinear resolution, linear solve, or constraint handling phases. Its role is limited to providing color mappings for visualization purposes.\n\n4. **Numerical Methods / Discretization Choices**\n - The component does not encode any numerical methods specific to FEM discretization (such as spatial or temporal discretizations). Instead, it provides a mechanism to convert scalar values into colors based on predefined color schemes and ranges.\n\n5. **Integration with Variational / Lagrangian Mechanics Framework**\n - While `OglColorMap` does not directly fit into the variational or Lagrangian mechanics framework, its functionality can be indirectly useful in visualizing results from such simulations. For instance, scalar fields derived from FEM solutions (e.g., stress, strain, displacement) can be mapped to colors using this component for better interpretability.\n\nIn summary, `OglColorMap` is a visualization tool that provides color mapping functionalities without any direct involvement in the core computational mechanics aspects of SOFA simulations.",
"abstract": "The `OglColorMap` component provides color palettes and supports conversion of numerical values to colors for visualization purposes in SOFA simulations.",
"sheet": "# OglColorMap\n\n## Overview\nThe `OglColorMap` is a visualization tool that inherits from the `VisualModel` class, providing functionalities for generating color palettes and converting scalar values into colors. It supports rendering of legends with customizable offsets and sizes.\n\n## Parameters and Data\n- **paletteSize**: Controls the number of colors in the palette (`unsigned int`, default: not specified).\n- **colorScheme**: Specifies the color scheme to use (`sofa::helper::OptionsGroup`, default: not specified).\n- **showLegend**: Activates rendering of a color scale legend on the side (`bool`, default: `false`).\n- **legendOffset**: Sets the x,y offset for drawing the legend (`type::Vec2f`, default: not specified).\n- **legendSize**: Determines the font size of the legend (`unsigned int`, default: not specified).\n- **min**: Specifies the minimum value for drawing the legend (`float`, default: not specified).\n- **max**: Specifies the maximum value for drawing the legend (`float`, default: not specified).\n- **legendRangeScale**: Adjusts the unit of the min/max values of the legend (`float`, default: not specified)."
}