Пример #1
0
def runTest():
    options = servermanager.vtkRemotingCoreConfiguration.GetInstance()
    url = options.GetServerURL()
    smp.Connect(getHost(url), getPort(url))

    r = smp.CreateRenderView()
    r.RemoteRenderThreshold = 20
    s = smp.Sphere()
    s.PhiResolution = 80
    s.ThetaResolution = 80

    d = smp.Show()
    d.Representation = "Wireframe"
    smp.Render()
    r.RemoteRenderThreshold = 0
    smp.Render()
    s.PhiResolution = 8
    s.ThetaResolution = 8
    smp.Render()

    smtesting.ProcessCommandLineArguments()
    if not smtesting.DoRegressionTesting(r.SMProxy):
        raise smtesting.TestError ("Test failed!!!")
    print ("Test Passed")
Пример #2
0
from paraview.simple import *
import sys
from paraview import smtesting

smtesting.ProcessCommandLineArguments()
reader = ExodusIIReader(FileName=smtesting.DataDir+'/can.ex2')

if len(reader.TimestepValues) != 44:
    raise smtesting.TestError('Wrong amount of time steps.')

if reader.TimestepValues[0] != 0.0 or reader.TimestepValues[-1] != 0.004299988504499197:
    raise smtesting.TestError('Wrong time step value.')

fields = reader.PointVariables

if 'DISPL' not in fields:
    raise smtesting.TestError('DISPL not available.')

if 'VEL' not in fields:
    raise smtesting.TestError('VEL not available.')

if 'ACCL' not in fields:
    raise smtesting.TestError('ACCL not available.')

fields = reader.PointVariables.Available

if 'DISPL' not in fields:
    raise smtesting.TestError('DISPL not available.')

if 'VEL' not in fields:
    raise smtesting.TestError('VEL not available.')
Пример #3
0
import os.path
from paraview.simple import *
import sys
from paraview import smtesting

servermanager.ToggleProgressPrinting()

hasnumpy = True
try:
    from numpy import *
except ImportError:
    hasnumpy = False

if not hasnumpy:
    raise smtesting.TestError("NumPy library is not found")


# This function prints an array of scalars/vectors/tensors for display. Since
# it will be called with a loop, it offers the option to display the entire
# array or just the first few tuples. This is mainly used for debug.
def print_array(vtkarray, verbose=0):
    ntuples = min(3, vtkarray.GetNumberOfTuples())
    if verbose: ntuples = max(3, vtkarray.GetNumberOfTuples())

    ncomps = min(6, vtkarray.GetNumberOfComponents())
    if verbose: ncomps = max(6, vtkarray.GetNumberOfComponents())

    for i in range(ntuples):
        for j in range(ncomps):
            print "%+12.6f" % vtkarray.GetComponent(i, j),
            sys.stdout.flush()
Пример #4
0
    del painter
del rw

if ok:
    smtesting.ProcessCommandLineArguments()

    LoadDistributedPlugin('SurfaceLIC', True, globals())

    smtesting.LoadServerManagerState(smtesting.StateXMLFileName)

    view = GetRenderView()
    view.RemoteRenderThreshold = 0

    if saveImage:
        SetActiveView(view)
        Render()
        imageFile = os.path.splitext(
            os.path.basename(smtesting.StateXMLFileName))[0]
        WriteImage('%s/../../%s.png' % (smtesting.TempDir, imageFile))

    if not smtesting.DoRegressionTesting(view.SMProxy):
        raise smtesting.TestError('Test failed.')

    print()
    print('Test passes')

else:
    print('Skipped untested.')

print()
opacityTransferFunction = simple.CreatePiecewiseFunction(
    Points=[0.0, 0.2, 0.5, 0.0, NUM_POINTS - 1, 1.0, 0.5, 0.0])
rep.OpacityTransferFunction = opacityTransferFunction
rep.OpacityArray = 'Inverse Distance'
rep.OpacityByArray = 1

# Now set a custom shader snippet
rep.CustomShader = '''
//VTK::Color::Impl
float dist = dot(offsetVCVSOutput.xy,offsetVCVSOutput.xy);
if (dist > 9.0) {
  discard;
}
'''
rep.CustomTriangleScale = 3
rep.ShaderPreset = "Custom"

# Now render, configure the view, and re-render
renderView = simple.Render()

renderView.CenterOfRotation = [(NUM_POINTS - 1) / 2.0, 0, 0]
renderView.CameraPosition = [(NUM_POINTS - 1) / 2.0, 0, NUM_POINTS * 2]
renderView.CameraFocalPoint = [(NUM_POINTS - 1) / 2.0, 0, 0]
renderView.CameraViewAngle = 30.0
renderView.CameraParallelProjection = 0

simple.Render(renderView)

if not smtesting.DoRegressionTesting(renderView.SMProxy):
    raise smtesting.TestError('Image comparison failed.')
Пример #6
0
from paraview.simple import *
import sys
from paraview import smtesting

sphere = Sphere()
sphere.PhiResolution = 20
sphere.ThetaResolution = 20

clientsphere = servermanager.Fetch(sphere)
if clientsphere.GetNumberOfPolys() != 720:
    raise smtesting.TestError('Test failed: Problem fetching polydata.')

elev = Elevation(sphere)
mm = servermanager.filters.MinMax()
mm.Operation = "MIN"

mindata = servermanager.Fetch(elev, mm, mm)

if mindata.GetPointData().GetNumberOfArrays() != 2:
    raise smtesting.TestError('Test failed: Wrong number of arrays.')

array = mindata.GetPointData().GetArray('Elevation')
print("%d %f" % (array.GetNumberOfTuples(), array.GetTuple1(0)))

if array.GetTuple1(0) < 0.2 and array.GetTuple1(0) > 0.29:
    raise smtesting.TestError('Test failed: Bad array value.')

rep = Show(elev)
ai = elev.PointData[1]
if ai.GetName() != 'Elevation':
    pd = elev.GetPointDataInformation()
# This test varifies that gathering rank specific information works
# as expected. It's designed to run on 5 ranks.

from paraview.simple import *
from paraview import smtesting

pm = servermanager.vtkProcessModule.GetProcessModule()
if pm.GetNumberOfLocalPartitions() != 5:
    raise smtesting.TestError("Test must be run on 5 ranks!")
if pm.GetSymmetricMPIMode():
    raise smtesting.TestError("Test cannot be run in symmetric mode!")

s = Sphere()
s.UpdatePipeline()

bds = s.GetRankDataInformation(0).GetBounds()
strBds = "({:1.1f}, {:1.1f}, {:1.1f}, {:1.1f}, {:1.1f}, {:1.1f})".format(
    bds[0], bds[1], bds[2], bds[3], bds[4], bds[5])
print("rank 0: ", strBds)
assert "(0.0, 0.5, 0.0, 0.3, -0.5, 0.5)" == strBds

bds = s.GetRankDataInformation(3).GetBounds()
strBds = "({:1.1f}, {:1.1f}, {:1.1f}, {:1.1f}, {:1.1f}, {:1.1f})".format(
    bds[0], bds[1], bds[2], bds[3], bds[4], bds[5])
print("rank 3: ", strBds)
assert "(-0.5, 0.0, -0.5, 0.0, -0.5, 0.5)" == strBds
Пример #8
0
from paraview.simple import *
import sys
from paraview import smtesting

resolution = 15
cone = Cone(Resolution=resolution)
if cone.Resolution != resolution:
    raise smtesting.TestError(
        'Test failed: Resolution has not been set properly.')

resolution = 12
cone.Resolution = resolution
if cone.Resolution != resolution:
    raise smtesting.TestError('Test failed: Problem changing resolution.')

cone.Center = [3.1, 4.2, 5.5]
if cone.Center[0] != 3.1 or cone.Center[1] != 4.2 or cone.Center[2] != 5.5:
    raise smtesting.TestError('Test failed: Problem setting center of cone.')

shrinkFilter = Shrink(cone)
if shrinkFilter.Input.GetAddressAsString('') != cone.GetAddressAsString(''):
    raise smtesting.TestError('Test failed: Pipeline not properly set.')

shrinkFilter.UpdatePipeline()
if shrinkFilter.GetDataInformation().GetNumberOfCells(
) != resolution + 1 or shrinkFilter.GetDataInformation().GetNumberOfPoints(
) != resolution * 4:
    raise smtesting.TestError('Test failed: Pipeline not operating properly.')

resolution = 33
rp = cone.GetProperty("Resolution")
Пример #9
0
r = Show(s)
r.ColorArrayName = 'RTData'
r.Representation = 'Surface'

v = GetRenderView()
v.CameraViewUp = [0, 1, 0]
v.CameraPosition = [-32, 32, 60]
v.CameraClippingRange = [33, 110]
v.UseGradientBackground = 1
v.Background2 = [0.0, 0.0, 0.16471]
v.Background = [0.3216, 0.3412, 0.4314]
v.CenterAxesVisibility = 0

# verify default laoding
if len(GetLookupTableNames()) < 1:
    raise smtesting.TestError('Failed to load the default LUTs.')

# exercsie the simple loader
if not LoadLookupTable(lutfile):
    raise smtesting.TestError('Failed to load the testlut file.')

names = GetLookupTableNames()
if 'testlut' not in names:
    raise smtesting.TestError('Failed to parse the testlut lut.')

# exercise simple assignment
print
print 'Rendering with %d LUTs' % (len(names))
print 'The available LUTs are:'
print names
print