itkMetaArrayWriter.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkMetaArrayWriter_h
00018 #define __itkMetaArrayWriter_h
00019
00020 #include "itkLightProcessObject.h"
00021 #include "itkArray.h"
00022 #include "itkFixedArray.h"
00023 #include "itkVector.h"
00024 #include "itkCovariantVector.h"
00025 #include "itkVariableLengthVector.h"
00026 #include "metaArray.h"
00027
00028 namespace itk
00029 {
00030
00031 class MetaArrayWriter : public LightProcessObject
00032 {
00033 public:
00034
00036 typedef MetaArrayWriter Self;
00037 typedef LightProcessObject Superclass;
00038
00039 typedef SmartPointer<Self> Pointer;
00040 typedef SmartPointer<const Self> ConstPointer;
00041
00043 itkNewMacro(Self);
00044
00046 itkTypeMacro(MetaArrayWriter, LightProcessObject);
00047
00049 itkSetStringMacro(FileName);
00050
00052 itkGetStringMacro(FileName);
00053
00057 itkSetStringMacro(DataFileName);
00058
00060 itkGetStringMacro(DataFileName);
00061
00063 itkSetMacro(Binary, bool);
00064
00067 itkGetConstMacro(Binary, bool);
00068
00070 template <typename TValueType>
00071 void SetInput(MET_ValueEnumType _metaElementType,
00072 const Array<TValueType> * _array)
00073 {
00074 m_Buffer = (const void *)(_array->data_block());
00075 m_MetaArray.InitializeEssential(_array->Size(),
00076 _metaElementType);
00077 }
00079
00081 template <typename TValueType, unsigned int VLength>
00082 void SetInput(MET_ValueEnumType _metaElementType,
00083 const FixedArray<TValueType, VLength> * _array)
00084 {
00085 m_Buffer = (const void *)(_array->GetDataPointer());
00086 m_MetaArray.InitializeEssential(VLength,
00087 _metaElementType);
00088 }
00090
00092 template <typename TValueType, unsigned int VLength>
00093 void SetInput(MET_ValueEnumType _metaElementType,
00094 const Vector<TValueType, VLength> * _vector)
00095 {
00096 m_Buffer = (const void *)(_vector->GetDataPointer());
00097 m_MetaArray.InitializeEssential(VLength,
00098 _metaElementType);
00099 }
00101
00103 template <typename TValueType, unsigned int VLength>
00104 void SetInput(MET_ValueEnumType _metaElementType,
00105 const CovariantVector<TValueType, VLength> * _vector)
00106 {
00107 m_Buffer = (const void *)(_vector->GetDataPointer());
00108 m_MetaArray.InitializeEssential(VLength,
00109 _metaElementType);
00110 }
00112
00114 template <typename TValueType>
00115 void SetInput(MET_ValueEnumType _metaElementType,
00116 const VariableLengthVector<TValueType> * _vector)
00117 {
00118 m_Buffer = (const void *)(_vector->GetDataPointer());
00119 m_MetaArray.InitializeEssential(_vector->Size(),
00120 _metaElementType);
00121 }
00123
00131 template <typename TValueType>
00132 void SetMultiChannelInput(MET_ValueEnumType _metaElementType,
00133 int _NumberOfChannels,
00134 const Array<TValueType> * _array)
00135 {
00136 int rows = _array->GetSize();
00137 int cols = (*_array)[0].GetSize();
00138 m_MetaArray.InitializeEssential(rows,
00139 _metaElementType,
00140 cols,
00141 NULL,
00142 true,
00143 true);
00144 m_Buffer = m_MetaArray.ElementData();
00145 for(int i=0; i<rows; i++)
00146 {
00147 for(int j=0; j<cols; j++)
00148 {
00149 m_MetaArray.ElementData(i*cols+j, (double)((*_array)[i][j]));
00150 }
00151 }
00152 }
00154
00155
00157 itkSetMacro(Precision, unsigned int);
00158 itkGetConstMacro(Precision, unsigned int);
00160
00162 void ConvertTo(MET_ValueEnumType _metaElementType);
00163
00165 void Update();
00166
00167 protected:
00168
00169 MetaArrayWriter();
00170 virtual ~MetaArrayWriter();
00171
00172 private:
00173
00174 bool m_Binary;
00175
00176 unsigned int m_Precision;
00177
00178 std::string m_FileName;
00179 std::string m_DataFileName;
00180
00181 MetaArray m_MetaArray;
00182
00183 const void * m_Buffer;
00184
00185 };
00186
00187 }
00188
00189
00190 #endif // __itkMetaArrayWriter_h
00191