diff --git a/testing/apps/VoxelizerTool/CMakeLists.txt b/testing/apps/VoxelizerTool/CMakeLists.txt index a5bc8bf..34179ff 100644 --- a/testing/apps/VoxelizerTool/CMakeLists.txt +++ b/testing/apps/VoxelizerTool/CMakeLists.txt @@ -1,29 +1,31 @@ #----------------------------------------------------------------------------- # 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 ${RTToolbox_BINARY_DIR}/testing/apps/VoxelizerTool) IF (WIN32) SET(VOXELIZERTOOL_EXE "VoxelizerTool") ELSE (WIN32) SET(VOXELIZERTOOL_EXE "./VoxelizerTool") ENDIF (WIN32) SET(STRUCT_FILE "${TEST_DATA_ROOT}/StructureSet/DICOM/RS1.3.6.1.4.1.2452.6.841242143.1311652612.1170940299.4217870819.dcm") SET(REFERENCE_FILE "${TEST_DATA_ROOT}/Dose/DICOM/ConstantTwo.dcm") #----------------------------------------------------------------------------- ADD_TEST(VoxelizerToolIncorrectCommandsTest ${VoxelizerTool_TESTS} VoxelizerToolIncorrectCommandsTest "${VOXELIZERTOOL_EXE}" ${STRUCT_FILE} "${TEST_DATA_ROOT}/StructureSet/DICOM/Wrong_Data_Struct_file.dicom" ${REFERENCE_FILE} "${TEST_DATA_ROOT}/Dose/DICOM/Wrong_Reference_file.dicom" "Rueckenmark" "blabla") ADD_TEST(VoxelizerToolVoxelizerAllStructsTest ${VoxelizerTool_TESTS} VoxelizerToolVoxelizerAllStructsTest "${VOXELIZERTOOL_EXE}" ${TEST_DATA} ${STRUCT_FILE} ${REFERENCE_FILE} ) +ADD_TEST(VoxelizerToolVoxelizerStructTest ${VoxelizerTool_TESTS} VoxelizerToolVoxelizerStructTest +"${VOXELIZERTOOL_EXE}" ${TEST_DATA} "${TEST_DATA_ROOT}/StructureSet/ITK/singleFiles/rtss.dcm" "${TEST_DATA_ROOT}/StructureSet/ITK/singleFiles/ct.0" ) ADD_TEST(VoxelizerToolDifferentCommandsTest ${VoxelizerTool_TESTS} VoxelizerToolDifferentCommandsTest "${VOXELIZERTOOL_EXE}" ${TEST_DATA} ${STRUCT_FILE} ${REFERENCE_FILE}) ADD_TEST(VoxelizerToolVoxelValueTest ${VoxelizerTool_TESTS} VoxelizerToolVoxelValue "${VOXELIZERTOOL_EXE}" ${TEST_DATA} ${STRUCT_FILE} ${REFERENCE_FILE} "Leber") RTTB_CREATE_APPLICATION_TESTS(VoxelizerTool PACKAGE_DEPENDS Litmus ITK BoostBinaries RTTBData) diff --git a/testing/apps/VoxelizerTool/VoxelizerToolTests.cpp b/testing/apps/VoxelizerTool/VoxelizerToolTests.cpp index 8854518..616fa8f 100644 --- a/testing/apps/VoxelizerTool/VoxelizerToolTests.cpp +++ b/testing/apps/VoxelizerTool/VoxelizerToolTests.cpp @@ -1,68 +1,63 @@ // ----------------------------------------------------------------------- // 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: 1127 $ (last changed revision) -// @date $Date: 2015-10-01 13:33:33 +0200 (Do, 01 Okt 2015) $ (last change date) -// @author $Author: hentsch $ (last changed by) -*/ // this file defines the rttbCoreTests for the test driver // and all it expects is that you have a function called RegisterTests #if defined(_MSC_VER) #pragma warning ( disable : 4786 ) #endif #include "litMultiTestsMain.h" namespace rttb { namespace testing { const char* _callingAppPath = nullptr; void registerTests() { LIT_REGISTER_TEST(VoxelizerToolDifferentCommandsTest); LIT_REGISTER_TEST(VoxelizerToolVoxelValue); LIT_REGISTER_TEST(VoxelizerToolIncorrectCommandsTest); LIT_REGISTER_TEST(VoxelizerToolVoxelizerAllStructsTest); + LIT_REGISTER_TEST(VoxelizerToolVoxelizerStructTest); } } } int main(int argc, char* argv[]) { int result = 0; rttb::testing::registerTests(); if (argc > 0) { rttb::testing::_callingAppPath = argv[0]; } try { result = lit::multiTestsMain(argc, argv); } catch (...) { result = -1; } return result; } diff --git a/testing/apps/VoxelizerTool/VoxelizerToolVoxelizerAllStructsTest.cpp b/testing/apps/VoxelizerTool/VoxelizerToolVoxelizerAllStructsTest.cpp index 74fa813..3167347 100644 --- a/testing/apps/VoxelizerTool/VoxelizerToolVoxelizerAllStructsTest.cpp +++ b/testing/apps/VoxelizerTool/VoxelizerToolVoxelizerAllStructsTest.cpp @@ -1,104 +1,98 @@ // ----------------------------------------------------------------------- // 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: 1333 $ (last changed revision) -// @date $Date: 2016-04-22 11:12:14 +0200 (Fr, 22 Apr 2016) $ (last change date) -// @author $Author: hentsch $ (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 > 4) { 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.*"); structNames.push_back("Magen/DD"); structNames.push_back("PTV"); std::string baseCommand = voxelizerToolExeWithPath; baseCommand += " -s \"" + structFile + "\""; baseCommand += " -r \"" + referenceFile + "\""; baseCommand += " -o outputAllStructs.hdr"; baseCommand += " -e \""; for (size_t 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); boost::filesystem::path HDRFile(tempDirectory); HDRFile /= "outputAllStructs.hdr"; boost::filesystem::path IMGFile(tempDirectory); IMGFile /= "outputAllStructs.img"; 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/apps/VoxelizerTool/VoxelizerToolVoxelizerAllStructsTest.cpp b/testing/apps/VoxelizerTool/VoxelizerToolVoxelizerStructTest.cpp similarity index 53% copy from testing/apps/VoxelizerTool/VoxelizerToolVoxelizerAllStructsTest.cpp copy to testing/apps/VoxelizerTool/VoxelizerToolVoxelizerStructTest.cpp index 74fa813..a42560c 100644 --- a/testing/apps/VoxelizerTool/VoxelizerToolVoxelizerAllStructsTest.cpp +++ b/testing/apps/VoxelizerTool/VoxelizerToolVoxelizerStructTest.cpp @@ -1,104 +1,98 @@ -// ----------------------------------------------------------------------- -// 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: 1333 $ (last changed revision) -// @date $Date: 2016-04-22 11:12:14 +0200 (Fr, 22 Apr 2016) $ (last change date) -// @author $Author: hentsch $ (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 > 4) - { - 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.*"); - structNames.push_back("Magen/DD"); - structNames.push_back("PTV"); - - std::string baseCommand = voxelizerToolExeWithPath; - baseCommand += " -s \"" + structFile + "\""; - baseCommand += " -r \"" + referenceFile + "\""; - baseCommand += " -o outputAllStructs.hdr"; - baseCommand += " -e \""; - - for (size_t 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); - - boost::filesystem::path HDRFile(tempDirectory); - HDRFile /= "outputAllStructs.hdr"; - - boost::filesystem::path IMGFile(tempDirectory); - IMGFile /= "outputAllStructs.img"; - - 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; - } - } -} +// ----------------------------------------------------------------------- +// 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. +// +//------------------------------------------------------------------------ + +#include +#include "litCheckMacros.h" +#include + +/*! @brief VoxelizerToolTest. + Tests a struct with multiple files and a single file +*/ + +namespace rttb +{ + namespace testing + { + //path to the current running directory. VoxelizerTool is in the same directory (Debug/Release) + extern const char* _callingAppPath; + int VoxelizerToolVoxelizerStructTest(int argc, char* argv[]) { + PREPARE_DEFAULT_TEST_REPORTING; + + std::string voxelizerToolExe; + std::string tempDirectory; + std::string structFile; + std::string referenceFile; + + boost::filesystem::path HDRFile(tempDirectory); + HDRFile /= "outputSingleStruct.hdr"; + + boost::filesystem::path IMGFile(tempDirectory); + IMGFile /= "outputSingleStruct.img"; + + if (argc > 4) { + 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::string structName = "Heart"; + + std::string baseCommand = voxelizerToolExeWithPath; + baseCommand += " -s \"" + structFile + "\""; + baseCommand += " -r \"" + referenceFile + "\""; + baseCommand += " -o outputSingleStruct.hdr"; + baseCommand += " -y itkDicom"; + baseCommand += " -e \""; + + std::string command = baseCommand + structName + "\""; + std::cout << "Command line call: " + command << std::endl; + int returnValue = system(command.c_str()); + + CHECK_EQUAL(returnValue, 0); + + CHECK_EQUAL(boost::filesystem::exists(HDRFile), true); + CHECK_EQUAL(boost::filesystem::exists(IMGFile), true); + + + + baseCommand = voxelizerToolExeWithPath; + baseCommand += " -s \"" + structFile + "\""; + baseCommand += " -r \"" + HDRFile.string() + "\""; + baseCommand += " -o outputSingleStruct.hdr"; + baseCommand += " -y itk"; + baseCommand += " -e \""; + + command = baseCommand + structName + "\""; + std::cout << "Command line call: " + command << std::endl; + returnValue = system(command.c_str()); + + CHECK_EQUAL(returnValue, 0); + + 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/apps/VoxelizerTool/files.cmake b/testing/apps/VoxelizerTool/files.cmake index 46961ff..ebcabaf 100644 --- a/testing/apps/VoxelizerTool/files.cmake +++ b/testing/apps/VoxelizerTool/files.cmake @@ -1,7 +1,8 @@ SET(CPP_FILES VoxelizerToolTests.cpp VoxelizerToolDifferentCommandsTest.cpp VoxelizerToolIncorrectCommandsTest.cpp VoxelizerToolVoxelizerAllStructsTest.cpp + VoxelizerToolVoxelizerStructTest.cpp VoxelizerToolVoxelValueTest.cpp )