-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathSingleBeamDeployment.py
More file actions
68 lines (53 loc) · 3.83 KB
/
SingleBeamDeployment.py
File metadata and controls
68 lines (53 loc) · 3.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import sys
import Sofa
def createScene(rootNode):
rootNode.addObject('RequiredPlugin', pluginName='BeamAdapter Sofa.Component.Constraint.Projective Sofa.Component.LinearSolver.Direct Sofa.Component.ODESolver.Backward Sofa.Component.StateContainer Sofa.Component.Topology.Container.Constant Sofa.Component.Topology.Container.Grid Sofa.Component.Visual Sofa.Component.SolidMechanics.Spring Sofa.Component.Topology.Container.Dynamic')
rootNode.addObject('VisualStyle', displayFlags='showVisualModels showBehaviorModels showCollisionModels hideMappings showForceFields')
rootNode.addObject('DefaultAnimationLoop')
rootNode.addObject('DefaultVisualManagerLoop')
topoLines = rootNode.addChild('EdgeTopology')
topoLines.addObject('RodStraightSection', name='StraightSection',
length=980.0, radius=0.9,
nbEdgesCollis=30, nbEdgesVisu=196,
youngModulus=20000)
topoLines.addObject('RodSpireSection', name='SpireSection',
length=20.0, radius=0.9,
nbEdgesCollis=5, nbEdgesVisu=4,
spireDiameter=25, spireHeight=0,
youngModulus=20000)
topoLines.addObject('WireRestShape', name='BeamRestShape', template="Rigid3d",
wireMaterials="@StraightSection @SpireSection")
topoLines.addObject('EdgeSetTopologyContainer', name='meshLinesBeam')
topoLines.addObject('EdgeSetTopologyModifier', name='Modifier')
topoLines.addObject('EdgeSetGeometryAlgorithms', name='GeomAlgo', template='Rigid3d')
topoLines.addObject('MechanicalObject', name='dofTopo2', template='Rigid3d')
BeamMechanics = rootNode.addChild('BeamModel', bbox="0 0 0 10 10 10")
BeamMechanics.addObject('EulerImplicitSolver', rayleighStiffness=0.2, printLog=False, rayleighMass=0.1)
BeamMechanics.addObject('BTDLinearSolver', verification=False, subpartSolve=False, verbose=False)
BeamMechanics.addObject('RegularGridTopology', name='MeshLines', drawEdges=True,
nx=60, ny=1, nz=1,
xmax=0.0, xmin=0.0, ymin=0, ymax=0, zmax=0, zmin=0,
p0=[0,0,0])
BeamMechanics.addObject('MechanicalObject', showIndices=False, name='DOFs Container', template='Rigid3d', ry=-90)
BeamMechanics.addObject('WireBeamInterpolation', name='BeamInterpolation', WireRestShape='@../EdgeTopology/BeamRestShape', printLog=False)
BeamMechanics.addObject('AdaptiveBeamForceFieldAndMass', name='BeamForceField', massDensity=0.00000155, interpolation='@BeamInterpolation')
BeamMechanics.addObject('InterventionalRadiologyController', name='DeployController', template='Rigid3d', instruments='BeamInterpolation',
startingPos=[0, 0, 0, 0, 0, 0, 1], xtip=[0, 0, 0], printLog=True,
rotationInstrument=[0, 0, 0], step=0.5, speed=0.5,
listening=True, controlledInstrument=0)
BeamMechanics.addObject('FixedProjectiveConstraint', indices=0, name='FixedConstraint')
BeamMechanics.addObject('FixedWeakConstraint', name="RestSPForceField", indices='@DeployController.indexFirstNode', angularStiffness=1e8, stiffness=1e8)
def main():
import SofaRuntime
import Sofa.Gui
root = Sofa.Core.Node('root')
createScene(root)
Sofa.Simulation.init(root)
Sofa.Gui.GUIManager.Init('myscene', 'qglviewer')
Sofa.Gui.GUIManager.createGUI(root, __file__)
Sofa.Gui.GUIManager.SetDimension(1080, 1080)
Sofa.Gui.GUIManager.MainLoop(root)
Sofa.Gui.GUIManager.closeGUI()
# Function used only if this script is called from a python environment
if __name__ == '__main__':
main()