Medical Imaging Interaction Toolkit  2018.4.99-12ad79a3
Medical Imaging Interaction Toolkit
mitkNavigationDataToMessageFilter.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 
19  m_PositionEpsilon(0.0f), m_OrientationEpsilon(0.0f), m_CovErrorEpsilon(0.0f), m_TimeStampEpsilon(0.0f)
20 {
21  this->SetNumberOfRequiredInputs(1);
22 }
23 
25 {
26 }
27 
28 
29 //void mitk::NavigationDataToMessageFilter::SetInput( unsigned int idx, const NavigationData* nd )
30 //{
31 // if (idx > 0)
32 // throw std::invalid_argument("mitk::NavigationDataToMessageFilter: only one input is supported");
33 // // Process object is not const-correct so the const_cast is required here
34 // this->ProcessObject::SetNthInput(idx, const_cast<NavigationData*>(nd));
35 // this->CreateOutputsForAllInputs();
36 //}
37 
38 
39 //void mitk::NavigationDataToMessageFilter::SetInput( const NavigationData* nd )
40 //{
41 // // Process object is not const-correct so the const_cast is required here
42 // this->ProcessObject::SetNthInput(0, const_cast<NavigationData*>(nd));
43 // this->CreateOutputsForAllInputs();
44 //}
45 
46 
48 {
49  /* update outputs with tracking data from tools */
50  for (unsigned int i = 0; i < this->GetNumberOfOutputs() ; ++i)
51  {
52  mitk::NavigationData* output = this->GetOutput(i);
53  assert(output);
54  const mitk::NavigationData* input = this->GetInput(i);
55  assert(input);
56 
57  /* check for differences, then send message. */
58  if ((output->GetPosition() - input->GetPosition()).GetNorm() > m_PositionEpsilon)
59  m_PositionChangedMessage.Send(input->GetPosition(), i);
60 
61  if ((output->GetOrientation() - input->GetOrientation()).magnitude() > m_OrientationEpsilon)
62  m_OrientationChangedMessage.Send(input->GetOrientation(), i);
63 
64  if ((output->GetCovErrorMatrix().GetVnlMatrix() - input->GetCovErrorMatrix().GetVnlMatrix()).absolute_value_max() > m_CovErrorEpsilon)
65  m_ErrorChangedMessage.Send(input->GetCovErrorMatrix(), i);
66 
67  if (fabs(output->GetIGTTimeStamp() - input->GetIGTTimeStamp()) > m_TimeStampEpsilon)
68  m_TimeStampChangedMessage.Send(input->GetIGTTimeStamp(), i);
69 
70  if (input->IsDataValid() != output->IsDataValid())
71  m_DataValidChangedMessage.Send(input->IsDataValid(), i);
72 
73  output->Graft(input); // Because this is a NavigationDataToNavigationData Filter, we need to copy the input to the output to provide up to date navigation data objects
74  }
75 }
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 PositionType GetPosition() const
returns position of the NavigationData object
const NavigationData * GetInput(void) const
Get the input of this filter.
virtual TimeStampType GetIGTTimeStamp() const
gets the IGT timestamp of the NavigationData object in milliseconds Please note, that there is also t...
void GenerateData() override
filter execute method
void Graft(const DataObject *data) override
Graft the data and information from one NavigationData to another.
virtual CovarianceMatrixType GetCovErrorMatrix() const
gets the 6x6 Error Covariance Matrix of the NavigationData object
virtual OrientationType GetOrientation() const
returns the orientation of the NavigationData object
virtual bool IsDataValid() const
returns true if the object contains valid data