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): |
13 |
""" |
14 |
Initialise the tube. |
15 |
""" |
16 |
|
17 |
self.__vtk_tube = vtk.vtkTubeFilter() |
18 |
|
19 |
def _setupTube(self, object): |
20 |
""" |
21 |
Setup the tube. |
22 |
""" |
23 |
|
24 |
self.__setInput(object) |
25 |
# Default radius of the tube is 0.02. |
26 |
self.setTubeRadius(0.02) |
27 |
# Default number of sides for the tube is 12. |
28 |
self.setTubeNumberOfSides(12) |
29 |
self.setTubeRadiusToVaryByVector() |
30 |
|
31 |
def __setInput(self, object): |
32 |
""" |
33 |
Set the input for the tube. |
34 |
|
35 |
@type object: vtkPolyData, etc |
36 |
@param object: Input for the tube |
37 |
""" |
38 |
|
39 |
self.__vtk_tube.SetInput(object) |
40 |
|
41 |
def setTubeRadius(self, radius): |
42 |
""" |
43 |
Set the radius of the tube. |
44 |
|
45 |
@type radius: Number |
46 |
@param radius: Radius of the tube |
47 |
""" |
48 |
|
49 |
self.__vtk_tube.SetRadius(radius) |
50 |
|
51 |
def setTubeNumberOfSides(self, sides): |
52 |
""" |
53 |
Set the number of sides for the tube. Minimum number of sides is 3. |
54 |
The larger the number of sides, the higher the quality. |
55 |
|
56 |
@type sides: Number |
57 |
@param sides: Number of sides for the tube |
58 |
""" |
59 |
|
60 |
self.__vtk_tube.SetNumberOfSides(sides) |
61 |
|
62 |
def setTubeRadiusToVaryByVector(self): |
63 |
""" |
64 |
Set the radius to vary by vector data. |
65 |
""" |
66 |
|
67 |
self.__vtk_tube.SetVaryRadiusToVaryRadiusByVector() |
68 |
|
69 |
def setTubeRadiusToVaryByScalar(self): |
70 |
""" |
71 |
Set the radius to vary by scalar data. |
72 |
""" |
73 |
|
74 |
self.__vtk_tube.SetVaryRadiusToVaryRadiusByScalar() |
75 |
|
76 |
def _getTubeOutput(self): |
77 |
""" |
78 |
Return the output of the tube. |
79 |
|
80 |
@rtype: vtkPolyData |
81 |
@return: Polygonal data |
82 |
""" |
83 |
|
84 |
return self.__vtk_tube.GetOutput() |