OTB  6.7.0
Orfeo Toolbox
otbPointSetSource.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbPointSetSource_hxx
22 #define otbPointSetSource_hxx
23 
24 #include "otbPointSetSource.h"
25 
26 namespace otb
27 {
28 
32 template<class TOutputPointSet>
35 {
36  // Create the output. We use static_cast<> here because we know the default
37  // output must be of type TOutputPointSet
39  = static_cast<TOutputPointSet*>(this->MakeOutput(0).GetPointer());
40 
41  this->ProcessObject::SetNumberOfRequiredOutputs(1);
42  this->ProcessObject::SetNthOutput(0, output.GetPointer());
43 
44  m_GenerateDataRegion = 0;
45  m_GenerateDataNumberOfRegions = 0;
46 }
47 
51 template<class TOutputPointSet>
55 {
56  return static_cast<itk::DataObject*>(TOutputPointSet::New().GetPointer());
57 }
58 
62 template<class TOutputPointSet>
66 {
67  if (this->GetNumberOfOutputs() < 1)
68  {
69  return nullptr;
70  }
71 
72  return static_cast<TOutputPointSet*>
73  (this->ProcessObject::GetOutput(0));
74 }
75 
79 template<class TOutputPointSet>
83 {
84  return static_cast<TOutputPointSet*>
85  (this->ProcessObject::GetOutput(idx));
86 }
87 
91 template<class TOutputPointSet>
92 void
95 {
96  itkWarningMacro(
97  <<
98  "SetOutput(): This method is slated to be removed from ITK. Please use GraftOutput() in possible combination with DisconnectPipeline() instead.");
99  this->ProcessObject::SetNthOutput(0, output);
100 }
102 
106 template<class TOutputPointSet>
107 void
110 {
111  Superclass::GenerateInputRequestedRegion();
112 }
113 
117 template<class TOutputPointSet>
118 void
121 {
122  this->GraftNthOutput(0, graft);
123 }
124 
128 template<class TOutputPointSet>
129 void
132 {
133  if (idx >= this->GetNumberOfOutputs())
134  {
135  itkExceptionMacro(<< "Requested to graft output " << idx <<
136  " but this filter only has " << this->GetNumberOfOutputs() << " Outputs.");
137  }
138 
139  if (!graft)
140  {
141  itkExceptionMacro(<< "Requested to graft output that is a NULL pointer");
142  }
143 
144  itk::DataObject * output = this->GetOutput(idx);
145 
146  // Call Graft on the PointSet in order to copy meta-information, and containers.
147  output->Graft(graft);
148 }
149 
153 template<class TOutputPointSet>
154 void
156 ::PrintSelf(std::ostream& os, itk::Indent indent) const
157 {
158  Superclass::PrintSelf(os, indent);
159 }
160 
161 } // end namespace otb
162 
163 #endif
OutputPointSetType::Pointer OutputPointSetPointer
OutputPointSetType * GetOutput(void)
virtual void GraftNthOutput(DataObjectPointerArraySizeType idx, itk::DataObject *output)
void PrintSelf(std::ostream &os, itk::Indent indent) const override
void SetOutput(OutputPointSetType *output)
void GenerateInputRequestedRegion() override
TOutputPointSet OutputPointSetType
virtual void Graft(const DataObject *)
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
virtual void GraftOutput(itk::DataObject *output)
DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override