Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
"""
TtestPython
is based on the scene
/home/zahra/sofa/Work/test/Ttest.scn
but it uses the SofaPython plugin.
Further informations on the usage of the plugin can be found in
sofa/applications/plugins/SofaPython/doc/SofaPython.pdf
To lance the scene, type
runSofa /home/zahra/sofa/Work/test/TtestPython.scn
The current file has been written by the python script
/home/zahra/sofa/Sofa17.06/src/applications/plugins/SofaPython/scn2python.py
Author of scn2python.py: Christoph PAULUS, christoph.paulus@inria.fr
"""
import Sofa
class Ttest (Sofa.PythonScriptController):
def createGraph(self,rootNode):
# rootNode
rootNode.createObject('DefaultPipeline', name='CollisionPipeline', verbose='0')
rootNode.createObject('BruteForceDetection', name='N2')
rootNode.createObject('DefaultContactManager', name='collision response', response='default')
rootNode.createObject('DiscreteIntersection', name='discreteIntersection1')
# rootNode/Liver
Liver = rootNode.createChild('Liver')
Liver.depend = 'topo dofs'
Liver.createObject('EulerImplicitSolver', name='cg_odesolver', printLog='0')
Liver.createObject('CGLinearSolver', threshold='1e-09', tolerance='1e-09', name='linear solver', iterations='25', template='GraphScattered')
Liver.createObject('MeshGmshLoader', tetrahedraGroups=' -1 0 38144', name='loader', filename='/home/zahra/sofa/Work/testbygmsh/livertetra7509.msh')
Liver.createObject('TetrahedronSetTopologyContainer', triangles='@loader.triangles', position='@loader.position', edges='@loader.edges', name='topo', tetrahedra='@loader.tetras')
Liver.createObject('MechanicalObject', force='0 0 0', name='dofs', template='Vec3d', position='@loader.position', velocity='0 0 0', externalForce='0 0 0', restScale='1')
Liver.createObject('TetrahedronSetGeometryAlgorithms', drawColorEdges='0.4 1 0.298039 1', showIndicesScale='0.01', name='GeomAlgo', showPointIndices='0', template='Vec3d')
Liver.createObject('DiagonalMass', massDensity='1', name='computed using mass density', template='Vec3d')
Liver.createObject('TetrahedralCorotationalFEMForceField', poissonRatio='0.3', name='FEM', computeGlobalMatrix='0', method='large', template='Vec3d', youngModulus='12000')
Liver.createObject('PlaneForceField', name='planeFF0', template='Vec3d', normal='0 1 0')
Liver.createObject('ConstantForceField', indices='111', name='constantFF0', template='Vec3d', forces='0 -120 0')
Liver.createObject('FixedConstraint', indices='11 17 16 15 14 4 3 0 45 95 42 40 38 39 53 62 61 60 4 63 59 125 24 20 19 9', drawSize='0', name='fixedConstraint0', template='Vec3d')
Liver.createObject('MeshExporter', exportEveryNumberOfSteps='1', quads='0', name='meshExporter3', format='gmsh', exportAtEnd='1', filename='/home/zahra/sofa/Work/Exported/Fine/LiverFine_111_0_-120_0', exportAtBegin='1', hexas='0', edges='0', listening='0', triangles='0')
Liver.createObject('TetrahedronSetTopologyModifier', name='tetrahedronSetTopologyModifier9')
Liver.createObject('TetrahedronSetTopologyAlgorithms', name='tetrahedronSetTopologyAlgorithms10', template='Vec3d')
# rootNode/Liver/Visu-fine
Visu_fine = Liver.createChild('Visu-fine')
Visu_fine.createObject('OglModel', sfactor='GL_SRC_ALPHA', blendEquation='GL_FUNC_ADD', name='oglModel0', template='ExtVec3f', dfactor='GL_ONE_MINUS_SRC_ALPHA', material='Default Diffuse 1 0.666667 0 0 1 Ambient 1 0.2 0.2 0.2 1 Specular 0 1 1 1 1 Emissive 0 0 0 0 0 Shininess 0 45 ', primitiveType='DEFAULT')
Visu_fine.createObject('IdentityMapping', input='@../', name='identityMap1', template='Vec3d,ExtVec3f', output='@./')
# rootNode/Liver/coarse
coarse = Liver.createChild('coarse')
coarse.createObject('MeshGmshLoader', tetrahedraGroups=' -1 0 596', name='meshGmshLoader1', filename='/home/zahra/sofa/Work/testbygmsh/livertetra181.gmsh')
coarse.createObject('TetrahedronSetTopologyContainer', triangles='@meshGmshLoader1.triangles', position='@meshGmshLoader1.position', edges='@meshGmshLoader1.edges', name='tetrahedronSetTopologyContainer2', tetrahedra='@meshGmshLoader1.tetras')
coarse.createObject('MechanicalObject', force='0 0 0', name='mObject0', template='Vec3d', position='@meshGmshLoader1.position', velocity='0 0 0', externalForce='0 0 0', restScale='1')
coarse.createObject('TetrahedronSetTopologyModifier', name='tetrahedronSetTopologyModifier3')
coarse.createObject('TetrahedronSetGeometryAlgorithms', drawColorEdges='0.4 1 0.298039 1', recomputeTrianglesOrientation='0', name='tetrahedronSetGeometryAlgorithms0', showPointIndices='1', flipNormals='1', showIndicesScale='0.01', template='Vec3d')
coarse.createObject('TetrahedronSetTopologyAlgorithms', name='tetrahedronSetTopologyAlgorithms1', template='Vec3d')
coarse.createObject('MeshExporter', exportEveryNumberOfSteps='1', quads='0', name='meshExporter13', format='gmsh', exportAtEnd='1', filename='/home/zahra/sofa/Work/Exported/Coarse/LiverCoarse_111_0_-120_0', exportAtBegin='1', hexas='0', edges='0', listening='0', triangles='0')
coarse.createObject('EulerImplicitSolver', name='eulerImplicitSolver0')
coarse.createObject('CGLinearSolver', name='cGLinearSolver1', template='GraphScattered')
coarse.createObject('DiagonalMass', name='diagonalMass2', template='Vec3d')
coarse.createObject('FixedConstraint', indices='0', name='fixedConstraint3', template='Vec3d')
coarse.createObject('PlaneForceField', name='planeFF4', template='Vec3d', normal='0 1 0')
coarse.createObject('TetrahedralCorotationalFEMForceField', youngModulus='12000', name='tetrahedralCorotationalFEMFF5', poissonRatio='0.3', template='Vec3d')
# rootNode/Liver/coarse/Visu-coarse
Visu_coarse = coarse.createChild('Visu-coarse')
Visu_coarse.createObject('OglModel', sfactor='GL_SRC_ALPHA', name='oglModel1', material='Default Diffuse 1 0 0 1 1 Ambient 1 0 0 0.2 1 Specular 0 0 0 1 1 Emissive 0 0 0 1 1 Shininess 0 45 ', primitiveType='DEFAULT', template='ExtVec3f', translation='0 0 0', dfactor='GL_ONE_MINUS_SRC_ALPHA', blendEquation='GL_FUNC_ADD')
Visu_coarse.createObject('IdentityMapping', input='@../', name='identityMap2', template='Vec3d,ExtVec3f', output='@./')
return 0;
def onKeyPressed(self, c):
return 0;
def onKeyReleased(self, c):
return 0;
def onLoaded(self, node):
return 0;
def onMouseButtonLeft(self, mouseX,mouseY,isPressed):
return 0;
def onMouseButtonRight(self, mouseX,mouseY,isPressed):
return 0;
def onMouseButtonMiddle(self, mouseX,mouseY,isPressed):
return 0;
def onMouseWheel(self, mouseX,mouseY,wheelDelta):
return 0;
def onGUIEvent(self, strControlID,valueName,strValue):
return 0;
def onBeginAnimationStep(self, deltaTime):
return 0;
def onEndAnimationStep(self, deltaTime):
return 0;
def onScriptEvent(self, senderNode, eventName,data):
return 0;
def initGraph(self, node):
return 0;
def bwdInitGraph(self, node):
return 0;
def storeResetState(self):
return 0;
def reset(self):
return 0;
def cleanup(self):
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.