OTB  7.2.0
Orfeo Toolbox
otbPointSetSource.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2020 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>
34 {
35  // Create the output. We use static_cast<> here because we know the default
36  // output must be of type TOutputPointSet
37  OutputPointSetPointer output = static_cast<TOutputPointSet*>(this->MakeOutput(0).GetPointer());
38 
39  this->ProcessObject::SetNumberOfRequiredOutputs(1);
40  this->ProcessObject::SetNthOutput(0, output.GetPointer());
41 
42  m_GenerateDataRegion = 0;
43  m_GenerateDataNumberOfRegions = 0;
44 }
45 
49 template <class TOutputPointSet>
51 {
52  return static_cast<itk::DataObject*>(TOutputPointSet::New().GetPointer());
53 }
54 
58 template <class TOutputPointSet>
60 {
61  if (this->GetNumberOfOutputs() < 1)
62  {
63  return nullptr;
64  }
65 
66  return static_cast<TOutputPointSet*>(this->ProcessObject::GetOutput(0));
67 }
68 
72 template <class TOutputPointSet>
74 {
75  return static_cast<TOutputPointSet*>(this->ProcessObject::GetOutput(idx));
76 }
77 
81 template <class TOutputPointSet>
83 {
84  itkWarningMacro(
85  << "SetOutput(): This method is slated to be removed from ITK. Please use GraftOutput() in possible combination with DisconnectPipeline() instead.");
86  this->ProcessObject::SetNthOutput(0, output);
87 }
89 
93 template <class TOutputPointSet>
95 {
96  Superclass::GenerateInputRequestedRegion();
97 }
98 
102 template <class TOutputPointSet>
104 {
105  this->GraftNthOutput(0, graft);
106 }
107 
111 template <class TOutputPointSet>
113 {
114  if (idx >= this->GetNumberOfOutputs())
115  {
116  itkExceptionMacro(<< "Requested to graft output " << idx << " but this filter only has " << this->GetNumberOfOutputs() << " Outputs.");
117  }
118 
119  if (!graft)
120  {
121  itkExceptionMacro(<< "Requested to graft output that is a NULL pointer");
122  }
123 
124  itk::DataObject* output = this->GetOutput(idx);
125 
126  // Call Graft on the PointSet in order to copy meta-information, and containers.
127  output->Graft(graft);
128 }
129 
133 template <class TOutputPointSet>
134 void PointSetSource<TOutputPointSet>::PrintSelf(std::ostream& os, itk::Indent indent) const
135 {
136  Superclass::PrintSelf(os, indent);
137 }
138 
139 } // end namespace otb
140 
141 #endif
itk::DataObject::Pointer DataObjectPointer
OutputPointSetType::Pointer OutputPointSetPointer
OutputPointSetType * GetOutput(void)
virtual void GraftNthOutput(DataObjectPointerArraySizeType idx, itk::DataObject *output)
itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
void PrintSelf(std::ostream &os, itk::Indent indent) const override
void SetOutput(OutputPointSetType *output)
void GenerateInputRequestedRegion() override
TOutputPointSet OutputPointSetType
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
virtual void GraftOutput(itk::DataObject *output)
DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override