]> Creatis software - gdcm.git/blob - gdcmPython/demo/vtkGdcmReader.py
* src/gdcmDocEntrySet.[h|cxx], gdcmDocument.[h|cxx] : amelioration of
[gdcm.git] / gdcmPython / demo / vtkGdcmReader.py
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).
6 from vtk import *
7 from gdcmPython import *
8 from gdcmPython.vtkgdcmPython import *
9 import sys
10
11 ### Get filename from command line or default it
12 try:
13    FileName = sys.argv[1]
14 except IndexError:
15    FileName = os.path.join(GDCM_DATA_PATH, "test.acr")
16
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."
21    sys.exit()
22 del test
23 toDisplay = vtkGdcmReader()
24 toDisplay.AddFileName(FileName)
25 ###toDisplay.DebugOn()
26
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)
34 VTKtable.Build()
35
36 VTKtexture = vtkTexture()
37 VTKtexture.SetInput(toDisplay.GetOutput())
38 VTKtexture.InterpolateOn()
39 VTKtexture.SetLookupTable(VTKtable)
40
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)
45
46 VTKplaneMapper = vtkPolyDataMapper()
47 VTKplaneMapper.SetInput(VTKplane.GetOutput())
48
49 VTKplaneActor = vtkActor()
50 VTKplaneActor.SetTexture(VTKtexture)
51 VTKplaneActor.SetMapper(VTKplaneMapper)
52 VTKplaneActor.PickableOn()
53
54 ren = vtkRenderer()
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)
61 renwin.Render()
62 iren.Start()
63
64
65