OTB  10.0.0
Orfeo Toolbox
otbVectorDataToRandomLineGenerator.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2024 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 "itkMersenneTwisterRandomVariateGenerator.h"
27 #include <string>
28 
29 namespace otb
30 {
47 template <class TVectorData>
48 class ITK_EXPORT VectorDataToRandomLineGenerator : public VectorDataSource<TVectorData>
49 {
50 public:
54  typedef itk::SmartPointer<Self> Pointer;
55  typedef itk::SmartPointer<const Self> ConstPointer;
56 
59 
61  itkNewMacro(Self);
62 
63  typedef TVectorData VectorDataType;
64  typedef typename VectorDataType::Pointer VectorDataPointerType;
65  typedef typename VectorDataType::DataNodeType DataNodeType;
66  typedef typename DataNodeType::PolygonType::RegionType RegionType;
67  typedef typename DataNodeType::PointType PointType;
68  typedef typename DataNodeType::LineType LineType;
69  typedef typename DataNodeType::LineType::VertexType VertexType;
70  typedef typename std::vector<PointType> PointVectorType;
71 
72  typedef itk::Statistics::MersenneTwisterRandomVariateGenerator RandomGeneratorType;
73 
75  using Superclass::SetInput;
76  void SetInput(const VectorDataType*);
77  const VectorDataType* GetInput() const;
79 
80  itkGetConstMacro(NumberOfOutputLine, unsigned int);
81  itkSetMacro(NumberOfOutputLine, unsigned int);
82 
83  itkGetConstMacro(MinLineSize, unsigned int);
84  itkSetMacro(MinLineSize, unsigned int);
85 
86  itkGetConstMacro(MaxLineSize, unsigned int);
87  itkSetMacro(MaxLineSize, unsigned int);
88 
90  void SetSeed(unsigned int seed)
91  {
92  m_RandomGenerator->SetSeed(seed);
93  m_RandomSizeGenerator->SetSeed(seed);
94  }
96 
97 protected:
100  {
101  }
102  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
103 
105  void GenerateData(void) override;
106 
107  PointVectorType RandomPointsGenerator(DataNodeType* node);
108 
109 private:
111  void operator=(const Self&) = delete;
112 
113  std::string GetNextID()
114  {
115  std::ostringstream oss;
116  oss << m_CurrentID++;
117  return oss.str();
118  }
119 
120  RandomGeneratorType::Pointer m_RandomGenerator;
121  RandomGeneratorType::Pointer m_RandomSizeGenerator;
122 
123  unsigned int m_NumberOfOutputLine;
124  unsigned int m_MinLineSize;
125  unsigned int m_MaxLineSize;
126  unsigned int m_CurrentID;
127 };
128 
129 } // end namespace otb
130 
131 #ifndef OTB_MANUAL_INSTANTIATION
133 #endif
134 
135 #endif
Filter hierarchy for generating VectorData.
Produces a VectorData Containing Random Lines.
void operator=(const Self &)=delete
itk::Statistics::MersenneTwisterRandomVariateGenerator RandomGeneratorType
VectorDataToRandomLineGenerator(const Self &)=delete
DataNodeType::PolygonType::RegionType RegionType
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.