Orfeo Toolbox  4.0
otbObjectListSource.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 __otbObjectListSource_txx
19 #define __otbObjectListSource_txx
20 
21 #include "otbObjectListSource.h"
22 #include "itkProgressReporter.h"
23 #include "otbMath.h"
24 
25 namespace otb
26 {
27 
31 template <class TOutputList>
34 {
35  // Create the output. We use static_cast<> here because we know the default
36  // output must be of type TOutputImage
37  typename TOutputList::Pointer output
38  = static_cast<TOutputList*>(this->MakeOutput(0).GetPointer());
39  this->Superclass::SetNumberOfRequiredOutputs(1);
40  this->Superclass::SetNthOutput(0, output.GetPointer());
41 
42 }
43 
47 template<class TOutputList>
50 ::MakeOutput(unsigned int)
51 {
52  return static_cast<itk::DataObject*>(TOutputList::New().GetPointer());
53 }
54 
58 template <class TOutputList>
62 {
63  if (this->GetNumberOfOutputs() < 1)
64  {
65  return 0;
66  }
67 
68  return static_cast<TOutputList*>
69  (this->Superclass::GetOutput(0));
70 }
71 
75 template <class TOutputList>
78 ::GetOutput(unsigned int idx)
79 {
80  return static_cast<TOutputList*>
81  (this->Superclass::GetOutput(idx));
82 }
83 
87 template<class TOutputList>
88 void
91 {
92  this->GraftNthOutput(0, graft);
93 }
94 
98 template<class TOutputList>
99 void
101 ::GraftNthOutput(unsigned int idx, itk::DataObject *graft)
102 {
103  if (idx >= this->GetNumberOfOutputs())
104  {
105  itkExceptionMacro(<< "Requested to graft output " << idx <<
106  " but this filter only has " << this->GetNumberOfOutputs() << " Outputs.");
107  }
108 
109  if (!graft)
110  {
111  itkExceptionMacro(<< "Requested to graft output that is a NULL pointer");
112  }
113 
114  itk::DataObject * output = this->GetOutput(idx);
115 
116  // Call GraftImage to copy meta-information, regions, and the pixel container
117  output->Graft(graft);
118 }
119 
120 //----------------------------------------------------------------------------
121 
122 template <class TOutputList>
123 void
126 {
127  OutputListPointer outputPtr;
128 
129  // Allocate the output memory
130  for (unsigned int i = 0; i < this->GetNumberOfOutputs(); ++i)
131  {
132  outputPtr = this->GetOutput(i);
133  outputPtr->Clear();
134  }
135 }
136 
140 template <class TOutputList>
141 void
144 {
145  itkExceptionMacro("subclass should override this method!!!");
146 }
147 
151 template <class TOutputList>
152 void
154 ::PrintSelf(std::ostream& os, itk::Indent indent) const
155 {
156  Superclass::PrintSelf(os, indent);
157 }
158 } // end namespace otb
159 
160 #endif

Generated at Sat Mar 8 2014 16:11:42 for Orfeo Toolbox with doxygen 1.8.3.1