diff --git a/apps/DoseMap/DoseMap.cpp b/apps/DoseMap/DoseMap.cpp index 703751a..9a2de01 100644 --- a/apps/DoseMap/DoseMap.cpp +++ b/apps/DoseMap/DoseMap.cpp @@ -1,212 +1,210 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision: 1221 $ (last changed revision) // @date $Date: 2015-12-01 13:43:31 +0100 (Di, 01 Dez 2015) $ (last change date) // @author $Author: hentsch $ (last changed by) */ #include "DoseMapApplicationData.h" #include "DoseMapHelper.h" #include "DoseMapCmdLineParser.h" #include "boost/shared_ptr.hpp" #include "boost/make_shared.hpp" #include "RTToolboxConfigure.h" #include "rttbException.h" #include "mapDummyRegistrationAlgorithm.h" rttb::apps::doseMap::ApplicationData appData; /** Main function of dose mapper. @retval 0 normal program execution - @retval 1 showed help or version (flag was set). @retval 2 not enough required input files. - @retval 3 Argument parsing error @retval 4 Error loading input dose file @retval 5 Error loading reference dose file @retval 6 Error loading registration @retval 9 Error while mapping or storing result. */ int main(int argc, const char** argv) { int result = 0; boost::shared_ptr argParser; try { std::string appName = "DoseMap"; std::string appVersion = RTTB_FULL_VERSION_STRING; argParser = boost::make_shared(argc, argv, appName, - appVersion); + appVersion,true); } catch (const std::exception& e) { std::cerr << e.what() << std::endl; - return 5; + return 2; } // This is vital. The application needs to exit if the "help" or "version" parameter is set // because this means the other parameters won't be parsed. if (argParser->isSet(argParser->OPTION_HELP) || argParser->isSet(argParser->OPTION_VERSION)) { return 0; } try{ rttb::apps::doseMap::populateAppData(argParser, appData); } catch (const std::exception& e) { std::cerr << e.what() << std::endl; } std::cout << std::endl << "*******************************************" << std::endl; std::cout << "Input dose file: " << appData._inputDoseFileName << std::endl; std::cout << "Input dose file load style: " << appData._inputDoseLoadStyle.at(0) << std::endl; std::cout << "Output file: " << appData._outputFileName << std::endl; if (!(appData._regFileName.empty())) { std::cout << "Registration file: " << appData._regFileName << std::endl; } if (!(appData._refDoseFileName.empty())) { std::cout << "Reference dose file: " << appData._refDoseFileName << std::endl; std::cout << "Reference dose style: " << appData._refDoseLoadStyle.at(0) << std::endl; } try { appData._inputDose = rttb::apps::doseMap::loadDose(appData._inputDoseFileName, appData._inputDoseLoadStyle); } catch (::itk::ExceptionObject& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e << std::endl; return 4; } catch (std::exception& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e.what() << std::endl; return 4; } catch (...) { std::cerr << "Error!!! unknown error while reading input image." << std::endl; return 4; } if (!(appData._refDoseFileName.empty())) { try { appData._refDose = rttb::apps::doseMap::loadDose(appData._refDoseFileName, appData._refDoseLoadStyle); } catch (::itk::ExceptionObject& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e << std::endl; return 5; } catch (std::exception& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e.what() << std::endl; return 5; } catch (...) { std::cerr << "Error!!! unknown error while reading reference image." << std::endl; return 5; } } else { appData._refDose = appData._inputDose; } if (!(appData._regFileName.empty())) { try { appData._spReg = rttb::apps::doseMap::loadRegistration(appData._regFileName); } catch (::itk::ExceptionObject& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e << std::endl; return 6; } catch (std::exception& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e.what() << std::endl; return 6; } catch (...) { std::cerr << "Error!!! unknown error while reading registration file." << std::endl; return 6; } } else { //generate dummy identity registration typedef map::algorithm::DummyRegistrationAlgorithm<3> DummyRegType; DummyRegType::Pointer regAlg = DummyRegType::New(); appData._spReg = regAlg->getRegistration(); } try { rttb::apps::doseMap::processData(appData); } catch (::itk::ExceptionObject& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e << std::endl; return 9; } catch (std::exception& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e.what() << std::endl; return 9; } catch (...) { std::cerr << "Error!!! unknown error while mapping and writing image." << std::endl; return 9; } std::cout << std::endl; return result; } diff --git a/apps/DoseMap/DoseMapApplicationData.cpp b/apps/DoseMap/DoseMapApplicationData.cpp index a74c8e7..44241b8 100644 --- a/apps/DoseMap/DoseMapApplicationData.cpp +++ b/apps/DoseMap/DoseMapApplicationData.cpp @@ -1,73 +1,72 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision: 1145 $ (last changed revision) // @date $Date: 2015-10-12 17:06:10 +0200 (Mo, 12 Okt 2015) $ (last change date) // @author $Author: hentsch $ (last changed by) */ #include "DoseMapApplicationData.h" namespace rttb { namespace apps { namespace doseMap { ApplicationData:: ApplicationData() { this->reset(); } void ApplicationData:: reset() { _inputDoseFileName = ""; _refDoseFileName = ""; _outputFileName = ""; _regFileName = ""; - _interpolatorName = "linear"; } void populateAppData(boost::shared_ptr argParser, ApplicationData& appData) { appData.reset(); appData._inputDoseFileName = argParser->get(argParser->OPTION_INPUT_DOSE_FILE_NAME); appData._outputFileName = argParser->get(argParser->OPTION_OUTPUT_FILE_NAME); appData._interpolatorName = argParser->get(argParser->OPTION_INTERPOLATOR); appData._regFileName = argParser->get(argParser->OPTION_REG_FILE_NAME); appData._inputDoseLoadStyle = argParser->get > (argParser->OPTION_INPUT_DOSE_LOAD_STYLE); if (!argParser->isSet(argParser->OPTION_REF_DOSE_FILE)){ appData._refDoseFileName = argParser->get(argParser->OPTION_INPUT_DOSE_FILE_NAME); appData._refDoseLoadStyle = argParser->get >(argParser->OPTION_INPUT_DOSE_LOAD_STYLE); } else{ appData._refDoseFileName = argParser->get(argParser->OPTION_REF_DOSE_FILE); appData._refDoseLoadStyle = argParser->get >(argParser->OPTION_REF_DOSE_LOAD_STYLE); } } } } } \ No newline at end of file diff --git a/apps/DoseMap/DoseMapApplicationData.h b/apps/DoseMap/DoseMapApplicationData.h index 13f1f41..a172fbf 100644 --- a/apps/DoseMap/DoseMapApplicationData.h +++ b/apps/DoseMap/DoseMapApplicationData.h @@ -1,76 +1,76 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision: 1221 $ (last changed revision) // @date $Date: 2015-12-01 13:43:31 +0100 (Di, 01 Dez 2015) $ (last change date) // @author $Author: hentsch $ (last changed by) */ #ifndef __DOSEMAP_APPLICATION_DATA_H #define __DOSEMAP_APPLICATION_DATA_H #include "mapRegistration.h" -#include "rttbBaseType.h" + #include "rttbDoseAccessorInterface.h" #include "DoseMapCmdLineParser.h" namespace rttb { namespace apps { namespace doseMap { class ApplicationData { public: typedef map::core::Registration<3, 3> RegistrationType; /**Vector of arguments used to specify the loading style (always the first argument) * and, if needed, additional arguments for the specified loading style (e.g. location of the * Virtuos plan file for the Virtuos IO style). */ typedef std::vector LoadingStyleArgType; /** Loaded Dose.*/ core::DoseAccessorInterface::DoseAccessorPointer _inputDose; std::string _inputDoseFileName; LoadingStyleArgType _inputDoseLoadStyle; core::DoseAccessorInterface::DoseAccessorPointer _refDose; std::string _refDoseFileName; LoadingStyleArgType _refDoseLoadStyle; RegistrationType::Pointer _spReg; std::string _regFileName; std::string _outputFileName; std::string _interpolatorName; void reset(); ApplicationData(); }; /*! @brief Reads the necessary arguments from the DoseToolCmdLineParser and writes them in the respective variables of ApplicationData. */ void populateAppData(boost::shared_ptr argParser, ApplicationData& appData); } } } #endif diff --git a/apps/DoseMap/DoseMapCmdLineParser.cpp b/apps/DoseMap/DoseMapCmdLineParser.cpp index f2b5350..f4a8326 100644 --- a/apps/DoseMap/DoseMapCmdLineParser.cpp +++ b/apps/DoseMap/DoseMapCmdLineParser.cpp @@ -1,121 +1,118 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision: 1145 $ (last changed revision) // @date $Date: 2015-10-12 17:06:10 +0200 (Mo, 12 Okt 2015) $ (last change date) // @author $Author: hentsch $ (last changed by) */ #include "DoseMapCmdLineParser.h" namespace rttb { namespace apps { namespace doseMap { DoseMapCmdLineParser::DoseMapCmdLineParser(int argc, const char** argv, const std::string& name, const std::string& version, bool virtuosSupport) : CmdLineParserBase(name, version), _virtuosSupport(virtuosSupport) { - typedef double DoseTypeGy; - std::vector defaultLoadingStyle; defaultLoadingStyle.push_back("dicom"); - std::string doseLoadStyleDescription = "\"dicom\": normal dicom dose\n" - "\"itk\": use itk image loading\n\"helax\": load a helax dose (choosing this style, the dose path should only be a directory)."; + std::string doseLoadStyleDescription = "Indicates the load style that should be used for the input dose. Available styles: \"dicom\": normal dicom dose (default);" + "\"virtuos\": load of a virtuos dose (This style is a multi argument. The second argument specifies the virtuos plan file, e.g. : \"--loadStyle1 virtuos myFavorite.pln\");" + "\"itk\": use itk image loading; \"helax\": load a helax dose (choosing this style, the dose path should only be a directory)."; addOption(OPTION_INPUT_DOSE_FILE_NAME, OPTION_GROUP_REQUIRED, "The name of the input dose file. Can be omitted if used as positional argument (see above).", 'd', true); + addOption(OPTION_OUTPUT_FILE_NAME, OPTION_GROUP_REQUIRED, "The name of the output file. Can be omitted if used as positional argument (see above).", 'o', true); + addOptionWithDefaultValue(OPTION_INTERPOLATOR, OPTION_GROUP_REQUIRED, "Specifies the interpolator that should be used for mapping." "Available options are: \"nn\": nearest neighbour,\"linear\": linear interpolation, \"rosu\" interpolation based on the concept of Rosu et al.. Default interpolator is \"linear\".", "linear", "linear", 'i', true); addOptionWithDefaultValue(OPTION_REG_FILE_NAME, OPTION_GROUP_REQUIRED, "Specifies name and location of the registration file that should be used to map the input dose. " - "Default is no mapping, thus an identity transform is used. The registration should be stored as MatchPoint registration.", "", "", 'r',true); + "Default is no mapping, thus an identity transform is used. The registration should be stored as MatchPoint registration.", "", "no mapping", 'r',true); addOption(OPTION_REF_DOSE_FILE, OPTION_GROUP_OPTIONAL, "Specifies name and location of the dose file that should be the reference/template for the grid to mapp into. " - "If flag is not specified, the input dose is the reference.", 't');//?? + "If flag is not specified, the input dose is the reference.", 't'); - addOptionWithDefaultValue >(OPTION_INPUT_DOSE_LOAD_STYLE, OPTION_GROUP_REQUIRED, "Indicates the load style that should be used for the input dose." - "Available styles: \"dicom\": normal dicom dose (default); \"virtuos\": load of a virtuos dose (This style is a multi argument. The second argument specifies " - "the virtuos plan file, e.g. : \"--loadStyle1 virtuos myFavorite.pln\"); \"itk\": use itk image loading; \"helax\": load a helax dose (choosing this style, the dose path should only be a directory)." - ,defaultLoadingStyle, defaultLoadingStyle.at(0),'l',true); - addOptionWithDefaultValue >(OPTION_REF_DOSE_LOAD_STYLE, OPTION_GROUP_REQUIRED, "Indicates the load style that should be used for the reference dose." - "Available styles: \"dicom\": normal dicom dose (default); \"virtuos\": load of a virtuos dose (This style is a multi argument. The second argument specifies the virtuos plan file, e.g. : \"--loadStyle2 virtuos myFavorite.pln\"); \"itk\": use itk image loading; \"helax\": load a helax dose (choosing this style, the dose path should only be a directory)." - , defaultLoadingStyle, defaultLoadingStyle.at(0), 's', true); + addOptionWithDefaultValue >(OPTION_INPUT_DOSE_LOAD_STYLE, OPTION_GROUP_REQUIRED, doseLoadStyleDescription, + defaultLoadingStyle, defaultLoadingStyle.at(0),'l',true); + addOptionWithDefaultValue >(OPTION_REF_DOSE_LOAD_STYLE, OPTION_GROUP_OPTIONAL, doseLoadStyleDescription, + defaultLoadingStyle, defaultLoadingStyle.at(0), 's', true); addPositionalOption(OPTION_INPUT_DOSE_FILE_NAME, 1); addPositionalOption(OPTION_OUTPUT_FILE_NAME, 1); - - parse(argc, argv); } void DoseMapCmdLineParser::validateInput() const { auto interpolator = get(OPTION_INTERPOLATOR); if (interpolator != "nn" && interpolator != "linear" && interpolator != "rosu") { - throw cmdlineparsing::InvalidConstraintException("Unknown interpolator:" + + throw cmdlineparsing::InvalidConstraintException("Unknown interpolator: " + interpolator + ".\nPlease refer to the help for valid interpolator settings."); } - std::vector indoseLoadStyle = get >(OPTION_INPUT_DOSE_LOAD_STYLE); - std::string indoseLoadStyleAbbreviation = indoseLoadStyle.at(0); + std::vector inputDoseLoadStyle = get >(OPTION_INPUT_DOSE_LOAD_STYLE); + std::string indoseLoadStyleAbbreviation = inputDoseLoadStyle.at(0); if (indoseLoadStyleAbbreviation != "dicom" && indoseLoadStyleAbbreviation != "virtuos" && indoseLoadStyleAbbreviation != "itk" && indoseLoadStyleAbbreviation != "helax") { - throw cmdlineparsing::InvalidConstraintException("Unknown load style for input dose file:" + + throw cmdlineparsing::InvalidConstraintException("Unknown load style for input dose file: " + indoseLoadStyleAbbreviation + ".\nPlease refer to the help for valid loading style settings."); } - std::vector refdoseLoadStyle = get >(OPTION_REF_DOSE_LOAD_STYLE); - std::string refdoseLoadStyleAbbreviation = refdoseLoadStyle.at(0); - if (refdoseLoadStyleAbbreviation != "dicom" && refdoseLoadStyleAbbreviation != "virtuos" - && refdoseLoadStyleAbbreviation != "itk" && refdoseLoadStyleAbbreviation != "helax") - { - throw cmdlineparsing::InvalidConstraintException("Unknown load style for referenz dose file:" + - refdoseLoadStyleAbbreviation + - ".\nPlease refer to the help for valid loading style settings."); + if (isSet(OPTION_REF_DOSE_FILE)){ + std::vector refDoseLoadStyle = get >(OPTION_REF_DOSE_LOAD_STYLE); + std::string refDoseLoadStyleAbbreviation = refDoseLoadStyle.at(0); + if (refDoseLoadStyleAbbreviation != "dicom" && refDoseLoadStyleAbbreviation != "virtuos" + && refDoseLoadStyleAbbreviation != "itk" && refDoseLoadStyleAbbreviation != "helax") + { + throw cmdlineparsing::InvalidConstraintException("Unknown load style for reference dose file: " + + refDoseLoadStyleAbbreviation + + ".\nPlease refer to the help for valid loading style settings."); + } } - } void DoseMapCmdLineParser::printHelp() const { cmdlineparsing::CmdLineParserBase::printHelp(); std::cout << "Example:" << std::endl << std::endl; std::cout << m_programName << - " dose1.mhd result.mhd -r reg.mapr --inputDoseLoadStyle itk --loadStyleReference itk" << + " dose1.mhd result.mhd -r reg.mapr --" << OPTION_INPUT_DOSE_LOAD_STYLE << " itk --" << OPTION_REF_DOSE_LOAD_STYLE+ " itk" << std::endl << std::endl; std::cout << "This will map \"dose1.mhd\" by using \"reg.mapr\" into the grid geometry of the input dose. The resulting dose will be stored in \"result.mhd\"." << std::endl; } } } } diff --git a/testing/apps/DoseMap/CMakeLists.txt b/testing/apps/DoseMap/CMakeLists.txt index 7e1ab18..0235e70 100644 --- a/testing/apps/DoseMap/CMakeLists.txt +++ b/testing/apps/DoseMap/CMakeLists.txt @@ -1,30 +1,30 @@ #----------------------------------------------------------------------------- # Setup the system information test. Write out some basic failsafe # information in case the test doesn't run. #----------------------------------------------------------------------------- SET(DOSEMAP_TEST ${EXECUTABLE_OUTPUT_PATH}/rttbDoseMapTests) SET(TEST_DATA_ROOT ${RTTBTesting_SOURCE_DIR}/data) SET(TEMP ${RTTBTesting_BINARY_DIR}/temporary) #----------------------------------------------------------------------------- IF(MSVC) ADD_DEFINITIONS(/bigobj) ENDIF() IF (WIN32) SET(DOSEMAPEXE "DoseMap.exe") ELSE (WIN32) SET(DOSEMAPEXE "./DoseMap") ENDIF (WIN32) ADD_TEST(DoseMapInvalidParametersTest ${DOSEMAP_TEST} DoseMapInvalidParametersTest ${DOSEMAPEXE}) -ADD_TEST(DoseMapSimpleTest ${DOSEMAP_TEST} DoseMapSimpleTest ${DOSEMAPEXE} "${TEST_DATA_ROOT}/DoseMap/input.mhd" "${TEST_DATA_ROOT}/DoseMap/outputfile.mhd" "-l itk" "-r ${TEST_DATA_ROOT}/DoseMap/Identity.mapr" ) +ADD_TEST(DoseMapSimpleTest ${DOSEMAP_TEST} DoseMapSimpleTest ${DOSEMAPEXE} "${TEST_DATA_ROOT}/DoseMap/input.mhd" "${TEST_DATA_ROOT}/DoseMap/outputfile.mhd" "itk" "${TEST_DATA_ROOT}/DoseMap/Identity.mapr" ) RTTB_CREATE_APPLICATION_TESTS(DoseMap PACKAGE_DEPENDS Litmus BoostBinaries) diff --git a/testing/apps/DoseMap/DoseMapInvalidParametersTest.cpp b/testing/apps/DoseMap/DoseMapInvalidParametersTest.cpp index e924586..960224d 100644 --- a/testing/apps/DoseMap/DoseMapInvalidParametersTest.cpp +++ b/testing/apps/DoseMap/DoseMapInvalidParametersTest.cpp @@ -1,78 +1,74 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision: 1221 $ (last changed revision) // @date $Date: 2015-12-01 13:43:31 +0100 (Di, 01 Dez 2015) $ (last change date) // @author $Author: hentsch $ (last changed by) */ #include #include "litCheckMacros.h" #include "boost/filesystem.hpp" namespace rttb { namespace testing { //path to the current running directory. DoseMap is in the same directory (Debug/Release) extern const char* _callingAppPath; int DoseMapInvalidParametersTest(int argc, char* argv[]) { PREPARE_DEFAULT_TEST_REPORTING; std::string doseMapExecutable; if (argc > 1) { doseMapExecutable = argv[1]; } boost::filesystem::path callingPath(_callingAppPath); std::string doseMapExeWithPath = callingPath.parent_path().string() + "/" + doseMapExecutable; //call with too few parameters - std::string toofewParametersCommand = doseMapExeWithPath; - toofewParametersCommand += " -d test"; + std::string toofewParametersCommand = doseMapExeWithPath + " -d test"; std::cout << "Command line call: " + toofewParametersCommand << std::endl; CHECK_EQUAL(system(toofewParametersCommand.c_str()) != 0, true); - toofewParametersCommand = doseMapExeWithPath; - toofewParametersCommand += " test"; + toofewParametersCommand = doseMapExeWithPath + " test"; std::cout << "Command line call: " + toofewParametersCommand << std::endl; CHECK_EQUAL(system(toofewParametersCommand.c_str()) != 0, true); //call with invalid dose load option std::string minimalCLI = doseMapExeWithPath + " test test "; - std::string invalidDoseLoadOption = minimalCLI; - invalidDoseLoadOption += "-l wrongOption"; + std::string invalidDoseLoadOption = minimalCLI + "-l wrongOption"; std::cout << "Command line call: " + invalidDoseLoadOption << std::endl; CHECK_EQUAL(system(invalidDoseLoadOption.c_str()) != 0, true); //call with invalid interpolator - std::string invalidStructLoadOption = minimalCLI; - invalidStructLoadOption += "-i wrongOption"; - std::cout << "Command line call: " + invalidStructLoadOption << std::endl; - CHECK_EQUAL(system(invalidStructLoadOption.c_str()) != 0, true); + std::string invalidInterpolatorOption = minimalCLI + "-i wrongOption"; + std::cout << "Command line call: " + invalidInterpolatorOption << std::endl; + CHECK_EQUAL(system(invalidInterpolatorOption.c_str()) != 0, true); RETURN_AND_REPORT_TEST_SUCCESS; } } //namespace testing } //namespace rttb diff --git a/testing/apps/DoseMap/DoseMapSimpleTest.cpp b/testing/apps/DoseMap/DoseMapSimpleTest.cpp index eb143c2..4fc6b49 100644 --- a/testing/apps/DoseMap/DoseMapSimpleTest.cpp +++ b/testing/apps/DoseMap/DoseMapSimpleTest.cpp @@ -1,99 +1,94 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision: 1221 $ (last changed revision) // @date $Date: 2015-12-01 13:43:31 +0100 (Di, 01 Dez 2015) $ (last change date) // @author $Author: hentsch $ (last changed by) */ #include -#include -#include + + #include "litCheckMacros.h" #include "boost/filesystem.hpp" -#include "boost/algorithm/string.hpp" + namespace rttb { namespace testing { //path to the current running directory. DoseMap is in the same directory (Debug/Release) extern const char* _callingAppPath; static std::string readFile(const std::string& filename); int DoseMapSimpleTest(int argc, char* argv[]) { PREPARE_DEFAULT_TEST_REPORTING; std::string doseMapExecutable; std::string regFilename; std::string inputFilename; std::string outputFilename; std::string refDoseLoadStyle; std::string inputDoseLoadStyle; boost::filesystem::path callingPath(_callingAppPath); if (argc > 5 ) { doseMapExecutable = argv[1]; inputFilename = argv[2]; outputFilename = argv[3]; inputDoseLoadStyle = argv[4]; regFilename = argv[5]; - //refDoseLoadStyle = argv[5]; + } //check if file exists - std::cout << "outputFilename" << outputFilename << std::endl <<"inputfilename"<< inputFilename << std::endl; - CHECK_EQUAL(boost::filesystem::exists(outputFilename), true); - CHECK_EQUAL(boost::filesystem::exists(inputFilename), true); - std::string doseToolExeWithPath = callingPath.parent_path().string() + "/" + doseMapExecutable; - std::string baseCommand = doseToolExeWithPath +" "+ inputFilename +" "+ outputFilename; + + std::string doseMapExeWithPath = callingPath.parent_path().string() + "/" + doseMapExecutable; + std::string baseCommand = doseMapExeWithPath +" "+ inputFilename +" "+ outputFilename; - std::string defaultDoseStatisticsCommand = baseCommand+" "+ inputDoseLoadStyle; + std::string defaultDoseStatisticsCommand = baseCommand+" -l "+ inputDoseLoadStyle; std::cout << "Command line call: " + defaultDoseStatisticsCommand << std::endl; CHECK_EQUAL(system(defaultDoseStatisticsCommand.c_str()), 0); + CHECK_EQUAL(boost::filesystem::exists(outputFilename), true); + CHECK_EQUAL(std::remove(outputFilename.c_str()),0); - std::string defaultDoseStatisticsCommandwithregistration = defaultDoseStatisticsCommand+ " " + regFilename; + std::string defaultDoseStatisticsCommandwithregistration = defaultDoseStatisticsCommand+ " -r " + regFilename; std::cout << "Command line call: " + defaultDoseStatisticsCommandwithregistration << std::endl; CHECK_EQUAL(system(defaultDoseStatisticsCommandwithregistration.c_str()), 0); + CHECK_EQUAL(boost::filesystem::exists(outputFilename), true); + CHECK_EQUAL(std::remove(outputFilename.c_str()), 0); - RETURN_AND_REPORT_TEST_SUCCESS; - } - std::string readFile(const std::string& filename) - { - std::ifstream fileStream(filename.c_str()); - std::string content((std::istreambuf_iterator(fileStream)), - (std::istreambuf_iterator())); - return content; + RETURN_AND_REPORT_TEST_SUCCESS; } } //namespace testing } //namespace rttb