Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkNavigationDataSmoothingFilter.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 
17  m_NumerOfValues(5)
18 {
19 }
20 
22 {
23 }
24 
26 {
27  DataObjectPointerArraySizeType numberOfInputs = this->GetNumberOfInputs();
28 
29  if ( numberOfInputs == 0 ) return;
30 
32 
33  //initialize list if nessesary
34  if ( m_LastValuesList.size() != numberOfInputs )
35  {
37  }
38 
39  //add current value to list
40  for ( unsigned int i = 0; i < numberOfInputs; ++i )
41  {
42  this->AddValue(i,this->GetInput(i)->GetPosition());
43  }
44 
45  //generate output
46  for (unsigned int i = 0; i < numberOfInputs; ++i)
47  {
48  const mitk::NavigationData* nd = this->GetInput(i);
49  assert(nd);
50 
51  mitk::NavigationData* output = this->GetOutput(i);
52  assert(output);
53 
54  output->Graft(nd); // copy all information from input to output
55 
56  output->SetPosition(GetMean(i));
57 
58  output->SetDataValid(nd->IsDataValid());
59  }
60 }
61 
63 {
64  m_LastValuesList = std::map< int, std::map< int , mitk::Point3D> >();
65 
66  for ( unsigned int i = 0; i < this->GetNumberOfOutputs(); ++i )
67  {
68  std::map<int,mitk::Point3D> currentList;
69  for ( int j = 0; j < m_NumerOfValues; ++j )
70  {
71  mitk::Point3D emptyPoint;
72  emptyPoint.Fill(0);
73  currentList.insert(std::pair<int, mitk::Point3D>(j, emptyPoint));
74  }
75  m_LastValuesList.insert(std::pair<int, std::map<int,mitk::Point3D> > (i,currentList));
76  }
77 }
78 
80 {
81  for (int i = 1; i < m_NumerOfValues; ++i)
82  {
83  m_LastValuesList[outputID][i-1] = m_LastValuesList[outputID][i];
84  }
85 
86  m_LastValuesList[outputID][m_NumerOfValues-1] = value;
87 }
88 
90 {
91  mitk::Point3D mean;
92  mean.Fill(0);
93  for (int i=0; i<m_NumerOfValues; i++)
94  {
95  mean[0] += m_LastValuesList[outputID][i][0];
96  mean[1] += m_LastValuesList[outputID][i][1];
97  mean[2] += m_LastValuesList[outputID][i][2];
98  }
99  mean[0] /= m_NumerOfValues;
100  mean[1] /= m_NumerOfValues;
101  mean[2] /= m_NumerOfValues;
102  return mean;
103 }
void AddValue(int outputID, mitk::Point3D value)
NavigationData * GetOutput(void)
return the output (output with id 0) of the filter
std::map< int, std::map< int, mitk::Point3D > > m_LastValuesList
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 ...
const NavigationData * GetInput(void) const
Get the input of this filter.
virtual void SetPosition(PositionType _arg)
sets the position of the NavigationData object
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