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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 852 - (show annotations)
Wed Sep 20 03:23:16 2006 UTC (14 years, 10 months ago) by jongui
File MIME type: text/x-python
File size: 1819 byte(s)
added carpet and isosurface


1 """
2 @author: John Ngui
3 @author: Lutz Gross
4 """
5
6 import vtk
7 from common import Common
8
9 class Image(Common):
10 """
11 Class that displays an image.
12 """
13
14 def __init__(self, scene, format):
15 """
16 @type scene: L{Scene <scene.Scene>} object
17 @param scene: Scene in which components are to be added to
18 @type format: String
19 @param format: Format of the image (i.e. jpg)
20 """
21
22 Common.__init__(self, scene)
23 self.vtk_image_reader = self.getImageReader(format)
24 self.vtk_texture = vtk.vtkTexture()
25
26 def getImageReader(self, format):
27 """
28 Determines the image format and returns the corresponding image reader.
29
30 @type format: String
31 @param format: Format of the image (i.e. jpg)
32 @rtype: vtkImageReader2 (i.e. vtkJPEGReader)
33 @return: VTK image reader
34 """
35
36 if(format == "jpeg"):
37 return vtk.vtkJPEGReader()
38 elif(format == "bmp"):
39 return vtk.vtkBMPReader()
40 elif(format == "pnm"):
41 return vtk.vtkPNMReader()
42 elif(format == "png"):
43 return vtk.vtkPNGReader()
44 elif(format == "tiff"):
45 return vtk.vtkTIFFReader()
46
47 def setFileName(self, file_name):
48 """
49 Set the file name, and setup the mapper as well as the actor.
50
51 @type file_name: String
52 @param file_name: Image file name
53 """
54
55 vtk_plane = vtk.vtkPlaneSource()
56 self.vtk_image_reader.SetFileName(file_name)
57
58 self.setTexture()
59 #self.setPlane()
60
61 Common.setMapperInput(self, vtk_plane.GetOutput())
62 Common.setMapperTexture(self, self.vtk_texture)
63 Common.setActorInput(self)
64 Common.addActor(self)
65
66 def setTexture(self):
67 """
68 Set the texture map.
69 """
70
71 self.vtk_texture.SetInput(self.vtk_image_reader.GetOutput())
72
73 # def setPlane(self):
74 """
75 Set the texture coordinates (generated from the plane), which controls
76 the positioning of the texture on a surface.
77 """
78
79 #self.vtk_plane = vtk.vtkPlaneSource()
80
81
82

  ViewVC Help
Powered by ViewVC 1.1.26