1 // $Header: /cvs/public/gdcm/vtk/Attic/testvtkGdcmReader.cxx,v 1.9 2004/03/30 09:00:40 regrain Exp $
3 #include <vtkRenderer.h>
4 #include <vtkRenderWindow.h>
5 #include <vtkRenderWindowInteractor.h>
6 #include <vtkPolyDataMapper.h>
8 #include <vtkImageMapper.h>
9 #include <vtkImageData.h>
10 #include <vtkImageViewer.h>
11 #include <vtkMatrix4x4.h>
12 #include <vtkLookupTable.h>
13 #include <vtkMatrixToLinearTransform.h>
14 #include <vtkTexture.h>
15 #include <vtkPlaneSource.h>
16 #include <vtkTextureMapToPlane.h>
17 #include <vtkDataSetMapper.h>
19 #include <vtkImageCast.h>
20 #include <vtkPNGWriter.h>
21 #include <vtkTexture.h>
23 #include "vtkGdcmReader.h"
26 int main( int argc, char *argv[] )
32 vtkGdcmReader *reader = vtkGdcmReader::New();
36 // reader->SetFileName("../gdcmData/CT-MONO2-8-abdo.dcm");
37 // 16 12 11 U : OK but saturated
38 // reader->SetFileName("../gdcmData/CT-MONO2-12-lomb-an2.acr2");
40 //OKreader->SetFileName("../gdcmData/MR-MONO2-12-an2.acr2");
42 //reader->SetFileName("../gdcmData/CR-MONO1-10-chest.dcm");
44 // 16 16 15 S: OK saturation ?
45 // reader->SetFileName("../gdcmData/CT-MONO2-16-ort.dcm");
49 reader->SetFileName( argv[1] );
51 reader->SetFileName("../gdcmData/CT-MONO2-16-ankle.dcm");
53 reader->UpdateWholeExtent();
55 vtkImageData *ima = reader->GetOutput();
56 taille=ima->GetDimensions();
57 x = taille[0]; y = taille[1];
58 cout << "Dimensions of the picture as read with gdcm: "
59 << x << " x " << y << endl;
61 vtkLookupTable *VTKtable = vtkLookupTable::New();
62 VTKtable->SetNumberOfColors(1000);
63 VTKtable->SetTableRange(0,1000);
64 VTKtable->SetSaturationRange(0,0);
65 VTKtable->SetHueRange(0,1);
66 VTKtable->SetValueRange(0,1);
67 VTKtable->SetAlphaRange(1,1);
70 vtkTexture * VTKtexture = vtkTexture::New();
71 VTKtexture->SetInput(ima);
72 VTKtexture->InterpolateOn();
73 VTKtexture->SetLookupTable(VTKtable);
75 vtkPlaneSource *VTKplane = vtkPlaneSource::New();
76 VTKplane->SetOrigin( -0.5, -0.5, 0.0);
77 VTKplane->SetPoint1( 0.5, -0.5, 0.0);
78 VTKplane->SetPoint2( -0.5, 0.5, 0.0);
80 vtkPolyDataMapper *VTKplaneMapper = vtkPolyDataMapper::New();
81 VTKplaneMapper->SetInput(VTKplane->GetOutput());
83 vtkActor* VTKplaneActor = vtkActor::New();
84 VTKplaneActor->SetTexture(VTKtexture);
85 VTKplaneActor->SetMapper(VTKplaneMapper);
86 VTKplaneActor->PickableOn();
88 vtkRenderer *ren = vtkRenderer::New();
89 vtkRenderWindow *renwin = vtkRenderWindow::New();
90 renwin->AddRenderer(ren);
91 vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
92 iren->SetRenderWindow(renwin);
93 ren->AddActor(VTKplaneActor);
94 ren->SetBackground(0,0,0.5);
100 VTKtexture->Delete();
102 VTKplaneMapper->Delete();
103 VTKplaneActor->Delete();