MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
mitkNavigationDataSmoothingFilter.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
20
24
26{
27 DataObjectPointerArraySizeType numberOfInputs = this->GetNumberOfInputs();
28
29 if ( numberOfInputs == 0 ) return;
30
31 this->CreateOutputsForAllInputs();
32
33 //initialize list if nessesary
34 if ( m_LastValuesList.size() != numberOfInputs )
35 {
36 this->InitializeLastValuesList();
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
79void mitk::NavigationDataSmoothingFilter::AddValue(int outputID, mitk::Point3D value)
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)
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.