OTB  7.4.0
Orfeo Toolbox
otbPolyLineParametricPathWithValue.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2020 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;
138  mutable RegionType m_BoundingRegion;
140 };
141 } // End namespace otb
142 
143 #ifndef OTB_MANUAL_INSTANTIATION
145 #endif
146 
147 #endif
This class implement a PolyLineParametricPath for which a value can be set. The value is stored in th...
itk::ContinuousIndex< Type > IndexType
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
static constexpr GLenum value() noexcept
itk::ContinuousIndex< Type > SizeType
itk::PolyLineParametricPath< VDimension > Superclass