1 |
""" |
2 |
@author: John NGUI |
3 |
""" |
4 |
|
5 |
import vtk |
6 |
|
7 |
class ContourModule: |
8 |
""" |
9 |
Class that defines contour. |
10 |
""" |
11 |
|
12 |
def __init__(self, object): |
13 |
""" |
14 |
Initliase the contour. |
15 |
|
16 |
@type object: vtkUnstructuredGrid, etc |
17 |
@param object: Input for the contour |
18 |
""" |
19 |
|
20 |
self.__object = object |
21 |
self.__vtk_contour = vtk.vtkContourFilter() |
22 |
|
23 |
self.__setInput() |
24 |
|
25 |
def __setInput(self): |
26 |
""" |
27 |
Set the input for the contour. |
28 |
""" |
29 |
|
30 |
self.__vtk_contour.SetInput(self.__object) |
31 |
|
32 |
# lower_range and upper_range by default is assigned to None. This allows |
33 |
# the contours to be altered without necessarily having to alter the |
34 |
# lower_range and upper_range together. |
35 |
def generateContours(self, contours, lower_range = None, |
36 |
upper_range = None): |
37 |
""" |
38 |
Generate the specified number of contours within the specified range. |
39 |
|
40 |
@type contours: Number |
41 |
@param contours: Number of contours to generate |
42 |
@type lower_range: Number |
43 |
@param lower_range: Lower range of contour values |
44 |
@type upper_range: Number |
45 |
@param upper_range: Upper range of contours values |
46 |
""" |
47 |
|
48 |
if(lower_range != None): # True if the lower_range is specified. |
49 |
self.__lower_range = lower_range |
50 |
if(upper_range != None): # True if the upper_range is specified. |
51 |
self.__upper_range = upper_range |
52 |
|
53 |
self.__vtk_contour.GenerateValues(contours, self.__lower_range, |
54 |
self.__upper_range) |
55 |
|
56 |
def _getOutput(self): |
57 |
""" |
58 |
Return the output of the contour. |
59 |
|
60 |
@rtype: vtkPolyData |
61 |
@return: Polygonal data |
62 |
""" |
63 |
|
64 |
return self.__vtk_contour.GetOutput() |
65 |
|