Medical Imaging Interaction Toolkit  2026.06.00
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 {
38  {
39  private:
46  AffineTransform3D::Pointer m_IndexToWorldTransform;
47 
48  vtkMatrix4x4 *m_VtkMatrix;
49  vtkMatrixToLinearTransform *m_VtkIndexToWorldTransform;
50 
51  static void CopySpacingFromTransform(const mitk::AffineTransform3D *transform, mitk::Vector3D &spacing);
52 
58  void TransferItkToVtkTransform();
59 
65  void TransferVtkToItkTransform();
66 
67  protected:
68  public:
69  typedef itk::ScalableAffineTransform<ScalarType, 3> TransformType;
70 
73 
80 
83 
85  void Initialize();
86 
92  void Initialize(const GeometryTransformHolder *other);
93 
99  Point3D GetOrigin() const;
100 
106  void SetOrigin(const Point3D &origin);
107 
114 
123  void SetSpacing(const mitk::Vector3D &aSpacing, bool enforceSetSpacing = false);
124 
131 
138 
147 
157  virtual void SetIndexToWorldTransformByVtkMatrix(vtkMatrix4x4 *vtkmatrix);
158 
165 
176 
182  vtkMatrix4x4 *GetVtkMatrix();
183 
189  const vtkMatrix4x4 *GetVtkMatrix() const;
190 
196  vtkLinearTransform *GetVtkTransform() const;
197 
203  void SetMatrix(Matrix3D &matrix);
204 
206  void SetIdentity();
207 
214  void Compose(const TransformType *other, bool pre = false);
215 
221  void SetVtkMatrixDeepCopy(vtkTransform *vtktransform);
222 
229 
235  AffineTransform3D::MatrixType::InternalMatrixType GetVnlMatrix();
236  };
247  const mitk::GeometryTransformHolder &rightHandSide,
248  ScalarType eps,
249  bool verbose);
250 
261  const mitk::GeometryTransformHolder *rightHandSide,
262  ScalarType eps,
263  bool verbose);
264 }
265 #endif
#define MITKCORE_EXPORT
Helper class that manages transform-related variables for geometries.
void SetVtkMatrixDeepCopy(vtkTransform *vtktransform)
Deep-copy a vtkTransform into the internal VTK matrix.
mitk::Vector3D GetSpacing() const
Get the spacing (size of a pixel).
Point3D GetOrigin() const
Get the origin, e.g. the upper-left corner of the plane.
void Initialize(const GeometryTransformHolder *other)
Initialize this transform holder from another instance.
vtkLinearTransform * GetVtkTransform() const
Get the index-to-world transform as a vtkLinearTransform.
void SetIndexToWorldTransformWithoutChangingSpacing(mitk::AffineTransform3D *transform)
Set the transformation used to convert from index to world coordinates, keeping original spacing.
virtual ~GeometryTransformHolder()
Destructor.
GeometryTransformHolder()
Default constructor.
itk::ScalableAffineTransform< ScalarType, 3 > TransformType
vtkMatrix4x4 * GetVtkMatrix()
Get the VTK matrix which describes the transform.
void SetMatrix(Matrix3D &matrix)
Set the rotation/scaling matrix.
const mitk::AffineTransform3D * GetIndexToWorldTransform() const
Get the transformation used to convert from index to world coordinates (const version).
void SetIndexToWorldTransform(mitk::AffineTransform3D *transform)
Set the transformation used to convert from index to world coordinates.
void SetIndexToWorldTransformByVtkMatrixWithoutChangingSpacing(vtkMatrix4x4 *vtkmatrix)
Set the ITK transform via a vtkMatrix4x4, keeping original spacing.
virtual void SetIndexToWorldTransformByVtkMatrix(vtkMatrix4x4 *vtkmatrix)
Set the ITK transform (m_IndexToWorldTransform) via a vtkMatrix4x4.
mitk::AffineTransform3D * GetIndexToWorldTransform()
Get the transformation used to convert from index to world coordinates.
void SetOrigin(const Point3D &origin)
Set the origin, i.e. the upper-left corner of the plane.
bool IsIndexToWorldTransformNull()
Check whether the IndexToWorldTransform is null.
void Compose(const TransformType *other, bool pre=false)
Compose with another transform.
GeometryTransformHolder(const GeometryTransformHolder &other)
Copy constructor.
AffineTransform3D::MatrixType::InternalMatrixType GetVnlMatrix()
Get the VNL matrix representation of the transform.
const vtkMatrix4x4 * GetVtkMatrix() const
Get the VTK matrix which describes the transform (const version).
void SetIdentity()
Set the transform to identity.
void SetSpacing(const mitk::Vector3D &aSpacing, bool enforceSetSpacing=false)
Set the spacing.
void Initialize()
Initialize the transform to default values.
MITK matrix type extending itk::Matrix with additional constructors and utility methods.
Definition: mitkMatrix.h:32
Find image slices visible on a given plane.
MITKCORE_EXPORT const ScalarType eps
Epsilon value for floating point comparison (vnl_math::eps * 100).
itk::ScalableAffineTransform< ScalarType, 3 > AffineTransform3D
3D affine transform type used throughout MITK.
double ScalarType
Scalar type used throughout MITK for geometric computations.
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.