1 // $Header: /cvs/public/gdcm/vtk/Attic/testvtkGdcmReader.cxx,v 1.4 2003/05/21 16:26:29 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[] )
33 vtkGdcmReader *reader = vtkGdcmReader::New();
37 // reader->SetFileName("../gdcmData/CT-MONO2-8-abdo.dcm");
38 // 16 12 11 U : OK but saturated
39 // reader->SetFileName("../gdcmData/CT-MONO2-12-lomb-an2.acr2");
41 //OKreader->SetFileName("../gdcmData/MR-MONO2-12-an2.acr2");
43 //reader->SetFileName("../gdcmData/CR-MONO1-10-chest.dcm");
45 // 16 16 15 S: OK saturation ?
46 // reader->SetFileName("../gdcmData/CT-MONO2-16-ort.dcm");
48 reader->SetFileName("../gdcmData/CT-MONO2-16-ankle.dcm");
49 reader->UpdateWholeExtent();
50 vtkImageData *ima = reader->GetOutput();
51 taille=ima->GetDimensions();
52 x = taille[0]; y = taille[1];
53 cout << "Dimensions of the picture as read with gdcm: "
54 << x << " x " << y << endl;
56 vtkLookupTable *VTKtable = vtkLookupTable::New();
57 VTKtable->SetNumberOfColors(1000);
58 VTKtable->SetTableRange(0,1000);
59 VTKtable->SetSaturationRange(0,0);
60 VTKtable->SetHueRange(0,1);
61 VTKtable->SetValueRange(0,1);
62 VTKtable->SetAlphaRange(1,1);
65 vtkTexture * VTKtexture = vtkTexture::New();
66 VTKtexture->SetInput(ima);
67 VTKtexture->InterpolateOn();
68 VTKtexture->SetLookupTable(VTKtable);
70 vtkPlaneSource *VTKplane = vtkPlaneSource::New();
71 VTKplane->SetOrigin( -0.5, -0.5, 0.0);
72 VTKplane->SetPoint1( 0.5, -0.5, 0.0);
73 VTKplane->SetPoint2( -0.5, 0.5, 0.0);
75 vtkPolyDataMapper *VTKplaneMapper = vtkPolyDataMapper::New();
76 VTKplaneMapper->SetInput(VTKplane->GetOutput());
78 vtkActor* VTKplaneActor = vtkActor::New();
79 VTKplaneActor->SetTexture(VTKtexture);
80 VTKplaneActor->SetMapper(VTKplaneMapper);
81 VTKplaneActor->PickableOn();
83 vtkRenderer *ren = vtkRenderer::New();
84 vtkRenderWindow *renwin = vtkRenderWindow::New();
85 renwin->AddRenderer(ren);
86 vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
87 iren->SetRenderWindow(renwin);
88 ren->AddActor(VTKplaneActor);
89 ren->SetBackground(0,0,0.5);