1 |
""" |
2 |
@author: John Ngui |
3 |
@author: Lutz Gross |
4 |
""" |
5 |
|
6 |
class Position: |
7 |
""" |
8 |
Class that defines the positioning of components in the visualization. |
9 |
""" |
10 |
|
11 |
def __init__(self, x_coor, y_coor, z_coor): |
12 |
""" |
13 |
Initialize the x,y and z coordinates. |
14 |
|
15 |
@type x_coor: Number |
16 |
@param x_coor: X coordinate in global position |
17 |
@type y_coor: Number |
18 |
@param y_coor: Y coordinate in global position |
19 |
@type z_coor: Number |
20 |
@param z_coor: Z coordinate in global position |
21 |
""" |
22 |
|
23 |
self.x_coor = x_coor |
24 |
self.y_coor = y_coor |
25 |
self.z_coor = z_coor |
26 |
|
27 |
def getXCoor(self): |
28 |
""" |
29 |
Return the x coordinate. |
30 |
|
31 |
@rtype: Number |
32 |
@return: X coordinate |
33 |
""" |
34 |
return self.x_coor |
35 |
|
36 |
def getYCoor(self): |
37 |
""" |
38 |
Return the y coordinate. |
39 |
|
40 |
@rtype: Number |
41 |
@return: Y coordiante |
42 |
""" |
43 |
|
44 |
return self.y_coor |
45 |
|
46 |
def getZCoor(self): |
47 |
""" |
48 |
Return the z coordinate |
49 |
|
50 |
@rtype: Number |
51 |
@return: Z coordinate |
52 |
""" |
53 |
|
54 |
return self.z_coor |
55 |
|
56 |
import vtk |
57 |
from common import Common |
58 |
|
59 |
class Plane(Common): |
60 |
""" |
61 |
Class that performs cutting using a plane as its implicit function. |
62 |
""" |
63 |
|
64 |
def __init__(self, scene, data_collector, component): |
65 |
""" |
66 |
@type scene: L{Scene <scene.Scene>} object |
67 |
@param scene: Scene in which components are to be added to |
68 |
@type data_collector: L{DataCollector <datacollector.DataCollector>} |
69 |
object |
70 |
@param data_collector: Source of data for visualization |
71 |
@type component: String |
72 |
@param component: Component to be cut using the plane |
73 |
""" |
74 |
|
75 |
Common.__init__(self, scene, data_collector) |
76 |
self.vtk_plane = vtk.vtkPlane() |
77 |
self.vtk_cutter = vtk.vtkCutter() |
78 |
self.setPlane() |
79 |
self.setCutter(component) |
80 |
|
81 |
Common.setMapperInput(self, self.vtk_cutter.GetOutput()) |
82 |
Common.setActorInput(self) |
83 |
Common.addActor(self) |
84 |
|
85 |
def setPlane(self): |
86 |
""" |
87 |
Setup the plane. |
88 |
""" |
89 |
|
90 |
# Default origin |
91 |
#self.vtk_plane.SetOrigin( |
92 |
#self.data_collector.getReader().GetOutput().GetCenter()) |
93 |
self.setPlaneOrigin(0,0,0) |
94 |
# Default normal |
95 |
self.setPlaneNormal(-1.2, 0.0, 0.9) |
96 |
#self.setPlaneNormal(1,0,1) |
97 |
|
98 |
|
99 |
def setPlaneOrigin(self, x_coor, y_coor, z_coor): |
100 |
""" |
101 |
Set the plane origin. |
102 |
|
103 |
@type x_coor: Number |
104 |
@param x_coor: X coordinate in global position |
105 |
@type y_coor: Number |
106 |
@param y_coor: Y coordinate in global position |
107 |
@type z_coor: Number |
108 |
@param z_coor: Z coordinate in global position |
109 |
""" |
110 |
|
111 |
self.vtk_plane.SetOrigin(x_coor, y_coor, z_coor) |
112 |
|
113 |
def setPlaneNormal(self, x_coor, y_coor, z_coor): |
114 |
""" |
115 |
Set the plance normal. |
116 |
|
117 |
@type x_coor: Number |
118 |
@param x_coor: X coordinate in global position |
119 |
@type y_coor: Number |
120 |
@param y_coor: Y coordinate in global position |
121 |
@type z_coor: Number |
122 |
@param z_coor: Z coordinate in global position |
123 |
""" |
124 |
|
125 |
self.vtk_plane.SetNormal(x_coor, y_coor, z_coor) |
126 |
|
127 |
def setCutter(self, component): |
128 |
""" |
129 |
Setup the cutter |
130 |
|
131 |
@type component: String |
132 |
@param component: Component to be cut using the plane |
133 |
""" |
134 |
|
135 |
self.vtk_cutter.SetInput(component) |
136 |
self.vtk_cutter.SetCutFunction(self.vtk_plane) |
137 |
|
138 |
#def Plane(object): |
139 |
""" |
140 |
A plane in global coordinates |
141 |
""" |
142 |
pass |
143 |
|
144 |
def Origin(Position): |
145 |
""" |
146 |
The position of the origin |
147 |
""" |
148 |
pass |
149 |
|
150 |
def Direction(object): |
151 |
""" |
152 |
A dirction in global coordinates |
153 |
""" |
154 |
pass |
155 |
|
156 |
def XAxis(Direction): |
157 |
""" |
158 |
The direction of the x-axis |
159 |
""" |
160 |
pass |
161 |
|
162 |
def YAxis(Direction): |
163 |
""" |
164 |
The direction of the y-axis |
165 |
""" |
166 |
pass |
167 |
|
168 |
def ZAxis(Direction): |
169 |
""" |
170 |
The direction of the z-axis |
171 |
""" |
172 |
pass |
173 |
|
174 |
|
175 |
def XYPlane(Plane): |
176 |
""" |
177 |
The XY plane orthogonal to the z-axis |
178 |
""" |
179 |
pass |
180 |
|
181 |
def YZPlane(Plane): |
182 |
""" |
183 |
The YZ plane orthogonal to the x-axis |
184 |
""" |
185 |
pass |
186 |
|
187 |
def ZXPlane(Plane): |
188 |
""" |
189 |
The ZX plane orthogonal to the y-axis |
190 |
""" |
191 |
pass |
192 |
|
193 |
def Sphere(object): |
194 |
""" |
195 |
A sphere |
196 |
""" |
197 |
pass |
198 |
|