/[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 2881 - (show annotations)
Thu Jan 28 02:03:15 2010 UTC (11 years, 1 month ago) by jfenwick
File MIME type: text/x-python
File size: 4018 byte(s)
Don't panic.
Updating copyright stamps

1
2 ########################################################
3 #
4 # Copyright (c) 2003-2010 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-2010 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 'upper_range' must be equal.
103 """
104
105 self.__vtk_contour.GenerateValues(self.__contours, self.__lower_range,
106 self.__upper_range)
107
108 def _getContourModuleOutput(self):
109 """
110 Return the output of the contour.
111
112 :rtype: vtkPolyData
113 :return: Polygonal data
114 """
115
116 return self.__vtk_contour.GetOutput()
117
118 def _isContoursSet(self):
119 """
120 Return whether the number of contours have been specified.
121
122 :rtype: Boolean
123 :return: True or False
124 """
125
126 if(self.__contours != None):
127 return True
128 else:
129 return False
130
131 def _isLowerRangeSet(self):
132 """
133 Return whether the lower range has been specified.
134
135 :rtype: Boolean
136 :return: True or False
137 """
138
139 if(self.__lower_range != None):
140 return True
141 else:
142 return False
143
144 def _isUpperRangeSet(self):
145 """
146 Return whether the upper range has been specified.
147
148 :rtype: Boolean
149 :return: True or False
150 """
151
152 if(self.__upper_range != None):
153 return True
154 else:
155 return False

  ViewVC Help
Powered by ViewVC 1.1.26