diff --git a/Modules/IGT/IO/mitkNavigationDataSetWriterCSV.cpp b/Modules/IGT/IO/mitkNavigationDataSetWriterCSV.cpp new file mode 100644 index 0000000000..136f9b4f9d --- /dev/null +++ b/Modules/IGT/IO/mitkNavigationDataSetWriterCSV.cpp @@ -0,0 +1,17 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#include "mitkNavigationDataSetWriterCSV.h" \ No newline at end of file diff --git a/Modules/IGT/IO/mitkNavigationDataSetWriterCSV.h b/Modules/IGT/IO/mitkNavigationDataSetWriterCSV.h new file mode 100644 index 0000000000..8836083c41 --- /dev/null +++ b/Modules/IGT/IO/mitkNavigationDataSetWriterCSV.h @@ -0,0 +1,28 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + + +#ifndef MITKNavigationDataSetWriterCSV_H_HEADER_INCLUDED_ +#define MITKNavigationDataSetWriterCSV_H_HEADER_INCLUDED_ + +namespace mitk { + class NavigationDataSetWriterCSV + { + + }; +} + +#endif // MITKNavigationDataSetWriterCSV_H_HEADER_INCLUDED_ diff --git a/Modules/IGT/IO/mitkNavigationDataSetWriterXML.cpp b/Modules/IGT/IO/mitkNavigationDataSetWriterXML.cpp new file mode 100644 index 0000000000..d9fc4e7704 --- /dev/null +++ b/Modules/IGT/IO/mitkNavigationDataSetWriterXML.cpp @@ -0,0 +1,129 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +// MITK +#include "mitkNavigationDataSetWriterXML.h" + +// Third Party +#include +#include + +void mitk::NavigationDataSetWriterXML::Write (std::string path, mitk::NavigationDataSet::Pointer data) +{ + std::stringstream ss; + std::ostream* stream; + + //An existing extension will be cut and replaced with .xml + std::string tmpPath = itksys::SystemTools::GetFilenamePath(path); + path = itksys::SystemTools::GetFilenameWithoutExtension(path); + std::string extension = ".xml"; + stream = new std::ofstream(ss.str().c_str()); + + // Pass to Stream Handler + Write(stream, data); + + // Cleanup + + delete stream; +} + +void mitk::NavigationDataSetWriterXML::Write (std::ostream* stream, mitk::NavigationDataSet::Pointer data) +{ + StreamHeader(stream, data); + StreamData(stream, data); + StreamFooter(stream); + + // Cleanup + + stream->flush(); +} + +void mitk::NavigationDataSetWriterXML::StreamHeader (std::ostream* stream, mitk::NavigationDataSet::Pointer data) +{ + stream->precision(10); + + //TODO store date and GMT time + //checking if the stream is good + if (stream->good()) + { + *stream << "" << std::endl; + /**m_Stream << "" << std::endl;*/ + // should be a generic version, meaning a member variable, which has the actual version + *stream << " " << "GetNumberOfTools() << "\" version=\"1.0\">" << std::endl; + } +} + +void mitk::NavigationDataSetWriterXML::StreamData (std::ostream* stream, mitk::NavigationDataSet::Pointer data) +{ + // For each time step in the Dataset + for (mitk::NavigationDataSet::NavigationDataSetIterator it = data->Begin(); it != data->End(); it++) + { + for (int toolIndex = 0; toolIndex < it->size(); toolIndex++) + { + mitk::NavigationData::Pointer nd = it->at(toolIndex); + TiXmlElement* elem = new TiXmlElement("NavigationData"); + + elem->SetDoubleAttribute("Time", nd->GetIGTTimeStamp()); + // elem->SetAttribute("SystemTime", sysTimeStr); // tag for system time + elem->SetDoubleAttribute("Tool", toolIndex); + elem->SetDoubleAttribute("X", nd->GetPosition()[0]); + elem->SetDoubleAttribute("Y", nd->GetPosition()[1]); + elem->SetDoubleAttribute("Z", nd->GetPosition()[2]); + + elem->SetDoubleAttribute("QX", nd->GetOrientation()[0]); + elem->SetDoubleAttribute("QY", nd->GetOrientation()[1]); + elem->SetDoubleAttribute("QZ", nd->GetOrientation()[2]); + elem->SetDoubleAttribute("QR", nd->GetOrientation()[3]); + + elem->SetDoubleAttribute("C00", nd->GetCovErrorMatrix()[0][0]); + elem->SetDoubleAttribute("C01", nd->GetCovErrorMatrix()[0][1]); + elem->SetDoubleAttribute("C02", nd->GetCovErrorMatrix()[0][2]); + elem->SetDoubleAttribute("C03", nd->GetCovErrorMatrix()[0][3]); + elem->SetDoubleAttribute("C04", nd->GetCovErrorMatrix()[0][4]); + elem->SetDoubleAttribute("C05", nd->GetCovErrorMatrix()[0][5]); + elem->SetDoubleAttribute("C10", nd->GetCovErrorMatrix()[1][0]); + elem->SetDoubleAttribute("C11", nd->GetCovErrorMatrix()[1][1]); + elem->SetDoubleAttribute("C12", nd->GetCovErrorMatrix()[1][2]); + elem->SetDoubleAttribute("C13", nd->GetCovErrorMatrix()[1][3]); + elem->SetDoubleAttribute("C14", nd->GetCovErrorMatrix()[1][4]); + elem->SetDoubleAttribute("C15", nd->GetCovErrorMatrix()[1][5]); + + if (nd->IsDataValid()) + elem->SetAttribute("Valid",1); + else + elem->SetAttribute("Valid",0); + + if (nd->GetHasOrientation()) + elem->SetAttribute("hO",1); + else + elem->SetAttribute("hO",0); + + if (nd->GetHasPosition()) + elem->SetAttribute("hP",1); + else + elem->SetAttribute("hP",0); + + *stream << " " << *elem << std::endl; + + delete elem; + } + } +} + +void mitk::NavigationDataSetWriterXML::StreamFooter (std::ostream* stream) +{ + *stream << "" << std::endl; +} \ No newline at end of file diff --git a/Modules/IGT/IO/mitkNavigationDataSetWriterXML.h b/Modules/IGT/IO/mitkNavigationDataSetWriterXML.h new file mode 100644 index 0000000000..c436f1905a --- /dev/null +++ b/Modules/IGT/IO/mitkNavigationDataSetWriterXML.h @@ -0,0 +1,38 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#ifndef MITKNavigationDataSetWriterXML_H_HEADER_INCLUDED_ +#define MITKNavigationDataSetWriterXML_H_HEADER_INCLUDED_ + +#include + +namespace mitk { + class NavigationDataSetWriterXML + { + public: + + virtual void Write (std::string path, mitk::NavigationDataSet::Pointer ); + virtual void Write (std::ostream* stream, mitk::NavigationDataSet::Pointer); + + protected: + + virtual void StreamHeader (std::ostream* stream, mitk::NavigationDataSet::Pointer data); + virtual void StreamData (std::ostream* stream, mitk::NavigationDataSet::Pointer data); + virtual void StreamFooter (std::ostream* stream); + }; +} + +#endif // MITKNavigationDataSetWriterXML_H_HEADER_INCLUDED_ diff --git a/Modules/IGT/files.cmake b/Modules/IGT/files.cmake index 6e637f533a..76e01c48ab 100644 --- a/Modules/IGT/files.cmake +++ b/Modules/IGT/files.cmake @@ -1,69 +1,71 @@ set(CPP_FILES Algorithms/mitkNavigationDataDisplacementFilter.cpp Algorithms/mitkNavigationDataEvaluationFilter.cpp Algorithms/mitkNavigationDataLandmarkTransformFilter.cpp Algorithms/mitkNavigationDataReferenceTransformFilter.cpp Algorithms/mitkNavigationDataToMessageFilter.cpp Algorithms/mitkNavigationDataToNavigationDataFilter.cpp Algorithms/mitkNavigationDataToPointSetFilter.cpp Algorithms/mitkNavigationDataTransformFilter.cpp Common/mitkIGTTimeStamp.cpp Common/mitkRealTimeClock.cpp Common/mitkSerialCommunication.cpp DataManagement/mitkNavigationData.cpp DataManagement/mitkNavigationDataSet.cpp DataManagement/mitkNavigationDataSource.cpp DataManagement/mitkNavigationTool.cpp DataManagement/mitkNavigationToolStorage.cpp DataManagement/mitkTrackingDeviceSourceConfigurator.cpp DataManagement/mitkTrackingDeviceSource.cpp ExceptionHandling/mitkIGTException.cpp ExceptionHandling/mitkIGTHardwareException.cpp ExceptionHandling/mitkIGTIOException.cpp IO/mitkNavigationDataPlayer.cpp IO/mitkNavigationDataPlayerBase.cpp IO/mitkNavigationDataRecorder.cpp IO/mitkNavigationDataSequentialPlayer.cpp IO/mitkNavigationToolReader.cpp IO/mitkNavigationToolStorageSerializer.cpp IO/mitkNavigationToolStorageDeserializer.cpp IO/mitkNavigationToolWriter.cpp IO/mitkNavigationDataReaderInterface.cpp IO/mitkNavigationDataReaderXML.cpp IO/mitkNavigationDataReaderCSV.cpp + IO/mitkNavigationDataSetWriterXML.cpp + IO/mitkNavigationDataSetWriterCSV.cpp Rendering/mitkCameraVisualization.cpp Rendering/mitkNavigationDataObjectVisualizationFilter.cpp TrackingDevices/mitkClaronTool.cpp TrackingDevices/mitkClaronTrackingDevice.cpp TrackingDevices/mitkInternalTrackingTool.cpp TrackingDevices/mitkNDIPassiveTool.cpp TrackingDevices/mitkNDIProtocol.cpp TrackingDevices/mitkNDITrackingDevice.cpp TrackingDevices/mitkTrackingDevice.cpp TrackingDevices/mitkTrackingTool.cpp TrackingDevices/mitkTrackingVolumeGenerator.cpp TrackingDevices/mitkVirtualTrackingDevice.cpp TrackingDevices/mitkVirtualTrackingTool.cpp ) if(MITK_USE_MICRON_TRACKER) set(CPP_FILES ${CPP_FILES} TrackingDevices/mitkClaronInterface.cpp) else() set(CPP_FILES ${CPP_FILES} TrackingDevices/mitkClaronInterfaceStub.cpp) endif(MITK_USE_MICRON_TRACKER) if(MITK_USE_MICROBIRD_TRACKER) set(CPP_FILES ${CPP_FILES} TrackingDevices/mitkMicroBirdTrackingDevice.cpp) endif(MITK_USE_MICROBIRD_TRACKER) if(WIN32) set(CPP_FILES ${CPP_FILES} Common/mitkWindowsRealTimeClock.cpp) else() set(CPP_FILES ${CPP_FILES} Common/mitkLinuxRealTimeClock.cpp) endif(WIN32)