This class records NavigationData objects. More...
#include <mitkNavigationDataRecorder.h>
Public Types | |
enum | RecordingMode { Console, NormalFile, ZipFile } |
Determines where the output is directed to. More... | |
typedef NavigationDataRecorder | Self |
typedef itk::ProcessObject | Superclass |
typedef itk::SmartPointer< Self > | Pointer |
typedef itk::SmartPointer < const Self > | ConstPointer |
Public Member Functions | |
virtual const char * | GetClassName () const |
virtual void | SetFileName (const char *_arg) |
sets the file name for the OutputMode NormalFile and ZipFile | |
virtual const char * | GetFileName () const |
Returns the file name of the recording file (in OutputMode NormalFile and ZipFile) | |
virtual bool | GetRecording () |
Returns whether the NavigationDataRecorder is recording or not. | |
virtual void | AddNavigationData (const NavigationData *nd) |
Adds the input NavigationDatas. | |
void | StartRecording () |
Starts the recording with the presetted OutputMode this method calls StartRecording(std::ostream*) | |
void | StartRecording (std::ostream *stream) |
Starts the recording with an own preinitialized stream. | |
void | StopRecording () |
Stops the recording and closes the stream. | |
virtual void | Update () |
Every call of update causes one line for each added NavigationData in the output if the recording was started. | |
void | SetRecordingMode (RecordingMode mode) |
Sets the recording mode which causes different types of output streams see enum RecordingMode. | |
Static Public Member Functions | |
static Pointer | New () |
Protected Member Functions | |
virtual void | GenerateData () |
filter execute method here it is not used | |
NavigationDataRecorder () | |
virtual | ~NavigationDataRecorder () |
Protected Attributes | |
std::string | m_FileName |
stores the file name and path | |
unsigned int | m_NumberOfInputs |
counts the numbers of added input NavigationDatas | |
std::ostream * | m_Stream |
the output stream | |
RecordingMode | m_RecordingMode |
stores the mode see enum RecordingMode | |
bool | m_Recording |
indicates whether the recording is started or not | |
unsigned int | m_NumberOfRecordedFiles |
necessary for the naming of the file if there is more than one start-stop cycle |
This class records NavigationData objects.
Documentation The output of this class is formated as a XML document.
Internal this class uses streams for recording NavigationData objects. Therefore different types of output are possible and can be set with the SetOutputMode() method. The default output is directed to the console. If you want to save into a file you have to set a file name and the path. The recording is started with the call of the method StartRecording(). Now every Update() stores the current state of the added NavigationDatas. With StopRecording() the stream is stopped. With another call of StartRecording() the output is written to a new file with incremented filename counter.
Definition at line 45 of file mitkNavigationDataRecorder.h.
typedef itk::SmartPointer<const Self> mitk::NavigationDataRecorder::ConstPointer |
Definition at line 48 of file mitkNavigationDataRecorder.h.
typedef itk::SmartPointer<Self> mitk::NavigationDataRecorder::Pointer |
Definition at line 48 of file mitkNavigationDataRecorder.h.
Definition at line 48 of file mitkNavigationDataRecorder.h.
typedef itk::ProcessObject mitk::NavigationDataRecorder::Superclass |
Definition at line 48 of file mitkNavigationDataRecorder.h.
Determines where the output is directed to.
Documentation Console: std::cout NormalFile: std::ofstream ZipFile: Not supported yet -> std::cout
Definition at line 105 of file mitkNavigationDataRecorder.h.
{ Console, NormalFile, ZipFile };
mitk::NavigationDataRecorder::NavigationDataRecorder | ( | ) | [protected] |
Definition at line 26 of file mitkNavigationDataRecorder.cpp.
References mitk::TimeStamp::GetInstance(), m_FileName, m_NumberOfInputs, m_NumberOfRecordedFiles, m_Recording, m_RecordingMode, m_Stream, NormalFile, and mitk::TimeStamp::Start().
{ m_NumberOfInputs = 0; m_RecordingMode = NormalFile; m_Recording = false; m_NumberOfRecordedFiles = 0; m_Stream = NULL; m_FileName = ""; //To get a start time mitk::TimeStamp::GetInstance()->Start(this); }
mitk::NavigationDataRecorder::~NavigationDataRecorder | ( | ) | [protected, virtual] |
Definition at line 40 of file mitkNavigationDataRecorder.cpp.
{ }
void mitk::NavigationDataRecorder::AddNavigationData | ( | const NavigationData * | nd ) | [virtual] |
Adds the input NavigationDatas.
Definition at line 50 of file mitkNavigationDataRecorder.cpp.
{ // Process object is not const-correct so the const_cast is required here this->SetNthInput(m_NumberOfInputs, const_cast< mitk::NavigationData * >( nd ) ); m_NumberOfInputs++; this->Modified(); }
void mitk::NavigationDataRecorder::GenerateData | ( | ) | [protected, virtual] |
filter execute method here it is not used
Documentation
Definition at line 45 of file mitkNavigationDataRecorder.cpp.
{ }
virtual const char* mitk::NavigationDataRecorder::GetClassName | ( | ) | const [virtual] |
virtual const char* mitk::NavigationDataRecorder::GetFileName | ( | ) | const [virtual] |
Returns the file name of the recording file (in OutputMode NormalFile and ZipFile)
virtual bool mitk::NavigationDataRecorder::GetRecording | ( | ) | [virtual] |
Returns whether the NavigationDataRecorder is recording or not.
static Pointer mitk::NavigationDataRecorder::New | ( | ) | [static] |
virtual void mitk::NavigationDataRecorder::SetFileName | ( | const char * | _arg ) | [virtual] |
sets the file name for the OutputMode NormalFile and ZipFile
Any extensions will be cut
void mitk::NavigationDataRecorder::SetRecordingMode | ( | RecordingMode | mode ) |
Sets the recording mode which causes different types of output streams see enum RecordingMode.
Documentation
Definition at line 61 of file mitkNavigationDataRecorder.cpp.
{ m_RecordingMode = mode; this->Modified(); }
void mitk::NavigationDataRecorder::StartRecording | ( | std::ostream * | stream ) |
Starts the recording with an own preinitialized stream.
Documentation
m_Stream << "<Version Ver=\"1" />" << std::endl;
Definition at line 204 of file mitkNavigationDataRecorder.cpp.
{ if (m_Recording) { std::cout << "Already recording please stop before start new recording session" << std::endl; return; } m_Stream = stream; m_Stream->precision(10); //TODO store date and GMT time if (m_Stream) { *m_Stream << "<?xml version=\"1.0\" ?>" << std::endl; // should be a generic version, meaning a member variable, which has the actual version *m_Stream << " " << "<Data ToolCount=\"" << (m_NumberOfInputs) << "\" version=\"1.0\">" << std::endl; m_Recording = true; } }
void mitk::NavigationDataRecorder::StartRecording | ( | ) |
Starts the recording with the presetted OutputMode this method calls StartRecording(std::ostream*)
Documentation
Definition at line 154 of file mitkNavigationDataRecorder.cpp.
{ if (m_Recording) { std::cout << "Already recording please stop before start new recording session" << std::endl; return; } if (m_Stream == NULL) { std::stringstream ss; std::ostream* stream; //An existing extension will be cut and replaced with .xml std::string tmpPath = itksys::SystemTools::GetFilenamePath(m_FileName); m_FileName = itksys::SystemTools::GetFilenameWithoutExtension(m_FileName); ss << tmpPath << "/" << m_FileName << "-" << m_NumberOfRecordedFiles << ".xml"; switch(m_RecordingMode) { case Console: stream = &std::cout; break; case NormalFile: //Check if there is a file name and path if (m_FileName == "") { stream = &std::cout; std::cout << "No file name or file path set the output is redirected to the console"; } else { stream = new std::ofstream(ss.str().c_str()); } break; case ZipFile: stream = &std::cout; std::cout << "Sorry no ZipFile support yet"; break; default: stream = &std::cout; break; } StartRecording(stream); } }
void mitk::NavigationDataRecorder::StopRecording | ( | ) |
Stops the recording and closes the stream.
Documentation
Definition at line 226 of file mitkNavigationDataRecorder.cpp.
{ if (!m_Recording) { std::cout << "You have to start a recording first" << std::endl; return; } if (m_Stream) { *m_Stream << "</Data>" << std::endl; } m_NumberOfRecordedFiles++; m_Stream = NULL; m_Recording = false; }
void mitk::NavigationDataRecorder::Update | ( | ) | [virtual] |
Every call of update causes one line for each added NavigationData in the output if the recording was started.
Documentation
Definition at line 67 of file mitkNavigationDataRecorder.cpp.
References mitk::NavigationData::GetCovErrorMatrix(), mitk::TimeStamp::GetElapsed(), mitk::NavigationData::GetHasOrientation(), mitk::NavigationData::GetHasPosition(), mitk::TimeStamp::GetInstance(), mitk::NavigationData::GetOrientation(), mitk::NavigationData::GetPosition(), mitk::NavigationData::IsDataValid(), matrix(), TiXmlElement::SetAttribute(), and TiXmlElement::SetDoubleAttribute().
{ if (m_Recording) { DataObjectPointerArray inputs = this->GetInputs(); //get all inputs mitk::NavigationData::TimeStampType timestamp=0.0; timestamp = mitk::TimeStamp::GetInstance()->GetElapsed(); for (unsigned int index = 0; index < inputs.size(); index++) { mitk::NavigationData* nd = dynamic_cast<mitk::NavigationData*>(inputs[index].GetPointer()); nd->Update(); // call update to propagate update to previous filters mitk::NavigationData::PositionType position; mitk::NavigationData::OrientationType orientation(0.0, 0.0, 0.0, 0.0); mitk::NavigationData::CovarianceMatrixType matrix; bool hasPosition = true; bool hasOrientation = true; bool dataValid = false; position.Fill(0.0); matrix.SetIdentity(); position = nd->GetPosition(); orientation = nd->GetOrientation(); matrix = nd->GetCovErrorMatrix(); hasPosition = nd->GetHasPosition(); hasOrientation = nd->GetHasOrientation(); dataValid = nd->IsDataValid(); //use this one if you want the timestamps of the source //timestamp = nd->GetTimeStamp(); //a timestamp is never < 0! this case happens only if you are using the timestamp of the nd object instead of getting a new one if (timestamp >= 0) { TiXmlElement* elem = new TiXmlElement("ND"); elem->SetDoubleAttribute("Time", timestamp); elem->SetDoubleAttribute("Tool", index); elem->SetDoubleAttribute("X", position[0]); elem->SetDoubleAttribute("Y", position[1]); elem->SetDoubleAttribute("Z", position[2]); elem->SetDoubleAttribute("QX", orientation[0]); elem->SetDoubleAttribute("QY", orientation[1]); elem->SetDoubleAttribute("QZ", orientation[2]); elem->SetDoubleAttribute("QR", orientation[3]); elem->SetDoubleAttribute("C00", matrix[0][0]); elem->SetDoubleAttribute("C01", matrix[0][1]); elem->SetDoubleAttribute("C02", matrix[0][2]); elem->SetDoubleAttribute("C03", matrix[0][3]); elem->SetDoubleAttribute("C04", matrix[0][4]); elem->SetDoubleAttribute("C05", matrix[0][5]); elem->SetDoubleAttribute("C10", matrix[1][0]); elem->SetDoubleAttribute("C11", matrix[1][1]); elem->SetDoubleAttribute("C12", matrix[1][2]); elem->SetDoubleAttribute("C13", matrix[1][3]); elem->SetDoubleAttribute("C14", matrix[1][4]); elem->SetDoubleAttribute("C15", matrix[1][5]); if (dataValid) elem->SetAttribute("Valid",1); else elem->SetAttribute("Valid",0); if (hasOrientation) elem->SetAttribute("hO",1); else elem->SetAttribute("hO",0); if (hasPosition) elem->SetAttribute("hP",1); else elem->SetAttribute("hP",0); *m_Stream << " " << *elem << std::endl; delete elem; } } } }
std::string mitk::NavigationDataRecorder::m_FileName [protected] |
stores the file name and path
Definition at line 130 of file mitkNavigationDataRecorder.h.
Referenced by NavigationDataRecorder().
unsigned int mitk::NavigationDataRecorder::m_NumberOfInputs [protected] |
counts the numbers of added input NavigationDatas
Definition at line 132 of file mitkNavigationDataRecorder.h.
Referenced by NavigationDataRecorder().
unsigned int mitk::NavigationDataRecorder::m_NumberOfRecordedFiles [protected] |
necessary for the naming of the file if there is more than one start-stop cycle
Definition at line 140 of file mitkNavigationDataRecorder.h.
Referenced by NavigationDataRecorder().
bool mitk::NavigationDataRecorder::m_Recording [protected] |
indicates whether the recording is started or not
Definition at line 138 of file mitkNavigationDataRecorder.h.
Referenced by NavigationDataRecorder().
stores the mode see enum RecordingMode
Definition at line 136 of file mitkNavigationDataRecorder.h.
Referenced by NavigationDataRecorder().
std::ostream* mitk::NavigationDataRecorder::m_Stream [protected] |
the output stream
Definition at line 134 of file mitkNavigationDataRecorder.h.
Referenced by NavigationDataRecorder().