OTB  6.7.0
Orfeo Toolbox
otbPatternSampler.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 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:
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(
108  const std::string &data,
109  ParameterType &param);
110 
115  static void ExportPatterns(
116  const ParameterType &param,
117  std::string &data);
118 
119 protected:
121  PatternSampler();
122 
124  ~PatternSampler() override {}
125 
126 private:
127  // Not implemented
128  PatternSampler(const Self&);
129  void operator=(const Self&);
130 
132  std::vector<bool> RandArray(unsigned long N,unsigned long T);
133 
135  unsigned long FindBestSize(unsigned long tot);
136 
139 
141  unsigned long m_Index1;
142 
144  unsigned long m_Index2;
145 
150  static unsigned int ParseSymbol(const char &s);
151 };
152 
153 } // namespace otb
154 #endif
Periodic sampler for iteration loops.
ParameterType GetParameters()
void SetParameters(const ParameterType &param)
OTBGdalAdapters_EXPORT bool operator!=(const CoordinateTransformation &ct1, const CoordinateTransformation &ct2) noexcept
different operator
itk::SmartPointer< const Self > ConstPointer
itk::SmartPointer< Self > Pointer
This is a base class for sampling methods.
ParameterType m_Parameters