vtkgdcmViewer.cxx File Reference

#include <vtkRenderWindowInteractor.h>
#include <vtkImageViewer.h>
#include <vtkStructuredPoints.h>
#include <vtkStructuredPointsWriter.h>
#include <vtkCommand.h>
#include <vtkRenderer.h>
#include <vtkImageMapToColors.h>
#include <vtkLookupTable.h>
#include "vtkGdcmReader.h"
#include "gdcmDocument.h"

Include dependency graph for vtkgdcmViewer.cxx:

Go to the source code of this file.

Classes

class  vtkgdcmObserver

Defines

#define vtkFloatingPointType   float

Functions

int main (int argc, char *argv[])


Define Documentation

#define vtkFloatingPointType   float
 

Definition at line 44 of file vtkgdcmViewer.cxx.


Function Documentation

int main int  argc,
char *  argv[]
 

Definition at line 82 of file vtkgdcmViewer.cxx.

References vtkGdcmReader::AddFileName(), GDCM_NAME_SPACE::LD_NOSHADOWSEQ, vtkGdcmReader::New(), and vtkGdcmReader::SetFileName().

00083 {
00084    if( argc < 2 )
00085       return 0;
00086   
00087    vtkGdcmReader *reader = vtkGdcmReader::New();
00088    reader->AllowLookupTableOff();
00089 
00090    if( argc == 2 )
00091       reader->SetFileName( argv[1] );
00092    else
00093       for(int i=1; i< argc; i++)
00094          reader->AddFileName( argv[i] );
00095 
00096 // TODO : allow user to choose Load Mode
00097    reader->SetLoadMode(GDCM_NAME_SPACE::LD_NOSHADOWSEQ);  
00098    reader->Update();
00099 
00100    //print debug info:
00101    reader->GetOutput()->Print( cout );
00102 
00103    vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
00104 
00105    vtkImageViewer *viewer = vtkImageViewer::New();
00106 
00107    if( reader->GetLookupTable() )
00108    {
00109       //convert to color:
00110       vtkImageMapToColors *map = vtkImageMapToColors::New ();
00111       map->SetInput (reader->GetOutput());
00112       map->SetLookupTable (reader->GetLookupTable());
00113       map->SetOutputFormatToRGB();
00114       viewer->SetInput ( map->GetOutput() );
00115       map->Delete();
00116    }
00117    else
00118    {
00119       vtkFloatingPointType *range = reader->GetOutput()->GetScalarRange();
00120       viewer->SetColorLevel (0.5 * (range[1] + range[0]));
00121       viewer->SetColorWindow (range[1] - range[0]);
00122 
00123       viewer->SetInput ( reader->GetOutput() );
00124    }
00125    viewer->SetupInteractor (iren);
00126   
00127    //vtkFloatingPointType *range = reader->GetOutput()->GetScalarRange();
00128    //viewer->SetColorWindow (range[1] - range[0]);
00129    //viewer->SetColorLevel (0.5 * (range[1] + range[0]));
00130 
00131    // Here is where we setup the observer, 
00132    vtkgdcmObserver *obs = vtkgdcmObserver::New();
00133    obs->ImageViewer = viewer;
00134    iren->AddObserver(vtkCommand::CharEvent,obs);
00135    obs->Delete();
00136 
00137    //viewer->Render();
00138    iren->Initialize();
00139    iren->Start();
00140 
00141    //if you wish you can export dicom to a vtk file  
00142    vtkStructuredPointsWriter *writer = vtkStructuredPointsWriter::New();
00143    writer->SetInput( reader->GetOutput());
00144    writer->SetFileName( "foo.vtk" );
00145    writer->SetFileTypeToBinary();
00146    //writer->Write();
00147 
00148    reader->Delete();
00149    iren->Delete();
00150    viewer->Delete();
00151    writer->Delete();
00152 
00153    return 0;
00154 }


Generated on Fri Aug 24 12:56:13 2007 for gdcm by  doxygen 1.4.6