18#ifndef itkMetaArrayReader_h
19#define itkMetaArrayReader_h
20#include "ITKIOMetaExport.h"
46 itkSetStringMacro(FileName);
49 itkGetStringMacro(FileName);
68 return m_MetaArray.ElementType();
75 return m_MetaArray.Length();
82 return m_MetaArray.Length();
89 return m_MetaArray.Length();
96 return m_MetaArray.Length();
103 return m_MetaArray.Length();
107 template <
typename TValue>
109 GetElement(TValue & value,
unsigned int i,
unsigned int channel = 0)
const
111 value =
static_cast<TValue
>(m_MetaArray.ElementData(i * m_MetaArray.ElementNumberOfChannels() + channel));
122 template <
typename TValue>
126 if (m_MetaArray.ElementType() != _metaElementType)
128 m_MetaArray.ConvertElementDataTo(_metaElementType);
130 _array->
SetData((TValue *)(m_MetaArray.ElementData()), m_MetaArray.Length(), _letArrayManageData);
131 if (_letArrayManageData)
133 m_MetaArray.AutoFreeElementData(
false);
139 template <
typename TValue,
unsigned int VLength>
143 if (
static_cast<int>(VLength) <= m_MetaArray.Length())
145 for (
unsigned int i = 0; i < VLength; ++i)
147 this->GetElement((*_array)[i], i);
158 template <
typename TValue,
unsigned int VLength>
162 if (
static_cast<int>(VLength) <= m_MetaArray.Length())
164 for (
unsigned int i = 0; i < VLength; ++i)
166 this->GetElement((*_vector)[i], i);
178 template <
typename TValue,
unsigned int VLength>
182 if (
static_cast<int>(VLength) <= m_MetaArray.Length())
184 for (
unsigned int i = 0; i < VLength; ++i)
186 this->GetElement((*_vector)[i], i);
203 template <
typename TValue>
207 bool _letVectorManageData =
true)
209 if (m_MetaArray.ElementType() != _metaElementType)
211 m_MetaArray.ConvertElementDataTo(_metaElementType);
213 _vector->SetData((TValue *)(m_MetaArray.ElementData()), m_MetaArray.Length(), _letVectorManageData);
214 if (_letVectorManageData)
216 m_MetaArray.AutoFreeElementData(
false);
226 template <
typename TValue>
230 if (m_MetaArray.ElementType() != _metaElementType)
232 m_MetaArray.ConvertElementDataTo(_metaElementType);
234 int rows = m_MetaArray.Length();
235 int cols = m_MetaArray.ElementNumberOfChannels();
237 for (
int i = 0; i < rows; ++i)
239 (*_array)[i].SetSize(cols);
240 for (
int j = 0; j < cols; ++j)
242 (*_array)[i][j] =
static_cast<typename TValue::ValueType
>(m_MetaArray.ElementData(i * cols + j));
255 MetaArray m_MetaArray{};
257 std::string m_FileName{};
259 void * m_Buffer{
nullptr };
Array class with size defined at construction time.
void SetData(TValue *datain, SizeValueType sz, bool LetArrayManageMemory=false)
void SetSize(SizeValueType sz)
A templated class holding a n-Dimensional covariant vector.
Simulate a standard C array with copy semantics.
Control indentation during Print() invocation.
Light weight base class for most itk classes.
LightProcessObject is the base class for all process objects (source, filters, mappers) in the Insigh...
Base class for most ITK classes.
A templated class holding a n-Dimensional vector.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....