MeVisLab Toolbox Reference
mlVTKSpecialFieldsSupport.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2007, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 #pragma once
14 
15 #include "mlInitSystemVTKSupport.h"
16 
17 #include "mlModuleIncludes.h"
18 #include "mlMultiFields.h"
19 
21 #include <vtkMatrix4x4.h>
22 
23 ML_START_NAMESPACE
24 
25 
26 //---------------------------------------------------------------------------
29 //---------------------------------------------------------------------------
30 inline vtkMatrix4x4* VTKMatrix4x4FromMLMatrix(const Matrix4 &mat)
31 {
32  vtkMatrix4x4 *resultMat=vtkMatrix4x4::New();
33  for (int i=0; i < 4; ++i){
34  for (int j=0; j < 4; ++j){
35  resultMat->SetElement(i,j, mat[i][j]);
36  }
37  }
38  return resultMat;
39 }
40 
41 //---------------------------------------------------------------------------
43 //---------------------------------------------------------------------------
44 inline Matrix4 MLMatrixFromVTKMatrix4x4(const vtkMatrix4x4* mat)
45 {
46  Matrix4 resultMat;
47  if (mat){
48  for (int i=0; i < 4; ++i){
49  for (int j=0; j < 4; ++j){
50  resultMat[i][j] = mat->GetElement(i,j);
51  }
52  }
53  }
54  else{
55  // Initialize as identity.
56  resultMat = Matrix4::getIdentity();
57  }
58  return resultMat;
59 }
60 
61 ML_END_NAMESPACE
vtkMatrix4x4 * VTKMatrix4x4FromMLMatrix(const Matrix4 &mat)
Convert an ML 4x4 matrix to a VTK 4x4 matrix which is created with vtkMatrix4x4::New() and which must...
Matrix4 MLMatrixFromVTKMatrix4x4(const vtkMatrix4x4 *mat)
Convert a VTK 4x4 matrix to an ML 4x4 matrix.