OTB  9.0.0
Orfeo Toolbox
otbRandomPointSetSource.hxx
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 
22 #ifndef otbRandomPointSetSource_hxx
23 #define otbRandomPointSetSource_hxx
24 
26 
27 namespace otb
28 {
29 
30 template <class TOutputPointSet>
32 {
33  m_NumberOfPoints = 1;
34  m_Generator = GeneratorType::New();
35  m_Generator->Initialize();
36 
37  m_MinPoint.Fill(0.0);
38  m_MaxPoint.Fill(1.0);
39 }
40 
41 // init seed
42 
43 template <class TOutputPointSet>
45 {
46  OutputPointSetPointer outputPointSet = this->GetOutput();
47  outputPointSet->Initialize();
48 
49  PointsContainerPointer outPoints = outputPointSet->GetPoints();
50  outPoints->Reserve(m_NumberOfPoints);
51 
52  typename PointsContainerType::Iterator outputPoint = outPoints->Begin();
53  while (outputPoint != outPoints->End())
54  {
55  PointType point;
56  for (unsigned int i = 0; i < OutputPointSetType::PointDimension; ++i)
57  {
58  double v = m_Generator->GetVariateWithClosedRange(1.0);
59  point[i] = (1.0 - v) * m_MinPoint[i] + v * m_MaxPoint[i];
60  }
61  outputPoint.Value() = point;
62  ++outputPoint;
63  }
64 }
65 }
66 
67 #endif
otb::RandomPointSetSource::PointsContainerPointer
PointsContainerType::Pointer PointsContainerPointer
Definition: otbRandomPointSetSource.h:68
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::RandomPointSetSource::GenerateData
void GenerateData(void) override
Definition: otbRandomPointSetSource.hxx:44
otb::PointSetSource::OutputPointSetPointer
OutputPointSetType::Pointer OutputPointSetPointer
Definition: otbPointSetSource.h:64
otbRandomPointSetSource.h
otb::RandomPointSetSource::PointType
OutputPointSetType::PointType PointType
Definition: otbRandomPointSetSource.h:69
otb::RandomPointSetSource::RandomPointSetSource
RandomPointSetSource()
Definition: otbRandomPointSetSource.hxx:31