Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkVectorDeprecated.h
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef MITKVECTORDEPRECATED_H_
18 #define MITKVECTORDEPRECATED_H_
19 
20 #include <itkIndex.h>
21 #include <vnl/vnl_quaternion.h>
22 
23 #include "mitkMatrix.h"
24 #include "mitkNumericConstants.h"
25 #include "mitkPoint.h"
26 #include "mitkVector.h"
27 
28 template <class T>
30 {
31 public:
32  typedef T ValueType;
33 };
34 
35 template <>
37 {
38 public:
40 };
41 
42 template <>
43 class VectorTraits<float[4]>
44 {
45 public:
46  typedef float ValueType;
47 };
48 
49 template <>
50 class VectorTraits<itk::Index<5>>
51 {
52 public:
54 };
55 
56 template <>
57 class VectorTraits<itk::Index<3>>
58 {
59 public:
61 };
62 
63 template <>
64 class VectorTraits<long int[3]>
65 {
66 public:
67  typedef long int ValueType;
68 };
69 template <>
70 class VectorTraits<float[3]>
71 {
72 public:
73  typedef float ValueType;
74 };
75 template <>
76 class VectorTraits<double[3]>
77 {
78 public:
79  typedef double ValueType;
80 };
81 
82 template <>
83 class VectorTraits<vnl_vector_fixed<mitk::ScalarType, 3>>
84 {
85 public:
87 };
88 
89 template <>
90 class VectorTraits<long unsigned int[3]>
91 {
92 public:
93  typedef long unsigned int ValueType;
94 };
95 
96 template <>
97 class VectorTraits<unsigned int *>
98 {
99 public:
100  typedef unsigned int ValueType;
101 };
102 
103 template <>
104 class VectorTraits<double[4]>
105 {
106 public:
107  typedef double ValueType;
108 };
109 
110 template <>
111 class VectorTraits<itk::Vector<float, 3>>
112 {
113 public:
114  typedef float ValueType;
115 };
116 
117 template <>
118 class VectorTraits<itk::Vector<double, 3>>
119 {
120 public:
121  typedef double ValueType;
122 };
123 
124 template <>
125 class VectorTraits<itk::Vector<int, 3>>
126 {
127 public:
128  typedef int ValueType;
129 };
130 
131 template <>
132 class VectorTraits<mitk::Vector<double, 3>>
133 {
134 public:
135  typedef double ValueType;
136 };
137 
138 template <>
139 class VectorTraits<mitk::Point<float, 3>>
140 {
141 public:
142  typedef float ValueType;
143 };
144 
145 template <>
146 class VectorTraits<mitk::Point<float, 4>>
147 {
148 public:
149  typedef float ValueType;
150 };
151 
152 template <>
153 class VectorTraits<itk::Point<float, 3>>
154 {
155 public:
156  typedef float ValueType;
157 };
158 
159 template <>
160 class VectorTraits<itk::Point<float, 4>>
161 {
162 public:
163  typedef float ValueType;
164 };
165 
166 template <>
167 class VectorTraits<mitk::Point<double, 3>>
168 {
169 public:
170  typedef double ValueType;
171 };
172 
173 template <>
174 class VectorTraits<mitk::Point<double, 4>>
175 {
176 public:
177  typedef double ValueType;
178 };
179 
180 template <>
181 class VectorTraits<itk::Point<double, 3>>
182 {
183 public:
184  typedef double ValueType;
185 };
186 
187 template <>
188 class VectorTraits<itk::Point<double, 4>>
189 {
190 public:
191  typedef double ValueType;
192 };
193 
194 template <>
195 class VectorTraits<mitk::Point<int, 3>>
196 {
197 public:
198  typedef int ValueType;
199 };
200 
201 namespace mitk
202 {
203  template <class Tin, class Tout>
204  inline void itk2vtk(const Tin &in, Tout &out)
205  {
206  out[0] = (typename VectorTraits<Tout>::ValueType)(in[0]);
207  out[1] = (typename VectorTraits<Tout>::ValueType)(in[1]);
208  out[2] = (typename VectorTraits<Tout>::ValueType)(in[2]);
209  }
210 
211  template <class Tin, class Tout>
212  inline void vtk2itk(const Tin &in, Tout &out)
213  {
214  out[0] = (typename VectorTraits<Tout>::ValueType)(in[0]);
215  out[1] = (typename VectorTraits<Tout>::ValueType)(in[1]);
216  out[2] = (typename VectorTraits<Tout>::ValueType)(in[2]);
217  }
218 
219  template <class Tin, class Tout>
220  inline void vnl2vtk(const vnl_vector<Tin> &in, Tout *out)
221  {
222  unsigned int i;
223  for (i = 0; i < in.size(); ++i)
224  out[i] = (Tout)(in[i]);
225  }
226 
227  template <class Tin, class Tout>
228  inline void vtk2vnl(const Tin *in, vnl_vector<Tout> &out)
229  {
230  unsigned int i;
231  for (i = 0; i < out.size(); ++i)
232  out[i] = (Tout)(in[i]);
233  }
234 
235  template <class Tin, class Tout, unsigned int n>
236  inline void vnl2vtk(const vnl_vector_fixed<Tin, n> &in, Tout *out)
237  {
238  unsigned int i;
239  for (i = 0; i < in.size(); ++i)
240  out[i] = (Tout)(in[i]);
241  }
242 
243  template <class Tin, class Tout, unsigned int n>
244  inline void vtk2vnl(const Tin *in, vnl_vector_fixed<Tout, n> &out)
245  {
246  unsigned int i;
247  for (i = 0; i < out.size(); ++i)
248  out[i] = (Tout)(in[i]);
249  }
250 
251  template <typename U, typename V, unsigned int NRows, unsigned int NColumns>
252  inline void TransferMatrix(const itk::Matrix<U, NRows, NColumns> &in, itk::Matrix<V, NRows, NColumns> &out)
253  {
254  for (unsigned int i = 0; i < in.RowDimensions; ++i)
255  for (unsigned int j = 0; j < in.ColumnDimensions; ++j)
256  out[i][j] = in[i][j];
257  }
258 
259 #define mitkSetConstReferenceMacro(name, type) \
260  virtual void Set##name(const type &_arg) \
261  { \
262  itkDebugMacro("setting " << #name " to " << _arg); \
263  if (this->m_##name != _arg) \
264  { \
265  this->m_##name = _arg; \
266  this->Modified(); \
267  } \
268  }
269 
270 #define mitkSetVectorMacro(name, type) mitkSetConstReferenceMacro(name, type)
271 
272 #define mitkGetVectorMacro(name, type) itkGetConstReferenceMacro(name, type)
273 
274 } // namespace mitk
275 
276 #endif /* MITKVECTORDEPRECATED_H_ */
vnl_vector< ScalarType > VnlVector
Definition: mitkVector.h:138
double ScalarType
itk::Index< 3 >::IndexValueType ValueType
void vtk2vnl(const Tin *in, vnl_vector< Tout > &out)
DataCollection - Class to facilitate loading/accessing structured data.
void vnl2vtk(const vnl_vector< Tin > &in, Tout *out)
void vtk2itk(const Tin &in, Tout &out)
void TransferMatrix(const itk::Matrix< U, NRows, NColumns > &in, itk::Matrix< V, NRows, NColumns > &out)
static bool in(Reader::Char c, Reader::Char c1, Reader::Char c2, Reader::Char c3, Reader::Char c4)
Definition: jsoncpp.cpp:244
void itk2vtk(const Tin &in, Tout &out)
itk::Index< 5 >::IndexValueType ValueType