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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1809 - (show annotations)
Thu Sep 25 06:43:44 2008 UTC (11 years, 2 months ago) by ksteube
File MIME type: text/x-python
File size: 4276 byte(s)
Copyright updated in all python files

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

  ViewVC Help
Powered by ViewVC 1.1.26