OTB  10.0.0
Orfeo Toolbox
otbImageSeriesFileReaderBase.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2024 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
Reads image data.
itk::SmartPointer< Self > Pointer
Base class for all the filters producing an otbImageList.
This class represent a list of images.
Definition: otbImageList.h:40
itk::SmartPointer< const Self > ConstPointer
Definition: otbImageList.h:46
itk::SmartPointer< Self > Pointer
Definition: otbImageList.h:45
virtual void TestBandSelection(std::vector< unsigned int > &)
ImageSeriesFileReaderBase(const Self &)
OutputImageType::InternalPixelType PixelType
std::vector< std::string > m_ListOfFileNames
OutputImageListType * GetOutput(void) override
itkGetObjectMacro(ImageFileReaderList, ReaderListType)
virtual unsigned int GetNumberOfOutputs() const
OutputImageType::Pointer OutputImagePointerType
std::vector< std::vector< unsigned int > > m_ListOfBandSelection
virtual void TestFileExistenceAndReadability(std::string &file, FileType fileType)
InternalImageType::Pointer InternalImagePointerType
~ImageSeriesFileReaderBase() override=default
InternalImageType::ValueType InternalValueType
ImageList< OutputImageType > OutputImageListType
OutputImageType::RegionType RegionType
OutputImageListType::ConstPointer OutputImageListConstPointerType
void operator=(const Self &)
itk::SmartPointer< const Self > ConstPointer
InternalImageType::RegionType InternalRegionType
InternalImageType::IndexType InternalIndexType
void PrintSelf(std::ostream &os, itk::Indent indent) const override
ReaderType * GetImageFileReader(unsigned int i) const
OutputImageListType::Pointer OutputImageListPointerType
InternalImageType::InternalPixelType InternalPixelType
virtual void SetFileName(const std::string &file)
InternalImageType::SizeType InternalSizeType
std::string GetFileName(unsigned int i) const
ImageFileReader< InternalImageType > ReaderType
virtual OutputImageListType * GenerateOutput(void)
std::vector< InternalRegionType > m_ListOfRegionSelection
itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
ImageSeriesFileReaderException(const char *file, unsigned int line, const char *message="Error in IO", const char *loc="Unknown")
ImageSeriesFileReaderException(const std::string &file, unsigned int line, const std::string &message="Error in IO", const std::string &loc="Unknown")
ImageSeriesFileReaderException(const std::string &file, unsigned int line, const char *message="Error in IO", const char *loc="Unknown")
This class is a generic all-purpose wrapping around an std::vector<itk::SmartPointer<ObjectType> >.
Definition: otbObjectList.h:41
itk::SmartPointer< Self > Pointer
Definition: otbObjectList.h:46
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.