MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
mitkTransform.h
Go to the documentation of this file.
1/*============================================================================
2
3The Medical Imaging Interaction Toolkit (MITK)
4
5Copyright (c) German Cancer Research Center (DKFZ)
6All rights reserved.
7
8Use of this source code is governed by a 3-clause BSD license that can be
9found 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
25namespace mitk {
26
35 class MITKCAMERACALIBRATION_EXPORT Transform: public itk::Object,
36 public XMLSerializable
37 {
38 public:
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();
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
297MITKCAMERACALIBRATION_EXPORT std::ostream& operator<<
298 (std::ostream& os, mitk::Transform::Pointer p);
299
300#endif
class representing a transfrom in 3D
static const std::string POINTER_TOOL
itkFactorylessNewMacro(Transform)
std::string m_Type
static const std::string EYE_TO_HAND_TRANSFORM
static const std::string BOARD_TO_BOARD_TOOL
static const std::string UNKNOWN_TYPE
itkSetMacro(Type, std::string &)
static const std::string CHESSBOARD_TOOL
static const std::string REFERENCE_CAMERA_TRANSFORM
static const std::string POINTER_TO_CHESSBOARD_Y_SUPPORT_POINT
mitkClassMacroItkParent(Transform, itk::Object)
static const std::string CAMERA_EXTRINSICS
mitkNewMacro1Param(Transform, const std::string &)
mitk::NavigationData::Pointer m_NavData
static const std::string ENDOSCOPE_CAM_TOOL
static const std::string ENDOSCOPE_SCOPE_TOOL
static const std::string REFERENCE_SCOPE_TRANSFORM
itkGetConstMacro(Type, std::string)
static const std::string POINTER_TO_CHESSBOARD_ORIGIN
static const std::string POINTER_TO_CHESSBOARD_X_SUPPORT_POINT
mitkNewMacro1Param(Transform, const mitk::NavigationData *)
interface for all classes able to write themselves to XML files
IGT Exceptions.