diff --git a/Modules/IGT/IO/mitkNavigationToolStorageDeserializer.cpp b/Modules/IGT/IO/mitkNavigationToolStorageDeserializer.cpp index cb7d9dbba7..cd0ae2b54d 100644 --- a/Modules/IGT/IO/mitkNavigationToolStorageDeserializer.cpp +++ b/Modules/IGT/IO/mitkNavigationToolStorageDeserializer.cpp @@ -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. ===================================================================*/ //Poco headers #include "Poco/Zip/Decompress.h" #include "Poco/Path.h" #include "Poco/File.h" #include "mitkNavigationToolStorageDeserializer.h" #include -#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::StandardFileLocations::GetInstance()->GetOptionDirectory() + Poco::Path::separator() + "tempNavigationToolDeserializer"; - Poco::File myFile(m_tempDirectory); - myFile.createDirectory(); + m_tempDirectory = mitk::IOUtil::CreateTemporaryDirectory(); + MITK_INFO << "TEMP DIRECTORY: " << m_tempDirectory; } 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 0cb2e78dd2..d3b2d40b82 100644 --- a/Modules/IGT/Testing/files.cmake +++ b/Modules/IGT/Testing/files.cmake @@ -1,58 +1,57 @@ 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. ################## DISABLED TESTS ################################################# - # + # mitkNavigationToolStorageDeserializerTest.cpp # disabled because of bug 17303 + # mitkNavigationToolStorageSerializerAndDeserializerIntegrationTest.cpp # disabled because of bug 17181 ################# RUNNING TESTS ################################################### mitkCameraVisualizationTest.cpp mitkClaronInterfaceTest.cpp mitkClaronToolTest.cpp mitkClaronTrackingDeviceTest.cpp mitkInternalTrackingToolTest.cpp mitkNavigationDataDisplacementFilterTest.cpp mitkNavigationDataLandmarkTransformFilterTest.cpp mitkNavigationDataObjectVisualizationFilterTest.cpp mitkNavigationDataTest.cpp mitkNavigationDataRecorderTest.cpp mitkNavigationDataReferenceTransformFilterTest.cpp mitkNavigationDataSequentialPlayerTest.cpp mitkNavigationDataSourceTest.cpp mitkNavigationDataToMessageFilterTest.cpp mitkNavigationDataToNavigationDataFilterTest.cpp mitkNavigationDataToPointSetFilterTest.cpp mitkNavigationDataTransformFilterTest.cpp mitkNDIPassiveToolTest.cpp mitkNDIProtocolTest.cpp mitkNDITrackingDeviceTest.cpp mitkTimeStampTest.cpp mitkTrackingVolumeGeneratorTest.cpp mitkTrackingDeviceTest.cpp mitkTrackingToolTest.cpp mitkVirtualTrackingDeviceTest.cpp mitkNavigationDataPlayerTest.cpp # see bug 11636 (extend this test by microservices) mitkTrackingDeviceSourceTest.cpp mitkTrackingDeviceSourceConfiguratorTest.cpp mitkNavigationDataEvaluationFilterTest.cpp mitkTrackingTypesTest.cpp # ------------------ Navigation Tool Management Tests ------------------- mitkNavigationToolStorageTest.cpp mitkNavigationToolTest.cpp mitkNavigationToolReaderAndWriterTest.cpp - mitkNavigationToolStorageDeserializerTest.cpp mitkNavigationToolStorageSerializerTest.cpp - mitkNavigationToolStorageSerializerAndDeserializerIntegrationTest.cpp # ----------------------------------------------------------------------- ) set(MODULE_CUSTOM_TESTS mitkNDIAuroraHardwareTest.cpp mitkNDIPolarisHardwareTest.cpp mitkClaronTrackingDeviceHardwareTest.cpp )