MCPcopy Create free account
hub / github.com/MITK/MITK / TransferVtkMatrixToItkTransform

Function TransferVtkMatrixToItkTransform

Modules/Core/include/mitkMatrixConvert.h:38–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36 */
37 template <class TTransformType>
38 void TransferVtkMatrixToItkTransform(const vtkMatrix4x4 *vtkmatrix, TTransformType *itkTransform)
39 {
40 if (itkTransform == nullptr)
41 return;
42
43 typename TTransformType::MatrixType::InternalMatrixType &vnlMatrix =
44 const_cast<typename TTransformType::MatrixType::InternalMatrixType &>(itkTransform->GetMatrix().GetVnlMatrix());
45
46 for (int i = 0; i < 3; ++i)
47 for (int j = 0; j < 3; ++j)
48 vnlMatrix[i][j] = vtkmatrix->GetElement(i, j);
49 // *This* ensures m_MatrixMTime.Modified(), which is therewith not equal to
50 // m_InverseMatrixMTime, thus a new inverse will be calculated (when
51 // requested).
52 static_cast<mitk::ItkMatrixHack<TTransformType> *>(itkTransform)->MatrixChanged();
53
54 typename TTransformType::OffsetType offset;
55 offset[0] = vtkmatrix->GetElement(0, 3);
56 offset[1] = vtkmatrix->GetElement(1, 3);
57 offset[2] = vtkmatrix->GetElement(2, 3);
58 itkTransform->SetOffset(offset);
59 }
60
61 /**
62 * \brief Transfer an ITK transform into a VTK 4x4 matrix.

Callers 2

ComposeMethod · 0.85

Calls 4

GetVnlMatrixMethod · 0.80
GetMatrixMethod · 0.80
MatrixChangedMethod · 0.80
GetElementMethod · 0.45

Tested by

no test coverage detected