Ejemplo n.º 1
0
def setup():
    global DTMPythonFilter
    DTMPythonFilter = smp.ProgrammableFilter()
    with open(Script_file, 'r') as f:
        Script_src = f.read()
    DTMPythonFilter.Script = Script_src
    DTMPythonFilter.PythonPath = "\"{}\"".format(thisModuleDir)
Ejemplo n.º 2
0
def runTest():

    options = servermanager.vtkProcessModule.GetProcessModule().GetOptions()
    url = options.GetServerURL()

    smp.Connect(getHost(url), getPort(url))

    sphere = smp.Sphere()

    f = smp.ProgrammableFilter(sphere)

    # test that vtk is imported automatically and contains the name vtkPolyData
    script = 'assert vtk.vtkPolyData'
    assert testScript(f, script)

    # test that variables can be passed using the Parameters property
    script = 'assert foo == "bar"'
    f.SetPropertyWithName('Parameters', ['foo', '"bar"'])
    assert testScript(f, script)

    smp.Disconnect()
Ejemplo n.º 3
0
  output.ShallowCopy(A)
  for array in Arrays: output.GetPointData().AddArray(array)

else:
  print "[ERROR] Output Data Set Type must be chosen!!"
#--------------------------------------------------------------------------||--#
#--------------------------------------------------------------------------||--#
"""

#------------------------------------------------------------------------------#
#
#VTU = Simple.OpenDataFile("../MESHES/Mesh01.vtu")
#Simple.Show(VTU)
#Simple.SetActiveSource(VTU)
#
PF = Simple.ProgrammableFilter()
PF.Script = Script03
PF.OutputDataSetType = "vtkUnstructuredGrid"
Simple.Show(PF)
#
#Writer = Simple.CreateWriter("xxx.vtu", PF)
#Writer.UpdatePipeline()
#
import os

print "Directory: \'%s\'" % os.getcwd()
print "OK!\n"
#------------------------------------------------------------------------------#
#------------------------------------------------------------------------------#
Ejemplo n.º 4
0
# get and check active source
source = ps.GetActiveSource()
if source is None:
    raise WrongInput('No source selected.')
info = source.GetDataInformation().DataInformation
if info is None:
    raise WrongInput('Source has no information, uncomplete.')
composite_class = info.GetCompositeDataClassName()
if composite_class is None or not composite_class == 'vtkMultiBlockDataSet':
    raise WrongInput(
        'Source produce wrong type of data. MultiBlockDataSet required.')

# make a filter to collect all well lines in order
# to workaround a bug that do not porduce selsection labels
# on composite datasets
merged = ps.ProgrammableFilter()
merged.Script = merge_groups_script
merged.OutputDataSetType = 0  # PolyData
merged.Input = source

# update pipeline in order to get total number of points
ps.SetActiveSource(merged)
ps.UpdatePipeline()

# make selection where to show labels
n_points = merged.GetDataInformation().DataInformation.GetNumberOfPoints()
selection = ps.IDSelectionSource()
IDs = []
for i in range(n_points):
    # select only non-head points
    IDs.append(0L)
        passedArray = vtk.vtkIntArray()
        passedArray.SetName('%s')
        self.GetOutput().GetFieldData().AddArray(passedArray)''' % arrayName)

    programmableFilter.UpdatePipeline()
    return programmableFilter.GetClientSideObject().GetOutput().GetFieldData(
    ).GetArray(arrayName) is not None


SMPythonTesting.ProcessCommandLineArguments()
tempDir = SMPythonTesting.TempDir
stateDir = SMPythonTesting.SMStatesDir

sphere = smp.Sphere()

f = smp.ProgrammableFilter(sphere)

script = '''
assert 1+1 == 2
'''

assert testScript(f, script)

script = '''
assert foo == 'bar'
'''

f.SetPropertyWithName('Parameters', ['foo', '"bar"'])

assert testScript(f, script)