Back

QuadSetGeometryAlgorithms

sofa::component::topology::container::dynamic::QuadSetGeometryAlgorithms
EdgeSetGeometryAlgorithms
Doc (from source)

Geometry algorithms dedicated to a quad topology. A class that provides geometry information on an QuadSet.

Abstract (AI generated)

The `QuadSetGeometryAlgorithms` component provides essential geometry information for quads in SOFA simulations, including area, centroid, normal vector calculations, and visualization controls.

Metadata
module
Sofa.Component.Topology.Container.Dynamic
namespace
sofa::component::topology::container::dynamic
include
sofa/component/topology/container/dynamic/QuadSetGeometryAlgorithms.h
inherits
  • EdgeSetGeometryAlgorithms
templates
  • sofa::defaulttype::Vec3Types
description

The QuadSetGeometryAlgorithms component in the SOFA framework provides various geometric computations for quads within a dynamic topology container. It does not contribute to the governing equations or operators such as mass matrix $M$, stiffness matrix $K$, internal force $f_{int}$, or residual $R$. Instead, it focuses on providing essential geometry information that can be used by other components in the simulation pipeline. Here is a detailed description of its mathematical and physical content:

Geometric Computations

  1. Area Computation
  2. The area of a quad is computed as follows:

    Given vertices $p_0, p_1, p_2, p_3$,
    the area can be calculated by splitting the quad into two triangles and summing their areas.
    $$ A = 0.5 \left( | (p_1 - p_0) \times (p_2 - p_0)| + | (p_3 - p_2) \times (p_0 - p_2)| \right) $$

This formula is used in the computeQuadArea method.

  1. Centroid Computation
  2. The centroid of a quad with vertices $p_0, p_1, p_2, p_3$ is given by:

    $$ C = 0.25 (p_0 + p_1 + p_2 + p_3) $$

This formula is used in the computeQuadCenter method.

  1. Normal Vector Computation
  2. The normal vector of a quad, assuming it lies on a plane, can be computed using two non-parallel edges originating from one vertex:

    Given vertices $p_0, p_1, p_2$,
    the normal vector is calculated as:
    $$ N = (p_1 - p_0) \times (p_2 - p_0) $$

This formula is used in the computeQuadNormal method.

  1. Point-In-Quad Test
  2. To determine if a point $P$ lies within a quad defined by vertices $A, B, C, D$, it checks if the point lies on the same side of each edge as the remaining vertex:

    Let $N_1 = (B - A) \times (C - A)$,
    $N_2 = (D - C) \times (A - C)$.

    Then, check if the point lies on the correct side of each edge using dot products:

    $$ P \text{ is in quad} \iff ((P - A) \cdot N_1 > 0 \land (P - D) \cdot N_2 > 0)$$

This test is used in the isPointInQuad method.

  1. Plane-Inclusion Test
  2. To determine if a quad lies within a plane defined by a vertex $V$ and normal vector $N$, it checks if all vertices are on the same side of the plane:

    Given vertices $p_0, p_1, p_2, p_3$,
    check if each vertex is on the correct side of the plane defined by $(V - N)$ and normal vector $N$:
    $$ (p_i - V) \cdot N > 0 \quad \text{for all } i$$

This test is used in the isQuadInPlane method.

Role in Global FEM Pipeline

The QuadSetGeometryAlgorithms component primarily supports geometry operations needed for other components involved in the simulation pipeline, such as rendering and collision detection. It does not directly contribute to mass matrix assembly, stiffness matrix evaluation, time integration, or linear solve steps of the finite element method.

Numerical Methods

The numerical methods used are basic geometric computations based on vector algebra (cross product for normals, dot products for plane inclusion tests). The area computation involves splitting a quad into two triangles and summing their areas using cross products. These operations ensure consistent geometry information is available throughout the simulation.

Variational / Lagrangian Mechanics Framework Fit

The QuadSetGeometryAlgorithms component fits into the broader variational and Lagrangian mechanics framework by providing essential geometric properties (areas, normals, centroids) that can be used in various parts of the FEM pipeline. While it does not directly contribute to the variational formulation or numerical integration schemes, these geometrical quantities are fundamental for ensuring correct spatial discretization and consistent mesh representation.

Conclusion

In summary, QuadSetGeometryAlgorithms provides essential geometric operations that support various aspects of simulation and visualization in SOFA, particularly useful when dealing with quad-based topologies. It ensures accurate computation of areas, normals, centroids, and point/quad relations which are crucial for maintaining the integrity of geometric information during deformations.

Data Fields
NameTypeDefaultHelp
showQuadIndices bool
_drawQuads bool
_drawColor sofa::type::RGBAColor
Methods
void computeQuadAABB (const QuadID i, Coord & minCoord, Coord & maxCoord)
Coord computeQuadCenter (const QuadID i)
void getQuadVertexCoordinates (const QuadID i, Coord[4] )
void getRestQuadVertexCoordinates (const QuadID i, Coord[4] )
Real computeQuadArea (const QuadID i)
void computeQuadArea (BasicArrayInterface<Real> & ai)
Real computeRestQuadArea (const QuadID i)
type::Vec<3, double> computeQuadNormal (const QuadID ind_q)
bool isQuadInPlane (const QuadID ind_q, const PointID ind_p, const type::Vec<3, Real> & plane_vect)
bool isPointInQuad (const QuadID ind_q, const sofa::type::Vec<3, Real> & p)
void draw (const core::visual::VisualParams * vparams)
bool mustComputeBBox ()
{
  "name": "QuadSetGeometryAlgorithms",
  "namespace": "sofa::component::topology::container::dynamic",
  "module": "Sofa.Component.Topology.Container.Dynamic",
  "include": "sofa/component/topology/container/dynamic/QuadSetGeometryAlgorithms.h",
  "doc": "Geometry algorithms dedicated to a quad topology.\n\nA class that provides geometry information on an QuadSet.",
  "inherits": [
    "EdgeSetGeometryAlgorithms"
  ],
  "templates": [
    "sofa::defaulttype::Vec3Types"
  ],
  "data_fields": [
    {
      "name": "showQuadIndices",
      "type": "bool"
    },
    {
      "name": "_drawQuads",
      "type": "bool"
    },
    {
      "name": "_drawColor",
      "type": "sofa::type::RGBAColor"
    }
  ],
  "links": [],
  "methods": [
    {
      "name": "computeQuadAABB",
      "return_type": "void",
      "params": [
        {
          "name": "i",
          "type": "const QuadID"
        },
        {
          "name": "minCoord",
          "type": "Coord &"
        },
        {
          "name": "maxCoord",
          "type": "Coord &"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "computeQuadCenter",
      "return_type": "Coord",
      "params": [
        {
          "name": "i",
          "type": "const QuadID"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getQuadVertexCoordinates",
      "return_type": "void",
      "params": [
        {
          "name": "i",
          "type": "const QuadID"
        },
        {
          "name": "",
          "type": "Coord[4]"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getRestQuadVertexCoordinates",
      "return_type": "void",
      "params": [
        {
          "name": "i",
          "type": "const QuadID"
        },
        {
          "name": "",
          "type": "Coord[4]"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "computeQuadArea",
      "return_type": "Real",
      "params": [
        {
          "name": "i",
          "type": "const QuadID"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "computeQuadArea",
      "return_type": "void",
      "params": [
        {
          "name": "ai",
          "type": "BasicArrayInterface<Real> &"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "computeRestQuadArea",
      "return_type": "Real",
      "params": [
        {
          "name": "i",
          "type": "const QuadID"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "computeQuadNormal",
      "return_type": "type::Vec<3, double>",
      "params": [
        {
          "name": "ind_q",
          "type": "const QuadID"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "isQuadInPlane",
      "return_type": "bool",
      "params": [
        {
          "name": "ind_q",
          "type": "const QuadID"
        },
        {
          "name": "ind_p",
          "type": "const PointID"
        },
        {
          "name": "plane_vect",
          "type": "const type::Vec<3, Real> &"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "isPointInQuad",
      "return_type": "bool",
      "params": [
        {
          "name": "ind_q",
          "type": "const QuadID"
        },
        {
          "name": "p",
          "type": "const sofa::type::Vec<3, Real> &"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "draw",
      "return_type": "void",
      "params": [
        {
          "name": "vparams",
          "type": "const core::visual::VisualParams *"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "mustComputeBBox",
      "return_type": "bool",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "protected"
    }
  ],
  "description": "The `QuadSetGeometryAlgorithms` component in the SOFA framework provides geometry information on a quad topology. It inherits from `EdgeSetGeometryAlgorithms` and is designed to operate with dynamic topology containers, specifically for managing quads within those containers.\n\nThis class offers various methods to compute properties of individual quads such as their area, center, normal vector, and whether they are included in a specific plane or contain given points. Additionally, it can retrieve the vertex coordinates of both deformed and rest positions of each quad.\n\nThe component supports drawing operations for visualizing quads and their indices during simulations. It uses data fields to control visualization features such as `_drawQuads` for enabling/disabling drawing of quads and `_drawColor` for specifying the color used in drawing.\n\nIt interacts with other SOFA components via its public API, which includes methods like `computeQuadAABB`, `computeQuadCenter`, `getQuadVertexCoordinates`, `computeQuadArea`, and `isPointInQuad`. These methods can be invoked by other components to access geometry-related information about the quads.\n\nPractical usage involves setting up the component within a SOFA scene graph where quad-based topologies are used, enabling specific visualizations through data fields like `_drawQuads` and `_showQuadIndices`, and leveraging its methods for geometric computations required in simulation or visualization pipelines.",
  "maths": "The `QuadSetGeometryAlgorithms` component in the SOFA framework provides various geometric computations for quads within a dynamic topology container. It does not contribute to the governing equations or operators such as mass matrix $M$, stiffness matrix $K$, internal force $f_{int}$, or residual $R$. Instead, it focuses on providing essential geometry information that can be used by other components in the simulation pipeline. Here is a detailed description of its mathematical and physical content:\n\n### Geometric Computations\n\n1. **Area Computation**\n   - The area of a quad is computed as follows:\n     \n     Given vertices $p_0, p_1, p_2, p_3$,\n     the area can be calculated by splitting the quad into two triangles and summing their areas.\n     \\[ A = 0.5 \\left( | (p_1 - p_0) \\times (p_2 - p_0)| + | (p_3 - p_2) \\times (p_0 - p_2)| \\right) \\]\n\n   This formula is used in the `computeQuadArea` method.\n\n2. **Centroid Computation**\n   - The centroid of a quad with vertices $p_0, p_1, p_2, p_3$ is given by:\n     \n     \\[ C = 0.25 (p_0 + p_1 + p_2 + p_3) \\]\n\n   This formula is used in the `computeQuadCenter` method.\n\n3. **Normal Vector Computation**\n   - The normal vector of a quad, assuming it lies on a plane, can be computed using two non-parallel edges originating from one vertex:\n     \n     Given vertices $p_0, p_1, p_2$,\n     the normal vector is calculated as:\n     \\[ N = (p_1 - p_0) \\times (p_2 - p_0) \\]\n\n   This formula is used in the `computeQuadNormal` method.\n\n4. **Point-In-Quad Test**\n   - To determine if a point $P$ lies within a quad defined by vertices $A, B, C, D$, it checks if the point lies on the same side of each edge as the remaining vertex:\n     \n     Let $N_1 = (B - A) \\times (C - A)$,\n     $N_2 = (D - C) \\times (A - C)$.\n\n     Then, check if the point lies on the correct side of each edge using dot products:\n     \n     \\[ P \\text{ is in quad} \\iff ((P - A) \\cdot N_1 > 0 \\land (P - D) \\cdot N_2 > 0)\\]\n\n   This test is used in the `isPointInQuad` method.\n\n5. **Plane-Inclusion Test**\n   - To determine if a quad lies within a plane defined by a vertex $V$ and normal vector $N$, it checks if all vertices are on the same side of the plane:\n     \n     Given vertices $p_0, p_1, p_2, p_3$,\n     check if each vertex is on the correct side of the plane defined by $(V - N)$ and normal vector $N$:\n     \\[ (p_i - V) \\cdot N > 0 \\quad \\text{for all } i\\]\n\n   This test is used in the `isQuadInPlane` method.\n\n### Role in Global FEM Pipeline\nThe `QuadSetGeometryAlgorithms` component primarily supports geometry operations needed for other components involved in the simulation pipeline, such as rendering and collision detection. It does not directly contribute to mass matrix assembly, stiffness matrix evaluation, time integration, or linear solve steps of the finite element method.\n\n### Numerical Methods\nThe numerical methods used are basic geometric computations based on vector algebra (cross product for normals, dot products for plane inclusion tests). The area computation involves splitting a quad into two triangles and summing their areas using cross products. These operations ensure consistent geometry information is available throughout the simulation.\n\n### Variational / Lagrangian Mechanics Framework Fit\nThe `QuadSetGeometryAlgorithms` component fits into the broader variational and Lagrangian mechanics framework by providing essential geometric properties (areas, normals, centroids) that can be used in various parts of the FEM pipeline. While it does not directly contribute to the variational formulation or numerical integration schemes, these geometrical quantities are fundamental for ensuring correct spatial discretization and consistent mesh representation.\n\n### Conclusion\nIn summary, `QuadSetGeometryAlgorithms` provides essential geometric operations that support various aspects of simulation and visualization in SOFA, particularly useful when dealing with quad-based topologies. It ensures accurate computation of areas, normals, centroids, and point/quad relations which are crucial for maintaining the integrity of geometric information during deformations.",
  "abstract": "The `QuadSetGeometryAlgorithms` component provides essential geometry information for quads in SOFA simulations, including area, centroid, normal vector calculations, and visualization controls.",
  "sheet": "# QuadSetGeometryAlgorithms\n\n## Overview\n\nThe `QuadSetGeometryAlgorithms` component is designed to provide geometric information on quad topologies within the SOFA framework. It inherits from `EdgeSetGeometryAlgorithms` and supports dynamic topology containers. This component offers methods for computing properties such as area, centroid, normal vector, and point-in-quad tests. Additionally, it includes visualization controls through data fields.\n\n## Mathematical Model\n\n### Geometric Computations\n1. **Area Computation**\n   - Given vertices $p_0, p_1, p_2, p_3$, the area is calculated by splitting the quad into two triangles and summing their areas:\n     \n     \\[ A = 0.5 \\left( | (p_1 - p_0) \\times (p_2 - p_0)| + | (p_3 - p_2) \\times (p_0 - p_2)| \\right) \\]\n\n2. **Centroid Computation**\n   - The centroid of a quad with vertices $p_0, p_1, p_2, p_3$ is given by:\n     \n     \\[ C = 0.25 (p_0 + p_1 + p_2 + p_3) \\]\n\n3. **Normal Vector Computation**\n   - The normal vector of a quad can be computed using two non-parallel edges originating from one vertex:\n     \n     Given vertices $p_0, p_1, p_2$,\n     the normal vector is calculated as:\n     \\[ N = (p_1 - p_0) \\times (p_2 - p_0) \\]\n\n4. **Point-In-Quad Test**\n   - To determine if a point $P$ lies within a quad defined by vertices $A, B, C, D$, it checks if the point lies on the same side of each edge as the remaining vertex:\n     \n     Let $N_1 = (B - A) \\times (C - A)$,\n     $N_2 = (D - C) \\times (A - C)$.\n     Then, check if the point lies on the correct side of each edge using dot products:\n     \n     \\[ P \\text{ is in quad} \\iff ((P - A) \\cdot N_1 > 0 \\land (P - D) \\cdot N_2 > 0)\\]\n\n5. **Plane-Inclusion Test**\n   - To determine if a quad lies within a plane defined by a vertex $V$ and normal vector $N$, it checks if all vertices are on the same side of the plane:\n     \n     Given vertices $p_0, p_1, p_2, p_3$,\n     check if each vertex is on the correct side of the plane defined by $(V - N)$ and normal vector $N$:\n     \\[ (p_i - V) \\cdot N > 0 \\quad \\text{for all } i\\]\n\n## Parameters and Data\n\n- **showQuadIndices**: `bool` — Controls whether quad indices are displayed during visualization.\n- **_drawQuads**: `bool` — Enables or disables the drawing of quads.\n- **_drawColor**: `sofa::type::RGBAColor` — Specifies the color used for drawing quads.\n\n## Practical Notes\n\nThe component is primarily used to provide geometric information and visualization controls for quad-based topologies in SOFA simulations. It does not directly contribute to core FEM operations but supports rendering, collision detection, and other geometry-dependent processes."
}