OTB  9.0.0
Orfeo Toolbox
otbPatternSampler.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 otbPatternSampler_h
22 #define otbPatternSampler_h
23 
24 #include "otbSamplerBase.h"
25 #include <string>
26 
27 namespace otb
28 {
29 
39 class ITK_EXPORT PatternSampler : public SamplerBase
40 {
41 public:
44  typedef itk::SmartPointer<Self> Pointer;
45  typedef itk::SmartPointer<const Self> ConstPointer;
46 
50  typedef struct Parameter
51  {
52 
54  unsigned long MaxPatternSize = 0;
55 
57  std::vector<bool> Pattern1;
58 
61  std::vector<bool> Pattern2;
62 
64  unsigned int Seed = 0;
65 
66  bool operator!=(const struct Parameter& param) const;
67  } ParameterType;
68 
70  itkNewMacro(Self);
71 
73  itkTypeMacro(PatternSampler, SamplerBase);
74 
76  void SetParameters(const ParameterType& param)
77  {
78  if (m_Parameters != param)
79  {
80  this->Modified();
81  m_Parameters = param;
82  }
83  }
85 
88  {
89  return m_Parameters;
90  }
91 
95  void Reset(void) override;
96 
101  bool TakeSample(void);
102 
107  static void ImportPatterns(const std::string& data, ParameterType& param);
108 
113  static void ExportPatterns(const ParameterType& param, std::string& data);
114 
115 protected:
117  PatternSampler();
118 
120  ~PatternSampler() override
121  {
122  }
123 
124 private:
125  // Not implemented
126  PatternSampler(const Self&);
127  void operator=(const Self&);
128 
130  std::vector<bool> RandArray(unsigned long N, unsigned long T);
131 
133  unsigned long FindBestSize(unsigned long tot);
134 
137 
139  unsigned long m_Index1;
140 
142  unsigned long m_Index2;
143 
148  static unsigned int ParseSymbol(const char& s);
149 };
150 
151 } // namespace otb
152 #endif
otb::PatternSampler::m_Index1
unsigned long m_Index1
Definition: otbPatternSampler.h:139
otb::PatternSampler::Parameter::Pattern1
std::vector< bool > Pattern1
Definition: otbPatternSampler.h:57
otb::PatternSampler::Parameter::Pattern2
std::vector< bool > Pattern2
Definition: otbPatternSampler.h:61
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::PatternSampler::Superclass
SamplerBase Superclass
Definition: otbPatternSampler.h:43
otb::SamplerBase
This is a base class for sampling methods.
Definition: otbSamplerBase.h:37
otb::PatternSampler::m_Index2
unsigned long m_Index2
Definition: otbPatternSampler.h:142
otb::PatternSampler::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbPatternSampler.h:45
otbSamplerBase.h
otb::PatternSampler::Parameter
Definition: otbPatternSampler.h:50
otb::PatternSampler::GetParameters
ParameterType GetParameters()
Definition: otbPatternSampler.h:87
otb::PatternSampler::Self
PatternSampler Self
Definition: otbPatternSampler.h:42
otb::PatternSampler::~PatternSampler
~PatternSampler() override
Definition: otbPatternSampler.h:120
otb::PatternSampler::m_Parameters
ParameterType m_Parameters
Definition: otbPatternSampler.h:136
otb::operator!=
constexpr bool operator!=(extents< StaticExtentsL... > const &lhs, extents< StaticExtentsR... > const &rhs)
Definition: otbExtents.h:164
otb::PatternSampler::SetParameters
void SetParameters(const ParameterType &param)
Definition: otbPatternSampler.h:76
otb::PatternSampler::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbPatternSampler.h:44
otb::Wrapper::ParameterType
ParameterType
Definition: otbWrapperTypes.h:37
otb::PatternSampler
Periodic sampler for iteration loops.
Definition: otbPatternSampler.h:39