]> Creatis software - gdcm.git/blob - vtk/testvtkGdcmReader.cxx
Final remove of spurious testTS
[gdcm.git] / vtk / testvtkGdcmReader.cxx
1 // $Header: /cvs/public/gdcm/vtk/Attic/testvtkGdcmReader.cxx,v 1.4 2003/05/21 16:26:29 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    char a;
29    int *taille;
30    int x,y;
31
32    // Lecture de l'image
33    vtkGdcmReader *reader = vtkGdcmReader::New();
34    reader->DebugOn();
35    // Alloc Used High
36    // 8 8 7 U : OK
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");
40    // 16 12 11 U OK
41    //OKreader->SetFileName("../gdcmData/MR-MONO2-12-an2.acr2");
42    // 16 10 9 U OK
43    //reader->SetFileName("../gdcmData/CR-MONO1-10-chest.dcm");
44    //reader->Update();
45    // 16 16 15 S: OK saturation ?
46    // reader->SetFileName("../gdcmData/CT-MONO2-16-ort.dcm");
47    // 16 16 15 S:
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;
55
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);
63    VTKtable->Build();
64    // Texture
65    vtkTexture * VTKtexture = vtkTexture::New();
66    VTKtexture->SetInput(ima);
67    VTKtexture->InterpolateOn();
68    VTKtexture->SetLookupTable(VTKtable);
69    // PlaneSource
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);
74    // PolyDataMapper
75    vtkPolyDataMapper *VTKplaneMapper = vtkPolyDataMapper::New();
76    VTKplaneMapper->SetInput(VTKplane->GetOutput());
77    // Actor
78    vtkActor* VTKplaneActor = vtkActor::New();
79    VTKplaneActor->SetTexture(VTKtexture);
80    VTKplaneActor->SetMapper(VTKplaneMapper);
81    VTKplaneActor->PickableOn();
82    //
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);
90    renwin->Render();
91    iren->Start();
92
93    return(0);
94 }
95