1 ## This demo illustrates the usage of the python-wrappers of vtkGdcmReader
2 ## native C++ vtk class. vtkGdcmReader.cxx is a C++ level wrapper of
3 ## gdcm which offers a vtk class vtkGdcmReader (inheriting from vtkImageReader,
4 ## see gdcm/vtk/vtkGdcmReader.cxx). vtkgdcmPython wraps this class for
5 ## python (by using vtk wrappers).
7 from gdcmPython import *
8 from gdcmPython.vtkgdcmPython import *
11 ### Get filename from command line or default it
13 FileName = sys.argv[1]
15 FileName = os.path.join(GDCM_DATA_PATH, "test.acr")
17 ### Build the header element list
18 test = gdcmHeader(FileName)
19 if not test.IsReadable():
20 print "The ", FileName, " file is not readable with gdcm. Sorry."
23 toDisplay = vtkGdcmReader()
24 toDisplay.AddFileName(FileName)
25 ###toDisplay.DebugOn()
27 VTKtable = vtkLookupTable()
28 VTKtable.SetNumberOfColors(1000)
29 VTKtable.SetTableRange(0,1000)
30 VTKtable.SetSaturationRange(0,0)
31 VTKtable.SetHueRange(0,1)
32 VTKtable.SetValueRange(0,1)
33 VTKtable.SetAlphaRange(1,1)
36 VTKtexture = vtkTexture()
37 VTKtexture.SetInput(toDisplay.GetOutput())
38 VTKtexture.InterpolateOn()
39 VTKtexture.SetLookupTable(VTKtable)
41 VTKplane = vtkPlaneSource()
42 VTKplane.SetOrigin( -0.5, -0.5, 0.0)
43 VTKplane.SetPoint1( 0.5, -0.5, 0.0)
44 VTKplane.SetPoint2( -0.5, 0.5, 0.0)
46 VTKplaneMapper = vtkPolyDataMapper()
47 VTKplaneMapper.SetInput(VTKplane.GetOutput())
49 VTKplaneActor = vtkActor()
50 VTKplaneActor.SetTexture(VTKtexture)
51 VTKplaneActor.SetMapper(VTKplaneMapper)
52 VTKplaneActor.PickableOn()
55 renwin = vtkRenderWindow()
56 renwin.AddRenderer(ren)
57 iren = vtkRenderWindowInteractor()
58 iren.SetRenderWindow(renwin)
59 ren.AddActor(VTKplaneActor)
60 ren.SetBackground(0,0,0.5)