17 #include <itksys/SystemTools.hxx> 20 #include "mitkIGTException.h" 21 #include "mitkIGTIOException.h" 57 const_cast< mitk::NavigationData * >( nd ) );
74 DataObjectPointerArray inputs = this->GetInputs();
83 std::ostringstream strs;
86 std::string sysTimeStr = strs.str();
96 for (
unsigned int index = 0; index < inputs.size(); index++){ *
m_Stream <<
";Valid_Tool" << index <<
100 ";QX_Tool" << index <<
101 ";QY_Tool" << index <<
102 ";QZ_Tool" << index <<
103 ";QR_Tool" << index;}
111 for (
unsigned int index = 0; index < inputs.size(); index++)
120 bool hasPosition =
true;
121 bool hasOrientation =
true;
122 bool dataValid =
false;
125 matrix.SetIdentity();
143 auto elem =
new TiXmlElement(
"NavigationData");
145 elem->SetDoubleAttribute(
"Time", timestamp);
146 elem->SetAttribute(
"SystemTime", sysTimeStr);
147 elem->SetDoubleAttribute(
"Tool", index);
148 elem->SetDoubleAttribute(
"X", position[0]);
149 elem->SetDoubleAttribute(
"Y", position[1]);
150 elem->SetDoubleAttribute(
"Z", position[2]);
152 elem->SetDoubleAttribute(
"QX", orientation[0]);
153 elem->SetDoubleAttribute(
"QY", orientation[1]);
154 elem->SetDoubleAttribute(
"QZ", orientation[2]);
155 elem->SetDoubleAttribute(
"QR", orientation[3]);
157 elem->SetDoubleAttribute(
"C00", matrix[0][0]);
158 elem->SetDoubleAttribute(
"C01", matrix[0][1]);
159 elem->SetDoubleAttribute(
"C02", matrix[0][2]);
160 elem->SetDoubleAttribute(
"C03", matrix[0][3]);
161 elem->SetDoubleAttribute(
"C04", matrix[0][4]);
162 elem->SetDoubleAttribute(
"C05", matrix[0][5]);
163 elem->SetDoubleAttribute(
"C10", matrix[1][0]);
164 elem->SetDoubleAttribute(
"C11", matrix[1][1]);
165 elem->SetDoubleAttribute(
"C12", matrix[1][2]);
166 elem->SetDoubleAttribute(
"C13", matrix[1][3]);
167 elem->SetDoubleAttribute(
"C14", matrix[1][4]);
168 elem->SetDoubleAttribute(
"C15", matrix[1][5]);
171 elem->SetAttribute(
"Valid",1);
173 elem->SetAttribute(
"Valid",0);
176 elem->SetAttribute(
"hO",1);
178 elem->SetAttribute(
"hO",0);
181 elem->SetAttribute(
"hP",1);
183 elem->SetAttribute(
"hP",0);
190 elem->SetAttribute(it->second.first, it->second.second);
193 *
m_Stream <<
" " << *elem << std::endl;
199 *
m_Stream <<
";" << dataValid <<
";" << position[0] <<
";" << position[1] <<
";" << position[2] <<
";" << orientation[0] <<
";" << orientation[1] <<
";" << orientation[2] <<
";" << orientation[3];
213 const std::string& attributeName
214 ,
const std::string& attributeValue )
222 it->second.first = attributeName;
223 it->second.second = attributeValue;
243 std::stringstream ss;
244 std::ostream* stream;
247 std::string tmpPath = itksys::SystemTools::GetFilenamePath(
m_FileName);
249 std::string extension =
".xml";
258 while( itksys::SystemTools::FileExists( ss.str().c_str() ) )
261 ss << tmpPath <<
"/" <<
m_FileName <<
"-" << index << extension;
275 std::string message =
"No file name or file path set.";
281 stream =
new std::ofstream(ss.str().c_str());
287 MITK_WARN <<
"Sorry no ZipFile support yet";
303 MITK_WARN <<
"Already recording please stop before start new recording session";
312 MITK_WARN <<
"Already recording please stop before start new recording session";
325 *
m_Stream <<
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" << std::endl;
344 std::cout <<
"You have to start a recording first" << std::endl;
350 *
m_Stream <<
"</Data>" << std::endl;
void SetAdditionalAttribute(const NavigationData *nd, const std::string &attributeName, const std::string &attributeValue)
NavigationDataRecorderDeprecated()
void SetRecordingMode(RecordingMode mode)
Sets the recording mode which causes different types of output streams see enum RecordingMode.
unsigned int m_NumberOfInputs
counts the numbers of added input NavigationDatas
void RemoveAdditionalAttribute(const NavigationData *nd)
itk::Matrix< mitk::ScalarType, 6, 6 > CovarianceMatrixType
type that holds the error characterization of the position and orientation measurements ...
std::map< const mitk::NavigationData *, std::pair< std::string, std::string > > m_AdditionalAttributes
void StopRecording()
Stops the recording and closes the stream.
double GetElapsed()
returns the time elapsed since calling Start() for the first time in milliseconds ...
An object of this class represents an exception of the MITK-IGT module.
int m_RecordCounter
counts the number of frames which are recorded since StartRecording
void GenerateData() override
filter execute method here it is not used
mitk::Quaternion OrientationType
Type that holds the orientation part of the tracking data.
virtual void AddNavigationData(const NavigationData *nd)
Adds the input NavigationDatas.
virtual PositionType GetPosition() const
returns position of the NavigationData object
void Update() override
Every call of update causes one line for each added NavigationData in the output if the recording was...
std::string m_FileName
stores the file name and path
std::ostream * m_Stream
the output stream
double TimeStampType
type that holds the time at which the data was recorded in milliseconds
void StartRecording()
Starts the recording with the presetted OutputMode. This method calls StartRecording(std::ostream*). Does nothing if the recorder is already recording and the method StartRecording is called again.
bool m_StreamMustBeDeleted
mitk::RealTimeClock::Pointer m_SystemTimeClock
system time clock for system time tag in output xml file
RecordingMode
Determines where the output is directed to.
bool m_Recording
indicates whether the recording is started or not
static IGTTimeStamp * GetInstance()
returns a pointer to the current instance of mitkTimeStamp
RecordingMode m_RecordingMode
stores the mode see enum RecordingMode
void Start(itk::Object::Pointer device)
starts the time-acquisition
unsigned int m_NumberOfRecordedFiles
necessary for the naming of the file if there is more than one start-stop cycle
virtual bool GetHasPosition() const
gets the HasPosition flag of the NavigationData object
#define mitkThrowException(classname)
virtual bool GetHasOrientation() const
gets the HasOrientation flag of the NavigationData object
~NavigationDataRecorderDeprecated() override
bool m_DoNotOverwriteFiles
do not overwrite any files if true
OutputFormatEnum m_OutputFormat
stores the output format; see enum OutputFormat
virtual CovarianceMatrixType GetCovErrorMatrix() const
gets the 6x6 Error Covariance Matrix of the NavigationData object
virtual OrientationType GetOrientation() const
returns the orientation of the NavigationData object
static Pointer New(void)
instanciates a new, operating-system dependant, instance of mitk::RealTimeClock.
virtual bool IsDataValid() const
returns true if the object contains valid data
int m_RecordCountLimit
limits the number of frames, recording will be stopped if the limit is reached. -1 disables the limit...