/[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 1199 - (hide annotations)
Wed Jun 20 05:01:30 2007 UTC (12 years, 2 months ago) by jongui
File MIME type: text/x-python
File size: 3882 byte(s)
- Updated the epydocs and guide.
Deleted redundant files and methods.
Tidied up the codes.
1 ksteube 1147 """
2 jongui 1197 @var __author__: name of author
3     @var __copyright__: copyrights
4     @var __license__: licence agreement
5     @var __url__: url entry point on documentation
6     @var __version__: version
7     @var __date__: date of the version
8 ksteube 1147 """
9    
10 jongui 1197 __author__="John Ngui, john.ngui@uq.edu.au"
11     __copyright__=""" Copyright (c) 2006 by ACcESS MNRF
12     http://www.access.edu.au
13     Primary Business: Queensland, Australia"""
14     __license__="""Licensed under the Open Software License version 3.0
15     http://www.opensource.org/licenses/osl-3.0.php"""
16     __url__="http://www.iservo.edu.au/esys"
17     __version__="$Revision$"
18     __date__="$Date$"
19    
20    
21 ksteube 1147 import vtk
22     from position import GlobalPosition
23    
24     class Plane:
25     """
26 jongui 1199 Class that defines a plane that cuts or clips rendered objects.
27 ksteube 1147 """
28    
29 jongui 1148 def __init__(self):
30 ksteube 1147 """
31     Initialise the plane.
32     """
33    
34     self.__vtk_plane = vtk.vtkPlane()
35    
36 jongui 1148 def _setupPlane(self, transform):
37 ksteube 1147 """
38     Setup the plane.
39 jongui 1148
40     @type transform: L{Transform <transform.Transform>} object
41     @param transform: Specifies the orientation of the plane
42 ksteube 1147 """
43    
44 jongui 1148 self.__transform = transform
45    
46 ksteube 1147 # Default origin of the of the plane is (0,0,0).
47     self.__setOrigin(GlobalPosition(0,0,0))
48     # Default normal of the plane is parrallel to the z-axis.
49     self.__setNormal(GlobalPosition(0, 0, 1))
50     self.__setTransform()
51    
52     def __setOrigin(self, position):
53     """
54     Set the origin of the plane.
55    
56     @type position: L{GlobalPosition <position.GlobalPosition>} object
57     @param position: Origin of the plane
58     """
59     self.__vtk_plane.SetOrigin(position._getGlobalPosition())
60    
61     def __setNormal(self, position):
62     """
63     Set the normal of the plane.
64    
65     @type position: L{GlobalPosition <position.GlobalPosition>} object
66     @param position: Normal of the plane
67     """
68    
69     self.__vtk_plane.SetNormal(position._getGlobalPosition())
70    
71     def __setTransform(self):
72     """
73     Set the transformation of the plane.
74     """
75    
76     self.__vtk_plane.SetTransform(self.__transform)
77    
78     def _getPlane(self):
79     """
80     Return the plane.
81    
82     @rtype: vtkPlane
83     @return: Plane that cuts through rendered objects
84     """
85    
86     return self.__vtk_plane
87    
88    
89     ###############################################################################
90    
91    
92     class PlaneSource:
93     """
94     Class that defines a plane source.
95     """
96    
97     def __init__(self):
98     """
99     Initialise the plane source. A plane source is defined by an origin
100 jongui 1199 and two other points, which form the axes (X and Y). By default the
101     origin is set to (0, 0, 0) and the two points are set to (1, 0, 0)
102     and (0, 1, 0).
103 ksteube 1147 """
104    
105     self.__vtk_plane_source = vtk.vtkPlaneSource()
106     # Default origin of the plane source is (0, 0, 0).
107     self.__setOrigin(GlobalPosition(0, 0, 0))
108     # Default position of the two point from the origin is (1, 0, 0) and
109     # (0, 1, 0).
110     self.setPoint1(GlobalPosition(1, 0, 0))
111     self.setPoint2(GlobalPosition(0, 1, 0))
112    
113     def __setOrigin(self, position):
114     """
115     Set the origin of the plane source.
116    
117     @type position: L{GlobalPosition <position.GlobalPosition>} object
118     @param position: Plane source origin
119     """
120    
121     self.__vtk_plane_source.SetOrigin(position._getGlobalPosition())
122    
123     def setPoint1(self, position):
124     """
125     Set the first point from the origin of the plane source.
126    
127     @type position: L{GlobalPosition <position.GlobalPosition>} object
128     @param position: Position of the first axis of the plane source
129     """
130    
131     self.__vtk_plane_source.SetPoint1(position._getGlobalPosition())
132    
133     def setPoint2(self, position):
134     """
135     Set the second point from the origin of the plane source.
136    
137     @type position: L{GlobalPosition <position.GlobalPosition>} object
138     @param position: Position of the second axis of the plane source
139     """
140    
141     self.__vtk_plane_source.SetPoint2(position._getGlobalPosition())
142    
143 jongui 1148 def _getPlaneSourceOutput(self):
144 ksteube 1147 """
145     Return the output of the plane source.
146    
147     @rtype: vtkPolyData
148     @return: Polygonal data
149     """
150    
151     return self.__vtk_plane_source.GetOutput()
152    

  ViewVC Help
Powered by ViewVC 1.1.26