OTB  6.7.0
Orfeo Toolbox
otbImageSeriesFileReaderBase.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
3  * Copyright (C) 2007-2012 Institut Mines Telecom / Telecom Bretagne
4  *
5  * This file is part of Orfeo Toolbox
6  *
7  * https://www.orfeo-toolbox.org/
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21 
22 
23 #ifndef otbImageSeriesFileReaderBase_h
24 #define otbImageSeriesFileReaderBase_h
25 
26 #include <string>
27 
28 #include "itkMacro.h"
29 
30 #include "otbImage.h"
31 #include "otbVectorImage.h"
32 
33 #include "otbImageListSource.h"
34 #include "otbImageFileReader.h"
35 
36 namespace otb {
37 
39 {
40 public:
42 
43  ImageSeriesFileReaderException(const char *file, unsigned int line,
44  const char* message = "Error in IO",
45  const char* loc = "Unknown") :
46  itk::ExceptionObject(file, line, message, loc) {}
47 
48  ImageSeriesFileReaderException(const std::string& file, unsigned int line,
49  const char* message = "Error in IO",
50  const char* loc = "Unknown") :
51  itk::ExceptionObject(file, line, message, loc) {}
52 
53  ImageSeriesFileReaderException(const std::string& file, unsigned int line,
54  const std::string& message = "Error in IO",
55  const std::string& loc = "Unknown") :
56  itk::ExceptionObject(file, line, message, loc) {}
57 };
58 
66 template <class TImage, class TInternalImage = TImage>
68  : public ImageListSource<TImage>
69 {
70 public:
76 
78  itkNewMacro(Self);
79 
82 
83  typedef TImage OutputImageType;
90 
94 
95  typedef TInternalImage InternalImageType;
102 
105 
108 
110 
112  itkGetStringMacro(FileName);
113 
119  virtual void SetFileName(const std::string& file);
120 
122  std::string GetFileName(unsigned int i) const
123  {
124  return this->m_ListOfFileNames.at(i);
125  }
126 
128  itkGetObjectMacro(ImageFileReaderList, ReaderListType);
129  ReaderType * GetImageFileReader(unsigned int i) const
130  {
131  return this->m_ImageFileReaderList->GetNthElement(i);
132  }
134 
136  virtual unsigned int GetNumberOfOutputs() const
137  {
138  return m_ListOfFileNames.size();
139  }
140  OutputImageListType * GetOutput(void) override;
143 
145  virtual OutputImageListType * GenerateOutput(void);
148 
150  void Update() override
151  {
152  this->GenerateData();
153  }
154 
155 protected:
158 
165  virtual void TestFileExistenceAndReadability(std::string& file, FileType fileType);
166  virtual void TestBandSelection(std::vector<unsigned int>& itkNotUsed(bands)) {}
167 
168  void GenerateData(void) override;
169 
177 
181  virtual void ReadMetaFile();
182 
188  virtual void AllocateListOfComponents(void);
189 
191  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
192 
193  std::string m_FileName;
195 
196  std::vector<std::string> m_ListOfFileNames;
197  std::vector<std::vector<unsigned int> > m_ListOfBandSelection;
198  std::vector<InternalRegionType> m_ListOfRegionSelection;
199 
201 
202 private:
204  void operator =(const Self&);
205 }; // end of class
206 
207 } // end of namespace otb
208 
209 #ifndef OTB_MANUAL_INSTANTIATION
211 #endif
212 
213 #endif
Superclass::ValueType ValueType
Definition: otbImage.h:114
void operator=(const Self &)
Superclass::RegionType RegionType
Definition: otbImage.h:155
virtual void TestBandSelection(std::vector< unsigned int > &)
void PrintSelf(std::ostream &os, itk::Indent indent) const override
virtual unsigned int GetNumberOfOutputs() const
virtual OutputImageListType * GenerateOutput(void)
Reads image data.
ImageFileReader< InternalImageType > ReaderType
Superclass::IndexType IndexType
InternalImageType::RegionType InternalRegionType
OutputImageType::RegionType RegionType
Superclass::IndexType IndexType
Definition: otbImage.h:143
virtual void SetFileName(const std::string &file)
OutputImageListType * GetOutput(void) override
virtual void TestFileExistenceAndReadability(std::string &file, FileType fileType)
std::string GetFileName(unsigned int i) const
ImageSeriesFileReaderException(const std::string &file, unsigned int line, const char *message="Error in IO", const char *loc="Unknown")
ReaderType * GetImageFileReader(unsigned int i) const
OutputImageListType::Pointer OutputImageListPointerType
This class is a generic all-purpose wrapping around an std::vector<itk::SmartPointer<ObjectType> >...
Definition: otbObjectList.h:40
Superclass::SizeType SizeType
itkGetObjectMacro(ImageFileReaderList, ReaderListType)
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
Superclass::ValueType ValueType
itk::SmartPointer< const Self > ConstPointer
InternalImageType::InternalPixelType InternalPixelType
InternalImageType::IndexType InternalIndexType
std::vector< std::string > m_ListOfFileNames
OutputImageListType::ConstPointer OutputImageListConstPointerType
InternalImageType::SizeType InternalSizeType
This class represent a list of images.
Definition: otbImageList.h:39
std::vector< InternalRegionType > m_ListOfRegionSelection
std::vector< std::vector< unsigned int > > m_ListOfBandSelection
itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
Superclass::InternalPixelType InternalPixelType
InternalImageType::Pointer InternalImagePointerType
Superclass::InternalPixelType InternalPixelType
Definition: otbImage.h:120
ImageSeriesFileReaderException(const char *file, unsigned int line, const char *message="Error in IO", const char *loc="Unknown")
Superclass::RegionType RegionType
ImageList< OutputImageType > OutputImageListType
Base class for all the filters producing an otbImageList.
InternalImageType::ValueType InternalValueType
Superclass::SizeType SizeType
Definition: otbImage.h:149
OutputImageType::Pointer OutputImagePointerType
OutputImageType::InternalPixelType PixelType
ImageSeriesFileReaderException(const std::string &file, unsigned int line, const std::string &message="Error in IO", const std::string &loc="Unknown")