diff --git a/Modules/IGT/DataManagement/mitkNavigationDataSet.cpp b/Modules/IGT/DataManagement/mitkNavigationDataSet.cpp new file mode 100644 index 0000000000..596e3e1238 --- /dev/null +++ b/Modules/IGT/DataManagement/mitkNavigationDataSet.cpp @@ -0,0 +1,116 @@ +/*=================================================================== + +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 numTools ) + : m_NavigationDataVectors(std::vector >(numTools, std::vector())) +{ + +} + +mitk::NavigationDataSet::~NavigationDataSet( ) +{ +} + +bool mitk::NavigationDataSet::InsertNavigationData( unsigned int toolIndex, mitk::NavigationData::Pointer navigationData ) +{ + // test if tool with given index exist + if ( toolIndex >= m_NavigationDataVectors.size() ) + { + MITK_WARN("NavigationDataSet") << "There is no tool with index "< 0 && + navigationData->GetIGTTimeStamp() <= (*(m_NavigationDataVectors.at(toolIndex).end()-1))->GetIGTTimeStamp()) + { + MITK_WARN("NavigationDataSet") << "IGTTimeStamp of new NavigationData should be greater then timestamp of last NavigationData."; + return false; + } + + m_NavigationDataVectors.at(toolIndex).push_back(navigationData); + return true; +} + +mitk::NavigationData::Pointer mitk::NavigationDataSet::GetNavigationDataForIndex( unsigned int toolIndex, unsigned int index ) const +{ + if ( toolIndex >= m_NavigationDataVectors.size() ) + { + MITK_WARN("NavigationDataSet") << "There is no tool with index "<= m_NavigationDataVectors.at(toolIndex).size() ) + { + MITK_WARN("NavigationDataSet") << "There is no mitk::Navigation with index "<= m_NavigationDataVectors.size() ) + { + MITK_WARN("NavigationDataSet") << "There is no tool with index "<::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); +} + +// ---> 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 diff --git a/Modules/IGT/DataManagement/mitkNavigationDataSet.h b/Modules/IGT/DataManagement/mitkNavigationDataSet.h new file mode 100644 index 0000000000..d7162d7a4c --- /dev/null +++ b/Modules/IGT/DataManagement/mitkNavigationDataSet.h @@ -0,0 +1,86 @@ +/*=================================================================== + +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 "mitkBaseData.h" +#include "mitkNavigationData.h" + +namespace mitk { + + /** + * \brief Data structure which stores sets of mitk::NavigationData for + * multiple tools. + * + * + */ + class MitkIGT_EXPORT NavigationDataSet : public BaseData + { + public: + mitkClassMacro(NavigationDataSet, BaseData); + + mitkNewMacro1Param(Self, unsigned int); + + /** + * \brief Add mitk::NavigationData of the given tool to the Set. + * + * @param toolIndex Index of the tool for which mitk::NavigationData should be added. + * @param navigationData mitk::NavigationData object to be added. + * @return true if object could be added to the set, false otherwise (e.g. tool with given index not existing) + */ + bool InsertNavigationData( unsigned int toolIndex, NavigationData::Pointer navigationData ); + + /** + * \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 toolIndex, unsigned int index ) 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. + */ + NavigationData::Pointer GetNavigationDataBeforeTimestamp( unsigned int toolIndex, mitk::NavigationData::TimeStampType timestamp ) const; + + // virtual methods, that need to be implemented, but aren't reasonable for NavigationData + virtual void SetRequestedRegionToLargestPossibleRegion( ); + virtual bool RequestedRegionIsOutsideOfTheBufferedRegion( ); + virtual bool VerifyRequestedRegion( ); + virtual void SetRequestedRegion( const itk::DataObject *data ); + + 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. + */ + std::vector > m_NavigationDataVectors; + }; +} + +#endif // MITKNAVIGATIONDATASET_H_HEADER_INCLUDED_ diff --git a/Modules/IGT/files.cmake b/Modules/IGT/files.cmake index 1d6e889c08..49f69862f2 100644 --- a/Modules/IGT/files.cmake +++ b/Modules/IGT/files.cmake @@ -1,65 +1,66 @@ 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 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)