MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
mitkNavigationDataTransformFilter.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============================================================================*/
12
14
15
22
23
28
30{
31
32 // only update data if m_Transform was set
33 if(m_Rigid3DTransform.IsNull())
34 {
35 itkExceptionMacro("Invalid parameter: Transform was not set! Use SetRigid3DTransform() before updating the filter.");
36 return;
37 }
38 else
39 {
40 this->CreateOutputsForAllInputs(); // make sure that we have the same number of outputs as inputs
41
42 /* update outputs with tracking data from tools */
43 for (unsigned int i = 0; i < this->GetNumberOfIndexedOutputs() ; ++i)
44 {
45 mitk::NavigationData* output = this->GetOutput(i);
46 assert(output);
47 const mitk::NavigationData* input = this->GetInput(i);
48 assert(input);
49
50 if (input->IsDataValid() == false)
51 {
52 output->SetDataValid(false);
53 continue;
54 }
55
56 // Get input position/orientation as float numbers
57 const NavigationData::PositionType pInF = input->GetPosition();
58 const NavigationData::OrientationType oInF = input->GetOrientation();
59
60 // Cast the input NavigationData to double precision
61 TransformType::OutputVectorType pInD;
62 FillVector3D(pInD, pInF[0], pInF[1], pInF[2]);
63 TransformType::VersorType oInD;
64 oInD.Set(oInF.x(), oInF.y(), oInF.z(), oInF.r());
65
66 TransformType::Pointer composedTransform = TransformType::New();
67 // SetRotation+SetOffset defines the Tip-to-World coordinate frame
68 // transformation ("World" is used in the generic sense)
69 composedTransform->SetRotation(oInD);
70 composedTransform->SetOffset(pInD);
71 // If !m_Precompose: The resulting transform is Tip-to-UserWorld
72 // If m_Precompose: The resulting transform is UserTip-to-World
73 composedTransform->Compose(m_Rigid3DTransform, m_Precompose);
74
75 // Transformed position/orientation as double numbers
76 const TransformType::OutputVectorType pOutD = composedTransform->GetOffset();
77 const TransformType::VersorType oOutD = composedTransform->GetVersor();
78
79 // Cast to transformed NavigationData back to float precision
80 NavigationData::OrientationType oOutF(oOutD.GetX(), oOutD.GetY(), oOutD.GetZ(), oOutD.GetW());
82 FillVector3D(pOutF, pOutD[0], pOutD[1], pOutD[2]);
83
84 output->SetOrientation(oOutF);
85 output->SetPosition(pOutF);
86 output->SetDataValid(true); // operation was successful, therefore data of output is valid.
87 }
88 }
89}
NavigationDataToNavigationDataFilter is the base class of all filters that receive NavigationDatas as...
TransformType::Pointer m_Rigid3DTransform
transform which will be applied on navigation data(s)
void GenerateData() override
filter execute method
mitk::Quaternion OrientationType
Type that holds the orientation part of the tracking data.
virtual bool IsDataValid() const
returns true if the object contains valid data
mitk::Point3D PositionType
Type that holds the position part of the tracking data.
IGT Exceptions.