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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1147 by ksteube, Wed May 16 06:39:11 2007 UTC revision 1199 by jongui, Wed Jun 20 05:01:30 2007 UTC
# Line 1  Line 1 
1  """  """
2  @author: John NGUI  @var __author__: name of author
3    @var __copyright__: copyrights
4    @var __license__: licence agreement
5    @var __url__: url entry point on documentation
6    @var __version__: version
7    @var __date__: date of the version
8  """  """
9    
10    __author__="John Ngui, john.ngui@uq.edu.au"
11    __copyright__="""  Copyright (c) 2006 by ACcESS MNRF
12                        http://www.access.edu.au
13                    Primary Business: Queensland, Australia"""
14    __license__="""Licensed under the Open Software License version 3.0
15                 http://www.opensource.org/licenses/osl-3.0.php"""
16    __url__="http://www.iservo.edu.au/esys"
17    __version__="$Revision$"
18    __date__="$Date$"
19    
20    
21  import vtk  import vtk
22    
23  class ContourModule:  class ContourModule:
24      """      """
25      Class that defines contour module.      Class that defines the contour module.
26      """      """
27    
28      def __init__(self, object):      def __init__(self):
29          """          """
30          Initliase the contour module.          Initliase the contour module.
31            """
32    
33            self.__vtk_contour = vtk.vtkContourFilter()
34            # Keeps track whether the number of contours and its range have
35            # been specified.
36            self.__contours = None
37            self.__lower_range = None
38            self.__upper_range = None
39    
40        def _setupContourModule(self, object):
41            """
42            Setup the contour module.
43    
44          @type object: vtkUnstructuredGrid, etc          @type object: vtkUnstructuredGrid, etc
45          @param object: Input for the contour          @param object: Input for the contour
46          """          """
47    
48          self.__object = object          self.__object = object
         self.__vtk_contour = vtk.vtkContourFilter()  
   
49          self.__setInput()          self.__setInput()
50    
51      def __setInput(self):      def __setInput(self):
# Line 29  class ContourModule: Line 55  class ContourModule:
55    
56          self.__vtk_contour.SetInput(self.__object)          self.__vtk_contour.SetInput(self.__object)
57    
58        # This method is used to delay the execution of generating the contours.
59    
60      # lower_range and upper_range by default is assigned to None. This allows      # lower_range and upper_range by default is assigned to None. This allows
61      # the contours to be altered without necessarily having to alter the      # the contours to be altered without necessarily having to alter the
62      # lower_range and upper_range at the same time.      # lower_range and upper_range at the same time.
63      def generateContours(self, contours, lower_range = None,      def generateContours(self, contours = None, lower_range = None,
64              upper_range = None):              upper_range = None):
65          """          """
66          Generate the specified number of contours within the specified range.          Set the number of contours to generate and its range.  
         In order to generate an iso surface, the 'lower_range' and  
         'upper_range' must be equal.  
67    
68          @type contours: Number          @type contours: Number
69          @param contours: Number of contours to generate          @param contours: Number of contours to generate
# Line 46  class ContourModule: Line 72  class ContourModule:
72          @type upper_range: Number          @type upper_range: Number
73          @param upper_range: Upper range of contours values          @param upper_range: Upper range of contours values
74          """          """
75        
76            if(contours != None): # True if the contours is specified.
77                self.__contours = contours
78          if(lower_range != None): # True if the lower_range is specified.          if(lower_range != None): # True if the lower_range is specified.
79              self.__lower_range = lower_range              self.__lower_range = lower_range
80          if(upper_range != None): # True if the upper_range is specified.          if(upper_range != None): # True if the upper_range is specified.
81              self.__upper_range = upper_range              self.__upper_range = upper_range
82    
83          self.__vtk_contour.GenerateValues(contours, self.__lower_range,      def _generateContours(self):
                 self.__upper_range)  
   
     def _getContour(self):  
84          """          """
85          Return the contour.          Generate the specified number of contours within the specified range.
86    
87          @rtype: vtkContourFilter          @attention: In order to generate an iso surface, the 'lower_range' and
88          @return: Contour filter          'upper_range' must be equal.
89          """          """
90    
91          return self.__vtk_contour          self.__vtk_contour.GenerateValues(self.__contours, self.__lower_range,
92                    self.__upper_range)
93    
94      def _getOutput(self):      def _getContourModuleOutput(self):
95          """          """
96          Return the output of the contour.          Return the output of the contour.
97    
# Line 75  class ContourModule: Line 101  class ContourModule:
101    
102          return self.__vtk_contour.GetOutput()          return self.__vtk_contour.GetOutput()
103    
104        def _isContoursSet(self):
105            """
106            Return whether the number of contours have been specified.
107    
108            @rtype: Boolean
109            @return: True or False
110            """
111    
112            if(self.__contours != None):
113                return True
114            else:
115                return False
116    
117        def _isLowerRangeSet(self):
118            """
119            Return whether the lower range has been specified.
120    
121            @rtype: Boolean
122            @return: True or False
123            """
124    
125            if(self.__lower_range != None):
126                return True
127            else:
128                return False
129    
130        def _isUpperRangeSet(self):
131            """
132            Return whether the upper range has been specified.
133    
134            @rtype: Boolean
135            @return: True or False
136            """
137    
138            if(self.__upper_range != None):
139                return True
140            else:
141                return False

Legend:
Removed from v.1147  
changed lines
  Added in v.1199

  ViewVC Help
Powered by ViewVC 1.1.26