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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1148 - (show annotations)
Wed May 16 22:45:33 2007 UTC (12 years, 9 months ago) by jongui
File MIME type: text/x-python
File size: 1279 byte(s)
Added the updated files for pyvisi and removed some incorrect reference images.
1 """
2 @author: John NGUI
3 """
4
5 import vtk
6 from constant import WarpMode
7
8 class Warp:
9 """
10 Class that defines the deformation of a scalar field.
11 """
12
13 def __init__(self, warp_mode):
14 """
15 Initialise the warp scalar/vector.
16
17 @type warp_mode: L{WarpMode <constant.WarpMode>} constant
18 @param warp_mode: Mode in which to deform the data
19 """
20
21 if(warp_mode == WarpMode.SCALAR): # Deform data with scalar data.
22 self.__vtk_warp = vtk.vtkWarpScalar()
23 elif(warp_mode == WarpMode.VECTOR): # Deform data with vector data.
24 self.__vtk_warp = vtk.vtkWarpVector()
25
26 def _setupWarp(self, object):
27 """
28 Setup the warp.
29
30 @type object: vtkPolyData, etc
31 @param object: Input for the warp scalar/vector
32 """
33
34 self.__object = object
35 self.__setInput()
36
37 def __setInput(self):
38 """
39 Set the input for the warp scalar/vector.
40 """
41
42 self.__vtk_warp.SetInput(self.__object)
43
44 def setScaleFactor(self, scale_factor):
45 """
46 Set the displacement scale factor.
47
48 @type scale_factor: Number
49 @param scale_factor: Scale factor of the displacement
50 """
51
52 self.__vtk_warp.SetScaleFactor(scale_factor)
53
54 def _getWarpOutput(self):
55 """
56 Return the output of the deformed data.
57
58 @rtype: vtkPointSet
59 @return: PointSet data
60 """
61
62 return self.__vtk_warp.GetOutput()
63

  ViewVC Help
Powered by ViewVC 1.1.26