/[escript]/tags/trunk_2172_checkpoint/pyvisi/py_src/contourmodule.py
ViewVC logotype

Contents of /tags/trunk_2172_checkpoint/pyvisi/py_src/contourmodule.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2175 - (show annotations)
Wed Dec 17 09:22:40 2008 UTC (12 years, 2 months ago) by phornby
File MIME type: text/x-python
File size: 3817 byte(s)
Try again at conforming to naming convention.
1
2 ########################################################
3 #
4 # Copyright (c) 2003-2008 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-2008 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__="http://www.uq.edu.au/esscc/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 import vtk
35
36 class ContourModule:
37 """
38 Class that defines the contour module.
39 """
40
41 def __init__(self):
42 """
43 Initliase the contour module.
44 """
45
46 self.__vtk_contour = vtk.vtkContourFilter()
47 # Keeps track whether the number of contours and its range have
48 # been specified.
49 self.__contours = None
50 self.__lower_range = None
51 self.__upper_range = None
52
53 def _setupContourModule(self, object):
54 """
55 Setup the contour module.
56
57 @type object: vtkUnstructuredGrid, etc
58 @param object: Input for the contour
59 """
60
61 self.__object = object
62 self.__setInput()
63
64 def __setInput(self):
65 """
66 Set the input for the contour.
67 """
68
69 self.__vtk_contour.SetInput(self.__object)
70
71 # This method is used to delay the execution of generating the contours.
72
73 # lower_range and upper_range by default is assigned to None. This allows
74 # the contours to be altered without necessarily having to alter the
75 # lower_range and upper_range at the same time.
76 def generateContours(self, contours = None, lower_range = None,
77 upper_range = None):
78 """
79 Set the number of contours to generate and its range.
80
81 @type contours: Number
82 @param contours: Number of contours to generate
83 @type lower_range: Number
84 @param lower_range: Lower range of contour values
85 @type upper_range: Number
86 @param upper_range: Upper range of contours values
87 """
88
89 if(contours != None): # True if the contours is specified.
90 self.__contours = contours
91 if(lower_range != None): # True if the lower_range is specified.
92 self.__lower_range = lower_range
93 if(upper_range != None): # True if the upper_range is specified.
94 self.__upper_range = upper_range
95
96 def _generateContours(self):
97 """
98 Generate the specified number of contours within the specified range.
99
100 @attention: In order to generate an iso surface, the 'lower_range' and
101 'upper_range' must be equal.
102 """
103
104 self.__vtk_contour.GenerateValues(self.__contours, self.__lower_range,
105 self.__upper_range)
106
107 def _getContourModuleOutput(self):
108 """
109 Return the output of the contour.
110
111 @rtype: vtkPolyData
112 @return: Polygonal data
113 """
114
115 return self.__vtk_contour.GetOutput()
116
117 def _isContoursSet(self):
118 """
119 Return whether the number of contours have been specified.
120
121 @rtype: Boolean
122 @return: True or False
123 """
124
125 if(self.__contours != None):
126 return True
127 else:
128 return False
129
130 def _isLowerRangeSet(self):
131 """
132 Return whether the lower range has been specified.
133
134 @rtype: Boolean
135 @return: True or False
136 """
137
138 if(self.__lower_range != None):
139 return True
140 else:
141 return False
142
143 def _isUpperRangeSet(self):
144 """
145 Return whether the upper range has been specified.
146
147 @rtype: Boolean
148 @return: True or False
149 """
150
151 if(self.__upper_range != None):
152 return True
153 else:
154 return False

  ViewVC Help
Powered by ViewVC 1.1.26