1 |
gross |
792 |
""" |
2 |
jongui |
839 |
@author: John Ngui |
3 |
|
|
@author: Lutz Gross |
4 |
gross |
792 |
""" |
5 |
|
|
|
6 |
jongui |
835 |
class Position: |
7 |
|
|
""" |
8 |
jongui |
839 |
Class that defines the positioning of components in the visualization. |
9 |
jongui |
835 |
""" |
10 |
gross |
792 |
|
11 |
jongui |
835 |
def __init__(self, x_coor, y_coor, z_coor): |
12 |
|
|
""" |
13 |
|
|
Initialize the x,y and z coordinates. |
14 |
gross |
792 |
|
15 |
jongui |
835 |
@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 |
gross |
792 |
|
27 |
jongui |
835 |
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 |
|
|
|
57 |
jongui |
845 |
from common import * |
58 |
jongui |
835 |
|
59 |
jongui |
845 |
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 = None |
77 |
|
|
self.vtk_cutter = None |
78 |
|
|
self.setPlane() |
79 |
|
|
self.setCutter(component) |
80 |
|
|
|
81 |
|
|
Common.setMapper(self, "self.vtk_cutter.GetOutput()") |
82 |
|
|
Common.setActor(self) |
83 |
|
|
Common.addActor(self) |
84 |
|
|
|
85 |
|
|
def setPlane(self): |
86 |
|
|
""" |
87 |
|
|
Setup the plane. |
88 |
|
|
""" |
89 |
|
|
|
90 |
|
|
self.vtk_plane = vtk.vtkPlane() |
91 |
|
|
# Default origin |
92 |
|
|
#self.vtk_plane.SetOrigin( |
93 |
|
|
#self.data_collector.getReader().GetOutput().GetCenter()) |
94 |
|
|
self.vtk_plane.SetOrigin(0,0,0) |
95 |
|
|
# Default normal |
96 |
|
|
self.vtk_plane.SetNormal(-1.2, 0.0, 0.9) |
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 = vtk.vtkCutter() |
136 |
|
|
eval("self.vtk_cutter.SetInput(%s)" % component) |
137 |
|
|
self.vtk_cutter.SetCutFunction(self.vtk_plane) |
138 |
|
|
|
139 |
|
|
#def Plane(object): |
140 |
jongui |
835 |
""" |
141 |
jongui |
845 |
A plane in global coordinates |
142 |
jongui |
835 |
""" |
143 |
|
|
pass |
144 |
|
|
|
145 |
gross |
792 |
def Origin(Position): |
146 |
|
|
""" |
147 |
|
|
The position of the origin |
148 |
|
|
""" |
149 |
|
|
pass |
150 |
|
|
|
151 |
|
|
def Direction(object): |
152 |
|
|
""" |
153 |
|
|
A dirction in global coordinates |
154 |
|
|
""" |
155 |
|
|
pass |
156 |
|
|
|
157 |
|
|
def XAxis(Direction): |
158 |
|
|
""" |
159 |
|
|
The direction of the x-axis |
160 |
|
|
""" |
161 |
|
|
pass |
162 |
|
|
|
163 |
|
|
def YAxis(Direction): |
164 |
|
|
""" |
165 |
|
|
The direction of the y-axis |
166 |
|
|
""" |
167 |
|
|
pass |
168 |
|
|
|
169 |
|
|
def ZAxis(Direction): |
170 |
|
|
""" |
171 |
|
|
The direction of the z-axis |
172 |
|
|
""" |
173 |
|
|
pass |
174 |
|
|
|
175 |
|
|
|
176 |
|
|
def XYPlane(Plane): |
177 |
|
|
""" |
178 |
|
|
The XY plane orthogonal to the z-axis |
179 |
|
|
""" |
180 |
|
|
pass |
181 |
|
|
|
182 |
|
|
def YZPlane(Plane): |
183 |
|
|
""" |
184 |
|
|
The YZ plane orthogonal to the x-axis |
185 |
|
|
""" |
186 |
|
|
pass |
187 |
|
|
|
188 |
|
|
def ZXPlane(Plane): |
189 |
|
|
""" |
190 |
|
|
The ZX plane orthogonal to the y-axis |
191 |
|
|
""" |
192 |
|
|
pass |
193 |
|
|
|
194 |
|
|
def Sphere(object): |
195 |
|
|
""" |
196 |
|
|
A sphere |
197 |
|
|
""" |
198 |
|
|
pass |
199 |
|
|
|