1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
|
/*=========================================================================
Program: Image Guided Surgery Software Toolkit
Module: $RCSfile: igstkCircularSimulatedTracker.cxx,v $
Language: C++
Date: $Date: 2011-01-18 21:40:16 $
Version: $Revision: 1.5 $
Copyright (c) ISC Insight Software Consortium. All rights reserved.
See IGSTKCopyright.txt or http://www.igstk.org/copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#if defined(_MSC_VER)
// Warning about: identifier was truncated to '255' characters in
// the debug information (MVC6.0 Debug)
#pragma warning( disable : 4786 )
#endif
#include "igstkCircularSimulatedTracker.h"
namespace igstk
{
CircularSimulatedTracker::CircularSimulatedTracker():m_StateMachine(this)
{
this->m_Radius = 1.0;
this->m_Angle = 0.0;
this->m_AngularSpeed = 0.01; // degrees per second
this->m_TimeOfLastUpdate = RealTimeClock::GetTimeStamp();
double validityTime = 1000.0;
double trackerFrequency = 1000.0 / (validityTime - 10);
this->RequestSetFrequency(trackerFrequency );
}
CircularSimulatedTracker::~CircularSimulatedTracker()
{
}
CircularSimulatedTracker::ResultType
CircularSimulatedTracker::InternalOpen( void )
{
return SUCCESS;
}
CircularSimulatedTracker::ResultType
CircularSimulatedTracker::InternalStartTracking( void )
{
return SUCCESS;
}
CircularSimulatedTracker::ResultType
CircularSimulatedTracker::InternalReset( void )
{
return SUCCESS;
}
CircularSimulatedTracker::ResultType
CircularSimulatedTracker::InternalStopTracking( void )
{
return SUCCESS;
}
CircularSimulatedTracker::ResultType
CircularSimulatedTracker::InternalClose( void )
{
return SUCCESS;
}
CircularSimulatedTracker::ResultType
CircularSimulatedTracker::VerifyTrackerToolInformation(
TrackerToolType * itkNotUsed(trackerTool) )
{
return SUCCESS;
}
CircularSimulatedTracker::ResultType
CircularSimulatedTracker::InternalUpdateStatus( void )
{
igstkLogMacro( DEBUG,
"CircularSimulatedTracker::InternalUpdateStatus called ...\n");
typedef TrackerToolsContainerType::const_iterator ConstIteratorType;
TrackerToolsContainerType trackerToolContainer =
this->GetTrackerToolContainer();
ConstIteratorType inputItr = trackerToolContainer.begin();
ConstIteratorType inputEnd = trackerToolContainer.end();
typedef igstk::Transform TransformType;
TransformType transform;
transform.SetToIdentity( this->GetValidityTime() );
typedef TransformType::VectorType PositionType;
PositionType position;
position[0] = cos( this->m_Angle ) * this->m_Radius;
position[1] = sin( this->m_Angle ) * this->m_Radius;
position[2] = 0;
typedef TransformType::ErrorType ErrorType;
ErrorType errorValue = 0.5; // +/- half millimeter Uncertainty
transform.SetTranslation( position, errorValue, this->GetValidityTime() );
// set the raw transform in all the tracker tools
while( inputItr != inputEnd )
{
this->SetTrackerToolRawTransform(
trackerToolContainer[inputItr->first], transform );
this->SetTrackerToolTransformUpdate(
trackerToolContainer[inputItr->first], true );
++inputItr;
}
const double MillisecondsToSeconds = 1.0 / 1000.0;
const double DegreesToRadians = ( atan(1.0) / 45.0 );
const RealTimeClock::TimeStampType timeNow = RealTimeClock::GetTimeStamp();
const RealTimeClock::TimeStampType timeLapseInSeconds =
MillisecondsToSeconds * ( timeNow - this->m_TimeOfLastUpdate );
this->m_Angle +=
DegreesToRadians * this->m_AngularSpeed * timeLapseInSeconds;
this->m_TimeOfLastUpdate = timeNow;
return SUCCESS;
}
SimulatedTracker::ResultType
CircularSimulatedTracker::InternalThreadedUpdateStatus( void )
{
return FAILURE;
}
CircularSimulatedTracker::ResultType
CircularSimulatedTracker
::RemoveTrackerToolFromInternalDataContainers
( const TrackerToolType * itkNotUsed(trackerTool) )
{
return FAILURE;
}
/** Print Self function */
void CircularSimulatedTracker::PrintSelf(
std::ostream& os, itk::Indent indent ) const
{
Superclass::PrintSelf(os, indent);
os << indent << "Radius: " << this->m_Radius << std::endl;
os << indent << "Angle: " << this->m_Angle << std::endl;
os << indent << "Angular Speed: " << this->m_AngularSpeed << std::endl;
os << indent << "Time of Last Update : ";
os << this->m_TimeOfLastUpdate << std::endl;
}
}
|