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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 851 by jongui, Mon Sep 11 07:40:09 2006 UTC revision 852 by jongui, Wed Sep 20 03:23:16 2006 UTC
# Line 4  Line 4 
4  """  """
5    
6  import vtk  import vtk
7  from common import *  from common import Common
8    
9  class Image(Common):  class Image(Common):
10      """      """
# Line 20  class Image(Common): Line 20  class Image(Common):
20          """          """
21    
22          Common.__init__(self, scene)          Common.__init__(self, scene)
23          self.vtk_image_reader = self.determineReader(format)          self.vtk_image_reader = self.getImageReader(format)
24          self.vtk_texture = None          self.vtk_texture = vtk.vtkTexture()
         self.vtk_plane = None  
25    
26      def determineReader(self, format):      def getImageReader(self, format):
27          """          """
28          Determines the image format and returns the corresponding image reader.          Determines the image format and returns the corresponding image reader.
29    
# Line 34  class Image(Common): Line 33  class Image(Common):
33          @return: VTK image reader          @return: VTK image reader
34          """          """
35    
36          if(format == "jpg"):          if(format == "jpeg"):
37              return vtk.vtkJPEGReader()                return vtk.vtkJPEGReader()  
38          elif(format == "bmp"):          elif(format == "bmp"):
39              return vtk.vtkBMPReader()              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):      def setFileName(self, file_name):
48          """          """
# Line 47  class Image(Common): Line 52  class Image(Common):
52          @param file_name: Image file name          @param file_name: Image file name
53          """          """
54    
55            vtk_plane = vtk.vtkPlaneSource()
56          self.vtk_image_reader.SetFileName(file_name)          self.vtk_image_reader.SetFileName(file_name)
57    
58          self.setTexture()          self.setTexture()
59          self.setPlane()          #self.setPlane()
60    
61          Common.setMapper(self, "self.vtk_plane.GetOutput()")          Common.setMapperInput(self, vtk_plane.GetOutput())
62          Common.setActor(self)          Common.setMapperTexture(self, self.vtk_texture)
63          Common.setTexture(self, self.vtk_texture)          Common.setActorInput(self)
64          Common.addActor(self)          Common.addActor(self)
65    
66      def setTexture(self):      def setTexture(self):
# Line 62  class Image(Common): Line 68  class Image(Common):
68          Set the texture map.              Set the texture map.    
69          """          """
70    
         self.vtk_texture = vtk.vtkTexture()  
71          self.vtk_texture.SetInput(self.vtk_image_reader.GetOutput())              self.vtk_texture.SetInput(self.vtk_image_reader.GetOutput())    
72    
73      def setPlane(self):  #   def setPlane(self):
74          """  """
75          Set the texture coordinates (generated from the plane), which controls  Set the texture coordinates (generated from the plane), which controls
76          the positioning of the texture on a surface.  the positioning of the texture on a surface.
77          """  """
78    
79          self.vtk_plane = vtk.vtkPlaneSource()  #self.vtk_plane = vtk.vtkPlaneSource()
80                    
81    
82    

Legend:
Removed from v.851  
changed lines
  Added in v.852

  ViewVC Help
Powered by ViewVC 1.1.26