/[escript]/trunk/pyvisi/py_src/contourmodule.py
ViewVC logotype

Annotation of /trunk/pyvisi/py_src/contourmodule.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1148 - (hide annotations)
Wed May 16 22:45:33 2007 UTC (13 years, 11 months ago) by jongui
File MIME type: text/x-python
File size: 2943 byte(s)
Added the updated files for pyvisi and removed some incorrect reference images.
1 ksteube 1147 """
2     @author: John NGUI
3     """
4    
5     import vtk
6    
7     class ContourModule:
8     """
9     Class that defines contour module.
10     """
11    
12 jongui 1148 def __init__(self):
13 ksteube 1147 """
14     Initliase the contour module.
15 jongui 1148 """
16 ksteube 1147
17 jongui 1148 self.__vtk_contour = vtk.vtkContourFilter()
18     # Keeps track whether the number of contours and its range have
19     # been specified.
20     self.__contours = None
21     self.__lower_range = None
22     self.__upper_range = None
23    
24     def _setupContourModule(self, object):
25     """
26     Setup the contour module.
27    
28 ksteube 1147 @type object: vtkUnstructuredGrid, etc
29     @param object: Input for the contour
30     """
31    
32     self.__object = object
33     self.__setInput()
34    
35     def __setInput(self):
36     """
37     Set the input for the contour.
38     """
39    
40     self.__vtk_contour.SetInput(self.__object)
41    
42 jongui 1148 # This method is used to delay the execution of generating the contours.
43    
44 ksteube 1147 # lower_range and upper_range by default is assigned to None. This allows
45     # the contours to be altered without necessarily having to alter the
46     # lower_range and upper_range at the same time.
47 jongui 1148 def generateContours(self, contours = None, lower_range = None,
48 ksteube 1147 upper_range = None):
49     """
50 jongui 1148 Set the number of contours to generate and its range.
51 ksteube 1147
52     @type contours: Number
53     @param contours: Number of contours to generate
54     @type lower_range: Number
55     @param lower_range: Lower range of contour values
56     @type upper_range: Number
57     @param upper_range: Upper range of contours values
58     """
59 jongui 1148
60     if(contours != None): # True if the contours is specified.
61     self.__contours = contours
62 ksteube 1147 if(lower_range != None): # True if the lower_range is specified.
63     self.__lower_range = lower_range
64     if(upper_range != None): # True if the upper_range is specified.
65     self.__upper_range = upper_range
66    
67 jongui 1148 def _generateContours(self):
68     """
69     Generate the specified number of contours within the specified range.
70     In order to generate an iso surface, the 'lower_range' and
71     'upper_range' must be equal.
72     """
73    
74     self.__vtk_contour.GenerateValues(self.__contours, self.__lower_range,
75 ksteube 1147 self.__upper_range)
76    
77     def _getContour(self):
78     """
79     Return the contour.
80    
81     @rtype: vtkContourFilter
82     @return: Contour filter
83     """
84    
85     return self.__vtk_contour
86    
87 jongui 1148 def _getContourModuleOutput(self):
88 ksteube 1147 """
89     Return the output of the contour.
90    
91     @rtype: vtkPolyData
92     @return: Polygonal data
93     """
94    
95     return self.__vtk_contour.GetOutput()
96    
97 jongui 1148 def _isContoursSet(self):
98     """
99     Return whether the number of contours have been specified.
100    
101     @rtype: Boolean
102     @return: True or False
103     """
104    
105     if(self.__contours != None):
106     return True
107     else:
108     return False
109    
110     def _isLowerRangeSet(self):
111     """
112     Return whether the lower range has been specified.
113    
114     @rtype: Boolean
115     @return: True or False
116     """
117    
118     if(self.__lower_range != None):
119     return True
120     else:
121     return False
122    
123     def _isUpperRangeSet(self):
124     """
125     Return whether the upper range has been specified.
126    
127     @rtype: Boolean
128     @return: True or False
129     """
130    
131     if(self.__upper_range != None):
132     return True
133     else:
134     return False

  ViewVC Help
Powered by ViewVC 1.1.26