1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ======================================================================-====*/
18 #ifndef VVIMAGEREADER_CXX
19 #define VVIMAGEREADER_CXX
21 #include <QApplication>
22 #include <itkImageFileReader.h>
23 #include "vvImageReader.h"
24 #include "vvImageReader.txx"
26 //------------------------------------------------------------------------------
27 vvImageReader::vvImageReader()
30 mInputFilenames.resize(0);
32 mType = UNDEFINEDIMAGETYPE;
34 //------------------------------------------------------------------------------
37 //------------------------------------------------------------------------------
38 vvImageReader::~vvImageReader() { }
39 //------------------------------------------------------------------------------
42 //------------------------------------------------------------------------------
43 void vvImageReader::Update()
47 //------------------------------------------------------------------------------
50 //------------------------------------------------------------------------------
51 void vvImageReader::Update(LoadedImageType type)
53 itk::ImageIOBase::Pointer reader = itk::ImageIOFactory::CreateImageIO(mInputFilenames[0].c_str(), itk::ImageIOFactory::ReadMode);
55 mLastError="Unable to read file.";
58 reader->SetFileName(mInputFilenames[0]);
59 reader->ReadImageInformation();
60 if (mInputFilenames.size() > 1)
61 Update(reader->GetNumberOfDimensions()+1,reader->GetComponentTypeAsString(reader->GetComponentType()),type);
63 Update(reader->GetNumberOfDimensions(),reader->GetComponentTypeAsString(reader->GetComponentType()),type);
66 //------------------------------------------------------------------------------
69 //------------------------------------------------------------------------------
70 void vvImageReader::Update(int dim,std::string inputPixelType, LoadedImageType type) {
71 //CALL_FOR_ALL_DIMS(dim,UpdateWithDim,inputPixelType);
74 mInputPixelType=inputPixelType;
75 this->start(); //Start heavy read operation in a separate thread
76 while (this->isRunning())
78 qApp->processEvents();
82 //------------------------------------------------------------------------------
85 //------------------------------------------------------------------------------
86 void vvImageReader::run()
90 UpdateWithDim<2>(mInputPixelType);
93 UpdateWithDim<3>(mInputPixelType);
96 UpdateWithDim<4>(mInputPixelType);
99 std::cerr << "dimension unknown in Update ! " << std::endl;
102 //------------------------------------------------------------------------------
105 //------------------------------------------------------------------------------
106 void vvImageReader::SetInputFilename(const std::string & filename)
108 mInputFilenames.resize(0);
109 mInputFilenames.push_back(filename);
111 //------------------------------------------------------------------------------
114 //------------------------------------------------------------------------------
115 void vvImageReader::SetInputFilenames(const std::vector<std::string> & filenames) {
116 mInputFilenames = filenames;
118 //------------------------------------------------------------------------------