Commit 870d668f authored by David Gobbi's avatar David Gobbi Committed by Kitware Robot

Merge topic 'refactor_python'

6aba0c75 Refactor python wrapper misc.py
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: David Gobbi's avatarDavid Gobbi <david.gobbi@gmail.com>
Merge-request: !5026
parents 9e4cddf1 6aba0c75
......@@ -24,51 +24,44 @@ def calldata_type(type):
supported_call_data_types = ['string0', vtkCommonCore.VTK_STRING,
vtkCommonCore.VTK_OBJECT, vtkCommonCore.VTK_INT,
vtkCommonCore.VTK_LONG, vtkCommonCore.VTK_DOUBLE, vtkCommonCore.VTK_FLOAT]
if type not in supported_call_data_types:
raise TypeError("'%s' is not a supported VTK call data type. Supported types are: %s" % (type, supported_call_data_types))
def wrap(f):
f.CallDataType = type
return f
return wrap
#----------------------------------------------------------------------
# the following functions are for the vtk regression testing and examples
def vtkGetDataRoot():
"""vtkGetDataRoot() -- return vtk example data directory
"""
dataIndex=-1;
for i in range(0, len(sys.argv)):
if sys.argv[i] == '-D' and i < len(sys.argv)-1:
dataIndex = i+1
"""vtkGetDataRoot() -- return vtk example data directory"""
dataRoot = None
for i, argv in enumerate(sys.argv):
if argv == '-D' and i+1 < len(sys.argv):
dataRoot = sys.argv[i+1]
if dataIndex != -1:
dataRoot = sys.argv[dataIndex]
else:
try:
dataRoot = os.environ['VTK_DATA_ROOT']
except KeyError:
dataRoot = '../../../../VTKData'
if dataRoot is None:
dataRoot = os.environ.get('VTK_DATA_ROOT', '../../../../VTKData')
return dataRoot
def vtkGetTempDir():
"""vtkGetTempDir() -- return vtk testing temp dir
"""
tempIndex=-1;
for i in range(0, len(sys.argv)):
if sys.argv[i] == '-T' and i < len(sys.argv)-1:
tempIndex = i+1
"""vtkGetTempDir() -- return vtk testing temp dir"""
tempDir = None
for i, argv in enumerate(sys.argv):
if argv == '-T' and i+1 < len(sys.argv):
tempDir = sys.argv[i+1]
if tempIndex != -1:
tempDir = sys.argv[tempIndex]
else:
if tempDir is None:
tempDir = '.'
return tempDir
def vtkRegressionTestImage( renWin ):
def vtkRegressionTestImage(renWin):
"""vtkRegressionTestImage(renWin) -- produce regression image for window
This function writes out a regression .png file for a vtkWindow.
......@@ -78,20 +71,19 @@ def vtkRegressionTestImage( renWin ):
from vtkmodules.vtkIOImage import vtkPNGReader
from vtkmodules.vtkImagingCore import vtkImageDifference
imageIndex=-1;
for i in range(0, len(sys.argv)):
if sys.argv[i] == '-V' and i < len(sys.argv)-1:
imageIndex = i+1
fname = None
for i, argv in enumerate(sys.argv):
if argv == '-V' and i+1 < len(sys.argv):
fname = os.path.join(vtkGetDataRoot(), sys.argv[i+1])
if imageIndex != -1:
fname = os.path.join(vtkGetDataRoot(), sys.argv[imageIndex])
if fname is None:
return 2
else:
rt_w2if = vtkWindowToImageFilter()
rt_w2if.SetInput(renWin)
if os.path.isfile(fname):
pass
else:
if not os.path.isfile(fname):
rt_pngw = vtkPNGWriter()
rt_pngw.SetFileName(fname)
rt_pngw.SetInputConnection(rt_w2if.GetOutputPort())
......@@ -112,4 +104,3 @@ def vtkRegressionTestImage( renWin ):
sys.stderr.write('Failed image test: %f\n'
% rt_id.GetThresholdedError())
return 0
return 2
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment