#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkImageMapper.h>
#include <vtkImageData.h>
#include <vtkImageViewer.h>
#include <vtkMatrix4x4.h>
#include <vtkLookupTable.h>
#include <vtkMatrixToLinearTransform.h>
#include <vtkTexture.h>
#include <vtkPlaneSource.h>
#include <vtkTextureMapToPlane.h>
#include <vtkDataSetMapper.h>
#include <vtkImageCast.h>
#include <vtkPNGWriter.h>
#include "vtkGdcmReader.h"
Include dependency graph for vtkGdcmDemo.cxx:
Go to the source code of this file.
Functions | |
int | main (int argc, char *argv[]) |
|
Definition at line 40 of file vtkGdcmDemo.cxx. References vtkGdcmReader::New(), vtkGdcmReader::SetFileName(), and vtkLookupTable. 00041 { 00042 vtkGdcmReader *reader = vtkGdcmReader::New(); 00043 00044 if (argc < 2) 00045 { 00046 cerr << "Usage: " << argv[0] << " image.dcm\n"; 00047 return 0; 00048 } 00049 00050 reader->SetFileName( argv[1] ); 00051 00052 reader->UpdateWholeExtent(); 00053 vtkImageData* ima = reader->GetOutput(); 00054 00056 int* Size = ima->GetDimensions(); 00057 cout << "Dimensions of the picture as read with gdcm: " 00058 << Size[0] << " x " << Size[1] << endl; 00059 00061 // 00062 vtkLookupTable* VTKtable = vtkLookupTable::New(); 00063 VTKtable->SetNumberOfColors(1000); 00064 VTKtable->SetTableRange(0,1000); 00065 VTKtable->SetSaturationRange(0,0); 00066 VTKtable->SetHueRange(0,1); 00067 VTKtable->SetValueRange(0,1); 00068 VTKtable->SetAlphaRange(1,1); 00069 VTKtable->Build(); 00070 00072 vtkTexture* VTKtexture = vtkTexture::New(); 00073 VTKtexture->SetInput(ima); 00074 VTKtexture->InterpolateOn(); 00075 VTKtexture->SetLookupTable(VTKtable); 00076 00078 vtkPlaneSource* VTKplane = vtkPlaneSource::New(); 00079 VTKplane->SetOrigin( -0.5, -0.5, 0.0); 00080 VTKplane->SetPoint1( 0.5, -0.5, 0.0); 00081 VTKplane->SetPoint2( -0.5, 0.5, 0.0); 00082 00084 vtkPolyDataMapper *VTKplaneMapper = vtkPolyDataMapper::New(); 00085 VTKplaneMapper->SetInput(VTKplane->GetOutput()); 00086 00088 vtkActor* VTKplaneActor = vtkActor::New(); 00089 VTKplaneActor->SetTexture(VTKtexture); 00090 VTKplaneActor->SetMapper(VTKplaneMapper); 00091 VTKplaneActor->PickableOn(); 00092 00094 vtkRenderer *ren = vtkRenderer::New(); 00095 vtkRenderWindow *renwin = vtkRenderWindow::New(); 00096 renwin->AddRenderer(ren); 00097 vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New(); 00098 iren->SetRenderWindow(renwin); 00099 ren->AddActor(VTKplaneActor); 00100 ren->SetBackground(0,0,0.5); 00101 renwin->Render(); 00102 iren->Start(); 00103 00105 reader->Delete(); 00106 VTKtable->Delete(); 00107 VTKtexture->Delete(); 00108 VTKplane->Delete(); 00109 VTKplaneMapper->Delete(); 00110 VTKplaneActor->Delete(); 00111 ren->Delete(); 00112 renwin->Delete(); 00113 iren->Delete(); 00114 00115 return(0); 00116 }
|