Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
17 
18 #include "mitkDataStorage.h"
19 
20 
23 m_ObjectsToTransform(),m_HandEyeTransformations()
24 {
25 }
26 
27 
29 {
30  m_ObjectsToTransform.clear();
31  m_HandEyeTransformations.clear();
32 }
33 
35 {
36  m_ObjectsToTransform[index] = data;
37 }
38 
40 {
41  m_HandEyeTransformations[index] = handEyeTransformation;
42 }
43 
45 {
46  /*get each input, lookup the associated BaseData and transfer the data*/
47  unsigned int numberOfInputs = this->GetNumberOfInputs();
48  for (unsigned int index=0; index < numberOfInputs; index++)
49  {
50  //get the needed variables
51  const mitk::NavigationData* nd = this->GetInput(index);
52  assert(nd);
53 
54  mitk::NavigationData* output = this->GetOutput(index);
55  assert(output);
56 
57  //check if the data is valid
58  if (!nd->IsDataValid())
59  {
60  output->SetDataValid(false);
61  continue;
62  }
63  output->Graft(nd); // copy all information from input to output
64  // get the object to transform for current input index
65  mitk::BaseData::Pointer objectToTransform = m_ObjectsToTransform[index];
66  if (!objectToTransform)
67  {
68  continue;
69  }
70  // get the transformation of the hand-eye calibration for current input index
72  if (!m_HandEyeTransformations[index])
73  {
74  continue;
75  }
76  else
77  {
78  handEyeTransform->SetRotation(m_HandEyeTransformations[index]->GetOrientation());
79  handEyeTransform->SetOffset(m_HandEyeTransformations[index]->GetPosition().GetVectorFromOrigin());
80  }
81  // get the transformation of the current navigation data
83  ndTransform->SetRotation(nd->GetOrientation());
84  ndTransform->SetOffset(nd->GetPosition().GetVectorFromOrigin());
85  // compose hand-eye transformation and transformation of NavigationData to final transformation to be applied
87  transform->SetIdentity();
88  transform->Compose(handEyeTransform);
89  transform->Compose(ndTransform);
90  // apply final transformation to BaseData
91  objectToTransform->GetGeometry()->SetIndexToWorldTransform(transform);
92  objectToTransform->Modified();
93  // operation was successful, therefore data of output is valid.
94  output->SetDataValid(true);
95  }
96 }
itk::SmartPointer< Self > Pointer
Base of all data objects.
Definition: mitkBaseData.h:39
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 ...
virtual OrientationType GetOrientation() const
returns the orientation of the NavigationData object
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...
virtual bool IsDataValid() const
returns true if the object contains valid data
virtual PositionType GetPosition() const
returns position of the NavigationData object
virtual void Graft(const DataObject *data) override
Graft the data and information from one NavigationData to another.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.