Medical Imaging Interaction Toolkit  2024.06.99-60d9b802
Medical Imaging Interaction Toolkit
mitkGeometryTransformHolder.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 
13 #ifndef mitkGeometryTransformHolder_h
14 #define mitkGeometryTransformHolder_h
15 
16 #include <MitkCoreExports.h>
17 #include <mitkAffineTransform3D.h>
18 #include <mitkAffineTransform3D.h>
19 #include <mitkCommon.h>
20 #include <mitkMatrix.h>
21 #include <mitkPoint.h>
22 #include <mitkVector.h>
23 #include <vtkMatrixToLinearTransform.h>
24 #include <vtkTransform.h>
25 
26 namespace mitk
27 {
28  /*
29  GeometryTransformHolder is a helper class which manages the transform related variables.
30  Its job is to keep all information about the transform (as e.g.: spacing, offset, transformation matrices) in
31  consistent states.
32  It provides getters and setters to all transformation related information. Implementation is hidden and may be
33  subject to changes.
34  */
36  {
37  private:
38  //##Documentation
39  //## @brief Index to World Transform, contains a transformation matrix to convert
40  //## points from index coordinates to world coordinates (mm). The Spacing is included in this variable.
41  AffineTransform3D::Pointer m_IndexToWorldTransform;
42 
43  vtkMatrix4x4 *m_VtkMatrix;
44  vtkMatrixToLinearTransform *m_VtkIndexToWorldTransform;
45 
46  static void CopySpacingFromTransform(const mitk::AffineTransform3D *transform, mitk::Vector3D &spacing);
47 
48  //##Documentation
49  //## @brief Copy the ITK transform
50  //## (m_IndexToWorldTransform) to the VTK transform
51  //## \sa SetIndexToWorldTransform
52  void TransferItkToVtkTransform();
53 
54  //##Documentation
55  //## @brief Copy the VTK transform
56  //## to the ITK transform (m_IndexToWorldTransform)
57  //## \sa SetIndexToWorldTransform
58  void TransferVtkToItkTransform();
59 
60  protected:
61  public:
62  typedef itk::ScalableAffineTransform<ScalarType, 3> TransformType;
63 
65 
67 
68  virtual ~GeometryTransformHolder();
69 
70  void Initialize();
71 
72  void Initialize(const GeometryTransformHolder *other);
73 
74  //##Documentation
75  //## @brief Get the origin, e.g. the upper-left corner of the plane
76  const Point3D GetOrigin() const;
77 
78  //##Documentation
79  //## @brief Set the origin, i.e. the upper-left corner of the plane
80  //##
81  void SetOrigin(const Point3D &origin);
82 
83  //##Documentation
84  //## @brief Get the spacing (size of a pixel).
85  //##
86  const mitk::Vector3D GetSpacing() const;
87 
88  //##Documentation
89  //## @brief Set the spacing (m_Spacing).
90  //##
91  //##The spacing is also changed in the IndexToWorldTransform.
92  void SetSpacing(const mitk::Vector3D &aSpacing, bool enforceSetSpacing = false);
93 
94  //##Documentation
95  //## @brief Get the transformation used to convert from index
96  //## to world coordinates
98 
99  //##Documentation
100  //## @brief Get the transformation used to convert from index
101  //## to world coordinates
103 
104  //## @brief Set the transformation used to convert from index
105  //## to world coordinates.This will also change the spacing.
107 
108  //##Documentation
109  //## @brief Convenience method for setting the ITK transform
110  //## (m_IndexToWorldTransform) via an vtkMatrix4x4. This will also change the spacing.
111  //## \sa SetIndexToWorldTransform
112  virtual void SetIndexToWorldTransformByVtkMatrix(vtkMatrix4x4 *vtkmatrix);
113 
114  //## @brief Set the transformation used to convert from index
115  //## to world coordinates.This function keeps the original spacing.
117 
118  //##Documentation
119  //## @brief Convenience method for setting the ITK transform
120  //## (m_IndexToWorldTransform) via an vtkMatrix4x4. This function keeps the original spacing.
121  //## \sa SetIndexToWorldTransform
122  void SetIndexToWorldTransformByVtkMatrixWithoutChangingSpacing(vtkMatrix4x4 *vtkmatrix);
123 
124  //## Get the Vtk Matrix which describes the transform.
125  vtkMatrix4x4 *GetVtkMatrix();
126 
127  //## Get the Vtk Matrix which describes the transform.
128  const vtkMatrix4x4 *GetVtkMatrix() const;
129 
130  //##Documentation
131  //## @brief Get the m_IndexToWorldTransform as a vtkLinearTransform
132  vtkLinearTransform *GetVtkTransform() const;
133 
134  void SetMatrix(Matrix3D &matrix);
135 
136  void SetIdentity();
137 
138  void Compose(const TransformType *other, bool pre = false);
139 
140  void SetVtkMatrixDeepCopy(vtkTransform *vtktransform);
141 
143 
144  AffineTransform3D::MatrixType::InternalMatrixType GetVnlMatrix();
145  };
146  MITKCORE_EXPORT bool Equal(const mitk::GeometryTransformHolder &leftHandSide,
147  const mitk::GeometryTransformHolder &rightHandSide,
148  ScalarType eps,
149  bool verbose);
150 
151  MITKCORE_EXPORT bool Equal(const mitk::GeometryTransformHolder *leftHandSide,
152  const mitk::GeometryTransformHolder *rightHandSide,
153  ScalarType eps,
154  bool verbose);
155 }
156 #endif
mitk::GeometryTransformHolder::GetSpacing
const mitk::Vector3D GetSpacing() const
Get the spacing (size of a pixel).
mitk::GeometryTransformHolder::GetVnlMatrix
AffineTransform3D::MatrixType::InternalMatrixType GetVnlMatrix()
mitk::eps
const MITKCORE_EXPORT ScalarType eps
mitk::GeometryTransformHolder::SetIndexToWorldTransformByVtkMatrix
virtual void SetIndexToWorldTransformByVtkMatrix(vtkMatrix4x4 *vtkmatrix)
Convenience method for setting the ITK transform (m_IndexToWorldTransform) via an vtkMatrix4x4....
mitk::GeometryTransformHolder::SetMatrix
void SetMatrix(Matrix3D &matrix)
mitk::GeometryTransformHolder::TransformType
itk::ScalableAffineTransform< ScalarType, 3 > TransformType
Definition: mitkGeometryTransformHolder.h:62
mitkAffineTransform3D.h
mitk::GeometryTransformHolder::SetVtkMatrixDeepCopy
void SetVtkMatrixDeepCopy(vtkTransform *vtktransform)
mitk::GeometryTransformHolder::SetIdentity
void SetIdentity()
mitk::Equal
MITKNEWMODULE_EXPORT bool Equal(mitk::ExampleDataStructure *leftHandSide, mitk::ExampleDataStructure *rightHandSide, mitk::ScalarType eps, bool verbose)
Returns true if the example data structures are considered equal.
mitk::GeometryTransformHolder::IsIndexToWorldTransformNull
bool IsIndexToWorldTransformNull()
mitkPoint.h
mitk::AffineTransform3D
itk::ScalableAffineTransform< ScalarType, 3 > AffineTransform3D
Definition: mitkAffineTransform3D.h:23
mitkMatrix.h
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::Vector< ScalarType, 3 >
MitkCoreExports.h
mitk::GeometryTransformHolder::Compose
void Compose(const TransformType *other, bool pre=false)
mitk::Point< ScalarType, 3 >
mitk::Matrix
Definition: mitkMatrix.h:25
mitk::GeometryTransformHolder::GetOrigin
const Point3D GetOrigin() const
Get the origin, e.g. the upper-left corner of the plane.
mitk::GeometryTransformHolder::SetIndexToWorldTransformByVtkMatrixWithoutChangingSpacing
void SetIndexToWorldTransformByVtkMatrixWithoutChangingSpacing(vtkMatrix4x4 *vtkmatrix)
Convenience method for setting the ITK transform (m_IndexToWorldTransform) via an vtkMatrix4x4....
mitkCommon.h
mitk::GeometryTransformHolder::Initialize
void Initialize()
mitk::GeometryTransformHolder::SetSpacing
void SetSpacing(const mitk::Vector3D &aSpacing, bool enforceSetSpacing=false)
Set the spacing (m_Spacing).
mitk::GeometryTransformHolder::SetIndexToWorldTransformWithoutChangingSpacing
void SetIndexToWorldTransformWithoutChangingSpacing(mitk::AffineTransform3D *transform)
mitk::GeometryTransformHolder::GetVtkMatrix
vtkMatrix4x4 * GetVtkMatrix()
mitk::GeometryTransformHolder::GeometryTransformHolder
GeometryTransformHolder()
mitk::GeometryTransformHolder::GetVtkTransform
vtkLinearTransform * GetVtkTransform() const
Get the m_IndexToWorldTransform as a vtkLinearTransform.
mitk::GeometryTransformHolder::GetIndexToWorldTransform
mitk::AffineTransform3D * GetIndexToWorldTransform()
Get the transformation used to convert from index to world coordinates.
mitk::GeometryTransformHolder::SetIndexToWorldTransform
void SetIndexToWorldTransform(mitk::AffineTransform3D *transform)
mitk::GeometryTransformHolder::~GeometryTransformHolder
virtual ~GeometryTransformHolder()
mitkVector.h
mitk::GeometryTransformHolder::SetOrigin
void SetOrigin(const Point3D &origin)
Set the origin, i.e. the upper-left corner of the plane.
mitk::GeometryTransformHolder
Definition: mitkGeometryTransformHolder.h:35
MITKCORE_EXPORT
#define MITKCORE_EXPORT
Definition: MitkCoreExports.h:15
mitk::ScalarType
double ScalarType
Definition: mitkNumericConstants.h:20