Skip to content

IdentityMultiMapping

Concatenate several States together

Templates:

  • Rigid3d,Rigid3d
  • Vec3d,Vec3d

Target: Sofa.Component.Mapping.Linear

namespace: sofa::component::mapping::linear

parents:

  • CRTPLinearMapping

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
mapForces Are forces mapped ? 1
mapConstraints Are constraints mapped ? 1
mapMasses Are masses mapped ? 1
mapMatrices Are matrix explicit mapped? 0
applyRestPosition set to true to apply this mapping to restPosition at init 0

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
input Input Object(s)
output Output Object(s)

Examples

Component/Mapping/Linear/IdentityMultiMapping.scn

<?xml version="1.0"?>
<Node name="root" dt="0.02" gravity="0 0 0">
    <RequiredPlugin name="Sofa.Component.Collision.Detection.Algorithm"/> <!-- Needed to use components [BVHNarrowPhase BruteForceBroadPhase CollisionPipeline] -->
    <RequiredPlugin name="Sofa.Component.Collision.Detection.Intersection"/> <!-- Needed to use components [DiscreteIntersection] -->
    <RequiredPlugin name="Sofa.Component.Collision.Geometry"/> <!-- Needed to use components [SphereCollisionModel] -->
    <RequiredPlugin name="Sofa.Component.Collision.Response.Contact"/> <!-- Needed to use components [CollisionResponse] -->
    <RequiredPlugin name="Sofa.Component.IO.Mesh"/> <!-- Needed to use components [GridMeshCreator] -->
    <RequiredPlugin name="Sofa.Component.LinearSolver.Iterative"/> <!-- Needed to use components [CGLinearSolver] -->
    <RequiredPlugin name="Sofa.Component.Mapping.Linear"/> <!-- Needed to use components [IdentityMultiMapping] -->
    <RequiredPlugin name="Sofa.Component.Mass"/> <!-- Needed to use components [UniformMass] -->
    <RequiredPlugin name="Sofa.Component.MechanicalLoad"/> <!-- Needed to use components [ConstantForceField] -->
    <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] -->

    <VisualStyle displayFlags="showBehaviorModels showCollisionModels showForceFields" />
    <DefaultAnimationLoop/>

    <CollisionPipeline/>
    <BruteForceBroadPhase/>
    <BVHNarrowPhase/>
    <CollisionResponse response="PenalityContactForceField" />
    <DiscreteIntersection/>


    <EulerImplicitSolver  rayleighStiffness="0.1" rayleighMass="0.1" />
    <CGLinearSolver iterations="25" tolerance="1e-5" threshold="1e-5"/>


    <Node name="object1">        
        <GridMeshCreator name="loader" filename="nofile" resolution="2 2" />
        <MeshTopology src="@loader" />
        <MechanicalObject template="Vec3" src="@loader" name="dof1" />

        <Node name="object2">        
            <GridMeshCreator name="loader" filename="nofile" resolution="2 2" translation="2 0 0" />
            <MeshTopology src="@loader" />
            <MechanicalObject template="Vec3" src="@loader"  name="dof2"/>

            <Node name="concatenation">
                <MechanicalObject template="Vec3" name="dofall" showObject="1"/>
                <IdentityMultiMapping template="Vec3,Vec3" input="@../../dof1 @../dof2" output="@./dofall" />
                <SphereCollisionModel radius="0.3" selfCollision="1"/>
                <UniformMass vertexMass="1" />
                <ConstantForceField indices="0" forces="1 0 0"/>
            </Node>

        </Node>

    </Node>


</Node>
def createScene(rootNode):

    root = rootNode.addChild('root', dt="0.02", gravity="0 0 0")
    root.addObject('RequiredPlugin', name="Sofa.Component.Collision.Detection.Algorithm")
    root.addObject('RequiredPlugin', name="Sofa.Component.Collision.Detection.Intersection")
    root.addObject('RequiredPlugin', name="Sofa.Component.Collision.Geometry")
    root.addObject('RequiredPlugin', name="Sofa.Component.Collision.Response.Contact")
    root.addObject('RequiredPlugin', name="Sofa.Component.IO.Mesh")
    root.addObject('RequiredPlugin', name="Sofa.Component.LinearSolver.Iterative")
    root.addObject('RequiredPlugin', name="Sofa.Component.Mapping.Linear")
    root.addObject('RequiredPlugin', name="Sofa.Component.Mass")
    root.addObject('RequiredPlugin', name="Sofa.Component.MechanicalLoad")
    root.addObject('RequiredPlugin', name="Sofa.Component.ODESolver.Backward")
    root.addObject('RequiredPlugin', name="Sofa.Component.StateContainer")
    root.addObject('RequiredPlugin', name="Sofa.Component.Topology.Container.Constant")
    root.addObject('RequiredPlugin', name="Sofa.Component.Visual")
    root.addObject('VisualStyle', displayFlags="showBehaviorModels showCollisionModels showForceFields")
    root.addObject('DefaultAnimationLoop')
    root.addObject('CollisionPipeline')
    root.addObject('BruteForceBroadPhase')
    root.addObject('BVHNarrowPhase')
    root.addObject('CollisionResponse', response="PenalityContactForceField")
    root.addObject('DiscreteIntersection')
    root.addObject('EulerImplicitSolver', rayleighStiffness="0.1", rayleighMass="0.1")
    root.addObject('CGLinearSolver', iterations="25", tolerance="1e-5", threshold="1e-5")

    object1 = root.addChild('object1')
    object1.addObject('GridMeshCreator', name="loader", filename="nofile", resolution="2 2")
    object1.addObject('MeshTopology', src="@loader")
    object1.addObject('MechanicalObject', template="Vec3", src="@loader", name="dof1")

    object2 = object1.addChild('object2')
    object2.addObject('GridMeshCreator', name="loader", filename="nofile", resolution="2 2", translation="2 0 0")
    object2.addObject('MeshTopology', src="@loader")
    object2.addObject('MechanicalObject', template="Vec3", src="@loader", name="dof2")

    concatenation = object2.addChild('concatenation')
    concatenation.addObject('MechanicalObject', template="Vec3", name="dofall", showObject="1")
    concatenation.addObject('IdentityMultiMapping', template="Vec3,Vec3", input="@../../dof1 @../dof2", output="@./dofall")
    concatenation.addObject('SphereCollisionModel', radius="0.3", selfCollision="1")
    concatenation.addObject('UniformMass', vertexMass="1")
    concatenation.addObject('ConstantForceField', indices="0", forces="1 0 0")