DilateEngine
Dilates a given mesh by moving vertices along their normal. This class dilates a given mesh by moving vertices along their normal.
The `DilateEngine` dilates or erodes a mesh by moving vertices along their normals according to a specified distance, with optional enforcement of minimum thickness.
- module
- Sofa.Component.Engine.Transform
- namespace
- sofa::component::engine::transform
- include
- sofa/component/engine/transform/DilateEngine.h
- inherits
-
- DataEngine
- templates
-
- sofa::defaulttype::Vec3Types
- summary
- details
-
- It extends the `core::DataEngine` class and operates on meshes defined by triangles and quads.
- The component computes vertex normals based on the input triangle and quad geometry.
- Vertices are then moved along these normals according to a specified distance value, with positive values for dilation (expansion) and negative values for erosion (contraction).
- An optional minimum thickness can be enforced to prevent vertices from coming too close together.
- inputs
-
- {'name': 'position or d_inputX', 'description': 'The input array of 3D points representing the mesh vertices.'}
- {'name': 'triangles (d_triangles)', 'description': 'Input mesh triangles used for normal computation.'}
- {'name': 'quads (d_quads)', 'description': 'Input mesh quads used for normal computation.'}
- {'name': 'distance (d_distance)', 'description': 'The distance to move the vertices along their normals. Positive values dilate, negative values erode.'}
- {'name': 'minThickness (d_minThickness)', 'description': 'Optional minimal thickness enforced between any two points on the mesh.'}
- outputs
-
- {'name': 'output (d_outputX)', 'description': 'The resulting array of 3D points representing the dilated or eroded vertices.'}
- {'name': 'normals', 'description': 'Computed vertex normals used for dilation/erosion.'}
- {'name': 'thickness', 'description': 'Thickness values ensuring minimal separation between any two points, if minThickness is enforced.'}
- usage_example
-
- To use the `DilateEngine`, you would typically define a mesh with triangles and quads. Then set the distance to control dilation or erosion.
- The component will automatically compute vertex normals and adjust positions accordingly.
The DilateEngine in the SOFA framework operates on meshes defined by triangles and quads, computing vertex normals based on their respective geometry. The process involves several mathematical steps to achieve dilation or erosion:
- Normal Computation:
- For each triangle with vertices $v_0$, $v_1$, and $v_2$, the face normal is computed as:
$$ n = (v_1 - v_0) \times (v_2 - v_0) $$ - For each quad with vertices $w_0$, $w_1$, $w_2$, and $w_3$, face normals are computed for the two triangles formed by splitting the quad:
$$ n_{quad1} = (w_1 - w_0) \times (w_2 - w_0) $$
$$ n_{quad2} = (w_2 - w_0) \times (w_3 - w_0) $$
The vertex normals are then aggregated from these face normals.
- Vertex Movement:
Each vertex position is adjusted along its computed normal by a specified distance,distance(positive for dilation and negative for erosion):
Let $d$ be the distance, and $n_i$ be the normalized normal at vertex $v_i$. The new vertex position, $v'_i$, is given by:
- Thickness Enforcement (Optional):
To enforce a minimum thickness between any two points on the mesh, a distance calculation from each point along its normal to other mesh elements is performed using a spatial data structure such as an octree. - For each vertex $v_i$, compute distances to other mesh faces in direction of the negative normal.
-
Adjust the movement if any computed thickness value falls below
minThickness. The adjusted distance for dilation/erosion would be:Let $t_i$ be the minimum thickness at vertex $v_i$. If $minThickness > 0$:
- Output:
The final output includes updated positions (d_outputX), computed normals, and thickness values (if enforced).
Data Fields
| Name | Type | Default | Help |
|---|---|---|---|
d_inputX |
VecCoord | |
input array of 3d points |
d_outputX |
VecCoord | |
output array of 3d points |
d_triangles |
SeqTriangles | |
input mesh triangles |
d_quads |
SeqQuads | |
input mesh quads |
d_normals |
VecCoord | |
point normals |
d_distance |
Real | |
distance to move the points (positive for dilatation, negative for erosion) |
d_minThickness |
Real | |
minimal thickness to enforce |
Methods
void
init
()
virtual
void
reinit
()
virtual
void
doUpdate
()
virtual
{
"name": "DilateEngine",
"namespace": "sofa::component::engine::transform",
"module": "Sofa.Component.Engine.Transform",
"include": "sofa/component/engine/transform/DilateEngine.h",
"doc": "Dilates a given mesh by moving vertices along their normal.\n\nThis class dilates a given mesh by moving vertices along their normal.",
"inherits": [
"DataEngine"
],
"templates": [
"sofa::defaulttype::Vec3Types"
],
"data_fields": [
{
"name": "d_inputX",
"type": "VecCoord",
"xmlname": "input_position",
"help": "input array of 3d points"
},
{
"name": "d_outputX",
"type": "VecCoord",
"xmlname": "output_position",
"help": "output array of 3d points"
},
{
"name": "d_triangles",
"type": "SeqTriangles",
"xmlname": "triangles",
"help": "input mesh triangles"
},
{
"name": "d_quads",
"type": "SeqQuads",
"xmlname": "quads",
"help": "input mesh quads"
},
{
"name": "d_normals",
"type": "VecCoord",
"xmlname": "normal",
"help": "point normals"
},
{
"name": "d_distance",
"type": "Real",
"xmlname": "distance",
"help": "distance to move the points (positive for dilatation, negative for erosion)"
},
{
"name": "d_minThickness",
"type": "Real",
"xmlname": "minThickness",
"help": "minimal thickness to enforce"
}
],
"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": "doUpdate",
"return_type": "void",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
}
],
"description": {
"summary": "The `DilateEngine` is a component in the SOFA framework that dilates or erodes a given mesh by moving its vertices along their respective normals.",
"details": [
"It extends the `core::DataEngine` class and operates on meshes defined by triangles and quads.",
"The component computes vertex normals based on the input triangle and quad geometry.",
"Vertices are then moved along these normals according to a specified distance value, with positive values for dilation (expansion) and negative values for erosion (contraction).",
"An optional minimum thickness can be enforced to prevent vertices from coming too close together."
],
"inputs": [
{
"name": "position or d_inputX",
"description": "The input array of 3D points representing the mesh vertices."
},
{
"name": "triangles (d_triangles)",
"description": "Input mesh triangles used for normal computation."
},
{
"name": "quads (d_quads)",
"description": "Input mesh quads used for normal computation."
},
{
"name": "distance (d_distance)",
"description": "The distance to move the vertices along their normals. Positive values dilate, negative values erode."
},
{
"name": "minThickness (d_minThickness)",
"description": "Optional minimal thickness enforced between any two points on the mesh."
}
],
"outputs": [
{
"name": "output (d_outputX)",
"description": "The resulting array of 3D points representing the dilated or eroded vertices."
},
{
"name": "normals",
"description": "Computed vertex normals used for dilation/erosion."
},
{
"name": "thickness",
"description": "Thickness values ensuring minimal separation between any two points, if minThickness is enforced."
}
],
"usage_example": [
"To use the `DilateEngine`, you would typically define a mesh with triangles and quads. Then set the distance to control dilation or erosion.",
"The component will automatically compute vertex normals and adjust positions accordingly."
]
},
"maths": "The `DilateEngine` in the SOFA framework operates on meshes defined by triangles and quads, computing vertex normals based on their respective geometry. The process involves several mathematical steps to achieve dilation or erosion:\n\n1. **Normal Computation**:\n - For each triangle with vertices \\(v_0\\), \\(v_1\\), and \\(v_2\\), the face normal is computed as: \n \\[ n = (v_1 - v_0) \\times (v_2 - v_0) \\]\n - For each quad with vertices \\(w_0\\), \\(w_1\\), \\(w_2\\), and \\(w_3\\), face normals are computed for the two triangles formed by splitting the quad: \n \\[ n_{quad1} = (w_1 - w_0) \\times (w_2 - w_0) \\]\n \\[ n_{quad2} = (w_2 - w_0) \\times (w_3 - w_0) \\]\n\n The vertex normals are then aggregated from these face normals.\n\n2. **Vertex Movement**:\n Each vertex position is adjusted along its computed normal by a specified distance, `distance` (positive for dilation and negative for erosion):\n \n Let \\(d\\) be the `distance`, and \\(n_i\\) be the normalized normal at vertex \\(v_i\\). The new vertex position, \\(v'_i\\), is given by:\n \n \\[ v'_i = v_i + n_i d \\]\n\n3. **Thickness Enforcement** (Optional):\n To enforce a minimum thickness between any two points on the mesh, a distance calculation from each point along its normal to other mesh elements is performed using a spatial data structure such as an octree.\n - For each vertex \\(v_i\\), compute distances to other mesh faces in direction of the negative normal. \n - Adjust the movement if any computed thickness value falls below `minThickness`. The adjusted distance for dilation/erosion would be:\n\n Let \\(t_i\\) be the minimum thickness at vertex \\(v_i\\). If \\(minThickness > 0\\):\n \n \\[ d'_i = d + (minThickness - t_i) \\times 0.5 \\]\n\n4. **Output**:\n The final output includes updated positions (`d_outputX`), computed normals, and thickness values (if enforced).",
"abstract": "The `DilateEngine` dilates or erodes a mesh by moving vertices along their normals according to a specified distance, with optional enforcement of minimum thickness.",
"sheet": "\n# DilateEngine\n\n## Overview\n\nThe `DilateEngine` is an engine component that dilates or erodes a given mesh by moving its vertices along their respective normals. It extends the `DataEngine` class and operates on meshes defined by triangles and quads.\n\n## Mathematical Model\n\n### Normal Computation\nFor each triangle with vertices \\(v_0\\), \\(v_1\\), and \\(v_2\\), the face normal is computed as:\n\\[ n = (v_1 - v_0) \\times (v_2 - v_0) \\]\nFor each quad with vertices \\(w_0\\), \\(w_1\\), \\(w_2\\), and \\(w_3\\), face normals are computed for the two triangles formed by splitting the quad:\n\\[ n_{quad1} = (w_1 - w_0) \\times (w_2 - w_0) \\]\n\\[ n_{quad2} = (w_2 - w_0) \\times (w_3 - w_0) \\]\nThe vertex normals are then aggregated from these face normals.\n\n### Vertex Movement\nEach vertex position is adjusted along its computed normal by a specified distance, `distance` (positive for dilation and negative for erosion). Let \\(d\\) be the `distance`, and \\(n_i\\) be the normalized normal at vertex \\(v_i\\). The new vertex position, \\(v'_i\\), is given by:\n\\[ v'_i = v_i + n_i d \\]\n\n### Thickness Enforcement (Optional)\nTo enforce a minimum thickness between any two points on the mesh, a distance calculation from each point along its normal to other mesh elements is performed using a spatial data structure such as an octree. For each vertex \\(v_i\\), compute distances to other mesh faces in direction of the negative normal. Adjust the movement if any computed thickness value falls below `minThickness`. The adjusted distance for dilation/erosion would be:\nLet \\(t_i\\) be the minimum thickness at vertex \\(v_i\\). If \\(minThickness > 0\\):\n\\[ d'_i = d + (minThickness - t_i) \\times 0.5 \\]\n\n## Parameters and Data\n- **input_position (`d_inputX`)**: Input array of 3D points representing the mesh vertices.\n- **output_position (`d_outputX`)**: Output array of 3D points representing the dilated or eroded vertices.\n- **triangles (`d_triangles`)**: Input mesh triangles used for normal computation.\n- **quads (`d_quads`)**: Input mesh quads used for normal computation.\n- **normal (`d_normals`)**: Computed vertex normals used for dilation/erosion.\n- **distance (`d_distance`)**: Distance to move the vertices along their normals. Positive values dilate, negative values erode.\n- **minThickness (`d_minThickness`)**: Optional minimal thickness enforced between any two points on the mesh."
}