Orfeo Toolbox  4.0
otbImageReference.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ORFEO Toolbox
4  Language: C++
5  Date: $Date$
6  Version: $Revision$
7 
8 
9  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
10  See OTBCopyright.txt for details.
11 
12 
13  This software is distributed WITHOUT ANY WARRANTY; without even
14  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  PURPOSE. See the above copyright notices for more information.
16 
17 =========================================================================*/
18 #ifndef __otbImageReference_h
19 #define __otbImageReference_h
20 
21 #include "itkVector.h"
22 #include "itkPoint.h"
23 #include "itkMacro.h"
24 
25 namespace otb
26 {
27 namespace ogr
28 {
35 template <typename TPrecision> class ImageReference
36 {
37 public:
38  typedef TPrecision PrecisionType;
39  enum { Dimension = 2 };
42  itkTypeMacro(ImageReference, void);
43  bool GetDebug() const
44  {
45  return m_Holder.GetDebug();
46  }
48 
54 
59  ImageReference(itk::Object const& holder)
60  : m_Holder(holder)
61  {
62  m_Spacing.Fill(1);
63  m_Origin.Fill(0);
64  }
69  ImageReference(SpacingType const& spacing, OriginType const& origin, itk::Object const& holder)
70  : m_Holder(holder) , m_Spacing(spacing), m_Origin(origin)
71  {
72  }
73 
74  void Modified() const
75  {
77  }
78 
83  itkGetConstReferenceMacro(Origin, OriginType);
84  itkSetMacro(Origin, OriginType);
85  void SetOrigin(const TPrecision origin[Dimension])
86  {
87  const OriginType p(origin);
88  this->SetOrigin(p);
89  }
91 
96  itkGetConstReferenceMacro(Spacing, SpacingType);
97  void SetSpacing(const SpacingType& spacing)
98  {
99  // itkDebugMacro("setting Spacing to " << spacing);
100  if (this->m_Spacing != spacing)
101  {
102  this->m_Spacing = spacing;
103  this->Modified();
104  }
105  }
106  void SetSpacing(const TPrecision spacing[Dimension])
107  {
108  const SpacingType s(spacing);
109  this->SetSpacing(s);
110  }
112 
120  void TransformPointToPhysicalPoint(const PointType& point, PointType& physicalPoint) const
121  {
122  for (size_t i=0; i!=Dimension; ++i)
123  physicalPoint[i] = point[i] * m_Spacing[i] + m_Origin[i];
124  }
125 
133  void TransformPointToPhysicalPoint(const PointType& point) const
134  {
135  // why no loop on VDimension ?
136  PointType physicalPoint;
137  for (size_t i=0; i!=Dimension; ++i)
138  physicalPoint[i] = point[i] * m_Spacing[i] + m_Origin[i];
139  return physicalPoint;
140  }
141 
151  {
152  m_Spacing = rhs.m_Spacing;
153  m_Origin = rhs.m_Origin;
154  return *this;
155  }
156 
157 private:
161 };
162 
163 } // ogr namespace
164 
165 } // end namespace otb
166 
167 #ifndef OTB_MANUAL_INSTANTIATION
168 // #include "otbImageReference.txx"
169 #endif
170 
171 #endif // __otbImageReference_h

Generated at Sat Mar 8 2014 15:59:27 for Orfeo Toolbox with doxygen 1.8.3.1