]> Creatis software - gdcm.git/blob - vtk/testvtkGdcmReader.cxx
47a9ae889952271732850024199cbbff36a607ac
[gdcm.git] / vtk / testvtkGdcmReader.cxx
1 // $Header: /cvs/public/gdcm/vtk/Attic/testvtkGdcmReader.cxx,v 1.1 2003/05/05 14:13:59 frog 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 "vtkImageViewer.h"
10 #include "vtkMatrix4x4.h"
11 #include "vtkLookupTable.h"
12 #include "vtkMatrixToLinearTransform.h"
13 #include "vtkTexture.h"
14 #include "vtkPlaneSource.h"
15 #include "vtkTextureMapToPlane.h"
16 #include "vtkDataSetMapper.h"
17 #include "vtkActor.h"
18 #include "vtkImageCast.h"
19 #include "vtkPNGWriter.h"
20 #include "vtkTexture.h"
21
22 #include "vtkGdcmReader.h"
23
24   
25 int main( int argc, char *argv[] )
26 {
27    char a;
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("../Data/CT-MONO2-8-abdo.dcm");
37    // 16 12 11 U : OK but saturated
38    // reader->SetFileName("../Data/CT-MONO2-12-lomb-an2.acr2");
39    // 16 12 11 U OK
40    //OKreader->SetFileName("../Data/MR-MONO2-12-an2.acr2");
41    // 16 10 9 U OK
42    //reader->SetFileName("../Data/CR-MONO1-10-chest.dcm");
43    //reader->Update();
44    // 16 16 15 S: OK saturation ?
45    // reader->SetFileName("../Data/CT-MONO2-16-ort.dcm");
46    // 16 16 15 S:
47    reader->SetFileName("../Data/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 << "Taille de l'image en X=" << x << " et en Y=" << y << endl;
53
54    vtkLookupTable *VTKtable = vtkLookupTable::New();
55    VTKtable->SetNumberOfColors(1000);
56    VTKtable->SetTableRange(0,1000);
57    VTKtable->SetSaturationRange(0,0);
58    VTKtable->SetHueRange(0,1);
59    VTKtable->SetValueRange(0,1);
60    VTKtable->SetAlphaRange(1,1);
61    VTKtable->Build();
62    // Texture
63    vtkTexture * VTKtexture = vtkTexture::New();
64    VTKtexture->SetInput(ima);
65    VTKtexture->InterpolateOn();
66    VTKtexture->SetLookupTable(VTKtable);
67    // PlaneSource
68    vtkPlaneSource *VTKplane = vtkPlaneSource::New();
69    VTKplane->SetOrigin( -0.5, -0.5, 0.0);
70    VTKplane->SetPoint1(  0.5, -0.5, 0.0);
71    VTKplane->SetPoint2( -0.5,  0.5, 0.0);
72    // PolyDataMapper
73    vtkPolyDataMapper *VTKplaneMapper = vtkPolyDataMapper::New();
74    VTKplaneMapper->SetInput(VTKplane->GetOutput());
75    // Actor
76    vtkActor* VTKplaneActor = vtkActor::New();
77    VTKplaneActor->SetTexture(VTKtexture);
78    VTKplaneActor->SetMapper(VTKplaneMapper);
79    VTKplaneActor->PickableOn();
80    //
81    vtkRenderer        *ren = vtkRenderer::New();
82    vtkRenderWindow *renwin = vtkRenderWindow::New();
83    renwin->AddRenderer(ren);
84    vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
85    iren->SetRenderWindow(renwin);
86    ren->AddActor(VTKplaneActor);
87    ren->SetBackground(0,0,0.5);
88    renwin->Render();
89    iren->Start();
90
91    return(0);
92 }
93