/[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 949 - (hide annotations)
Fri Feb 2 05:33:05 2007 UTC (13 years, 6 months ago) by jongui
File MIME type: text/x-python
File size: 3240 byte(s)
Fixed some more bugs and added more epydocs. Testing remains outstanding.
1 jongui 943 """
2     @author: John NGUI
3     """
4    
5     import vtk
6    
7     class StreamLineModule:
8     """
9 jongui 949 Class that defines streamlines.
10 jongui 943 """
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 jongui 946 # Default maximum propagation time is 100.
36     self.setMaximumPropagationTime(100)
37 jongui 943 # 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 jongui 946 value results in a smoother streamline (but is more expensive). Setting
75     the step length usually goes hand-in-hand with setting the integration
76     step length. Otherwise, errors such as "... can't compute normals" may
77     arise. However, it does not usually apply the other way around.
78 jongui 943
79     @type length: Number
80     @param length: Length of the line segment expressed in elapsed time
81     """
82    
83     self.__vtk_stream_line.SetStepLength(length)
84    
85     def setIntegrationStepLength(self, length):
86     """
87     Set the integration step size expressed as a fraction of the size of
88     each cell. A smaller length results in a better image (but is more
89     expensive).
90    
91     @type length: Number
92     @param length: Length of the integration step expressed as a fraction
93     """
94    
95     self.__vtk_stream_line.SetIntegrationStepLength(length)
96    
97     def setIntegrationToBothDirections(self):
98     """
99     Set the integration to occur both sides: forward (where the streamline
100     goes) and backward (where the streamline came from).
101     """
102    
103     self.__vtk_stream_line.SetIntegrationDirectionToIntegrateBothDirections()
104    
105     def setIntegrator(self, integrator):
106     """
107 jongui 949 Set the integrator to be used in the streamline calculation.
108 jongui 943
109     @type integrator: vtkInitialValueProblemSolver
110     @param integrator: Integrator type. i.e. vtkRungeKutta2, vtkRungeKutta4
111     """
112    
113     self.__vtk_stream_line.SetIntegrator(integrator)
114    
115     def _getOutput(self):
116     """
117 jongui 949 Return the output of the streamline.
118 jongui 943
119     @rtype: vtkPolyData
120     @return Polygonal data
121     """
122    
123     return self.__vtk_stream_line.GetOutput()

  ViewVC Help
Powered by ViewVC 1.1.26