[vtkusers] problems with vtkCamera
Brenno Ribeiro
brennobr at gmail.com
Tue Mar 6 10:59:30 EST 2012
//THIS IS MY CODE
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkRescaleIntensityImageFilter.h"
#include "itkGDCMImageIO.h"
#include "itkImageToVTKImageFilter.h"
#include "vtkSphereSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkProperty.h"
#include "vtkActor.h"
#include "vtkRenderWindow.h"
#include "vtkRenderer.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkCamera.h"
#include "vtkContourFilter.h"
#include "vtkPolyDataNormals.h"
#include "vtkImageGaussianSmooth.h"
#include "itkImage.h"
#include "itkSmoothingRecursiveGaussianImageFilter.h"
#include "itkRescaleIntensityImageFilter.h"
#include "vtkImageViewer.h"
int main( int argc, char* argv[] )
{
typedef signed short InputPixelType;
const unsigned int InputDimension = 2;
typedef itk::Image< InputPixelType, InputDimension > InputImageType;
typedef itk::Image< InputPixelType, InputDimension > GaussianImageType;
typedef itk::Image< InputPixelType, InputDimension > WriteImageType;
typedef itk::ImageFileReader< InputImageType > ReaderType;
typedef itk::ImageFileWriter< InputImageType > WriterType;
typedef itk::ImageToVTKImageFilter<InputImageType> FilterType;
typedef itk::GDCMImageIO ImageIOTypeGDCM;
typedef itk::SmoothingRecursiveGaussianImageFilter< InputImageType ,
GaussianImageType > SmoothingFilterType;
typedef itk::RescaleIntensityImageFilter< InputImageType,
WriteImageType > RescaleFilterType;
ReaderType::Pointer reader = ReaderType::New();
FilterType::Pointer connector = FilterType::New();
ImageIOTypeGDCM::Pointer gdcmImageIO = ImageIOTypeGDCM::New();
SmoothingFilterType::Pointer smoother = SmoothingFilterType::New();
RescaleFilterType::Pointer rescaler = RescaleFilterType::New();
const char * inputDicomFilename = argv[1];
reader->SetFileName( inputDicomFilename );
reader->SetImageIO( gdcmImageIO );
try
{
reader->Update();
}
catch (itk::ExceptionObject & e)
{
std::cerr << "exception in file reader " << std::endl;
std::cerr << e << std::endl;
return EXIT_FAILURE;
}
rescaler->SetOutputMinimum( 0 );
rescaler->SetOutputMaximum( 255 );
//smoother->SetSigma( 1.0 );
//smoother->SetNormalizeAcrossScale( true );
rescaler->SetInput( reader->GetOutput() );
connector->SetInput( rescaler->GetOutput() );
try
{
connector->Update();
}
catch( itk::ExceptionObject & err )
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
return EXIT_FAILURE;
}
vtkContourFilter *isoSurface = vtkContourFilter::New();
vtkPolyDataNormals *normals = vtkPolyDataNormals::New();
vtkImageGaussianSmooth *smooth = vtkImageGaussianSmooth::New();
isoSurface->SetValue(90,90);
isoSurface->SetInput(connector->GetOutput() );
try
{
isoSurface->Update();
}
catch( itk::ExceptionObject & err )
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
return EXIT_FAILURE;
}
normals->SetInput( isoSurface->GetOutput() );
try
{
normals->Update();
}
catch( itk::ExceptionObject & err )
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
return EXIT_FAILURE;
}
vtkPolyDataMapper *map = vtkPolyDataMapper::New();
map->SetInput(normals->GetOutput());// isoSurface->GetOutput()
vtkActor *aSphere = vtkActor::New();//don't used
vtkRenderer *ren1 = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
aSphere->SetMapper(map);//don't used
aSphere->GetProperty()->SetColor(0,0,1); //don't used
renWin->AddRenderer(ren1);
iren->SetRenderWindow(renWin);
ren1->AddActor(aSphere);//don't used
ren1->SetBackground(0,0,0); //don't used
renWin->Render();
vtkCamera * cam = ren1->GetActiveCamera();
cam->SetViewUp(0, -1, 0);
cam->Azimuth(180);
ren1->ResetCamera();
iren->Start();
ren1->Delete();
renWin->Delete();
iren->Delete();
return EXIT_SUCCESS;
}
--
Brenno Bernardes Ribeiro
Engenharia da Computação
Universidade Federal do Pará
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120306/86832da0/attachment.htm>
More information about the vtkusers
mailing list