/[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 1197 - (show annotations)
Mon Jun 18 02:08:34 2007 UTC (12 years, 2 months ago) by jongui
File MIME type: text/x-python
File size: 3866 byte(s)
Update the way movies are generated. Please refer to the examples. 

The user can now either specify the image range(first and last images inclusive):
mov.imageRange(input_directory = PYVISI_EXAMPLE_IMAGES_PATH,
        first_image = IMAGE_NAME + "000938.jpg",
		last_image = IMAGE_NAME + "000948.jpg")
mov.makeMovie(os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, "movie.mpg"))

or the user can specify a list of images:

lst = ['image1.jpg', 'image5.jpg', 'image7.jpg]
mov.imageList(input_directory = PYVISI_EXAMPLE_IMAGES_PATH, image_list = lst)
mov.makeMovie(os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, "movie.mpg"))


1 """
2 @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 """
9
10 __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 import vtk
22 from position import GlobalPosition
23
24 class Plane:
25 """
26 Class that defines a plane that cuts/clips rendered objects.
27 """
28
29 def __init__(self):
30 """
31 Initialise the plane.
32 """
33
34 self.__vtk_plane = vtk.vtkPlane()
35
36 def _setupPlane(self, transform):
37 """
38 Setup the plane.
39
40 @type transform: L{Transform <transform.Transform>} object
41 @param transform: Specifies the orientation of the plane
42 """
43
44 self.__transform = transform
45
46 # 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 and two other points, which form the axes. By default the origin is
101 set to (0, 0, 0) and the two points are set to (1, 0, 0) and (0, 1, 0).
102 """
103
104 self.__vtk_plane_source = vtk.vtkPlaneSource()
105 # Default origin of the plane source is (0, 0, 0).
106 self.__setOrigin(GlobalPosition(0, 0, 0))
107 # Default position of the two point from the origin is (1, 0, 0) and
108 # (0, 1, 0).
109 self.setPoint1(GlobalPosition(1, 0, 0))
110 self.setPoint2(GlobalPosition(0, 1, 0))
111
112 def __setOrigin(self, position):
113 """
114 Set the origin of the plane source.
115
116 @type position: L{GlobalPosition <position.GlobalPosition>} object
117 @param position: Plane source origin
118 """
119
120 self.__vtk_plane_source.SetOrigin(position._getGlobalPosition())
121
122 def setPoint1(self, position):
123 """
124 Set the first point from the origin of the plane source.
125
126 @type position: L{GlobalPosition <position.GlobalPosition>} object
127 @param position: Position of the first axis of the plane source
128 """
129
130 self.__vtk_plane_source.SetPoint1(position._getGlobalPosition())
131
132 def setPoint2(self, position):
133 """
134 Set the second point from the origin of the plane source.
135
136 @type position: L{GlobalPosition <position.GlobalPosition>} object
137 @param position: Position of the second axis of the plane source
138 """
139
140 self.__vtk_plane_source.SetPoint2(position._getGlobalPosition())
141
142 def _getPlaneSourceOutput(self):
143 """
144 Return the output of the plane source.
145
146 @rtype: vtkPolyData
147 @return: Polygonal data
148 """
149
150 return self.__vtk_plane_source.GetOutput()
151

  ViewVC Help
Powered by ViewVC 1.1.26