mirror of
https://github.com/OpenFOAM/ThirdParty-6.git
synced 2025-12-08 06:57:43 +00:00
43 lines
974 B
Python
43 lines
974 B
Python
# Set up a basic scene for rendering.
|
|
from paraview.simple import *
|
|
import sys
|
|
|
|
script = """
|
|
import numpy
|
|
import paraview.numpy_support
|
|
|
|
def setup_data(view):
|
|
# Don't actually need any data
|
|
pass
|
|
|
|
def render(view, width, height):
|
|
cb = numpy.zeros((height, width, 4), dtype=numpy.uint8)
|
|
for i in xrange(width):
|
|
cb[:,i,0] = i%255
|
|
|
|
for i in xrange(height):
|
|
cb[i,:,1] = i%255
|
|
|
|
from paraview.python_view import numpy_to_image
|
|
|
|
return numpy_to_image(cb)
|
|
"""
|
|
|
|
view = CreateView("PythonView")
|
|
view.Script = script
|
|
|
|
Render()
|
|
|
|
try:
|
|
baselineIndex = sys.argv.index('-B')+1
|
|
baselinePath = sys.argv[baselineIndex]
|
|
except:
|
|
print "Could not get baseline directory. Test failed."
|
|
|
|
import os
|
|
baseline_file = os.path.join(baselinePath, "TestPythonViewNumpyScript.png")
|
|
import vtk.test.Testing
|
|
vtk.test.Testing.VTK_TEMP_DIR = vtk.util.misc.vtkGetTempDir()
|
|
vtk.test.Testing.compareImage(view.GetRenderWindow(), baseline_file, threshold=25)
|
|
vtk.test.Testing.interact()
|