Skip to content

MergeMeshes

Merge several meshes.

Templates:

  • Rigid2d
  • Rigid3d
  • Vec1d
  • Vec2d
  • Vec3d

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 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
nbMeshes number of meshes to merge 2
npoints Number Of out points 0
position Output Vertices of the merged mesh
edges Output Edges of the merged mesh
triangles Output Triangles of the merged mesh
quads Output Quads of the merged mesh
polygons Output Polygons of the merged mesh
tetrahedra Output Tetrahedra of the merged mesh
hexahedra Output Hexahedra of the merged mesh
Inputs
position1 input positions for mesh 1
position2 input positions for mesh 2
edges1 input edges for mesh 1
edges2 input edges for mesh 2
triangles1 input triangles for mesh 1
triangles2 input triangles for mesh 2
quads1 input quads for mesh 1
quads2 input quads for mesh 2
tetrahedra1 input tetrahedra for mesh 1
tetrahedra2 input tetrahedra for mesh 2
hexahedra1 input hexahedra for mesh 1
hexahedra2 input hexahedra for mesh 2
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

Examples

MergeMeshes.scn

<Node name="Scene" gravity="0 0 0" dt="0.1" >
    <RequiredPlugin name="Sofa.Component.Engine.Generate"/> <!-- Needed to use components [MergeMeshes] -->
    <RequiredPlugin name="Sofa.Component.IO.Mesh"/> <!-- Needed to use components [MeshOBJLoader] -->
    <RequiredPlugin name="Sofa.Component.LinearSolver.Iterative"/> <!-- Needed to use components [CGLinearSolver] -->
    <RequiredPlugin name="Sofa.Component.Mass"/> <!-- Needed to use components [UniformMass] -->
    <RequiredPlugin name="Sofa.Component.ODESolver.Backward"/> <!-- Needed to use components [EulerImplicitSolver] -->
    <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.Component.Visual"/> <!-- Needed to use components [VisualStyle] -->

    <DefaultAnimationLoop/>
    <VisualStyle displayFlags="showBehavior" />
    <EulerImplicitSolver  rayleighStiffness="0.1" rayleighMass="0.1" />
    <CGLinearSolver iterations="25" tolerance="1e-05" threshold="1e-05"/>
    <Node>
        <MeshOBJLoader name="frog" filename="mesh/frog.obj" />
        <MeshOBJLoader name="dragon" filename="mesh/dragon.obj" />

        <MergeMeshes name="basis" nbMeshes="2" 
                     position1="@frog.position" 
                     triangles1="@frog.triangles"
                     position2="@dragon.position"
                     triangles2="@dragon.triangles"
                     />

        <MeshTopology src="@basis" drawTriangles="1"/>
        <MechanicalObject showObject="1"/>
        <UniformMass totalMass="1.0"/>
    </Node>
</Node>
def createScene(root_node):

   scene = root_node.addChild('Scene', gravity="0 0 0", dt="0.1")

   scene.addObject('RequiredPlugin', name="Sofa.Component.Engine.Generate")
   scene.addObject('RequiredPlugin', name="Sofa.Component.IO.Mesh")
   scene.addObject('RequiredPlugin', name="Sofa.Component.LinearSolver.Iterative")
   scene.addObject('RequiredPlugin', name="Sofa.Component.Mass")
   scene.addObject('RequiredPlugin', name="Sofa.Component.ODESolver.Backward")
   scene.addObject('RequiredPlugin', name="Sofa.Component.StateContainer")
   scene.addObject('RequiredPlugin', name="Sofa.Component.Topology.Container.Constant")
   scene.addObject('RequiredPlugin', name="Sofa.Component.Visual")
   scene.addObject('DefaultAnimationLoop', )
   scene.addObject('VisualStyle', displayFlags="showBehavior")
   scene.addObject('EulerImplicitSolver', rayleighStiffness="0.1", rayleighMass="0.1")
   scene.addObject('CGLinearSolver', iterations="25", tolerance="1e-05", threshold="1e-05")

   node = Scene.addChild('node')

   node.addObject('MeshOBJLoader', name="frog", filename="mesh/frog.obj")
   node.addObject('MeshOBJLoader', name="dragon", filename="mesh/dragon.obj")
   node.addObject('MergeMeshes', name="basis", nbMeshes="2", position1="@frog.position", triangles1="@frog.triangles", position2="@dragon.position", triangles2="@dragon.triangles")
   node.addObject('MeshTopology', src="@basis", drawTriangles="1")
   node.addObject('MechanicalObject', showObject="1")
   node.addObject('UniformMass', totalMass="1.0")