Orfeo Toolbox  4.0
otbModelComponentBase.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ORFEO Toolbox
4  Language: C++
5  Date: $Date$
6  Version: $Revision$
7 
8 
9  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
10  See OTBCopyright.txt for details.
11 
12  Some parts of this code are covered by the GET copyright.
13  See GETCopyright.txt for details.
14 
15  This software is distributed WITHOUT ANY WARRANTY; without even
16  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
17  PURPOSE. See the above copyright notices for more information.
18 
19 =========================================================================*/
20 #ifndef __otbModelComponentBase_txx
21 #define __otbModelComponentBase_txx
22 
23 #include <iostream>
24 
25 #include "otbMacro.h"
26 #include "otbModelComponentBase.h"
27 
28 namespace otb
29 {
30 namespace Statistics
31 {
32 
33 template<class TSample>
36 {
37  m_Sample = 0;
38  m_PdfFunction = 0;
39  m_CdfFunction = 0;
40  m_SampleModified = 0;
41 }
42 
43 template<class TSample>
44 void
46 ::PrintSelf(std::ostream& os, itk::Indent indent) const
47 {
48  Superclass::PrintSelf(os, indent);
49 
50  os << indent << "Sample: ";
51  if (m_Sample != 0)
52  {
53  os << m_Sample << std::endl;
54  }
55  else
56  {
57  os << "not set." << std::endl;
58  }
59 
60  os << indent << "Membership Function for pdf: ";
61  if (m_PdfFunction != 0)
62  {
63  os << m_PdfFunction << std::endl;
64  }
65  else
66  {
67  os << "not instantiated yet." << std::endl;
68  }
69 
70  os << indent << "Membership Function for cdf: ";
71  if (m_CdfFunction != 0)
72  {
73  os << m_CdfFunction << std::endl;
74  }
75  else
76  {
77  os << "not instantiated yet." << std::endl;
78  }
79 
80  os << indent << "Sample are modified and parameters updated: ";
81  os << m_SampleModified << std::endl;
82 }
83 
84 template <class TSample>
85 void
87 ::ShowParameters(std::ostream& os, itk::Indent indent) const
88 {
89  os << indent << "Generic class of model-component. Parameters :\n";
90  for (unsigned int i = 0; i < m_Parameters.Size(); ++i)
91  os << indent << m_Parameters[i] << "\n";
92 }
93 
94 template<class TSample>
95 void
97 ::SetSample(const TSample* sample)
98 {
99  m_Sample = sample;
100  m_SampleModified = 1;
101 }
102 
103 template<class TSample>
104 const TSample*
106 ::GetSample() const
107 {
108  return m_Sample;
109 }
110 
111 template<class TSample>
112 void
114 ::SetParameters(const ParametersType& parameters)
115 {
116  if (m_Parameters != parameters) m_Parameters = parameters;
117 }
118 
119 template<class TSample>
120 void
123 {
124  m_PdfFunction = function;
125 }
126 
127 template<class TSample>
128 void
131 {
132  m_CdfFunction = function;
133 }
134 
135 template<class TSample>
139 {
140  return m_PdfFunction;
141 }
142 
143 template<class TSample>
147 {
148  return m_CdfFunction;
149 }
150 
151 template<class TSample>
152 inline double
155 {
156  return this->m_PdfFunction->Evaluate(measurements);
157 }
158 
159 template<class TSample>
160 inline double
163 {
164  return m_CdfFunction->Evaluate(measurements);
165 }
166 
167 template <class TSample>
168 int
171 {
172  return m_SampleModified;
173 }
174 
175 template<class TSample>
176 void
179 {
180  if (m_SampleModified) this->GenerateData();
181  m_SampleModified = 0;
182 }
183 
184 template <class TSample>
185 void
188 {
193  m_SampleModified = 0;
194 }
195 
196 } // end of namespace Statistics
197 } // end of namespace otb
198 
199 #endif

Generated at Sat Mar 8 2014 16:08:10 for Orfeo Toolbox with doxygen 1.8.3.1