OTB  9.0.0
Orfeo Toolbox
otbImageReference.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 otbImageReference_h
22 #define otbImageReference_h
23 
24 #include "itkPoint.h"
25 
26 namespace otb
27 {
28 namespace ogr
29 {
38 template <typename TPrecision>
40 {
41 public:
42  typedef TPrecision PrecisionType;
43  enum
44  {
46  };
47 
50 
51  bool GetDebug() const
52  {
53  return m_Holder.GetDebug();
54  }
56 
58  typedef itk::Vector<PrecisionType, 2> SpacingType;
59  typedef itk::Point<PrecisionType, 2> OriginType;
60  typedef itk::Point<PrecisionType, 2> PointType;
62 
63  inline const char* GetNameOfClass()
64  {
65  return "ImageReference";
66  }
67 
72  ImageReference(itk::Object const& holder) : m_Holder(holder)
73  {
74  m_Spacing.Fill(1);
75  m_Origin.Fill(0);
76  }
77 
82  ImageReference(SpacingType const& spacing, OriginType const& origin, itk::Object const& holder) : m_Holder(holder), m_Spacing(spacing), m_Origin(origin)
83  {
84  }
85 
86  void Modified() const
87  {
88  m_Holder.Modified();
89  }
90 
95  itkGetConstReferenceMacro(Origin, OriginType);
96  itkSetMacro(Origin, OriginType);
97  void SetOrigin(const TPrecision origin[Dimension])
98  {
99  const OriginType p(origin);
100  this->SetOrigin(p);
101  }
103 
104 
109  itkGetConstReferenceMacro(Spacing, SpacingType);
110  void SetSpacing(const SpacingType& spacing)
111  {
112  // itkDebugMacro("setting Spacing to " << spacing);
113  if (this->m_Spacing != spacing)
114  {
115  this->m_Spacing = spacing;
116  this->Modified();
117  }
118  }
119  void SetSpacing(const TPrecision spacing[Dimension])
120  {
121  const SpacingType s(spacing);
122  this->SetSpacing(s);
123  }
125 
126 
134  void TransformPointToPhysicalPoint(const PointType& point, PointType& physicalPoint) const
135  {
136  for (size_t i = 0; i != Dimension; ++i)
137  physicalPoint[i] = point[i] * m_Spacing[i] + m_Origin[i];
138  }
140 
149  {
150  // why no loop on VDimension ?
151  PointType physicalPoint;
152  for (size_t i = 0; i != Dimension; ++i)
153  physicalPoint[i] = point[i] * m_Spacing[i] + m_Origin[i];
154  return physicalPoint;
155  }
157 
167  {
168  m_Spacing = rhs.m_Spacing;
169  m_Origin = rhs.m_Origin;
170  return *this;
171  }
173 
174 private:
175  itk::Object const& m_Holder;
178 };
179 
180 } // ogr namespace
181 
182 } // end namespace otb
183 
184 #ifndef OTB_MANUAL_INSTANTIATION
185 // #include "otbImageReference.hxx"
186 #endif
187 
188 #endif // otbImageReference_h
otb::ogr::ImageReference::TransformPointToPhysicalPoint
PointType TransformPointToPhysicalPoint(const PointType &point) const
Definition: otbImageReference.h:148
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::ogr::ImageReference::OriginType
itk::Point< PrecisionType, 2 > OriginType
Definition: otbImageReference.h:59
otb::ogr::ImageReference::operator=
ImageReference & operator=(ImageReference const &rhs)
Definition: otbImageReference.h:166
otb::ogr::ImageReference::m_Spacing
SpacingType m_Spacing
Spacing getter.
Definition: otbImageReference.h:176
otb::ogr::ImageReference::m_Origin
OriginType m_Origin
Spacing getter.
Definition: otbImageReference.h:177
otb::ogr::ImageReference::SpacingType
itk::Vector< PrecisionType, 2 > SpacingType
Definition: otbImageReference.h:58
otb::ogr::ImageReference::GetDebug
bool GetDebug() const
Definition: otbImageReference.h:51
otb::ogr::ImageReference::ImageReference
ImageReference(SpacingType const &spacing, OriginType const &origin, itk::Object const &holder)
Definition: otbImageReference.h:82
otb::ogr::ImageReference
Definition: otbImageReference.h:39
otb::ogr::ImageReference::m_Holder
itk::Object const & m_Holder
Spacing getter.
Definition: otbImageReference.h:175
otb::ogr::ImageReference::SetOrigin
virtual void SetOrigin(OriginType _arg)
Origin getter.
otb::ogr::ImageReference::GetNameOfClass
const char * GetNameOfClass()
Definition: otbImageReference.h:63
otb::ogr::ImageReference::PrecisionType
TPrecision PrecisionType
Definition: otbImageReference.h:42
otb::ogr::ImageReference::SetOrigin
void SetOrigin(const TPrecision origin[Dimension])
Origin setter.
Definition: otbImageReference.h:97
otb::ogr::ImageReference::Dimension
@ Dimension
Definition: otbImageReference.h:45
otb::ogr::ImageReference::PointType
itk::Point< PrecisionType, 2 > PointType
Definition: otbImageReference.h:60
otb::ogr::ImageReference::Modified
void Modified() const
Definition: otbImageReference.h:86
otb::ogr::ImageReference::SetSpacing
void SetSpacing(const SpacingType &spacing)
Spacing getter.
Definition: otbImageReference.h:110
otb::ogr::ImageReference::SetSpacing
void SetSpacing(const TPrecision spacing[Dimension])
Spacing getter.
Definition: otbImageReference.h:119
otb::ogr::ImageReference::ImageReference
ImageReference(itk::Object const &holder)
Definition: otbImageReference.h:72
otb::ogr::ImageReference::TransformPointToPhysicalPoint
void TransformPointToPhysicalPoint(const PointType &point, PointType &physicalPoint) const
Definition: otbImageReference.h:134