Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "mitkVtiFileReader.h"
00019
00020 #include <vtkImageData.h>
00021 #include <vtkXMLImageDataReader.h>
00022
00023 mitk::VtiFileReader::VtiFileReader()
00024 : m_FileName(""), m_FilePrefix(""), m_FilePattern("")
00025 {
00026 }
00027
00028 mitk::VtiFileReader::~VtiFileReader()
00029 {
00030 }
00031
00032 void mitk::VtiFileReader::GenerateData()
00033 {
00034 if( m_FileName != "")
00035 {
00036 vtkXMLImageDataReader * vtkReader = vtkXMLImageDataReader::New();
00037 vtkReader->SetFileName( m_FileName.c_str() );
00038 vtkReader->Update();
00039
00040 if ( vtkReader->GetOutput() != NULL )
00041 {
00042 mitk::Image::Pointer output = this->GetOutput();
00043 output->Initialize( vtkReader->GetOutput() );
00044 output->SetVolume( vtkReader->GetOutput()->GetScalarPointer() );
00045 }
00046 vtkReader->Delete();
00047 }
00048 }
00049
00050 bool mitk::VtiFileReader::CanReadFile(const std::string filename, const std::string , const std::string )
00051 {
00052
00053 if( filename == "" )
00054 return false;
00055
00056 bool extensionFound = false;
00057 std::string::size_type VTIPos = filename.rfind(".vti");
00058 if ((VTIPos != std::string::npos) && (VTIPos == filename.length() - 4))
00059 extensionFound = true;
00060
00061 VTIPos = filename.rfind(".VTI");
00062 if ((VTIPos != std::string::npos) && (VTIPos == filename.length() - 4))
00063 extensionFound = true;
00064
00065 if (!extensionFound)
00066 return false;
00067
00068 return true;
00069 }