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

Diff of /trunk/pyvisi/py_src/streamlines.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 792 by gross, Fri Jul 28 10:37:16 2006 UTC revision 879 by jongui, Wed Oct 25 03:56:34 2006 UTC
# Line 1  Line 1 
1  """  """
2  class that shows the path of all particles placed in a set of spheres through a vector field.  @author: John Ngui
3    @author: Lutz Gross
 @var __author__: name of author  
 @var __license__: licence agreement  
 @var __copyright__: copyrights  
 @var __url__: url entry point on documentation  
 @var __version__: version  
 @var __date__: date of the version  
4  """  """
5  __copyright__="""  Copyright (c) 2006 by ACcESS MNRF  
6                      http://www.access.edu.au  import vtk
7                  Primary Business: Queensland, Australia"""  from common import Common
8  __license__="""Licensed under the Open Software License version 3.0  from geo import Position
9               http://www.opensource.org/licenses/osl-3.0.php"""  
10  __author__="Paul Cochrane, L. Gross"  class StreamLines(Common):
11  __url__="http://www.iservo.edu.au/esys"      """
12  __version__="$Revision:$"      Class that shows the path of particles (within a specified cloud of points)
13  __date__="$Date:$"      in a vector field.
14        """
15  from common import Component  
16        def __init__(self, scene, data_collector, lut = None):
17  class StreamLines(Component):          """
18      """          @type scene: L{Scene <scene.Scene>} object
19      shows the path of all particles placed in a set of spheres through a vector field.          @param scene: Scene in which components are to be added to
20      """          @type data_collector: L{DataCollector <datacollector.DataCollector>}
21      pass              object
22            @param data_collector: Source of data for visualization
23            @type lut: L{BlueToRed <colormap.BlueToRed>} or
24                L{RedToBlue <colormap.RedToBlue>} object
25            @param lut: Lookup table to be used by the mapper
26            """
27    
28            Common.__init__(self, scene, data_collector)
29            # Create a spherical cloud of points.
30            self.vtk_point_source = vtk.vtkPointSource()
31            # Create streamlines
32            self.vtk_stream_lines = vtk.vtkStreamLine()
33            # Create tube to be wrapped around the streamlines.
34            self.vtk_tube = vtk.vtkTubeFilter()
35    
36            self.setSource()
37            self.setStreamLines()
38            self.setTube()
39            
40            Common.setMapperInput(self, self.vtk_tube.GetOutput(), lut)
41            Common.setActorInput(self)
42            Common.addActor(self)
43    
44        def setSource(self):
45            """
46            Set the default parameters for the spherical cloud of points.
47            """
48    
49            self.setCloudRadius(0.2)
50            self.setCenter(Position(0.2, 2.1, 0.5))
51            self.setNumberOfPoints(8)
52    
53        def setStreamLines(self):
54            """
55            Set the default parameters for the streamlines.
56            """
57    
58            self.vtk_stream_lines.SetInput(
59                self.data_collector.getReader().GetOutput())
60            self.vtk_stream_lines.SetSource(self.vtk_point_source.GetOutput())
61            self.setMaximumPropagationTime(500)
62            self.setLineSize(0.2)
63            self.setAccuracy(0.05)
64            
65            self.setIntegrationToBothDirections()
66            self.vtk_stream_lines.SetIntegrator(vtk.vtkRungeKutta4())
67    
68    
69        def setTube(self):
70            """
71            Set the default parameters for the tube.
72            """
73    
74            self.vtk_tube.SetInput(self.vtk_stream_lines.GetOutput())
75            self.setTubeRadius(0.01)
76            self.setNumberOfSides(12)
77            self.setVaryRadiusByVector()
78            
79        def setCloudRadius(self, radius):
80            """
81            Set the radius for the cloud of points.
82            @type radius: Number
83            @param radius: Radius for the cloud of points
84            """
85    
86            self.vtk_point_source.SetRadius(radius)
87    
88        def setCenter(self, position):
89            """
90            Set the center for the cloud of points.
91            @type position: L{Position <geo.Position>} object
92            @param position: Center for the cloud of points
93            """
94    
95            self.vtk_point_source.SetCenter(position.getXCoor(),
96                position.getYCoor(), position.getZCoor())
97    
98        def setNumberOfPoints(self, points):
99            """
100            Set the number of points to generate for the cloud of points.
101            @type points: Number
102            @param points: Number of points to generate for the cloud of points
103            """
104    
105            self.vtk_point_source.SetNumberOfPoints(points)
106    
107        def setMaximumPropagationTime(self, time):
108            """
109            Set the maximum length for the streamlines in units of time.
110            @type time: Number
111            @param time: Units of time specifying the maximum length of streamlines
112            """
113    
114            self.vtk_stream_lines.SetMaximumPropagationTime(time)
115    
116        def setStreamLinesSize(self, stream_lines_size):
117            """
118            Set the size of the streamlines.
119            @type stream_lines_size: Number
120            @param stream_lines_size: Size of the streamlines
121            """
122    
123            self.vtk_stream_lines.SetStepLength(stream_lines_size)
124    
125        def setAccuracy(self, accuracy):
126            """
127            Set the level of accuracy for the streamlines. The smaller the value
128            the more accurate it is.
129            @type accuracy: Number
130            @param accuracy: Accuracy for the streamlines (between 0 to 1)
131            """
132    
133            self.vtk_stream_lines.SetIntegrationStepLength(accuracy)
134    
135        def setIntegrationToBothDirections(self):
136            """
137            Set the integration to occur in both directions.
138            """    
139    
140            self.vtk_stream_lines.SetIntegrationDirectionToIntegrateBothDirections()
141    
142        def setTubeRadius(self, radius):
143            """
144            Set the minimum radius of the tube.
145            @type radius: Number
146            @param radius: Minimum radius of the tube
147            """
148    
149            self.vtk_tube.SetRadius(radius)
150    
151        def setNumberOfSides(self, sides):
152            """
153            Set the number of sides for the tube.
154            @type sides: Number
155            @param sides: Number of sides for the tube (mimimum is 3)
156            """
157    
158            self.vtk_tube.SetNumberOfSides(sides)
159    
160        def setVaryRadiusByVector(self):
161            """
162            Set the variation of the tube radius with vector data.
163            """
164            
165            self.vtk_tube.SetVaryRadiusToVaryRadiusByVector()

Legend:
Removed from v.792  
changed lines
  Added in v.879

  ViewVC Help
Powered by ViewVC 1.1.26