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
20 #include <QApplication>
21 #include <itkImageFileReader.h>
22 #include "vvImageReader.h"
23 #include "vvImageReader.txx"
26 //====================================================================
27 vvImageReader::vvImageReader()
30 mInputFilenames.resize(0);
32 mType = UNDEFINEDIMAGETYPE;
35 vvImageReader::~vvImageReader() { }
37 void vvImageReader::Update()
42 void vvImageReader::Update(LoadedImageType type)
44 itk::ImageIOBase::Pointer reader = itk::ImageIOFactory::CreateImageIO(mInputFilenames[0].c_str(), itk::ImageIOFactory::ReadMode);
46 mLastError="Unable to read file.";
49 reader->SetFileName(mInputFilenames[0]);
50 reader->ReadImageInformation();
51 if (mInputFilenames.size() > 1)
52 Update(reader->GetNumberOfDimensions()+1,reader->GetComponentTypeAsString(reader->GetComponentType()),type);
54 Update(reader->GetNumberOfDimensions(),reader->GetComponentTypeAsString(reader->GetComponentType()),type);
58 //====================================================================
59 void vvImageReader::Update(int dim,std::string inputPixelType, LoadedImageType type) {
60 //CALL_FOR_ALL_DIMS(dim,UpdateWithDim,inputPixelType);
63 mInputPixelType=inputPixelType;
64 this->start(); //Start heavy read operation in a separate thread
65 while (this->isRunning())
67 qApp->processEvents();
72 void vvImageReader::run()
77 UpdateWithDim<2>(mInputPixelType);
80 UpdateWithDim<3>(mInputPixelType);
83 UpdateWithDim<4>(mInputPixelType);
86 std::cerr << "dimension unknown in Update ! " << std::endl;
89 //====================================================================
91 //====================================================================
92 /*void vvImageReader::Extract(int dim, std::string inputPixelType, int slice) {
93 CALL_FOR_ALL_DIMS(dim, ExtractWithDim, inputPixelType, slice);
95 //====================================================================
96 void vvImageReader::SetInputFilename(const std::string & filename)
98 mInputFilenames.resize(0);
99 mInputFilenames.push_back(filename);
102 //====================================================================
103 void vvImageReader::SetInputFilenames(const std::vector<std::string> & filenames) {
104 mInputFilenames = filenames;
106 //====================================================================