Back

BarycentricMapperMeshTopology

This component is part of the SOFA (Simulation Open-Framework Architecture) library and implements a barycentric mapping between two topological models. It performs geometric interpolation from points on one model to corresponding points in another model based on the topological elements such as lines, triangles, tetrahedra, and hexahedra.

abstract
The BarycentricMapperMeshTopology performs barycentric mapping between two topological models, interpolating point positions within lines, triangles, tetrahedra, and hexahedra based on barycentric coordinates.
sheet
# BarycentricMapperMeshTopology ## Overview The BarycentricMapperMeshTopology is a component in the SOFA framework that facilitates geometric interpolation between two topological models using barycentric coordinates. It inherits from `TopologyBarycentricMapper` and supports various topological elements such as lines, triangles, tetrahedra, and hexahedra. ## Mathematical Model The BarycentricMapperMeshTopology performs geometric interpolation based on barycentric coordinates within different topological elements: - **Lines:** Interpolation within a line segment involves two vertices $v_1$ and $v_2$. The interpolated position $p$ is given by: $$ p = w_1 v_1 + w_2 v_2 $$ where $w_1 + w_2 = 1$. - **Triangles:** For a triangle with vertices $v_1, v_2, v_3$, the interpolated position $p$ is given by: $$ p = w_1 v_1 + w_2 v_2 + w_3 v_3 $$ where $w_1 + w_2 + w_3 = 1$. The barycentric coordinates $(w_1, w_2, w_3)$ specify the relative influence of each vertex. - **Tetrahedra:** For a tetrahedron with vertices $v_1, v_2, v_3, v_4$, the interpolated position $p$ is given by: $$ p = w_1 v_1 + w_2 v_2 + w_3 v_3 + w_4 v_4 $$ where $w_1 + w_2 + w_3 + w_4 = 1$. The barycentric coordinates $(w_1, w_2, w_3, w_4)$ specify the relative influence of each vertex. - **Hexahedra:** For a hexahedron with vertices $v_1, v_2, \ldots, v_8$, the interpolated position $p$ is given by: $$ p = \sum_{i=1}^{8} w_i v_i $$ where $\sum_{i=1}^{8} w_i = 1$. The barycentric coordinates $(w_1, w_2, \ldots, w_8)$ specify the relative influence of each vertex. ## Dependencies and Connections The BarycentricMapperMeshTopology typically requires a `MeshTopology` component to define the topological structure. It is often used in conjunction with other components such as force fields or solvers that require geometric data transfer between different meshes.
name
BarycentricMapperMeshTopology
namespace
sofa.component.mapping.linear
description
This component is part of the SOFA (Simulation Open-Framework Architecture) library and implements a barycentric mapping between two topological models. It performs geometric interpolation from points on one model to corresponding points in another model based on the topological elements such as lines, triangles, tetrahedra, and hexahedra.
parameters
  • {'name': 'm_map1d', 'description': 'Vector containing MappingData1D structures for 1-dimensional elements (lines). Each structure stores barycentric coordinates and index information for mapping from the source to target model.'}
  • {'name': 'm_map2d', 'description': 'Vector containing MappingData2D structures for 2-dimensional elements (triangles, quads). Each structure contains barycentric coordinates and index data used in the interpolation process.'}
  • {'name': 'm_map3d', 'description': 'Vector of MappingData3D structures for 3-dimensional elements (tetrahedra, hexahedra). Holds barycentric coordinate information and indices required for mapping points from one model to another in 3D space.'}
methods
  • {'name': 'apply', 'description': 'Performs the actual mapping operation. Given a set of coordinates (in) from the source model, this method computes corresponding coordinates (out) for the target model using barycentric interpolation over lines, triangles/tetrahedra/quads/hexahedra.'}
  • {'name': 'applyJ', 'description': 'Computes the Jacobian of the mapping operation. This matrix represents how changes in the source coordinates affect the mapped target coordinates, and is essential for calculating gradients in optimization problems or physics simulations involving this mapping.'}
  • {'name': 'resize', 'description': 'Resizes the state of the target model to match the number of points resulting from applying the barycentric mappings defined by m_map1d, m_map2d, and m_map3d.'}
operators
  • {'symbol': '>>', 'description': 'Overloaded input operator for deserializing the BarycentricMapperMeshTopology object. Reads from an input stream to populate the vectors of mapping data (m_map1d, m_map2d, m_map3d) with their respective structures.'}
  • {'symbol': '<<', 'description': 'Overloaded output operator for serializing the BarycentricMapperMeshTopology object. Writes the sizes and contents of the mapping vectors to an output stream for saving or transmitting the state of the mapping.'}
example_usage
  • {'code': 'BarycentricMapperMeshTopology<Vec3Types, Vec3Types> mapper;', 'description': 'Instantiates a BarycentricMapperMeshTopology object that maps between two models with Vec3 coordinate types. The template parameters indicate the type of data being mapped from and to.'}
maths
The BarycentricMapperMeshTopology component in the SOFA (Simulation Open-Framework Architecture) framework performs geometric interpolation between two topological models based on barycentric coordinates. The primary purpose is to map points from one model onto corresponding positions in another model, taking into account the underlying topological structure and geometry of the elements involved. ### Mathematical Formulation: #### Barycentric Coordinates: The mapping utilizes barycentric coordinates to interpolate point positions within geometric primitives (lines, triangles, tetrahedra, hexahedra). Given a set of vertices $\{v_1, v_2, \ldots, v_n\}$ and corresponding barycentric weights $\{w_1, w_2, \ldots, w_n\}$ such that $\sum_{i=1}^{n} w_i = 1$, the interpolated position $p$ is given by: $$ p = \sum_{i=1}^{n} w_i v_i $$ #### Topological Elements: The component supports various topological elements: - **Lines:** Interpolation within a line segment involves two vertices. - **Triangles:** For a triangle with vertices $v_1, v_2, v_3$, the interpolated position $p$ is given by: $$ p = w_1 v_1 + w_2 v_2 + w_3 v_3 $$ where $w_1 + w_2 + w_3 = 1$. The barycentric coordinates $(w_1, w_2, w_3)$ specify the relative influence of each vertex. - **Tetrahedra:** For a tetrahedron with vertices $v_1, v_2, v_3, v_4$, the interpolated position $p$ is given by: $$ p = w_1 v_1 + w_2 v_2 + w_3 v_3 + w_4 v_4 $$ where $w_1 + w_2 + w_3 + w_4 = 1$. The barycentric coordinates $(w_1, w_2, w_3, w_4)$ specify the relative influence of each vertex. - **Hexahedra:** For a hexahedron with vertices $v_1, v_2, \ldots, v_8$, the interpolated position $p$ is given by: $$ p = \sum_{i=1}^{8} w_i v_i $$ where $\sum_{i=1}^{8} w_i = 1$. The barycentric coordinates $(w_1, w_2, \ldots, w_8)$ specify the relative influence of each vertex. #### Mapping Data Structures: The component uses mapping data structures `MappingData1D`, `MappingData2D`, and `MappingData3D` to store the barycentric coordinates and corresponding topological indices for lines, triangles/tetrahedra, and hexahedra, respectively. These are used to compute the interpolated positions during the mapping process. ### Physical Interpretation: The BarycentricMapperMeshTopology is often used in simulations where geometric data needs to be transferred between different meshes or topologies. The interpolation ensures smooth transition of properties such as positions, velocities, and deformations across the mapped points. This is particularly useful for transferring deformation fields from a detailed mesh to a simpler one (or vice versa) while preserving local geometric relationships. In summary, this component provides a flexible and efficient way to interpolate point positions within topological elements using barycentric coordinates, facilitating geometric mapping between different meshes in the SOFA simulation framework.
{
  "name": "BarycentricMapperMeshTopology",
  "main": {
    "name": "BarycentricMapperMeshTopology",
    "namespace": "sofa::component::mapping::linear",
    "module": "Sofa.Component.Mapping.Linear",
    "include": "sofa/component/mapping/linear/BarycentricMappers/BarycentricMapperMeshTopology.h",
    "doc": "Class allowing barycentric mapping computation on a MeshTopology",
    "inherits": [
      "TopologyBarycentricMapper"
    ],
    "templates": [
      "sofa::defaulttype::Vec3Types, sofa::defaulttype::Vec3Types"
    ],
    "data_fields": [],
    "links": [],
    "methods": [
      {
        "name": "clear",
        "return_type": "void",
        "params": [
          {
            "name": "reserve",
            "type": "int"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "resize",
        "return_type": "void",
        "params": [
          {
            "name": "toModel",
            "type": "core::State<Out> *"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "addPointInLine",
        "return_type": "int",
        "params": [
          {
            "name": "lineIndex",
            "type": "const int"
          },
          {
            "name": "baryCoords",
            "type": "const SReal *"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "createPointInLine",
        "return_type": "int",
        "params": [
          {
            "name": "p",
            "type": "const typename Out::Coord &"
          },
          {
            "name": "lineIndex",
            "type": "int"
          },
          {
            "name": "points",
            "type": "const typename In::VecCoord *"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "addPointInTriangle",
        "return_type": "int",
        "params": [
          {
            "name": "triangleIndex",
            "type": "const int"
          },
          {
            "name": "baryCoords",
            "type": "const SReal *"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "createPointInTriangle",
        "return_type": "int",
        "params": [
          {
            "name": "p",
            "type": "const typename Out::Coord &"
          },
          {
            "name": "triangleIndex",
            "type": "int"
          },
          {
            "name": "points",
            "type": "const typename In::VecCoord *"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "addPointInQuad",
        "return_type": "int",
        "params": [
          {
            "name": "quadIndex",
            "type": "const int"
          },
          {
            "name": "baryCoords",
            "type": "const SReal *"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "createPointInQuad",
        "return_type": "int",
        "params": [
          {
            "name": "p",
            "type": "const typename Out::Coord &"
          },
          {
            "name": "quadIndex",
            "type": "int"
          },
          {
            "name": "points",
            "type": "const typename In::VecCoord *"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "addPointInTetra",
        "return_type": "int",
        "params": [
          {
            "name": "tetraIndex",
            "type": "const int"
          },
          {
            "name": "baryCoords",
            "type": "const SReal *"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "addPointInCube",
        "return_type": "int",
        "params": [
          {
            "name": "cubeIndex",
            "type": "const int"
          },
          {
            "name": "baryCoords",
            "type": "const SReal *"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "init",
        "return_type": "void",
        "params": [
          {
            "name": "out",
            "type": "const typename Out::VecCoord &"
          },
          {
            "name": "in",
            "type": "const typename In::VecCoord &"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "draw",
        "return_type": "void",
        "params": [
          {
            "name": "",
            "type": "const core::visual::VisualParams *"
          },
          {
            "name": "out",
            "type": "const typename Out::VecCoord &"
          },
          {
            "name": "in",
            "type": "const typename In::VecCoord &"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "apply",
        "return_type": "void",
        "params": [
          {
            "name": "out",
            "type": "typename Out::VecCoord &"
          },
          {
            "name": "in",
            "type": "const typename In::VecCoord &"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "applyJ",
        "return_type": "void",
        "params": [
          {
            "name": "out",
            "type": "typename Out::VecDeriv &"
          },
          {
            "name": "in",
            "type": "const typename In::VecDeriv &"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "applyJT",
        "return_type": "void",
        "params": [
          {
            "name": "out",
            "type": "typename In::VecDeriv &"
          },
          {
            "name": "in",
            "type": "const typename Out::VecDeriv &"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "applyJT",
        "return_type": "void",
        "params": [
          {
            "name": "out",
            "type": "typename In::MatrixDeriv &"
          },
          {
            "name": "in",
            "type": "const typename Out::MatrixDeriv &"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "getJ",
        "return_type": "const BaseMatrix *",
        "params": [
          {
            "name": "outSize",
            "type": "int"
          },
          {
            "name": "inSize",
            "type": "int"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "getMap3d",
        "return_type": "const int *",
        "params": [],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      }
    ]
  },
  "desc": {
    "name": "BarycentricMapperMeshTopology",
    "namespace": "sofa.component.mapping.linear",
    "description": "This component is part of the SOFA (Simulation Open-Framework Architecture) library and implements a barycentric mapping between two topological models. It performs geometric interpolation from points on one model to corresponding points in another model based on the topological elements such as lines, triangles, tetrahedra, and hexahedra.",
    "parameters": [
      {
        "name": "m_map1d",
        "description": "Vector containing MappingData1D structures for 1-dimensional elements (lines). Each structure stores barycentric coordinates and index information for mapping from the source to target model."
      },
      {
        "name": "m_map2d",
        "description": "Vector containing MappingData2D structures for 2-dimensional elements (triangles, quads). Each structure contains barycentric coordinates and index data used in the interpolation process."
      },
      {
        "name": "m_map3d",
        "description": "Vector of MappingData3D structures for 3-dimensional elements (tetrahedra, hexahedra). Holds barycentric coordinate information and indices required for mapping points from one model to another in 3D space."
      }
    ],
    "methods": [
      {
        "name": "apply",
        "description": "Performs the actual mapping operation. Given a set of coordinates (in) from the source model, this method computes corresponding coordinates (out) for the target model using barycentric interpolation over lines, triangles/tetrahedra/quads/hexahedra."
      },
      {
        "name": "applyJ",
        "description": "Computes the Jacobian of the mapping operation. This matrix represents how changes in the source coordinates affect the mapped target coordinates, and is essential for calculating gradients in optimization problems or physics simulations involving this mapping."
      },
      {
        "name": "resize",
        "description": "Resizes the state of the target model to match the number of points resulting from applying the barycentric mappings defined by m_map1d, m_map2d, and m_map3d."
      }
    ],
    "operators": [
      {
        "symbol": ">>",
        "description": "Overloaded input operator for deserializing the BarycentricMapperMeshTopology object. Reads from an input stream to populate the vectors of mapping data (m_map1d, m_map2d, m_map3d) with their respective structures."
      },
      {
        "symbol": "<<",
        "description": "Overloaded output operator for serializing the BarycentricMapperMeshTopology object. Writes the sizes and contents of the mapping vectors to an output stream for saving or transmitting the state of the mapping."
      }
    ],
    "example_usage": [
      {
        "code": "BarycentricMapperMeshTopology<Vec3Types, Vec3Types> mapper;",
        "description": "Instantiates a BarycentricMapperMeshTopology object that maps between two models with Vec3 coordinate types. The template parameters indicate the type of data being mapped from and to."
      }
    ]
  },
  "maths": {
    "maths": "The BarycentricMapperMeshTopology component in the SOFA (Simulation Open-Framework Architecture) framework performs geometric interpolation between two topological models based on barycentric coordinates. The primary purpose is to map points from one model onto corresponding positions in another model, taking into account the underlying topological structure and geometry of the elements involved.\n\n### Mathematical Formulation:\n\n#### Barycentric Coordinates:\nThe mapping utilizes barycentric coordinates to interpolate point positions within geometric primitives (lines, triangles, tetrahedra, hexahedra). Given a set of vertices $\\{v_1, v_2, \\ldots, v_n\\}$ and corresponding barycentric weights $\\{w_1, w_2, \\ldots, w_n\\}$ such that $\\sum_{i=1}^{n} w_i = 1$, the interpolated position $p$ is given by:\n$$ p = \\sum_{i=1}^{n} w_i v_i $$\n\n#### Topological Elements:\nThe component supports various topological elements:\n- **Lines:** Interpolation within a line segment involves two vertices.\n- **Triangles:** For a triangle with vertices $v_1, v_2, v_3$, the interpolated position $p$ is given by:\n$$ p = w_1 v_1 + w_2 v_2 + w_3 v_3 $$\nwhere $w_1 + w_2 + w_3 = 1$. The barycentric coordinates $(w_1, w_2, w_3)$ specify the relative influence of each vertex.\n- **Tetrahedra:** For a tetrahedron with vertices $v_1, v_2, v_3, v_4$, the interpolated position $p$ is given by:\n$$ p = w_1 v_1 + w_2 v_2 + w_3 v_3 + w_4 v_4 $$\nwhere $w_1 + w_2 + w_3 + w_4 = 1$. The barycentric coordinates $(w_1, w_2, w_3, w_4)$ specify the relative influence of each vertex.\n- **Hexahedra:** For a hexahedron with vertices $v_1, v_2, \\ldots, v_8$, the interpolated position $p$ is given by:\n$$ p = \\sum_{i=1}^{8} w_i v_i $$\nwhere $\\sum_{i=1}^{8} w_i = 1$. The barycentric coordinates $(w_1, w_2, \\ldots, w_8)$ specify the relative influence of each vertex.\n\n#### Mapping Data Structures:\nThe component uses mapping data structures `MappingData1D`, `MappingData2D`, and `MappingData3D` to store the barycentric coordinates and corresponding topological indices for lines, triangles/tetrahedra, and hexahedra, respectively. These are used to compute the interpolated positions during the mapping process.\n\n### Physical Interpretation:\nThe BarycentricMapperMeshTopology is often used in simulations where geometric data needs to be transferred between different meshes or topologies. The interpolation ensures smooth transition of properties such as positions, velocities, and deformations across the mapped points. This is particularly useful for transferring deformation fields from a detailed mesh to a simpler one (or vice versa) while preserving local geometric relationships.\n\nIn summary, this component provides a flexible and efficient way to interpolate point positions within topological elements using barycentric coordinates, facilitating geometric mapping between different meshes in the SOFA simulation framework."
  },
  "summary": {
    "abstract": "The BarycentricMapperMeshTopology performs barycentric mapping between two topological models, interpolating point positions within lines, triangles, tetrahedra, and hexahedra based on barycentric coordinates.",
    "sheet": "# BarycentricMapperMeshTopology\n\n## Overview\nThe BarycentricMapperMeshTopology is a component in the SOFA framework that facilitates geometric interpolation between two topological models using barycentric coordinates. It inherits from `TopologyBarycentricMapper` and supports various topological elements such as lines, triangles, tetrahedra, and hexahedra.\n\n## Mathematical Model\nThe BarycentricMapperMeshTopology performs geometric interpolation based on barycentric coordinates within different topological elements:\n\n- **Lines:** Interpolation within a line segment involves two vertices $v_1$ and $v_2$. The interpolated position $p$ is given by:\n  $$ p = w_1 v_1 + w_2 v_2 $$\n  where $w_1 + w_2 = 1$.\n\n- **Triangles:** For a triangle with vertices $v_1, v_2, v_3$, the interpolated position $p$ is given by:\n  $$ p = w_1 v_1 + w_2 v_2 + w_3 v_3 $$\n  where $w_1 + w_2 + w_3 = 1$. The barycentric coordinates $(w_1, w_2, w_3)$ specify the relative influence of each vertex.\n\n- **Tetrahedra:** For a tetrahedron with vertices $v_1, v_2, v_3, v_4$, the interpolated position $p$ is given by:\n  $$ p = w_1 v_1 + w_2 v_2 + w_3 v_3 + w_4 v_4 $$\n  where $w_1 + w_2 + w_3 + w_4 = 1$. The barycentric coordinates $(w_1, w_2, w_3, w_4)$ specify the relative influence of each vertex.\n\n- **Hexahedra:** For a hexahedron with vertices $v_1, v_2, \\ldots, v_8$, the interpolated position $p$ is given by:\n  $$ p = \\sum_{i=1}^{8} w_i v_i $$\n  where $\\sum_{i=1}^{8} w_i = 1$. The barycentric coordinates $(w_1, w_2, \\ldots, w_8)$ specify the relative influence of each vertex.\n\n## Dependencies and Connections\nThe BarycentricMapperMeshTopology typically requires a `MeshTopology` component to define the topological structure. It is often used in conjunction with other components such as force fields or solvers that require geometric data transfer between different meshes."
  }
}