OTB  9.0.0
Orfeo Toolbox
otbPointSetSource.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 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
otb::PointSetSource::GraftNthOutput
virtual void GraftNthOutput(DataObjectPointerArraySizeType idx, itk::DataObject *output)
Definition: otbPointSetSource.hxx:112
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::PointSetSource::DataObjectPointer
itk::DataObject::Pointer DataObjectPointer
Definition: otbPointSetSource.h:62
otb::PointSetSource::GetOutput
OutputPointSetType * GetOutput(void)
Definition: otbPointSetSource.hxx:59
otb::PointSetSource::PointSetSource
PointSetSource()
Definition: otbPointSetSource.hxx:33
otb::PointSetSource::GraftOutput
virtual void GraftOutput(itk::DataObject *output)
Definition: otbPointSetSource.hxx:103
otb::PointSetSource::SetOutput
void SetOutput(OutputPointSetType *output)
Definition: otbPointSetSource.hxx:82
otb::PointSetSource< itk::PointSet< typename TInputImage::PixelType, 2 > >::DataObjectPointerArraySizeType
itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
Definition: otbPointSetSource.h:58
otb::PointSetSource::GenerateInputRequestedRegion
void GenerateInputRequestedRegion() override
Definition: otbPointSetSource.hxx:94
otbPointSetSource.h
otb::PointSetSource< itk::PointSet< typename TInputImage::PixelType, 2 > >::OutputPointSetPointer
OutputPointSetType::Pointer OutputPointSetPointer
Definition: otbPointSetSource.h:64
otb::PointSetSource::OutputPointSetType
TOutputPointSet OutputPointSetType
Definition: otbPointSetSource.h:63
otb::PointSetSource::PrintSelf
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Definition: otbPointSetSource.hxx:134
otb::PointSetSource::MakeOutput
DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override
Definition: otbPointSetSource.hxx:50