22 #ifndef otbImportVectorImageFilter_hxx
23 #define otbImportVectorImageFilter_hxx
26 #include "itkObjectFactory.h"
34 template <
class TOutputImage>
39 for (idx = 0; idx < TOutputImage::ImageDimension; ++idx)
44 m_Direction.SetIdentity();
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;
106 template <
class TOutputImage>
109 if (ptr != m_ImportPointer)
111 if (m_ImportPointer && m_FilterManageMemory)
113 delete[] m_ImportPointer;
115 m_ImportPointer = ptr;
118 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);
167 typename RegionType::SizeType size = m_Region.GetSize();
169 int numberOfBands = m_Size / (size[0] * size[1]);
171 if (numberOfBands !=
static_cast<int>(numberOfBands))
172 itkExceptionMacro(<<
"Buffer size and image size are not compatible !");
174 outputPtr->SetNumberOfComponentsPerPixel(numberOfBands);
180 template <
class TOutputImage>
192 outputPtr->SetBufferedRegion(outputPtr->GetLargestPossibleRegion());
199 outputPtr->GetPixelContainer()->SetImportPointer(m_ImportPointer, m_Size,
false);
205 template <
class TOutputImage>
208 double dspacing[TOutputImage::ImageDimension];
209 for (
unsigned int i = 0; i < TOutputImage::ImageDimension; ++i)
211 dspacing[i] = spacing[i];
213 this->SetSpacing(dspacing);
220 template <
class TOutputImage>
223 double dorigin[TOutputImage::ImageDimension];
224 for (
unsigned int i = 0; i < TOutputImage::ImageDimension; ++i)
226 dorigin[i] = origin[i];
228 this->SetOrigin(dorigin);
233 template <
class TOutputImage>
236 bool modified =
false;
237 for (
unsigned int r = 0; r < TOutputImage::ImageDimension; ++r)
239 for (
unsigned int c = 0; c < TOutputImage::ImageDimension; ++c)
241 if (m_Direction[r][c] != direction[r][c])
243 m_Direction[r][c] = direction[r][c];