22 #ifndef otbImportImageFilter_hxx
23 #define otbImportImageFilter_hxx
26 #include "itkObjectFactory.h"
34 template <
class TOutputImage>
39 for (idx = 0; idx < TOutputImage::ImageDimension; ++idx)
44 m_Direction.SetIdentity();
46 m_ImportPointer =
nullptr;
47 m_FilterManageMemory =
false;
54 template <
class TOutputImage>
57 if (m_ImportPointer && m_FilterManageMemory)
59 delete[] m_ImportPointer;
67 template <
class TOutputImage>
72 Superclass::PrintSelf(os, indent);
76 os << indent <<
"Imported pointer: (" << m_ImportPointer <<
")" << std::endl;
80 os << indent <<
"Imported pointer: (None)" << std::endl;
82 os << indent <<
"Import buffer size: " << m_Size << std::endl;
83 os << indent <<
"Import buffer size: " << m_Size << std::endl;
84 os << indent <<
"Filter manages memory: " << (m_FilterManageMemory ?
"true" :
"false") << std::endl;
86 os << indent <<
"Spacing: [";
87 for (i = 0; i < static_cast<int>(TOutputImage::ImageDimension) - 1; ++i)
89 os << m_Spacing[i] <<
", ";
91 os << m_Spacing[i] <<
"]" << std::endl;
93 os << indent <<
"Origin: [";
94 for (i = 0; i < static_cast<int>(TOutputImage::ImageDimension) - 1; ++i)
96 os << m_Origin[i] <<
", ";
98 os << m_Origin[i] <<
"]" << std::endl;
99 os << indent <<
"Direction: " << std::endl << this->GetDirection() << std::endl;
105 template <
class TOutputImage>
108 if (ptr != m_ImportPointer)
110 if (m_ImportPointer && m_FilterManageMemory)
112 delete[] m_ImportPointer;
114 m_ImportPointer = ptr;
117 m_FilterManageMemory = LetFilterManageMemory;
125 template <
class TOutputImage>
128 return m_ImportPointer;
134 template <
class TOutputImage>
138 Superclass::EnlargeOutputRequestedRegion(output);
145 outputPtr->SetRequestedRegion(outputPtr->GetLargestPossibleRegion());
151 template <
class TOutputImage>
155 Superclass::GenerateOutputInformation();
162 outputPtr->SetSignedSpacing(m_Spacing);
163 outputPtr->SetOrigin(m_Origin);
164 outputPtr->SetDirection(m_Direction);
165 outputPtr->SetLargestPossibleRegion(m_Region);
171 template <
class TOutputImage>
183 outputPtr->SetBufferedRegion(outputPtr->GetLargestPossibleRegion());
190 outputPtr->GetPixelContainer()->SetImportPointer(m_ImportPointer, m_Size,
false);
196 template <
class TOutputImage>
199 double dspacing[TOutputImage::ImageDimension];
200 for (
unsigned int i = 0; i < TOutputImage::ImageDimension; ++i)
202 dspacing[i] = spacing[i];
204 this->SetSpacing(dspacing);
211 template <
class TOutputImage>
214 double dorigin[TOutputImage::ImageDimension];
215 for (
unsigned int i = 0; i < TOutputImage::ImageDimension; ++i)
217 dorigin[i] = origin[i];
219 this->SetOrigin(dorigin);
224 template <
class TOutputImage>
227 bool modified =
false;
228 for (
unsigned int r = 0; r < TOutputImage::ImageDimension; ++r)
230 for (
unsigned int c = 0; c < TOutputImage::ImageDimension; ++c)
232 if (m_Direction[r][c] != direction[r][c])
234 m_Direction[r][c] = direction[r][c];