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

Annotation of /trunk/pyvisi/py_src/streamlinemodule.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: 4292 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 StreamLineModule:
24     """
25     Class that defines the streamline module.
26     """
27    
28 jongui 1148 def __init__(self):
29 ksteube 1147 """
30     Initialise the streamline module.
31 jongui 1148 """
32 ksteube 1147
33 jongui 1148 self.__vtk_stream_line = vtk.vtkStreamLine()
34    
35     def _setupStreamLineModule(self, object, source):
36     """
37     Setup the streamline.
38    
39 ksteube 1147 @type object: vtkUnstructuredGrid, etc
40     @param object: Input for the streamline
41     @type source: vtkPolyData
42     @param source: Source to generate the starting points
43     """
44    
45     self.__object = object
46     self.__source = source
47    
48     self.__setInput()
49     self.__setSource()
50     # Default maximum propagation time is 100.
51     self.setMaximumPropagationTime(100)
52     # Default step length is 0.01
53     self.setStepLength(0.01)
54     # Default integration step length is 0.01
55     self.setIntegrationStepLength(0.01)
56     # Default integration is set to both directions.
57     self.setIntegrationToBothDirections()
58     # Default integrator is set to vtkRungeKutta4
59     self.setIntegrator(vtk.vtkRungeKutta4())
60    
61     def __setInput(self):
62     """
63     Set the input for the streamline.
64     """
65    
66     self.__vtk_stream_line.SetInput(self.__object)
67    
68     def __setSource(self):
69     """
70     Set the source to generate the starting points for the streamline.
71     """
72    
73     self.__vtk_stream_line.SetSource(self.__source)
74    
75     def setMaximumPropagationTime(self, time):
76     """
77     Set the maximum length of the streamline expressed in elapsed time.
78    
79     @type time: Number
80     @param time: Maximum length of the streamline expressed in elapsed time
81     """
82    
83     self.__vtk_stream_line.SetMaximumPropagationTime(time)
84    
85     def setStepLength(self, length):
86     """
87     Set the length of the streamline segment expressed in elapsed time.
88     A smaller value results in a smoother streamline
89     (but is more expensive). Setting the step length usually goes
90     hand-in-hand with setting the integration step length. Otherwise,
91     errors such as "... can't compute normals" may arise. If such an
92     error occurs try changing the value. However, it does not usually
93     apply the other way around.
94    
95     @type length: Number
96     @param length: Length of the streamline segment expressed in
97 jongui 1197 elapsed time
98 ksteube 1147 """
99    
100     self.__vtk_stream_line.SetStepLength(length)
101    
102     def setIntegrationStepLength(self, length):
103     """
104     Set the integration step size expressed as a fraction of the size of
105     each cell. A smaller length results in a better image (but is more
106     expensive).
107    
108     @type length: Number
109     @param length: Length of the integration step expressed as a fraction
110 jongui 1197 of the size of each cell
111 ksteube 1147 """
112    
113     self.__vtk_stream_line.SetIntegrationStepLength(length)
114    
115     def setIntegrationToBothDirections(self):
116     """
117     Set the integration to occur both sides: forward (where the streamline
118     goes) and backward (where the streamline came from).
119     """
120    
121 jongui 1148 self.__vtk_stream_line.\
122     SetIntegrationDirectionToIntegrateBothDirections()
123 ksteube 1147
124     def setIntegrator(self, integrator):
125     """
126     Set the integrator to be used in the streamline calculation.
127    
128     @type integrator: vtkInitialValueProblemSolver
129     @param integrator: Integrator type. i.e. vtkRungeKutta2, vtkRungeKutta4
130     """
131    
132     self.__vtk_stream_line.SetIntegrator(integrator)
133    
134     def _setSpeedScalarsOn(self):
135     """
136     Turn on the creation of scalar data from velocity magnitude.
137     """
138    
139     self.__vtk_stream_line.SpeedScalarsOn()
140    
141     def _setSpeedScalarsOff(self):
142     """
143     Turn off the creation of scalar data from velocity magnitude. If
144     input dataset has scalars, input dataset scalars are used.
145     """
146    
147     self.__vtk_stream_line.SpeedScalarsOff()
148    
149 jongui 1148 def _getStreamLineModuleOutput(self):
150 ksteube 1147 """
151     Return the output of the streamline.
152    
153     @rtype: vtkPolyData
154     @return Polygonal data
155     """
156    
157     return self.__vtk_stream_line.GetOutput()

  ViewVC Help
Powered by ViewVC 1.1.26