OTB  6.7.0
Orfeo Toolbox
otbPolyLineParametricPathWithValue.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 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"
28 #pragma GCC diagnostic pop
29 #else
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>
51  : public itk::PolyLineParametricPath<VDimension>
52 {
53 public:
59 
61  itkNewMacro(Self);
62 
64  itkTypeMacro(PolyLineParametricPath, MySuperclass);
65 
67  typedef TValue ValueType;
68 
70  typedef typename Superclass::VertexType VertexType;
71  typedef typename Superclass::VertexListType VertexListType;
72  typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
74 
75 // typedef itk::ImageRegion<2> RegionType;
77  typedef typename RegionType::SizeType SizeType;
78  typedef typename RegionType::IndexType IndexType;
79 
80  itkGetMacro(Key, std::string);
81 
82  void SetValue(ValueType value)
83  {
84  itk::MetaDataDictionary& dict = this->GetMetaDataDictionary();
85  itk::EncapsulateMetaData<ValueType>(dict, m_Key, value);
86  }
87 
88  ValueType GetValue(void) const
89  {
90  ValueType resp(0);
91  const itk::MetaDataDictionary& dict = this->GetMetaDataDictionary();
92  if (dict.HasKey(m_Key))
93  {
94  itk::ExposeMetaData<ValueType>(dict, m_Key, resp);
95  }
96  else
97  {
98  itkGenericExceptionMacro(<< "Key " << m_Key << " not found in metadata dictionary !");
99  }
100  return resp;
101  }
102 
107  virtual double GetLength() const;
108 
109  virtual void AddVertex(const ContinuousIndexType& vertex);
110 
115  virtual RegionType GetBoundingRegion(void) const;
116 
117 protected:
120 
123 
125  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
126 
127  virtual void ComputeLength() const;
128  virtual void ComputeBoundingRegion() const;
129  void Modified() const override;
130 
131 private:
132  PolyLineParametricPathWithValue(const Self &) = delete;
133  void operator =(const Self&) = delete;
134  std::string m_Key;
135  mutable double m_Length;
136  mutable bool m_LengthIsValid;
139 
140 };
141 } // End namespace otb
142 
143 #ifndef OTB_MANUAL_INSTANTIATION
145 #endif
146 
147 #endif
bool HasKey(const std::string &) const
This class implement a PolyLineParametricPath for which a value can be set. The value is stored in th...
itk::PolyLineParametricPath< VDimension > Superclass