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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1148 - (hide annotations)
Wed May 16 22:45:33 2007 UTC (14 years ago) by jongui
File MIME type: text/x-python
File size: 3261 byte(s)
Added the updated files for pyvisi and removed some incorrect reference images.
1 ksteube 1147 """
2     @author: John NGUI
3     """
4    
5     import vtk
6     from position import GlobalPosition
7    
8     class Plane:
9     """
10     Class that defines a plane that cuts/clips rendered objects.
11     """
12    
13 jongui 1148 def __init__(self):
14 ksteube 1147 """
15     Initialise the plane.
16     """
17    
18     self.__vtk_plane = vtk.vtkPlane()
19    
20 jongui 1148 def _setupPlane(self, transform):
21 ksteube 1147 """
22     Setup the plane.
23 jongui 1148
24     @type transform: L{Transform <transform.Transform>} object
25     @param transform: Specifies the orientation of the plane
26 ksteube 1147 """
27    
28 jongui 1148 self.__transform = transform
29    
30 ksteube 1147 # Default origin of the of the plane is (0,0,0).
31     self.__setOrigin(GlobalPosition(0,0,0))
32     # Default normal of the plane is parrallel to the z-axis.
33     self.__setNormal(GlobalPosition(0, 0, 1))
34     self.__setTransform()
35    
36     def __setOrigin(self, position):
37     """
38     Set the origin of the plane.
39    
40     @type position: L{GlobalPosition <position.GlobalPosition>} object
41     @param position: Origin of the plane
42     """
43     self.__vtk_plane.SetOrigin(position._getGlobalPosition())
44    
45     def __setNormal(self, position):
46     """
47     Set the normal of the plane.
48    
49     @type position: L{GlobalPosition <position.GlobalPosition>} object
50     @param position: Normal of the plane
51     """
52    
53     self.__vtk_plane.SetNormal(position._getGlobalPosition())
54    
55     def __setTransform(self):
56     """
57     Set the transformation of the plane.
58     """
59    
60     self.__vtk_plane.SetTransform(self.__transform)
61    
62     def _getPlane(self):
63     """
64     Return the plane.
65    
66     @rtype: vtkPlane
67     @return: Plane that cuts through rendered objects
68     """
69    
70     return self.__vtk_plane
71    
72    
73     ###############################################################################
74    
75    
76     class PlaneSource:
77     """
78     Class that defines a plane source.
79     """
80    
81     def __init__(self):
82     """
83     Initialise the plane source. A plane source is defined by an origin
84     and two other points, which form the axes. By default the origin is
85     set to (0, 0, 0) and the two points are set to (1, 0, 0) and (0, 1, 0).
86     """
87    
88     self.__vtk_plane_source = vtk.vtkPlaneSource()
89     # Default origin of the plane source is (0, 0, 0).
90     self.__setOrigin(GlobalPosition(0, 0, 0))
91     # Default position of the two point from the origin is (1, 0, 0) and
92     # (0, 1, 0).
93     self.setPoint1(GlobalPosition(1, 0, 0))
94     self.setPoint2(GlobalPosition(0, 1, 0))
95    
96     def __setOrigin(self, position):
97     """
98     Set the origin of the plane source.
99    
100     @type position: L{GlobalPosition <position.GlobalPosition>} object
101     @param position: Plane source origin
102     """
103    
104     self.__vtk_plane_source.SetOrigin(position._getGlobalPosition())
105    
106     def setPoint1(self, position):
107     """
108     Set the first point from the origin of the plane source.
109    
110     @type position: L{GlobalPosition <position.GlobalPosition>} object
111     @param position: Position of the first axis of the plane source
112     """
113    
114     self.__vtk_plane_source.SetPoint1(position._getGlobalPosition())
115    
116     def setPoint2(self, position):
117     """
118     Set the second point from the origin of the plane source.
119    
120     @type position: L{GlobalPosition <position.GlobalPosition>} object
121     @param position: Position of the second axis of the plane source
122     """
123    
124     self.__vtk_plane_source.SetPoint2(position._getGlobalPosition())
125    
126 jongui 1148 def _getPlaneSourceOutput(self):
127 ksteube 1147 """
128     Return the output of the plane source.
129    
130     @rtype: vtkPolyData
131     @return: Polygonal data
132     """
133    
134     return self.__vtk_plane_source.GetOutput()
135    

  ViewVC Help
Powered by ViewVC 1.1.26