/[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 1147 - (hide annotations)
Wed May 16 06:39:11 2007 UTC (13 years, 11 months ago) by ksteube
File MIME type: text/x-python
File size: 3729 byte(s)
Added back in some files that were accidentally deleted.

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

  ViewVC Help
Powered by ViewVC 1.1.26