OTB  9.0.0
Orfeo Toolbox
otbWrapperInputImageParameter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbWrapperInputImageParameter_h
22 #define otbWrapperInputImageParameter_h
23 
24 
25 #include "otbImageFileReader.h"
26 #include "otbClampImageFilter.h"
27 #include "otbWrapperParameter.h"
28 
29 #include "itkImageBase.h"
30 
31 #include <string>
32 
33 namespace otb
34 {
35 namespace Wrapper
36 {
43 class OTBApplicationEngine_EXPORT InputImageParameter : public Parameter
44 {
45 public:
49  typedef itk::SmartPointer<Self> Pointer;
50  typedef itk::SmartPointer<const Self> ConstPointer;
51 
53  itkNewMacro(Self);
54 
56  itkTypeMacro(InputImageParameter, Parameter);
57 
58  struct Connector
59  {
60  itk::Object::Pointer app;
61  std::string key;
62  bool isMem;
63  };
64 
66  bool SetFromFileName(std::string filename);
67  itkGetConstReferenceMacro(FileName, std::string);
69 
71  {
72  m_Connection = std::move(c);
73  }
74 
75  const Connector& GetConnection() const
76  {
77  return m_Connection;
78  }
79 
80  void SetConnectionMode(bool isMem)
81  {
82  m_Connection.isMem = isMem;
83  }
84 
86  ImageBaseType const* GetImage() const;
87  ImageBaseType* GetImage();
89 
91  UInt8ImageType* GetUInt8Image();
92  UInt16ImageType* GetUInt16Image();
93  Int16ImageType* GetInt16Image();
94  UInt32ImageType* GetUInt32Image();
95  Int32ImageType* GetInt32Image();
96  FloatImageType* GetFloatImage();
97  DoubleImageType* GetDoubleImage();
99 
100  UInt8VectorImageType* GetUInt8VectorImage();
101  UInt16VectorImageType* GetUInt16VectorImage();
102  Int16VectorImageType* GetInt16VectorImage();
103  UInt32VectorImageType* GetUInt32VectorImage();
104  Int32VectorImageType* GetInt32VectorImage();
105  FloatVectorImageType* GetFloatVectorImage();
106  DoubleVectorImageType* GetDoubleVectorImage();
107 
108  UInt8RGBImageType* GetUInt8RGBImage();
109  UInt8RGBAImageType* GetUInt8RGBAImage();
110 
111  // Complex image
112  ComplexInt16ImageType* GetComplexInt16Image();
113  ComplexInt32ImageType* GetComplexInt32Image();
114  ComplexFloatImageType* GetComplexFloatImage();
115  ComplexDoubleImageType* GetComplexDoubleImage();
116 
117  ComplexInt16VectorImageType* GetComplexInt16VectorImage();
118  ComplexInt32VectorImageType* GetComplexInt32VectorImage();
119  ComplexFloatVectorImageType* GetComplexFloatVectorImage();
120  ComplexDoubleVectorImageType* GetComplexDoubleVectorImage();
121 
123  template <class TImageType>
124  TImageType* GetImage();
125 
127  void SetImage(ImageBaseType* image);
128 
129 
131  template <class TInputImage, class TOutputImage>
132  TOutputImage* CastImage();
133 
134  bool HasValue() const override;
135  void ClearValue() override;
136 
137  ParameterType GetType() const override;
138  std::string ToString() const override;
139  void FromString(const std::string& value) override;
140 
141 protected:
144 
146  ~InputImageParameter() override = default;
147 
148 private:
149  InputImageParameter(const Parameter&) = delete;
150  void operator=(const Parameter&) = delete;
151 
152  std::string m_FileName;
153  itk::ProcessObject::Pointer m_Reader = nullptr;
154 
155  ImageBaseType::Pointer m_Image = nullptr;
156 
157  itk::ProcessObject::Pointer m_OutputCaster = nullptr;
158  itk::DataObject::Pointer m_OutputCasted = nullptr;
159 
160 private:
162  template <typename TOutputImage, typename TInputImage>
163  TOutputImage* Cast(TInputImage*);
164 
166  std::string m_PreviousFileName;
167 
169  bool m_UseFilename = true;
170 
171  Connector m_Connection{};
172 
173 }; // End class InputImage Parameter
174 
175 } // End namespace Wrapper
176 } // End namespace otb
177 
178 #ifndef OTB_MANUAL_INSTANTIATION
180 #endif
181 
182 #endif
otb::Wrapper::InputImageParameter
This class represents a InputImage parameter.
Definition: otbWrapperInputImageParameter.h:43
otb::Wrapper::Parameter
This class represent a parameter for the wrapper framework This class is a high level class represent...
Definition: otbWrapperParameter.h:49
otb::Wrapper::InputImageParameter::m_PreviousFileName
std::string m_PreviousFileName
Definition: otbWrapperInputImageParameter.h:166
otb::Wrapper::InputImageParameter::Superclass
Parameter Superclass
Definition: otbWrapperInputImageParameter.h:48
otb::Wrapper::InputImageParameter::Self
InputImageParameter Self
Definition: otbWrapperInputImageParameter.h:47
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::Image
Creation of an "otb" image which contains metadata.
Definition: otbImage.h:89
otb::Wrapper::InputImageParameter::m_FileName
std::string m_FileName
Definition: otbWrapperInputImageParameter.h:152
otb::Wrapper::InputImageParameter::GetConnection
const Connector & GetConnection() const
Definition: otbWrapperInputImageParameter.h:75
otb::Wrapper::InputImageParameter::SetConnection
void SetConnection(Connector c)
Definition: otbWrapperInputImageParameter.h:70
otb::Wrapper::InputImageParameter::SetConnectionMode
void SetConnectionMode(bool isMem)
Definition: otbWrapperInputImageParameter.h:80
otb::Wrapper::InputImageParameter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbWrapperInputImageParameter.h:49
otb::Wrapper::InputImageParameter::Connector::key
std::string key
Definition: otbWrapperInputImageParameter.h:61
otb::Wrapper::InputImageParameter::Connector::app
itk::Object::Pointer app
Definition: otbWrapperInputImageParameter.h:60
otb::Wrapper::ImageBaseType
itk::ImageBase< 2 > ImageBaseType
Definition: otbWrapperTypes.h:180
otb::Wrapper::InputImageParameter::Connector
Definition: otbWrapperInputImageParameter.h:58
otbClampImageFilter.h
otb::Wrapper::InputImageParameter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbWrapperInputImageParameter.h:50
otbWrapperParameter.h
otb::Wrapper::MetaDataHelper::GetType
OTBApplicationEngine_EXPORT MDType GetType(const std::string &val)
otbImageFileReader.h
otbWrapperInputImageParameter.hxx
otb::Wrapper::InputImageParameter::Connector::isMem
bool isMem
Definition: otbWrapperInputImageParameter.h:62
otb::Wrapper::ParameterType
ParameterType
Definition: otbWrapperTypes.h:37
otb::VectorImage
Creation of an "otb" vector image which contains metadata.
Definition: otbVectorImage.h:45