OTB  7.2.0
Orfeo Toolbox
otbVectorDataToRandomLineGenerator.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 otbVectorDataToRandomLineGenerator_h
22 #define otbVectorDataToRandomLineGenerator_h
23 
24 #include "otbVectorDataSource.h"
25 #include "otbVectorData.h"
26 #include "itkPreOrderTreeIterator.h"
27 #include "itkMersenneTwisterRandomVariateGenerator.h"
28 #include <string>
29 
30 namespace otb
31 {
48 template <class TVectorData>
49 class ITK_EXPORT VectorDataToRandomLineGenerator : public VectorDataSource<TVectorData>
50 {
51 public:
55  typedef itk::SmartPointer<Self> Pointer;
56  typedef itk::SmartPointer<const Self> ConstPointer;
57 
60 
62  itkNewMacro(Self);
63 
64  typedef TVectorData VectorDataType;
65  typedef typename VectorDataType::Pointer VectorDataPointerType;
66  typedef typename VectorDataType::DataNodeType DataNodeType;
67  typedef typename DataNodeType::PolygonType::RegionType RegionType;
69  typedef typename DataNodeType::LineType LineType;
70  typedef typename DataNodeType::LineType::VertexType VertexType;
71  typedef typename std::vector<PointType> PointVectorType;
72 
73  typedef itk::PreOrderTreeIterator<typename VectorDataType::DataTreeType> TreeIteratorType;
74 
75  typedef itk::Statistics::MersenneTwisterRandomVariateGenerator RandomGeneratorType;
76 
78  using Superclass::SetInput;
79  void SetInput(const VectorDataType*);
80  const VectorDataType* GetInput() const;
82 
83  itkGetConstMacro(NumberOfOutputLine, unsigned int);
84  itkSetMacro(NumberOfOutputLine, unsigned int);
85 
86  itkGetConstMacro(MinLineSize, unsigned int);
87  itkSetMacro(MinLineSize, unsigned int);
88 
89  itkGetConstMacro(MaxLineSize, unsigned int);
90  itkSetMacro(MaxLineSize, unsigned int);
91 
93  void SetSeed(unsigned int seed)
94  {
95  m_RandomGenerator->SetSeed(seed);
96  m_RandomSizeGenerator->SetSeed(seed);
97  }
99 
100 protected:
103  {
104  }
105  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
106 
108  void GenerateData(void) override;
109 
110  PointVectorType RandomPointsGenerator(DataNodeType* node);
111 
112 private:
113  VectorDataToRandomLineGenerator(const Self&) = delete;
114  void operator=(const Self&) = delete;
115 
116  std::string GetNextID()
117  {
118  std::ostringstream oss;
119  oss << m_CurrentID++;
120  return oss.str();
121  }
122 
123  RandomGeneratorType::Pointer m_RandomGenerator;
124  RandomGeneratorType::Pointer m_RandomSizeGenerator;
125 
126  unsigned int m_NumberOfOutputLine;
127  unsigned int m_MinLineSize;
128  unsigned int m_MaxLineSize;
129  unsigned int m_CurrentID;
130 };
131 
132 } // end namespace otb
133 
134 #ifndef OTB_MANUAL_INSTANTIATION
136 #endif
137 
138 #endif
Filter hierarchy for generating VectorData.
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Produces a VectorData Containing Random Lines.
DataNodeType::PolygonType::RegionType RegionType
VectorImageType::PointType PointType
Definition: mvdTypes.h:183
itk::PreOrderTreeIterator< typename VectorDataType::DataTreeType > TreeIteratorType
itk::Statistics::MersenneTwisterRandomVariateGenerator RandomGeneratorType