]> Creatis software - gdcm.git/blob - vtk/testvtkGdcmReader.cxx
Mark as advanced: debug and Dart
[gdcm.git] / vtk / testvtkGdcmReader.cxx
1 // $Header: /cvs/public/gdcm/vtk/Attic/testvtkGdcmReader.cxx,v 1.9 2004/03/30 09:00:40 regrain Exp $
2
3 #include <vtkRenderer.h>
4 #include <vtkRenderWindow.h>
5 #include <vtkRenderWindowInteractor.h>
6 #include <vtkPolyDataMapper.h>
7 #include <vtkActor.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>
18 #include <vtkActor.h>
19 #include <vtkImageCast.h>
20 #include <vtkPNGWriter.h>
21 #include <vtkTexture.h>
22
23 #include "vtkGdcmReader.h"
24
25   
26 int main( int argc, char *argv[] )
27 {
28    int *taille;
29    int x,y;
30
31    // Lecture de l'image
32    vtkGdcmReader *reader = vtkGdcmReader::New();
33 //   reader->DebugOn();
34    // Alloc Used High
35    // 8 8 7 U : OK
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");
39    // 16 12 11 U OK
40    //OKreader->SetFileName("../gdcmData/MR-MONO2-12-an2.acr2");
41    // 16 10 9 U OK
42    //reader->SetFileName("../gdcmData/CR-MONO1-10-chest.dcm");
43    //reader->Update();
44    // 16 16 15 S: OK saturation ?
45    // reader->SetFileName("../gdcmData/CT-MONO2-16-ort.dcm");
46    // 16 16 15 S:
47
48         if (argc > 1)
49      reader->SetFileName( argv[1] );
50         else
51      reader->SetFileName("../gdcmData/CT-MONO2-16-ankle.dcm");
52
53    reader->UpdateWholeExtent();
54 //   reader->Update();
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;
60
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);
68    VTKtable->Build();
69    // Texture
70    vtkTexture * VTKtexture = vtkTexture::New();
71    VTKtexture->SetInput(ima);
72    VTKtexture->InterpolateOn();
73    VTKtexture->SetLookupTable(VTKtable);
74    // PlaneSource
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);
79    // PolyDataMapper
80    vtkPolyDataMapper *VTKplaneMapper = vtkPolyDataMapper::New();
81    VTKplaneMapper->SetInput(VTKplane->GetOutput());
82    // Actor
83    vtkActor* VTKplaneActor = vtkActor::New();
84    VTKplaneActor->SetTexture(VTKtexture);
85    VTKplaneActor->SetMapper(VTKplaneMapper);
86    VTKplaneActor->PickableOn();
87    //
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);
95    renwin->Render();
96    iren->Start();
97
98    reader->Delete();
99    VTKtable->Delete();
100    VTKtexture->Delete();
101    VTKplane->Delete();
102    VTKplaneMapper->Delete();
103    VTKplaneActor->Delete();
104    ren->Delete();
105    renwin->Delete();
106    iren->Delete();
107
108    return(0);
109 }
110