Medical Imaging Interaction Toolkit  2018.4.99-6aa36ba9
Medical Imaging Interaction Toolkit
mitkNavigationDataDisplacementFilter.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 ============================================================================*/
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 
25 
26 }
27 
28 
30 {
31 }
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 
113 void 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 
130 {
132  p->SetProperty("NavigationDataDisplacementFilter_Offset", mitk::Vector3DProperty::New(this->GetOffset())); // store Offset parameter
134 }
static Pointer New()
static Pointer New()
NavigationData * GetOutput(void)
return the output (output with id 0) of the filter
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 ...
Key-value list holding instances of BaseProperty.
virtual PositionType GetPosition() const
returns position of the NavigationData object
const NavigationData * GetInput(void) const
Get the input of this filter.
static Pointer New()
bool GetPropertyValue(const char *propertyKey, T &value) const
Convenience access method for GenericProperty<T> properties (T being the type of the second parameter...
#define MITK_WARN
Definition: mitkLogMacros.h:19
mitk::PropertyList::ConstPointer GetParameters() const override
Get all filter parameters (offset) as a PropertyList.
void SetTransformation(mitk::AffineTransform3D::Pointer transform)
itk::SmartPointer< const Self > ConstPointer
virtual void SetPosition(PositionType _arg)
sets the position of the NavigationData object
void SetParameters(const mitk::PropertyList *p) override
Set all filter parameters (Offset) as the PropertyList p.
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
mitk::Vector3D m_Offset
offset that is added to all inputs