1 /*=========================================================================
4 Module: $RCSfile: vvImageReader.cxx,v $
6 Date: $Date: 2010/01/26 15:04:33 $
7 Version: $Revision: 1.2 $
8 Author : Pierre Seroul (pierre.seroul@gmail.com)
11 Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
12 CREATIS-LRMN http://www.creatis.insa-lyon.fr
14 This program is free software: you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation, version 3 of the License.
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program. If not, see <http://www.gnu.org/licenses/>.
26 =========================================================================*/
27 #ifndef vvImageReader_CXX
28 #define vvImageReader_CXX
30 #include <QApplication>
31 #include <itkImageFileReader.h>
32 #include "vvImageReader.h"
33 #include "vvImageReader.txx"
36 //====================================================================
37 vvImageReader::vvImageReader()
40 mInputFilenames.resize(0);
42 mType = UNDEFINEDIMAGETYPE;
45 vvImageReader::~vvImageReader() { }
47 void vvImageReader::Update()
52 void vvImageReader::Update(LoadedImageType type)
54 itk::ImageIOBase::Pointer reader = itk::ImageIOFactory::CreateImageIO(mInputFilenames[0].c_str(), itk::ImageIOFactory::ReadMode);
56 mLastError="Unable to read file.";
59 reader->SetFileName(mInputFilenames[0]);
60 reader->ReadImageInformation();
61 if (mInputFilenames.size() > 1)
62 Update(reader->GetNumberOfDimensions()+1,reader->GetComponentTypeAsString(reader->GetComponentType()),type);
64 Update(reader->GetNumberOfDimensions(),reader->GetComponentTypeAsString(reader->GetComponentType()),type);
68 //====================================================================
69 void vvImageReader::Update(int dim,std::string inputPixelType, LoadedImageType type) {
70 //CALL_FOR_ALL_DIMS(dim,UpdateWithDim,inputPixelType);
73 mInputPixelType=inputPixelType;
74 this->start(); //Start heavy read operation in a separate thread
75 while (this->isRunning())
77 qApp->processEvents();
82 void vvImageReader::run()
87 UpdateWithDim<2>(mInputPixelType);
90 UpdateWithDim<3>(mInputPixelType);
93 UpdateWithDim<4>(mInputPixelType);
96 std::cerr << "dimension unknown in Update ! " << std::endl;
99 //====================================================================
101 //====================================================================
102 /*void vvImageReader::Extract(int dim, std::string inputPixelType, int slice) {
103 CALL_FOR_ALL_DIMS(dim, ExtractWithDim, inputPixelType, slice);
105 //====================================================================
106 void vvImageReader::SetInputFilename(const std::string & filename)
108 mInputFilenames.resize(0);
109 mInputFilenames.push_back(filename);
112 //====================================================================
113 void vvImageReader::SetInputFilenames(const std::vector<std::string> & filenames) {
114 mInputFilenames = filenames;
116 //====================================================================