7 |
|
|
8 |
class DataCollector: |
class DataCollector: |
9 |
""" |
""" |
10 |
Class that defines a data collector which deal with the source |
Class that defines a data collector which dealrs with the source |
11 |
of the data for visualisation. |
of data for the visualisation. |
12 |
""" |
""" |
13 |
|
|
14 |
def __init__(self, source = Source.XML): |
def __init__(self, source = Source.XML): |
16 |
Initialise the data collector. |
Initialise the data collector. |
17 |
|
|
18 |
@type source: L{Source <constant.Source>} constant |
@type source: L{Source <constant.Source>} constant |
19 |
@param source: Source input type |
@param source: Source data type |
20 |
""" |
""" |
21 |
|
|
22 |
if(source == Source.XML): # Source is an XML file. |
if(source == Source.XML): # Source is an XML file. |
24 |
|
|
25 |
def setFileName(self, file_name): |
def setFileName(self, file_name): |
26 |
""" |
""" |
27 |
Set the source file name to read for the data collector. |
Set the source file name to read. |
28 |
|
|
29 |
@type file_name: String |
@type file_name: String |
30 |
@param file_name: Name of the file to read |
@param file_name: Name of the file to read |
32 |
|
|
33 |
self.__vtk_xml_reader.SetFileName(file_name) |
self.__vtk_xml_reader.SetFileName(file_name) |
34 |
self.__output = self.__vtk_xml_reader.GetOutput() |
self.__output = self.__vtk_xml_reader.GetOutput() |
35 |
|
|
36 |
# NOTE: Update must be called after SetFileName to make the reader |
# NOTE: Update must be called after SetFileName to make the reader |
37 |
# up to date. Otherwise, some output values may be incorrect. |
# up to date. Otherwise, some output values may be incorrect. |
38 |
self.__vtk_xml_reader.Update() |
self.__vtk_xml_reader.Update() |
39 |
|
|
40 |
def _setActiveScalar(self, scalar): |
def _setActiveScalar(self, scalar): |
41 |
""" |
""" |
42 |
Specify the scalar field to laod from the source |
Specify the scalar field to load from the source file. |
|
file for the data collector. |
|
43 |
|
|
44 |
@type scalar: String |
@type scalar: String |
45 |
@param scalar: Scalar field to load from the file. |
@param scalar: Scalar field to load from the file. |
49 |
|
|
50 |
def _setActiveVector(self, vector): |
def _setActiveVector(self, vector): |
51 |
""" |
""" |
52 |
Specify the vector field to laod from the source |
Specify the vector field to load from the source file. |
|
file for the data collector. |
|
53 |
|
|
54 |
@type vector: String |
@type vector: String |
55 |
@param vector: Vector field to load from the file. |
@param vector: Vector field to load from the file. |
59 |
|
|
60 |
def _setActiveTensor(self, tensor): |
def _setActiveTensor(self, tensor): |
61 |
""" |
""" |
62 |
Specify the tensor field to laod from the source |
Specify the tensor field to load from the source file. |
|
file for the data collector. |
|
63 |
|
|
64 |
@type tensor: String |
@type tensor: String |
65 |
@param tensor: Tensor field to load from the file. |
@param tensor: Tensor field to load from the file. |
85 |
@return: Vector range |
@return: Vector range |
86 |
""" |
""" |
87 |
|
|
88 |
vector_range = self._getOutput().GetPointData().GetVectors().GetRange(-1) |
vector_range = self._getOutput().GetPoitData().GetVectors().GetRange(-1) |
89 |
|
|
90 |
# NOTE: Generally GetRange(-1) returns the correct vector range. |
# NOTE: Generally GetRange(-1) returns the correct vector range. |
91 |
# However, there are certain data sets where GetRange(-1) seems |
# However, there are certain data sets where GetRange(-1) seems |
115 |
return self.__output |
return self.__output |
116 |
|
|
117 |
|
|
118 |
|
############################################################################### |
119 |
|
|
120 |
|
|
121 |
from constant import ImageFormat |
from constant import ImageFormat |
122 |
|
|
123 |
class ImageReader: |
class ImageReader: |
138 |
|
|
139 |
def getImageReader(self): |
def getImageReader(self): |
140 |
""" |
""" |
141 |
Return the corresponding image reader based on the supplied image |
Return the appropriate image reader based on the supplied image |
142 |
format. |
format. |
143 |
|
|
144 |
@rtype: vtkImageReader2 (i.e. vtkJPEGReader, etc) |
@rtype: vtkImageReader2 (i.e. vtkJPEGReader, etc) |
161 |
Set the image file name. |
Set the image file name. |
162 |
|
|
163 |
@type file_name: String |
@type file_name: String |
164 |
@param file_name: Image file name which is to be read |
@param file_name: Image file name to be read |
165 |
""" |
""" |
166 |
|
|
167 |
self.__vtk_image_reader.SetFileName(file_name) |
self.__vtk_image_reader.SetFileName(file_name) |
168 |
|
|
169 |
def _getOutput(self): |
def _getOutput(self): |
170 |
""" |
""" |
171 |
Return the image reader. |
Return the output of the image reader. |
172 |
|
|
173 |
@rtype: vtkImageData |
@rtype: vtkImageData |
174 |
@return Image data |
@return Image data |