Back

MeshTetraStuffing

sofa::component::engine::generate::MeshTetraStuffing
DataEngine
Doc (from source)

Create a tetrahedral volume mesh from a surface, using the algorithm from F. Labelle and J.R. Shewchuk, \"Isosurface Stuffing: Fast Tetrahedral Meshes with Good Dihedral Angles\", SIGGRAPH 2007. Create a tetrahedral volume mesh from a surface, using the algorithm from F. Labelle and J.R. Shewchuk, "Isosurface Stuffing: Fast Tetrahedral Meshes with Good Dihedral Angles", SIGGRAPH 2007.

Abstract (AI generated)

The `MeshTetraStuffing` component generates tetrahedral volume meshes from surface meshes using the Isosurface Stuffing algorithm by Labelle and Shewchuk (SIGGRAPH 2007). It handles mesh generation parameters such as size, snapping criteria, and splitting of tetrahedra crossing surfaces.

Metadata
module
Sofa.Component.Engine.Generate
namespace
sofa::component::engine::generate
include
sofa/component/engine/generate/MeshTetraStuffing.h
inherits
  • DataEngine
description

The MeshTetraStuffing component is designed to generate tetrahedral volume meshes from surface meshes, following the algorithm described by Labelle and Shewchuk in their SIGGRAPH 2007 paper titled "Isosurface Stuffing: Fast Tetrahedral Meshes with Good Dihedral Angles". The primary role of this component is to create a volumetric mesh representation that can be used for further mechanical simulations within the SOFA framework, particularly relevant for biomechanical applications and soft tissue modeling.

Governing Equations and Operators:

The MeshTetraStuffing does not directly implement or contribute to any governing equations such as mass matrix $M$, stiffness matrix $K$, internal force vector $f_{int}$, or residual function $R$. Instead, it focuses on the spatial discretization phase of the FEM pipeline by generating a tetrahedral mesh from an input surface.

Constitutive and Kinematic Laws:

The component itself does not involve constitutive laws such as strain measures, stress tensors, hyperelastic potentials, or damping models. However, once the tetrahedral mesh is generated, it can be used in subsequent FEM simulations where these laws are applied to each element of the discretized domain.

Role in the Global FEM Pipeline:

The MeshTetraStuffing fits into the spatial discretization phase of the FEM pipeline. Its primary function is to convert a surface mesh, given as input points (d_inputPoints), triangles (d_inputTriangles), and optionally quads (d_inputQuads), into a volumetric tetrahedral mesh that can be used for simulations.

Numerical Methods or Discretization Choices:

The component uses the Isosurface Stuffing algorithm, which aims to generate tetrahedral meshes with good dihedral angles. The process involves:
- BBox Restriction: Bounding box (d_vbbox) is used to restrict the volume mesh generation within a specified region.
- Grid Generation: A grid of points is generated based on the specified size parameter, which determines the size of tetrahedra or the number of grid cells along the largest bounding box dimension. The grid points are adjusted by snapping them to the surface if necessary (d_bSnapPoints).
- Intersection and Edge Handling: The component checks intersections between edges and surfaces, calculating minimum alpha values on long and short edges when snapping points (d_alphaLong, d_alphaShort).
- Tetrahedra Creation: Tetrahedral elements are created by connecting grid points while respecting the surface geometry. If enabled (d_bSplitTetrahedra), tetrahedra that intersect with the surface can be split to ensure accurate representation of boundary conditions.

Variational / Lagrangian Mechanics Framework:

While MeshTetraStuffing does not directly contribute to variational or Lagrangian mechanics formulations, it provides a critical step in creating a volumetric mesh that is necessary for subsequent FEM simulations. The tetrahedral elements generated by this component are used as the basis for discretizing the weak form of mechanical equations and constitutive laws, enabling the simulation of deformable continua within the broader variational framework.

Constraints and Mappings:

The MeshTetraStuffing does not explicitly handle constraints or mappings in terms of Lagrange multipliers or slave/master relations. However, it ensures that tetrahedra crossing the surface can be accurately represented if splitting is enabled (d_bSplitTetrahedra). This is essential for maintaining the integrity of boundary conditions during further mechanical simulations.

Visualization and Debugging:

The component includes options to render internal datasets for debugging purposes, which can help visualize generated points, intersections, diagonals, and snapped points. This feature aids in ensuring that the mesh generation process is proceeding as expected.

Data Fields
NameTypeDefaultHelp
d_size Real Size of the generate tetrahedra. If negative, number of grid cells in the largest bbox dimension
d_inputPoints SeqPoints Input surface mesh points
d_inputTriangles SeqTriangles Input surface mesh triangles
d_inputQuads SeqQuads Input surface mesh quads
d_outputPoints SeqPoints Output volume mesh points
d_outputTetrahedra SeqTetrahedra Output volume mesh tetrahedra
d_alphaLong Real Minimum alpha values on long edges when snapping points
d_alphaShort Real Minimum alpha values on short edges when snapping points
d_bSnapPoints bool Snap points to the surface if intersections on edges are closed to given alpha values
d_bSplitTetrahedra bool Split tetrahedra crossing the surface
d_bDraw bool Activate rendering of internal datasets
Methods
void init () virtual
void draw (const core::visual::VisualParams * vparams) virtual
void doUpdate () virtual
int getEdgePoint2 (int p, int e)
int getEdgeSize2 (int e)
Point getEdgeDir (int e)
void addTetra (SeqTetrahedra & outT, SeqPoints & outP, int p1, int p2, int p3, int p4, int line)
void addFinalTetra (SeqTetrahedra & outT, SeqPoints & outP, int p1, int p2, int p3, int p4, bool flip, int line)
int getSplitPoint (int from, int to)
bool flipDiag (const SeqPoints & outP, int a, int b, int c, int d, int e)
bool needFlip (int p1, int p2, int p3, int p4, int q1, int q2, int q3, int q4)
{
  "name": "MeshTetraStuffing",
  "namespace": "sofa::component::engine::generate",
  "module": "Sofa.Component.Engine.Generate",
  "include": "sofa/component/engine/generate/MeshTetraStuffing.h",
  "doc": "Create a tetrahedral volume mesh from a surface, using the algorithm from F. Labelle and J.R. Shewchuk, \\\"Isosurface Stuffing: Fast Tetrahedral Meshes with Good Dihedral Angles\\\", SIGGRAPH 2007.\n\nCreate a tetrahedral volume mesh from a surface, using the algorithm from F. Labelle and J.R. Shewchuk, \"Isosurface Stuffing: Fast Tetrahedral Meshes with Good Dihedral Angles\", SIGGRAPH 2007.",
  "inherits": [
    "DataEngine"
  ],
  "templates": [],
  "data_fields": [
    {
      "name": "d_size",
      "type": "Real",
      "xmlname": "size",
      "help": "Size of the generate tetrahedra. If negative, number of grid cells in the largest bbox dimension"
    },
    {
      "name": "d_inputPoints",
      "type": "SeqPoints",
      "xmlname": "inputPoints",
      "help": "Input surface mesh points"
    },
    {
      "name": "d_inputTriangles",
      "type": "SeqTriangles",
      "xmlname": "inputTriangles",
      "help": "Input surface mesh triangles"
    },
    {
      "name": "d_inputQuads",
      "type": "SeqQuads",
      "xmlname": "inputQuads",
      "help": "Input surface mesh quads"
    },
    {
      "name": "d_outputPoints",
      "type": "SeqPoints",
      "xmlname": "outputPoints",
      "help": "Output volume mesh points"
    },
    {
      "name": "d_outputTetrahedra",
      "type": "SeqTetrahedra",
      "xmlname": "outputTetrahedra",
      "help": "Output volume mesh tetrahedra"
    },
    {
      "name": "d_alphaLong",
      "type": "Real",
      "xmlname": "alphaLong",
      "help": "Minimum alpha values on long edges when snapping points"
    },
    {
      "name": "d_alphaShort",
      "type": "Real",
      "xmlname": "alphaShort",
      "help": "Minimum alpha values on short edges when snapping points"
    },
    {
      "name": "d_bSnapPoints",
      "type": "bool",
      "xmlname": "snapPoints",
      "help": "Snap points to the surface if intersections on edges are closed to given alpha values"
    },
    {
      "name": "d_bSplitTetrahedra",
      "type": "bool",
      "xmlname": "splitTetrahedra",
      "help": "Split tetrahedra crossing the surface"
    },
    {
      "name": "d_bDraw",
      "type": "bool",
      "xmlname": "draw",
      "help": "Activate rendering of internal datasets"
    }
  ],
  "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": "doUpdate",
      "return_type": "void",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getEdgePoint2",
      "return_type": "int",
      "params": [
        {
          "name": "p",
          "type": "int"
        },
        {
          "name": "e",
          "type": "int"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getEdgeSize2",
      "return_type": "int",
      "params": [
        {
          "name": "e",
          "type": "int"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getEdgeDir",
      "return_type": "Point",
      "params": [
        {
          "name": "e",
          "type": "int"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "addTetra",
      "return_type": "void",
      "params": [
        {
          "name": "outT",
          "type": "SeqTetrahedra &"
        },
        {
          "name": "outP",
          "type": "SeqPoints &"
        },
        {
          "name": "p1",
          "type": "int"
        },
        {
          "name": "p2",
          "type": "int"
        },
        {
          "name": "p3",
          "type": "int"
        },
        {
          "name": "p4",
          "type": "int"
        },
        {
          "name": "line",
          "type": "int"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "addFinalTetra",
      "return_type": "void",
      "params": [
        {
          "name": "outT",
          "type": "SeqTetrahedra &"
        },
        {
          "name": "outP",
          "type": "SeqPoints &"
        },
        {
          "name": "p1",
          "type": "int"
        },
        {
          "name": "p2",
          "type": "int"
        },
        {
          "name": "p3",
          "type": "int"
        },
        {
          "name": "p4",
          "type": "int"
        },
        {
          "name": "flip",
          "type": "bool"
        },
        {
          "name": "line",
          "type": "int"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getSplitPoint",
      "return_type": "int",
      "params": [
        {
          "name": "from",
          "type": "int"
        },
        {
          "name": "to",
          "type": "int"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "flipDiag",
      "return_type": "bool",
      "params": [
        {
          "name": "outP",
          "type": "const SeqPoints &"
        },
        {
          "name": "a",
          "type": "int"
        },
        {
          "name": "b",
          "type": "int"
        },
        {
          "name": "c",
          "type": "int"
        },
        {
          "name": "d",
          "type": "int"
        },
        {
          "name": "e",
          "type": "int"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "needFlip",
      "return_type": "bool",
      "params": [
        {
          "name": "p1",
          "type": "int"
        },
        {
          "name": "p2",
          "type": "int"
        },
        {
          "name": "p3",
          "type": "int"
        },
        {
          "name": "p4",
          "type": "int"
        },
        {
          "name": "q1",
          "type": "int"
        },
        {
          "name": "q2",
          "type": "int"
        },
        {
          "name": "q3",
          "type": "int"
        },
        {
          "name": "q4",
          "type": "int"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    }
  ],
  "description": "The `MeshTetraStuffing` component is part of the SOFA framework and is used to generate tetrahedral volume meshes from surface meshes, following an algorithm described by F. Labelle and J.R. Shewchuk in \"Isosurface Stuffing: Fast Tetrahedral Meshes with Good Dihedral Angles\" (SIGGRAPH 2007). This component inherits from `DataEngine` and is part of the `sofa::component::engine::generate` namespace, residing within the Sofa.Component.Engine.Generate module.\n\n### Purpose in SOFA Ecosystem:\n- **Tetrahedral Mesh Generation:** The primary role is to create a tetrahedral mesh from an input surface, using specified parameters such as size and snapping criteria.\n- **Integration into Simulations:** It provides an essential pre-processing step for simulations requiring volumetric representations of surfaces, especially useful in biomechanical applications and soft tissue modeling where accurate tetrahedral meshes are crucial.\n\n### Interactions with Other Components:\n- **Input Data:** The component expects input points (`inputPoints`), triangles (`inputTriangles`), and quads (`inputQuads`) which can come from other SOFA components such as `MeshLoader`, `TopologyContainer`, or any component that provides mesh data.\n- **Output Data:** It produces output tetrahedral points (`outputPoints`) and tetrahedra (`outputTetrahedra`), which can be further utilized by other simulation components like FEM solvers, collision detection systems, or visualization tools within the SOFA framework.\n\n### Practical Usage Guidance:\n- **Input Parameters:** Users need to provide surface mesh data via `inputPoints`, `inputTriangles`, and optionally `inputQuads`. The size of tetrahedra can be controlled with `size` (default is -8.0, which means a negative value indicates the number of grid cells along the largest bounding box dimension).\n- **Snap Points:** Users can enable snapping points to surfaces using `snapPoints` and setting appropriate `alphaLong` and `alphaShort` values for minimum alpha thresholds on long and short edges.\n- **Split Tetrahedra:** Option to split tetrahedra crossing the surface with `splitTetrahedra`. This is useful in ensuring that boundary conditions are respected accurately.\n\n### Data Fields:\n- `d_size`: Size of generated tetrahedra; negative values determine grid cell count based on the bounding box dimensions.\n- `d_inputPoints`, `d_inputTriangles`, `d_inputQuads`: Input surface mesh data.\n- `d_outputPoints`, `d_outputTetrahedra`: Output volumetric mesh data points and tetrahedra, respectively.\n- `d_alphaLong`, `d_alphaShort`: Minimum alpha values for snapping points on long and short edges.\n- `d_bSnapPoints`, `d_bSplitTetrahedra`: Boolean flags to enable point snapping and splitting of tetrahedra crossing the surface.\n- `d_bDraw`: Activates rendering of internal datasets, useful for debugging or visualization purposes.",
  "maths": "The `MeshTetraStuffing` component is designed to generate tetrahedral volume meshes from surface meshes, following the algorithm described by Labelle and Shewchuk in their SIGGRAPH 2007 paper titled \"Isosurface Stuffing: Fast Tetrahedral Meshes with Good Dihedral Angles\". The primary role of this component is to create a volumetric mesh representation that can be used for further mechanical simulations within the SOFA framework, particularly relevant for biomechanical applications and soft tissue modeling.\n\n### Governing Equations and Operators:\n\nThe `MeshTetraStuffing` does not directly implement or contribute to any governing equations such as mass matrix $M$, stiffness matrix $K$, internal force vector $f_{int}$, or residual function $R$. Instead, it focuses on the spatial discretization phase of the FEM pipeline by generating a tetrahedral mesh from an input surface.\n\n### Constitutive and Kinematic Laws:\n\nThe component itself does not involve constitutive laws such as strain measures, stress tensors, hyperelastic potentials, or damping models. However, once the tetrahedral mesh is generated, it can be used in subsequent FEM simulations where these laws are applied to each element of the discretized domain.\n\n### Role in the Global FEM Pipeline:\n\nThe `MeshTetraStuffing` fits into the spatial discretization phase of the FEM pipeline. Its primary function is to convert a surface mesh, given as input points (`d_inputPoints`), triangles (`d_inputTriangles`), and optionally quads (`d_inputQuads`), into a volumetric tetrahedral mesh that can be used for simulations.\n\n### Numerical Methods or Discretization Choices:\n\nThe component uses the Isosurface Stuffing algorithm, which aims to generate tetrahedral meshes with good dihedral angles. The process involves:\n- **BBox Restriction:** Bounding box (`d_vbbox`) is used to restrict the volume mesh generation within a specified region.\n- **Grid Generation:** A grid of points is generated based on the specified `size` parameter, which determines the size of tetrahedra or the number of grid cells along the largest bounding box dimension. The grid points are adjusted by snapping them to the surface if necessary (`d_bSnapPoints`).\n- **Intersection and Edge Handling:** The component checks intersections between edges and surfaces, calculating minimum alpha values on long and short edges when snapping points (`d_alphaLong`, `d_alphaShort`).\n- **Tetrahedra Creation:** Tetrahedral elements are created by connecting grid points while respecting the surface geometry. If enabled (`d_bSplitTetrahedra`), tetrahedra that intersect with the surface can be split to ensure accurate representation of boundary conditions.\n\n### Variational / Lagrangian Mechanics Framework:\n\nWhile `MeshTetraStuffing` does not directly contribute to variational or Lagrangian mechanics formulations, it provides a critical step in creating a volumetric mesh that is necessary for subsequent FEM simulations. The tetrahedral elements generated by this component are used as the basis for discretizing the weak form of mechanical equations and constitutive laws, enabling the simulation of deformable continua within the broader variational framework.\n\n### Constraints and Mappings:\n\nThe `MeshTetraStuffing` does not explicitly handle constraints or mappings in terms of Lagrange multipliers or slave/master relations. However, it ensures that tetrahedra crossing the surface can be accurately represented if splitting is enabled (`d_bSplitTetrahedra`). This is essential for maintaining the integrity of boundary conditions during further mechanical simulations.\n\n### Visualization and Debugging:\n\nThe component includes options to render internal datasets for debugging purposes, which can help visualize generated points, intersections, diagonals, and snapped points. This feature aids in ensuring that the mesh generation process is proceeding as expected.",
  "abstract": "The `MeshTetraStuffing` component generates tetrahedral volume meshes from surface meshes using the Isosurface Stuffing algorithm by Labelle and Shewchuk (SIGGRAPH 2007). It handles mesh generation parameters such as size, snapping criteria, and splitting of tetrahedra crossing surfaces.",
  "sheet": "\n# MeshTetraStuffing\n\n## Overview\nThe `MeshTetraStuffing` component generates a tetrahedral volume mesh from an input surface mesh using the Isosurface Stuffing algorithm by Labelle and Shewchuk (SIGGRAPH 2007). It inherits from `DataEngine` and is part of the `sofa::component::engine::generate` namespace. This component provides essential pre-processing for simulations requiring volumetric representations, particularly useful in biomechanical applications.\n\n## Parameters and Data\nThe significant data fields exposed by this component are:\n- **d_size**: Size of generated tetrahedra; negative values indicate the number of grid cells along the largest bounding box dimension (default: -8.0).\n- **d_inputPoints**: Input surface mesh points.\n- **d_inputTriangles**: Input surface mesh triangles.\n- **d_inputQuads**: Input surface mesh quads (optional).\n- **d_outputPoints**: Output volume mesh points.\n- **d_outputTetrahedra**: Output volume mesh tetrahedra.\n- **d_alphaLong**: Minimum alpha values on long edges when snapping points.\n- **d_alphaShort**: Minimum alpha values on short edges when snapping points.\n- **d_bSnapPoints**: Boolean flag to enable point snapping to the surface (default: false).\n- **d_bSplitTetrahedra**: Boolean flag to split tetrahedra crossing the surface (default: true).\n- **d_bDraw**: Activates rendering of internal datasets for debugging purposes (default: false).\n\n## Dependencies and Connections\nThe `MeshTetraStuffing` component requires input data from other SOFA components such as `MeshLoader`, `TopologyContainer`, or any component that provides mesh data. It produces output tetrahedral points (`outputPoints`) and tetrahedra (`outputTetrahedra`), which can be further utilized by FEM solvers, collision detection systems, or visualization tools within the SOFA framework.\n\n## Practical Notes\n- **Input Parameters**: Users need to provide surface mesh data via `inputPoints`, `inputTriangles`, and optionally `inputQuads`. The size of tetrahedra can be controlled with `size` (default is -8.0, indicating a negative value for grid cell count).\n- **Snap Points**: Users can enable snapping points to surfaces using `snapPoints` and setting appropriate `alphaLong` and `alphaShort` values for minimum alpha thresholds on long and short edges.\n- **Split Tetrahedra**: Option to split tetrahedra crossing the surface with `splitTetrahedra`. This is useful in ensuring that boundary conditions are respected accurately."
}