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

Contents of /trunk/pyvisi/py_src/streamlinemodule.py

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.26