Orfeo Toolbox  4.0
otbMetaImageFunction.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 
13  This software is distributed WITHOUT ANY WARRANTY; without even
14  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  PURPOSE. See the above copyright notices for more information.
16 
17 =========================================================================*/
18 #ifndef __otbMetaImageFunction_txx
19 #define __otbMetaImageFunction_txx
20 
21 #include "otbMetaImageFunction.h"
23 
24 #include <algorithm>
25 
26 namespace otb
27 {
28 template <class TOutputPrecision, class TCoordRep>
30 ::MetaImageFunction() : m_FunctionContainer()
31  {
32 
33  }
34 
35 template <class TOutputPrecision, class TCoordRep>
38  {
39  this->ClearFunctions();
40  }
41 
42 template <class TOutputPrecision, class TCoordRep>
43 void
46  {
47  m_FunctionContainer.push_back(function);
48  }
49 
50 //template <class TOutputPrecision, class TCoordRep, typename T1, typename T2>
51 //void
52 //MetaImageFunction<TOutputPrecision, TCoordRep>
53 //::AddFunction(itk::ImageFunction<T1, T2, TCoordRep> * function)
54 // {
55 // // Define the adapter
56 // typedef itk::ImageFunction<T1, T2, TCoordRep> ImageFunctionType;
57 // typedef otb::ImageFunctionAdapter<T1, ImageFunctionType, TCoordRep > AdapterType;
58 //
59 // typename AdapterType::Pointer adapter = AdapterType::New();
60 // adapte
61 //
62 // }
63 
64 template <class TOutputPrecision, class TCoordRep>
65 void
68  {
69  m_FunctionContainer.clear();
70  }
71 
72 template <class TOutputPrecision, class TCoordRep>
73 unsigned int
76  {
77  return m_FunctionContainer.size();
78  }
79 
80 template <class TOutputPrecision, class TCoordRep>
82 ::FunctionType *
84 ::GetNthFunction(unsigned int index)
85  {
86  return m_FunctionContainer.at(index);
87  }
88 
89  template <class TOutputPrecision, class TCoordRep>
90  void
92  ::RemoveNthFunction(unsigned int index)
93  {
94  typename FunctionContainerType::iterator fIt = m_FunctionContainer.begin()+index;
95  m_FunctionContainer.erase(fIt);
96  }
97 
98 template <class TOutputPrecision, class TCoordRep>
100 ::OutputType
102 ::Evaluate(const PointType & point) const
103  {
104  // Build output
105  OutputType resp;
106 
107  // For each function
108  typename FunctionContainerType::const_iterator fIt = m_FunctionContainer.begin();
109  while(fIt != m_FunctionContainer.end())
110  {
111  // Store current size
112  unsigned int currentSize = static_cast<unsigned int>(resp.GetSize());
113 
114  // Call current function evaluation
115  OutputType currentVector = (*fIt)->Evaluate(point);
116 
117  // Compute current vector size
118  unsigned int currentVectorSize = static_cast<unsigned int>(currentVector.GetSize());
119 
120  // Enlarge the output vector
121  resp.SetSize(currentSize + currentVectorSize, false);
122 
123  // Fill the output
124  for(unsigned int i = 0; i < currentVectorSize; ++i)
125  {
126  resp.SetElement(currentSize+i, static_cast<ValueType>(currentVector[i]));
127  }
128 
129  // Go to next function
130  ++fIt;
131  }
132 
133  return resp;
134  }
135 
136 
137 template <class TOutputPrecision, class TCoordRep>
138 void
140 ::PrintSelf(std::ostream& os, itk::Indent indent) const
141 {
142  Superclass::PrintSelf(os, indent);
143  os<<indent<<"Number of image functions: "<<this->GetNumberOfFunctions()<<std::endl;
144 }
145 
146 } // end namespace otb
147 
148 #endif

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