diff --git a/Modules/IGT/files.cmake b/Modules/IGT/files.cmake index aef21bf3f1..1d88064ded 100644 --- a/Modules/IGT/files.cmake +++ b/Modules/IGT/files.cmake @@ -1,92 +1,88 @@ set(CPP_FILES TestingHelper/mitkNavigationToolStorageTestHelper.cpp Algorithms/mitkNavigationDataDelayFilter.cpp Algorithms/mitkNavigationDataDisplacementFilter.cpp Algorithms/mitkNavigationDataEvaluationFilter.cpp Algorithms/mitkNavigationDataLandmarkTransformFilter.cpp Algorithms/mitkNavigationDataReferenceTransformFilter.cpp Algorithms/mitkNavigationDataSmoothingFilter.cpp Algorithms/mitkNavigationDataToMessageFilter.cpp Algorithms/mitkNavigationDataToNavigationDataFilter.cpp Algorithms/mitkNavigationDataToPointSetFilter.cpp Algorithms/mitkNavigationDataTransformFilter.cpp Algorithms/mitkIGTLMessageToNavigationDataFilter.cpp Algorithms/mitkNavigationDataToIGTLMessageFilter.cpp Common/mitkIGTTimeStamp.cpp Common/mitkSerialCommunication.cpp Common/mitkTrackingTypes.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/mitkNavigationDataRecorderDeprecated.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 TrackingDevices/mitkOptitrackErrorMessages.cpp TrackingDevices/mitkOptitrackTrackingDevice.cpp TrackingDevices/mitkOptitrackTrackingTool.cpp ) set(RESOURCE_FILES ClaronMicron.stl IntuitiveDaVinci.stl NDIAurora.stl NDIAurora_Dome.stl NDIAuroraCompactFG_Dome.stl NDIAuroraPlanarFG_Dome.stl NDIAuroraTabletopFG_Dome.stl NDIAuroraTabletopFG_Prototype_Dome.stl NDIPolarisOldModel.stl NDIPolarisSpectra.stl NDIPolarisSpectraExtendedPyramid.stl NDIPolarisVicra.stl ) 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) diff --git a/Modules/IGTBase/CMakeLists.txt b/Modules/IGTBase/CMakeLists.txt index f2d0202473..1b7d3f1881 100644 --- a/Modules/IGTBase/CMakeLists.txt +++ b/Modules/IGTBase/CMakeLists.txt @@ -1,4 +1,5 @@ -MITK_CREATE_MODULE( - DEPENDS MitkCore - WARNINGS_AS_ERRORS -) +MITK_CREATE_MODULE(DEPENDS MitkCore + WARNINGS_AS_ERRORS + ) + +add_subdirectory(autoload) diff --git a/Modules/IGTBase/autoload/CMakeLists.txt b/Modules/IGTBase/autoload/CMakeLists.txt new file mode 100644 index 0000000000..66a5ad38ee --- /dev/null +++ b/Modules/IGTBase/autoload/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(IO) \ No newline at end of file diff --git a/Modules/IGTBase/autoload/IO/CMakeLists.txt b/Modules/IGTBase/autoload/IO/CMakeLists.txt new file mode 100644 index 0000000000..8b4886b3d7 --- /dev/null +++ b/Modules/IGTBase/autoload/IO/CMakeLists.txt @@ -0,0 +1,4 @@ +MITK_CREATE_MODULE(DEPENDS MitkIGTBase + WARNINGS_AS_ERRORS + AUTOLOAD_WITH MitkCore + ) \ No newline at end of file diff --git a/Modules/IGTBase/autoload/IO/files.cmake b/Modules/IGTBase/autoload/IO/files.cmake new file mode 100644 index 0000000000..467c276415 --- /dev/null +++ b/Modules/IGTBase/autoload/IO/files.cmake @@ -0,0 +1,5 @@ +set(CPP_FILES + mitkIGTBaseActivator.cpp + mitkNavigationDataSetWriterXML.cpp + mitkNavigationDataSetWriterCSV.cpp +) \ No newline at end of file diff --git a/Modules/IGTBase/mitkRealTimeClock.cpp b/Modules/IGTBase/autoload/IO/mitkIGTBaseActivator.cpp similarity index 53% copy from Modules/IGTBase/mitkRealTimeClock.cpp copy to Modules/IGTBase/autoload/IO/mitkIGTBaseActivator.cpp index 8e3a83d24e..62bc4ec788 100644 --- a/Modules/IGTBase/mitkRealTimeClock.cpp +++ b/Modules/IGTBase/autoload/IO/mitkIGTBaseActivator.cpp @@ -1,38 +1,37 @@ /*=================================================================== 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 "mitkRealTimeClock.h" +#include "mitkIGTBaseActivator.h" +#include "mitkNavigationDataSetWriterXML.h" +#include "mitkNavigationDataSetWriterCSV.h" -// check if MITK runs on a Windows-System -#ifdef _WIN32 - #include "mitkWindowsRealTimeClock.h" -#else // should be Linux or Mac OSX - #include "mitkLinuxRealTimeClock.h" -#endif -mitk::RealTimeClock::Pointer mitk::RealTimeClock::New() +namespace mitk { + +void IOExtActivator::Load(us::ModuleContext*) { - mitk::RealTimeClock::Pointer smartPtr; + m_NavigationDataSetWriterXML.reset(new NavigationDataSetWriterXML()); + m_NavigationDataSetWriterCSV.reset(new NavigationDataSetWriterCSV()); +} -#ifdef _WIN32 - smartPtr = mitk::WindowsRealTimeClock::New(); -#else - smartPtr = mitk::LinuxRealTimeClock::New(); -#endif +void IOExtActivator::Unload(us::ModuleContext*) +{ +} - return smartPtr; } + +US_EXPORT_MODULE_ACTIVATOR(mitk::IOExtActivator) diff --git a/Modules/IGTBase/mitkRealTimeClock.cpp b/Modules/IGTBase/autoload/IO/mitkIGTBaseActivator.h similarity index 50% copy from Modules/IGTBase/mitkRealTimeClock.cpp copy to Modules/IGTBase/autoload/IO/mitkIGTBaseActivator.h index 8e3a83d24e..9a34b3b751 100644 --- a/Modules/IGTBase/mitkRealTimeClock.cpp +++ b/Modules/IGTBase/autoload/IO/mitkIGTBaseActivator.h @@ -1,38 +1,45 @@ /*=================================================================== 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 "mitkRealTimeClock.h" +#ifndef MITKIGTBASEACTIVATOR_H +#define MITKIGTBASEACTIVATOR_H +#include -// check if MITK runs on a Windows-System -#ifdef _WIN32 - #include "mitkWindowsRealTimeClock.h" -#else // should be Linux or Mac OSX - #include "mitkLinuxRealTimeClock.h" -#endif +#include -mitk::RealTimeClock::Pointer mitk::RealTimeClock::New() +namespace mitk { + +struct IFileReader; +struct IFileWriter; + +class IOExtActivator : public us::ModuleActivator { - mitk::RealTimeClock::Pointer smartPtr; +public: + + void Load(us::ModuleContext*context) override; + void Unload(us::ModuleContext* context) override; -#ifdef _WIN32 - smartPtr = mitk::WindowsRealTimeClock::New(); -#else - smartPtr = mitk::LinuxRealTimeClock::New(); -#endif +private: + + std::unique_ptr m_NavigationDataSetWriterXML; + std::unique_ptr m_NavigationDataSetWriterCSV; + +}; - return smartPtr; } + +#endif // MITKIGTBASEACTIVATOR_H diff --git a/Modules/IGT/IO/mitkNavigationDataSetWriterCSV.cpp b/Modules/IGTBase/autoload/IO/mitkNavigationDataSetWriterCSV.cpp similarity index 86% rename from Modules/IGT/IO/mitkNavigationDataSetWriterCSV.cpp rename to Modules/IGTBase/autoload/IO/mitkNavigationDataSetWriterCSV.cpp index c8f3f1ae95..5be4706fe9 100644 --- a/Modules/IGT/IO/mitkNavigationDataSetWriterCSV.cpp +++ b/Modules/IGTBase/autoload/IO/mitkNavigationDataSetWriterCSV.cpp @@ -1,85 +1,83 @@ /*=================================================================== 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" #include -void mitk::NavigationDataSetWriterCSV::Write (std::string path, mitk::NavigationDataSet::Pointer data) -{ - MITK_INFO << "Writing navigation data set to file: " << path; - std::ofstream stream; - stream.open (path.c_str(), std::ios_base::trunc); - // Pass to Stream Handler - Write(&stream, data); - stream.close(); +mitk::NavigationDataSetWriterCSV* mitk::NavigationDataSetWriterCSV::Clone() const +{ + return new NavigationDataSetWriterCSV(*this); } -void mitk::NavigationDataSetWriterCSV::Write (std::ostream* stream, mitk::NavigationDataSet::Pointer data) +void mitk::NavigationDataSetWriterCSV::Write() { - //save old locale + std::ostream* out = GetOutputStream(); + mitk::NavigationDataSet::ConstPointer data = dynamic_cast (this->GetInput()); + + //save old locale char * oldLocale; oldLocale = setlocale( LC_ALL, nullptr ); //define own locale std::locale C("C"); setlocale( LC_ALL, "C" ); //write header unsigned int numberOfTools = data->GetNumberOfTools(); for (unsigned int index = 0; index < numberOfTools; index++){ *stream << "TimeStamp_Tool" << index << ";Valid_Tool" << index << ";X_Tool" << index << ";Y_Tool" << index << ";Z_Tool" << index << ";QX_Tool" << index << ";QY_Tool" << index << ";QZ_Tool" << index << ";QR_Tool" << index << ";";} *stream << "\n"; stream->precision(15); // rounding precision because we don't want to loose data. //write data MITK_INFO << "Number of timesteps: " << data->Size(); for (unsigned int i=0; iSize(); i++) { std::vector< mitk::NavigationData::Pointer > NavigationDatasOfCurrentStep = data->GetTimeStep(i); for (unsigned int toolIndex = 0; toolIndex < numberOfTools; toolIndex++) { mitk::NavigationData::Pointer nd = NavigationDatasOfCurrentStep.at(toolIndex); *stream << nd->GetTimeStamp() << ";" << nd->IsDataValid() << ";" << nd->GetPosition()[0] << ";" << nd->GetPosition()[1] << ";" << nd->GetPosition()[2] << ";" << nd->GetOrientation()[0] << ";" << nd->GetOrientation()[1] << ";" << nd->GetOrientation()[2] << ";" << nd->GetOrientation()[3] << ";"; } *stream << "\n"; } //switch back to old locale setlocale( LC_ALL, oldLocale ); } mitk::NavigationDataSetWriterCSV::NavigationDataSetWriterCSV() {} mitk::NavigationDataSetWriterCSV::~NavigationDataSetWriterCSV() {} diff --git a/Modules/IGT/IO/mitkNavigationDataSetWriterCSV.h b/Modules/IGTBase/autoload/IO/mitkNavigationDataSetWriterCSV.h similarity index 71% rename from Modules/IGT/IO/mitkNavigationDataSetWriterCSV.h rename to Modules/IGTBase/autoload/IO/mitkNavigationDataSetWriterCSV.h index bf51ddd5f9..c3c4092c87 100644 --- a/Modules/IGT/IO/mitkNavigationDataSetWriterCSV.h +++ b/Modules/IGTBase/autoload/IO/mitkNavigationDataSetWriterCSV.h @@ -1,35 +1,41 @@ /*=================================================================== 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_ #include +#include namespace mitk { - class MITKIGT_EXPORT NavigationDataSetWriterCSV + class NavigationDataSetWriterCSV : public AbstractFileWriter { public: NavigationDataSetWriterCSV(); virtual~NavigationDataSetWriterCSV(); - virtual void Write (std::string path, mitk::NavigationDataSet::Pointer ); - virtual void Write (std::ostream* stream, mitk::NavigationDataSet::Pointer); + using AbstractFileWriter::Write; + virtual void Write() override; + + protected: + NavigationDataSetWriterCSV(const NavigationDataSetWriterCSV& other); + + virtual mitk::NavigationDataSetWriterCSV* Clone() const override; }; } #endif // MITKNavigationDataSetWriterCSV_H_HEADER_INCLUDED_ diff --git a/Modules/IGT/IO/mitkNavigationDataSetWriterXML.cpp b/Modules/IGTBase/autoload/IO/mitkNavigationDataSetWriterXML.cpp similarity index 89% rename from Modules/IGT/IO/mitkNavigationDataSetWriterXML.cpp rename to Modules/IGTBase/autoload/IO/mitkNavigationDataSetWriterXML.cpp index 9f839956a1..03562b4115 100644 --- a/Modules/IGT/IO/mitkNavigationDataSetWriterXML.cpp +++ b/Modules/IGTBase/autoload/IO/mitkNavigationDataSetWriterXML.cpp @@ -1,137 +1,135 @@ /*=================================================================== 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 #include #include mitk::NavigationDataSetWriterXML::NavigationDataSetWriterXML() { } mitk::NavigationDataSetWriterXML::~NavigationDataSetWriterXML() { } -void mitk::NavigationDataSetWriterXML::Write (std::string path, mitk::NavigationDataSet::Pointer data) +mitk::NavigationDataSetWriterXML* mitk::NavigationDataSetWriterXML::Clone() const { - std::ofstream stream; - stream.open (path.c_str(), std::ios_base::trunc); - - // Pass to Stream Handler - Write(&stream, data); - stream.close(); + return new NavigationDataSetWriterXML(*this); } -void mitk::NavigationDataSetWriterXML::Write (std::ostream* stream, mitk::NavigationDataSet::Pointer data) +void mitk::NavigationDataSetWriterXML::Write() { + std::ostream* out = GetOutputStream(); + mitk::NavigationDataSet::ConstPointer data = dynamic_cast (this->GetInput()); + //save old locale char * oldLocale; oldLocale = setlocale( LC_ALL, nullptr ); StreamHeader(stream, data); StreamData(stream, data); StreamFooter(stream); // Cleanup stream->flush(); //switch back to old locale setlocale( LC_ALL, oldLocale ); } -void mitk::NavigationDataSetWriterXML::StreamHeader (std::ostream* stream, mitk::NavigationDataSet::Pointer data) +void mitk::NavigationDataSetWriterXML::StreamHeader (std::ostream* stream, mitk::NavigationDataSet::ConstPointer 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) +void mitk::NavigationDataSetWriterXML::StreamData (std::ostream* stream, mitk::NavigationDataSet::ConstPointer data) { // For each time step in the Dataset for (auto it = data->Begin(); it != data->End(); it++) { for (std::size_t toolIndex = 0; toolIndex < it->size(); toolIndex++) { mitk::NavigationData::Pointer nd = it->at(toolIndex); auto elem = new TiXmlElement("ND"); 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; } diff --git a/Modules/IGT/IO/mitkNavigationDataSetWriterXML.h b/Modules/IGTBase/autoload/IO/mitkNavigationDataSetWriterXML.h similarity index 72% rename from Modules/IGT/IO/mitkNavigationDataSetWriterXML.h rename to Modules/IGTBase/autoload/IO/mitkNavigationDataSetWriterXML.h index 8d0e48b64b..a4360a2250 100644 --- a/Modules/IGT/IO/mitkNavigationDataSetWriterXML.h +++ b/Modules/IGTBase/autoload/IO/mitkNavigationDataSetWriterXML.h @@ -1,41 +1,47 @@ /*=================================================================== 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 +#include namespace mitk { - class MITKIGT_EXPORT NavigationDataSetWriterXML + class NavigationDataSetWriterXML : public AbstractFileWriter { public: NavigationDataSetWriterXML(); virtual ~NavigationDataSetWriterXML(); - virtual void Write (std::string path, mitk::NavigationDataSet::Pointer ); - virtual void Write (std::ostream* stream, mitk::NavigationDataSet::Pointer); + + using AbstractFileWriter::Write; + virtual void Write() override; protected: - virtual void StreamHeader (std::ostream* stream, mitk::NavigationDataSet::Pointer data); - virtual void StreamData (std::ostream* stream, mitk::NavigationDataSet::Pointer data); + NavigationDataSetWriterXML(const NavigationDataSetWriterXML& other); + + virtual mitk::NavigationDataSetWriterXML* Clone() const override; + + virtual void StreamHeader (std::ostream* stream, mitk::NavigationDataSet::ConstPointer data); + virtual void StreamData (std::ostream* stream, mitk::NavigationDataSet::ConstPointer data); virtual void StreamFooter (std::ostream* stream); }; } #endif // MITKNavigationDataSetWriterXML_H_HEADER_INCLUDED_ diff --git a/Modules/IGTBase/files.cmake b/Modules/IGTBase/files.cmake index 9acce817e6..20ee894099 100644 --- a/Modules/IGTBase/files.cmake +++ b/Modules/IGTBase/files.cmake @@ -1,9 +1,13 @@ +file(GLOB_RECURSE H_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/include/*") + set(CPP_FILES - mitkRealTimeClock.cpp + mitkRealTimeClock.cpp + mitkNavigationData.cpp + mitkNavigationDataSet.cpp ) if(WIN32) set(CPP_FILES ${CPP_FILES} mitkWindowsRealTimeClock.cpp) else() set(CPP_FILES ${CPP_FILES} mitkLinuxRealTimeClock.cpp) endif(WIN32) diff --git a/Modules/IGTBase/mitkLinuxRealTimeClock.h b/Modules/IGTBase/include/mitkLinuxRealTimeClock.h similarity index 100% rename from Modules/IGTBase/mitkLinuxRealTimeClock.h rename to Modules/IGTBase/include/mitkLinuxRealTimeClock.h diff --git a/Modules/IGT/DataManagement/mitkNavigationData.h b/Modules/IGTBase/include/mitkNavigationData.h similarity index 97% rename from Modules/IGT/DataManagement/mitkNavigationData.h rename to Modules/IGTBase/include/mitkNavigationData.h index 801bd2a2c0..34044b3d9e 100644 --- a/Modules/IGT/DataManagement/mitkNavigationData.h +++ b/Modules/IGTBase/include/mitkNavigationData.h @@ -1,297 +1,297 @@ /*=================================================================== 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 MITKNAVIGATIONDATA_H_HEADER_INCLUDED_ #define MITKNAVIGATIONDATA_H_HEADER_INCLUDED_ #include -#include +#include #include #include namespace mitk { /**Documentation * \brief Navigation Data * * This class represents the data object that is passed through the MITK-IGT navigation filter * pipeline. It encapsulates position and orientation of a tracked tool/sensor. Additionally, * it contains a data structure that contains error/plausibility information * * It provides methods to work with the affine transformation represented by its orientation and position. * Additionally, it provides a constructor to construct a NavigationData object from an AffineTransform3D and * a getter to create an AffineTransform3D from a NavigationData object. * * \ingroup IGT */ - class MITKIGT_EXPORT NavigationData : public itk::DataObject + class MITKIGTBASE_EXPORT NavigationData : public itk::DataObject { public: mitkClassMacroItkParent(NavigationData, itk::DataObject); itkFactorylessNewMacro(Self); itkCloneMacro(Self); mitkNewMacro2Param(Self, mitk::AffineTransform3D::Pointer, const bool); mitkNewMacro1Param(Self, mitk::AffineTransform3D::Pointer); /** * \brief Type that holds the position part of the tracking data */ typedef mitk::Point3D PositionType; /** * \brief Type that holds the orientation part of the tracking data */ typedef mitk::Quaternion OrientationType; /** * \brief type that holds the error characterization of the position and orientation measurements */ typedef itk::Matrix CovarianceMatrixType; /** * \brief type that holds the time at which the data was recorded */ typedef double TimeStampType; /** * \brief sets the position of the NavigationData object */ itkSetMacro(Position, PositionType); /** * \brief returns position of the NavigationData object */ itkGetConstMacro(Position, PositionType); /** * \brief sets the orientation of the NavigationData object */ itkSetMacro(Orientation, OrientationType); /** * \brief returns the orientation of the NavigationData object */ itkGetConstMacro(Orientation, OrientationType); /** * \brief returns true if the object contains valid data */ virtual bool IsDataValid() const; /** * \brief sets the dataValid flag of the NavigationData object indicating if the object contains valid data */ itkSetMacro(DataValid, bool); /** * \brief sets the IGT timestamp of the NavigationData object */ itkSetMacro(IGTTimeStamp, TimeStampType); /** * \brief gets the IGT timestamp of the NavigationData object */ itkGetConstMacro(IGTTimeStamp, TimeStampType); /** * \brief sets the HasPosition flag of the NavigationData object */ itkSetMacro(HasPosition, bool); /** * \brief gets the HasPosition flag of the NavigationData object */ itkGetConstMacro(HasPosition, bool); /** * \brief sets the HasOrientation flag of the NavigationData object */ itkSetMacro(HasOrientation, bool); /** * \brief gets the HasOrientation flag of the NavigationData object */ itkGetConstMacro(HasOrientation, bool); /** * \brief sets the 6x6 Error Covariance Matrix of the NavigationData object */ itkSetMacro(CovErrorMatrix, CovarianceMatrixType); /** * \brief gets the 6x6 Error Covariance Matrix of the NavigationData object */ itkGetConstMacro(CovErrorMatrix, CovarianceMatrixType); /** * \brief set the name of the NavigationData object */ itkSetStringMacro(Name); /** * \brief returns the name of the NavigationData object */ itkGetStringMacro(Name); /** * \brief Graft the data and information from one NavigationData to another. * * Copies the content of data into this object. * This is a convenience method to setup a second NavigationData object with all the meta * information of another NavigationData object. * Note that this method is different than just using two * SmartPointers to the same NavigationData object since separate DataObjects are * still maintained. */ virtual void Graft(const DataObject *data) override; /** * \brief copy meta data of a NavigationData object * * copies all meta data from NavigationData data to this object */ virtual void CopyInformation(const DataObject* data) override; /** * \brief Prints the object information to the given stream os. * \param os The stream which is used to print the output. * \param indent Defines the indentation of the output. */ void PrintSelf(std::ostream& os, itk::Indent indent) const override; /** * Set the position part of m_CovErrorMatrix to I*error^2 * This means that all position variables are assumed to be independent */ void SetPositionAccuracy(mitk::ScalarType error); /** * Set the orientation part of m_CovErrorMatrix to I*error^2 * This means that all orientation variables are assumed to be independent */ void SetOrientationAccuracy(mitk::ScalarType error); /** * \brief Calculate AffineTransform3D from the transformation held by this NavigationData. * TODO: should throw an error if transformation is invalid. */ mitk::AffineTransform3D::Pointer GetAffineTransform3D() const; /** * \brief Calculate the RotationMatrix of this transformation. */ mitk::Matrix3D GetRotationMatrix() const; /** * \brief Transform by an affine transformation * * This method applies the affine transform given by self to a * given point, returning the transformed point. */ mitk::Point3D TransformPoint(const mitk::Point3D point) const; /** * Get inverse of the Transformation represented by this NavigationData. * @throws mitk::Exception in case the transformation is invalid (only case: quaternion is zero) */ mitk::NavigationData::Pointer GetInverse() const; /** Compose with another NavigationData * * This method composes self with another NavigationData of the * same dimension, modifying self to be the composition of self * and other. If the argument pre is true, then other is * precomposed with self; that is, the resulting transformation * consists of first applying other to the source, followed by * self. If pre is false or omitted, then other is post-composed * with self; that is the resulting transformation consists of * first applying self to the source, followed by other. */ void Compose(const mitk::NavigationData::Pointer n, const bool pre = false); protected: mitkCloneMacro(Self); NavigationData(); /* * Copy constructor internally used. */ NavigationData(const mitk::NavigationData& toCopy); /** * Creates a NavigationData object from an affineTransform3D. * Caution: NavigationData doesn't support spacing, only translation and rotation. If the affine * transform includes spacing it cannot be converted to a NavigationData and an exception is thrown. * @param checkForRotationMatrix if this is true, the rotation matrix coming from the affineTransform is checked * for being a rotation matrix. If it isn't, an exception is thrown. Disable this check by * setting checkForRotationMatrix to false. * * @throws mitkException if checkForRotationMatrix is true and a non rotation matrix was introduced by * AffineTransform. */ NavigationData(mitk::AffineTransform3D::Pointer affineTransform3D, const bool checkForRotationMatrix = true); virtual ~NavigationData(); /** * \brief holds the position part of the tracking data */ PositionType m_Position; /** * \brief holds the orientation part of the tracking data */ OrientationType m_Orientation; /** * \brief A 6x6 covariance matrix parameterizing the Gaussian error * distribution of the measured position and orientation. * * The hasPosition/hasOrientation fields define which entries * are valid. */ CovarianceMatrixType m_CovErrorMatrix; ///< holds the error characterization of the position and orientation /** * \brief defines if position part of m_CovErrorMatrix is valid */ bool m_HasPosition; /** * \brief defines if orientation part of m_CovErrorMatrix is valid */ bool m_HasOrientation; /** * \brief defines if the object contains valid values */ bool m_DataValid; /** * \brief contains the time at which the tracking data was recorded */ TimeStampType m_IGTTimeStamp; /** * \brief name of the navigation data */ std::string m_Name; private: void ResetCovarianceValidity(); // pre = false static mitk::NavigationData::Pointer getComposition(const mitk::NavigationData::Pointer nd1, const mitk::NavigationData::Pointer nd2); }; /** * @brief Equal A function comparing two navigation data objects for beeing equal in meta- and imagedata * * @ingroup MITKTestingAPI * * Following aspects are tested for equality: * - position * - orientation * - other members and flags of the class * * @param rightHandSide An NavigationData to be compared * @param leftHandSide An NavigationData to be compared * @param eps Tolarence for comparison. You can use mitk::eps in most cases. * @param verbose Flag indicating if the user wants detailed console output or not. * @return true, if all subsequent comparisons are true, false otherwise */ - MITKIGT_EXPORT bool Equal( const mitk::NavigationData& leftHandSide, const mitk::NavigationData& rightHandSide, ScalarType eps = mitk::eps, bool verbose = false ); + MITKIGTBASE_EXPORT bool Equal( const mitk::NavigationData& leftHandSide, const mitk::NavigationData& rightHandSide, ScalarType eps = mitk::eps, bool verbose = false ); } // namespace mitk #endif /* MITKNAVIGATIONDATA_H_HEADER_INCLUDED_ */ diff --git a/Modules/IGT/DataManagement/mitkNavigationDataSet.h b/Modules/IGTBase/include/mitkNavigationDataSet.h similarity index 97% rename from Modules/IGT/DataManagement/mitkNavigationDataSet.h rename to Modules/IGTBase/include/mitkNavigationDataSet.h index cd9a6a5675..5fd8c6e62f 100644 --- a/Modules/IGT/DataManagement/mitkNavigationDataSet.h +++ b/Modules/IGTBase/include/mitkNavigationDataSet.h @@ -1,158 +1,158 @@ /*=================================================================== 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 MITKNAVIGATIONDATASET_H_HEADER_INCLUDED_ #define MITKNAVIGATIONDATASET_H_HEADER_INCLUDED_ -#include +#include #include "mitkBaseData.h" #include "mitkNavigationData.h" namespace mitk { /** * \brief Data structure which stores streams of mitk::NavigationData for * multiple tools. * * Use mitk::NavigationDataRecorder to create these sets easily from pipelines. * Use mitk::NavigationDataPlayer to stream from these sets easily. * */ - class MITKIGT_EXPORT NavigationDataSet : public BaseData + class MITKIGTBASE_EXPORT NavigationDataSet : public BaseData { public: /** * \brief This iterator iterates over the distinct time steps in this set. * * It returns an array of the length equal to GetNumberOfTools(), containing a * mitk::NavigationData for each tool.. */ typedef std::vector< std::vector >::iterator NavigationDataSetIterator; mitkClassMacro(NavigationDataSet, BaseData); mitkNewMacro1Param(Self, unsigned int); /** * \brief Add mitk::NavigationData of the given tool to the Set. * * @param navigationDatas vector of mitk::NavigationData objects to be added. Make sure that the size of the * vector equals the number of tools given in the constructor * @return true if object was be added to the set successfully, false otherwise */ bool AddNavigationDatas( std::vector navigationDatas ); /** * \brief Get mitk::NavigationData from the given tool at given index. * * @param toolIndex Index of the tool from which mitk::NavigationData should be returned. * @param index Index of the mitk::NavigationData object that should be returned. * @return mitk::NavigationData at the specified indices, 0 if there is no object at the indices. */ NavigationData::Pointer GetNavigationDataForIndex( unsigned int index, unsigned int toolIndex ) const; ///** //* \brief Get last mitk::Navigation object for given tool whose timestamp is less than the given timestamp. //* @param toolIndex Index of the tool from which mitk::NavigationData should be returned. //* @param timestamp Timestamp for selecting last object before. //* @return Last mitk::NavigationData with timestamp less than given timestamp, 0 if there is no adequate object. //*/ // Method not yet supported! //NavigationData::Pointer GetNavigationDataBeforeTimestamp( mitk::NavigationData::TimeStampType timestamp , unsigned int toolIndex ) const; /** * \brief Returns a vector that contains all tracking data for a given tool. * * This is a relatively expensive operation, as it requires the construction of a new vector. * * @param toolIndex Index of the tool for which the stream should be returned. * @return Returns a vector that contains all tracking data for a given tool. */ virtual std::vector< mitk::NavigationData::Pointer > GetDataStreamForTool(unsigned int toolIndex); /** * \brief Returns a vector that contains NavigationDatas for each tool for a given timestep. * * If GetNumberOFTools() equals four, then 4 NavigationDatas will be returned. * * @param index Index of the timeStep for which the datas should be returned. cannot be larger than mitk::NavigationDataSet::Size() * @return Returns a vector that contains all tracking data for a given tool. */ virtual std::vector< mitk::NavigationData::Pointer > GetTimeStep(unsigned int index); /** * \brief Returns the number of tools for which NavigationDatas are stored in this set. * * This is always equal to the number given in the constructor of this class. * * @return the number of tools for which NavigationDatas are stored in this set. */ - unsigned int GetNumberOfTools(); + unsigned int GetNumberOfTools() const; /** * \brief Returns the number of time steps stored in this NavigationDataSet. * * This is not the total number of Navigation Datas stored in this set, but the number stored for each tool. * i.e. the total number of NavigationDatas equals Size() * GetNumberOfTools(); * * @return Returns the number of time steps stored in this NavigationDataSet. */ - unsigned int Size(); + unsigned int Size() const; /** * \brief Returns an iterator pointing to the first TimeStep. * * @return Returns an iterator pointing to the first TimeStep. */ virtual NavigationDataSetIterator Begin(); /** * \brief Returns an iterator pointing behind to the last TimeStep. * * @return Returns an iterator pointing behind to the last TimeStep. */ virtual NavigationDataSetIterator End(); // virtual methods, that need to be implemented, but aren't reasonable for NavigationData virtual void SetRequestedRegionToLargestPossibleRegion( ) override; virtual bool RequestedRegionIsOutsideOfTheBufferedRegion( ) override; virtual bool VerifyRequestedRegion( ) override; virtual void SetRequestedRegion( const itk::DataObject *data ) override; protected: /** * \brief Constructs set with fixed number of tools. * @param numTools How many tools are used with this mitk::NavigationDataSet. */ NavigationDataSet( unsigned int numTools ); virtual ~NavigationDataSet( ); /** * \brief Holds all the mitk::NavigationData objects managed by this class. * * The first dimension is the index of the navigation data, the second is the * tool to which this data belongs. i.e. the first dimension is usually the longer one. */ std::vector > m_NavigationDataVectors; /** * \brief The Number of Tools that this class is going to support. */ int m_NumberOfTools; }; } #endif // MITKNAVIGATIONDATASET_H_HEADER_INCLUDED_ diff --git a/Modules/IGTBase/mitkRealTimeClock.h b/Modules/IGTBase/include/mitkRealTimeClock.h similarity index 100% rename from Modules/IGTBase/mitkRealTimeClock.h rename to Modules/IGTBase/include/mitkRealTimeClock.h diff --git a/Modules/IGTBase/mitkWindowsRealTimeClock.h b/Modules/IGTBase/include/mitkWindowsRealTimeClock.h similarity index 100% rename from Modules/IGTBase/mitkWindowsRealTimeClock.h rename to Modules/IGTBase/include/mitkWindowsRealTimeClock.h diff --git a/Modules/IGTBase/mitkLinuxRealTimeClock.cpp b/Modules/IGTBase/src/mitkLinuxRealTimeClock.cpp similarity index 100% rename from Modules/IGTBase/mitkLinuxRealTimeClock.cpp rename to Modules/IGTBase/src/mitkLinuxRealTimeClock.cpp diff --git a/Modules/IGT/DataManagement/mitkNavigationData.cpp b/Modules/IGTBase/src/mitkNavigationData.cpp similarity index 100% rename from Modules/IGT/DataManagement/mitkNavigationData.cpp rename to Modules/IGTBase/src/mitkNavigationData.cpp diff --git a/Modules/IGT/DataManagement/mitkNavigationDataSet.cpp b/Modules/IGTBase/src/mitkNavigationDataSet.cpp similarity index 97% rename from Modules/IGT/DataManagement/mitkNavigationDataSet.cpp rename to Modules/IGTBase/src/mitkNavigationDataSet.cpp index 0b48f14f09..917194ed95 100644 --- a/Modules/IGT/DataManagement/mitkNavigationDataSet.cpp +++ b/Modules/IGTBase/src/mitkNavigationDataSet.cpp @@ -1,161 +1,161 @@ /*=================================================================== 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 "mitkNavigationDataSet.h" mitk::NavigationDataSet::NavigationDataSet( unsigned int numberOfTools ) : m_NavigationDataVectors(std::vector >()), m_NumberOfTools(numberOfTools) { } mitk::NavigationDataSet::~NavigationDataSet( ) { } bool mitk::NavigationDataSet::AddNavigationDatas( std::vector navigationDatas ) { // test if tool with given index exist if ( navigationDatas.size() != m_NumberOfTools ) { MITK_WARN("NavigationDataSet") << "Tried to add too many or too few navigation Datas to NavigationDataSet. " << m_NumberOfTools << " required, tried to add " << navigationDatas.size() << "."; return false; } // test for consistent timestamp if ( m_NavigationDataVectors.size() > 0) { for (int i = 0; i < navigationDatas.size(); i++) if (navigationDatas[i]->GetIGTTimeStamp() <= m_NavigationDataVectors.back()[i]->GetIGTTimeStamp()) { MITK_WARN("NavigationDataSet") << "IGTTimeStamp of new NavigationData should be newer than timestamp of last NavigationData."; return false; } } m_NavigationDataVectors.push_back(navigationDatas); return true; } mitk::NavigationData::Pointer mitk::NavigationDataSet::GetNavigationDataForIndex( unsigned int index, unsigned int toolIndex ) const { if ( index >= m_NavigationDataVectors.size() ) { MITK_WARN("NavigationDataSet") << "There is no NavigationData available at index " << index << "."; return nullptr; } if ( toolIndex >= m_NavigationDataVectors.at(index).size() ) { MITK_WARN("NavigationDataSet") << "There is NavigatitionData available at index " << index << " for tool " << toolIndex << "."; return nullptr; } return m_NavigationDataVectors.at(index).at(toolIndex); } // Method not yet supported, code below compiles but delivers wrong results //mitk::NavigationData::Pointer mitk::NavigationDataSet::GetNavigationDataBeforeTimestamp( // mitk::NavigationData::TimeStampType timestamp, unsigned int toolIndex) const //{ // if ( toolIndex >= m_NavigationDataVectors.size() ) // { // MITK_WARN("NavigationDataSet") << "There is no tool with index " << toolIndex << "."; // return NULL; // } // // std::vector::const_iterator it; // // // iterate through all NavigationData objects of the given tool index // // till the timestamp of the NavigationData is greater then the given timestamp // for (it = m_NavigationDataVectors.at(toolIndex).begin(); // it != m_NavigationDataVectors.at(toolIndex).end(); ++it) // { // if ( (*it)->GetIGTTimeStamp() > timestamp) { break; } // } // // // first element was greater than timestamp -> return null // if ( it == m_NavigationDataVectors.at(toolIndex).begin() ) // { // MITK_WARN("NavigationDataSet") << "No NavigationData was recorded before given timestamp."; // return NULL; // } // // // return last element smaller than the given timestamp // return *(it-1); //} std::vector< mitk::NavigationData::Pointer > mitk::NavigationDataSet::GetDataStreamForTool(unsigned int toolIndex) { if (toolIndex >= m_NumberOfTools ) { MITK_WARN("NavigationDataSet") << "Invalid toolIndex: " << m_NumberOfTools << " Tools known, requested index " << toolIndex << ""; return std::vector(); } std::vector< mitk::NavigationData::Pointer > result; for(int i = 0; i < m_NavigationDataVectors.size(); i++) result.push_back(m_NavigationDataVectors[i][toolIndex]); return result; } std::vector< mitk::NavigationData::Pointer > mitk::NavigationDataSet::GetTimeStep(unsigned int index) { return m_NavigationDataVectors[index]; } -unsigned int mitk::NavigationDataSet::GetNumberOfTools() +unsigned int mitk::NavigationDataSet::GetNumberOfTools() const { return m_NumberOfTools; } -unsigned int mitk::NavigationDataSet::Size() +unsigned int mitk::NavigationDataSet::Size() const { return m_NavigationDataVectors.size(); } // ---> methods necessary for BaseData void mitk::NavigationDataSet::SetRequestedRegionToLargestPossibleRegion() { } bool mitk::NavigationDataSet::RequestedRegionIsOutsideOfTheBufferedRegion() { return false; } bool mitk::NavigationDataSet::VerifyRequestedRegion() { return true; } void mitk::NavigationDataSet::SetRequestedRegion(const DataObject * ) { } // <--- methods necessary for BaseData // ---> methods for Iterators mitk::NavigationDataSet::NavigationDataSetIterator mitk::NavigationDataSet::Begin() { return m_NavigationDataVectors.begin(); } mitk::NavigationDataSet::NavigationDataSetIterator mitk::NavigationDataSet::End() { return m_NavigationDataVectors.end(); } diff --git a/Modules/IGTBase/mitkRealTimeClock.cpp b/Modules/IGTBase/src/mitkRealTimeClock.cpp similarity index 100% rename from Modules/IGTBase/mitkRealTimeClock.cpp rename to Modules/IGTBase/src/mitkRealTimeClock.cpp diff --git a/Modules/IGTBase/mitkWindowsRealTimeClock.cpp b/Modules/IGTBase/src/mitkWindowsRealTimeClock.cpp similarity index 100% rename from Modules/IGTBase/mitkWindowsRealTimeClock.cpp rename to Modules/IGTBase/src/mitkWindowsRealTimeClock.cpp