/[escript]/trunk/pyvisi/py_src/geo.py
ViewVC logotype

Annotation of /trunk/pyvisi/py_src/geo.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 849 - (hide annotations)
Fri Sep 15 07:11:55 2006 UTC (14 years, 4 months ago) by jongui
File MIME type: text/x-python
File size: 3748 byte(s)
Optimized codes and modularized functions to make it more scalable. Partially 
integrated carpet into the existing modules.  

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 jongui 849 import vtk
57     from common import Common
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 jongui 849 self.vtk_plane = vtk.vtkPlane()
77     self.vtk_cutter = vtk.vtkCutter()
78 jongui 845 self.setPlane()
79     self.setCutter(component)
80    
81 jongui 849 Common.setMapperInput(self, self.vtk_cutter.GetOutput())
82     Common.setActorInput(self)
83 jongui 845 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 jongui 849 self.setPlaneOrigin(0,0,0)
94 jongui 845 # Default normal
95 jongui 849 self.setPlaneNormal(-1.2, 0.0, 0.9)
96     #self.setPlaneNormal(1,0,1)
97 jongui 845
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 jongui 849 self.vtk_cutter.SetInput(component)
136 jongui 845 self.vtk_cutter.SetCutFunction(self.vtk_plane)
137    
138     #def Plane(object):
139 jongui 835 """
140 jongui 845 A plane in global coordinates
141 jongui 835 """
142     pass
143    
144 gross 792 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    

  ViewVC Help
Powered by ViewVC 1.1.26