OTB  9.0.0
Orfeo Toolbox
otbImageSeriesFileReaderBase.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 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 {
38 
39 class ImageSeriesFileReaderException : public itk::ExceptionObject
40 {
41 public:
42  itkTypeMacro(ImageSeriesFileReaderException, ExceptionObject);
43 
44  ImageSeriesFileReaderException(const char* file, unsigned int line, const char* message = "Error in IO", const char* loc = "Unknown")
45  : itk::ExceptionObject(file, line, message, loc)
46  {
47  }
48 
49  ImageSeriesFileReaderException(const std::string& file, unsigned int line, const char* message = "Error in IO", const char* loc = "Unknown")
50  : itk::ExceptionObject(file, line, message, loc)
51  {
52  }
53 
54  ImageSeriesFileReaderException(const std::string& file, unsigned int line, const std::string& message = "Error in IO", const std::string& loc = "Unknown")
55  : itk::ExceptionObject(file, line, message, loc)
56  {
57  }
58 };
59 
67 template <class TImage, class TInternalImage = TImage>
69 {
70 public:
74  typedef itk::SmartPointer<Self> Pointer;
75  typedef itk::SmartPointer<const Self> ConstPointer;
76 
78  itkNewMacro(Self);
79 
82 
83  typedef TImage OutputImageType;
84  typedef typename OutputImageType::Pointer OutputImagePointerType;
85  typedef typename OutputImageType::InternalPixelType PixelType;
86  typedef typename OutputImageType::ValueType ValueType;
87  typedef typename OutputImageType::IndexType IndexType;
88  typedef typename OutputImageType::SizeType SizeType;
89  typedef typename OutputImageType::RegionType RegionType;
90 
94 
95  typedef TInternalImage InternalImageType;
96  typedef typename InternalImageType::Pointer InternalImagePointerType;
97  typedef typename InternalImageType::InternalPixelType InternalPixelType;
98  typedef typename InternalImageType::ValueType InternalValueType;
99  typedef typename InternalImageType::IndexType InternalIndexType;
100  typedef typename InternalImageType::SizeType InternalSizeType;
101  typedef typename InternalImageType::RegionType InternalRegionType;
102 
105 
108 
109  typedef itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType;
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:
157  ~ImageSeriesFileReaderBase() override = default;
158 
159  enum FileType
160  {
164  };
170  virtual void TestFileExistenceAndReadability(std::string& file, FileType fileType);
171  virtual void TestBandSelection(std::vector<unsigned int>& itkNotUsed(bands))
172  {
173  }
174 
175  void GenerateData(void) override;
176 
184 
188  virtual void ReadMetaFile();
189 
195  virtual void AllocateListOfComponents(void);
196 
198  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
199 
200  std::string m_FileName;
202 
203  std::vector<std::string> m_ListOfFileNames;
204  std::vector<std::vector<unsigned int>> m_ListOfBandSelection;
205  std::vector<InternalRegionType> m_ListOfRegionSelection;
206 
208 
209 private:
211  void operator=(const Self&);
212 }; // end of class
213 
214 } // end of namespace otb
215 
216 #ifndef OTB_MANUAL_INSTANTIATION
218 #endif
219 
220 #endif
otb::ImageSeriesFileReaderBase::kImageFileName
@ kImageFileName
Definition: otbImageSeriesFileReaderBase.h:162
otb::ImageSeriesFileReaderBase::InternalSizeType
InternalImageType::SizeType InternalSizeType
Definition: otbImageSeriesFileReaderBase.h:100
otb::ImageSeriesFileReaderBase::AllocateListOfComponents
virtual void AllocateListOfComponents(void)
Definition: otbImageSeriesFileReaderBase.hxx:292
otb::ImageSeriesFileReaderBase::InternalImageType
TInternalImage InternalImageType
Definition: otbImageSeriesFileReaderBase.h:95
otb::ImageSeriesFileReaderBase::ReaderPointerType
ReaderType::Pointer ReaderPointerType
Definition: otbImageSeriesFileReaderBase.h:104
otb::ImageSeriesFileReaderBase::OutputImageListType
ImageList< OutputImageType > OutputImageListType
Definition: otbImageSeriesFileReaderBase.h:91
otb::ImageSeriesFileReaderBase::SetFileName
virtual void SetFileName(const std::string &file)
Definition: otbImageSeriesFileReaderBase.hxx:43
otb::ImageListSource< TImage >::OutputImageListPointerType
OutputImageListType::Pointer OutputImageListPointerType
Definition: otbImageListSource.h:62
otb::ImageSeriesFileReaderBase< TImage, TImage >::FileType
FileType
Definition: otbImageSeriesFileReaderBase.h:159
otb::ImageSeriesFileReaderBase::InternalIndexType
InternalImageType::IndexType InternalIndexType
Definition: otbImageSeriesFileReaderBase.h:99
otb::ImageSeriesFileReaderBase::InternalImagePointerType
InternalImageType::Pointer InternalImagePointerType
Definition: otbImageSeriesFileReaderBase.h:96
otb::ImageSeriesFileReaderBase::InternalPixelType
InternalImageType::InternalPixelType InternalPixelType
Definition: otbImageSeriesFileReaderBase.h:97
otbVectorImage.h
otb::ImageSeriesFileReaderBase::kAnyFileName
@ kAnyFileName
Definition: otbImageSeriesFileReaderBase.h:163
otb::bands
Definition: otbParserXPlugins.h:52
otb::ImageSeriesFileReaderBase::PrintSelf
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Definition: otbImageSeriesFileReaderBase.hxx:342
otbImage.h
otb::ImageListSource
Base class for all the filters producing an otbImageList.
Definition: otbImageListSource.h:40
otb::ImageSeriesFileReaderBase::OutputImagePointerType
OutputImageType::Pointer OutputImagePointerType
Definition: otbImageSeriesFileReaderBase.h:84
otb::ImageFileReader::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbImageFileReader.h:74
otb::ImageSeriesFileReaderBase::GetFileName
std::string GetFileName(unsigned int i) const
Definition: otbImageSeriesFileReaderBase.h:122
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::ImageSeriesFileReaderBase::~ImageSeriesFileReaderBase
~ImageSeriesFileReaderBase() override=default
otb::ImageSeriesFileReaderBase::m_ListOfRegionSelection
std::vector< InternalRegionType > m_ListOfRegionSelection
Definition: otbImageSeriesFileReaderBase.h:205
otb::ImageSeriesFileReaderBase::DataObjectPointerArraySizeType
itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
Definition: otbImageSeriesFileReaderBase.h:109
otb::ImageSeriesFileReaderBase::ValueType
OutputImageType::ValueType ValueType
Definition: otbImageSeriesFileReaderBase.h:86
otb::ImageSeriesFileReaderBase::InternalRegionType
InternalImageType::RegionType InternalRegionType
Definition: otbImageSeriesFileReaderBase.h:101
otb::ImageSeriesFileReaderBase::Update
void Update() override
Definition: otbImageSeriesFileReaderBase.h:150
otb::ImageSeriesFileReaderBase::GenerateData
void GenerateData(void) override
Definition: otbImageSeriesFileReaderBase.hxx:316
otb::ImageSeriesFileReaderBase::IndexType
OutputImageType::IndexType IndexType
Definition: otbImageSeriesFileReaderBase.h:87
otb::ImageSeriesFileReaderBase::ReadMetaFile
virtual void ReadMetaFile()
Definition: otbImageSeriesFileReaderBase.hxx:78
otb::ImageSeriesFileReaderException::ImageSeriesFileReaderException
ImageSeriesFileReaderException(const std::string &file, unsigned int line, const char *message="Error in IO", const char *loc="Unknown")
Definition: otbImageSeriesFileReaderBase.h:49
otb::ObjectList::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbObjectList.h:46
otb::ImageSeriesFileReaderBase::Self
ImageSeriesFileReaderBase Self
Definition: otbImageSeriesFileReaderBase.h:72
otb::ImageSeriesFileReaderBase::InternalValueType
InternalImageType::ValueType InternalValueType
Definition: otbImageSeriesFileReaderBase.h:98
otb::ImageSeriesFileReaderBase::ReaderListType
ObjectList< ReaderType > ReaderListType
Definition: otbImageSeriesFileReaderBase.h:106
otb::ImageSeriesFileReaderBase::ReaderListPointerType
ReaderListType::Pointer ReaderListPointerType
Definition: otbImageSeriesFileReaderBase.h:107
otb::ImageSeriesFileReaderBase::itkGetObjectMacro
itkGetObjectMacro(ImageFileReaderList, ReaderListType)
otb::ImageSeriesFileReaderBase
Definition: otbImageSeriesFileReaderBase.h:68
otb::ImageSeriesFileReaderBase::m_ListOfBandSelection
std::vector< std::vector< unsigned int > > m_ListOfBandSelection
Definition: otbImageSeriesFileReaderBase.h:204
otb::ImageSeriesFileReaderBase::PixelType
OutputImageType::InternalPixelType PixelType
Definition: otbImageSeriesFileReaderBase.h:85
otb::ImageList::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbImageList.h:45
otb::ImageSeriesFileReaderBase::ImageSeriesFileReaderBase
ImageSeriesFileReaderBase()
Definition: otbImageSeriesFileReaderBase.hxx:31
otb::ImageSeriesFileReaderException::ImageSeriesFileReaderException
ImageSeriesFileReaderException(const std::string &file, unsigned int line, const std::string &message="Error in IO", const std::string &loc="Unknown")
Definition: otbImageSeriesFileReaderBase.h:54
otb::ImageSeriesFileReaderBase::TestBandSelection
virtual void TestBandSelection(std::vector< unsigned int > &)
Definition: otbImageSeriesFileReaderBase.h:171
otb::ImageSeriesFileReaderBase::Superclass
ImageListSource< TImage > Superclass
Definition: otbImageSeriesFileReaderBase.h:73
otbImageSeriesFileReaderBase.hxx
otb::ImageSeriesFileReaderBase::operator=
void operator=(const Self &)
otb::ImageSeriesFileReaderBase::GenerateOutput
virtual OutputImageListType * GenerateOutput(void)
Definition: otbImageSeriesFileReaderBase.hxx:326
otb::ImageSeriesFileReaderBase::RegionType
OutputImageType::RegionType RegionType
Definition: otbImageSeriesFileReaderBase.h:89
otb::ImageSeriesFileReaderException::ImageSeriesFileReaderException
ImageSeriesFileReaderException(const char *file, unsigned int line, const char *message="Error in IO", const char *loc="Unknown")
Definition: otbImageSeriesFileReaderBase.h:44
otb::ImageSeriesFileReaderBase::GetImageFileReader
ReaderType * GetImageFileReader(unsigned int i) const
Definition: otbImageSeriesFileReaderBase.h:129
otb::ImageSeriesFileReaderBase::kFileName
@ kFileName
Definition: otbImageSeriesFileReaderBase.h:161
otb::ImageSeriesFileReaderBase::GetNumberOfOutputs
virtual unsigned int GetNumberOfOutputs() const
Definition: otbImageSeriesFileReaderBase.h:136
otb::ImageSeriesFileReaderBase::OutputImageListPointerType
OutputImageListType::Pointer OutputImageListPointerType
Definition: otbImageSeriesFileReaderBase.h:92
otb::ImageSeriesFileReaderBase::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbImageSeriesFileReaderBase.h:75
otb::ImageSeriesFileReaderBase::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbImageSeriesFileReaderBase.h:74
otb::ImageSeriesFileReaderException
Definition: otbImageSeriesFileReaderBase.h:39
otb::ImageSeriesFileReaderBase::OutputImageType
TImage OutputImageType
Definition: otbImageSeriesFileReaderBase.h:81
otb::ImageSeriesFileReaderBase::OutputImageListConstPointerType
OutputImageListType::ConstPointer OutputImageListConstPointerType
Definition: otbImageSeriesFileReaderBase.h:93
otb::ImageList
This class represent a list of images.
Definition: otbImageList.h:39
otb::ImageSeriesFileReaderBase::m_ImageFileReaderList
ReaderListPointerType m_ImageFileReaderList
Definition: otbImageSeriesFileReaderBase.h:207
itk
Definition: otbNoDataHelper.h:31
otb::ImageSeriesFileReaderBase::TestFileExistenceAndReadability
virtual void TestFileExistenceAndReadability(std::string &file, FileType fileType)
Definition: otbImageSeriesFileReaderBase.hxx:373
otb::ObjectList
This class is a generic all-purpose wrapping around an std::vector<itk::SmartPointer<ObjectType> >.
Definition: otbObjectList.h:40
otb::ImageSeriesFileReaderBase::m_ListOfFileNames
std::vector< std::string > m_ListOfFileNames
Definition: otbImageSeriesFileReaderBase.h:203
otb::ImageFileReader
Reads image data.
Definition: otbImageFileReader.h:68
otb::ImageSeriesFileReaderBase::SizeType
OutputImageType::SizeType SizeType
Definition: otbImageSeriesFileReaderBase.h:88
otb::ImageSeriesFileReaderBase::m_FileName
std::string m_FileName
Definition: otbImageSeriesFileReaderBase.h:200
otbImageListSource.h
otbImageFileReader.h
otb::ImageSeriesFileReaderBase::m_OutputList
OutputImageListPointerType m_OutputList
Definition: otbImageSeriesFileReaderBase.h:201
otb::ImageSeriesFileReaderBase::GetOutput
OutputImageListType * GetOutput(void) override
Definition: otbImageSeriesFileReaderBase.hxx:56
otb::ImageSeriesFileReaderBase::ReaderType
ImageFileReader< InternalImageType > ReaderType
Definition: otbImageSeriesFileReaderBase.h:103
otb::ImageList::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbImageList.h:46