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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.26