1 /*=========================================================================
4 Module: $RCSfile: vvImageReader.cxx,v $
6 Date: $Date: 2010/01/06 13:31:57 $
7 Version: $Revision: 1.1 $
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(LoadedImageType type)
49 itk::ImageIOBase::Pointer reader = itk::ImageIOFactory::CreateImageIO(mInputFilenames[0].c_str(), itk::ImageIOFactory::ReadMode);
51 mLastError="Unable to read file.";
54 reader->SetFileName(mInputFilenames[0]);
55 reader->ReadImageInformation();
56 if (mInputFilenames.size() > 1)
57 Update(reader->GetNumberOfDimensions()+1,reader->GetComponentTypeAsString(reader->GetComponentType()),type);
59 Update(reader->GetNumberOfDimensions(),reader->GetComponentTypeAsString(reader->GetComponentType()),type);
63 //====================================================================
64 void vvImageReader::Update(int dim,std::string inputPixelType, LoadedImageType type) {
65 //CALL_FOR_ALL_DIMS(dim,UpdateWithDim,inputPixelType);
68 mInputPixelType=inputPixelType;
69 this->start(); //Start heavy read operation in a separate thread
70 while (this->isRunning())
72 qApp->processEvents();
77 void vvImageReader::run()
82 UpdateWithDim<2>(mInputPixelType);
85 UpdateWithDim<3>(mInputPixelType);
88 UpdateWithDim<4>(mInputPixelType);
91 std::cerr << "dimension unknown in Update ! " << std::endl;
94 //====================================================================
96 //====================================================================
97 /*void vvImageReader::Extract(int dim, std::string inputPixelType, int slice) {
98 CALL_FOR_ALL_DIMS(dim, ExtractWithDim, inputPixelType, slice);
100 //====================================================================
101 void vvImageReader::SetInputFilename(const std::string & filename)
103 mInputFilenames.resize(0);
104 mInputFilenames.push_back(filename);
107 //====================================================================
108 void vvImageReader::SetInputFilenames(const std::vector<std::string> & filenames) {
109 mInputFilenames = filenames;
111 //====================================================================