MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
mitkNavigationDataDisplacementFilter.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#include "mitkPropertyList.h"
15#include "mitkProperties.h"
16
18: mitk::NavigationDataToNavigationDataFilter(), m_Transform6DOF(false)
19{
20 m_Offset[0] = 0.0;
21 m_Offset[1] = 0.0;
22 m_Offset[2] = 0.0;
23
24 m_Transformation = mitk::NavigationData::New();
25
26}
27
28
32
33
35{
36 /* update outputs with tracking data from tools */
37 if( !m_Transform6DOF )
38 {
39 for (unsigned int i = 0; i < this->GetNumberOfOutputs() ; ++i)
40 {
41 mitk::NavigationData* output = this->GetOutput(i);
42 assert(output);
43 const mitk::NavigationData* input = this->GetInput(i);
44 assert(input);
45
46 if (input->IsDataValid() == false)
47 {
48 output->SetDataValid(false);
49 continue;
50 }
51 output->Graft(input); // First, copy all information from input to output
52 output->SetPosition(input->GetPosition() + m_Offset); // Then change the member(s): add offset to position of navigation data
53 output->SetDataValid(true); // operation was successful, therefore data of output is valid.
54 // don't change anything else here
55 }
56 }
57 else
58 {
59 if( this->GetNumberOfOutputs() < 2 )
60 {
61 MITK_WARN << "TrackedUltrasound not possible. The number of tracked devices must be at least 2.";
62 return;
63 }
64
65 //important: First device = Needle | Second device = US-Tracker
66
67 mitk::NavigationData::Pointer needleOut = this->GetOutput(0);
68 const mitk::NavigationData* needleIn = this->GetInput(0);
69
70 mitk::NavigationData::Pointer usTrackerOut = this->GetOutput(1);
71 const mitk::NavigationData* usTrackerIn = this->GetInput(1);
72
73 if(needleIn->IsDataValid() == false )
74 {
75 needleOut->SetDataValid(false);
76 }
77 else
78 needleOut->Graft(needleIn);
79
80 if (usTrackerIn->IsDataValid() == false)
81 {
82 usTrackerOut->SetDataValid(false);
83 }
84 else
85 usTrackerOut->Graft(usTrackerIn);
86
87 needleOut->Compose( usTrackerOut->GetInverse(), false );
88 needleOut->Compose( m_Transformation->GetInverse() );
89
90 usTrackerOut->SetDataValid(true);
91 needleOut->SetDataValid(true);
92
93 if( this->GetNumberOfOutputs() > 2 )
94 {
95 for( unsigned int i = 2; i < this->GetNumberOfOutputs(); ++i )
96 {
97 mitk::NavigationData* output = this->GetOutput(i);
98 const mitk::NavigationData* input = this->GetInput(i);
99
100 if (input->IsDataValid() == false)
101 {
102 output->SetDataValid(false);
103 continue;
104 }
105 output->Graft(input);
106 output->SetDataValid(true);
107 }
108 }
109 }
110}
111
112
113void mitk::NavigationDataDisplacementFilter::SetTransformation(mitk::AffineTransform3D::Pointer transform)
114{
115 mitk::NavigationData::Pointer transformation = mitk::NavigationData::New(transform);
116 m_Transformation = transformation;
117}
118
120{
121 if (p == nullptr)
122 return;
123 mitk::Vector3D v;
124 if (p->GetPropertyValue<mitk::Vector3D>("NavigationDataDisplacementFilter_Offset", v) == true) // search for Offset parameter
125 this->SetOffset(v); // apply if found;
126}
127
128
129mitk::PropertyList::ConstPointer mitk::NavigationDataDisplacementFilter::GetParameters() const
130{
131 mitk::PropertyList::Pointer p = mitk::PropertyList::New();
132 p->SetProperty("NavigationDataDisplacementFilter_Offset", mitk::Vector3DProperty::New(this->GetOffset())); // store Offset parameter
133 return mitk::PropertyList::ConstPointer(p);
134}
mitk::PropertyList::ConstPointer GetParameters() const override
Get all filter parameters (offset) as a PropertyList.
mitk::Vector3D m_Offset
offset that is added to all inputs
void SetTransformation(mitk::AffineTransform3D::Pointer transform)
void SetParameters(const mitk::PropertyList *p) override
Set all filter parameters (Offset) as the PropertyList p.
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
IGT Exceptions.