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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1809 - (show annotations)
Thu Sep 25 06:43:44 2008 UTC (11 years, 2 months ago) by ksteube
File MIME type: text/x-python
File size: 4465 byte(s)
Copyright updated in all python files

1
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 """
23 @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 """
30
31 __author__="John Ngui, john.ngui@uq.edu.au"
32
33
34 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 def __init__(self):
44 """
45 Initialise the point source.
46 """
47
48 self.__vtk_point_source = vtk.vtkPointSource()
49 self.__center = None
50
51 def _setupPointSource(self, object):
52 """
53 Setup the point source.
54
55 @type object: vtkPolyData, etc
56 @param object: Used to define the location of the sphere
57 """
58
59 self.__object = object
60
61 # 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 # This method is used to delay the execution of setting the point source
77 # center.
78 def setPointSourceCenter(self, center):
79 """
80 Specity the sphere's center.
81
82 @type center: L{GLobalPosition <position.GlobalPosition>} object
83 @param center: Center of the sphere
84 """
85
86 self.__center = center
87
88 def _setPointSourceCenter(self):
89 """
90 Set the sphere's center.
91 """
92
93 self.__vtk_point_source.SetCenter(self.__center._getGlobalPosition())
94
95 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 def _getPointSourceOutput(self):
107 """
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 def _isPointSourceCenterSet(self):
117 """
118 Return whether the center has been specified.
119
120 @rtype: Boolean
121 @return: True or False
122 """
123
124 if(self.__center != None):
125 return True
126 else:
127 return False
128
129
130 ##############################################################################
131
132
133 class MaskPoints:
134 """
135 Class that defines the masking of points
136 every n'th point. This is useful to prevent the rendered object
137 from being cluttered with arrows or ellipsoids.
138 """
139
140 def __init__(self):
141 """
142 Initialise the mask points.
143 """
144
145 self.__vtk_mask_points = vtk.vtkMaskPoints()
146
147 def _setupMaskPoints(self, object):
148 """
149 Setup the mask points.
150
151 @type object: vtkDataSet (i.e. vtkUnstructuredGrid, etc)
152 @param object: Data source from which to mask points
153 """
154
155 self.__object = object
156 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 Mask every n'th point.
168
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 def _getMaskPointsOutput(self):
190 """
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