/[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 948 - (show annotations)
Thu Feb 1 07:23:34 2007 UTC (12 years, 2 months ago) by jongui
File MIME type: text/x-python
File size: 1945 byte(s)
fixed some bugs in pyvisi and added more epydocs.
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 through 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.
84 """
85
86 self.__vtk_plane_source = vtk.vtkPlaneSource()
87
88 def _getOutput(self):
89 """
90 Return the output of the plance source.
91
92 @rtype: vtkPolyData
93 @return: Polygonal data
94 """
95
96 return self.__vtk_plane_source.GetOutput()
97
98

  ViewVC Help
Powered by ViewVC 1.1.26