TriangleSetTopologyModifier
Topology modifier dedicated to a triangular topology. A class that modifies the topology by adding and removing triangles
The `TriangleSetTopologyModifier` modifies triangular mesh topology by adding and removing triangles, ensuring consistency in SOFA simulations.
- module
- Sofa.Component.Topology.Container.Dynamic
- namespace
- sofa::component::topology::container::dynamic
- include
- sofa/component/topology/container/dynamic/TriangleSetTopologyModifier.h
- inherits
-
- EdgeSetTopologyModifier
- description
The TriangleSetTopologyModifier is a topology modification tool in the SOFA framework designed to manage operations on triangular meshes. This component does not directly contribute to governing equations such as mass matrices, stiffness matrices, internal forces, or residuals; instead, it operates at the level of mesh manipulation and ensures that the underlying topological structures are consistent after any modifications.
Governing Equations and Operators
This component does not implement or contribute to governing equations directly. It focuses on modifying the topology by adding, removing, and reordering triangles within a mesh structure.
Constitutive or Kinematic Laws
The TriangleSetTopologyModifier is primarily concerned with the topological consistency of triangular elements in a mesh. It does not directly involve constitutive laws (such as stress-strain relationships) or kinematic descriptions specific to materials or deformable bodies.
Role in Global FEM Pipeline
In the context of the broader Finite Element Method (FEM) simulation pipeline, this component plays a crucial role during the mesh generation and modification phase:
- Mesh Generation/Modification: Ensures that the mesh is correctly defined before any numerical discretization takes place.
The topological modifications performed by TriangleSetTopologyModifier, such as adding or removing triangles, are essential for maintaining a valid and consistent mesh. This consistency is required to ensure that the FEM operators (e.g., stiffness matrix assembly) can be computed correctly.
Numerical Methods/Discretization Choices
The component does not implement any numerical integration schemes or discretizations directly related to solving partial differential equations. Its role is more about ensuring that the mesh used for these operations remains valid and consistent after any topological changes are applied.
Topological Pre-conditions and Post-processing
The TriangleSetTopologyModifier includes mechanisms to test preconditions before modifying the topology. For example, it checks that no invalid triangles (e.g., those with collinear vertices) are added:
void TriangleSetTopologyModifier::addTriangleProcess(Triangle t)
{
if ((t[0] == t[1]) || (t[0] == t[2]) || (t[1] == t[2]))
{
msg_error() << "Invalid triangle:" << t[0] << "," << t[1] << "," << t[2];
}
// Check if there already exists a triangle with the same indices
const TriangleID previd = m_container->getTriangleIndex(t[0], t[1], t[2]);
if (previd != sofa::InvalidID)
{
msg_error() << "Triangle" << t[0] << "," << t[1] << "," << t[2] << "already exists with index" << previd << ".";
}
}
Postprocessing steps ensure that the mesh remains consistent after topological changes:
void TriangleSetTopologyModifier::removeTrianglesPostProcessing(const sofa::type::vector<TriangleID>& edgeToBeRemoved, const sofa::type::vector<TriangleID>& vertexToBeRemoved )
{
(void)vertexToBeRemoved;
(void)edgeToBeRemoved;
}
Fit into Variational/Lagrangian Mechanics Framework
The TriangleSetTopologyModifier supports the FEM simulation pipeline by ensuring that the discretization mesh used for variational formulations remains valid and consistent. This is important because a consistent mesh is necessary to apply weak form integration, assemble global operators (such as mass matrices and stiffness matrices), and ultimately solve the nonlinear system of equations arising from the variational formulation.
In summary, although TriangleSetTopologyModifier does not directly contribute mathematical operators or governing equations, it ensures that the underlying mesh topology is appropriate for accurate FEM simulation. This is critical for maintaining numerical stability and physical consistency in the broader context of mechanical simulations involving deformable continua.
Methods
void
init
()
virtual
void
reinit
()
virtual
void
addTriangles
(const int & triangles)
virtual
void
addTriangles
(const int & triangles, const int & ancestors, const int & baryCoefs)
virtual
void
addTriangleProcess
(Triangle t)
void
removeItems
(const int & items)
void
removeTriangles
(const int & triangleIds, const bool removeIsolatedEdges, const bool removeIsolatedPoints)
virtual
void
addRemoveTriangles
(const int nTri2Add, const int & triangles2Add, const int & trianglesIndex2Add, const int & ancestors, const int & baryCoefs, int & trianglesIndex2remove)
virtual
int
InciseAlongEdge
(EdgeID edge, int * createdPoints)
virtual
void
addTrianglesWarning
(const int nTriangles, const int & trianglesList, const int & trianglesIndexList)
void
addTrianglesWarning
(const int nTriangles, const int & trianglesList, const int & trianglesIndexList, const int & ancestors, const int & baryCoefs)
void
addTrianglesProcess
(const int & triangles)
virtual
void
removeTrianglesWarning
(int & triangles)
virtual
void
removeTrianglesProcess
(const int & indices, const bool removeIsolatedEdges, const bool removeIsolatedPoints)
virtual
void
addEdgesWarning
(const int nEdges, const int & edgesList, const int & edgesIndexList)
void
addEdgesWarning
(const int nEdges, const int & edgesList, const int & edgesIndexList, const int & ancestors, const int & baryCoefs)
void
addEdgesProcess
(const int & edges)
void
removeEdgesProcess
(const int & indices, const bool removeIsolatedItems)
void
addPointsProcess
(const int nPoints)
void
removePointsProcess
(const int & indices, const bool removeDOF)
void
movePointsProcess
(const int & id, const int & ancestors, const int & coefs, const bool moveDOF)
void
renumberPointsProcess
(const int & index, const int & inv_index, const bool renumberDOF)
void
propagateTopologicalEngineChanges
()
virtual
bool
removeTrianglesPreconditions
(const int & items)
virtual
void
removeTrianglesPostProcessing
(const int & edgeToBeRemoved, const int & vertexToBeRemoved)
virtual
bool
addTrianglesPreconditions
(const int & triangles)
virtual
void
addTrianglesPostProcessing
(const int & triangles)
virtual
{
"name": "TriangleSetTopologyModifier",
"namespace": "sofa::component::topology::container::dynamic",
"module": "Sofa.Component.Topology.Container.Dynamic",
"include": "sofa/component/topology/container/dynamic/TriangleSetTopologyModifier.h",
"doc": "Topology modifier dedicated to a triangular topology.\n\nA class that modifies the topology by adding and removing triangles",
"inherits": [
"EdgeSetTopologyModifier"
],
"templates": [],
"data_fields": [],
"links": [],
"methods": [
{
"name": "init",
"return_type": "void",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "reinit",
"return_type": "void",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "addTriangles",
"return_type": "void",
"params": [
{
"name": "triangles",
"type": "const int &"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "addTriangles",
"return_type": "void",
"params": [
{
"name": "triangles",
"type": "const int &"
},
{
"name": "ancestors",
"type": "const int &"
},
{
"name": "baryCoefs",
"type": "const int &"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "addTriangleProcess",
"return_type": "void",
"params": [
{
"name": "t",
"type": "Triangle"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "removeItems",
"return_type": "void",
"params": [
{
"name": "items",
"type": "const int &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "removeTriangles",
"return_type": "void",
"params": [
{
"name": "triangleIds",
"type": "const int &"
},
{
"name": "removeIsolatedEdges",
"type": "const bool"
},
{
"name": "removeIsolatedPoints",
"type": "const bool"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "addRemoveTriangles",
"return_type": "void",
"params": [
{
"name": "nTri2Add",
"type": "const int"
},
{
"name": "triangles2Add",
"type": "const int &"
},
{
"name": "trianglesIndex2Add",
"type": "const int &"
},
{
"name": "ancestors",
"type": "const int &"
},
{
"name": "baryCoefs",
"type": "const int &"
},
{
"name": "trianglesIndex2remove",
"type": "int &"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "InciseAlongEdge",
"return_type": "int",
"params": [
{
"name": "edge",
"type": "EdgeID"
},
{
"name": "createdPoints",
"type": "int *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "addTrianglesWarning",
"return_type": "void",
"params": [
{
"name": "nTriangles",
"type": "const int"
},
{
"name": "trianglesList",
"type": "const int &"
},
{
"name": "trianglesIndexList",
"type": "const int &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "addTrianglesWarning",
"return_type": "void",
"params": [
{
"name": "nTriangles",
"type": "const int"
},
{
"name": "trianglesList",
"type": "const int &"
},
{
"name": "trianglesIndexList",
"type": "const int &"
},
{
"name": "ancestors",
"type": "const int &"
},
{
"name": "baryCoefs",
"type": "const int &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "addTrianglesProcess",
"return_type": "void",
"params": [
{
"name": "triangles",
"type": "const int &"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "removeTrianglesWarning",
"return_type": "void",
"params": [
{
"name": "triangles",
"type": "int &"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "removeTrianglesProcess",
"return_type": "void",
"params": [
{
"name": "indices",
"type": "const int &"
},
{
"name": "removeIsolatedEdges",
"type": "const bool"
},
{
"name": "removeIsolatedPoints",
"type": "const bool"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "addEdgesWarning",
"return_type": "void",
"params": [
{
"name": "nEdges",
"type": "const int"
},
{
"name": "edgesList",
"type": "const int &"
},
{
"name": "edgesIndexList",
"type": "const int &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "addEdgesWarning",
"return_type": "void",
"params": [
{
"name": "nEdges",
"type": "const int"
},
{
"name": "edgesList",
"type": "const int &"
},
{
"name": "edgesIndexList",
"type": "const int &"
},
{
"name": "ancestors",
"type": "const int &"
},
{
"name": "baryCoefs",
"type": "const int &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "addEdgesProcess",
"return_type": "void",
"params": [
{
"name": "edges",
"type": "const int &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "removeEdgesProcess",
"return_type": "void",
"params": [
{
"name": "indices",
"type": "const int &"
},
{
"name": "removeIsolatedItems",
"type": "const bool"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "addPointsProcess",
"return_type": "void",
"params": [
{
"name": "nPoints",
"type": "const int"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "removePointsProcess",
"return_type": "void",
"params": [
{
"name": "indices",
"type": "const int &"
},
{
"name": "removeDOF",
"type": "const bool"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "movePointsProcess",
"return_type": "void",
"params": [
{
"name": "id",
"type": "const int &"
},
{
"name": "ancestors",
"type": "const int &"
},
{
"name": "coefs",
"type": "const int &"
},
{
"name": "moveDOF",
"type": "const bool"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "renumberPointsProcess",
"return_type": "void",
"params": [
{
"name": "index",
"type": "const int &"
},
{
"name": "inv_index",
"type": "const int &"
},
{
"name": "renumberDOF",
"type": "const bool"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "propagateTopologicalEngineChanges",
"return_type": "void",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "removeTrianglesPreconditions",
"return_type": "bool",
"params": [
{
"name": "items",
"type": "const int &"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "removeTrianglesPostProcessing",
"return_type": "void",
"params": [
{
"name": "edgeToBeRemoved",
"type": "const int &"
},
{
"name": "vertexToBeRemoved",
"type": "const int &"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "addTrianglesPreconditions",
"return_type": "bool",
"params": [
{
"name": "triangles",
"type": "const int &"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "addTrianglesPostProcessing",
"return_type": "void",
"params": [
{
"name": "triangles",
"type": "const int &"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
}
],
"description": "The `TriangleSetTopologyModifier` is a SOFA component responsible for modifying the topology of objects represented with triangular elements. It inherits from `EdgeSetTopologyModifier` and is designed to handle operations such as adding, removing, and reordering triangles in a mesh. This modifier interacts with other components through its API, which includes methods like `addTriangles`, `removeTriangles`, and `InciseAlongEdge`. These methods ensure that the topology modifications are done correctly by testing preconditions and applying postprocessing steps to maintain consistency. It is typically used within a SOFA scene graph alongside topology containers such as `TriangleSetTopologyContainer` for managing the dynamic changes in triangle-based geometries. The component also supports propagation of topological events to other components via the `propagateTopologicalEngineChanges` method, ensuring that all dependent objects are updated accordingly.",
"maths": "<p>The <code>TriangleSetTopologyModifier</code> is a topology modification tool in the SOFA framework designed to manage operations on triangular meshes. This component does not directly contribute to governing equations such as mass matrices, stiffness matrices, internal forces, or residuals; instead, it operates at the level of mesh manipulation and ensures that the underlying topological structures are consistent after any modifications.</p>\n\n<h2>Governing Equations and Operators</h2>\n<p>This component does not implement or contribute to governing equations directly. It focuses on modifying the topology by adding, removing, and reordering triangles within a mesh structure.</p>\n\n<h2>Constitutive or Kinematic Laws</h2>\n<p>The <code>TriangleSetTopologyModifier</code> is primarily concerned with the topological consistency of triangular elements in a mesh. It does not directly involve constitutive laws (such as stress-strain relationships) or kinematic descriptions specific to materials or deformable bodies.</p>\n\n<h2>Role in Global FEM Pipeline</h2>\n<p>In the context of the broader Finite Element Method (FEM) simulation pipeline, this component plays a crucial role during the mesh generation and modification phase:</p>\n<ul>\n<li><strong>Mesh Generation/Modification:</strong> Ensures that the mesh is correctly defined before any numerical discretization takes place.</li>\n</ul>\n<p>The topological modifications performed by <code>TriangleSetTopologyModifier</code>, such as adding or removing triangles, are essential for maintaining a valid and consistent mesh. This consistency is required to ensure that the FEM operators (e.g., stiffness matrix assembly) can be computed correctly.</p>\n\n<h2>Numerical Methods/Discretization Choices</h2>\n<p>The component does not implement any numerical integration schemes or discretizations directly related to solving partial differential equations. Its role is more about ensuring that the mesh used for these operations remains valid and consistent after any topological changes are applied.</p>\n\n<h3>Topological Pre-conditions and Post-processing</h3>\n<p>The <code>TriangleSetTopologyModifier</code> includes mechanisms to test preconditions before modifying the topology. For example, it checks that no invalid triangles (e.g., those with collinear vertices) are added:</p>\n<pre><code class=\"language-cpp\">void TriangleSetTopologyModifier::addTriangleProcess(Triangle t)\n{\n if ((t[0] == t[1]) || (t[0] == t[2]) || (t[1] == t[2]))\n {\n msg_error() << \"Invalid triangle:\" << t[0] << \",\" << t[1] << \",\" << t[2];\n }\n\n // Check if there already exists a triangle with the same indices\n const TriangleID previd = m_container->getTriangleIndex(t[0], t[1], t[2]);\n if (previd != sofa::InvalidID)\n {\n msg_error() << \"Triangle\" << t[0] << \",\" << t[1] << \",\" << t[2] << \"already exists with index\" << previd << \".\";\n }\n}</code></pre>\n<p>Postprocessing steps ensure that the mesh remains consistent after topological changes:</p>\n<pre><code class=\"language-cpp\">void TriangleSetTopologyModifier::removeTrianglesPostProcessing(const sofa::type::vector<TriangleID>& edgeToBeRemoved, const sofa::type::vector<TriangleID>& vertexToBeRemoved )\n{\n (void)vertexToBeRemoved;\n (void)edgeToBeRemoved;\n}</code></pre>\n\n<h2>Fit into Variational/Lagrangian Mechanics Framework</h2>\n<p>The <code>TriangleSetTopologyModifier</code> supports the FEM simulation pipeline by ensuring that the discretization mesh used for variational formulations remains valid and consistent. This is important because a consistent mesh is necessary to apply weak form integration, assemble global operators (such as mass matrices and stiffness matrices), and ultimately solve the nonlinear system of equations arising from the variational formulation.</p>\n<p>In summary, although <code>TriangleSetTopologyModifier</code> does not directly contribute mathematical operators or governing equations, it ensures that the underlying mesh topology is appropriate for accurate FEM simulation. This is critical for maintaining numerical stability and physical consistency in the broader context of mechanical simulations involving deformable continua.</p>",
"abstract": "The `TriangleSetTopologyModifier` modifies triangular mesh topology by adding and removing triangles, ensuring consistency in SOFA simulations.",
"sheet": "# TriangleSetTopologyModifier\n\n## Overview\nThe `TriangleSetTopologyModifier` is a component dedicated to modifying the topology of objects represented with triangular elements. It inherits from `EdgeSetTopologyModifier` and provides methods for adding, removing, and reordering triangles within a mesh structure.\n\n## Dependencies and Connections\nThis component typically requires or exchanges data with other components such as `TriangleSetTopologyContainer`. It fits into the SOFA scene graph by ensuring that topological changes are propagated to dependent objects via the `propagateTopologicalEngineChanges` method."
}