/[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 943 - (hide annotations)
Mon Jan 29 07:22:43 2007 UTC (12 years, 7 months ago) by jongui
File MIME type: text/x-python
File size: 3002 byte(s)
new pyvisi files
1 jongui 943 """
2     @author: John NGUI
3     """
4    
5     import vtk
6    
7     class StreamLineModule:
8     """
9     Class that defines streamline.
10     """
11    
12     def __init__(self, object, source):
13     """
14     Initialise the streamline.
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 50.
36     self.setMaximumPropagationTime(50)
37     # Default step length is 0.1
38     self.setStepLength(0.1)
39     # Default integration step length is 0.1
40     self.setIntegrationStepLength(0.1)
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 streamlines.
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 line segment expressed in elapsed time. A smaller
74     value results in a smoother streamline (but is more expensive).
75    
76     @type length: Number
77     @param length: Length of the line segment expressed in elapsed time
78     """
79    
80     self.__vtk_stream_line.SetStepLength(length)
81    
82     def setIntegrationStepLength(self, length):
83     """
84     Set the integration step size expressed as a fraction of the size of
85     each cell. A smaller length results in a better image (but is more
86     expensive).
87    
88     @type length: Number
89     @param length: Length of the integration step expressed as a fraction
90     """
91    
92     self.__vtk_stream_line.SetIntegrationStepLength(length)
93    
94     def setIntegrationToBothDirections(self):
95     """
96     Set the integration to occur both sides: forward (where the streamline
97     goes) and backward (where the streamline came from).
98     """
99    
100     self.__vtk_stream_line.SetIntegrationDirectionToIntegrateBothDirections()
101    
102     def setIntegrator(self, integrator):
103     """
104     Set the integrator to be used in the streamline calculation.
105    
106     @type integrator: vtkInitialValueProblemSolver
107     @param integrator: Integrator type. i.e. vtkRungeKutta2, vtkRungeKutta4
108     """
109    
110     self.__vtk_stream_line.SetIntegrator(integrator)
111    
112     def _getOutput(self):
113     """
114     Return the streamline.
115    
116     @rtype: vtkPolyData
117     @return Polygonal data
118     """
119    
120     return self.__vtk_stream_line.GetOutput()

  ViewVC Help
Powered by ViewVC 1.1.26