/[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 1197 - (hide annotations)
Mon Jun 18 02:08:34 2007 UTC (13 years, 10 months ago) by jongui
File MIME type: text/x-python
File size: 3548 byte(s)
Update the way movies are generated. Please refer to the examples. 

The user can now either specify the image range(first and last images inclusive):
mov.imageRange(input_directory = PYVISI_EXAMPLE_IMAGES_PATH,
        first_image = IMAGE_NAME + "000938.jpg",
		last_image = IMAGE_NAME + "000948.jpg")
mov.makeMovie(os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, "movie.mpg"))

or the user can specify a list of images:

lst = ['image1.jpg', 'image5.jpg', 'image7.jpg]
mov.imageList(input_directory = PYVISI_EXAMPLE_IMAGES_PATH, image_list = lst)
mov.makeMovie(os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, "movie.mpg"))


1 ksteube 1147 """
2 jongui 1197 @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 ksteube 1147 """
9    
10 jongui 1197 __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 ksteube 1147 import vtk
22    
23     class ContourModule:
24     """
25     Class that defines contour module.
26     """
27    
28 jongui 1148 def __init__(self):
29 ksteube 1147 """
30     Initliase the contour module.
31 jongui 1148 """
32 ksteube 1147
33 jongui 1148 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 ksteube 1147 @type object: vtkUnstructuredGrid, etc
45     @param object: Input for the contour
46     """
47    
48     self.__object = object
49     self.__setInput()
50    
51     def __setInput(self):
52     """
53     Set the input for the contour.
54     """
55    
56     self.__vtk_contour.SetInput(self.__object)
57    
58 jongui 1148 # This method is used to delay the execution of generating the contours.
59    
60 ksteube 1147 # 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
62     # lower_range and upper_range at the same time.
63 jongui 1148 def generateContours(self, contours = None, lower_range = None,
64 ksteube 1147 upper_range = None):
65     """
66 jongui 1148 Set the number of contours to generate and its range.
67 ksteube 1147
68     @type contours: Number
69     @param contours: Number of contours to generate
70     @type lower_range: Number
71     @param lower_range: Lower range of contour values
72     @type upper_range: Number
73     @param upper_range: Upper range of contours values
74     """
75 jongui 1148
76     if(contours != None): # True if the contours is specified.
77     self.__contours = contours
78 ksteube 1147 if(lower_range != None): # True if the lower_range is specified.
79     self.__lower_range = lower_range
80     if(upper_range != None): # True if the upper_range is specified.
81     self.__upper_range = upper_range
82    
83 jongui 1148 def _generateContours(self):
84     """
85     Generate the specified number of contours within the specified range.
86     In order to generate an iso surface, the 'lower_range' and
87     'upper_range' must be equal.
88     """
89    
90     self.__vtk_contour.GenerateValues(self.__contours, self.__lower_range,
91 ksteube 1147 self.__upper_range)
92    
93     def _getContour(self):
94     """
95     Return the contour.
96    
97     @rtype: vtkContourFilter
98     @return: Contour filter
99     """
100    
101     return self.__vtk_contour
102    
103 jongui 1148 def _getContourModuleOutput(self):
104 ksteube 1147 """
105     Return the output of the contour.
106    
107     @rtype: vtkPolyData
108     @return: Polygonal data
109     """
110    
111     return self.__vtk_contour.GetOutput()
112    
113 jongui 1148 def _isContoursSet(self):
114     """
115     Return whether the number of contours have been specified.
116    
117     @rtype: Boolean
118     @return: True or False
119     """
120    
121     if(self.__contours != None):
122     return True
123     else:
124     return False
125    
126     def _isLowerRangeSet(self):
127     """
128     Return whether the lower range has been specified.
129    
130     @rtype: Boolean
131     @return: True or False
132     """
133    
134     if(self.__lower_range != None):
135     return True
136     else:
137     return False
138    
139     def _isUpperRangeSet(self):
140     """
141     Return whether the upper range has been specified.
142    
143     @rtype: Boolean
144     @return: True or False
145     """
146    
147     if(self.__upper_range != None):
148     return True
149     else:
150     return False

  ViewVC Help
Powered by ViewVC 1.1.26