diff --git a/Modules/IGT/CMakeLists.txt b/Modules/IGT/CMakeLists.txt index c041a273f6..8246566077 100644 --- a/Modules/IGT/CMakeLists.txt +++ b/Modules/IGT/CMakeLists.txt @@ -1,64 +1,67 @@ include(MITKIGTHardware.cmake) if(MITK_USE_MICRON_TRACKER) - set(INCLUDE_DIRS_INTERNAL ${INCLUDE_DIRS_INTERNAL} ${MITK_MICRON_TRACKER_INCLUDE_DIR}) + set(ADDITIONAL_INCLUDE_DIRS ${ADDITIONAL_INCLUDE_DIRS} ${MITK_MICRON_TRACKER_INCLUDE_DIR}) set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} ${MITK_MICRON_TRACKER_LIB}) endif(MITK_USE_MICRON_TRACKER) if(MITK_USE_OPTITRACK_TRACKER) - set(INCLUDE_DIRS_INTERNAL ${INCLUDE_DIRS_INTERNAL} ${MITK_OPTITRACK_TRACKER_INCLUDE_DIR}) + set(ADDITIONAL_INCLUDE_DIRS ${ADDITIONAL_INCLUDE_DIRS} ${MITK_OPTITRACK_TRACKER_INCLUDE_DIR}) set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} ${MITK_OPTITRACK_TRACKER_LIB}) add_definitions( -DMITK_USE_OPTITRACK_TRACKER ) endif(MITK_USE_OPTITRACK_TRACKER) if(MITK_USE_MICROBIRD_TRACKER) - set(INCLUDE_DIRS_INTERNAL ${INCLUDE_DIRS_INTERNAL} ${MITK_USE_MICROBIRD_TRACKER_INCLUDE_DIR}) + set(ADDITIONAL_INCLUDE_DIRS ${ADDITIONAL_INCLUDE_DIRS} ${MITK_USE_MICROBIRD_TRACKER_INCLUDE_DIR}) set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} ${MITK_USE_MICROBIRD_TRACKER_LIB}) endif(MITK_USE_MICROBIRD_TRACKER) if(MITK_USE_POLHEMUS_TRACKER) - set(INCLUDE_DIRS_INTERNAL ${INCLUDE_DIRS_INTERNAL} ${MITK_POLHEMUS_TRACKER_INCLUDE_DIR}) + set(ADDITIONAL_INCLUDE_DIRS ${ADDITIONAL_INCLUDE_DIRS} ${MITK_POLHEMUS_TRACKER_INCLUDE_DIR}) set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} ${MITK_POLHEMUS_TRACKER_LIB}) endif(MITK_USE_POLHEMUS_TRACKER) +message(STATUS "ADDITIONAL_INCLUDE_DIRS" ${ADDITIONAL_INCLUDE_DIRS}) +message(STATUS "ADDITIONAL_LIBS" ${ADDITIONAL_LIBS}) + MITK_CREATE_MODULE( SUBPROJECTS MITK-IGT - INCLUDE_DIRS Algorithms Common DataManagement ExceptionHandling IO Rendering TrackingDevices TestingHelper - INTERNAL_INCLUDE_DIRS ${INCLUDE_DIRS_INTERNAL} + INCLUDE_DIRS Algorithms Common DataManagement ExceptionHandling IO Rendering TrackingDevices TestingHelper + INTERNAL_INCLUDE_DIRS ${ADDITIONAL_INCLUDE_DIRS} DEPENDS MitkImageStatistics MitkSceneSerialization MitkIGTBase MitkOpenIGTLink PACKAGE_DEPENDS ITK|ITKRegistrationCommon tinyxml OpenIGTLink - ADDITIONAL_LIBS "${ADDITIONAL_LIBS}" + ADDITIONAL_LIBS ${ADDITIONAL_LIBS} #WARNINGS_AS_ERRORS disabled for release 2014-03 because of bug 17463 ) if(MitkIGT_IS_ENABLED) MITK_INSTALL(FILES ${MITK_SOURCE_DIR}/Modules/IGT/Resources/ClaronMicron.stl ) MITK_INSTALL(FILES ${MITK_SOURCE_DIR}/Modules/IGT/Resources/IntuitiveDaVinci.stl ) MITK_INSTALL(FILES ${MITK_SOURCE_DIR}/Modules/IGT/Resources/NDIAurora.stl ) MITK_INSTALL(FILES ${MITK_SOURCE_DIR}/Modules/IGT/Resources/NDIAurora_Dome.stl ) MITK_INSTALL(FILES ${MITK_SOURCE_DIR}/Modules/IGT/Resources/NDIAuroraCompactFG_Dome.stl ) MITK_INSTALL(FILES ${MITK_SOURCE_DIR}/Modules/IGT/Resources/NDIAuroraPlanarFG_Dome.stl ) MITK_INSTALL(FILES ${MITK_SOURCE_DIR}/Modules/IGT/Resources/NDIAuroraTabletopFG_Dome.stl ) MITK_INSTALL(FILES ${MITK_SOURCE_DIR}/Modules/IGT/Resources/NDIAuroraTabletopFG_Prototype_Dome.stl ) MITK_INSTALL(FILES ${MITK_SOURCE_DIR}/Modules/IGT/Resources/NDIPolarisOldModel.stl ) MITK_INSTALL(FILES ${MITK_SOURCE_DIR}/Modules/IGT/Resources/NDIPolarisSpectra.stl ) MITK_INSTALL(FILES ${MITK_SOURCE_DIR}/Modules/IGT/Resources/NDIPolarisSpectraExtendedPyramid.stl ) MITK_INSTALL(FILES ${MITK_SOURCE_DIR}/Modules/IGT/Resources/NDIPolarisVicra.stl ) endif() if(NOT MODULE_IS_ENABLED) message(STATUS "IGTTutorialStep1 won't be built. Missing: ${_RESULT}") else() ## create IGT config configure_file(mitkIGTConfig.h.in ${PROJECT_BINARY_DIR}/mitkIGTConfig.h @ONLY) # add test programm for serial communication classADD_EXECUTABLE(SerialCommunicationTest IGTTrackingDevices/mitkSerialCommunicationTest.cpp)target_link_libraries(SerialCommunicationTest mitkIGT Mitk tinyxml PocoXML) add_subdirectory(autoload/DeviceRegistry) add_subdirectory(Tutorial) add_subdirectory(Testing) endif() diff --git a/Modules/IGT/Testing/files.cmake b/Modules/IGT/Testing/files.cmake index 0a90d07c87..4be7accede 100644 --- a/Modules/IGT/Testing/files.cmake +++ b/Modules/IGT/Testing/files.cmake @@ -1,68 +1,75 @@ set(MODULE_TESTS # IMPORTANT: If you plan to deactivate / comment out a test please write a bug number to the commented out line of code. # # Example: #mitkMyTest #this test is commented out because of bug 12345 # # It is important that the bug is open and that the test will be activated again before the bug is closed. This assures that # no test is forgotten after it was commented out. If there is no bug for your current problem, please add a new one and # mark it as critical. ################## ON THE FENCE TESTS ################################################# # none ################## DISABLED TESTS ##################################################### ################# RUNNING TESTS ####################################################### mitkCameraVisualizationTest.cpp mitkClaronInterfaceTest.cpp mitkClaronToolTest.cpp mitkClaronTrackingDeviceTest.cpp mitkInternalTrackingToolTest.cpp mitkNavigationDataDisplacementFilterTest.cpp mitkNavigationDataLandmarkTransformFilterTest.cpp mitkNavigationDataObjectVisualizationFilterTest.cpp mitkNavigationDataSetTest.cpp mitkNavigationDataTest.cpp mitkNavigationDataRecorderTest.cpp mitkNavigationDataReferenceTransformFilterTest.cpp mitkNavigationDataSequentialPlayerTest.cpp mitkNavigationDataSetReaderWriterXMLTest.cpp mitkNavigationDataSetReaderWriterCSVTest.cpp mitkNavigationDataSourceTest.cpp mitkNavigationDataToMessageFilterTest.cpp mitkNavigationDataToNavigationDataFilterTest.cpp mitkNavigationDataToPointSetFilterTest.cpp mitkNavigationDataToIGTLMessageFilterTest.cpp mitkNavigationDataTransformFilterTest.cpp mitkNDIPassiveToolTest.cpp mitkNDIProtocolTest.cpp mitkNDITrackingDeviceTest.cpp mitkTimeStampTest.cpp mitkTrackingVolumeGeneratorTest.cpp mitkTrackingDeviceTest.cpp mitkTrackingToolTest.cpp mitkVirtualTrackingDeviceTest.cpp # mitkNavigationDataPlayerTest.cpp # random fails see bug 16485. # We decided to won't fix because of complete restructuring via bug 15959. mitkTrackingDeviceSourceTest.cpp mitkTrackingDeviceSourceConfiguratorTest.cpp mitkNavigationDataEvaluationFilterTest.cpp mitkTrackingTypesTest.cpp mitkOpenIGTLinkTrackingDeviceTest.cpp # ------------------ Navigation Tool Management Tests ------------------- mitkNavigationToolStorageDeserializerTest.cpp # Activated experimentally on dart clients, see task T17303 for details. mitkNavigationToolStorageTest.cpp mitkNavigationToolTest.cpp # ----------------------------------------------------------------------- ) set(MODULE_CUSTOM_TESTS mitkNDIAuroraHardwareTest.cpp mitkNDIPolarisHardwareTest.cpp mitkClaronTrackingDeviceHardwareTest.cpp mitkNavigationToolReaderAndWriterTest.cpp #deactivated because of bug 18835 mitkNavigationToolStorageSerializerAndDeserializerIntegrationTest.cpp # This test was disabled because of bug 17181. mitkNavigationToolStorageSerializerTest.cpp # This test was disabled because of bug 18671 + #mitkPolhemusTrackingDeviceHardwareTest.cpp +) + +if(MITK_USE_POLHEMUS_TRACKER) +set(MODULE_CUSTOM_TESTS + ${MODULE_CUSTOM_TESTS} mitkPolhemusTrackingDeviceHardwareTest.cpp ) +endif(MITK_USE_POLHEMUS_TRACKER) diff --git a/Modules/IGT/TrackingDevices/mitkPolhemusInterface.cpp b/Modules/IGT/TrackingDevices/mitkPolhemusInterface.cpp index 775161715f..26f1b570b8 100644 --- a/Modules/IGT/TrackingDevices/mitkPolhemusInterface.cpp +++ b/Modules/IGT/TrackingDevices/mitkPolhemusInterface.cpp @@ -1,197 +1,200 @@ /*=================================================================== 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 #define _USE_MATH_DEFINES #include +#include + BYTE MotionBuf[0x1FA400]; mitk::PolhemusInterface::PolhemusInterface() { - + m_pdiDev = new CPDIdev(); } mitk::PolhemusInterface::~PolhemusInterface() { - + delete m_pdiDev; } + bool mitk::PolhemusInterface::InitializeDevice() { - m_pdiDev.ResetTracker(); - m_pdiDev.ResetSAlignment(-1); - m_pdiDev.Trace(TRUE, 7); + m_pdiDev->ResetTracker(); + m_pdiDev->ResetSAlignment(-1); + m_pdiDev->Trace(TRUE, 7); return true; } bool mitk::PolhemusInterface::SetupDevice() { - m_pdiDev.SetPnoBuffer(MotionBuf, 0x1FA400); - m_pdiDev.SetMetric(true); //use cm instead of inches + m_pdiDev->SetPnoBuffer(MotionBuf, 0x1FA400); + m_pdiDev->SetMetric(true); //use cm instead of inches - m_pdiDev.StartPipeExport(); + m_pdiDev->StartPipeExport(); CPDImdat pdiMDat; pdiMDat.Empty(); pdiMDat.Append(PDI_MODATA_FRAMECOUNT); pdiMDat.Append(PDI_MODATA_POS); pdiMDat.Append(PDI_MODATA_ORI); - m_pdiDev.SetSDataList(-1, pdiMDat); + m_pdiDev->SetSDataList(-1, pdiMDat); CPDIbiterr cBE; - m_pdiDev.GetBITErrs(cBE); + m_pdiDev->GetBITErrs(cBE); - if (!(cBE.IsClear())) {m_pdiDev.ClearBITErrs();} + if (!(cBE.IsClear())) {m_pdiDev->ClearBITErrs();} - if (this->m_HemisphereTrackingEnabled) { m_pdiDev.SetSHemiTrack(-1); } - else { m_pdiDev.SetSHemisphere(-1, { (float)2.54,0,0 }); } + if (this->m_HemisphereTrackingEnabled) { m_pdiDev->SetSHemiTrack(-1); } + else { m_pdiDev->SetSHemisphere(-1, { (float)2.54,0,0 }); } return true; } bool mitk::PolhemusInterface::StartTracking() { LPCTSTR szWindowClass = _T("PDIconsoleWinClass"); HINSTANCE hInst = GetModuleHandle(0); HWND hwnd = CreateWindowEx( WS_EX_NOACTIVATE,//WS_EX_STATICEDGE, // szWindowClass, _T("MyWindowName"), WS_POPUP, 0, 0, 1, 1, HWND_MESSAGE, 0, hInst, 0); m_continousTracking = true; - return m_pdiDev.StartContPno(hwnd); + return m_pdiDev->StartContPno(hwnd); } bool mitk::PolhemusInterface::StopTracking() { m_continousTracking = false; return true; } bool mitk::PolhemusInterface::Connect() { if (!InitializeDevice()) { return false; } - if (m_pdiDev.CnxReady()) { return true; } + if (m_pdiDev->CnxReady()) { return true; } CPDIser pdiSer; - m_pdiDev.SetSerialIF(&pdiSer); + m_pdiDev->SetSerialIF(&pdiSer); - ePiCommType eType = m_pdiDev.DiscoverCnx(); + ePiCommType eType = m_pdiDev->DiscoverCnx(); switch (eType) { case PI_CNX_USB: - MITK_INFO << "USB Connection: " << m_pdiDev.GetLastResultStr(); + MITK_INFO << "USB Connection: " << m_pdiDev->GetLastResultStr(); break; case PI_CNX_SERIAL: - MITK_INFO << "Serial Connection: " << m_pdiDev.GetLastResultStr(); + MITK_INFO << "Serial Connection: " << m_pdiDev->GetLastResultStr(); break; default: - MITK_INFO << "DiscoverCnx result: " << m_pdiDev.GetLastResultStr(); + MITK_INFO << "DiscoverCnx result: " << m_pdiDev->GetLastResultStr(); break; } if (!SetupDevice()) { return false; } - return m_pdiDev.CnxReady(); + return m_pdiDev->CnxReady(); } bool mitk::PolhemusInterface::Disconnect() { if (m_continousTracking) { m_continousTracking = false; - if (!m_pdiDev.Disconnect()) return false; + if (!m_pdiDev->Disconnect()) return false; } return true; } std::vector mitk::PolhemusInterface::GetLastFrame() { PBYTE pBuf; DWORD dwSize; //read one frame - if (!m_pdiDev.LastPnoPtr(pBuf, dwSize)) {MITK_WARN << m_pdiDev.GetLastResultStr();} + if (!m_pdiDev->LastPnoPtr(pBuf, dwSize)) {MITK_WARN << m_pdiDev->GetLastResultStr();} std::vector returnValue = ParsePolhemusRawData(pBuf, dwSize); if (returnValue.empty()) { MITK_WARN << "Cannot parse data / no tools present"; } return returnValue; } unsigned int mitk::PolhemusInterface::GetNumberOfTools() { if (m_continousTracking) return GetLastFrame().size(); else return GetSingleFrame().size(); } std::vector mitk::PolhemusInterface::GetSingleFrame() { if (m_continousTracking) return std::vector(); PBYTE pBuf; DWORD dwSize; //read one frame - if (!m_pdiDev.ReadSinglePnoBuf(pBuf, dwSize)) { MITK_WARN << m_pdiDev.GetLastResultStr(); } + if (!m_pdiDev->ReadSinglePnoBuf(pBuf, dwSize)) { MITK_WARN << m_pdiDev->GetLastResultStr(); } return ParsePolhemusRawData(pBuf, dwSize); } std::vector mitk::PolhemusInterface::ParsePolhemusRawData(PBYTE pBuf, DWORD dwSize) { std::vector returnValue; DWORD i = 0; while (i eulerQuat(rollAngle, elevationAngle, azimuthAngle); currentTrackingData.rot = eulerQuat; returnValue.push_back(currentTrackingData); i += shSize; } return returnValue; } diff --git a/Modules/IGT/TrackingDevices/mitkPolhemusInterface.h b/Modules/IGT/TrackingDevices/mitkPolhemusInterface.h index c11f4ebcce..28eea88760 100644 --- a/Modules/IGT/TrackingDevices/mitkPolhemusInterface.h +++ b/Modules/IGT/TrackingDevices/mitkPolhemusInterface.h @@ -1,118 +1,117 @@ /*=================================================================== 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 MITKPolhemusINTERFACE_H_HEADER_INCLUDED_ #define MITKPolhemusINTERFACE_H_HEADER_INCLUDED_ #include #include #include #include "mitkCommon.h" #include #include #include #include #include -#include #include - +class CPDIdev; namespace mitk { /** Documentation: * \brief An object of this class represents the interface to Polhemus trackers. * \ingroup IGT */ class MITKIGT_EXPORT PolhemusInterface : public itk::Object { public: mitkClassMacroItkParent(PolhemusInterface,itk::Object); itkFactorylessNewMacro(Self); itkCloneMacro(Self); struct trackingData { mitk::Point3D pos; mitk::Quaternion rot; BYTE id; }; /** * \brief Opens the connection to the device and makes it ready to track tools. * \return Returns true if there is a connection to the device and the device is ready to track tools, false if not. */ bool StartTracking(); /** * \brief Clears all resources. After this method have been called the system isn't ready to track any longer. * \return Returns true if the operation was succesful, false if not. */ bool StopTracking(); bool Connect(); bool Disconnect(); /** @return Returns a single frame. Only works if the tracking device is not in continous tracking mode. Returns an empty vector in case of an error.*/ std::vector GetSingleFrame(); /** @return Returns the last frame when the tracking device is in continous tracking mode. Returns an empty vector in case of an error.*/ std::vector GetLastFrame(); /** @return Returns the number of tools. Returns 0 if no information is avialable.*/ unsigned int GetNumberOfTools(); /** Enables/disables hemisphere tracking for all sensors. */ itkSetMacro(HemisphereTrackingEnabled, bool); protected: /** * \brief standard constructor */ PolhemusInterface(); /** * \brief standard destructor */ ~PolhemusInterface(); - /** Polhemus liberty/patriot tracker object*/ - CPDIdev m_pdiDev; - - /** Parses polhemus raw data to a collection of tracking data of single tools. */ + /** Polhemus liberty/patriot tracker object*/ + CPDIdev* m_pdiDev; + + /** Parses polhemus raw data to a collection of tracking data of single tools. */ std::vector ParsePolhemusRawData(PBYTE pBuf, DWORD dwSize); unsigned int m_numberOfTools; bool m_continousTracking; bool InitializeDevice(); bool SetupDevice(); bool m_HemisphereTrackingEnabled; }; }//mitk #endif diff --git a/Modules/IGT/autoload/DeviceRegistry/src/mitkIGTActivator.cpp b/Modules/IGT/autoload/DeviceRegistry/src/mitkIGTActivator.cpp index 5d48a323e0..8e34c40cd4 100644 --- a/Modules/IGT/autoload/DeviceRegistry/src/mitkIGTActivator.cpp +++ b/Modules/IGT/autoload/DeviceRegistry/src/mitkIGTActivator.cpp @@ -1,65 +1,70 @@ /*=================================================================== 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 "mitkIGTConfig.h" #include "mitkIGTActivator.h" //All Tracking devices, which should be available by default #include "mitkNDIAuroraTypeInformation.h" #include "mitkNDIPolarisTypeInformation.h" #include "mitkVirtualTrackerTypeInformation.h" #include "mitkMicronTrackerTypeInformation.h" #include "mitkNPOptitrackTrackingTypeInformation.h" #include "mitkOpenIGTLinkTypeInformation.h" +#ifdef MITK_USE_POLHEMUS_TRACKER #include "mitkPolhemusTrackerTypeInformation.h" +#endif namespace mitk { IGTActivator::IGTActivator() { } IGTActivator::~IGTActivator() { } void IGTActivator::Load(us::ModuleContext*) { m_DeviceTypeCollection.RegisterTrackingDeviceType(new mitk::NDIAuroraTypeInformation()); m_DeviceTypeCollection.RegisterTrackingDeviceType(new mitk::NDIPolarisTypeInformation()); m_DeviceTypeCollection.RegisterTrackingDeviceType(new mitk::MicronTrackerTypeInformation()); m_DeviceTypeCollection.RegisterTrackingDeviceType(new mitk::NPOptitrackTrackingTypeInformation()); m_DeviceTypeCollection.RegisterTrackingDeviceType(new mitk::VirtualTrackerTypeInformation()); m_DeviceTypeCollection.RegisterTrackingDeviceType(new mitk::OpenIGTLinkTypeInformation()); +#ifdef MITK_USE_POLHEMUS_TRACKER m_DeviceTypeCollection.RegisterTrackingDeviceType(new mitk::PolhemusTrackerTypeInformation()); - m_DeviceTypeCollection.RegisterAsMicroservice(); +#endif + m_DeviceTypeCollection.RegisterAsMicroservice(); } void IGTActivator::Unload(us::ModuleContext*) { try { m_DeviceTypeCollection.UnRegisterMicroservice(); } catch (std::exception& e) { MITK_WARN << "Unable to unregister IGT DeviceTypeCollection Microservice: "<