1
/*=========================================================================
3
Program: Image Guided Surgery Software Toolkit
4
Module: $RCSfile: igstkVideoImagerTest.cxx,v $
6
Date: $Date: 2009-06-19 15:53:29 $
7
Version: $Revision: 1.2 $
9
Copyright (c) ISC Insight Software Consortium. All rights reserved.
10
See IGSTKCopyright.txt or http://www.igstk.org/copyright.htm for details.
12
This software is distributed WITHOUT ANY WARRANTY; without even
13
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14
PURPOSE. See the above copyright notices for more information.
16
=========================================================================*/
19
// Warning about: identifier was truncated to '255' characters
20
// in the debug information (MVC6.0 Debug)
21
#pragma warning( disable : 4786 )
25
#include "igstkLandmark3DRegistration.h"
26
#include "igstkLogger.h"
27
#include "itkStdStreamLogOutput.h"
28
#include "itkObject.h"
29
#include "itkCommand.h"
31
#include "igstkEvents.h"
32
#include "igstkVideoImager.h"
33
#include "igstkVideoImagerTool.h"
38
namespace VideoImagerTest
42
class VideoImagerTool;
43
class DummyVideoImager;
44
class DummyVideoImagerTool;
46
class DummyVideoImagerTool : public igstk::VideoImagerTool
50
igstkFriendClassMacro( DummyVideoImager );
52
/** Macro with standard traits declarations. */
53
igstkStandardClassTraitsMacro( DummyVideoImagerTool, igstk::VideoImagerTool )
55
void RequestAttachToVideoImager(DummyVideoImager* imager );
57
DummyVideoImagerTool::Pointer DummyVideoImagerToolPointer;
60
DummyVideoImagerTool(): m_StateMachine(this) {};
61
~DummyVideoImagerTool()
64
/** Check if the tracker tool is configured or not. This method should
65
* be implemented in the derived classes*/
66
virtual bool CheckIfVideoImagerToolIsConfigured( ) const { return true; }
70
class DummyVideoImager : public igstk::VideoImager
74
igstkFriendClassMacro( DummyVideoImagerTool );
76
double GetImagerValidityTime()
78
return this->GetValidityTime();
81
/** Typedef for internal boolean return type. */
82
typedef VideoImager::ResultType ResultType;
84
/** Open communication with the imaging device. */
85
virtual ResultType InternalOpen( void ) { return SUCCESS; };
87
/** Close communication with the imaging device. */
88
virtual ResultType InternalClose( void ){ return SUCCESS; };
90
/** Put the imaging device into imaging mode. */
91
virtual ResultType InternalStartImaging( void ){ return SUCCESS; };
93
/** Take the imaging device out of imaging mode. */
94
virtual ResultType InternalStopImaging( void ){ return SUCCESS; };
96
/** Update the status and the transforms for all VideoImagerTools. */
97
virtual ResultType InternalUpdateStatus( void ){ return SUCCESS; };
99
/** Update the status and the frames.
100
This function is called by a separate thread. */
101
virtual ResultType InternalThreadedUpdateStatus( void ){ return SUCCESS; };
103
/** Reset the imaging device to put it back to its original state. */
104
virtual ResultType InternalReset( void ){ return SUCCESS; };
106
/** Verify imager tool information */
107
virtual ResultType VerifyVideoImagerToolInformation(
108
const VideoImagerToolType * ){ return SUCCESS; };
110
/** The "ValidateSpecifiedFrequency" method checks if the specified
111
* frequency is valid for the imaging device that is being used. */
112
virtual ResultType ValidateSpecifiedFrequency( double frequencyInHz ){ return SUCCESS; };
114
/** Print object information */
115
virtual void PrintSelf( std::ostream& os, itk::Indent indent ) const{ return; };
117
/** Remove imager tool entry from internal containers */
118
virtual ResultType RemoveVideoImagerToolFromInternalDataContainers( const
119
VideoImagerToolType * imagerTool ){ return SUCCESS; };
121
/** Add imager tool entry to internal containers */
122
virtual ResultType AddVideoImagerToolToInternalDataContainers( const
123
VideoImagerToolType * imagerTool ){ return SUCCESS; };
125
DummyVideoImager::Pointer DummyVideoImagerPointer;
126
//typedef ::itk::SmartPointer< Self > Pointer;
128
/** Macro with standard traits declarations. */
129
igstkStandardClassTraitsMacro( DummyVideoImager, igstk::VideoImager )
132
DummyVideoImager( void ): m_StateMachine(this) {};
133
~DummyVideoImager( void ) {};
137
/** The "RequestAttachToVideoImager" method attaches
138
* the imager tool to a imager. */
139
void DummyVideoImagerTool::RequestAttachToVideoImager(DummyVideoImager* imager )
141
this->VideoImagerTool::RequestAttachToVideoImager( imager );
147
int igstkVideoImagerTest( int argv, char * argc[] )
149
typedef igstk::VideoImagerTest::DummyVideoImager VideoImagerType;
150
typedef igstk::VideoImagerTest::DummyVideoImagerTool VideoImagerToolType;
152
VideoImagerType::Pointer videoImager= VideoImagerType::New();
154
videoImager->RequestOpen();
156
double defaultValidityTime = videoImager->GetImagerValidityTime();
157
std::cout << "Default validity time: " << defaultValidityTime << std::endl;
159
double videoImagerFrequency = 1;
160
double validityTimeShouldBe = (1000.0/videoImagerFrequency) + 10;
162
videoImager->RequestSetFrequency( videoImagerFrequency );
164
double validityTimeReturned = videoImager->GetImagerValidityTime();
166
if( fabs( validityTimeShouldBe - validityTimeReturned ) > 1e-5 )
168
std::cerr << "Error in RequestSetFrequency()/GetImagerValidityTime() "<<std::endl;
172
videoImager->RequestSetFrequency( 30 );
174
VideoImagerToolType::Pointer videoImagerTool = VideoImagerToolType::New();
176
videoImagerTool->RequestConfigure();
177
videoImagerTool->RequestAttachToVideoImager( videoImager );
179
videoImager->RequestStartImaging();
180
videoImager->RequestStopImaging();
181
videoImager->RequestReset();
182
videoImager->VerifyVideoImagerToolInformation(videoImagerTool);
183
videoImager->ValidateSpecifiedFrequency(50);
184
videoImager->Print(std::cout);
185
videoImager->AddVideoImagerToolToInternalDataContainers(videoImagerTool);
186
videoImager->RemoveVideoImagerToolFromInternalDataContainers(videoImagerTool);
187
videoImager->RequestClose();