OTB  9.0.0
Orfeo Toolbox
otbImportGeoInformationImageFilter.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 otbImportGeoInformationImageFilter_hxx
22 #define otbImportGeoInformationImageFilter_hxx
23 
25 #include "itkMetaDataObject.h"
26 #include "otbMetaDataKey.h"
27 
28 namespace otb
29 {
33 template <class TImage, class TSourceImage>
35 {
36  this->InPlaceOn();
37  this->SetNumberOfRequiredInputs(2);
38 }
40 
41 template <class TImage, class TSourceImage>
43 {
44  this->SetNthInput(1, const_cast<TSourceImage*>(source));
45 }
46 template <class TImage, class TSourceImage>
48 {
49  return static_cast<const TSourceImage*>(this->itk::ProcessObject::GetInput(1));
50 }
51 
52 template <class TImage, class TSourceImage>
54 {
55  Superclass::GenerateInputRequestedRegion();
56 
57  typename SourceImageType::RegionType region;
58  typename SourceImageType::SizeType size;
59  typename SourceImageType::IndexType index;
60 
61  size.Fill(0);
62  index.Fill(0);
63  region.SetSize(size);
64  region.SetIndex(index);
65 
66  SourceImageType* sourcePtr = const_cast<SourceImageType*>(this->GetSource());
67  sourcePtr->SetRequestedRegion(region);
68 }
69 
70 template <class TImage, class TSourceImage>
72 {
73  Superclass::GenerateOutputInformation();
74  // Get output and source pointer
75  ImagePointerType outputPtr = this->GetOutput();
76  SourceImageType* sourcePtr = const_cast<SourceImageType*>(this->GetSource());
77  // Import metadata
78  outputPtr->CopyInformation(sourcePtr);
79 
80  outputPtr->SetLargestPossibleRegion(this->GetInput()->GetLargestPossibleRegion());
81 
82  outputPtr->SetNumberOfComponentsPerPixel(this->GetInput()->GetNumberOfComponentsPerPixel());
83 }
84 
85 // template <class TImage, class TSourceImage>
86 // void
87 // ImportGeoInformationImageFilter<TImage, TSourceImage>
88 // ::GenerateData(void)
89 // {
90 // // Get output and source pointer
91 // ImagePointerType outputPtr = this->GetOutput();
92 // SourceImageType * sourcePtr =const_cast<SourceImageType *>(this->GetSource());
93 // // Import metadata
94 // outputPtr->CopyInformation(sourcePtr);
95 // // Don't forget to copy also the origin and spacing, not handled by the CopyInformation method.
96 // outputPtr->SetOrigin(sourcePtr->GetOrigin());
97 // outputPtr->SetSignedSpacing(sourcePtr->GetSignedSpacing());
98 // }
99 
otb::ImportGeoInformationImageFilter::GetSource
const TSourceImage * GetSource(void)
otb::ImportGeoInformationImageFilter::GenerateOutputInformation
void GenerateOutputInformation(void) override
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::ImportGeoInformationImageFilter::GenerateInputRequestedRegion
void GenerateInputRequestedRegion(void) override
otb::ImportGeoInformationImageFilter::ImportGeoInformationImageFilter
ImportGeoInformationImageFilter()
otb::ImportGeoInformationImageFilter::SetSource
void SetSource(const TSourceImage *source)
otbImportGeoInformationImageFilter.h
otbMetaDataKey.h