Back

LineCollisionModel

sofa::component::collision::geometry::LineCollisionModel
CollisionModel
Doc (from source)

Collision model using a linear mesh, as described in MeshTopology.

Abstract (AI generated)

The `LineCollisionModel` handles collision detection for linear structures by computing bounding boxes and continuous bounding trees based on the mesh topology.

Metadata
module
Sofa.Component.Collision.Geometry
namespace
sofa::component::collision::geometry
include
sofa/component/collision/geometry/LineCollisionModel.h
inherits
  • CollisionModel
templates
  • sofa::defaulttype::Vec3Types
description

Mathematical and Physical Description of LineCollisionModel

Governing Equations and Operators

The LineCollisionModel does not directly implement or contribute to any specific governing equations such as the mass matrix $ M $, stiffness matrix $ K $, internal force vector $ f_{int} $, residual vector $ R $, etc. Instead, its primary role is in collision detection and handling geometric constraints for line-based models. This component interacts with other SOFA components to ensure that lines can be accurately represented and checked for collisions during simulations.

Constitutive or Kinematic Laws Involved

The LineCollisionModel does not explicitly involve any constitutive laws (such as stress-strain relationships) or kinematic laws (such as strain measures). Instead, it focuses on geometric representations of lines defined by a set of edges from the mesh topology. Specifically:

  • Edges and Vertices: The component works with edges in a linear mesh, where each edge is represented by two vertices.
  • Bounding Boxes: It computes bounding boxes ($ BBox $) for efficient collision detection between lines. For each line defined by endpoints $ p_1 $ and $ p_2 $, the bounding box is computed as:
$$ minElem[c] = \min(p_{1,c}, p_{2,c}) - d, \quad maxElem[c] = \max(p_{1,c}, p_{2,c}) + d $$

where $ c $ denotes the component (x, y, or z), and $ d $ is a predefined distance to account for collision margins.

  • Continuous Bounding Boxes: For dynamic simulations, it computes continuous bounding boxes considering motion over time. The positions at future time steps are estimated as:
$$ pt1v = p_1 + v_1 \cdot dt, \quad pt2v = p_2 + v_2 \cdot dt $$

where $ v_1 $ and $ v_2 $ are the velocities of the endpoints.

Role in the Global FEM Pipeline

The LineCollisionModel plays a role primarily in collision detection and geometric constraint handling within the SOFA framework. Its primary contributions include:

  • Topology Handling: It updates from topology changes to ensure that lines (edges) are correctly defined based on the current mesh state.
  • The method updateFromTopology() ensures that the model is consistent with any changes in the mesh topology, such as adding or removing edges.
  • Collision Detection: It determines if two elements can collide by checking their geometric proximity and boundary conditions. This includes:
  • canCollideWithElement(): Evaluates if two lines (edges) can potentially collide based on their positions and adjacency in the mesh topology.
  • Bounding Box Computation: Efficient collision detection is enabled through bounding box computation, which helps in filtering out non-colliding pairs quickly.

Numerical Methods or Discretization Choices

The component does not discretize physical equations but focuses on geometric representations and efficient data structures for collision detection. Key numerical methods include:

  • Bounding Box: Utilizes simple bounding box computations to determine if potential collisions should be checked in more detail.
  • Continuous Bounding Boxes: For dynamic simulations, it computes future positions based on current velocities to predict potential intersections.

Broad Variational / Lagrangian Mechanics Framework

Although the LineCollisionModel does not directly contribute to variational or Lagrangian mechanics formulations, it is essential for ensuring that geometric constraints and collision events are accurately handled within these frameworks. This ensures that the overall simulation remains physically consistent by preventing interpenetration of line-based structures.

In summary, the LineCollisionModel provides a crucial geometric representation and efficient collision detection mechanism in SOFA, enabling accurate simulations involving linear structures or segments.

Data Fields
NameTypeDefaultHelp
d_bothSide bool activate collision on both side of the line model (when surface normals are defined on these lines)
d_displayFreePosition bool Display Collision Model Points free position(in green)
Links
NameTypeHelp
l_topology link to the topology container
Methods
void updateFromTopology () virtual
void drawCollisionModel (const core::visual::VisualParams * vparams) virtual
void init () virtual
void resize (int size)
void computeBoundingTree (int maxDepth) virtual
void computeContinuousBoundingTree (SReal dt, ContinuousIntersectionTypeFlag continuousIntersectionFlag, int maxDepth) virtual
void handleTopologyChange () virtual
bool canCollideWithElement (int index, CollisionModel * model2, int index2)
core::behavior::MechanicalState<DataTypes> * getMechanicalState ()
Deriv velocity (int index)
int getElemEdgeIndex (int index)
int getLineFlags (int i)
bool canCreate (T *& obj, core::objectmodel::BaseContext * context, core::objectmodel::BaseObjectDescription * arg)
sofa::core::topology::BaseMeshTopology * getCollisionTopology () virtual
void computeBBox (const core::ExecParams * params, bool onlyVisible) virtual
{
  "name": "LineCollisionModel",
  "namespace": "sofa::component::collision::geometry",
  "module": "Sofa.Component.Collision.Geometry",
  "include": "sofa/component/collision/geometry/LineCollisionModel.h",
  "doc": "Collision model using a linear mesh, as described in MeshTopology.",
  "inherits": [
    "CollisionModel"
  ],
  "templates": [
    "sofa::defaulttype::Vec3Types"
  ],
  "data_fields": [
    {
      "name": "d_bothSide",
      "type": "bool",
      "xmlname": "bothSide",
      "help": "activate collision on both side of the line model (when surface normals are defined on these lines)"
    },
    {
      "name": "d_displayFreePosition",
      "type": "bool",
      "xmlname": "displayFreePosition",
      "help": "Display Collision Model Points free position(in green)"
    }
  ],
  "links": [
    {
      "name": "l_topology",
      "target": "BaseMeshTopology",
      "kind": "single",
      "xmlname": "topology",
      "help": "link to the topology container"
    }
  ],
  "methods": [
    {
      "name": "updateFromTopology",
      "return_type": "void",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "protected"
    },
    {
      "name": "drawCollisionModel",
      "return_type": "void",
      "params": [
        {
          "name": "vparams",
          "type": "const core::visual::VisualParams *"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "protected"
    },
    {
      "name": "init",
      "return_type": "void",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "resize",
      "return_type": "void",
      "params": [
        {
          "name": "size",
          "type": "int"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "computeBoundingTree",
      "return_type": "void",
      "params": [
        {
          "name": "maxDepth",
          "type": "int"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "computeContinuousBoundingTree",
      "return_type": "void",
      "params": [
        {
          "name": "dt",
          "type": "SReal"
        },
        {
          "name": "continuousIntersectionFlag",
          "type": "ContinuousIntersectionTypeFlag"
        },
        {
          "name": "maxDepth",
          "type": "int"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "handleTopologyChange",
      "return_type": "void",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "canCollideWithElement",
      "return_type": "bool",
      "params": [
        {
          "name": "index",
          "type": "int"
        },
        {
          "name": "model2",
          "type": "CollisionModel *"
        },
        {
          "name": "index2",
          "type": "int"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getMechanicalState",
      "return_type": "core::behavior::MechanicalState<DataTypes> *",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "velocity",
      "return_type": "Deriv",
      "params": [
        {
          "name": "index",
          "type": "int"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getElemEdgeIndex",
      "return_type": "int",
      "params": [
        {
          "name": "index",
          "type": "int"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getLineFlags",
      "return_type": "int",
      "params": [
        {
          "name": "i",
          "type": "int"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "canCreate",
      "return_type": "bool",
      "params": [
        {
          "name": "obj",
          "type": "T *&"
        },
        {
          "name": "context",
          "type": "core::objectmodel::BaseContext *"
        },
        {
          "name": "arg",
          "type": "core::objectmodel::BaseObjectDescription *"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": true,
      "access": "public"
    },
    {
      "name": "getCollisionTopology",
      "return_type": "sofa::core::topology::BaseMeshTopology *",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "computeBBox",
      "return_type": "void",
      "params": [
        {
          "name": "params",
          "type": "const core::ExecParams *"
        },
        {
          "name": "onlyVisible",
          "type": "bool"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    }
  ],
  "description": "The `LineCollisionModel` is part of the SOFA framework and belongs to the collision geometry module. It serves as a collision model using a linear mesh, which is described by the MeshTopology. This class inherits from the generic `CollisionModel` class and specializes it for line-based models.\n\n### Role and Purpose:\nThe primary role of this component is to enable accurate collision detection between lines in simulations involving linear structures or segments (e.g., cables, rods). The `LineCollisionModel` provides functionality for computing bounding trees, handling topology changes, and determining if two elements can collide based on specific conditions.\n\n### Interactions with Other Components:\nThe `LineCollisionModel` interacts primarily with the `BaseMeshTopology`, which it links to via a strong connection. It also interfaces with various SOFA core components like `MechanicalState`, `VisualParams`, and other collision models (like `PointCollisionModel`).\n\nThe component relies on the topology container for edge information, which is used to determine active segments for collision detection.\n\n### Data Fields:\n- **bothSide**: A boolean flag (`d_bothSide`) that activates collision detection on both sides of the line model when surface normals are defined.\n- **displayFreePosition**: Another boolean field (`d_displayFreePosition`) that enables visualizing the free positions of collision points in green.\n\n### Practical Usage Guidance:\nThe `LineCollisionModel` is initialized with a topology container and can be configured to handle various aspects of line-based collision detection. It supports dynamic resizing based on the number of edges defined in the mesh topology, which ensures adaptability for different simulation scenarios.\n\nThe component automatically computes bounding boxes (BBox) and continuous bounding trees for efficient collision detection during runtime. Additionally, it provides methods for updating from topology changes, drawing visualization data, and checking if two elements can collide based on predefined conditions.",
  "maths": "### Mathematical and Physical Description of `LineCollisionModel`\n\n#### Governing Equations and Operators\n\nThe `LineCollisionModel` does not directly implement or contribute to any specific governing equations such as the mass matrix \\( M \\), stiffness matrix \\( K \\), internal force vector \\( f_{int} \\), residual vector \\( R \\), etc. Instead, its primary role is in collision detection and handling geometric constraints for line-based models. This component interacts with other SOFA components to ensure that lines can be accurately represented and checked for collisions during simulations.\n\n#### Constitutive or Kinematic Laws Involved\n\nThe `LineCollisionModel` does not explicitly involve any constitutive laws (such as stress-strain relationships) or kinematic laws (such as strain measures). Instead, it focuses on geometric representations of lines defined by a set of edges from the mesh topology. Specifically:\n\n- **Edges and Vertices**: The component works with edges in a linear mesh, where each edge is represented by two vertices.\n- **Bounding Boxes**: It computes bounding boxes (\\( BBox \\)) for efficient collision detection between lines. For each line defined by endpoints \\( p_1 \\) and \\( p_2 \\), the bounding box is computed as:\n  \n  \n  \\[\n  minElem[c] = \\min(p_{1,c}, p_{2,c}) - d, \\quad maxElem[c] = \\max(p_{1,c}, p_{2,c}) + d\n  \\]\n  \n  where \\( c \\) denotes the component (x, y, or z), and \\( d \\) is a predefined distance to account for collision margins.\n\n- **Continuous Bounding Boxes**: For dynamic simulations, it computes continuous bounding boxes considering motion over time. The positions at future time steps are estimated as:\n  \n  \n  \\[\n  pt1v = p_1 + v_1 \\cdot dt, \\quad pt2v = p_2 + v_2 \\cdot dt\n  \\]\n  \n  where \\( v_1 \\) and \\( v_2 \\) are the velocities of the endpoints.\n\n#### Role in the Global FEM Pipeline\n\nThe `LineCollisionModel` plays a role primarily in collision detection and geometric constraint handling within the SOFA framework. Its primary contributions include:\n\n- **Topology Handling**: It updates from topology changes to ensure that lines (edges) are correctly defined based on the current mesh state.\n  - The method `updateFromTopology()` ensures that the model is consistent with any changes in the mesh topology, such as adding or removing edges.\n- **Collision Detection**: It determines if two elements can collide by checking their geometric proximity and boundary conditions. This includes:\n  - `canCollideWithElement()`: Evaluates if two lines (edges) can potentially collide based on their positions and adjacency in the mesh topology.\n- **Bounding Box Computation**: Efficient collision detection is enabled through bounding box computation, which helps in filtering out non-colliding pairs quickly.\n\n#### Numerical Methods or Discretization Choices\n\nThe component does not discretize physical equations but focuses on geometric representations and efficient data structures for collision detection. Key numerical methods include:\n\n- **Bounding Box**: Utilizes simple bounding box computations to determine if potential collisions should be checked in more detail.\n- **Continuous Bounding Boxes**: For dynamic simulations, it computes future positions based on current velocities to predict potential intersections.\n\n#### Broad Variational / Lagrangian Mechanics Framework\n\nAlthough the `LineCollisionModel` does not directly contribute to variational or Lagrangian mechanics formulations, it is essential for ensuring that geometric constraints and collision events are accurately handled within these frameworks. This ensures that the overall simulation remains physically consistent by preventing interpenetration of line-based structures.\n\nIn summary, the `LineCollisionModel` provides a crucial geometric representation and efficient collision detection mechanism in SOFA, enabling accurate simulations involving linear structures or segments.",
  "abstract": "The `LineCollisionModel` handles collision detection for linear structures by computing bounding boxes and continuous bounding trees based on the mesh topology.",
  "sheet": "# LineCollisionModel\n\n**Overview**\n\nThe `LineCollisionModel` is a specialized collision model component in SOFA that enables accurate collision detection between lines. It inherits from the generic `CollisionModel` class and interacts with the `BaseMeshTopology` to handle geometric representations of linear structures.\n\n**Parameters and Data**\n\n- **bothSide**: A boolean flag (`d_bothSide`) that activates collision detection on both sides of the line model when surface normals are defined. Default: `false`.\n- **displayFreePosition**: Another boolean field (`d_displayFreePosition`) that enables visualizing the free positions of collision points in green. Default: `false`.\n\n**Dependencies and Connections**\n\nThe component requires a link to the `BaseMeshTopology`, which provides edge information for determining active segments for collision detection.\n\n**Practical Notes**\n\n- The component automatically computes bounding boxes (BBox) and continuous bounding trees for efficient collision detection during runtime.\n- It supports dynamic resizing based on the number of edges defined in the mesh topology, ensuring adaptability for different simulation scenarios."
}