/[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 943 - (hide annotations)
Mon Jan 29 07:22:43 2007 UTC (14 years, 2 months ago) by jongui
File MIME type: text/x-python
File size: 1981 byte(s)
new pyvisi files
1 jongui 943 """
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 meshes.
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 rendered 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     #self.__setOrigin(GlobalPosition(center[0], center[1], center[2]))
33     # Default normal of the plane is parrallel to the z-axis.
34     self.__setNormal(GlobalPosition(0, 0, 1))
35     #self.__setNormal(GlobalPosition(center[0], center[1], center[2]*1000))
36     self.__setTransform()
37    
38     def __setOrigin(self, position):
39     """
40     Set the origin of the plane.
41    
42     @type position: L{GlobalPosition <position.GlobalPosition>} object
43     @param position: Origin of the plane
44     """
45     self.__vtk_plane.SetOrigin(position._getGlobalPosition())
46    
47     def __setNormal(self, position):
48     """
49     Set the normal of the plane.
50    
51     @type position: L{GlobalPosition <position.GlobalPosition>} object
52     @param position: Normal of the plane
53     """
54    
55     self.__vtk_plane.SetNormal(position._getGlobalPosition())
56    
57     def __setTransform(self):
58     """
59     Set the transformation to the plane.
60     """
61    
62     self.__vtk_plane.SetTransform(self.__transform)
63    
64     def _getPlane(self):
65     """
66     Return the plane.
67    
68     @rtype: vtkPlane
69     @return: Plane that cuts through meshes
70     """
71    
72     return self.__vtk_plane
73    
74    
75     class PlaneSource:
76     """
77     Class that defines a plane source.
78     """
79    
80     def __init__(self):
81     """
82     Initialise the plane source.
83     """
84    
85     self.__vtk_plane_source = vtk.vtkPlaneSource()
86    
87     def _getOutput(self):
88     """
89     Return the plance source.
90    
91     @rtype: vtkPolyData
92     @return: Polygonal data
93     """
94    
95     return self.__vtk_plane_source.GetOutput()
96    
97    

  ViewVC Help
Powered by ViewVC 1.1.26