Skip to content

SmoothMeshEngine

Compute the laplacian smoothing of a mesh.

Vec3d

Templates:

  • Vec3d

Target: Sofa.Component.Engine.Transform

namespace: sofa::component::engine::transform

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 object 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
input_indices Position indices that need to be smoothed, leave empty for all positions
nb_iterations Number of iterations of laplacian smoothing 1
Inputs
input_position Input position
Outputs
output_position Output position
Visualization
showInput showInput 0
showOutput showOutput 0
Name Description Destination type name
context Graph Node containing this object (or BaseContext::getDefault() if no graph is used) BaseContext
slaves Sub-objects used internally by this object BaseObject
master nullptr for regular objects, or master object for which this object is one sub-objects BaseObject
topology link to the topology container BaseMeshTopology

Examples

SmoothMeshEngine.scn

<?xml version="1.0"?>
<Node name="root" >
    <RequiredPlugin name="Sofa.Component.Engine.Transform"/> <!-- Needed to use components [SmoothMeshEngine] -->
    <RequiredPlugin name="Sofa.Component.IO.Mesh"/> <!-- Needed to use components [MeshOBJLoader] -->
    <RequiredPlugin name="Sofa.Component.Topology.Container.Constant"/> <!-- Needed to use components [MeshTopology] -->
    <RequiredPlugin name="Sofa.Component.Visual"/> <!-- Needed to use components [VisualStyle] -->
    <RequiredPlugin name="Sofa.GL.Component.Rendering3D"/> <!-- Needed to use components [OglModel] -->

    <DefaultAnimationLoop/>
    <Node name="origin" >
        <VisualStyle displayFlags="showWireframe" />
        <MeshOBJLoader name="loader" filename="mesh/dragon.obj" />
        <OglModel name="visual" src="@loader" color="yellow" />
    </Node>
    <Node name="smoothed" >
        <VisualStyle displayFlags="hideWireframe" />
        <MeshTopology name="topology" src="@/origin/loader"/>
        <SmoothMeshEngine template="Vec3" name="smoother" input_position="@/origin/loader.position" nb_iterations="1" showOutput="true"/>
    </Node>
</Node>
def createScene(root_node):

   root = root_node.addChild('root')

   root.addObject('RequiredPlugin', name="Sofa.Component.Engine.Transform")
   root.addObject('RequiredPlugin', name="Sofa.Component.IO.Mesh")
   root.addObject('RequiredPlugin', name="Sofa.Component.Topology.Container.Constant")
   root.addObject('RequiredPlugin', name="Sofa.Component.Visual")
   root.addObject('RequiredPlugin', name="Sofa.GL.Component.Rendering3D")
   root.addObject('DefaultAnimationLoop', )

   origin = root.addChild('origin')

   origin.addObject('VisualStyle', displayFlags="showWireframe")
   origin.addObject('MeshOBJLoader', name="loader", filename="mesh/dragon.obj")
   origin.addObject('OglModel', name="visual", src="@loader", color="yellow")

   smoothed = root.addChild('smoothed')

   smoothed.addObject('VisualStyle', displayFlags="hideWireframe")
   smoothed.addObject('MeshTopology', name="topology", src="@/origin/loader")
   smoothed.addObject('SmoothMeshEngine', template="Vec3", name="smoother", input_position="@/origin/loader.position", nb_iterations="1", showOutput="true")