1 |
""" |
2 |
@var __author__: name of author |
3 |
@var __copyright__: copyrights |
4 |
@var __license__: licence agreement |
5 |
@var __url__: url entry point on documentation |
6 |
@var __version__: version |
7 |
@var __date__: date of the version |
8 |
""" |
9 |
|
10 |
__author__="John Ngui, john.ngui@uq.edu.au" |
11 |
__copyright__=""" Copyright (c) 2006 by ACcESS MNRF |
12 |
http://www.access.edu.au |
13 |
Primary Business: Queensland, Australia""" |
14 |
__license__="""Licensed under the Open Software License version 3.0 |
15 |
http://www.opensource.org/licenses/osl-3.0.php""" |
16 |
__url__="http://www.iservo.edu.au/esys" |
17 |
__version__="$Revision$" |
18 |
__date__="$Date$" |
19 |
|
20 |
|
21 |
import vtk |
22 |
|
23 |
class Glyph3D: |
24 |
""" |
25 |
Class that defines 3D glyphs. |
26 |
""" |
27 |
|
28 |
def __init__(self): |
29 |
""" |
30 |
Initialise the 3D glyph. |
31 |
""" |
32 |
|
33 |
self.__vtk_glyph3D = vtk.vtkGlyph3D() |
34 |
|
35 |
def _setupGlyph3D(self, object, source): |
36 |
""" |
37 |
Setup the 3D glyph. |
38 |
|
39 |
@type object: vtkDataSet, etc |
40 |
@param object: Input for the 3D glyph |
41 |
@type source: vtkPolyData |
42 |
@param source: Source for the 3D glyph (i.e. Arrow2D, Arrow3D, etc) |
43 |
""" |
44 |
|
45 |
self.__object = object |
46 |
self.__source = source |
47 |
|
48 |
self.__setInput() |
49 |
self.__setSource() |
50 |
self.setScaleModeByVector() |
51 |
self.__setVectorModeByVector() |
52 |
self.__setClampingOn() |
53 |
|
54 |
self.__setScalingOn() |
55 |
self.__setOrientOn() |
56 |
|
57 |
def __setInput(self): |
58 |
""" |
59 |
Set the input for the 3D glyph. |
60 |
""" |
61 |
|
62 |
self.__vtk_glyph3D.SetInput(self.__object) |
63 |
|
64 |
def __setSource(self): |
65 |
""" |
66 |
Set the source for the 3D glyph. |
67 |
""" |
68 |
|
69 |
self.__vtk_glyph3D.SetSource(self.__source) |
70 |
|
71 |
def setScaleModeByVector(self): |
72 |
""" |
73 |
Set the 3D glyph to scale according to the vector. |
74 |
""" |
75 |
|
76 |
self.__vtk_glyph3D.SetScaleModeToScaleByVector() |
77 |
|
78 |
def setScaleModeByScalar(self): |
79 |
""" |
80 |
Set the 3D glyph to scale according to the scalar. |
81 |
""" |
82 |
|
83 |
self.__vtk_glyph3D.SetScaleModeToScaleByScalar() |
84 |
|
85 |
def _setColorModeByVector(self): |
86 |
""" |
87 |
Set the 3D glyph to color according to the vector. |
88 |
""" |
89 |
|
90 |
self.__vtk_glyph3D.SetColorModeToColorByVector() |
91 |
|
92 |
def _setColorModeByScalar(self): |
93 |
""" |
94 |
Set the 3D glyph to color according to the scalar. |
95 |
""" |
96 |
|
97 |
self.__vtk_glyph3D.SetColorModeToColorByScalar() |
98 |
|
99 |
def __setVectorModeByVector(self): |
100 |
""" |
101 |
Set the 3D glyph vector mode according to the vector. |
102 |
""" |
103 |
|
104 |
self.__vtk_glyph3D.SetVectorModeToUseVector() |
105 |
|
106 |
def setScaleFactor(self, scale_factor): |
107 |
""" |
108 |
Set the 3D glyph scale factor. |
109 |
|
110 |
@type scale_factor: Number |
111 |
@param scale_factor: Scale factor |
112 |
""" |
113 |
|
114 |
self.__vtk_glyph3D.SetScaleFactor(scale_factor) |
115 |
|
116 |
def __setClampingOn(self): |
117 |
""" |
118 |
Enable clamping of "scalar" values to range. |
119 |
""" |
120 |
|
121 |
self.__vtk_glyph3D.SetClamping(1) |
122 |
|
123 |
def __setScalingOn(self): |
124 |
""" |
125 |
Enable the scaling of the rendered object. |
126 |
""" |
127 |
|
128 |
self.__vtk_glyph3D.ScalingOn() |
129 |
|
130 |
def __setOrientOn(self): |
131 |
""" |
132 |
Enable the orientation of the rendered object along the vector/normal. |
133 |
""" |
134 |
|
135 |
self.__vtk_glyph3D.OrientOn() |
136 |
|
137 |
def _setRange(self, range): |
138 |
""" |
139 |
Set the range to map scalar values. |
140 |
|
141 |
@type range: Two column tuple containing numbers |
142 |
@param range: Range to map scalar values |
143 |
""" |
144 |
|
145 |
self.__vtk_glyph3D.SetRange(range) |
146 |
|
147 |
def _getGlyph3D(self): |
148 |
""" |
149 |
Return the 3D glyph. |
150 |
|
151 |
@rtype: vtkGlyph3D |
152 |
@return: 3D glyph |
153 |
""" |
154 |
|
155 |
return self.__vtk_glyph3D |
156 |
|
157 |
def _getGlyph3DOutput(self): |
158 |
""" |
159 |
Return the output of the 3D glyph. |
160 |
|
161 |
@rtype: vtkPolyData |
162 |
@return Polygonal data |
163 |
""" |
164 |
|
165 |
return self.__vtk_glyph3D.GetOutput() |
166 |
|
167 |
|
168 |
############################################################################### |
169 |
|
170 |
|
171 |
class TensorGlyph: |
172 |
""" |
173 |
Class that defines tensor glyphs. |
174 |
""" |
175 |
|
176 |
def __init__(self): |
177 |
""" |
178 |
Initialise the tensor glyph. |
179 |
""" |
180 |
|
181 |
self.__vtk_tensor_glyph = vtk.vtkTensorGlyph() |
182 |
|
183 |
def _setupTensorGlyph(self, object, source): |
184 |
""" |
185 |
Setup the tensor glyph. |
186 |
|
187 |
@type object: vtkDataSet, etc |
188 |
@param object: Input for the 3D glyph |
189 |
@type source: vtkPolyData |
190 |
@param source: Source for the 3D glyph (i.e. Sphere, etc) |
191 |
""" |
192 |
|
193 |
self.__object = object |
194 |
self.__source = source |
195 |
|
196 |
self.__setInput() |
197 |
self.__setSource() |
198 |
self.__vtk_tensor_glyph.ClampScalingOn() |
199 |
|
200 |
def __setInput(self): |
201 |
""" |
202 |
Set the input for the tensor glyph. |
203 |
""" |
204 |
|
205 |
self.__vtk_tensor_glyph.SetInput(self.__object) |
206 |
|
207 |
def __setSource(self): |
208 |
""" |
209 |
Set the source for the tensor glyph. |
210 |
""" |
211 |
|
212 |
self.__vtk_tensor_glyph.SetSource(self.__source) |
213 |
|
214 |
def setScaleFactor(self, scale_factor): |
215 |
""" |
216 |
Set the scale factor for the tensor glyph. |
217 |
|
218 |
@type scale_factor: Number |
219 |
@param scale_factor: Scale factor |
220 |
""" |
221 |
|
222 |
self.__vtk_tensor_glyph.SetScaleFactor(scale_factor) |
223 |
|
224 |
def setMaxScaleFactor(self, max_scale_factor): |
225 |
""" |
226 |
Set the maximum allowable scale factor for the tensor glyph. |
227 |
|
228 |
@type max_scale_factor: Number |
229 |
@param max_scale_factor: Maximum allowable scale factor. |
230 |
""" |
231 |
|
232 |
self.__vtk_tensor_glyph.SetMaxScaleFactor(max_scale_factor) |
233 |
|
234 |
def _getTensorGlyphOutput(self): |
235 |
""" |
236 |
Return the output of the tensor glyph. |
237 |
|
238 |
@rtype: vtkPolyData |
239 |
@return: Polygonal data |
240 |
""" |
241 |
|
242 |
return self.__vtk_tensor_glyph.GetOutput() |
243 |
|