orientation.hh
Go to the documentation of this file.
1 /* -*- mia-c++ -*-
2  *
3  * This file is part of MIA - a toolbox for medical image analysis
4  * Copyright (c) Leipzig, Madrid 1999-2017 Gert Wollny
5  *
6  * MIA is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with MIA; if not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 #ifndef __mia_3d_oriantation_hh
22 #define __mia_3d_oriantation_hh
23 
24 #include <ostream>
25 #include <istream>
26 
27 #include <mia/core/attributes.hh>
28 #include <mia/3d/quaternion.hh>
29 #include <mia/3d/matrix.hh>
30 #include <mia/core/vector.hh>
31 
33 
34 
41 
45  ior_xyz = 1,
47  ior_yxz = 3,
50  ior_xzy = 5,
52  ior_zxy = 7,
55  ior_yzx = 9,
57  ior_zyx =11,
61  ior_axial = 1,
69  ior_unknown = 13,
70 };
71 
72 
74 
88 public:
90 
92 
94  const C3DFVector& origin,
95  const C3DFVector& scale,
96  const Quaternion& rot);
97 
98  void get_transform_parameters(CDoubleVector& params) const;
99 
100  void get_inverse_transform_parameters(CDoubleVector& params) const;
101 
103 
104  bool operator == (const C3DOrientationAndPosition& other) const;
105 
106  bool operator < (const C3DOrientationAndPosition& other) const;
107 
108 
109  void print(std::ostream& os) const;
110 
111  E3DImageOrientation get_axis_orientation() const;
112 
114  const mia::C3DFVector& get_scale() const;
115 
117  const mia::C3DFVector& get_origin()const;
118 
120  const mia::Quaternion& get_rotation()const;
121 
122 private:
123 
124  const C3DFMatrix& get_axis_switch_matrix() const;
125 
126  E3DImageOrientation m_axisorder;
127  C3DFVector m_origin;
128  C3DFVector m_scale;
129  Quaternion m_rotation;
130 
131  static const C3DFMatrix ms_order_XYZ;
132  static const C3DFMatrix ms_order_YXZ;
133  static const C3DFMatrix ms_order_XZY;
134  static const C3DFMatrix ms_order_ZYX;
135  static const C3DFMatrix ms_order_ZXY;
136  static const C3DFMatrix ms_order_YZX;
137 
138  static const C3DFMatrix ms_order_XYZ_F;
139  static const C3DFMatrix ms_order_YXZ_F;
140  static const C3DFMatrix ms_order_XZY_F;
141  static const C3DFMatrix ms_order_ZXY_F;
142  static const C3DFMatrix ms_order_ZYX_F;
143  static const C3DFMatrix ms_order_YZX_F;
144 
145 };
146 
147 
173 };
174 
175 
177 
185 EXPORT_3D std::ostream& operator << (std::ostream& os, E3DImageOrientation orient);
186 
194 EXPORT_3D std::istream& operator >> (std::istream& is, E3DImageOrientation& orient);
195 
196 
204 inline std::ostream& operator << (std::ostream& os, const C3DOrientationAndPosition& orient)
205 {
206  orient.print(os);
207  return os;
208 }
209 
217 EXPORT_3D std::istream& operator >> (std::istream& is, C3DOrientationAndPosition& orient);
218 
219 
227 EXPORT_3D std::ostream& operator << (std::ostream& os, E3DPatientPositioning pp);
228 
236 EXPORT_3D std::istream& operator >> (std::istream& is, E3DPatientPositioning& pp);
237 
243 extern template class EXPORT_3D TAttribute<E3DImageOrientation>;
244 
250 extern template class EXPORT_3D TTranslator<E3DImageOrientation>;
251 
252 
258 extern template class EXPORT_3D TAttribute<E3DPatientPositioning>;
259 
262 
263 extern template class EXPORT_3D TAttribute<C3DOrientationAndPosition>;
265 
271 
272 template <>
274  static const int value = 3000;
275 };
276 
277 template <>
279  static const int value = 3001;
280 };
281 
282 template <>
284  static const int value = 3002;
285 };
286 
287 
288 
289 extern EXPORT_3D const char * IDPatientPosition;
290 
292 
293 #endif
a class to implement a quaternion
Definition: quaternion.hh:43
Generic string vs. attribute translator singleton.
Definition: attributes.hh:509
TAttribute< E3DPatientPositioning > CPatientPositionAttribute
attribute for the patient position
Definition: orientation.hh:257
TTranslator< C3DOrientationAndPosition > COrientationPositionTranslator
Definition: orientation.hh:261
bool operator==(const CAttribute &a, const CAttribute &b)
Definition: attributes.hh:93
A wrapper around the c-array to provide an STL like interface for iterators.
Definition: core/vector.hh:75
T3DVector< float > C3DFVector
A float 3D Vector.
Definition: 3d/vector.hh:346
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition: defines.hh:33
EXPORT_2D C2DFVectorfield & operator+=(C2DFVectorfield &a, const C2DFVectorfield &b)
bool operator<(const T2DVector< T > &a, const T2DVector< S > &b)
Definition: 2d/vector.hh:453
#define EXPORT_3D
Definition: defines3d.hh:44
const TDictMap< E3DPatientPositioning > g_patient_position_map
EXPORT_3D std::ostream & operator<<(std::ostream &os, E3DImageOrientation orient)
Stream operator to write orientation orient to stream os.
void print(std::ostream &os) const
EXPORT_3D std::istream & operator>>(std::istream &is, E3DImageOrientation &orient)
Stream operator to read orientation orient from stream is.
This class represents the oriantation and position of a 3D data set.
Definition: orientation.hh:87
const TDictMap< E3DImageOrientation > g_image_orientation_map
E3DImageOrientation
Definition: orientation.hh:40
EXPORT_3D const char * IDPatientPosition
E3DPatientPositioning
Definition: orientation.hh:162
TTranslator< E3DPatientPositioning > CPatientPositionTranslator
translator for the patient position
Definition: orientation.hh:270
a simple 3x3 matrix
Definition: 3d/matrix.hh:45
TAttribute< C3DOrientationAndPosition > C3DImageOrientationPositionAttribute
Definition: orientation.hh:260
TAttribute< E3DImageOrientation > C3DImageOrientation
attribute for 3D image orientation
Definition: orientation.hh:242
TTranslator< E3DImageOrientation > COrientationTranslator
translator for 3D image orientations to and from strings
Definition: orientation.hh:249
A mapper from emums to string values. - usefull for names flags.
Definition: dictmap.hh:45
Class of an attribute that holds data of type T.
Definition: attributes.hh:116
#define NS_MIA_END
conveniance define to end the mia namespace
Definition: defines.hh:36