1 |
|
2 |
######################################################## |
3 |
# |
4 |
# Copyright (c) 2003-2010 by University of Queensland |
5 |
# Earth Systems Science Computational Center (ESSCC) |
6 |
# http://www.uq.edu.au/esscc |
7 |
# |
8 |
# Primary Business: Queensland, Australia |
9 |
# Licensed under the Open Software License version 3.0 |
10 |
# http://www.opensource.org/licenses/osl-3.0.php |
11 |
# |
12 |
######################################################## |
13 |
|
14 |
__copyright__="""Copyright (c) 2003-2010 by University of Queensland |
15 |
Earth Systems Science Computational Center (ESSCC) |
16 |
http://www.uq.edu.au/esscc |
17 |
Primary Business: Queensland, Australia""" |
18 |
__license__="""Licensed under the Open Software License version 3.0 |
19 |
http://www.opensource.org/licenses/osl-3.0.php""" |
20 |
__url__="https://launchpad.net/escript-finley" |
21 |
|
22 |
""" |
23 |
:var __author__: name of author |
24 |
:var __copyright__: copyrights |
25 |
:var __license__: licence agreement |
26 |
:var __url__: url entry point on documentation |
27 |
:var __version__: version |
28 |
:var __date__: date of the version |
29 |
""" |
30 |
|
31 |
__author__="John Ngui, john.ngui@uq.edu.au" |
32 |
|
33 |
|
34 |
from esys.escript import getMPISizeWorld |
35 |
if getMPISizeWorld()==1: import vtk |
36 |
|
37 |
class ImageReslice: |
38 |
""" |
39 |
Class that defines an image reslice used to resize static |
40 |
(no interaction capability) images (i.e. logo). |
41 |
""" |
42 |
|
43 |
def __init__(self): |
44 |
""" |
45 |
Initialise the image reslice. |
46 |
""" |
47 |
if getMPISizeWorld()>1: |
48 |
raise ValueError,"pyvisi.ImageReslice is not running on more than one processor." |
49 |
self.__vtk_image_reslice = vtk.vtkImageReslice() |
50 |
|
51 |
def _setupImageReslice(self, object): |
52 |
""" |
53 |
Setup the image reslice. |
54 |
|
55 |
:type object: vtkImageData |
56 |
:param object: Image Data |
57 |
""" |
58 |
|
59 |
self.__object = object |
60 |
self.__setInput() |
61 |
|
62 |
def __setInput(self): |
63 |
""" |
64 |
Set the input for the image reslice. |
65 |
""" |
66 |
|
67 |
self.__vtk_image_reslice.SetInput(self.__object) |
68 |
|
69 |
def setSize(self, size): |
70 |
""" |
71 |
Set the size of the image, between 0 and 2. |
72 |
Size 1 (one) displays the image in its original size |
73 |
(which is the default). |
74 |
|
75 |
:type size: Number |
76 |
:param size: Size of the static image |
77 |
""" |
78 |
|
79 |
# By default, with image reslice, the larger the output spacing, the |
80 |
# smaller the image. Similarly, the smaller the output spacing, the |
81 |
# larger the image. This behaviour is reversed so that the larger the |
82 |
# size the larger the image. Similarly, the smaller the size, the |
83 |
# smaller the image. |
84 |
if(size > 1): |
85 |
size = 1 - (size - 1) |
86 |
self.__vtk_image_reslice.SetOutputSpacing(size, size, size) |
87 |
elif(size < 1): |
88 |
size = (1 - size) + 1 |
89 |
self.__vtk_image_reslice.SetOutputSpacing(size, size, size) |
90 |
|
91 |
def _getImageResliceOutput(self): |
92 |
""" |
93 |
Return the output of the image reslice. |
94 |
|
95 |
:rtype: vtkImageData |
96 |
:return: Image data |
97 |
""" |
98 |
|
99 |
return self.__vtk_image_reslice.GetOutput() |