/[escript]/tags/trunk_2172_checkpoint/pyvisi/py_src/point.py
ViewVC logotype

Annotation of /tags/trunk_2172_checkpoint/pyvisi/py_src/point.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2174 - (hide annotations)
Wed Dec 17 09:21:26 2008 UTC (12 years, 4 months ago) by phornby
Original Path: tags/trunk_at_2172_checkpoint/pyvisi/py_src/point.py
File MIME type: text/x-python
File size: 4465 byte(s)
Conform to previous naming convention.
1 ksteube 1809
2     ########################################################
3     #
4     # Copyright (c) 2003-2008 by University of Queensland
5     # Earth Systems Science Computational Center (ESSCC)
6     # http://www.uq.edu.au/esscc
7     #
8     # Primary Business: Queensland, Australia
9     # Licensed under the Open Software License version 3.0
10     # http://www.opensource.org/licenses/osl-3.0.php
11     #
12     ########################################################
13    
14     __copyright__="""Copyright (c) 2003-2008 by University of Queensland
15     Earth Systems Science Computational Center (ESSCC)
16     http://www.uq.edu.au/esscc
17     Primary Business: Queensland, Australia"""
18     __license__="""Licensed under the Open Software License version 3.0
19     http://www.opensource.org/licenses/osl-3.0.php"""
20     __url__="http://www.uq.edu.au/esscc/escript-finley"
21    
22 ksteube 1147 """
23 jongui 1197 @var __author__: name of author
24     @var __copyright__: copyrights
25     @var __license__: licence agreement
26     @var __url__: url entry point on documentation
27     @var __version__: version
28     @var __date__: date of the version
29 ksteube 1147 """
30    
31 jongui 1197 __author__="John Ngui, john.ngui@uq.edu.au"
32    
33    
34 ksteube 1147 import vtk
35     from position import GlobalPosition
36    
37     class PointSource:
38     """
39     Class that defines the source (location) to generate points. The points are
40     generated within the radius of a sphere.
41     """
42    
43 jongui 1148 def __init__(self):
44 ksteube 1147 """
45     Initialise the point source.
46     """
47    
48     self.__vtk_point_source = vtk.vtkPointSource()
49 jongui 1148 self.__center = None
50 ksteube 1147
51 jongui 1148 def _setupPointSource(self, object):
52 ksteube 1147 """
53     Setup the point source.
54 jongui 1148
55     @type object: vtkPolyData, etc
56     @param object: Used to define the location of the sphere
57 ksteube 1147 """
58    
59 jongui 1148 self.__object = object
60    
61 ksteube 1147 # Default number of points to generate within the sphere is 10.
62     self.setPointSourceNumberOfPoints(10)
63     # Default radius of the sphere is 0.5.
64     self.setPointSourceRadius(0.5)
65    
66     def setPointSourceRadius(self, radius):
67     """
68     Set the radius of the sphere.
69    
70     @type radius: Number
71     @param radius: Radius of the sphere
72     """
73    
74     self.__vtk_point_source.SetRadius(radius)
75    
76 jongui 1148 # This method is used to delay the execution of setting the point source
77     # center.
78     def setPointSourceCenter(self, center):
79 ksteube 1147 """
80 jongui 1199 Specity the sphere's center.
81 ksteube 1147
82 jongui 1148 @type center: L{GLobalPosition <position.GlobalPosition>} object
83     @param center: Center of the sphere
84 ksteube 1147 """
85 jongui 1148
86     self.__center = center
87 ksteube 1147
88 jongui 1148 def _setPointSourceCenter(self):
89     """
90     Set the sphere's center.
91     """
92 ksteube 1147
93 jongui 1148 self.__vtk_point_source.SetCenter(self.__center._getGlobalPosition())
94    
95 ksteube 1147 def setPointSourceNumberOfPoints(self, points):
96     """
97     Set the number of points to generate within the sphere (the larger the
98     number of points, the more streamlines are generated)
99    
100     @type points: Number
101     @param points: Number of points to generate
102     """
103    
104     self.__vtk_point_source.SetNumberOfPoints(points)
105    
106 jongui 1148 def _getPointSourceOutput(self):
107 ksteube 1147 """
108     Return the output of the point source.
109    
110     @rtype: vtkPolyData
111     @return: Polygonal data
112     """
113    
114     return self.__vtk_point_source.GetOutput()
115    
116 jongui 1148 def _isPointSourceCenterSet(self):
117 ksteube 1147 """
118 jongui 1148 Return whether the center has been specified.
119 ksteube 1147
120 jongui 1148 @rtype: Boolean
121     @return: True or False
122 ksteube 1147 """
123    
124 jongui 1148 if(self.__center != None):
125     return True
126     else:
127     return False
128 ksteube 1147
129    
130     ##############################################################################
131    
132    
133     class MaskPoints:
134     """
135 jongui 1211 Class that defines the masking of points
136 ksteube 1147 every n'th point. This is useful to prevent the rendered object
137     from being cluttered with arrows or ellipsoids.
138     """
139    
140 jongui 1148 def __init__(self):
141 ksteube 1147 """
142     Initialise the mask points.
143     """
144    
145     self.__vtk_mask_points = vtk.vtkMaskPoints()
146    
147 jongui 1148 def _setupMaskPoints(self, object):
148 ksteube 1147 """
149     Setup the mask points.
150 jongui 1148
151     @type object: vtkDataSet (i.e. vtkUnstructuredGrid, etc)
152     @param object: Data source from which to mask points
153 ksteube 1147 """
154    
155 jongui 1148 self.__object = object
156 ksteube 1147 self.__setInput()
157    
158     def __setInput(self):
159     """
160     Set the input for the mask points.
161     """
162    
163     self.__vtk_mask_points.SetInput(self.__object)
164    
165     def setRatio(self, ratio):
166     """
167 jongui 1199 Mask every n'th point.
168 ksteube 1147
169     @type ratio: Number
170     @param ratio: Masking ratio
171     """
172    
173     self.__vtk_mask_points.SetOnRatio(ratio)
174    
175     def randomOn(self):
176     """
177     Enables the randomization of the points selected for masking.
178     """
179    
180     self.__vtk_mask_points.RandomModeOn()
181    
182     def randomOff(self):
183     """
184     Disables the randomization of the points selected for masking.
185     """
186    
187     self.__vtk_mask_points.RandomModeOff()
188    
189 jongui 1148 def _getMaskPointsOutput(self):
190 ksteube 1147 """
191     Return the output of the masked points.
192    
193     @rtype: vtkPolyData
194     @return: Polygonal datda
195     """
196    
197     return self.__vtk_mask_points.GetOutput()
198    
199    

  ViewVC Help
Powered by ViewVC 1.1.26