ExtrudeSurface
This component belongs to the category of Engines. This engine extrude a surface and returns corresponding triangles.
Input Data
- triangles: list of triangles of the object to extrude. It must me a vector of BaseMeshTopology::Triangle
- surfaceTriangles: list of triangles of the surface to extrude. The type of triangle must be BaseMeshTopology::TriangleID, and not BaseMeshTopology::Triangle
- surfaceVertices: list of positions
Output Data
- extrusionVertices: list of positions of the new triangles, created from extrusion
- extrusionTriangles: list of triangles from extrusion (vector of BaseMeshTopology::Triangle)
Important Parameter
- heightFactor: extrusion is based on normals. So, this factor defines the final height of the extrusion.
Examples
An example scene involving the ExtrudeSurface engine is available in examples/Component/Engine/Generate/ExtrudeSurface.scn
Target: Sofa.Component.Engine.Generate
namespace: sofa::component::engine::generate
parents:
DataEngine
Data:
Name | Description | Default value |
---|---|---|
name | object name | unnamed |
printLog | if true, emits extra messages at runtime. | 0 |
tags | list of the subsets the objet belongs to | |
bbox | this object bounding box | |
componentState | The state of the component among (Dirty, Valid, Undefined, Loading, Invalid). | Undefined |
listening | if true, handle the events, otherwise ignore the events | 0 |
isVisible | is Visible ? | 1 |
heightFactor | Factor for the height of the extrusion (based on normal) ? | 1 |
Inputs | ||
triangles | List of triangle indices | |
surfaceVertices | Position coordinates of the surface | |
surfaceTriangles | Indices of the triangles of the surface to extrude | |
Outputs | ||
extrusionVertices | Position coordinates of the extrusion | |
extrusionTriangles | Triangles indices of the extrusion |
Links:
Name | Description |
---|---|
context | Graph Node containing this object (or BaseContext::getDefault() if no graph is used) |
slaves | Sub-objects used internally by this object |
master | nullptr for regular objects, or master object for which this object is one sub-objects |
Examples
Component/Engine/Generate/ExtrudeSurface.scn
<?xml version="1.0"?>
<Node name="root" dt="0.02">
<RequiredPlugin name="Sofa.Component.Engine.Generate"/> <!-- Needed to use components [ExtrudeSurface RandomPointDistributionInSurface] -->
<RequiredPlugin name="Sofa.Component.Engine.Select"/> <!-- Needed to use components [SphereROI] -->
<RequiredPlugin name="Sofa.Component.IO.Mesh"/> <!-- Needed to use components [MeshOBJLoader] -->
<RequiredPlugin name="Sofa.Component.StateContainer"/> <!-- Needed to use components [MechanicalObject] -->
<RequiredPlugin name="Sofa.Component.Topology.Container.Constant"/> <!-- Needed to use components [MeshTopology] -->
<RequiredPlugin name="Sofa.GL.Component.Rendering3D"/> <!-- Needed to use components [OglModel] -->
<DefaultAnimationLoop/>
<Node name="extrude">
<MeshOBJLoader name="meshLoader" filename="mesh/liver.obj" />
<MechanicalObject src="@meshLoader"/>
<SphereROI name="surface1" centers="2 4 0" radii="0.88" drawSize="0" isVisible="0" src="@meshLoader" />
<ExtrudeSurface template="Vec3" name="extrusion" triangles="@meshLoader.triangles" surfaceVertices="@meshLoader.position" surfaceTriangles="@surface1.triangleIndices" isVisible="0" />
<RandomPointDistributionInSurface template="Vec3" vertices="@extrusion.extrusionVertices" triangles="@extrusion.extrusionTriangles" numberOfInPoints="100" numberOfTests="3" minDistanceBetweenPoints="0.1" />
</Node>
<Node name="Extrusion">
<MeshTopology points="@../extrude/extrusion.extrusionVertices" triangles="@../extrude/extrusion.extrusionTriangles" />
<MechanicalObject position="@../extrude/extrusion.extrusionVertices"/>
<OglModel color="red" />
</Node>
<Node>
<MeshOBJLoader name='myLoader' filename='mesh/liver.obj'/>
<OglModel src='@myLoader'/>
</Node>
</Node>
def createScene(rootNode):
root = rootNode.addChild('root', dt="0.02")
root.addObject('RequiredPlugin', name="Sofa.Component.Engine.Generate")
root.addObject('RequiredPlugin', name="Sofa.Component.Engine.Select")
root.addObject('RequiredPlugin', name="Sofa.Component.IO.Mesh")
root.addObject('RequiredPlugin', name="Sofa.Component.StateContainer")
root.addObject('RequiredPlugin', name="Sofa.Component.Topology.Container.Constant")
root.addObject('RequiredPlugin', name="Sofa.GL.Component.Rendering3D")
root.addObject('DefaultAnimationLoop')
extrude = root.addChild('extrude')
extrude.addObject('MeshOBJLoader', name="meshLoader", filename="mesh/liver.obj")
extrude.addObject('MechanicalObject', src="@meshLoader")
extrude.addObject('SphereROI', name="surface1", centers="2 4 0", radii="0.88", drawSize="0", isVisible="0", src="@meshLoader")
extrude.addObject('ExtrudeSurface', template="Vec3", name="extrusion", triangles="@meshLoader.triangles", surfaceVertices="@meshLoader.position", surfaceTriangles="@surface1.triangleIndices", isVisible="0")
extrude.addObject('RandomPointDistributionInSurface', template="Vec3", vertices="@extrusion.extrusionVertices", triangles="@extrusion.extrusionTriangles", numberOfInPoints="100", numberOfTests="3", minDistanceBetweenPoints="0.1")
Extrusion = root.addChild('Extrusion')
Extrusion.addObject('MeshTopology', points="@../extrude/extrusion.extrusionVertices", triangles="@../extrude/extrusion.extrusionTriangles")
Extrusion.addObject('MechanicalObject', position="@../extrude/extrusion.extrusionVertices")
Extrusion.addObject('OglModel', color="red")
root = root.addChild('root')
root.addObject('MeshOBJLoader', name="myLoader", filename="mesh/liver.obj")
root.addObject('OglModel', src="@myLoader")