diff --git a/Modules/IGT/IO/mitkNavigationToolStorageDeserializer.cpp b/Modules/IGT/IO/mitkNavigationToolStorageDeserializer.cpp index f9722c0fd5..23db54b17f 100644 --- a/Modules/IGT/IO/mitkNavigationToolStorageDeserializer.cpp +++ b/Modules/IGT/IO/mitkNavigationToolStorageDeserializer.cpp @@ -1,116 +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. ===================================================================*/ //Poco headers #include "Poco/Zip/Decompress.h" #include "Poco/Path.h" #include "Poco/File.h" #include "mitkNavigationToolStorageDeserializer.h" #include #include #include "mitkNavigationToolReader.h" //POCO #include #include "mitkIGTException.h" #include "mitkIGTIOException.h" mitk::NavigationToolStorageDeserializer::NavigationToolStorageDeserializer(mitk::DataStorage::Pointer dataStorage) { m_DataStorage = dataStorage; //create temp directory for this reader - m_tempDirectory = mitk::IOUtil::CreateTemporaryDirectory("NavigationToolStorageDeserializerTmp_XXXXXX",mitk::IOUtil::GetProgramPath()); + m_tempDirectory = mitk::IOUtil::CreateTemporaryDirectory("NavigationToolStorageDeserializerTmp_XXXXXX",mitk::IOUtil::GetTempPath()); } mitk::NavigationToolStorageDeserializer::~NavigationToolStorageDeserializer() { //remove temp directory Poco::File myFile(m_tempDirectory); try { if (myFile.exists()) myFile.remove(); } catch(...) { MITK_ERROR << "Can't remove temp directory " << m_tempDirectory << "!"; } } mitk::NavigationToolStorage::Pointer mitk::NavigationToolStorageDeserializer::Deserialize(std::string filename) { //decomress zip file into temporary directory decomressFiles(filename,m_tempDirectory); //now read all files and convert them to navigation tools mitk::NavigationToolStorage::Pointer returnValue = mitk::NavigationToolStorage::New(m_DataStorage); bool cont = true; int i; for (i=0; cont==true; i++) { std::string fileName = m_tempDirectory + Poco::Path::separator() + "NavigationTool" + convertIntToString(i) + ".tool"; mitk::NavigationToolReader::Pointer myReader = mitk::NavigationToolReader::New(); mitk::NavigationTool::Pointer readTool = myReader->DoRead(fileName); if (readTool.IsNull()) cont = false; else returnValue->AddTool(readTool); //delete file std::remove(fileName.c_str()); } if(i==1) { //throw an exception here in case of not finding any tool m_ErrorMessage = "Error: did not find any tool. \n Is this a tool storage file?"; mitkThrowException(mitk::IGTException)<<"Error: did not find any tool. \n Is this a tool storage file?"; } return returnValue; } std::string mitk::NavigationToolStorageDeserializer::convertIntToString(int i) { std::string s; std::stringstream out; out << i; s = out.str(); return s; } void mitk::NavigationToolStorageDeserializer::decomressFiles(std::string filename,std::string path) { std::ifstream file( filename.c_str(), std::ios::binary ); if (!file.good()) { m_ErrorMessage = "Cannot open '" + filename + "' for reading"; mitkThrowException(mitk::IGTException)<<"Cannot open"+filename+" for reading"; } try { Poco::Zip::Decompress unzipper( file, Poco::Path( path ) ); unzipper.decompressAllFiles(); file.close(); } catch(Poco::IllegalStateException e) //temporary solution: replace this by defined exception handling later! { m_ErrorMessage = "Error: wrong file format! \n (please only load tool storage files)"; MITK_ERROR << m_ErrorMessage; mitkThrowException(mitk::IGTException) << m_ErrorMessage; } } diff --git a/Modules/IGT/Testing/files.cmake b/Modules/IGT/Testing/files.cmake index a7e72a1ad9..3f3bb46b60 100644 --- a/Modules/IGT/Testing/files.cmake +++ b/Modules/IGT/Testing/files.cmake @@ -1,67 +1,67 @@ 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 - mitkNavigationToolStorageDeserializerTest.cpp # This test was disabled because of bug 17303. mitkNavigationToolStorageSerializerAndDeserializerIntegrationTest.cpp # This test was disabled because of bug 17181. mitkNavigationToolStorageSerializerTest.cpp # This test was disabled because of bug 18671 )