MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
mitkNavigationDataRecorder.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 <mitkIGTTimeStamp.h>
15
17 : m_NumberOfInputs(0),
18 m_NavigationDataSet(nullptr),
19 m_Recording(false),
20 m_StandardizeTime(false),
21 m_StandardizedTimeInitialized(false),
22 m_RecordCountLimit(-1),
23 m_RecordOnlyValidData(false)
24{
25
26}
27
29{
30 //mitk::IGTTimeStamp::GetInstance()->Stop(this); //commented out because of bug 18952
31}
32
34{
35 // get each input, lookup the associated BaseData and transfer the data
36 DataObjectPointerArray inputs = this->GetIndexedInputs(); //get all inputs
37
38 //This vector will hold the NavigationDatas that are copied from the inputs
39 std::vector< mitk::NavigationData::Pointer > clonedDatas;
40
41 bool atLeastOneInputIsInvalid = false;
42
43 // For each input
44 for (unsigned int index=0; index < inputs.size(); index++)
45 {
46 // First copy input to output
47 this->GetOutput(index)->Graft(this->GetInput(index));
48
49 // if we are not recording, that's all there is to do
50 if (! m_Recording) continue;
51
52 if (atLeastOneInputIsInvalid || !this->GetInput(index)->IsDataValid())
53 {
54 atLeastOneInputIsInvalid = true;
55 }
56
57 // Clone a Navigation Data
58 mitk::NavigationData::Pointer clone = mitk::NavigationData::New();
59 clone->Graft(this->GetInput(index));
60 clonedDatas.push_back(clone);
61
62 if (m_StandardizeTime)
63 {
65 clonedDatas[index]->SetIGTTimeStamp(igtTimestamp);
66 }
67 }
68
69 // if limitation is set and has been reached, stop recording
70 if ((m_RecordCountLimit > 0) && (m_NavigationDataSet->Size() >= static_cast<unsigned int>(m_RecordCountLimit)))
71 m_Recording = false;
72 // We can skip the rest of the method, if recording is deactivated
73 if (!m_Recording) return;
74 // We can skip the rest of the method, if we read only valid data
75 if (m_RecordOnlyValidData && atLeastOneInputIsInvalid) return;
76
77 // Add data to set
78 m_NavigationDataSet->AddNavigationDatas(clonedDatas);
79}
80
82{
83 if (m_Recording)
84 {
85 MITK_WARN << "Already recording please stop before start new recording session";
86 return;
87 }
88 m_Recording = true;
89
90 // The first time this StartRecording is called, we initialize the standardized time.
91 // Afterwards, it can be reset via ResetNavigationDataSet();
92 if (! m_StandardizedTimeInitialized)
94
95 if (m_NavigationDataSet.IsNull())
96 m_NavigationDataSet = mitk::NavigationDataSet::New(GetNumberOfIndexedInputs());
97}
98
100{
101 if (!m_Recording)
102 {
103 std::cout << "You have to start a recording first" << std::endl;
104 return;
105 }
106 m_Recording = false;
107}
108
110{
111 m_NavigationDataSet = mitk::NavigationDataSet::New(GetNumberOfIndexedInputs());
112
113 if (m_Recording)
114 {
117 }
118}
119
121{
122 return m_NavigationDataSet->Size();
123}
static IGTTimeStamp * GetInstance()
returns a pointer to the current instance of mitkTimeStamp
void Start(itk::Object::Pointer device)
starts the time-acquisition
void Stop(itk::Object::Pointer device)
stops the time-acqusition
double GetElapsed()
returns the time elapsed since calling Start() for the first time in milliseconds
virtual void StopRecording()
Stops StopsRecording to the NavigationDataSet.
virtual void StartRecording()
Starts recording NavigationData into the NavigationDataSet.
virtual void ResetRecording()
Resets the Datasets and the timestamp, so a new recording can happen.
virtual int GetNumberOfRecordedSteps()
Returns the number of time steps that were recorded in the current set. Warning: This Method does NOT...
double TimeStampType
type that holds the time at which the data was recorded in milliseconds