OTB  5.0.0
Orfeo Toolbox
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());
42 
43 }
44 
48 template<class TOutputList>
52 {
53  return static_cast<itk::DataObject*>(TOutputList::New().GetPointer());
54 }
55 
59 template <class TOutputList>
63 {
64  if (this->GetNumberOfOutputs() < 1)
65  {
66  return 0;
67  }
68 
69  return static_cast<TOutputList*>
70  (this->Superclass::GetOutput(0));
71 }
72 
76 template <class TOutputList>
80 {
81  return static_cast<TOutputList*>
82  (this->Superclass::GetOutput(idx));
83 }
84 
88 template<class TOutputList>
89 void
92 {
93  this->GraftNthOutput(0, graft);
94 }
95 
99 template<class TOutputList>
100 void
103 {
104  if (idx >= this->GetNumberOfOutputs())
105  {
106  itkExceptionMacro(<< "Requested to graft output " << idx <<
107  " but this filter only has " << this->GetNumberOfOutputs() << " Outputs.");
108  }
109 
110  if (!graft)
111  {
112  itkExceptionMacro(<< "Requested to graft output that is a NULL pointer");
113  }
114 
115  itk::DataObject * output = this->GetOutput(idx);
116 
117  // Call GraftImage to copy meta-information, regions, and the pixel container
118  output->Graft(graft);
119 }
120 
121 //----------------------------------------------------------------------------
122 
123 template <class TOutputList>
124 void
127 {
128  OutputListPointer outputPtr;
129 
130  // Allocate the output memory
131  for (unsigned int i = 0; i < this->GetNumberOfOutputs(); ++i)
132  {
133  outputPtr = this->GetOutput(i);
134  outputPtr->Clear();
135  }
136 }
137 
141 template <class TOutputList>
142 void
145 {
146  itkExceptionMacro("subclass should override this method!!!");
147 }
148 
152 template <class TOutputList>
153 void
155 ::PrintSelf(std::ostream& os, itk::Indent indent) const
156 {
157  Superclass::PrintSelf(os, indent);
158 }
159 } // end namespace otb
161 
162 #endif
virtual void Graft(const DataObject *)
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
void GraftOutput(itk::DataObject *graft)
TOutputList::Pointer OutputListPointer
OutputListType * GetOutput(void)
virtual void GenerateData(void)
void GraftNthOutput(DataObjectPointerArraySizeType idx, itk::DataObject *graft)
virtual DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx)
virtual void PrintSelf(std::ostream &os, itk::Indent indent) const