00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date$ 00006 Version: $Revision$ 00007 00008 Copyright (c) German Cancer Research Center, Division of Medical and 00009 Biological Informatics. All rights reserved. 00010 See MITKCopyright.txt or https://www.mitk.org/copyright.html for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 00019 #include "mitkVtkVolumeTimeSeriesReader.h" 00020 #include "mitkVtkSurfaceReader.h" 00021 #include "mitkSurface.h" 00022 #include "vtkPolyData.h" 00023 00024 void mitk::VtkVolumeTimeSeriesReader::GenerateData() 00025 { 00026 if ( !this->GenerateFileList() ) 00027 { 00028 itkWarningMacro( << "Sorry, file list could not be determined..." ); 00029 return ; 00030 } 00031 00032 mitk::Surface::Pointer output = this->GetOutput(); 00033 MITK_INFO << "prefix: "<< m_FilePrefix << ", pattern: " <<m_FilePattern << std::endl; 00034 output->Expand(m_MatchedFileNames.size()); 00035 for ( unsigned int i = 0 ; i < m_MatchedFileNames.size(); ++i ) 00036 { 00037 std::string fileName = m_MatchedFileNames[i]; 00038 MITK_INFO << "Loading " << fileName << " as vtk..." << std::endl; 00039 00040 VtkSurfaceReader::Pointer vtkReader = VtkSurfaceReader::New(); 00041 vtkReader->SetFileName( fileName.c_str() ); 00042 vtkReader->Update(); 00043 00044 if ( vtkReader->GetOutput() != NULL ) 00045 { 00046 output->SetVtkPolyData( vtkReader->GetOutput()->GetVtkPolyData(), i ); 00047 } 00048 else 00049 { 00050 itkWarningMacro(<< "vtkPolyDataReader returned NULL while reading " << fileName << ". Trying to continue with empty vtkPolyData..."); 00051 output->SetVtkPolyData( vtkPolyData::New(), i ); 00052 } 00053 } 00054 } 00055 00056 bool mitk::VtkVolumeTimeSeriesReader::CanReadFile(const std::string /*filename*/, const std::string filePrefix, const std::string filePattern) 00057 { 00058 if( filePattern != "" && filePrefix != "" ) 00059 return false; 00060 00061 bool extensionFound = false; 00062 std::string::size_type VTKPos = filePattern.rfind(".vtk"); 00063 if ((VTKPos != std::string::npos) && (VTKPos == filePattern.length() - 4)) 00064 extensionFound = true; 00065 00066 VTKPos = filePattern.rfind(".VTK"); 00067 if ((VTKPos != std::string::npos) && (VTKPos == filePattern.length() - 4)) 00068 extensionFound = true; 00069 00070 if( !extensionFound ) 00071 return false; 00072 00073 return true; 00074 } 00075 00076 mitk::VtkVolumeTimeSeriesReader::VtkVolumeTimeSeriesReader() 00077 {} 00078 00079 mitk::VtkVolumeTimeSeriesReader::~VtkVolumeTimeSeriesReader() 00080 {}