OTB  9.0.0
Orfeo Toolbox
otbTransformPointSetFilter.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 otbTransformPointSetFilter_hxx
22 #define otbTransformPointSetFilter_hxx
23 
25 #include "itkMacro.h"
26 
27 namespace otb
28 {
29 
33 template <class TInputPointSet, class TOutputPointSet, class TTransform>
35 {
36  m_Transform = TransformType::New();
37 }
38 
42 template <class TInputPointSet, class TOutputPointSet, class TTransform>
44 {
45  Superclass::PrintSelf(os, indent);
46  if (m_Transform)
47  {
48  os << indent << "Transform: " << m_Transform << std::endl;
49  }
50 }
52 
56 template <class TInputPointSet, class TOutputPointSet, class TTransform>
58 {
59 
60  typedef typename TInputPointSet::PointsContainer InputPointsContainer;
61  typedef typename TOutputPointSet::PointsContainer OutputPointsContainer;
62 
63  typedef typename TInputPointSet::PointsContainerPointer InputPointsContainerPointer;
64  typedef typename TOutputPointSet::PointsContainerPointer OutputPointsContainerPointer;
65 
66  InputPointSetPointer inputPointSet = this->GetInput();
67  OutputPointSetPointer outputPointSet = this->GetOutput();
68 
69  if (!inputPointSet)
70  {
71  itkExceptionMacro(<< "Missing Input PointSet");
72  }
73 
74  if (!outputPointSet)
75  {
76  itkExceptionMacro(<< "Missing Output PointSet");
77  }
78 
79  outputPointSet->SetBufferedRegion(outputPointSet->GetRequestedRegion());
80 
81  InputPointsContainerPointer inPoints = inputPointSet->GetPoints();
82  OutputPointsContainerPointer outPoints = outputPointSet->GetPoints();
83 
84  outPoints->Reserve(inputPointSet->GetNumberOfPoints());
85  outPoints->Squeeze(); // in case the previous PointSet had
86  // allocated a larger memory
87 
88  typename InputPointsContainer::ConstIterator inputPoint = inPoints->Begin();
89  typename OutputPointsContainer::Iterator outputPoint = outPoints->Begin();
90 
91  while (inputPoint != inPoints->End())
92  {
93  outputPoint.Value() = m_Transform->TransformPoint(inputPoint.Value());
94 
95  ++inputPoint;
96  ++outputPoint;
97  }
98 
99  // Create duplicate references to the rest of data on the PointSet
100 
101  outputPointSet->SetPointData(inputPointSet->GetPointData());
102  // TODO validate that we are copying everything
103 }
104 
105 } // end namespace itk
106 
107 #endif
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::TransformPointSetFilter::GenerateData
void GenerateData(void) override
Definition: otbTransformPointSetFilter.hxx:57
otb::PointSetSource::OutputPointSetPointer
OutputPointSetType::Pointer OutputPointSetPointer
Definition: otbPointSetSource.h:64
otb::TransformPointSetFilter::TransformPointSetFilter
TransformPointSetFilter()
Definition: otbTransformPointSetFilter.hxx:34
otbTransformPointSetFilter.h
otb::TransformPointSetFilter::PrintSelf
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Definition: otbTransformPointSetFilter.hxx:43
otb::PointSetToPointSetFilter::InputPointSetPointer
InputPointSetType::Pointer InputPointSetPointer
Definition: otbPointSetToPointSetFilter.h:56