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

Function GetWorldToItkPhysicalTransform

Modules/Core/include/mitkMatrixConvert.h:150–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148 */
149 template <class TTransformType>
150 void GetWorldToItkPhysicalTransform(const mitk::BaseGeometry *geometry, TTransformType *itkTransform)
151 {
152 if (itkTransform == nullptr)
153 return;
154
155 // get rotation matrix and offset from Geometry and transfer in TTransformType types
156 typename TTransformType::MatrixType rotationMatrix;
157 GetRotation(geometry, rotationMatrix);
158
159 const typename mitk::BaseGeometry::TransformType::OffsetType &geometryOffset =
160 geometry->GetIndexToWorldTransform()->GetOffset();
161
162 vnl_vector<typename TTransformType::MatrixType::ValueType> vnlOffset(3);
163 vnlOffset[0] = geometryOffset[0];
164 vnlOffset[1] = geometryOffset[1];
165 vnlOffset[2] = geometryOffset[2];
166
167 // do calculations
168 typename TTransformType::MatrixType::InternalMatrixType inverseRotationVnlMatrix = rotationMatrix.GetTranspose();
169
170 vnlOffset -= inverseRotationVnlMatrix * vnlOffset;
171
172 typename TTransformType::OutputVectorType offset; // vnl_vector<TTransformType::MatrixType::ValueType> offset;
173 offset[0] = vnlOffset[0];
174 offset[1] = vnlOffset[1];
175 offset[2] = vnlOffset[2];
176 itkTransform->SetOffset(offset);
177
178 // copy in destination itkTransform
179 typename TTransformType::MatrixType::InternalMatrixType &destVnlMatrix =
180 itkTransform->GetMatrix().GetVnlMatrix();
181
182 for (int i = 0; i < 3; ++i)
183 for (int j = 0; j < 3; ++j)
184 destVnlMatrix[i][j] = inverseRotationVnlMatrix[i][j];
185 // *This* ensures m_MatrixMTime.Modified(), which is therewith not equal to
186 // m_InverseMatrixMTime, thus a new inverse will be calculated (when
187 // requested).
188 static_cast<mitk::ItkMatrixHack<TTransformType> *>(itkTransform)->MatrixChanged();
189 }
190}
191
192#endif

Callers

nothing calls this directly

Calls 6

GetRotationFunction · 0.85
GetOffsetMethod · 0.80
GetVnlMatrixMethod · 0.80
GetMatrixMethod · 0.80
MatrixChangedMethod · 0.80

Tested by

no test coverage detected