Beispiel #1
0
def bowl(pos):
    b = pouf.rigid.Body('bowl')
    b.collision = Sofa.src_dir() + '/share/mesh/SaladBowl.obj'
    b.mass_from_mesh( b.collision )
    b.dofs.translation = pos
    b.dofs.rotation = pouf.quat.exp( [-math.pi / 2, 0, 0] )
    b.scale = [1, 1, 1]
    return b
Beispiel #2
0
import Sofa
import SofaTest

flexible_path = Sofa.src_dir() + '/applications/plugins/Flexible'
mesh_path = flexible_path+ '/examples/beam/'

##Check if calling Mapping::init() change anything
#
#The trick is to know that if the option evaluateShapeFunction is activated
#in the ImageGaussPointSampler then a sampler::bwdInit() must be called
#to update weights using gauss points.
class Controller(SofaTest.Controller):
    def initGraph(self,node):
        self.success = 1
        self.count = 0
        return 0

    def createGraph(self,node):
        self.node = node
        return 0

    def initAndCheckMapping(self, node):
        mapping = node

        oldWeights = mapping.findData("weights").value
        oldWeightGradients = mapping.findData("weightGradients").value
        oldWeightHessians = mapping.findData("weightHessians").value

        mapping.init()

        newWeights = mapping.findData("weights").value
Beispiel #3
0
import Sofa

# TODO handle this more cleanly, i.e. standardize plugins python
# directory, then use something like Sofa.add_plugin_path('Compliant')

import sys
sys.path.append( Sofa.src_dir() + '/applications/plugins/Compliant/python' )

from Compliant import Rigid


def createScene(root):
    root.createObject('RequiredPlugin', pluginName = 'Compliant')
    root.createObject('VisualStyle', displayFlags="showBehavior" )
    
    root.dt = 0.001
    root.gravity = [0, -9.8, 0]
    
    ode = root.createObject('AssembledSolver')
    ode.stabilization = True
    
    num = root.createObject('MinresSolver')
    num.iterations = 500
    
    scene = root.createChild('scene')
    
    base = Rigid.Body('base')
    moving = Rigid.Body('moving')

    moving.dofs.translation = [0, 2, 0]
Beispiel #4
0
# importing this takes care of adding compliant python path to
# sys.path. you might want to symlink this file next to your actual
# scene files. this will become unnecessary in the future.

import Sofa
import sys

path = Sofa.src_dir() + '/applications/plugins/Compliant/python' 
# TODO avoid doing this twice ?
sys.path.append(path)



Beispiel #5
0
import Sofa

import sys
sys.path.append(Sofa.src_dir() + '/applications/plugins/Compliant/python')
from Compliant import Rigid

colladasceneloader_path = Sofa.src_dir(
) + '/applications/plugins/ColladaSceneLoader'
mesh_path = colladasceneloader_path + '/Demos/'

scale = 1

clothSelfCollision = 1


def createScene(root):

    # simulation parameters
    root.dt = 0.02
    root.gravity = [0, -9.81, 0]

    # plugins
    root.createObject('RequiredPlugin', name='Flexible', pluginName='Flexible')
    root.createObject('RequiredPlugin',
                      name='Compliant',
                      pluginName='Compliant')
    root.createObject('RequiredPlugin',
                      name='ColladaSceneLoader',
                      pluginName='ColladaSceneLoader')

    # visual style
Beispiel #6
0
import Sofa
import math

# TODO ease this nonsense, upstream in SofaPython
compliant_path = Sofa.src_dir() + '/applications/plugins/Compliant'
import sys
sys.path.append(compliant_path + '/python')

from Compliant import Rigid

# global structure for passing data to controller
class ControlData:
     pass

global control

control = ControlData


def createScene(node):
     node.createObject('RequiredPlugin', pluginName = 'Compliant')

     node.animate = 'true'

     node.createObject('VisualStyle', displayFlags='hideBehaviorModels hideCollisionModels hideMappings hideForceFields')
     node.dt = 0.005
     
     node.gravity = '0 -9.81 0'
     
     ode = node.createObject('AssembledSolver',
                             name='odesolver' )
Beispiel #7
0
import Sofa

from Compliant import Rigid

colladasceneloader_path = Sofa.src_dir() + '/applications/plugins/ColladaSceneLoader'
mesh_path = colladasceneloader_path + '/Demos/'

scale = 1

clothSelfCollision = 1



def createScene(root):

    # simulation parameters
    root.dt = 0.02
    root.gravity = [0, -9.81, 0]
        
    # plugins
    root.createObject('RequiredPlugin', name='Flexible', pluginName='Flexible')
    root.createObject('RequiredPlugin', name='Compliant', pluginName='Compliant')
    root.createObject('RequiredPlugin', name='ColladaSceneLoader', pluginName='ColladaSceneLoader')
    
    # visual style
    root.createObject('VisualStyle', displayFlags='showBehaviorModels')
    
    # scene node
    scene = root.createChild('scene')

    scene.createObject('DefaultPipeline', depth='6')
import Sofa

import sys
sys.path.append( Sofa.src_dir() + '/applications/plugins/Compliant/python' )
from Compliant import Rigid

colladasceneloader_path = Sofa.src_dir() + '/applications/plugins/ColladaSceneLoader'
mesh_path = colladasceneloader_path + '/Demos/'

scale = 1

clothSelfCollision = 1



def createScene(root):

    # simulation parameters
    root.dt = 0.02
    root.gravity = [0, -9.81, 0]
        
    # plugins
    root.createObject('RequiredPlugin', name='Flexible', pluginName='Flexible')
    root.createObject('RequiredPlugin', name='Compliant', pluginName='Compliant')
    root.createObject('RequiredPlugin', name='ColladaSceneLoader', pluginName='ColladaSceneLoader')
    
    # visual style
    root.createObject('VisualStyle', displayFlags='showBehaviorModels')
    
    # scene node
    scene = root.createChild('scene')
Beispiel #9
0
import os
import os.path
import sys
import Sofa


# add plugin path to sys.path
plugins_paths = ["applications/plugins", "applications-dev/plugins"]

for relative in plugins_paths:
    absolute = os.path.join(Sofa.src_dir(), relative)

    for plugin in os.listdir(absolute):
        path = os.path.join(absolute, plugin)

        if os.path.isdir(path):
            python = os.path.join(path, "python")

            if os.path.exists(python):
                print "SofaPython: added plugin path for", plugin
                sys.path.append(python)

# add more customization here if needed
Beispiel #10
0
import os
import os.path
import sys
import Sofa


# add plugin path to sys.path
plugins_paths = ['applications/plugins',
                 'applications-dev/plugins']

for relative in plugins_paths:
        absolute = os.path.join(Sofa.src_dir(), relative)
        
        if os.path.exists(absolute): # applications-dev is not necessarily existing
        
		for plugin in os.listdir( absolute ):
			path = os.path.join(absolute, plugin)
			
			if os.path.isdir( path ):
				python = os.path.join(path, 'python')

				if os.path.exists( python ):
					print "SofaPython: added plugin path for", plugin
					sys.path.append( python )

# add more customization here if needed