TriangleCollisionModel
Collision model using a triangular mesh, as described in BaseMeshTopology. This class will create collision elements based on a triangle and/or quad mesh. It uses directly the information of the topology and the dof to compute the triangle normals, BB and BoundingTree. The class \sa TTriangle is used to access specific triangle of this collision Model.
The `TriangleCollisionModel` manages triangular mesh data for collision detection in SOFA simulations, computing normals, bounding boxes, and bounding trees from topology information.
- module
- Sofa.Component.Collision.Geometry
- namespace
- sofa::component::collision::geometry
- include
- sofa/component/collision/geometry/TriangleCollisionModel.h
- inherits
-
- CollisionModel
- templates
-
- sofa::defaulttype::Vec3Types
- description
The TriangleCollisionModel in the SOFA framework is designed for collision detection involving triangular or quadrilateral meshes. It does not directly contribute to the governing equations or operators typically found in a finite element analysis (such as mass matrix M, stiffness matrix K, internal force $f_{int}$, residual R, etc.). Instead, it focuses on geometric and topological aspects necessary for accurate collision handling.
Governing Equations / Operators:
- Collision Elements: The component does not implement physical equations like those found in a mechanical simulation. It is designed to manage the geometry (triangles and quads) required for collision detection.
- Bounding Boxes (BB): Bounding boxes are computed for each triangle, which are used in initial collision tests to quickly determine if two objects might be colliding.
Constitutive or Kinematic Laws Involved:
- Normals: Normals are computed per triangle using the cross product of edge vectors:
$$\mathbf{n} = (\mathbf{p}_2 - \mathbf{p}_1) \times (\mathbf{p}_3 - \mathbf{p}_1),$$
where $ egin{aligned} & ext{Triangle vertices are } \mathbf{p}_1, \mathbf{p}_2, \mathbf{p}_3. \end{aligned} $
Role in the Global FEM Pipeline:
- Assembly Phase: The component is not directly involved in assembling global matrices or forces but ensures that collision elements are correctly updated based on the mesh topology.
- Constraint Handling: It helps manage self-collision constraints by ensuring that points, edges, and faces of a single object do not intersect with themselves (if
useCurvatureis enabled).
Numerical Methods / Discretization Choices:
- Bounding Tree Construction: The component constructs bounding trees for efficient collision queries. This involves recursively subdividing the space occupied by the mesh to minimize the number of pairwise tests required.
- Normals and Bounding Boxes Update: Normals are recomputed if
computeNormalsis enabled, and bounding boxes are updated based on vertex positions.
How It Fits into the Broader Variational / Lagrangian Mechanics Framework:
- The
TriangleCollisionModeldoes not directly fit into the variational or Lagrangian mechanics framework since it primarily deals with collision detection rather than physical simulation. However, accurate collision handling is essential for maintaining the integrity of simulations involving deformable bodies and rigid objects.
Summary:
- Collision Model: Manages triangular mesh data for collision detection.
- Normals and Bounding Boxes: Computes normals and bounding boxes to facilitate efficient collision queries.
- Topology Synchronization: Ensures that collision elements are updated when the mesh topology changes.
Data Fields
| Name | Type | Default | Help |
|---|---|---|---|
d_bothSide |
bool | |
activate collision on both side of the triangle model |
d_computeNormals |
bool | |
set to false to disable computation of triangles normal |
d_useCurvature |
bool | |
use the curvature of the mesh to avoid some self-intersection test |
Links
| Name | Type | Help |
|---|---|---|
l_topology |
link to the topology container |
Methods
void
updateFromTopology
()
virtual
void
updateNormals
()
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
draw
(const core::visual::VisualParams * , int index)
bool
canCollideWithElement
(int index, CollisionModel * model2, int index2)
core::behavior::MechanicalState<DataTypes> *
getMechanicalState
()
const VecCoord &
getX
()
const int &
getTriangles
()
const VecDeriv &
getNormals
()
int
getTriangleFlags
(sofa::core::topology::BaseMeshTopology::TriangleID i)
Deriv
velocity
(int index)
bool
canCreate
(T *& obj, core::objectmodel::BaseContext * context, core::objectmodel::BaseObjectDescription * arg)
void
computeBBox
(const core::ExecParams * params, bool onlyVisible)
virtual
sofa::core::topology::BaseMeshTopology *
getCollisionTopology
()
virtual
{
"name": "TriangleCollisionModel",
"namespace": "sofa::component::collision::geometry",
"module": "Sofa.Component.Collision.Geometry",
"include": "sofa/component/collision/geometry/TriangleCollisionModel.h",
"doc": "Collision model using a triangular mesh, as described in BaseMeshTopology.\n\nThis class will create collision elements based on a triangle and/or quad mesh.\nIt uses directly the information of the topology and the dof to compute the triangle normals, BB and BoundingTree.\nThe class \\sa TTriangle is used to access specific triangle of this collision Model.",
"inherits": [
"CollisionModel"
],
"templates": [
"sofa::defaulttype::Vec3Types"
],
"data_fields": [
{
"name": "d_bothSide",
"type": "bool",
"xmlname": "bothSide",
"help": "activate collision on both side of the triangle model"
},
{
"name": "d_computeNormals",
"type": "bool",
"xmlname": "computeNormals",
"help": "set to false to disable computation of triangles normal"
},
{
"name": "d_useCurvature",
"type": "bool",
"xmlname": "useCurvature",
"help": "use the curvature of the mesh to avoid some self-intersection test"
}
],
"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": "updateNormals",
"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": "draw",
"return_type": "void",
"params": [
{
"name": "",
"type": "const core::visual::VisualParams *"
},
{
"name": "index",
"type": "int"
}
],
"is_virtual": false,
"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": "getX",
"return_type": "const VecCoord &",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getTriangles",
"return_type": "const int &",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getNormals",
"return_type": "const VecDeriv &",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getTriangleFlags",
"return_type": "int",
"params": [
{
"name": "i",
"type": "sofa::core::topology::BaseMeshTopology::TriangleID"
}
],
"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": "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": "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"
},
{
"name": "getCollisionTopology",
"return_type": "sofa::core::topology::BaseMeshTopology *",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
}
],
"description": "The `TriangleCollisionModel` is a collision model in the SOFA framework that uses triangular meshes for collision detection, as described in `BaseMeshTopology`. It creates collision elements based on both triangle and quad meshes. The class computes normals, bounding boxes (BB), and bounding trees directly from topology information and degrees of freedom (DoF). The main purpose is to enable accurate and efficient collision handling with complex 3D geometries represented by triangular or quadrilateral surfaces.\n\n### Interactions with Other Components:\n- **Topology:** It requires a link (`l_topology`) to the `BaseMeshTopology` for accessing mesh information. This ensures that the model can update its internal data (triangles, normals) whenever there is a change in topology.\n- **MechanicalState:** It accesses mechanical state components (`m_mstate`) to read positions and velocities required for collision computations and visualizations.\n\n### Practical Usage:\n- `bothSide`: A boolean field that determines whether collisions should be considered on both sides of the triangle model (default is false).\n- `computeNormals`: Another boolean field that controls whether normals are computed for each triangle (enabled by default).\n- `useCurvature`: This boolean allows curvature to be used in avoiding self-intersections during collision detection.\n\nThe component provides methods like `updateFromTopology`, `updateNormals`, and `drawCollisionModel` to synchronize with changes in the topology, compute normals, and visualize the collision model respectively.",
"maths": "The `TriangleCollisionModel` in the SOFA framework is designed for collision detection involving triangular or quadrilateral meshes. It does not directly contribute to the governing equations or operators typically found in a finite element analysis (such as mass matrix M, stiffness matrix K, internal force \\(f_{int}\\), residual R, etc.). Instead, it focuses on geometric and topological aspects necessary for accurate collision handling.\n\n### Governing Equations / Operators:\n- **Collision Elements:** The component does not implement physical equations like those found in a mechanical simulation. It is designed to manage the geometry (triangles and quads) required for collision detection.\n- **Bounding Boxes (BB):** Bounding boxes are computed for each triangle, which are used in initial collision tests to quickly determine if two objects might be colliding.\n\n### Constitutive or Kinematic Laws Involved:\n- **Normals:** Normals are computed per triangle using the cross product of edge vectors:\n \\[\\mathbf{n} = (\\mathbf{p}_2 - \\mathbf{p}_1) \\times (\\mathbf{p}_3 - \\mathbf{p}_1),\\]\n where \\(\n \begin{aligned}\n &\n \text{Triangle vertices are } \\mathbf{p}_1, \\mathbf{p}_2, \\mathbf{p}_3. \n \\end{aligned}\n \\)\n\n### Role in the Global FEM Pipeline:\n- **Assembly Phase:** The component is not directly involved in assembling global matrices or forces but ensures that collision elements are correctly updated based on the mesh topology.\n- **Constraint Handling:** It helps manage self-collision constraints by ensuring that points, edges, and faces of a single object do not intersect with themselves (if `useCurvature` is enabled).\n\n### Numerical Methods / Discretization Choices:\n- **Bounding Tree Construction:** The component constructs bounding trees for efficient collision queries. This involves recursively subdividing the space occupied by the mesh to minimize the number of pairwise tests required.\n- **Normals and Bounding Boxes Update:** Normals are recomputed if `computeNormals` is enabled, and bounding boxes are updated based on vertex positions.\n\n### How It Fits into the Broader Variational / Lagrangian Mechanics Framework:\n- The `TriangleCollisionModel` does not directly fit into the variational or Lagrangian mechanics framework since it primarily deals with collision detection rather than physical simulation. However, accurate collision handling is essential for maintaining the integrity of simulations involving deformable bodies and rigid objects.\n\n### Summary:\n- **Collision Model:** Manages triangular mesh data for collision detection.\n- **Normals and Bounding Boxes:** Computes normals and bounding boxes to facilitate efficient collision queries.\n- **Topology Synchronization:** Ensures that collision elements are updated when the mesh topology changes.",
"abstract": "The `TriangleCollisionModel` manages triangular mesh data for collision detection in SOFA simulations, computing normals, bounding boxes, and bounding trees from topology information.",
"sheet": "\\# TriangleCollisionModel\n\n## Overview\nThe `TriangleCollisionModel` is a collision model component that uses triangular meshes to enable accurate and efficient collision handling. It computes normals, bounding boxes (BB), and bounding trees directly from the mesh topology and degrees of freedom (DoF). This component ensures that collision elements are updated when the mesh topology changes.\n\n## Parameters and Data\nThe `TriangleCollisionModel` exposes several significant parameters:\n- **bothSide**: A boolean field that determines whether collisions should be considered on both sides of the triangle model. Default is false.\n- **computeNormals**: Another boolean field that controls whether normals are computed for each triangle. Enabled by default.\n- **useCurvature**: This boolean allows curvature to be used in avoiding self-intersections during collision detection.\n\n## Dependencies and Connections\nThe `TriangleCollisionModel` requires a link (`l_topology`) to the `BaseMeshTopology` component, which provides access to mesh information necessary for updating internal data such as triangles and normals. It also interacts with mechanical state components to read positions and velocities required for collision computations and visualizations.\n"
}