Back

MeshSTLLoader

sofa::component::io::mesh::MeshSTLLoader
MeshLoader
Doc (from source)

Loader for the STL file format. STL can be used to represent the surface of object using with a triangulation.

Abstract (AI generated)

The MeshSTLLoader loads STL files into SOFA's internal mesh representation, supporting both ASCII and binary formats, and offers options for efficient position merging.

Metadata
module
Sofa.Component.IO.Mesh
namespace
sofa::component::io::mesh
include
sofa/component/io/mesh/MeshSTLLoader.h
inherits
  • MeshLoader
description

The MeshSTLLoader component in the SOFA framework is an I/O component designed to load STL (Stereo Lithography) files, which are used for representing surface geometries using triangulations. It does not directly contribute to the governing equations or operators such as mass matrix $M$, stiffness matrix $K$, internal force $f_{int}$, residual $R$, or any constitutive or kinematic laws involved in FEM simulations. Instead, it serves a preparatory role by loading mesh data into the simulation environment for further processing and use.

Role in Global FEM Pipeline:

  1. Mesh Generation: The MeshSTLLoader reads STL files to generate triangular surface meshes. This is an essential step before any spatial discretization can take place, as it provides the initial geometric description of the object to be simulated.
  2. Data Preparation: By reading both ASCII and binary STL formats, this component ensures that mesh data is correctly parsed and loaded into SOFA's internal representation, ready for subsequent operations such as FEM discretization, time integration, nonlinear solve, linear solve, constraint handling, etc.

Numerical Methods or Discretization Choices:

The MeshSTLLoader does not encode any specific numerical methods related to the FEM pipeline. Instead, it focuses on efficiently reading and parsing STL files to ensure that surface geometries are accurately represented in simulations. It supports two modes for file loading:
- ASCII Mode: Reads STL files line by line and processes each facet (triangle) individually.
- Binary Mode: Skips a specified header size (headerSize), reads the number of facets, and then parses each facet efficiently using binary reading operations.

Merging Positions Using Maps:

The component includes an option to merge duplicated positions in STL files by utilizing a map (mergePositionUsingMap). This optimization is beneficial for reducing memory usage and improving performance by avoiding redundant vertex storage. However, it temporarily duplicates memory during the merging process, which can be disabled if memory efficiency is critical.

Summary:

The MeshSTLLoader is primarily an I/O component that loads STL files into SOFA's internal mesh representation, preparing them for use in further simulations involving FEM and other numerical methods. It does not directly contribute to the mathematical or physical aspects of the FEM simulation pipeline but plays a crucial role in ensuring accurate geometric data input.

Data Fields
NameTypeDefaultHelp
d_headerSize unsigned int Size of the header binary file (just before the number of facet).
d_forceBinary bool Force reading in binary mode. Even in first keyword of the file is solid.
d_mergePositionUsingMap bool Since positions are duplicated in a STL, they have to be merged. Using a map to do so will temporarily duplicate memory but should be more efficient. Disable it if memory is really an issue.
Methods
bool readSTL (int & file)
bool readBinarySTL (const char * filename)
{
  "name": "MeshSTLLoader",
  "namespace": "sofa::component::io::mesh",
  "module": "Sofa.Component.IO.Mesh",
  "include": "sofa/component/io/mesh/MeshSTLLoader.h",
  "doc": "Loader for the STL file format. STL can be used to represent the surface of object using with a triangulation.",
  "inherits": [
    "MeshLoader"
  ],
  "templates": [],
  "data_fields": [
    {
      "name": "d_headerSize",
      "type": "unsigned int",
      "xmlname": "headerSize",
      "help": "Size of the header binary file (just before the number of facet)."
    },
    {
      "name": "d_forceBinary",
      "type": "bool",
      "xmlname": "forceBinary",
      "help": "Force reading in binary mode. Even in first keyword of the file is solid."
    },
    {
      "name": "d_mergePositionUsingMap",
      "type": "bool",
      "xmlname": "mergePositionUsingMap",
      "help": "Since positions are duplicated in a STL, they have to be merged. Using a map to do so will temporarily duplicate memory but should be more efficient. Disable it if memory is really an issue."
    }
  ],
  "links": [],
  "methods": [
    {
      "name": "readSTL",
      "return_type": "bool",
      "params": [
        {
          "name": "file",
          "type": "int &"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "protected"
    },
    {
      "name": "readBinarySTL",
      "return_type": "bool",
      "params": [
        {
          "name": "filename",
          "type": "const char *"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "protected"
    }
  ],
  "description": "The `MeshSTLLoader` component in the SOFA framework is designed to load STL (Stereo Lithography) file format, which is commonly used for representing object surfaces using triangulations. It inherits from the `MeshLoader` class and provides functionality to read both ASCII and binary STL files. The component includes several configurable data fields:\n\n- **headerSize**: Specifies the size of the header in a binary STL file.\n- **forceBinary**: Forces the loader to read files in binary mode, even if the first keyword is 'solid'.\n- **mergePositionUsingMap**: Merges duplicated positions in the STL file using a map for efficiency. This can temporarily duplicate memory but improves performance; it should be disabled if memory usage is critical.\n\nThe `MeshSTLLoader` interacts with other SOFA components through its inherited methods from `MeshLoader`, particularly by loading mesh data into the simulation environment, which can then be used for visualization or further processing within SOFA simulations. The component supports efficient reading and parsing of STL files to ensure that surface geometries are accurately represented in simulations.",
  "maths": "The `MeshSTLLoader` component in the SOFA framework is an I/O component designed to load STL (Stereo Lithography) files, which are used for representing surface geometries using triangulations. It does not directly contribute to the governing equations or operators such as mass matrix \\(M\\), stiffness matrix \\(K\\), internal force \\(f_{int}\\), residual \\(R\\), or any constitutive or kinematic laws involved in FEM simulations. Instead, it serves a preparatory role by loading mesh data into the simulation environment for further processing and use.\n\n### Role in Global FEM Pipeline:\n\n1. **Mesh Generation**: The `MeshSTLLoader` reads STL files to generate triangular surface meshes. This is an essential step before any spatial discretization can take place, as it provides the initial geometric description of the object to be simulated.\n2. **Data Preparation**: By reading both ASCII and binary STL formats, this component ensures that mesh data is correctly parsed and loaded into SOFA's internal representation, ready for subsequent operations such as FEM discretization, time integration, nonlinear solve, linear solve, constraint handling, etc.\n\n### Numerical Methods or Discretization Choices:\n\nThe `MeshSTLLoader` does not encode any specific numerical methods related to the FEM pipeline. Instead, it focuses on efficiently reading and parsing STL files to ensure that surface geometries are accurately represented in simulations. It supports two modes for file loading:\n- **ASCII Mode**: Reads STL files line by line and processes each facet (triangle) individually.\n- **Binary Mode**: Skips a specified header size (`headerSize`), reads the number of facets, and then parses each facet efficiently using binary reading operations.\n\n### Merging Positions Using Maps:\n\nThe component includes an option to merge duplicated positions in STL files by utilizing a map (`mergePositionUsingMap`). This optimization is beneficial for reducing memory usage and improving performance by avoiding redundant vertex storage. However, it temporarily duplicates memory during the merging process, which can be disabled if memory efficiency is critical.\n\n### Summary:\n\nThe `MeshSTLLoader` is primarily an I/O component that loads STL files into SOFA's internal mesh representation, preparing them for use in further simulations involving FEM and other numerical methods. It does not directly contribute to the mathematical or physical aspects of the FEM simulation pipeline but plays a crucial role in ensuring accurate geometric data input.",
  "abstract": "The MeshSTLLoader loads STL files into SOFA's internal mesh representation, supporting both ASCII and binary formats, and offers options for efficient position merging.",
  "sheet": "<h1>MeshSTLLoader</h1>\n\n<h2>Overview</h2>\n<p>The <code>MeshSTLLoader</code> is an I/O component that loads STL (Stereo Lithography) files into SOFA's internal mesh representation. It supports both ASCII and binary formats, providing options for efficient position merging to ensure accurate geometric data input.</p>\n\n<h2>Parameters and Data</h2>\n<ul>\n<li><strong>headerSize</strong>: Specifies the size of the header in a binary STL file (type: unsigned int).</li>\n<li><strong>forceBinary</strong>: Forces the loader to read files in binary mode, even if the first keyword is 'solid' (type: bool).</li>\n<li><strong>mergePositionUsingMap</strong>: Merges duplicated positions using a map for efficiency. Temporarily duplicates memory but improves performance; disable if memory usage is critical (type: bool).</li>\n</ul>\n\n<h2>Dependencies and Connections</h2>\n<p>The <code>MeshSTLLoader</code> inherits from the <code>MeshLoader</code> class, which provides functionality for loading mesh data into the simulation environment. It interacts with other SOFA components through this inheritance to prepare surface geometries for further processing within simulations.</p>"
}