]> Creatis software - gdcm.git/blob - vtk/testvtkGdcmReader.cxx
* vtk/testvtkGdcmReader.cxx : remove a symbol that is unused
[gdcm.git] / vtk / testvtkGdcmReader.cxx
1 // $Header: /cvs/public/gdcm/vtk/Attic/testvtkGdcmReader.cxx,v 1.5 2003/07/08 09:48:43 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    reader->SetFileName("../gdcmData/CT-MONO2-16-ankle.dcm");
48    reader->UpdateWholeExtent();
49    vtkImageData *ima = reader->GetOutput();
50    taille=ima->GetDimensions();
51    x = taille[0];  y = taille[1];
52    cout << "Dimensions of the picture as read with gdcm: "
53         << x << " x " << y << endl;
54
55    vtkLookupTable *VTKtable = vtkLookupTable::New();
56    VTKtable->SetNumberOfColors(1000);
57    VTKtable->SetTableRange(0,1000);
58    VTKtable->SetSaturationRange(0,0);
59    VTKtable->SetHueRange(0,1);
60    VTKtable->SetValueRange(0,1);
61    VTKtable->SetAlphaRange(1,1);
62    VTKtable->Build();
63    // Texture
64    vtkTexture * VTKtexture = vtkTexture::New();
65    VTKtexture->SetInput(ima);
66    VTKtexture->InterpolateOn();
67    VTKtexture->SetLookupTable(VTKtable);
68    // PlaneSource
69    vtkPlaneSource *VTKplane = vtkPlaneSource::New();
70    VTKplane->SetOrigin( -0.5, -0.5, 0.0);
71    VTKplane->SetPoint1(  0.5, -0.5, 0.0);
72    VTKplane->SetPoint2( -0.5,  0.5, 0.0);
73    // PolyDataMapper
74    vtkPolyDataMapper *VTKplaneMapper = vtkPolyDataMapper::New();
75    VTKplaneMapper->SetInput(VTKplane->GetOutput());
76    // Actor
77    vtkActor* VTKplaneActor = vtkActor::New();
78    VTKplaneActor->SetTexture(VTKtexture);
79    VTKplaneActor->SetMapper(VTKplaneMapper);
80    VTKplaneActor->PickableOn();
81    //
82    vtkRenderer        *ren = vtkRenderer::New();
83    vtkRenderWindow *renwin = vtkRenderWindow::New();
84    renwin->AddRenderer(ren);
85    vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
86    iren->SetRenderWindow(renwin);
87    ren->AddActor(VTKplaneActor);
88    ren->SetBackground(0,0,0.5);
89    renwin->Render();
90    iren->Start();
91
92    return(0);
93 }
94