Medical Imaging Interaction Toolkit  2023.12.00
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 #ifndef mitkTransform_h
13 #define mitkTransform_h
14 
15 #include <itkObject.h>
16 #include <opencv2/calib3d.hpp>
17 #include <mitkCommon.h>
18 #include <mitkNumericTypes.h>
19 #include <mitkNavigationData.h>
20 #include <sstream>
21 #include <vtkMatrix4x4.h>
22 #include <mitkXMLSerializable.h>
23 #include <MitkCameraCalibrationExports.h>
24 
25 namespace mitk {
26 
35  class MITKCAMERACALIBRATION_EXPORT Transform: public itk::Object,
36  public XMLSerializable
37  {
38  public:
39  mitkClassMacroItkParent(Transform, itk::Object);
40  itkFactorylessNewMacro(Transform);
42  mitkNewMacro1Param(Transform, const std::string&);
43 
48  static const std::string UNKNOWN_TYPE;
49  static const std::string ENDOSCOPE_SCOPE_TOOL;
50  static const std::string ENDOSCOPE_CAM_TOOL;
51  static const std::string CHESSBOARD_TOOL;
52  static const std::string POINTER_TOOL;
53  static const std::string POINTER_TO_CHESSBOARD_ORIGIN;
54  static const std::string POINTER_TO_CHESSBOARD_X_SUPPORT_POINT;
55  static const std::string POINTER_TO_CHESSBOARD_Y_SUPPORT_POINT;
56  static const std::string BOARD_TO_BOARD_TOOL;
57  static const std::string REFERENCE_CAMERA_TRANSFORM;
58  static const std::string REFERENCE_SCOPE_TRANSFORM;
59  static const std::string EYE_TO_HAND_TRANSFORM;
60  static const std::string CAMERA_EXTRINSICS;
61 
62  itkGetConstMacro(Type, std::string);
63  itkSetMacro(Type, std::string&);
68  void Copy( const mitk::Transform* transform );
69 
74  void Copy( const mitk::NavigationData* transform );
75 
82  void TransposeRotation();
83 
87  mitk::Transform::Pointer Clone() const;
88 
96  void Concatenate( mitk::Transform* transform );
100  void Concatenate( const vnl_matrix_fixed<mitk::ScalarType, 4, 4>& transform );
101 
105  void Concatenate( const vtkMatrix4x4* transform );
106 
110  void Invert();
114  void Reset();
115 
119  void FromXML(const tinyxml2::XMLElement* elem) override;
123  void FromCSVFile(const std::string& file);
127  void SetNavigationData( const mitk::NavigationData* naviData );
131  void SetOrientation( const vnl_quaternion<mitk::ScalarType>& orientation);
135  void SetOrientation( const vnl_quaternion<float>& orientation);
139  void SetTranslation( const vnl_vector_fixed<mitk::ScalarType, 3>& transl);
143  void SetTranslation( const vnl_vector<double>& transl);
147  void SetPosition( const mitk::Point3D& transl);
151  void SetRotation( vnl_matrix_fixed<mitk::ScalarType, 3, 3>& mat);
155  void SetRotation( vnl_matrix<mitk::ScalarType>& mat);
159  void SetMatrix( const vnl_matrix_fixed<mitk::ScalarType, 4, 4>& mat);
163  void SetMatrix( const vtkMatrix4x4* mat);
167  void SetTranslation( float* array );
173  void SetRotation( float* array );
177  void SetTranslation( double array[3] );
181  void SetRotation( double array[3][3] );
182 
186  void SetTranslation( const cv::Mat& transl);
190  void SetRotation( const cv::Mat& mat );
194  void SetRotationVector( const cv::Mat& rotVec);
195 
199  mitk::NavigationData::Pointer GetNavigationData() const;
203  mitk::Point3D GetPosition() const;
207  mitk::Point3D GetTranslation() const;
211  bool IsValid() const;
215  void SetValid(bool valid);
216 
220  mitk::Quaternion GetOrientation() const;
221 
225  vnl_matrix_fixed<mitk::ScalarType, 4, 4> GetMatrix() const;
229  void GetMatrix(vtkMatrix4x4* matrix) const;
234  void GetVtkOpenGlMatrix(vtkMatrix4x4* matrix) const;
235 
236  mitk::Point3D TransformPoint(mitk::Point3D point) const;
237 
241  void ToXML(tinyxml2::XMLElement* elem) const override;
245  std::string ToString() const;
249  std::string ToCSVString() const;
253  std::string ToMatlabString(const std::string& varname="transform",
254  bool printLastRow=true) const;
258  void ToCSVFile(const std::string& file) const;
262  void ToMatlabFile(const std::string& file
263  , const std::string& varname="transform") const;
267  cv::Mat GetCvTranslation() const;
268  cv::Mat GetCvRotationVector() const;
269  cv::Mat GetCvRotationMatrix() const;
270  cv::Mat GetCvMatrix() const;
271 
275  vnl_vector_fixed<mitk::ScalarType, 3> GetVnlTranslation() const;
276  vnl_vector_fixed<double, 3> GetVnlDoubleTranslation() const;
277  vnl_quaternion<double> GetVnlDoubleQuaternion() const;
278  vnl_matrix_fixed<mitk::ScalarType, 3, 3> GetVnlRotationMatrix() const;
279  vnl_matrix_fixed<double, 4, 4> GetVnlDoubleMatrix() const;
280 
281  protected:
282  Transform();
283  Transform(const mitk::NavigationData* nd);
284  Transform(const std::string& s);
285 
286  // everything is stored here
287  mitk::NavigationData::Pointer m_NavData;
288 
292  std::string m_Type;
293 };
294 
295 } // namespace mitk
296 
297 MITKCAMERACALIBRATION_EXPORT std::ostream& operator<<
298  (std::ostream& os, mitk::Transform::Pointer p);
299 
300 #endif
mitk::Transform
class representing a transfrom in 3D
Definition: mitkTransform.h:35
mitk::Transform::POINTER_TO_CHESSBOARD_X_SUPPORT_POINT
static const std::string POINTER_TO_CHESSBOARD_X_SUPPORT_POINT
Definition: mitkTransform.h:54
mitk::XMLSerializable
interface for all classes able to write themselves to XML files
Definition: mitkXMLSerializable.h:30
mitk::Transform::EYE_TO_HAND_TRANSFORM
static const std::string EYE_TO_HAND_TRANSFORM
Definition: mitkTransform.h:59
mitkXMLSerializable.h
mitkNewMacro1Param
#define mitkNewMacro1Param(classname, type)
Definition: mitkCommon.h:68
mitk::Transform::POINTER_TO_CHESSBOARD_Y_SUPPORT_POINT
static const std::string POINTER_TO_CHESSBOARD_Y_SUPPORT_POINT
Definition: mitkTransform.h:55
mitk::Transform::CHESSBOARD_TOOL
static const std::string CHESSBOARD_TOOL
Definition: mitkTransform.h:51
mitkNavigationData.h
mitk::Transform::ENDOSCOPE_CAM_TOOL
static const std::string ENDOSCOPE_CAM_TOOL
Definition: mitkTransform.h:50
mitk::NavigationData
Navigation Data.
Definition: mitkNavigationData.h:36
mitk::Transform::CAMERA_EXTRINSICS
static const std::string CAMERA_EXTRINSICS
Definition: mitkTransform.h:60
mitk::Transform::UNKNOWN_TYPE
static const std::string UNKNOWN_TYPE
Definition: mitkTransform.h:48
mitkClassMacroItkParent
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:45
mitk::Transform::BOARD_TO_BOARD_TOOL
static const std::string BOARD_TO_BOARD_TOOL
Definition: mitkTransform.h:56
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::Point< ScalarType, 3 >
mitkNumericTypes.h
mitk::Transform::REFERENCE_CAMERA_TRANSFORM
static const std::string REFERENCE_CAMERA_TRANSFORM
Definition: mitkTransform.h:57
mitkCommon.h
mitk::Transform::POINTER_TOOL
static const std::string POINTER_TOOL
Definition: mitkTransform.h:52
mitk::Transform::ENDOSCOPE_SCOPE_TOOL
static const std::string ENDOSCOPE_SCOPE_TOOL
Definition: mitkTransform.h:49
mitk::Quaternion
vnl_quaternion< ScalarType > Quaternion
Definition: mitkQuaternion.h:21
mitk::Transform::m_Type
std::string m_Type
Definition: mitkTransform.h:292
mitk::Transform::m_NavData
mitk::NavigationData::Pointer m_NavData
Definition: mitkTransform.h:287
mitk::Transform::POINTER_TO_CHESSBOARD_ORIGIN
static const std::string POINTER_TO_CHESSBOARD_ORIGIN
Definition: mitkTransform.h:53
mitk::Transform::REFERENCE_SCOPE_TRANSFORM
static const std::string REFERENCE_SCOPE_TRANSFORM
Definition: mitkTransform.h:58