1 |
""" |
2 |
@author: John NGUI |
3 |
""" |
4 |
|
5 |
import vtk |
6 |
|
7 |
class Tube: |
8 |
""" |
9 |
Class that defines the tube wrapped around the streamlines. |
10 |
""" |
11 |
|
12 |
def __init__(self, object): |
13 |
""" |
14 |
Initialise the tube. |
15 |
""" |
16 |
|
17 |
self.__object = object |
18 |
self.__vtk_tube = vtk.vtkTubeFilter() |
19 |
|
20 |
self.__setupTube() |
21 |
|
22 |
def __setupTube(self): |
23 |
""" |
24 |
Setup the tube. |
25 |
""" |
26 |
|
27 |
self.__setInput() |
28 |
# Default radius of the tube is 0.02. |
29 |
self.setTubeRadius(0.02) |
30 |
# Default number of sides for the tube is 12. |
31 |
self.setTubeNumberOfSides(12) |
32 |
self.setTubeRadiusToVaryByVector() |
33 |
self.__vtk_tube.Update() |
34 |
|
35 |
def __setInput(self): |
36 |
""" |
37 |
Set the input for the tube. |
38 |
""" |
39 |
|
40 |
self.__vtk_tube.SetInput(self.__object) |
41 |
|
42 |
def setTubeRadius(self, radius): |
43 |
""" |
44 |
Set the radius of the tube. |
45 |
|
46 |
@type radius: Number |
47 |
@param radius: Radius of the tube |
48 |
""" |
49 |
|
50 |
self.__vtk_tube.SetRadius(radius) |
51 |
|
52 |
def setTubeNumberOfSides(self, sides): |
53 |
""" |
54 |
Set the number of sides for the tube. Minimum number of sides is 3. |
55 |
The larger the number of sides, the higher the quality. |
56 |
|
57 |
@type sides: Number |
58 |
@param sides: Number of sides for the tube |
59 |
""" |
60 |
|
61 |
self.__vtk_tube.SetNumberOfSides(sides) |
62 |
|
63 |
def setTubeRadiusToVaryByVector(self): |
64 |
""" |
65 |
Set the radius to vary by vector data. |
66 |
""" |
67 |
|
68 |
self.__vtk_tube.SetVaryRadiusToVaryRadiusByVector() |
69 |
|
70 |
def setTubeRadiusToVaryByScalar(self): |
71 |
""" |
72 |
Set the radius to vary by scalar data. |
73 |
""" |
74 |
|
75 |
self.__vtk_tube.SetVaryRadiusToVaryRadiusByScalar() |
76 |
|
77 |
def _getOutput(self): |
78 |
""" |
79 |
Return the output of the tube. |
80 |
|
81 |
@rtype: vtkPolyData |
82 |
@return: Polygonal data |
83 |
""" |
84 |
|
85 |
return self.__vtk_tube.GetOutput() |