diff --git a/demoapps/VoxelizerTool/rttbCommandOptions.cpp b/demoapps/VoxelizerTool/rttbCommandOptions.cpp index 6c9756f..544ae84 100644 --- a/demoapps/VoxelizerTool/rttbCommandOptions.cpp +++ b/demoapps/VoxelizerTool/rttbCommandOptions.cpp @@ -1,142 +1,144 @@ // ----------------------------------------------------------------------- // 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: 5603 $ (last changed revision) // @date $Date: 2015-08-24 15:17:30 +0200 (Mo, 24 Aug 2015) $ (last change date) // @author $Author: strubel $ (last changed by) */ #include #include "rttbCommandOptions.h" #include "rttbVoxelizerHelper.h" namespace rttb { namespace apps { namespace voxelizer { CommandOptions::CommandOptions(): PARAM_HELP("help"), PARAM_STRUCT_FILE("structFile"), PARAM_REFERENCE_FILE("referenceFile"), PARAM_OUT_FILE("output"), PARAM_REGEX("struct"), PARAM_MULTISTRUCT("multipleStructs"), PARAM_LEGACY_VOXELIZATION("legacyVoxelization"), PARAM_BOOST_VOXELIZATION("boostVoxelization"), PARAM_BOOLEAN_VOXELIZATION("booleanVoxelization"), PARAM_ADDSTRUCTURES("addStructures") { _params.multipleStructs = false; _params.legacyVoxelization = false; _params.booleanVoxelization = false; _params.addStructures = false; + _returnAfterHelp = false; po::options_description required("Required arguments"); addOption(required, PARAM_STRUCT_FILE, "s", po::value(&_params.structFile)->required(), "Filename of the structfile (*.dcm)"); addOption(required, PARAM_REFERENCE_FILE, "r", po::value(&_params.referenceFile)->required(), "Filename of the reference image (*.dcm)"); addOption(required, PARAM_REGEX, "e", po::value>(&_params.regEx)->multitoken()->required(), "set a regular expression describing the structs of interest"); addOption(required, PARAM_OUT_FILE, "o", po::value(&_params.outputFilename)->default_value("out.hdr")->required(), "set output file name "); addOption(required, PARAM_BOOST_VOXELIZATION, "b", po::bool_switch()->default_value(true), "to use boost voxelization"); po::options_description optional("Optional arguments"); addOption(optional, PARAM_HELP, "h", nullptr, "Display help message"); addOption(optional, PARAM_MULTISTRUCT, "m", po::bool_switch(&_params.multipleStructs)->default_value(false), "if multiple structs match the regular expression (--struct), save all in files"); addOption(optional, PARAM_LEGACY_VOXELIZATION, "l", po::bool_switch(&_params.legacyVoxelization)->default_value(false), "to use legacy voxelization"); addOption(optional, PARAM_BOOLEAN_VOXELIZATION, "v", po::bool_switch(&_params.booleanVoxelization)->default_value(false), "Determines if the voxelization should be binarized (only values 0 or 1)"); addOption(optional, PARAM_ADDSTRUCTURES, "a", nullptr, ""); _description.add(required).add(optional); } void CommandOptions::addOption(po::options_description& o, const std::string& name, const std::string& shortcut, const po::value_semantic* valueSemantic, const std::string& description) { if (valueSemantic) { o.add_options()((name + std::string(",") + shortcut).c_str(), valueSemantic, description.c_str()); } else { o.add_options()((name + std::string(",") + shortcut).c_str(), description.c_str()); } } void CommandOptions::showHelp() const { std::cout << "Usage: VoxelizerTool [options] \n"; std::cout << _description << std::endl; std::cout << "Example: VoxelizerTool -s structFile.dcm -r referenceFile.dcm -e Kidney -o outputFile.mhd -m" << std::endl; std::cout << "Computes a voxelization file outputFile.mhd based on the DICOMRT-STRUCT structFile.dcm in the geometry of referenceFile.dcm where"; std::cout << "the name of the struct matches the regular expression 'Kidney'." << std::endl; std::cout << "If structures 'Kidney_left' and 'Kidney_right' are defined, "; std::cout << "both are written under the names outputFile_Kidney_left.mhd and outputFile_Kidney_right.mhd (parameter -m)." << std::endl; } bool CommandOptions::command(int argc, char* argv[]) { try { po::variables_map var; po::store(po::command_line_parser(argc, argv).options(_description).run(), var); if (var.count(PARAM_HELP)) { showHelp(); + _returnAfterHelp = true; return true; } po::notify(var); if (var.count(PARAM_BOOST_VOXELIZATION)) { _params.legacyVoxelization = false; } if (var.count(PARAM_ADDSTRUCTURES)) { _params.addStructures = true; _params.multipleStructs = false; } } catch (const std::exception& e) { std::cout << "Error: " << e.what() << std::endl; return false; } return true; } } } } \ No newline at end of file diff --git a/demoapps/VoxelizerTool/rttbCommandOptions.h b/demoapps/VoxelizerTool/rttbCommandOptions.h index 30d6698..1dc620a 100644 --- a/demoapps/VoxelizerTool/rttbCommandOptions.h +++ b/demoapps/VoxelizerTool/rttbCommandOptions.h @@ -1,121 +1,123 @@ // ----------------------------------------------------------------------- // 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: 5506 $ (last changed revision) // @date $Date: 2015-07-30 14:45:24 +0200 (Do, 30 Jul 2015) $ (last change date) // @author $Author: strubel $ (last changed by) */ #ifndef __CommandOptions_h #define __CommandOptions_h #include namespace rttb { namespace apps { namespace voxelizer { namespace po = boost::program_options; /** @brief Simple struct holding all variables. */ struct Parameters { /** @brief Filename of the StructFile*/ std::string structFile; /** @brief Filename of the ReferenceFile*/ std::string referenceFile; /** @brief Output Filename*/ std::string outputFilename; /** @brief Expressions from User*/ std::vector regEx; /** @brief for more than one struct*/ bool multipleStructs; /** @brief add: legacyVoxelization=false means boostVoxelization is turned on*/ bool legacyVoxelization; /** @brief voxelization should be binarized to value 0 or 1 */ bool booleanVoxelization ; /** @brief multiple structures voxelization should be combined in one file*/ bool addStructures; }; /*! @class CommandOptions @brief CommandOptions Class, everything about the command line */ class CommandOptions { public: /** @details add the description for command line options * add parameter --h or --help for help informations, * --Structfile= to set a struct file, * --Reference= to set the reference file, * --Output= to set an output file name and * --struct= to add an expression like(SPINE). */ CommandOptions(); /** @brief Validates the given input parameters and fills the corresponding variables. @param argc Number of arguments. @param argv Array of individual arguments. @return true if all arguments were valid (i.e. none were missing or incorrect), otherwise false. */ bool command(int argc, char* argv[]); const Parameters& getParameters() const { return _params; } + bool isReturnAfterHelp() const + { + return _returnAfterHelp; + } private: /** *@brief Adds an option to the given option container. *@param o Option container the new option should be added to. *@param name Name of the new option (i.e. the actual parameter, e.g. "test" adds the option with the parameter "--test"). *@param shortcut A single letter that is used as a shortcut for this option (e.g. if the name is "test, the shortcut might be "t", so you can call the parameter with "-t" instead of "--test"). *@param valueSemantic The desired value semantic object, i.e. the object that binds this option's value to a variable. *@param description The description text for this option. */ void addOption(po::options_description& o, const std::string& name, const std::string& shortcut, const po::value_semantic* valueSemantic, const std::string& description); /*! @brief print out the dicription.*/ void showHelp()const; const std::string PARAM_STRUCT_FILE; const std::string PARAM_REFERENCE_FILE; const std::string PARAM_OUT_FILE; const std::string PARAM_REGEX; const std::string PARAM_MULTISTRUCT; const std::string PARAM_HELP; const std::string PARAM_LEGACY_VOXELIZATION; const std::string PARAM_BOOST_VOXELIZATION; const std::string PARAM_BOOLEAN_VOXELIZATION; const std::string PARAM_ADDSTRUCTURES; /*! create description object */ po::options_description _description; Parameters _params; - - /**@brief minimum arguments that must be present on the Command Line*/ - int _minArguments; + bool _returnAfterHelp; }; } } } #endif \ No newline at end of file diff --git a/demoapps/VoxelizerTool/rttbVoxelizerHelper.cpp b/demoapps/VoxelizerTool/rttbVoxelizerHelper.cpp index 59fc5ae..df4a12d 100644 --- a/demoapps/VoxelizerTool/rttbVoxelizerHelper.cpp +++ b/demoapps/VoxelizerTool/rttbVoxelizerHelper.cpp @@ -1,82 +1,82 @@ // ----------------------------------------------------------------------- // 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: 5603 $ (last changed revision) // @date $Date: 2015-08-24 15:17:30 +0200 (Mo, 24 Aug 2015) $ (last change date) // @author $Author: strubel $ (last changed by) */ #include "rttbVoxelizerHelper.h" #include #include #include -#include namespace rttb { namespace apps { namespace voxelizer { std::vector filterForExpression(const std::vector& listOfExpressions, const std::string& inputExpression) { std::vector listOfFoundElements; for (int j = 0; j < listOfExpressions.size(); j++) { boost::regex e(boost::algorithm::to_lower_copy(inputExpression)); std::string s = boost::algorithm::to_lower_copy(listOfExpressions.at(j)); if (boost::regex_match(s, e)) { listOfFoundElements.push_back(j); } } return listOfFoundElements; } - std::string getLabelFromList(std::vector listOfExpressions, int j) + void removeSpecialCharacters(std::string& label) { - //Replace / to avoid problems with directories (struct "Magen/DD" --> Magen/DD.mhd), delete trailing . to avoid filenames with two trailing points (Niere re. --> Niere re..mhd) - listOfExpressions.at(j).replace(listOfExpressions.at(j).find("/"), 1, "_"); - if (listOfExpressions.at(j).substr(listOfExpressions.at(j).size() - 1) == ".") + //Replace / to avoid problems with directories (struct "Magen/DD" --> Magen/DD.mhd), delete trailing . to avoid filenames with two trailing points (Niere re. --> Niere re..mhd) + while (label.find("/") != std::string::npos) { - listOfExpressions.at(j).replace(listOfExpressions.at(j).size() - 1, 1, ""); + label.replace(label.find("/"), 1, "_"); } - std::cout << listOfExpressions.at(j) << std::endl; - return listOfExpressions.at(j); + if (*label.rbegin() == '.') + { + label.replace(label.size() - 1, 1, ""); + } } std::string getFilenameWithoutEnding(const std::string& outfilename) { boost::filesystem::path p(outfilename); return p.stem().string(); } std::string getFileEnding(const std::string& outfilename) { boost::filesystem::path p(outfilename); return p.extension().string(); } } } } \ No newline at end of file diff --git a/demoapps/VoxelizerTool/rttbVoxelizerHelper.h b/demoapps/VoxelizerTool/rttbVoxelizerHelper.h index 328a111..ad5c3a2 100644 --- a/demoapps/VoxelizerTool/rttbVoxelizerHelper.h +++ b/demoapps/VoxelizerTool/rttbVoxelizerHelper.h @@ -1,44 +1,44 @@ // ----------------------------------------------------------------------- // 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: 5603 $ (last changed revision) // @date $Date: 2015-08-24 15:17:30 +0200 (Mo, 24 Aug 2015) $ (last change date) // @author $Author: strubel $ (last changed by) */ #include #include namespace rttb { namespace apps { namespace voxelizer { /**@brief ListofExpression contains input expression @return a vector of found labels */ std::vector filterForExpression(const std::vector& listOfExpressions, const std::string& inputExpression); /**@brief Search the label with the position from index @return a label from the list as string */ - std::string getLabelFromList(std::vector listOfExpressions, int index); + void removeSpecialCharacters(std::string& label); std::string getFilenameWithoutEnding(const std::string& outfilename); std::string getFileEnding(const std::string& outfilename); } } } \ No newline at end of file diff --git a/demoapps/VoxelizerTool/rttbVoxelizerTool.cpp b/demoapps/VoxelizerTool/rttbVoxelizerTool.cpp index efb28d7..2def25d 100644 --- a/demoapps/VoxelizerTool/rttbVoxelizerTool.cpp +++ b/demoapps/VoxelizerTool/rttbVoxelizerTool.cpp @@ -1,156 +1,148 @@ // ----------------------------------------------------------------------- // 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: 5603 $ (last changed revision) // @date $Date: 2015-08-24 15:17:30 +0200 (Mo, 24 Aug 2015) $ (last change date) // @author $Author: strubel $ (last changed by) */ #include #include "rttbVoxelizerHelper.h" #include "rttbMaskProcess.h" #include "rttbMaskWriter.h" #include "rttbStructDataReader.h" #include "rttbCommandOptions.h" int main(int argc, char* argv[]) { typedef rttb::core::MaskAccessorInterface::MaskAccessorPointer MaskAccessorPointer; boost::shared_ptr co = boost::make_shared(); if (!co->command(argc, argv)) { return EXIT_FAILURE; } + if (co->isReturnAfterHelp()) + { + return EXIT_SUCCESS; + } + rttb::apps::voxelizer::Parameters params = co->getParameters(); - if (!params.structFile.empty() && !params.referenceFile.empty()) + boost::shared_ptr SDR; + + try + { + SDR = boost::make_shared(params.structFile, + params.referenceFile); + } + catch (rttb::core::Exception& e) { - boost::shared_ptr SDR; + std::cerr << "RTTB Error!!!" << std::endl; + std::cerr << e.what() << std::endl; + return 1; + } + catch (const std::exception& e) + { + std::cerr << "Error!!!" << std::endl; + std::cerr << e.what() << std::endl; + return 1; + } + catch (...) + { + std::cerr << "Error!!! unknown error while reading input image." << std::endl; + return 1; + } - try - { - SDR = boost::make_shared(params.structFile, - params.referenceFile); - } - catch (rttb::core::Exception& e) - { - std::cerr << "RTTB Error!!!" << std::endl; - std::cerr << e.what() << std::endl; - return 1; - } - catch (const std::exception& e) - { - std::cerr << "Error!!!" << std::endl; - std::cerr << e.what() << std::endl; - return 1; - } - catch (...) - { - std::cerr << "Error!!! unknown error while reading input image." << std::endl; - return 1; - } + std::vector listOfCorrectElements; + + for (int i = 0; i < params.regEx.size(); i++) + { + std::vector indexOfCorrectElements; + indexOfCorrectElements = rttb::apps::voxelizer::filterForExpression(SDR->getAllLabels(), + params.regEx.at(i)); + std::copy(indexOfCorrectElements.begin(), indexOfCorrectElements.end(), std::back_inserter(listOfCorrectElements)); + } + + boost::shared_ptr MP = + boost::make_shared(SDR->getStructureSetPointer(), + SDR->getDoseAccessorPointer(), + params.legacyVoxelization); + + if (!listOfCorrectElements.empty()) + { + std::string fileName = rttb::apps::voxelizer::getFilenameWithoutEnding( + params.outputFilename); + std::string fileEnding = rttb::apps::voxelizer::getFileEnding(params.outputFilename); - std::vector listOfCorrectElements; + std::vector maskVector; - for (int i = 0; i < params.regEx.size(); i++) + if (params.addStructures) { - std::vector indexOfCorrectElements; - indexOfCorrectElements = rttb::apps::voxelizer::filterForExpression(SDR->getAllLabels(), - params.regEx.at(i)); + std::string labelName; - for (int k = 0 ; k < indexOfCorrectElements.size() ; k++) + for (int i = 0; i < listOfCorrectElements.size(); i++) { - listOfCorrectElements.push_back(indexOfCorrectElements.at(k)); + maskVector.push_back(MP->createMask(listOfCorrectElements.at(i))); + int labelIndex = listOfCorrectElements.at(i); + std::vector labelVector = SDR->getAllLabels(); + std::string labelOfInterest = labelVector.at(labelIndex); + rttb::apps::voxelizer::removeSpecialCharacters(labelOfInterest); + labelName += "_" + labelOfInterest; + } - } - boost::shared_ptr MP = - boost::make_shared(SDR->getStructureSetPointer(), - SDR->getDoseAccessorPointer(), - params.legacyVoxelization); + boost::shared_ptr MW = + boost::make_shared(maskVector, + params.booleanVoxelization); + MW->writeMaskToFile(fileName + labelName + fileEnding); - if (!listOfCorrectElements.empty()) + } + else { - std::string fileName = rttb::apps::voxelizer::getFilenameWithoutEnding( - params.outputFilename); - std::string fileEnding = rttb::apps::voxelizer::getFileEnding(params.outputFilename); - - std::vector maskPointer; + unsigned int maxIterationCount = 1; - if (params.addStructures) + if (params.multipleStructs) { - std::string labelName; - - for (int i = 0; i < listOfCorrectElements.size(); i++) - { - maskPointer.push_back(MP->createMask(listOfCorrectElements.at(i))); - - labelName += "_" + rttb::apps::voxelizer::getLabelFromList(SDR->getAllLabels(), - listOfCorrectElements.at(i)); - } + maxIterationCount = listOfCorrectElements.size(); + } + for (unsigned int i = 0; i < maxIterationCount; i++) + { + maskVector.push_back(MP->createMask(listOfCorrectElements.at(i))); + int labelIndex = listOfCorrectElements.at(i); + std::vector labelVector = SDR->getAllLabels(); + std::string labelOfInterest = labelVector.at(labelIndex); + rttb::apps::voxelizer::removeSpecialCharacters(labelOfInterest); boost::shared_ptr MW = - boost::make_shared(maskPointer, + boost::make_shared(maskVector, params.booleanVoxelization); - MW->writeMaskToFile(fileName + labelName + fileEnding); + MW->writeMaskToFile(fileName + "_" + labelOfInterest + fileEnding); } - else - { - std::string labelName; - - if (params.multipleStructs) - { - for (unsigned int i = 0; i < listOfCorrectElements.size(); i++) - { - maskPointer.push_back(MP->createMask(listOfCorrectElements.at(i))); - - labelName = rttb::apps::voxelizer::getLabelFromList(SDR->getAllLabels(), - listOfCorrectElements.at(i)); - boost::shared_ptr MW = - boost::make_shared(maskPointer, - params.booleanVoxelization); - MW->writeMaskToFile(fileName + "_" + labelName + fileEnding); - } - } - else - { - maskPointer.push_back(MP->createMask(listOfCorrectElements.at(0))); - - labelName = rttb::apps::voxelizer::getLabelFromList(SDR->getAllLabels(), - listOfCorrectElements.at(0)); - boost::shared_ptr MW = - boost::make_shared(maskPointer, - params.booleanVoxelization); - MW->writeMaskToFile(fileName + "_" + labelName + fileEnding); - - } - - } - } - else - { - std::cout << "No struct found" << std::endl; } } + else + { + std::cout << "No struct found" << std::endl; + } return EXIT_SUCCESS; } diff --git a/testing/demoapps/VoxelizerTool/CMakeLists.txt b/testing/demoapps/VoxelizerTool/CMakeLists.txt index 1bbb2fd..b943c2d 100644 --- a/testing/demoapps/VoxelizerTool/CMakeLists.txt +++ b/testing/demoapps/VoxelizerTool/CMakeLists.txt @@ -1,27 +1,27 @@ #----------------------------------------------------------------------------- # Setup the system information test. Write out some basic failsafe # information in case the test doesn't run. #----------------------------------------------------------------------------- SET(VoxelizerTool_TESTS ${EXECUTABLE_OUTPUT_PATH}/RTTBVoxelizerToolTests) SET(TEST_DATA_ROOT ${RTTBTesting_SOURCE_DIR}/data) SET(TEST_DATA ${RTToolbox_BINARY_DIR}/Testing/demoapps/VoxelizerTool) SET(VOXELIZERTOOL_EXE "VoxelizerTool") SET(STRUCT_FILE "${TEST_DATA_ROOT}/DICOM/StructureSet/RS1.3.6.1.4.1.2452.6.841242143.1311652612.1170940299.4217870819.dcm") SET(REFERENCE_FILE "${TEST_DATA_ROOT}/DICOM/TestDose/ConstantTwo.dcm") #----------------------------------------------------------------------------- ADD_TEST(rttbVoxelizerToolIncorrectCommandsTest ${VoxelizerTool_TESTS} VoxelizerToolIncorrectCommandsTest "${VOXELIZERTOOL_EXE}" ${STRUCT_FILE} "${TEST_DATA_ROOT}/DICOM/StructureSet/Wrong_Data_Struct_file.dicom" ${REFERENCE_FILE} "${TEST_DATA_ROOT}/DICOM/TestDose/Wrong_Reference_file.dicom" "Rueckenmark" "blabla") ADD_TEST(rttbVoxelizerToolVoxelizerAllStructsTest ${VoxelizerTool_TESTS} VoxelizerToolVoxelizerAllStructsTest "${VOXELIZERTOOL_EXE}" ${TEST_DATA} ${STRUCT_FILE} ${REFERENCE_FILE} ) -#ADD_TEST(rttbVoxelizerToolDifferentCommandsTest ${VoxelizerTool_TESTS} VoxelizerToolDifferentCommandsTest -#"${VOXELIZERTOOL_EXE}" ${TEST_DATA} ${STRUCT_FILE} ${REFERENCE_FILE}) -#ADD_TEST(rttbVoxelizerToolVoxelizerBoostLegacyTest ${VoxelizerTool_TESTS} VoxelizerToolVoxelizerBoostLegacy -#"${VOXELIZERTOOL_EXE}" ${TEST_DATA} ${STRUCT_FILE} ${REFERENCE_FILE}) -#ADD_TEST(rttbVoxelizerToolVoxelValueTest ${VoxelizerTool_TESTS} VoxelizerToolVoxelValue -#"${VOXELIZERTOOL_EXE}" ${TEST_DATA} ${STRUCT_FILE} ${REFERENCE_FILE} "Leber") +ADD_TEST(rttbVoxelizerToolDifferentCommandsTest ${VoxelizerTool_TESTS} VoxelizerToolDifferentCommandsTest +"${VOXELIZERTOOL_EXE}" ${TEST_DATA} ${STRUCT_FILE} ${REFERENCE_FILE}) +ADD_TEST(rttbVoxelizerToolVoxelizerBoostLegacyTest ${VoxelizerTool_TESTS} VoxelizerToolVoxelizerBoostLegacy +"${VOXELIZERTOOL_EXE}" ${TEST_DATA} ${STRUCT_FILE} ${REFERENCE_FILE}) +ADD_TEST(rttbVoxelizerToolVoxelValueTest ${VoxelizerTool_TESTS} VoxelizerToolVoxelValue +"${VOXELIZERTOOL_EXE}" ${TEST_DATA} ${STRUCT_FILE} ${REFERENCE_FILE} "Leber") RTTB_CREATE_TEST_MODULE(RTTBVoxelizerTool DEPENDS RTTBITKIO RTTBCore RTTBMasks RTTBOTBMask RTTBBoostMask RTTBDicomIO RTTBOtherIO PACKAGE_DEPENDS Litmus) diff --git a/testing/demoapps/VoxelizerTool/rttbVoxelizerToolDifferentCommandsTest.cpp b/testing/demoapps/VoxelizerTool/rttbVoxelizerToolDifferentCommandsTest.cpp index 7052e2b..7620cd9 100644 --- a/testing/demoapps/VoxelizerTool/rttbVoxelizerToolDifferentCommandsTest.cpp +++ b/testing/demoapps/VoxelizerTool/rttbVoxelizerToolDifferentCommandsTest.cpp @@ -1,105 +1,110 @@ // ----------------------------------------------------------------------- // 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: 5603 $ (last changed revision) // @date $Date: 2015-08-24 15:17:30 +0200 (Mo, 24 Aug 2015) $ (last change date) // @author $Author: strubel $ (last changed by) */ #include "litCheckMacros.h" #include #include #include /*! @brief VoxelizerToolTest3. Test the output, multipleStructs and the booleanVoxelization parameter. */ namespace rttb { namespace testing { //path to the current running directory. VoxelizerTool is in the same directory (Debug/Release) extern const char* _callingAppPath; int VoxelizerToolDifferentCommandsTest(int argc, char* argv[]) { PREPARE_DEFAULT_TEST_REPORTING; std::string voxelizerToolExe; std::string tempDirectory; std::string structFile; std::string referenceFile; if (argc > 4) { voxelizerToolExe = argv[1]; tempDirectory = argv[2]; structFile = argv[3]; referenceFile = argv[4]; } std::vector commands; commands.push_back("\"Niere.*\" -m -o Test.hdr"); commands.push_back("\"Leber\" -o Boolean.hdr -v"); std::vector filenames; filenames.push_back("Test_Niere li"); filenames.push_back("Test_Niere re"); filenames.push_back("Boolean_Leber"); boost::filesystem::path callingPath(_callingAppPath); std::string voxelizerToolExeWithPath = callingPath.parent_path().string() + "/" + voxelizerToolExe; std::string baseCommand = voxelizerToolExeWithPath; baseCommand += " -s " + structFile; baseCommand += " -r " + referenceFile; baseCommand += " -e "; for (int i = 0; i < commands.size(); i++) { std::string command = baseCommand + commands.at(i); int returnValue = system(command.c_str()); std::cout << "Command line call: " + command << std::endl; CHECK_EQUAL(returnValue, 0); } + std::string helpCommand = voxelizerToolExeWithPath + " -h"; + int returnValue = system(helpCommand.c_str()); + std::cout << "Command line call: " + helpCommand << std::endl; + CHECK_EQUAL(returnValue, 0); + for (int i = 0; i < filenames.size(); i++) { const std::string HDRfileName = tempDirectory + "/" + filenames.at(i) + ".hdr"; boost::filesystem::path HDRFile(HDRfileName); const std::string IMGfileName = tempDirectory + "/" + filenames.at(i) + ".img"; boost::filesystem::path IMGFile(IMGfileName); CHECK_EQUAL(boost::filesystem::exists(HDRFile), true); CHECK_EQUAL(boost::filesystem::exists(IMGFile), true); if (boost::filesystem::exists(IMGFile)) { boost::filesystem::remove(IMGFile); } if (boost::filesystem::exists(HDRFile)) { boost::filesystem::remove(HDRFile); } } RETURN_AND_REPORT_TEST_SUCCESS; } } } diff --git a/testing/demoapps/VoxelizerTool/rttbVoxelizerToolVoxelizerAllStructsTest.cpp b/testing/demoapps/VoxelizerTool/rttbVoxelizerToolVoxelizerAllStructsTest.cpp index 172cadd..89e9ea0 100644 --- a/testing/demoapps/VoxelizerTool/rttbVoxelizerToolVoxelizerAllStructsTest.cpp +++ b/testing/demoapps/VoxelizerTool/rttbVoxelizerToolVoxelizerAllStructsTest.cpp @@ -1,109 +1,109 @@ // ----------------------------------------------------------------------- // 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: 5503 $ (last changed revision) // @date $Date: 2015-07-24 12:33:26 +0200 (Fr, 24 Jul 2015) $ (last change date) // @author $Author: strubel $ (last changed by) */ #include #include "litCheckMacros.h" #include #include /*! @brief VoxelizerToolTest. Tests a selection of structs. */ namespace rttb { namespace testing { //path to the current running directory. VoxelizerTool is in the same directory (Debug/Release) extern const char* _callingAppPath; int VoxelizerToolVoxelizerAllStructsTest(int argc, char* argv[]) { PREPARE_DEFAULT_TEST_REPORTING; std::string voxelizerToolExe; std::string tempDirectory; std::string structFile; std::string referenceFile; if (argc > 3) { voxelizerToolExe = argv[1]; tempDirectory = argv[2]; structFile = argv[3]; referenceFile = argv[4]; } boost::filesystem::path callingPath(_callingAppPath); std::string voxelizerToolExeWithPath = callingPath.parent_path().string() + "/" + voxelizerToolExe; std::vector structNames; - structNames.push_back("Niere re."); + structNames.push_back("Niere.*"); structNames.push_back("Magen/DD"); structNames.push_back("PTV"); //structure names will be used for file naming, BUT '.' in the end will be cropped and '/' will be replaced by '_'. Thus, the different filenames. std::vector filenames; filenames.push_back("Niere re"); filenames.push_back("Magen_DD"); filenames.push_back("PTV"); std::string baseCommand = voxelizerToolExeWithPath; baseCommand += " -s " + structFile; baseCommand += " -r " + referenceFile; baseCommand += " -e \""; for (int i = 0; i < structNames.size(); i++) { std::string command = baseCommand + structNames.at(i) + "\""; std::cout << "Command line call: " + command << std::endl; int returnValue = system(command.c_str()); CHECK_EQUAL(returnValue, 0); const std::string HDRfileName = tempDirectory + "/out_" + filenames.at(i) + ".hdr"; boost::filesystem::path HDRFile(HDRfileName); const std::string IMGfileName = tempDirectory + "/out_" + filenames.at(i) + ".img"; boost::filesystem::path IMGFile(IMGfileName); CHECK_EQUAL( boost::filesystem::exists(HDRFile), true); CHECK_EQUAL( boost::filesystem::exists(IMGFile), true); if (boost::filesystem::exists(IMGFile)) { boost::filesystem::remove(IMGFile); } if (boost::filesystem::exists(HDRFile)) { boost::filesystem::remove(HDRFile); } } RETURN_AND_REPORT_TEST_SUCCESS; } } } \ No newline at end of file