MeshExporter
Export topology and positions into file.
The `MeshExporter` exports mesh topology and positions into various file formats including VTK (XML and ASCII), Gmsh, Netgen, TetGen, and OBJ.
- module
- Sofa.Component.IO.Mesh
- namespace
- sofa::component::_meshexporter_
- include
- sofa/component/io/mesh/MeshExporter.h
- inherits
-
- BaseSimulationExporter
- description
The MeshExporter component in the SOFA framework is primarily an I/O utility designed to export mesh topology and positions into various file formats, including VTK (XML and ASCII), Gmsh, Netgen, TetGen, and OBJ. The component does not directly contribute to governing equations or operators such as mass matrix wzxhzdk:0, stiffness matrix wzxhzdk:1, internal force wzxhzdk:2, or the nonlinear residual wzxhzdk:3. Instead, it serves as a tool for exporting mesh data generated from other components in the simulation pipeline, such as those responsible for spatial discretization and numerical integration. The MeshExporter is not involved in the variational mechanics framework directly but rather supports post-processing and visualization by writing out mesh data that can be used externally or within SOFA itself for further analysis or rendering.
The key mathematical content of this component involves handling mesh connectivity and geometry:
- Vertices (Points): The positions of vertices are stored in a vector wzxhzdk:4, where each entry represents the coordinates wzxhzdk:5 of vertex wzxhzdk:6.
- Connectivity: Mesh elements such as edges, triangles, quads, tetrahedra, and hexahedra are defined by their connectivity lists. For example, a triangle with vertices wzxhzdk:7, wzxhzdk:8, wzxhzdk:9 is represented by the triplet wzxhzdk:10.
The component supports exporting the following types of elements:
- Edges: Connectivity list of pairs of vertices forming edges.
- Triangles: Connectivity list of triplets of vertices forming triangular faces.
- Quads: Connectivity list of quadruplets of vertices forming quadrilateral faces.
- Tetrahedra: Connectivity list of quartets of vertices forming tetrahedral elements.
- Hexahedra: Connectivity list of sextuplets (six vertices) forming hexahedral elements.
For each supported file format, the component writes out these connectivity lists and vertex positions according to the respective file specifications. The exported files can then be used in various applications for visualization, further analysis, or as input to other simulation software.
Data Fields
| Name | Type | Default | Help |
|---|---|---|---|
d_fileFormat |
sofa::helper::OptionsGroup | |
File format to use |
d_writeEdges |
bool | |
write edge topology |
d_writeTriangles |
bool | |
write triangle topology |
d_writeQuads |
bool | |
write quad topology |
d_writeTetras |
bool | |
write tetra topology |
d_writeHexas |
bool | |
write hexa topology |
Methods
void
doInit
()
virtual
void
doReInit
()
virtual
bool
write
()
virtual
bool
writeMesh
()
bool
writeMeshVTKXML
()
bool
writeMeshVTK
()
bool
writeMeshGmsh
()
bool
writeMeshNetgen
()
bool
writeMeshTetgen
()
bool
writeMeshObj
()
int
getMeshFilename
(const char * ext)
{
"name": "MeshExporter",
"namespace": "sofa::component::_meshexporter_",
"module": "Sofa.Component.IO.Mesh",
"include": "sofa/component/io/mesh/MeshExporter.h",
"doc": "Export topology and positions into file.",
"inherits": [
"BaseSimulationExporter"
],
"templates": [],
"data_fields": [
{
"name": "d_fileFormat",
"type": "sofa::helper::OptionsGroup",
"xmlname": "ALL",
"help": "File format to use"
},
{
"name": "d_writeEdges",
"type": "bool",
"xmlname": "edges",
"help": "write edge topology"
},
{
"name": "d_writeTriangles",
"type": "bool",
"xmlname": "triangles",
"help": "write triangle topology"
},
{
"name": "d_writeQuads",
"type": "bool",
"xmlname": "quads",
"help": "write quad topology"
},
{
"name": "d_writeTetras",
"type": "bool",
"xmlname": "tetras",
"help": "write tetra topology"
},
{
"name": "d_writeHexas",
"type": "bool",
"xmlname": "hexas",
"help": "write hexa topology"
}
],
"links": [],
"methods": [
{
"name": "doInit",
"return_type": "void",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "doReInit",
"return_type": "void",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "write",
"return_type": "bool",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "writeMesh",
"return_type": "bool",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "writeMeshVTKXML",
"return_type": "bool",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "writeMeshVTK",
"return_type": "bool",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "writeMeshGmsh",
"return_type": "bool",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "writeMeshNetgen",
"return_type": "bool",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "writeMeshTetgen",
"return_type": "bool",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "writeMeshObj",
"return_type": "bool",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getMeshFilename",
"return_type": "int",
"params": [
{
"name": "ext",
"type": "const char *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
}
],
"description": "This component exports the topology and positions of a mesh to various file formats.",
"parameters": [
{
"name": "filename",
"description": "The base filename for the exported files (without extension). The actual filename will be this value with the appropriate extension appended based on the chosen file format.",
"type": "string"
},
{
"name": "fileFormat",
"description": "Specifies the file format to use for exporting. Supported formats include: vtkxml, vtk, netgen, teten, gmsh, and obj.",
"type": "OptionsGroup"
},
{
"name": "position",
"description": "A vector of 3D coordinates representing the positions of points in the mesh. If left empty, it will use the points from either the topology or mechanical state by default.",
"type": "VecCoord"
},
{
"name": "writeEdges",
"description": "Boolean value to determine whether to write edge topology information to the file.",
"type": "bool",
"default_value": "false"
},
{
"name": "writeTriangles",
"description": "Boolean value to determine whether to write triangle topology information to the file.",
"type": "bool",
"default_value": "false"
},
{
"name": "writeQuads",
"description": "Boolean value to determine whether to write quad (quadrilateral) topology information to the file.",
"type": "bool",
"default_value": "false"
},
{
"name": "writeTetras",
"description": "Boolean value to determine whether to write tetrahedral (tetra) topology information to the file.",
"type": "bool",
"default_value": "false"
},
{
"name": "writeHexas",
"description": "Boolean value to determine whether to write hexahedral (hexa) topology information to the file.",
"type": "bool",
"default_value": "false"
}
],
"supported_formats": [
"VTKXML (.vtu)",
"VTK ASCII (.vtk)",
"Netgen Mesh Generator Format (.vol)",
"TetGen Tetrahedral Mesh Generator Format",
"Gmsh Geometry Definition Language (.msh)",
"Wavefront Object File Format (.obj)"
],
"maths": "The `MeshExporter` component in the SOFA framework is primarily an I/O utility designed to export mesh topology and positions into various file formats, including VTK (XML and ASCII), Gmsh, Netgen, TetGen, and OBJ. The component does not directly contribute to governing equations or operators such as mass matrix $M$, stiffness matrix $K$, internal force $f_{\text{int}}$, or the nonlinear residual $R$. Instead, it serves as a tool for exporting mesh data generated from other components in the simulation pipeline, such as those responsible for spatial discretization and numerical integration. The `MeshExporter` is not involved in the variational mechanics framework directly but rather supports post-processing and visualization by writing out mesh data that can be used externally or within SOFA itself for further analysis or rendering.\n\nThe key mathematical content of this component involves handling mesh connectivity and geometry:\n- **Vertices (Points)**: The positions of vertices are stored in a vector $\\mathbf{P}$, where each entry represents the coordinates $(x_i, y_i, z_i)$ of vertex $i$.\n- **Connectivity**: Mesh elements such as edges, triangles, quads, tetrahedra, and hexahedra are defined by their connectivity lists. For example, a triangle with vertices $v_1$, $v_2$, $v_3$ is represented by the triplet $(v_1, v_2, v_3)$.\n\nThe component supports exporting the following types of elements:\n- **Edges**: Connectivity list of pairs of vertices forming edges.\n- **Triangles**: Connectivity list of triplets of vertices forming triangular faces.\n- **Quads**: Connectivity list of quadruplets of vertices forming quadrilateral faces.\n- **Tetrahedra**: Connectivity list of quartets of vertices forming tetrahedral elements.\n- **Hexahedra**: Connectivity list of sextuplets (six vertices) forming hexahedral elements.\n\nFor each supported file format, the component writes out these connectivity lists and vertex positions according to the respective file specifications. The exported files can then be used in various applications for visualization, further analysis, or as input to other simulation software.",
"abstract": "The `MeshExporter` exports mesh topology and positions into various file formats including VTK (XML and ASCII), Gmsh, Netgen, TetGen, and OBJ.",
"sheet": "# MeshExporter\n\n## Overview\n\nThe `MeshExporter` is an I/O utility in the SOFA framework that exports mesh topology and positions to different file formats. It inherits from `BaseSimulationExporter` and supports exporting vertices, edges, triangles, quads, tetrahedra, and hexahedra.\n\n## Parameters and Data\n\nThe significant data fields exposed by this component are:\n- **d_fileFormat**: File format to use (type: `sofa::helper::OptionsGroup`).\n- **d_writeEdges**: Write edge topology (type: `bool`, default: false).\n- **d_writeTriangles**: Write triangle topology (type: `bool`, default: false).\n- **d_writeQuads**: Write quad topology (type: `bool`, default: false).\n- **d_writeTetras**: Write tetra topology (type: `bool`, default: false).\n- **d_writeHexas**: Write hexa topology (type: `bool`, default: false).\n\n## Practical Notes\n\nThe `MeshExporter` is a utility component for exporting mesh data. It does not directly contribute to the simulation but supports post-processing and visualization by writing out mesh data in various formats. Ensure that the appropriate file format and connectivity types are selected based on the intended use of the exported files."
}