Skip to content

ReadState

Read State vectors from file at each timestep.

Target: Sofa.Component.Playback

namespace: sofa::component::playback

parents:

  • BaseObject

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
filename output file name
interval time duration between inputs 0
shift shift between times in the file and times when they will be read 0
loop set to 'true' to re-read the file when reaching the end 0
Transformation
scalePos scale the input mechanical object 1
rotation rotate the input mechanical object 0 0 0
translation translate the input mechanical object 0 0 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

Examples

ReadState.scn

<?xml version="1.0"?>
<Node name="root" dt="0.01" gravity="0 0 -9.81">
    <Node name="plugins">
        <RequiredPlugin name="Sofa.Component.Playback"/> <!-- Needed to use components [ReadState] -->
        <RequiredPlugin name="Sofa.Component.StateContainer"/> <!-- Needed to use components [MechanicalObject] -->
        <RequiredPlugin name="Sofa.Component.Topology.Container.Dynamic"/> <!-- Needed to use components [EdgeSetGeometryAlgorithms,EdgeSetTopologyContainer,EdgeSetTopologyModifier] -->
        <RequiredPlugin name="Sofa.Component.Topology.Container.Grid"/> <!-- Needed to use components [RegularGridTopology] -->
        <RequiredPlugin name="Sofa.Component.Visual"/> <!-- Needed to use components [VisualStyle] -->
    </Node>
    <VisualStyle displayFlags="showForceFields showBehaviorModels showVisual showInteractionForceFields" />
    <DefaultAnimationLoop/>

    <!-- Beam animated by reading the state file -->
    <Node name="Beam">
        <MechanicalObject name="beamMO" showObject="1"/>
        <RegularGridTopology name="grid" nx="3" ny="3" nz="7" xmin="0" xmax="3" ymin="0" ymax="3" zmin="0" zmax="7" />
        <!-- Read the file: beamGravity.txt -->
        <!-- This file is generated by the example scene: WriteState.scn -->
        <ReadState name="StateReader" filename="beamGravity.txt.gz" />

        <Node name="visu">
            <EdgeSetTopologyContainer edges="@../grid.edges"/>
            <EdgeSetTopologyModifier />
            <EdgeSetGeometryAlgorithms template="Vec3" drawEdges="1"/>
        </Node>
    </Node>
</Node>
def createScene(root_node):

   root = root_node.addChild('root', dt="0.01", gravity="0 0 -9.81")

   plugins = root.addChild('plugins')

   plugins.addObject('RequiredPlugin', name="Sofa.Component.Playback")
   plugins.addObject('RequiredPlugin', name="Sofa.Component.StateContainer")
   plugins.addObject('RequiredPlugin', name="Sofa.Component.Topology.Container.Dynamic")
   plugins.addObject('RequiredPlugin', name="Sofa.Component.Topology.Container.Grid")
   plugins.addObject('RequiredPlugin', name="Sofa.Component.Visual")

   root.addObject('VisualStyle', displayFlags="showForceFields showBehaviorModels showVisual showInteractionForceFields")
   root.addObject('DefaultAnimationLoop', )

   beam = root.addChild('Beam')

   beam.addObject('MechanicalObject', name="beamMO", showObject="1")
   beam.addObject('RegularGridTopology', name="grid", nx="3", ny="3", nz="7", xmin="0", xmax="3", ymin="0", ymax="3", zmin="0", zmax="7")
   beam.addObject('ReadState', name="StateReader", filename="beamGravity.txt.gz")

   visu = Beam.addChild('visu')

   visu.addObject('EdgeSetTopologyContainer', edges="@../grid.edges")
   visu.addObject('EdgeSetTopologyModifier', )
   visu.addObject('EdgeSetGeometryAlgorithms', template="Vec3", drawEdges="1")