OTB  9.0.0
Orfeo Toolbox
otbPolyLineParametricPathWithValue.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 otbPolyLineParametricPathWithValue_h
22 #define otbPolyLineParametricPathWithValue_h
23 
24 #if defined(__GNUC__) || defined(__clang__)
25 #pragma GCC diagnostic push
26 #pragma GCC diagnostic ignored "-Wunused-parameter"
27 #include "itkPolyLineParametricPath.h"
28 #pragma GCC diagnostic pop
29 #else
30 #include "itkPolyLineParametricPath.h"
31 #endif
32 
33 #include "itkMetaDataObject.h"
34 #include "otbRemoteSensingRegion.h"
35 #include "otbMacro.h"
36 #include <string>
37 
38 namespace otb
39 {
49 template <class TValue, unsigned int VDimension = 2>
50 class ITK_EXPORT PolyLineParametricPathWithValue : public itk::PolyLineParametricPath<VDimension>
51 {
52 public:
55  typedef itk::PolyLineParametricPath<VDimension> Superclass;
56  typedef itk::SmartPointer<Self> Pointer;
57  typedef itk::SmartPointer<const Self> ConstPointer;
58 
60  itkNewMacro(Self);
61 
63  itkTypeMacro(PolyLineParametricPath, MySuperclass);
64 
66  typedef TValue ValueType;
67 
69  typedef typename Superclass::VertexType VertexType;
70  typedef typename Superclass::VertexListType VertexListType;
71  typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
72  typedef typename VertexListType::ConstIterator VertexListConstIteratorType;
73 
74  // typedef itk::ImageRegion<2> RegionType;
76  typedef typename RegionType::SizeType SizeType;
77  typedef typename RegionType::IndexType IndexType;
78 
79  itkGetMacro(Key, std::string);
80 
81  void SetValue(ValueType value)
82  {
83  itk::MetaDataDictionary& dict = this->GetMetaDataDictionary();
84  itk::EncapsulateMetaData<ValueType>(dict, m_Key, value);
85  }
86 
87  ValueType GetValue(void) const
88  {
89  ValueType resp(0);
90  const itk::MetaDataDictionary& dict = this->GetMetaDataDictionary();
91  if (dict.HasKey(m_Key))
92  {
93  itk::ExposeMetaData<ValueType>(dict, m_Key, resp);
94  }
95  else
96  {
97  itkGenericExceptionMacro(<< "Key " << m_Key << " not found in metadata dictionary !");
98  }
99  return resp;
100  }
101 
106  virtual double GetLength() const;
107 
108  virtual void AddVertex(const ContinuousIndexType& vertex);
109 
114  virtual RegionType GetBoundingRegion(void) const;
115 
116 protected:
119 
122  {
123  }
124 
126  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
127 
128  virtual void ComputeLength() const;
129  virtual void ComputeBoundingRegion() const;
130  void Modified() const override;
131 
132 private:
133  PolyLineParametricPathWithValue(const Self&) = delete;
134  void operator=(const Self&) = delete;
135  std::string m_Key;
136  mutable double m_Length;
137  mutable bool m_LengthIsValid;
140 };
141 } // End namespace otb
142 
143 #ifndef OTB_MANUAL_INSTANTIATION
145 #endif
146 
147 #endif
otb::PolyLineParametricPathWithValue::Self
PolyLineParametricPathWithValue Self
Definition: otbPolyLineParametricPathWithValue.h:54
otbRemoteSensingRegion.h
otbPolyLineParametricPathWithValue.hxx
otb::PolyLineParametricPathWithValue::m_LengthIsValid
bool m_LengthIsValid
Definition: otbPolyLineParametricPathWithValue.h:137
otb::PolyLineParametricPathWithValue::m_Key
std::string m_Key
Definition: otbPolyLineParametricPathWithValue.h:135
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::PolyLineParametricPathWithValue::SizeType
RegionType::SizeType SizeType
Definition: otbPolyLineParametricPathWithValue.h:76
otb::PolyLineParametricPathWithValue::ContinuousIndexType
Superclass::ContinuousIndexType ContinuousIndexType
Definition: otbPolyLineParametricPathWithValue.h:71
otbMacro.h
otb::PolyLineParametricPathWithValue::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbPolyLineParametricPathWithValue.h:57
otb::PolyLineParametricPathWithValue::Superclass
itk::PolyLineParametricPath< VDimension > Superclass
Definition: otbPolyLineParametricPathWithValue.h:55
otb::PolyLineParametricPathWithValue::ValueType
TValue ValueType
Definition: otbPolyLineParametricPathWithValue.h:63
otb::PolyLineParametricPathWithValue::VertexListConstIteratorType
VertexListType::ConstIterator VertexListConstIteratorType
Definition: otbPolyLineParametricPathWithValue.h:72
otb::RemoteSensingRegion< double >::SizeType
itk::ContinuousIndex< Type > SizeType
Definition: otbRemoteSensingRegion.h:79
otb::PolyLineParametricPathWithValue::GetValue
ValueType GetValue(void) const
Definition: otbPolyLineParametricPathWithValue.h:87
otb::PolyLineParametricPathWithValue::m_BoundingRegionIsValid
bool m_BoundingRegionIsValid
Definition: otbPolyLineParametricPathWithValue.h:139
otb::PolyLineParametricPathWithValue::m_Length
double m_Length
Definition: otbPolyLineParametricPathWithValue.h:136
otb::PolyLineParametricPathWithValue::IndexType
RegionType::IndexType IndexType
Definition: otbPolyLineParametricPathWithValue.h:77
otb::RemoteSensingRegion< double >
otb::PolyLineParametricPathWithValue::VertexListType
Superclass::VertexListType VertexListType
Definition: otbPolyLineParametricPathWithValue.h:70
otb::PolyLineParametricPathWithValue::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbPolyLineParametricPathWithValue.h:56
otb::PolyLineParametricPathWithValue
This class implement a PolyLineParametricPath for which a value can be set. The value is stored in th...
Definition: otbPolyLineParametricPathWithValue.h:50
otb::RemoteSensingRegion< double >::IndexType
itk::ContinuousIndex< Type > IndexType
Definition: otbRemoteSensingRegion.h:75
otb::PolyLineParametricPathWithValue::VertexType
Superclass::VertexType VertexType
Definition: otbPolyLineParametricPathWithValue.h:69
otb::PolyLineParametricPathWithValue::m_BoundingRegion
RegionType m_BoundingRegion
Definition: otbPolyLineParametricPathWithValue.h:138
otb::PolyLineParametricPathWithValue::RegionType
otb::RemoteSensingRegion< double > RegionType
Definition: otbPolyLineParametricPathWithValue.h:75
otb::PolyLineParametricPathWithValue::SetValue
void SetValue(ValueType value)
Definition: otbPolyLineParametricPathWithValue.h:81
otb::PolyLineParametricPathWithValue::~PolyLineParametricPathWithValue
~PolyLineParametricPathWithValue() override
Definition: otbPolyLineParametricPathWithValue.h:121