Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkNavigationDataTransformFilter.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 ===================================================================*/
16 
18 
19 
22 {
23  m_Rigid3DTransform = NULL;
24  m_Precompose = false;
25 }
26 
27 
29 {
30  m_Rigid3DTransform = NULL;
31 }
32 
34 {
35 
36  // only update data if m_Transform was set
37  if(m_Rigid3DTransform.IsNull())
38  {
39  itkExceptionMacro("Invalid parameter: Transform was not set! Use SetRigid3DTransform() before updating the filter.");
40  return;
41  }
42  else
43  {
44  this->CreateOutputsForAllInputs(); // make sure that we have the same number of outputs as inputs
45 
46  /* update outputs with tracking data from tools */
47  for (unsigned int i = 0; i < this->GetNumberOfIndexedOutputs() ; ++i)
48  {
49  mitk::NavigationData* output = this->GetOutput(i);
50  assert(output);
51  const mitk::NavigationData* input = this->GetInput(i);
52  assert(input);
53 
54  if (input->IsDataValid() == false)
55  {
56  output->SetDataValid(false);
57  continue;
58  }
59 
60  // Get input position/orientation as float numbers
61  const NavigationData::PositionType pInF = input->GetPosition();
62  const NavigationData::OrientationType oInF = input->GetOrientation();
63 
64  // Cast the input NavigationData to double precision
65  TransformType::OutputVectorType pInD;
66  FillVector3D(pInD, pInF[0], pInF[1], pInF[2]);
67  TransformType::VersorType oInD;
68  oInD.Set(oInF.x(), oInF.y(), oInF.z(), oInF.r());
69 
70  TransformType::Pointer composedTransform = TransformType::New();
71  // SetRotation+SetOffset defines the Tip-to-World coordinate frame
72  // transformation ("World" is used in the generic sense)
73  composedTransform->SetRotation(oInD);
74  composedTransform->SetOffset(pInD);
75  // If !m_Precompose: The resulting transform is Tip-to-UserWorld
76  // If m_Precompose: The resulting transform is UserTip-to-World
77  composedTransform->Compose(m_Rigid3DTransform, m_Precompose);
78 
79  // Transformed position/orientation as double numbers
80  const TransformType::OutputVectorType pOutD = composedTransform->GetOffset();
81  const TransformType::VersorType oOutD = composedTransform->GetVersor();
82 
83  // Cast to transformed NavigationData back to float precision
84  NavigationData::OrientationType oOutF(oOutD.GetX(), oOutD.GetY(), oOutD.GetZ(), oOutD.GetW());
86  FillVector3D(pOutF, pOutD[0], pOutD[1], pOutD[2]);
87 
88  output->SetOrientation(oOutF);
89  output->SetPosition(pOutF);
90  output->SetDataValid(true); // operation was successful, therefore data of output is valid.
91  }
92  }
93 }
itk::SmartPointer< Self > Pointer
NavigationDataToNavigationDataFilter is the base class of all filters that receive NavigationDatas as...
Navigation Data.
DataCollection - Class to facilitate loading/accessing structured 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
mitk::Quaternion OrientationType
Type that holds the orientation part of the tracking data.
void FillVector3D(Tout &out, mitk::ScalarType x, mitk::ScalarType y, mitk::ScalarType z)
Definition: mitkArray.h:110
TransformType::Pointer m_Rigid3DTransform
transform which will be applied on navigation data(s)
virtual void SetOrientation(OrientationType _arg)
sets the orientation of the NavigationData object
virtual bool IsDataValid() const
returns true if the object contains valid data
virtual void SetPosition(PositionType _arg)
sets the position of the NavigationData object
virtual PositionType GetPosition() const
returns position of the NavigationData object
virtual void GenerateData() override
filter execute method
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.