18 #ifndef __itkMetaArrayReader_h
19 #define __itkMetaArrayReader_h
25 #include "metaArray.h"
46 itkSetStringMacro(FileName);
49 itkGetStringMacro(FileName);
53 MetaArray * GetMetaArrayPointer(
void);
56 void SetBuffer(
void *_buffer);
62 MET_ValueEnumType GetDataType(
void)
const
64 return m_MetaArray.ElementType();
70 return m_MetaArray.Length();
74 int GetNumberOfElements(
void)
const
76 return m_MetaArray.Length();
82 return m_MetaArray.Length();
86 int GetNumberOfComponents(
void)
const
88 return m_MetaArray.Length();
92 int GetCovariantVectorDimension(
void)
const
94 return m_MetaArray.Length();
98 template<
typename TValueType >
99 inline void GetElement(TValueType & value,
unsigned int i,
100 unsigned int channel = 0)
const
102 value =
static_cast< TValueType
>( m_MetaArray.ElementData(
103 i * m_MetaArray.ElementNumberOfChannels() + channel) );
114 template<
typename TValueType >
115 void GetOutput(MET_ValueEnumType _metaElementType,
117 bool _letArrayManageData =
true)
119 if ( m_MetaArray.ElementType() != _metaElementType )
121 m_MetaArray.ConvertElementDataTo(_metaElementType);
123 _array->
SetData( (TValueType *)( m_MetaArray.ElementData() ),
124 m_MetaArray.Length(),
125 _letArrayManageData );
126 if ( _letArrayManageData )
128 m_MetaArray.AutoFreeElementData(
false);
134 template<
typename TValueType,
unsigned int VLength >
135 bool GetOutput(MET_ValueEnumType itkNotUsed(_metaElementType),
138 if ( static_cast< int >( VLength ) <= m_MetaArray.Length() )
141 for ( i = 0; i < VLength; i++ )
143 this->GetElement( ( *_array )[i], i );
154 template<
typename TValueType,
unsigned int VLength >
155 bool GetOutput(MET_ValueEnumType itkNotUsed(_metaElementType),
158 if ( static_cast< int >( VLength ) <= m_MetaArray.Length() )
161 for ( i = 0; i < VLength; i++ )
163 this->GetElement( ( *_vector )[i], i );
175 template<
typename TValueType,
unsigned int VLength >
176 bool GetOutput(MET_ValueEnumType itkNotUsed(_metaElementType),
179 if ( static_cast< int >( VLength ) <= m_MetaArray.Length() )
182 for ( i = 0; i < VLength; i++ )
184 this->GetElement( ( *_vector )[i], i );
201 template<
typename TValueType >
202 void GetOutput(MET_ValueEnumType _metaElementType,
204 bool _letVectorManageData =
true)
206 if ( m_MetaArray.ElementType() != _metaElementType )
208 m_MetaArray.ConvertElementDataTo(_metaElementType);
210 _vector->
SetData( (TValueType *)( m_MetaArray.ElementData() ),
211 m_MetaArray.Length(),
212 _letVectorManageData );
213 if ( _letVectorManageData )
215 m_MetaArray.AutoFreeElementData(
false);
225 template<
typename TValueType >
226 void GetMultiChannelOutput(MET_ValueEnumType _metaElementType,
229 if ( m_MetaArray.ElementType() != _metaElementType )
231 m_MetaArray.ConvertElementDataTo(_metaElementType);
233 int rows = m_MetaArray.Length();
234 int cols = m_MetaArray.ElementNumberOfChannels();
236 for (
int i = 0; i < rows; i++ )
238 ( *_array )[i].SetSize(cols);
239 for (
int j = 0; j < cols; j++ )
241 ( *_array )[i][j] =
static_cast< typename TValueType::ValueType
>
242 ( m_MetaArray.ElementData(i * cols + j) );
252 void PrintSelf(std::ostream & os,
Indent indent)
const;
264 #endif // __itkTransformFileReader_h