Medical Imaging Interaction Toolkit  2018.4.99-12ad79a3
Medical Imaging Interaction Toolkit
mitkNavigationDataHandEyeCalibrationFilter.cpp
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 ============================================================================*/
13 
14 #include "mitkDataStorage.h"
15 
16 
19 m_ObjectsToTransform(),m_HandEyeTransformations()
20 {
21 }
22 
23 
25 {
26  m_ObjectsToTransform.clear();
28 }
29 
31 {
32  m_ObjectsToTransform[index] = data;
33 }
34 
35 void 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 }
NavigationData * GetOutput(void)
return the output (output with id 0) of the filter
Base of all data objects.
Definition: mitkBaseData.h:37
NavigationDataToNavigationDataFilter is the base class of all filters that receive NavigationDatas as...
Navigation Data.
virtual void SetDataValid(bool _arg)
sets the dataValid flag of the NavigationData object indicating if the object contains valid data ...
std::map< int, Transform::Pointer > m_HandEyeTransformations
Map of the hand-eye transformations that should be applied to the BaseDatas.
virtual PositionType GetPosition() const
returns position of the NavigationData object
const NavigationData * GetInput(void) const
Get the input of this filter.
void SetObjectToTransform(unsigned int index, BaseData *data)
Set the object that will be transformed to tracking coordinates using the current NavigationData and ...
std::map< int, BaseData::Pointer > m_ObjectsToTransform
Map of the BaseDatas that should be transformed.
void SetHandEyeTransformation(unsigned int index, Transform::Pointer handEyeTransform)
Set the transformation of the HandEyeCalibration that should be applied to the BaseData with the curr...
void Graft(const DataObject *data) override
Graft the data and information from one NavigationData to another.
virtual OrientationType GetOrientation() const
returns the orientation of the NavigationData object
virtual bool IsDataValid() const
returns true if the object contains valid data