MeshLoader
The `MeshLoader` loads geometric meshes into SOFA simulations, managing elements such as points, edges, triangles, quads, tetrahedra, hexahedra, prisms, and pyramids. It supports transformations and mesh processing options like flipping normals or subdividing polygons.
- module
- Sofa.framework.Core
- namespace
- sofa::core::loader
- include
- sofa/core/loader/MeshLoader.h
- inherits
-
- BaseLoader
- description
The MeshLoader component in the SOFA framework is primarily responsible for loading and managing geometric meshes. It does not directly contribute to governing equations such as mass matrix $$ \varepsilon = \frac{1}{2}(\nabla u + (\nabla u)^T) $$, stiffness matrix $ M $, internal force $ K $, or residual $ f_{int} $. Instead, it plays a role in providing the spatial discretization necessary for these matrices and forces to be computed by other components within the SOFA framework.
Governing Equations and Operators Contribution
-
Mass Matrix $ M $: The
MeshLoaderprovides the mesh with nodal positions, which are required for computing the mass matrix through integration of element-wise contributions. However, the actual assembly and computation of $ M $ are performed by other components. -
Stiffness Matrix $ K $: Similarly, the stiffness matrix is computed from the spatial discretization provided by
MeshLoader, but the actual computation is done in other components such as element solvers. -
Internal Force $ f_{int} $ and Residual $ R $: The internal forces and residuals are also dependent on the mesh, but their computation involves constitutive models and nonlinear solution methods which are handled by different components within SOFA.
Constitutive or Kinematic Laws Involved
-
Strain Measures: While
MeshLoaderdoes not directly compute strain measures, it provides the nodal positions $ \mathbf{u} $ needed for computing strains. The strains are typically computed as:
$$ \varepsilon = \frac{1}{2}(\nabla u + (\nabla u)^T) $$ -
Stress Tensors:
MeshLoaderdoes not compute stress tensors directly, but it provides the basis for computing these through element-wise constitutive laws.
Role in Global FEM Pipeline
- Assembly Phase:
- Provides nodal positions and connectivity information for elements such as edges, triangles, quads, tetrahedra, hexahedra, prisms, and pyramids.
-
Ensures that the mesh data is consistent and can be used by other components to assemble global operators like $ M $ and $ K $.
-
Time Integration:
-
MeshLoader does not directly contribute to time integration schemes but provides the initial configuration needed for temporal discretization.
-
Nonlinear Solution:
-
Does not solve nonlinear systems directly, but ensures that the mesh data is ready for use in nonlinear solvers like Newton-Raphson iterations.
-
Linear Resolution:
- Provides necessary inputs for linear solvers to compute displacements and internal forces.
Numerical Methods or Discretization Choices
- Mesh Representation: Supports various types of elements including edges, triangles, quads, tetrahedra, hexahedra, prisms, and pyramids. It also handles high-order elements with additional control points for more accurate representation.
- Transformation Operations: Allows for transformations such as translation, rotation, scaling, and general homogeneous matrix transformations to be applied to the mesh data.
Broad Variational / Lagrangian Mechanics Framework Fit
- The
MeshLoaderfits into the broader variational mechanics framework by providing a consistent discretization of the continuum model. This discretization is essential for computing the weak form of the governing equations, enabling numerical solutions through FEM.
In summary, while the MeshLoader does not directly contribute to solving the nonlinear system or performing time integration, it plays a critical role in setting up the spatial discretization required by other components within the SOFA framework. Its functionality is fundamental for ensuring that the mesh data is correctly loaded and managed throughout the simulation process.
Data Fields
| Name | Type | Default | Help |
|---|---|---|---|
d_flipNormals |
bool | |
Flip Normals |
d_triangulate |
bool | |
Divide all polygons into triangles |
d_createSubelements |
bool | |
Divide all n-D elements into their (n-1)-D boundary elements (e.g. tetrahedra to triangles) |
d_onlyAttachedPoints |
bool | |
Only keep points attached to elements of the mesh |
d_translation |
Vec3 | |
Translation of the DOFs |
d_rotation |
Vec3 | |
Rotation of the DOFs |
d_scale |
Vec3 | |
Scale of the DOFs in 3 dimensions |
d_transformation |
type::Matrix4 | |
4x4 Homogeneous matrix to transform the DOFs (when present replace any) |
Methods
void
clearBuffers
()
virtual
bool
canLoad
()
virtual
void
parse
(sofa::core::objectmodel::BaseObjectDescription * arg)
virtual
void
init
()
virtual
void
reinit
()
virtual
bool
load
()
virtual
void
applyTransformation
(const sofa::type::Matrix4 & T)
virtual
void
setTranslation
(SReal dx, SReal dy, SReal dz)
void
setRotation
(SReal rx, SReal ry, SReal rz)
void
setScale
(SReal sx, SReal sy, SReal sz)
void
setTransformation
(const sofa::type::Matrix4 & t)
Vec3
getTranslation
()
virtual
Vec3
getRotation
()
virtual
Vec3
getScale
()
virtual
sofa::type::Matrix4
getTransformation
()
virtual
void
updateMesh
()
virtual
void
updateElements
()
virtual
void
updatePoints
()
virtual
void
updateNormals
()
virtual
void
addPosition
(int & pPositions, const sofa::type::Vec3 & p)
void
addPosition
(int & pPositions, SReal x, SReal y, SReal z)
void
addPolyline
(int & pPolylines, Polyline p)
void
addEdge
(int & pEdges, const Edge & p)
void
addEdge
(int & pEdges, int p0, int p1)
void
addTriangle
(int & pTriangles, const Triangle & p)
void
addTriangle
(int & pTriangles, int p0, int p1, int p2)
void
addQuad
(int & pQuads, const Quad & p)
void
addQuad
(int & pQuads, int p0, int p1, int p2, int p3)
void
addPolygon
(int & pPolygons, const int & p)
void
addTetrahedron
(int & pTetrahedra, const Tetrahedron & p)
void
addTetrahedron
(int & pTetrahedra, int p0, int p1, int p2, int p3)
void
addHexahedron
(int & pHexahedra, const Hexahedron & p)
void
addHexahedron
(int & pHexahedra, int p0, int p1, int p2, int p3, int p4, int p5, int p6, int p7)
void
addPrism
(int & pPrism, const Prism & p)
void
addPrism
(int & pPrism, int p0, int p1, int p2, int p3, int p4, int p5)
void
addPyramid
(int & pPyramids, const Pyramid & p)
void
addPyramid
(int & pPyramids, int p0, int p1, int p2, int p3, int p4)
void
copyMeshToData
(helper::io::Mesh & _mesh)
{
"name": "MeshLoader",
"namespace": "sofa::core::loader",
"module": "Sofa.framework.Core",
"include": "sofa/core/loader/MeshLoader.h",
"doc": "",
"inherits": [
"BaseLoader"
],
"templates": [],
"data_fields": [
{
"name": "d_flipNormals",
"type": "bool",
"xmlname": "flipNormals",
"help": "Flip Normals"
},
{
"name": "d_triangulate",
"type": "bool",
"xmlname": "triangulate",
"help": "Divide all polygons into triangles"
},
{
"name": "d_createSubelements",
"type": "bool",
"xmlname": "createSubelements",
"help": "Divide all n-D elements into their (n-1)-D boundary elements (e.g. tetrahedra to triangles)"
},
{
"name": "d_onlyAttachedPoints",
"type": "bool",
"xmlname": "onlyAttachedPoints",
"help": "Only keep points attached to elements of the mesh"
},
{
"name": "d_translation",
"type": "Vec3",
"xmlname": "translation",
"help": "Translation of the DOFs"
},
{
"name": "d_rotation",
"type": "Vec3",
"xmlname": "rotation",
"help": "Rotation of the DOFs"
},
{
"name": "d_scale",
"type": "Vec3",
"xmlname": "scale3d",
"help": "Scale of the DOFs in 3 dimensions"
},
{
"name": "d_transformation",
"type": "type::Matrix4",
"xmlname": "transformation",
"help": "4x4 Homogeneous matrix to transform the DOFs (when present replace any)"
}
],
"links": [],
"methods": [
{
"name": "clearBuffers",
"return_type": "void",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "canLoad",
"return_type": "bool",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "parse",
"return_type": "void",
"params": [
{
"name": "arg",
"type": "sofa::core::objectmodel::BaseObjectDescription *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"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": "load",
"return_type": "bool",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "applyTransformation",
"return_type": "void",
"params": [
{
"name": "T",
"type": "const sofa::type::Matrix4 &"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setTranslation",
"return_type": "void",
"params": [
{
"name": "dx",
"type": "SReal"
},
{
"name": "dy",
"type": "SReal"
},
{
"name": "dz",
"type": "SReal"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setRotation",
"return_type": "void",
"params": [
{
"name": "rx",
"type": "SReal"
},
{
"name": "ry",
"type": "SReal"
},
{
"name": "rz",
"type": "SReal"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setScale",
"return_type": "void",
"params": [
{
"name": "sx",
"type": "SReal"
},
{
"name": "sy",
"type": "SReal"
},
{
"name": "sz",
"type": "SReal"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setTransformation",
"return_type": "void",
"params": [
{
"name": "t",
"type": "const sofa::type::Matrix4 &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getTranslation",
"return_type": "Vec3",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getRotation",
"return_type": "Vec3",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getScale",
"return_type": "Vec3",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getTransformation",
"return_type": "sofa::type::Matrix4",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "updateMesh",
"return_type": "void",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "updateElements",
"return_type": "void",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "updatePoints",
"return_type": "void",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "updateNormals",
"return_type": "void",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "addPosition",
"return_type": "void",
"params": [
{
"name": "pPositions",
"type": "int &"
},
{
"name": "p",
"type": "const sofa::type::Vec3 &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "addPosition",
"return_type": "void",
"params": [
{
"name": "pPositions",
"type": "int &"
},
{
"name": "x",
"type": "SReal"
},
{
"name": "y",
"type": "SReal"
},
{
"name": "z",
"type": "SReal"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "addPolyline",
"return_type": "void",
"params": [
{
"name": "pPolylines",
"type": "int &"
},
{
"name": "p",
"type": "Polyline"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "addEdge",
"return_type": "void",
"params": [
{
"name": "pEdges",
"type": "int &"
},
{
"name": "p",
"type": "const Edge &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "addEdge",
"return_type": "void",
"params": [
{
"name": "pEdges",
"type": "int &"
},
{
"name": "p0",
"type": "int"
},
{
"name": "p1",
"type": "int"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "addTriangle",
"return_type": "void",
"params": [
{
"name": "pTriangles",
"type": "int &"
},
{
"name": "p",
"type": "const Triangle &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "addTriangle",
"return_type": "void",
"params": [
{
"name": "pTriangles",
"type": "int &"
},
{
"name": "p0",
"type": "int"
},
{
"name": "p1",
"type": "int"
},
{
"name": "p2",
"type": "int"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "addQuad",
"return_type": "void",
"params": [
{
"name": "pQuads",
"type": "int &"
},
{
"name": "p",
"type": "const Quad &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "addQuad",
"return_type": "void",
"params": [
{
"name": "pQuads",
"type": "int &"
},
{
"name": "p0",
"type": "int"
},
{
"name": "p1",
"type": "int"
},
{
"name": "p2",
"type": "int"
},
{
"name": "p3",
"type": "int"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "addPolygon",
"return_type": "void",
"params": [
{
"name": "pPolygons",
"type": "int &"
},
{
"name": "p",
"type": "const int &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "addTetrahedron",
"return_type": "void",
"params": [
{
"name": "pTetrahedra",
"type": "int &"
},
{
"name": "p",
"type": "const Tetrahedron &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "addTetrahedron",
"return_type": "void",
"params": [
{
"name": "pTetrahedra",
"type": "int &"
},
{
"name": "p0",
"type": "int"
},
{
"name": "p1",
"type": "int"
},
{
"name": "p2",
"type": "int"
},
{
"name": "p3",
"type": "int"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "addHexahedron",
"return_type": "void",
"params": [
{
"name": "pHexahedra",
"type": "int &"
},
{
"name": "p",
"type": "const Hexahedron &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "addHexahedron",
"return_type": "void",
"params": [
{
"name": "pHexahedra",
"type": "int &"
},
{
"name": "p0",
"type": "int"
},
{
"name": "p1",
"type": "int"
},
{
"name": "p2",
"type": "int"
},
{
"name": "p3",
"type": "int"
},
{
"name": "p4",
"type": "int"
},
{
"name": "p5",
"type": "int"
},
{
"name": "p6",
"type": "int"
},
{
"name": "p7",
"type": "int"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "addPrism",
"return_type": "void",
"params": [
{
"name": "pPrism",
"type": "int &"
},
{
"name": "p",
"type": "const Prism &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "addPrism",
"return_type": "void",
"params": [
{
"name": "pPrism",
"type": "int &"
},
{
"name": "p0",
"type": "int"
},
{
"name": "p1",
"type": "int"
},
{
"name": "p2",
"type": "int"
},
{
"name": "p3",
"type": "int"
},
{
"name": "p4",
"type": "int"
},
{
"name": "p5",
"type": "int"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "addPyramid",
"return_type": "void",
"params": [
{
"name": "pPyramids",
"type": "int &"
},
{
"name": "p",
"type": "const Pyramid &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "addPyramid",
"return_type": "void",
"params": [
{
"name": "pPyramids",
"type": "int &"
},
{
"name": "p0",
"type": "int"
},
{
"name": "p1",
"type": "int"
},
{
"name": "p2",
"type": "int"
},
{
"name": "p3",
"type": "int"
},
{
"name": "p4",
"type": "int"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "copyMeshToData",
"return_type": "void",
"params": [
{
"name": "_mesh",
"type": "helper::io::Mesh &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
}
],
"description": "The `MeshLoader` class in the SOFA framework inherits from `BaseLoader` and is responsible for loading geometric meshes into the simulation environment, enabling the representation and manipulation of various 3D elements such as points, edges, triangles, quads, tetrahedra, hexahedra, prisms, pyramids, and their high-order counterparts. It provides a set of methods to manage these elements, apply transformations, update mesh data, and support additional features like flipping normals or subdividing polygons into triangles.\n\n`MeshLoader` interacts with other SOFA components by providing data fields for the different types of geometric entities, such as positions, edges, triangles, quads, tetrahedra, hexahedra, prisms, pyramids, and their high-order counterparts. These data fields are designed to be accessible and modifiable across various parts of the simulation pipeline.\n\nPractical usage involves configuring parameters like `flipNormals`, `triangulate`, `createSubelements`, and `onlyAttachedPoints` to control how the mesh is processed after loading. Transformations such as translation, rotation, and scaling can also be applied to the loaded mesh through the corresponding data fields (`d_translation`, `d_rotation`, `d_scale`, `d_transformation`).",
"maths": "The `MeshLoader` component in the SOFA framework is primarily responsible for loading and managing geometric meshes. It does not directly contribute to governing equations such as mass matrix \\( M \\), stiffness matrix \\( K \\), internal force \\( f_{int} \\), or residual \\( R \\). Instead, it plays a role in providing the spatial discretization necessary for these matrices and forces to be computed by other components within the SOFA framework.\n\n### Governing Equations and Operators Contribution\n- **Mass Matrix \\( M \\)**: The `MeshLoader` provides the mesh with nodal positions, which are required for computing the mass matrix through integration of element-wise contributions. However, the actual assembly and computation of \\( M \\) are performed by other components.\n\n- **Stiffness Matrix \\( K \\)**: Similarly, the stiffness matrix is computed from the spatial discretization provided by `MeshLoader`, but the actual computation is done in other components such as element solvers.\n\n- **Internal Force \\( f_{int} \\)** and **Residual \\( R \\)**: The internal forces and residuals are also dependent on the mesh, but their computation involves constitutive models and nonlinear solution methods which are handled by different components within SOFA.\n\n### Constitutive or Kinematic Laws Involved\n- **Strain Measures**: While `MeshLoader` does not directly compute strain measures, it provides the nodal positions \\( \\mathbf{u} \\) needed for computing strains. The strains are typically computed as:\n \\[ \\varepsilon = \\frac{1}{2}(\\nabla u + (\\nabla u)^T) \\]\n- **Stress Tensors**: `MeshLoader` does not compute stress tensors directly, but it provides the basis for computing these through element-wise constitutive laws.\n\n### Role in Global FEM Pipeline\n1. **Assembly Phase**:\n - Provides nodal positions and connectivity information for elements such as edges, triangles, quads, tetrahedra, hexahedra, prisms, and pyramids.\n - Ensures that the mesh data is consistent and can be used by other components to assemble global operators like \\( M \\) and \\( K \\).\n\n2. **Time Integration**:\n - MeshLoader does not directly contribute to time integration schemes but provides the initial configuration needed for temporal discretization.\n\n3. **Nonlinear Solution**:\n - Does not solve nonlinear systems directly, but ensures that the mesh data is ready for use in nonlinear solvers like Newton-Raphson iterations.\n\n4. **Linear Resolution**:\n - Provides necessary inputs for linear solvers to compute displacements and internal forces.\n\n### Numerical Methods or Discretization Choices\n- **Mesh Representation**: Supports various types of elements including edges, triangles, quads, tetrahedra, hexahedra, prisms, and pyramids. It also handles high-order elements with additional control points for more accurate representation.\n- **Transformation Operations**: Allows for transformations such as translation, rotation, scaling, and general homogeneous matrix transformations to be applied to the mesh data.\n\n### Broad Variational / Lagrangian Mechanics Framework Fit\n- The `MeshLoader` fits into the broader variational mechanics framework by providing a consistent discretization of the continuum model. This discretization is essential for computing the weak form of the governing equations, enabling numerical solutions through FEM.\n\nIn summary, while the `MeshLoader` does not directly contribute to solving the nonlinear system or performing time integration, it plays a critical role in setting up the spatial discretization required by other components within the SOFA framework. Its functionality is fundamental for ensuring that the mesh data is correctly loaded and managed throughout the simulation process.",
"abstract": "The `MeshLoader` loads geometric meshes into SOFA simulations, managing elements such as points, edges, triangles, quads, tetrahedra, hexahedra, prisms, and pyramids. It supports transformations and mesh processing options like flipping normals or subdividing polygons.",
"sheet": "# MeshLoader\n\n## Overview\nThe `MeshLoader` is a component in the SOFA framework that loads geometric meshes into simulations. It handles various types of elements including points, edges, triangles, quads, tetrahedra, hexahedra, prisms, and pyramids. The component supports transformations such as translation, rotation, scaling, and general homogeneous matrix transformations.\n\n## Parameters and Data\nThe `MeshLoader` exposes several parameters that control how the mesh is processed after loading:\n- **flipNormals**: Flip normals of the loaded mesh (`bool`, default: false).\n- **triangulate**: Divide all polygons into triangles (`bool`, default: false).\n- **createSubelements**: Divide n-D elements into their (n-1)-D boundary elements (`bool`, default: false).\n- **onlyAttachedPoints**: Keep only points attached to mesh elements (`bool`, default: false).\n- **translation**: Translation of the DOFs (`Vec3`).\n- **rotation**: Rotation of the DOFs (`Vec3`).\n- **scale3d**: Scale of the DOFs in 3 dimensions (`Vec3`).\n- **transformation**: 4x4 Homogeneous matrix to transform the DOFs (`type::Matrix4`, overrides other transformations when present).\n\n## Dependencies and Connections\nThe `MeshLoader` typically requires a mesh file as input. It interacts with other SOFA components by providing data fields for geometric entities such as positions, edges, triangles, quads, tetrahedra, hexahedra, prisms, pyramids, and their high-order counterparts."
}