/[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 1029 - (show annotations)
Wed Mar 14 05:01:13 2007 UTC (12 years, 5 months ago) by jongui
File MIME type: text/x-python
File size: 3033 byte(s)
Fixed problems in relation to updates propagating when multiple files/sources are read.
1 """
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 def __init__(self, transform):
14 """
15 Initialise the plane.
16
17 @type transform: L{Transform <transform.Transform>} object
18 @param transform: Specifies the orientation of the plane
19 """
20
21 self.__transform = transform
22 self.__vtk_plane = vtk.vtkPlane()
23 self.__setupPlane()
24
25 def __setupPlane(self):
26 """
27 Setup the plane.
28 """
29
30 # 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.
85 """
86
87 self.__vtk_plane_source = vtk.vtkPlaneSource()
88 self.__setOrigin(GlobalPosition(0, 0, 0))
89 self.setPoint1(GlobalPosition(1, 0, 0))
90 self.setPoint2(GlobalPosition(0, 1, 0))
91
92 def __setOrigin(self, position):
93 """
94 Set the origin of the plane source.
95
96 @type position: L{GlobalPosition <position.GlobalPosition>} object
97 @param position: Plane source origin
98 """
99
100 self.__vtk_plane_source.SetOrigin(position._getGlobalPosition())
101
102 def setPoint1(self, position):
103 """
104 Set the first point from the origin of the plane source.
105
106 @type position: L{GlobalPosition <position.GlobalPosition>} object
107 @param position: Position of the first axis of the plane source
108 """
109
110 self.__vtk_plane_source.SetPoint1(position._getGlobalPosition())
111
112 def setPoint2(self, position):
113 """
114 Set the second point from the origin of the plane source.
115
116 @type position: L{GlobalPosition <position.GlobalPosition>} object
117 @param position: Position of the second axis of the plane source
118 """
119
120 self.__vtk_plane_source.SetPoint2(position._getGlobalPosition())
121
122
123 def _getOutput(self):
124 """
125 Return the output of the plane source.
126
127 @rtype: vtkPolyData
128 @return: Polygonal data
129 """
130
131 return self.__vtk_plane_source.GetOutput()
132

  ViewVC Help
Powered by ViewVC 1.1.26