Orfeo Toolbox  3.16
itkMetaArrayWriter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkMetaArrayWriter.h,v $
5  Language: C++
6  Date: $Date: 2009-04-25 12:25:44 $
7  Version: $Revision: 1.4 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 #ifndef __itkMetaArrayWriter_h
18 #define __itkMetaArrayWriter_h
19 
20 #include "itkLightProcessObject.h"
21 #include "itkArray.h"
22 #include "itkFixedArray.h"
23 #include "itkVector.h"
24 #include "itkCovariantVector.h"
26 #include "metaArray.h"
27 
28 namespace itk
29 {
30 
32 {
33 public:
34 
38 
41 
43  itkNewMacro(Self);
44 
46  itkTypeMacro(MetaArrayWriter, LightProcessObject);
47 
49  itkSetStringMacro(FileName);
50 
52  itkGetStringMacro(FileName);
53 
57  itkSetStringMacro(DataFileName);
58 
60  itkGetStringMacro(DataFileName);
61 
63  itkSetMacro(Binary, bool);
66  itkGetConstMacro(Binary, bool);
67 
69  template <typename TValueType>
70  void SetInput(MET_ValueEnumType _metaElementType,
71  const Array<TValueType> * _array)
72  {
73  m_Buffer = (const void *)(_array->data_block());
74  m_MetaArray.InitializeEssential(_array->Size(),
75  _metaElementType);
76  }
77 
79  template <typename TValueType, unsigned int VLength>
80  void SetInput(MET_ValueEnumType _metaElementType,
81  const FixedArray<TValueType, VLength> * _array)
82  {
83  m_Buffer = (const void *)(_array->GetDataPointer());
84  m_MetaArray.InitializeEssential(VLength,
85  _metaElementType);
86  }
87 
89  template <typename TValueType, unsigned int VLength>
90  void SetInput(MET_ValueEnumType _metaElementType,
91  const Vector<TValueType, VLength> * _vector)
92  {
93  m_Buffer = (const void *)(_vector->GetDataPointer());
94  m_MetaArray.InitializeEssential(VLength,
95  _metaElementType);
96  }
97 
99  template <typename TValueType, unsigned int VLength>
100  void SetInput(MET_ValueEnumType _metaElementType,
101  const CovariantVector<TValueType, VLength> * _vector)
102  {
103  m_Buffer = (const void *)(_vector->GetDataPointer());
104  m_MetaArray.InitializeEssential(VLength,
105  _metaElementType);
106  }
107 
109  template <typename TValueType>
110  void SetInput(MET_ValueEnumType _metaElementType,
111  const VariableLengthVector<TValueType> * _vector)
112  {
113  m_Buffer = (const void *)(_vector->GetDataPointer());
114  m_MetaArray.InitializeEssential(_vector->Size(),
115  _metaElementType);
116  }
117 
125  template <typename TValueType>
126  void SetMultiChannelInput(MET_ValueEnumType _metaElementType,
127  int _NumberOfChannels,
128  const Array<TValueType> * _array)
129  {
130  int rows = _array->GetSize();
131  int cols = (*_array)[0].GetSize();
132  m_MetaArray.InitializeEssential(rows,
133  _metaElementType,
134  cols,
135  NULL,
136  true,
137  true);
138  m_Buffer = m_MetaArray.ElementData();
139  for(int i=0; i<rows; i++)
140  {
141  for(int j=0; j<cols; j++)
142  {
143  m_MetaArray.ElementData(i*cols+j, (double)((*_array)[i][j]));
144  }
145  }
146  }
147 
148 
150  itkSetMacro(Precision, unsigned int);
151  itkGetConstMacro(Precision, unsigned int);
152 
154  void ConvertTo(MET_ValueEnumType _metaElementType);
155 
157  void Update();
158 
159 protected:
160 
161  MetaArrayWriter();
162  virtual ~MetaArrayWriter();
163 
164 private:
165 
166  bool m_Binary;
167 
168  unsigned int m_Precision;
169 
170  std::string m_FileName;
171  std::string m_DataFileName;
172 
173  MetaArray m_MetaArray;
174 
175  const void * m_Buffer;
176 
177 };
178 
179 } // namespace itk
180 
181 
182 #endif // __itkMetaArrayWriter_h

Generated at Sat May 18 2013 23:53:37 for Orfeo Toolbox with doxygen 1.8.3.1