Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkTransform.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 #ifndef MITKTRANSFORM_H
17 #define MITKTRANSFORM_H
18 
19 #include <itkObject.h>
20 #include <cv.h>
21 #include <mitkCommon.h>
22 #include <mitkNumericTypes.h>
23 #include <mitkNavigationData.h>
24 #include <tinyxml.h>
25 #include <sstream>
26 #include <vtkMatrix4x4.h>
27 #include <mitkXMLSerializable.h>
28 #include <MitkCameraCalibrationExports.h>
29 
30 namespace mitk {
31 
40  class MITKCAMERACALIBRATION_EXPORT Transform: public itk::Object,
41  public XMLSerializable
42  {
43  public:
44  mitkClassMacroItkParent(Transform, itk::Object);
45  itkFactorylessNewMacro(Transform);
47  mitkNewMacro1Param(Transform, const std::string&);
48 
53  static const std::string UNKNOWN_TYPE;
54  static const std::string ENDOSCOPE_SCOPE_TOOL;
55  static const std::string ENDOSCOPE_CAM_TOOL;
56  static const std::string CHESSBOARD_TOOL;
57  static const std::string POINTER_TOOL;
58  static const std::string POINTER_TO_CHESSBOARD_ORIGIN;
59  static const std::string POINTER_TO_CHESSBOARD_X_SUPPORT_POINT;
60  static const std::string POINTER_TO_CHESSBOARD_Y_SUPPORT_POINT;
61  static const std::string BOARD_TO_BOARD_TOOL;
62  static const std::string REFERENCE_CAMERA_TRANSFORM;
63  static const std::string REFERENCE_SCOPE_TRANSFORM;
64  static const std::string EYE_TO_HAND_TRANSFORM;
65  static const std::string CAMERA_EXTRINSICS;
66 
67  itkGetConstMacro(Type, std::string);
68  itkSetMacro(Type, std::string&);
73  void Copy( const mitk::Transform* transform );
74 
79  void Copy( const mitk::NavigationData* transform );
80 
87  void TransposeRotation();
88 
93 
101  void Concatenate( mitk::Transform* transform );
105  void Concatenate( const vnl_matrix_fixed<mitk::ScalarType, 4, 4>& transform );
106 
110  void Concatenate( const vtkMatrix4x4* transform );
111 
115  void Invert();
119  void Reset();
120 
124  void FromXML(TiXmlElement* elem) override;
128  void FromCSVFile(const std::string& file);
132  void SetNavigationData( const mitk::NavigationData* naviData );
136  void SetOrientation( const vnl_quaternion<mitk::ScalarType>& orientation);
140  void SetOrientation( const vnl_quaternion<float>& orientation);
144  void SetTranslation( const vnl_vector_fixed<mitk::ScalarType, 3>& transl);
148  void SetTranslation( const vnl_vector<double>& transl);
152  void SetPosition( const mitk::Point3D& transl);
156  void SetRotation( vnl_matrix_fixed<mitk::ScalarType, 3, 3>& mat);
160  void SetRotation( vnl_matrix<mitk::ScalarType>& mat);
164  void SetMatrix( const vnl_matrix_fixed<mitk::ScalarType, 4, 4>& mat);
168  void SetMatrix( const vtkMatrix4x4* mat);
172  void SetTranslation( float* array );
178  void SetRotation( float* array );
182  void SetTranslation( double array[3] );
186  void SetRotation( double array[3][3] );
187 
191  void SetTranslation( const cv::Mat& transl);
195  void SetRotation( const cv::Mat& mat );
199  void SetRotationVector( const cv::Mat& rotVec);
200 
204  mitk::NavigationData::Pointer GetNavigationData() const;
208  mitk::Point3D GetPosition() const;
212  mitk::Point3D GetTranslation() const;
216  bool IsValid() const;
220  void SetValid(bool valid);
221 
225  mitk::Quaternion GetOrientation() const;
226 
230  vnl_matrix_fixed<mitk::ScalarType, 4, 4> GetMatrix() const;
234  void GetMatrix(vtkMatrix4x4* matrix) const;
239  void GetVtkOpenGlMatrix(vtkMatrix4x4* matrix) const;
240 
241  mitk::Point3D TransformPoint(mitk::Point3D point) const;
242 
246  void ToXML(TiXmlElement* elem) const override;
250  std::string ToString() const;
254  std::string ToCSVString() const;
258  std::string ToMatlabString(const std::string& varname="transform",
259  bool printLastRow=true) const;
263  void ToCSVFile(const std::string& file) const;
267  void ToMatlabFile(const std::string& file
268  , const std::string& varname="transform") const;
272  cv::Mat GetCvTranslation() const;
273  cv::Mat GetCvRotationVector() const;
274  cv::Mat GetCvRotationMatrix() const;
275  cv::Mat GetCvMatrix() const;
276 
280  vnl_vector_fixed<mitk::ScalarType, 3> GetVnlTranslation() const;
281  vnl_vector_fixed<double, 3> GetVnlDoubleTranslation() const;
282  vnl_quaternion<double> GetVnlDoubleQuaternion() const;
283  vnl_matrix_fixed<mitk::ScalarType, 3, 3> GetVnlRotationMatrix() const;
284  vnl_matrix_fixed<double, 4, 4> GetVnlDoubleMatrix() const;
285 
286  protected:
287  Transform();
288  Transform(const mitk::NavigationData* nd);
289  Transform(const std::string& s);
290 
291  // everything is stored here
293 
297  std::string m_Type;
298 };
299 
300 } // namespace mitk
301 
302 MITKCAMERACALIBRATION_EXPORT std::ostream& operator<<
303  (std::ostream& os, mitk::Transform::Pointer p);
304 
305 #endif // MITKTRANSFORM_H
itk::SmartPointer< Self > Pointer
static const std::string BOARD_TO_BOARD_TOOL
Definition: mitkTransform.h:61
Pointer Clone() const
#define mitkNewMacro1Param(classname, type)
Definition: mitkCommon.h:76
Navigation Data.
static const std::string ENDOSCOPE_CAM_TOOL
Definition: mitkTransform.h:55
DataCollection - Class to facilitate loading/accessing structured data.
static const std::string UNKNOWN_TYPE
Definition: mitkTransform.h:53
mitk::NavigationData::Pointer m_NavData
std::string m_Type
static const std::string EYE_TO_HAND_TRANSFORM
Definition: mitkTransform.h:64
static const std::string ENDOSCOPE_SCOPE_TOOL
Definition: mitkTransform.h:54
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:53
static const std::string REFERENCE_CAMERA_TRANSFORM
Definition: mitkTransform.h:62
vnl_quaternion< ScalarType > Quaternion
static const std::string POINTER_TO_CHESSBOARD_ORIGIN
Definition: mitkTransform.h:58
class representing a transfrom in 3D
Definition: mitkTransform.h:40
static const std::string CHESSBOARD_TOOL
Definition: mitkTransform.h:56
static const std::string POINTER_TOOL
Definition: mitkTransform.h:57
static const std::string POINTER_TO_CHESSBOARD_Y_SUPPORT_POINT
Definition: mitkTransform.h:60
static const std::string CAMERA_EXTRINSICS
Definition: mitkTransform.h:65
interface for all classes able to write themselves to XML files
static const std::string REFERENCE_SCOPE_TRANSFORM
Definition: mitkTransform.h:63
static const std::string POINTER_TO_CHESSBOARD_X_SUPPORT_POINT
Definition: mitkTransform.h:59