Orfeo Toolbox  3.16
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 
26 #include "otbMacro.h"
27 #include "otbModelComponentBase.h"
28 
29 namespace otb
30 {
31 namespace Statistics
32 {
33 
34 template<class TSample>
37 {
38  m_Sample = 0;
39  m_PdfFunction = 0;
40  m_CdfFunction = 0;
41  m_SampleModified = 0;
42 }
43 
44 template<class TSample>
45 void
47 ::PrintSelf(std::ostream& os, itk::Indent indent) const
48 {
49  Superclass::PrintSelf(os, indent);
50 
51  os << indent << "Sample: ";
52  if (m_Sample != 0)
53  {
54  os << m_Sample << std::endl;
55  }
56  else
57  {
58  os << "not set." << std::endl;
59  }
60 
61  os << indent << "Membership Function for pdf: ";
62  if (m_PdfFunction != 0)
63  {
64  os << m_PdfFunction << std::endl;
65  }
66  else
67  {
68  os << "not instantiated yet." << std::endl;
69  }
70 
71  os << indent << "Membership Function for cdf: ";
72  if (m_CdfFunction != 0)
73  {
74  os << m_CdfFunction << std::endl;
75  }
76  else
77  {
78  os << "not instantiated yet." << std::endl;
79  }
80 
81  os << indent << "Sample are modified and parameters updated: ";
82  os << m_SampleModified << std::endl;
83 }
84 
85 template <class TSample>
86 void
88 ::ShowParameters(std::ostream& os, itk::Indent indent) const
89 {
90  os << indent << "Generic class of model-component. Parameters :\n";
91  for (unsigned int i = 0; i < m_Parameters.Size(); ++i)
92  os << indent << m_Parameters[i] << "\n";
93 }
94 
95 template<class TSample>
96 void
98 ::SetSample(const TSample* sample)
99 {
100  m_Sample = sample;
101  m_SampleModified = 1;
102 }
103 
104 template<class TSample>
105 const TSample*
107 ::GetSample() const
108 {
109  return m_Sample;
110 }
111 
112 template<class TSample>
113 void
115 ::SetParameters(const ParametersType& parameters)
116 {
117  if (m_Parameters != parameters) m_Parameters = parameters;
118 }
119 
120 template<class TSample>
121 void
124 {
125  m_PdfFunction = function;
126 }
127 
128 template<class TSample>
129 void
132 {
133  m_CdfFunction = function;
134 }
135 
136 template<class TSample>
140 {
141  return m_PdfFunction;
142 }
143 
144 template<class TSample>
148 {
149  return m_CdfFunction;
150 }
151 
152 template<class TSample>
153 inline double
156 {
157  return this->m_PdfFunction->Evaluate(measurements);
158 }
159 
160 template<class TSample>
161 inline double
164 {
165  return m_CdfFunction->Evaluate(measurements);
166 }
167 
168 template <class TSample>
169 int
172 {
173  return m_SampleModified;
174 }
175 
176 template<class TSample>
177 void
180 {
181  if (m_SampleModified) this->GenerateData();
182  m_SampleModified = 0;
183 }
184 
185 template <class TSample>
186 void
189 {
194  m_SampleModified = 0;
195 }
196 
197 } // end of namespace Statistics
198 } // end of namespace otb
199 
200 #endif

Generated at Sun Feb 3 2013 00:37:05 for Orfeo Toolbox with doxygen 1.8.1.1