Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Sofa
- import os
- meshPath = os.path.dirname(os.path.abspath(__file__))+'/mesh/'
- def createScene(rootNode):
- rootNode.createObject('RequiredPlugin', name='ModelOrderReduction', pluginName='ModelOrderReduction')
- rootNode.createObject('RequiredPlugin', name='SofaPython', pluginName='SofaPython')
- rootNode.createObject('VisualStyle', displayFlags='showCollision showVisualModels showForceFields showInteractionForceFields hideCollisionModels hideBoundingCollisionModels hideWireframe')
- rootNode.findData('dt').value=0.01
- rootNode.findData('gravity').value=[0, -981, 0]
- rootNode.createObject('FreeMotionAnimationLoop')
- rootNode.createObject('GenericConstraintSolver', tolerance="1e-12", maxIterations="10000")
- liver = rootNode.createChild('liver')
- liver.createObject('EulerImplicitSolver', rayleighStiffness = 0.0, rayleighMass = 0.0)
- liver.createObject('SparseLDLSolver', saveMatrixToFile='False', name='preconditioner')
- liver.createObject('MeshVTKLoader', name="loader", filename=meshPath+'liverFine.vtu')
- liver.createObject('TetrahedronSetTopologyContainer', src="@loader")
- liver.createObject('TetrahedronSetGeometryAlgorithms')
- liver.createObject('MechanicalObject')
- liver.createObject('BoxROI', name='ROI1', box='0 3 -1 2 5 2', drawBoxes='true')
- liver.createObject('BoxROI', name='boxROIactuation', box='-5 0 -0.5 -4 0.5 0.5', drawBoxes='true')
- liver.createObject('UniformMass', totalMass=0.3)
- liver.createObject('TetrahedronFEMForceField', poissonRatio="0.3", youngModulus="5000")
- liver.createObject('GenericConstraintCorrection', solverName='preconditioner')
- liver.createObject('RestShapeSpringsForceField', points='@ROI1.indices', stiffness = '1e8')
- liver.createObject('RestShapeSpringsForceField' , external_points = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], points = '@boxROIactuation.indices', name = 'actuatorSpring', stiffness = '1e8', external_rest_shape = '@actuator/actuatorState')
- visu = liver.createChild('visu')
- visu.createObject( 'MeshObjLoader', name= 'loader', filename=meshPath+'liver-smoothUV.obj')
- visu.createObject('OglModel', src="@loader")
- visu.createObject('BarycentricMapping')
- actuator = rootNode.createChild('actuator')
- actuator.createObject('MechanicalObject', name = 'actuatorState', position = '@../liver/boxROIactuation.pointsInROI', free_velocity = '@../liver/boxROIactuation.pointsInROI', template = 'Vec3d')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement