17 #ifndef __itkVTKImageExport_txx
18 #define __itkVTKImageExport_txx
22 #include "itkPixelTraits.h"
31 template <
class TInputImage>
34 typedef typename TInputImage::PixelType PixelType;
35 typedef typename PixelTraits< PixelType >::ValueType ScalarType;
37 if(
typeid(ScalarType) ==
typeid(
double))
39 m_ScalarTypeName =
"double";
41 else if(
typeid(ScalarType) ==
typeid(
float))
43 m_ScalarTypeName =
"float";
45 else if(
typeid(ScalarType) ==
typeid(
long))
47 m_ScalarTypeName =
"long";
49 else if(
typeid(ScalarType) ==
typeid(
unsigned long))
51 m_ScalarTypeName =
"unsigned long";
53 else if(
typeid(ScalarType) ==
typeid(
int))
55 m_ScalarTypeName =
"int";
57 else if(
typeid(ScalarType) ==
typeid(
unsigned int))
59 m_ScalarTypeName =
"unsigned int";
61 else if(
typeid(ScalarType) ==
typeid(
short))
63 m_ScalarTypeName =
"short";
65 else if(
typeid(ScalarType) ==
typeid(
unsigned short))
67 m_ScalarTypeName =
"unsigned short";
69 else if(
typeid(ScalarType) ==
typeid(
char))
71 m_ScalarTypeName =
"char";
73 else if(
typeid(ScalarType) ==
typeid(
unsigned char))
75 m_ScalarTypeName =
"unsigned char";
77 else if(
typeid(ScalarType) ==
typeid(
signed char))
79 m_ScalarTypeName =
"signed char";
83 itkExceptionMacro(<<
"Type currently not supported");
87 template <
class TInputImage>
91 Superclass::PrintSelf(os, indent);
98 template <
class TInputImage>
102 const_cast<TInputImage*>(input) );
109 template <
class TInputImage>
113 return static_cast<TInputImage*
>(
123 template <
class TInputImage>
129 itkExceptionMacro(<<
"Need to set an input");
139 for(;i < InputImageDimension;++i)
141 m_WholeExtent[i*2] = int(index[i]);
142 m_WholeExtent[i*2+1] = int(index[i]+size[i])-1;
147 m_WholeExtent[i*2] = 0;
148 m_WholeExtent[i*2+1] = 0;
150 return m_WholeExtent;
158 template <
class TInputImage>
164 itkExceptionMacro(<<
"Need to set an input");
168 const typename TInputImage::SpacingType& spacing = input->GetSpacing();
172 for(;i < InputImageDimension;++i)
174 m_DataSpacing[i] =
static_cast<double>(spacing[i]);
179 m_DataSpacing[i] = 1;
181 return m_DataSpacing;
188 template <
class TInputImage>
192 const typename TInputImage::SpacingType& spacing = input->GetSpacing();
196 for(;i < InputImageDimension;++i)
198 m_FloatDataSpacing[i] =
static_cast<float>(spacing[i]);
203 m_FloatDataSpacing[i] = 1;
205 return m_FloatDataSpacing;
213 template <
class TInputImage>
219 itkExceptionMacro(<<
"Need to set an input");
223 const typename TInputImage::PointType& origin = input->GetOrigin();
227 for(;i < InputImageDimension;++i)
229 m_DataOrigin[i] =
static_cast<double>(origin[i]);
243 template <
class TInputImage>
247 const typename TInputImage::PointType& origin = input->GetOrigin();
251 for(;i < InputImageDimension;++i)
253 m_FloatDataOrigin[i] =
static_cast<float>(origin[i]);
258 m_FloatDataOrigin[i] = 0;
260 return m_FloatDataOrigin;
268 template <
class TInputImage>
271 return m_ScalarTypeName.c_str();
281 template <
class TInputImage>
284 typedef typename TInputImage::PixelType PixelType;
285 typedef typename PixelTraits< PixelType >::ValueType ValueType;
288 return sizeof( PixelType ) /
sizeof( ValueType );
298 template <
class TInputImage>
304 for(
unsigned int i=0;i < InputImageDimension;++i)
306 index[i] = extent[i*2];
307 size[i] = (extent[i*2+1]-extent[i*2])+1;
311 region.SetSize(size);
312 region.SetIndex(index);
317 itkExceptionMacro(<<
"Need to set an input");
321 input->SetRequestedRegion(region);
331 template <
class TInputImage>
337 itkExceptionMacro(<<
"Need to set an input");
346 for(;i < InputImageDimension;++i)
348 m_DataExtent[i*2] = int(index[i]);
349 m_DataExtent[i*2+1] = int(index[i]+size[i])-1;
353 m_DataExtent[i*2] = 0;
354 m_DataExtent[i*2+1] = 0;
364 template <
class TInputImage>
370 itkExceptionMacro(<<
"Need to set an input");
374 return input->GetBufferPointer();