MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
mitkNavigationDataHandEyeCalibrationFilter.cpp
Go to the documentation of this file.
1/*============================================================================
2
3The Medical Imaging Interaction Toolkit (MITK)
4
5Copyright (c) German Cancer Research Center (DKFZ)
6All rights reserved.
7
8Use of this source code is governed by a 3-clause BSD license that can be
9found in the LICENSE file.
10
11============================================================================*/
13
14#include "mitkDataStorage.h"
15
16
22
23
25{
26 m_ObjectsToTransform.clear();
27 m_HandEyeTransformations.clear();
28}
29
31{
32 m_ObjectsToTransform[index] = data;
33}
34
35void mitk::NavigationDataHandEyeCalibrationFilter::SetHandEyeTransformation(unsigned int index, mitk::Transform::Pointer handEyeTransformation)
36{
37 m_HandEyeTransformations[index] = handEyeTransformation;
38}
39
41{
42 /*get each input, lookup the associated BaseData and transfer the data*/
43 unsigned int numberOfInputs = this->GetNumberOfInputs();
44 for (unsigned int index=0; index < numberOfInputs; index++)
45 {
46 //get the needed variables
47 const mitk::NavigationData* nd = this->GetInput(index);
48 assert(nd);
49
50 mitk::NavigationData* output = this->GetOutput(index);
51 assert(output);
52
53 //check if the data is valid
54 if (!nd->IsDataValid())
55 {
56 output->SetDataValid(false);
57 continue;
58 }
59 output->Graft(nd); // copy all information from input to output
60 // get the object to transform for current input index
61 mitk::BaseData::Pointer objectToTransform = m_ObjectsToTransform[index];
62 if (!objectToTransform)
63 {
64 continue;
65 }
66 // get the transformation of the hand-eye calibration for current input index
67 QuaternionRigidTransformType::Pointer handEyeTransform = QuaternionRigidTransformType::New();;
68 if (!m_HandEyeTransformations[index])
69 {
70 continue;
71 }
72 else
73 {
74 handEyeTransform->SetRotation(m_HandEyeTransformations[index]->GetOrientation());
75 handEyeTransform->SetOffset(m_HandEyeTransformations[index]->GetPosition().GetVectorFromOrigin());
76 }
77 // get the transformation of the current navigation data
78 QuaternionRigidTransformType::Pointer ndTransform = QuaternionRigidTransformType::New();
79 ndTransform->SetRotation(nd->GetOrientation());
80 ndTransform->SetOffset(nd->GetPosition().GetVectorFromOrigin());
81 // compose hand-eye transformation and transformation of NavigationData to final transformation to be applied
82 mitk::AffineTransform3D::Pointer transform = mitk::AffineTransform3D::New();
83 transform->SetIdentity();
84 transform->Compose(handEyeTransform);
85 transform->Compose(ndTransform);
86 // apply final transformation to BaseData
87 objectToTransform->GetGeometry()->SetIndexToWorldTransform(transform);
88 objectToTransform->Modified();
89 // operation was successful, therefore data of output is valid.
90 output->SetDataValid(true);
91 }
92}
void SetObjectToTransform(unsigned int index, BaseData *data)
Set the object that will be transformed to tracking coordinates using the current NavigationData and ...
void SetHandEyeTransformation(unsigned int index, Transform::Pointer handEyeTransform)
Set the transformation of the HandEyeCalibration that should be applied to the BaseData with the curr...
NavigationDataToNavigationDataFilter is the base class of all filters that receive NavigationDatas as...
void Graft(const DataObject *data) override
Graft the data and information from one NavigationData to another.
virtual bool IsDataValid() const
returns true if the object contains valid data