OTB  9.0.0
Orfeo Toolbox
otbVectorDataToRandomLineGenerator.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 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;
68  typedef typename DataNodeType::PointType PointType;
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
otb::VectorDataToRandomLineGenerator::VectorDataPointerType
VectorDataType::Pointer VectorDataPointerType
Definition: otbVectorDataToRandomLineGenerator.h:65
otb::VectorDataToRandomLineGenerator
Produces a VectorData Containing Random Lines.
Definition: otbVectorDataToRandomLineGenerator.h:49
otb::VectorDataToRandomLineGenerator::RegionType
DataNodeType::PolygonType::RegionType RegionType
Definition: otbVectorDataToRandomLineGenerator.h:67
otb::VectorDataToRandomLineGenerator::m_NumberOfOutputLine
unsigned int m_NumberOfOutputLine
Definition: otbVectorDataToRandomLineGenerator.h:126
otb::VectorDataToRandomLineGenerator::LineType
DataNodeType::LineType LineType
Definition: otbVectorDataToRandomLineGenerator.h:69
otb::VectorDataToRandomLineGenerator::DataNodeType
VectorDataType::DataNodeType DataNodeType
Definition: otbVectorDataToRandomLineGenerator.h:66
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::VectorDataToRandomLineGenerator::TreeIteratorType
itk::PreOrderTreeIterator< typename VectorDataType::DataTreeType > TreeIteratorType
Definition: otbVectorDataToRandomLineGenerator.h:73
otb::VectorDataToRandomLineGenerator::m_CurrentID
unsigned int m_CurrentID
Definition: otbVectorDataToRandomLineGenerator.h:129
otb::VectorDataToRandomLineGenerator::SetSeed
void SetSeed(unsigned int seed)
Definition: otbVectorDataToRandomLineGenerator.h:93
otb::VectorDataToRandomLineGenerator::Self
VectorDataToRandomLineGenerator Self
Definition: otbVectorDataToRandomLineGenerator.h:53
otb::VectorDataToRandomLineGenerator::VectorDataType
TVectorData VectorDataType
Definition: otbVectorDataToRandomLineGenerator.h:62
otb::VectorDataToRandomLineGenerator::PointVectorType
std::vector< PointType > PointVectorType
Definition: otbVectorDataToRandomLineGenerator.h:71
otb::VectorDataToRandomLineGenerator::m_MaxLineSize
unsigned int m_MaxLineSize
Definition: otbVectorDataToRandomLineGenerator.h:128
otb::VectorDataToRandomLineGenerator::m_RandomSizeGenerator
RandomGeneratorType::Pointer m_RandomSizeGenerator
Definition: otbVectorDataToRandomLineGenerator.h:124
otbVectorDataToRandomLineGenerator.hxx
otbVectorDataSource.h
otb::VectorDataToRandomLineGenerator::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbVectorDataToRandomLineGenerator.h:56
otb::VectorDataToRandomLineGenerator::RandomGeneratorType
itk::Statistics::MersenneTwisterRandomVariateGenerator RandomGeneratorType
Definition: otbVectorDataToRandomLineGenerator.h:75
otb::VectorDataToRandomLineGenerator::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbVectorDataToRandomLineGenerator.h:55
otb::VectorDataToRandomLineGenerator::VertexType
DataNodeType::LineType::VertexType VertexType
Definition: otbVectorDataToRandomLineGenerator.h:70
otbVectorData.h
otb::VectorDataToRandomLineGenerator::GetNextID
std::string GetNextID()
Definition: otbVectorDataToRandomLineGenerator.h:116
otb::VectorDataToRandomLineGenerator::PointType
DataNodeType::PointType PointType
Definition: otbVectorDataToRandomLineGenerator.h:68
otb::VectorDataToRandomLineGenerator::~VectorDataToRandomLineGenerator
~VectorDataToRandomLineGenerator() override
Definition: otbVectorDataToRandomLineGenerator.h:102
otb::VectorDataToRandomLineGenerator::m_RandomGenerator
RandomGeneratorType::Pointer m_RandomGenerator
Definition: otbVectorDataToRandomLineGenerator.h:123
otb::VectorDataSource
Filter hierarchy for generating VectorData.
Definition: otbVectorDataSource.h:42
otb::VectorDataToRandomLineGenerator::Superclass
VectorDataSource< TVectorData > Superclass
Definition: otbVectorDataToRandomLineGenerator.h:54
otb::VectorDataToRandomLineGenerator::m_MinLineSize
unsigned int m_MinLineSize
Definition: otbVectorDataToRandomLineGenerator.h:127