1 /*=========================================================================
5 Author : Pierre Seroul (pierre.seroul@gmail.com)
8 Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
9 CREATIS-LRMN http://www.creatis.insa-lyon.fr
11 This program is free software: you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation, version 3 of the License.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 =========================================================================*/
24 #ifndef vvImageReader_CXX
25 #define vvImageReader_CXX
27 #include <QApplication>
28 #include <itkImageFileReader.h>
29 #include "vvImageReader.h"
30 #include "vvImageReader.txx"
33 //====================================================================
34 vvImageReader::vvImageReader()
37 mInputFilenames.resize(0);
39 mType = UNDEFINEDIMAGETYPE;
42 vvImageReader::~vvImageReader() { }
44 void vvImageReader::Update()
49 void vvImageReader::Update(LoadedImageType type)
51 itk::ImageIOBase::Pointer reader = itk::ImageIOFactory::CreateImageIO(mInputFilenames[0].c_str(), itk::ImageIOFactory::ReadMode);
53 mLastError="Unable to read file.";
56 reader->SetFileName(mInputFilenames[0]);
57 reader->ReadImageInformation();
58 if (mInputFilenames.size() > 1)
59 Update(reader->GetNumberOfDimensions()+1,reader->GetComponentTypeAsString(reader->GetComponentType()),type);
61 Update(reader->GetNumberOfDimensions(),reader->GetComponentTypeAsString(reader->GetComponentType()),type);
65 //====================================================================
66 void vvImageReader::Update(int dim,std::string inputPixelType, LoadedImageType type) {
67 //CALL_FOR_ALL_DIMS(dim,UpdateWithDim,inputPixelType);
70 mInputPixelType=inputPixelType;
71 this->start(); //Start heavy read operation in a separate thread
72 while (this->isRunning())
74 qApp->processEvents();
79 void vvImageReader::run()
84 UpdateWithDim<2>(mInputPixelType);
87 UpdateWithDim<3>(mInputPixelType);
90 UpdateWithDim<4>(mInputPixelType);
93 std::cerr << "dimension unknown in Update ! " << std::endl;
96 //====================================================================
98 //====================================================================
99 /*void vvImageReader::Extract(int dim, std::string inputPixelType, int slice) {
100 CALL_FOR_ALL_DIMS(dim, ExtractWithDim, inputPixelType, slice);
102 //====================================================================
103 void vvImageReader::SetInputFilename(const std::string & filename)
105 mInputFilenames.resize(0);
106 mInputFilenames.push_back(filename);
109 //====================================================================
110 void vvImageReader::SetInputFilenames(const std::vector<std::string> & filenames) {
111 mInputFilenames = filenames;
113 //====================================================================