Skip to content

AdaptiveBeamController

Adaptive beam controller.

Rigid3d

Templates:

  • Rigid3d

Target: BeamAdapter

namespace: beamadapter

parents:

  • MechanicalStateController

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
handleEventTriggersUpdate Event handling frequency controls the controller update frequency 0
index Index of the controlled DOF 0
onlyTranslation Controlling the DOF only in translation 0
buttonDeviceState state of ths device button 0
mainDirection Main direction and orientation of the controlled DOF 0 0 -1
interpolation Path to the Interpolation component on scene
controlledInstrument provide the id of the interventional radiology instrument which is under control: press contr + number to change it 0
xtip curvilinear abscissa of the tip of each interventional radiology instrument
rotationInstrument angle of rotation for each interventional radiology instrument
step base step when changing beam length 0.1
angularStep base step when changing beam angle 0.15708
speed continuous beam length increase/decrease 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

AdaptiveBeamController.scn

<?xml version="1.0"?>
<Node name="root" gravity="0 -9.81 0" dt="0.01" bbox="0 0 0 10 10 10">
    <RequiredPlugin name="Sofa.Component.Constraint.Projective"/> <!-- Needed to use components [FixedProjectiveConstraint] -->
    <RequiredPlugin name="Sofa.Component.LinearSolver.Direct"/> <!-- Needed to use components [EigenSparseLU] -->
    <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] -->
    <RequiredPlugin name="BeamAdapter"/> <!-- Needed to use components [AdaptiveBeamController,AdaptiveBeamForceFieldAndMass,BeamInterpolation] -->

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

    <Node name="AdaptiveBeam1">
        <EulerImplicitSolver rayleighStiffness="0" rayleighMass="0" printLog="false" />
        <EigenSparseLU template="CompressedRowSparseMatrixMat3x3d"/>
        <MechanicalObject template="Rigid3d" name="DOFs" position="0 0 0 0 0 0 1  0.5 0 0 0 0 0 1  1 0 0 0 0 0 1  1.5 0 0 0 0 0 1  2 0 0 0 0 0 1  2.5 0 0 0 0 0 1  3 0 0 0 0 0 1"/> 
        <MeshTopology name="lines" lines="0 1 1 2 2 3 3 4 4 5 5 6" /> 
        <FixedProjectiveConstraint name="FixedConstraint" indices="0" />
        <BeamInterpolation name="BeamInterpolation" radius="0.1"/> 
        <AdaptiveBeamForceFieldAndMass name="BeamForceField"   computeMass="1" massDensity="50"/> 
<!--
        <Node name="Collision">
            <CubeTopology nx="13" ny="2" nz="2" min="0 -0.2 -0.2" max="3 0.2 0.2" />
            <MechanicalObject name="collision"/>
            <AdaptiveBeamMapping isMechanical="true" input="@../DOFs" output="@collision"/>
            <Triangle />
        </Node>
-->
    </Node>

    <Node name="AdaptiveBeam2">
        <EulerImplicitSolver rayleighStiffness="0" rayleighMass="0" printLog="false" />
        <EigenSparseLU template="CompressedRowSparseMatrixMat3x3d"/>
        <MeshTopology name="lines" lines="0 1 1 2 2 3" /> 
        <MechanicalObject template="Rigid3d" name="DOFs" position="0 0 2 0 0 0 1  1 0 2 0 0 0 1  2 0 2 0 0 0 1  3 0 2 0 0 0 1"/> 
        <BeamInterpolation name="BeamInterpolation2" radius="0.1" /> 
        <FixedProjectiveConstraint name="FixedConstraint" indices="0" />
        <AdaptiveBeamController template="Rigid3d" name="m_controller"/>    
        <AdaptiveBeamForceFieldAndMass name="BeamForceField"  computeMass="1" massDensity="50"/> 
<!--
        <Node name="Collision">
            <CubeTopology nx="13" ny="2" nz="2" min="0 -0.2 -0.2" max="3 0.2 0.2" />
            <MechanicalObject name="collision"/>
            <AdaptiveBeamMapping isMechanical="true" input="@../DOFs" output="@collision"/>
            <Triangle />
        </Node>
-->
    </Node>
</Node>
def createScene(root_node):

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

   root.addObject('RequiredPlugin', name="Sofa.Component.Constraint.Projective")
   root.addObject('RequiredPlugin', name="Sofa.Component.LinearSolver.Direct")
   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('RequiredPlugin', name="BeamAdapter")
   root.addObject('VisualStyle', displayFlags="showBehaviorModels showCollisionModels hideBoundingCollisionModels showForceFields")
   root.addObject('DefaultAnimationLoop', )

   adaptive_beam1 = root.addChild('AdaptiveBeam1')

   adaptive_beam1.addObject('EulerImplicitSolver', rayleighStiffness="0", rayleighMass="0", printLog="false")
   adaptive_beam1.addObject('EigenSparseLU', template="CompressedRowSparseMatrixMat3x3d")
   adaptive_beam1.addObject('MechanicalObject', template="Rigid3d", name="DOFs", position="0 0 0 0 0 0 1  0.5 0 0 0 0 0 1  1 0 0 0 0 0 1  1.5 0 0 0 0 0 1  2 0 0 0 0 0 1  2.5 0 0 0 0 0 1  3 0 0 0 0 0 1")
   adaptive_beam1.addObject('MeshTopology', name="lines", lines="0 1 1 2 2 3 3 4 4 5 5 6")
   adaptive_beam1.addObject('FixedProjectiveConstraint', name="FixedConstraint", indices="0")
   adaptive_beam1.addObject('BeamInterpolation', name="BeamInterpolation", radius="0.1")
   adaptive_beam1.addObject('AdaptiveBeamForceFieldAndMass', name="BeamForceField", computeMass="1", massDensity="50")

   adaptive_beam2 = root.addChild('AdaptiveBeam2')

   adaptive_beam2.addObject('EulerImplicitSolver', rayleighStiffness="0", rayleighMass="0", printLog="false")
   adaptive_beam2.addObject('EigenSparseLU', template="CompressedRowSparseMatrixMat3x3d")
   adaptive_beam2.addObject('MeshTopology', name="lines", lines="0 1 1 2 2 3")
   adaptive_beam2.addObject('MechanicalObject', template="Rigid3d", name="DOFs", position="0 0 2 0 0 0 1  1 0 2 0 0 0 1  2 0 2 0 0 0 1  3 0 2 0 0 0 1")
   adaptive_beam2.addObject('BeamInterpolation', name="BeamInterpolation2", radius="0.1")
   adaptive_beam2.addObject('FixedProjectiveConstraint', name="FixedConstraint", indices="0")
   adaptive_beam2.addObject('AdaptiveBeamController', template="Rigid3d", name="m_controller")
   adaptive_beam2.addObject('AdaptiveBeamForceFieldAndMass', name="BeamForceField", computeMass="1", massDensity="50")