OglViewport
Set an additional viewport into the main one.
`OglViewport` creates an additional viewport within the main window in SOFA's rendering pipeline, managing its position, size, camera settings, and visibility.
- module
- Sofa.GL.Component.Rendering2D
- namespace
- sofa::gl::component::rendering2d
- include
- sofa/gl/component/rendering2d/OglViewport.h
- inherits
-
- VisualManager
- description
The MergeROIs component in the SOFA framework is designed to merge multiple Regions Of Interest (ROIs), represented as vectors of indices, into a single structured output vector. This process does not involve any physical or mathematical operations that are typically associated with FEM simulations such as mass matrices, stiffness matrices, internal forces, or residuals. Instead, it focuses on data management and organization within the simulation environment.
Mathematical and Physical Description:
Governing Equations and Operators
- Mass Matrix ((M")), Stiffness Matrix ((K"), Internal Force ((f_{int}"), Residual ((R"): None. The MergeROIs component does not contribute to these FEM operators.
Constitutive or Kinematic Laws Involved
- Strain measures, stress tensors, hyperelastic potentials, damping models, constraint Jacobians: None. This component is purely data-related and does not involve any constitutive laws or kinematic formulations.
Role in the Global FEM Pipeline
- Assembly: No contribution to assembling mass matrices, stiffness matrices, internal forces, etc.
- Time Integration: Not involved in time integration schemes such as implicit Euler or Newmark-type methods.
- Nonlinear Resolution: Does not participate in nonlinear solve steps like Newton-Raphson iterations.
- Linear Resolution: No involvement in linear solvers or matrix-free operations.
- Update: Does not contribute to state update, velocity reconstruction, or timestep advancement.
Numerical Methods and Discretization Choices
- The component does not encode any numerical methods or discretization choices related to FEM. It is purely a data manipulation utility for merging ROIs represented as index lists.
Integration into the Variational / Lagrangian Mechanics Framework
- Variational Formulation: None. This component operates on input data and outputs merged ROI lists without affecting any variational or Lagrangian formulations.
- Lagrangian Mechanics: No contribution to Lagrangian mechanics principles, as it is purely a data management tool.
Summary
The MergeROIs component in SOFA is used for merging multiple ROIs (represented as vectors of indices) into a single structured output vector. It does not contribute to the mathematical or physical aspects of FEM simulations but plays a role in organizing and preparing ROI data for further processing within the simulation environment.
Data Fields
| Name | Type | Default | Help |
|---|---|---|---|
p_screenPosition |
type::Vec<2, int> | |
Viewport position |
p_screenSize |
type::Vec<2, unsigned int> | |
Viewport size |
p_cameraPosition |
type::Vec3 | |
Camera's position in eye's space |
p_cameraOrientation |
type::Quat<SReal> | |
Camera's orientation |
p_cameraRigid |
RigidCoord | |
Camera's rigid coord |
p_zNear |
double | |
Camera's ZNear |
p_zFar |
double | |
Camera's ZFar |
p_fovy |
double | |
Field of View (Y axis) |
p_enabled |
bool | |
Enable visibility of the viewport |
p_advancedRendering |
bool | |
If true, viewport will be hidden if advancedRendering visual flag is not enabled |
p_useFBO |
bool | |
Use a FBO to render the viewport |
p_swapMainView |
bool | |
Swap this viewport with the main view |
p_drawCamera |
bool | |
Draw a frame representing the camera (see it in main viewport) |
Methods
void
init
()
virtual
void
draw
(const core::visual::VisualParams * vparams)
virtual
void
doInitVisual
(const core::visual::VisualParams * )
virtual
void
preDrawScene
(core::visual::VisualParams * vp)
virtual
bool
drawScene
(core::visual::VisualParams * vp)
virtual
void
postDrawScene
(core::visual::VisualParams * vp)
virtual
bool
isVisible
(const core::visual::VisualParams * vparams)
void
renderToViewport
(core::visual::VisualParams * vp)
void
renderFBOToScreen
(core::visual::VisualParams * vp)
{
"name": "OglViewport",
"namespace": "sofa::gl::component::rendering2d",
"module": "Sofa.GL.Component.Rendering2D",
"include": "sofa/gl/component/rendering2d/OglViewport.h",
"doc": "Set an additional viewport into the main one.",
"inherits": [
"VisualManager"
],
"templates": [],
"data_fields": [
{
"name": "p_screenPosition",
"type": "type::Vec<2, int>",
"xmlname": "screenPosition",
"help": "Viewport position"
},
{
"name": "p_screenSize",
"type": "type::Vec<2, unsigned int>",
"xmlname": "screenSize",
"help": "Viewport size"
},
{
"name": "p_cameraPosition",
"type": "type::Vec3",
"xmlname": "cameraPosition",
"help": "Camera's position in eye's space"
},
{
"name": "p_cameraOrientation",
"type": "type::Quat<SReal>",
"xmlname": "cameraOrientation",
"help": "Camera's orientation"
},
{
"name": "p_cameraRigid",
"type": "RigidCoord",
"xmlname": "cameraRigid",
"help": "Camera's rigid coord"
},
{
"name": "p_zNear",
"type": "double",
"xmlname": "zNear",
"help": "Camera's ZNear"
},
{
"name": "p_zFar",
"type": "double",
"xmlname": "zFar",
"help": "Camera's ZFar"
},
{
"name": "p_fovy",
"type": "double",
"xmlname": "fovy",
"help": "Field of View (Y axis)"
},
{
"name": "p_enabled",
"type": "bool",
"xmlname": "enabled",
"help": "Enable visibility of the viewport"
},
{
"name": "p_advancedRendering",
"type": "bool",
"xmlname": "advancedRendering",
"help": "If true, viewport will be hidden if advancedRendering visual flag is not enabled"
},
{
"name": "p_useFBO",
"type": "bool",
"xmlname": "useFBO",
"help": "Use a FBO to render the viewport"
},
{
"name": "p_swapMainView",
"type": "bool",
"xmlname": "swapMainView",
"help": "Swap this viewport with the main view"
},
{
"name": "p_drawCamera",
"type": "bool",
"xmlname": "drawCamera",
"help": "Draw a frame representing the camera (see it in main viewport)"
}
],
"links": [],
"methods": [
{
"name": "init",
"return_type": "void",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "draw",
"return_type": "void",
"params": [
{
"name": "vparams",
"type": "const core::visual::VisualParams *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "doInitVisual",
"return_type": "void",
"params": [
{
"name": "",
"type": "const core::visual::VisualParams *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "preDrawScene",
"return_type": "void",
"params": [
{
"name": "vp",
"type": "core::visual::VisualParams *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "drawScene",
"return_type": "bool",
"params": [
{
"name": "vp",
"type": "core::visual::VisualParams *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "postDrawScene",
"return_type": "void",
"params": [
{
"name": "vp",
"type": "core::visual::VisualParams *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "isVisible",
"return_type": "bool",
"params": [
{
"name": "vparams",
"type": "const core::visual::VisualParams *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "renderToViewport",
"return_type": "void",
"params": [
{
"name": "vp",
"type": "core::visual::VisualParams *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "renderFBOToScreen",
"return_type": "void",
"params": [
{
"name": "vp",
"type": "core::visual::VisualParams *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
}
],
"description": "The `OglViewport` component in the SOFA framework is used to create an additional viewport within the main one, allowing for more flexible and complex rendering scenarios. It inherits from `VisualManager`, which suggests that it manages visual aspects of a scene. The component provides several data fields to customize its behavior:\n\n- **screenPosition**: Defines the position of the viewport.\n- **screenSize**: Specifies the size of the viewport.\n- **cameraPosition** and **cameraOrientation**: Define the camera's position and orientation within the viewport.\n- **zNear** and **zFar**: Set the near and far clipping planes for the camera.\n- **fovy**: Field of view along the Y-axis, crucial for perspective calculations.\n- **enabled**: Boolean to enable or disable the visibility of the viewport.\n- **advancedRendering**: If true, hides the viewport if advanced rendering is not enabled.\n- **useFBO**: Use Frame Buffer Object (FBO) for off-screen rendering.\n- **swapMainView**: Swap this viewport with the main view.\n- **drawCamera**: Draw a frame representing the camera position in the main viewport.\n\nThis component interacts primarily through methods like `init`, `draw`, and various lifecycle events such as `preDrawScene`, `postDrawScene`, and `doInitVisual`. These methods are inherited from the `VisualManager` class, allowing it to integrate seamlessly into SOFA's rendering pipeline.",
"maths": "The `OglViewport` component in the SOFA framework does not directly contribute to any mathematical or physical equations related to finite element methods (FEM). Instead, it serves a purely graphical role by managing an additional viewport within the main one. The primary function of this component is to enhance visualization capabilities and allow for more complex rendering scenarios without affecting the underlying mechanics simulation. Here are some key points regarding its functionality:\n\n- **Viewport Positioning**: \nThe `screenPosition` field specifies the position \\((p_x, p_y)\\) of the viewport within the main window.\n- **Viewport Size**: The `screenSize` field defines the dimensions \\((w, h)\\) of the viewport.\n- **Camera Parameters**: The `cameraPosition`, `cameraOrientation`, and associated parameters (such as `zNear`, `zFar`, `fovy`) are used to define the perspective projection matrix for rendering within the specified viewport. These parameters determine how objects are transformed from 3D space into 2D screen coordinates.\n\n### Mathematical Context:\n- **Projection Matrix**: The camera parameters can be used to construct a perspective projection matrix \\(P\\). Given `fovy` (field of view along Y-axis), `aspectRatio` (width/height ratio), and `zNear`, `zFar`, the perspective matrix is defined as:\n\n\begin{equation}\n P = \n \\begin{pmatrix}\n \\frac{n}{w} & 0 & 0 & 0 \\\\\n 0 & \\frac{n}{h} & 0 & 0 \\\\\n 0 & 0 & -\\frac{(f+n)}{(f-n)} & -\\frac{2fn}{(f-n)} \\\\\n 0 & 0 & -1 & 0\n \\end{pmatrix}\n\tag{1}\n\text{where } n = zNear, f = zFar,\n w = aspectRatio * h.\n\tag{2}\n\tag{3}\n\tag{4}\n\tag{5}\n\tag{6}\n\n- **View Matrix**: The camera position and orientation can be used to construct the view matrix \\(V\\), which transforms points from world coordinates to eye (camera) coordinates. Given `cameraPosition` \\((x_c, y_c, z_c)\\) and `cameraOrientation` as a quaternion \\(q = [w, x, y, z]\\), the transformation involves translation and rotation operations.\n\n### Role in FEM Pipeline:\nThe `OglViewport` does not play a role in any part of the FEM simulation pipeline. It is entirely concerned with rendering aspects of the scene visualization. The methods such as `init`, `draw`, and others like `preDrawScene`, `postDrawScene`, etc., are related to integrating this component into SOFA's rendering process.\n\n### Numerical Methods:\nThe numerical aspect here pertains to graphics, where operations include matrix transformations for perspective projection and camera view. These operations ensure that the visual representation of the scene is correctly projected onto the specified viewport within the main window.\n\n### Integration with Lagrangian Mechanics Framework:\nThere is no direct integration into the Lagrangian mechanics framework since `OglViewport` is a visualization tool. Its primary purpose is to enhance how simulations are visually presented, without affecting any mechanical or numerical aspects of the simulation itself.",
"abstract": "`OglViewport` creates an additional viewport within the main window in SOFA's rendering pipeline, managing its position, size, camera settings, and visibility.",
"sheet": "# OglViewport\n\n## Overview\nThe `OglViewport` component manages an additional viewport within the main one, allowing for flexible visualization scenarios. It inherits from `VisualManager`, integrating seamlessly into SOFA's rendering process.\n\n## Parameters and Data\n- **screenPosition**: Defines the position \\\\( (p_x, p_y) \\\\) of the viewport within the main window.\n- **screenSize**: Specifies the dimensions \\\\( (w, h) \\\\) of the viewport.\n- **cameraPosition**: Camera's position in eye space.\n- **cameraOrientation**: Camera's orientation as a quaternion.\n- **zNear** and **zFar**: Near and far clipping planes for the camera.\n- **fovy**: Field of view along the Y-axis, used to construct the perspective projection matrix.\n- **enabled**: Boolean to enable or disable viewport visibility.\n- **advancedRendering**: If true, hides the viewport if advanced rendering is not enabled.\n- **useFBO**: Use Frame Buffer Object (FBO) for off-screen rendering.\n- **swapMainView**: Swap this viewport with the main view.\n- **drawCamera**: Draw a frame representing the camera position in the main viewport.\n\n## Practical Notes\nThe `OglViewport` component is primarily used to enhance visualization capabilities. Ensure that the parameters are set correctly for proper rendering, especially when using advanced features like FBOs or swapping with the main view."
}