OTB  7.2.0
Orfeo Toolbox
otbVectorData.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 otbVectorData_h
22 #define otbVectorData_h
23 
24 #include "itkTreeContainer.h"
25 #include "itkDataObject.h"
26 #include "otbDataNode.h"
27 
28 namespace otb
29 {
57 template <class TPrecision = double, unsigned int VDimension = 2, class TValuePrecision = double>
58 class VectorData : public itk::DataObject
59 {
60 public:
62  typedef VectorData Self;
63  typedef itk::DataObject Superclass;
64  typedef itk::SmartPointer<Self> Pointer;
65  typedef itk::SmartPointer<const Self> ConstPointer;
66 
68  itkNewMacro(Self);
69  itkTypeMacro(VectorData, DataObject);
70  itkStaticConstMacro(Dimension, unsigned int, VDimension);
72 
74  typedef TPrecision PrecisionType;
75  typedef TValuePrecision ValuePrecisionType;
76  // define VDimension Dimension;
79  typedef itk::TreeContainer<DataNodePointerType> DataTreeType;
80  typedef typename DataTreeType::Pointer DataTreePointerType;
81 
83  typedef typename DataNodeType::LineType LineType;
85 
86  typedef itk::Vector<double, 2> SpacingType;
87  typedef itk::Point<double, 2> OriginType;
88 
89  itkGetObjectMacro(DataTree, DataTreeType);
90  itkGetConstObjectMacro(DataTree, DataTreeType);
91 
92  virtual void SetProjectionRef(const std::string& projectionRef);
93  virtual std::string GetProjectionRef() const;
94 
98  itkSetMacro(Origin, OriginType);
99  virtual void SetOrigin(const double origin[2]);
100  virtual void SetOrigin(const float origin[2]);
102 
103  itkGetConstReferenceMacro(Origin, OriginType);
104 
108  virtual void SetSpacing(const SpacingType& spacing);
109  virtual void SetSpacing(const double spacing[2]);
110  virtual void SetSpacing(const float spacing[2]);
112 
113  itkGetConstReferenceMacro(Spacing, SpacingType);
114 
116  virtual bool Clear();
117 
119  virtual int Size() const;
120 
121  void TransformPointToPhysicalPoint(const PointType& point, PointType& physicalPoint) const
122  {
123  physicalPoint[0] = point[0] * m_Spacing[0] + m_Origin[0];
124  physicalPoint[1] = point[1] * m_Spacing[1] + m_Origin[1];
125  }
126 
134  void Graft(const itk::DataObject* data) override;
135 
136 protected:
138  VectorData();
139 
141  ~VectorData() override
142  {
143  }
144 
146  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
147 
148 private:
149  VectorData(const Self&) = delete;
150  void operator=(const Self&) = delete;
151 
153  DataTreePointerType m_DataTree;
154 
155  SpacingType m_Spacing;
156  OriginType m_Origin;
157 };
158 } // end namespace otb
159 
160 #ifndef OTB_MANUAL_INSTANTIATION
161 #include "otbVectorData.hxx"
162 #endif
163 
164 #endif
void TransformPointToPhysicalPoint(const PointType &point, PointType &physicalPoint) const
DataTreeType::Pointer DataTreePointerType
Definition: otbVectorData.h:80
virtual void SetProjectionRef(const std::string &projectionRef)
itkGetObjectMacro(DataTree, DataTreeType)
virtual bool Clear()
itk::SmartPointer< Self > Pointer
Definition: otbDataNode.h:79
itk::DataObject Superclass
Definition: otbVectorData.h:63
void Graft(const itk::DataObject *data) override
This class implement a PolyLineParametricPath for which a value can be set. The value is stored in th...
TValuePrecision ValuePrecisionType
Definition: otbVectorData.h:75
DataNodeType::PointType PointType
Definition: otbVectorData.h:82
VectorData Self
Definition: otbVectorData.h:62
virtual int Size() const
virtual void SetOrigin(OriginType _arg)
itk::Vector< double, 2 > SpacingType
Definition: otbVectorData.h:86
OriginType m_Origin
This class represents a node of data in a vector data hierarchy.
Definition: otbDataNode.h:73
itk::SmartPointer< Self > Pointer
Definition: otbVectorData.h:64
This class represent a 2D polygon.
Definition: otbPolygon.h:44
itk::SmartPointer< const Self > ConstPointer
Definition: otbVectorData.h:65
DataNodeType::Pointer DataNodePointerType
Definition: otbVectorData.h:78
otb::DataNode< TPrecision, VDimension, TValuePrecision > DataNodeType
Definition: otbVectorData.h:77
virtual std::string GetProjectionRef() const
SpacingType m_Spacing
~VectorData() override
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
DataTreePointerType m_DataTree
itk::TreeContainer< DataNodePointerType > DataTreeType
Definition: otbVectorData.h:79
static const unsigned int Dimension
Definition: otbVectorData.h:70
This class represents a hierarchy of vector data.
Definition: otbVectorData.h:58
virtual void SetSpacing(const SpacingType &spacing)
itk::Point< double, 2 > OriginType
Definition: otbVectorData.h:87
TPrecision PrecisionType
Definition: otbVectorData.h:74
void operator=(const Self &)=delete
DataNodeType::PolygonType PolygonType
Definition: otbVectorData.h:84
DataNodeType::LineType LineType
Definition: otbVectorData.h:83
itk::Point< PrecisionType, VDimension > PointType
Definition: otbDataNode.h:93
void PrintSelf(std::ostream &os, itk::Indent indent) const override