diff --git a/testing/CMakeLists.txt b/testing/CMakeLists.txt index f317d0d..2d56829 100644 --- a/testing/CMakeLists.txt +++ b/testing/CMakeLists.txt @@ -1,70 +1,70 @@ MESSAGE(STATUS "processing RTToolbox testing code") # Testing branch PROJECT(RTTBTesting) #----------------------------------------------------------------------------- # Find Litmus. #----------------------------------------------------------------------------- MESSAGE(STATUS "searching Litmus") FIND_PACKAGE(Litmus) IF(Litmus_FOUND) INCLUDE(${Litmus_USE_FILE}) SET(ADDITIONAL_TEST_INCLUDES ${Litmus_USE_FILE}) ELSE(Litmus_FOUND) MESSAGE(FATAL_ERROR "Cannot build without Litmus. Please set Litmus_DIR.") ENDIF(Litmus_FOUND) #----------------------------------------------------------------------------- # Configure Testing branch #----------------------------------------------------------------------------- MAKE_DIRECTORY(${RTTBTesting_BINARY_DIR}/Temporary) MESSAGE(STATUS "Process All Tests...") #----------------------------------------------------------------------------- # Include sub directories #----------------------------------------------------------------------------- OPTION(BUILD_RTToolbox_core_Tester "build project on/off" OFF) OPTION(BUILD_RTToolbox_Test_examples "build project on/off" OFF) OPTION(BUILD_RTToolbox_algorithms_Tester "build project on/off" OFF) OPTION(BUILD_RTToolbox_models_Tester "build project on/off" OFF) OPTION(BUILD_RTToolbox_io_Tester "build project on/off" OFF) OPTION(BUILD_RTToolbox_masks_Tester "build project on/off" OFF) OPTION(BUILD_RTToolbox_interpolation_Tester "build project on/off" OFF) OPTION(BUILD_RTToolbox_demoapps_VoxelizerTool_Tester "build project on/off" OFF) IF(${BUILD_RTToolbox_core_Tester} STREQUAL ON) ADD_SUBDIRECTORY(core) ENDIF(${BUILD_RTToolbox_core_Tester} STREQUAL ON) IF(${BUILD_RTToolbox_Test_examples} STREQUAL ON) ADD_SUBDIRECTORY(examples) ENDIF(${BUILD_RTToolbox_Test_examples} STREQUAL ON) IF(${BUILD_RTToolbox_algorithms_Tester} STREQUAL ON) ADD_SUBDIRECTORY(algorithms) ENDIF(${BUILD_RTToolbox_algorithms_Tester} STREQUAL ON) IF(${BUILD_RTToolbox_models_Tester} STREQUAL ON) ADD_SUBDIRECTORY(models) ENDIF(${BUILD_RTToolbox_models_Tester} STREQUAL ON) IF(${BUILD_RTToolbox_io_Tester} STREQUAL ON) ADD_SUBDIRECTORY(io) ENDIF(${BUILD_RTToolbox_io_Tester} STREQUAL ON) IF(${BUILD_RTToolbox_masks_Tester} STREQUAL ON) ADD_SUBDIRECTORY(masks) ENDIF(${BUILD_RTToolbox_masks_Tester} STREQUAL ON) IF(${BUILD_RTToolbox_interpolation_Tester} STREQUAL ON) ADD_SUBDIRECTORY(interpolation) ENDIF(${BUILD_RTToolbox_interpolation_Tester} STREQUAL ON) IF(${BUILD_RTToolbox_demoapps_VoxelizerTool_Tester} STREQUAL ON) -ADD_SUBDIRECTORY(interpolation) +ADD_SUBDIRECTORY(demoapps/VoxelizerTool) ENDIF(${BUILD_RTToolbox_demoapps_VoxelizerTool_Tester} STREQUAL ON) diff --git a/testing/demoapps/VoxelizerTool/CMakeLists.txt b/testing/demoapps/VoxelizerTool/CMakeLists.txt index 02ff805..55f6304 100644 --- a/testing/demoapps/VoxelizerTool/CMakeLists.txt +++ b/testing/demoapps/VoxelizerTool/CMakeLists.txt @@ -1,32 +1,22 @@ #----------------------------------------------------------------------------- # Setup the system information test. Write out some basic failsafe # information in case the test doesn't run. #----------------------------------------------------------------------------- - -SET(CORE_TEST_EXAMPLES ${EXECUTABLE_OUTPUT_PATH}/rttbExamplesTests) - +SET(VoxelizerTool_TESTS ${EXECUTABLE_OUTPUT_PATH}/Release/RTTBDemoappsVoxelizertoolTests) SET(TEST_DATA_ROOT ${RTTBTesting_SOURCE_DIR}/data) - -SET(TEMP ${RTTBTesting_BINARY_DIR}/temporary) - +SET(TEST_DATA ${RTToolbox_BINARY_DIR}/Testing/demoapps/VoxelizerTool) #----------------------------------------------------------------------------- -ADD_TEST(rttbVoxelizerToolDifferentCommandsTest ${CORE_TEST_EXAMPLES} RTBioModelExampleTest - -ADD_TEST(rttbVoxelizerToolIncorrectCommandsTest ${CORE_TEST_EXAMPLES} DVHCalculatorExampleTest - -ADD_TEST(rttbVoxelizerToolVoxelizerAllStuctsTest ${CORE_TEST_EXAMPLES} RTDoseIndexTest - -ADD_TEST(rttbVoxelizerToolVoxelizerBoostLegacyTest ${CORE_TEST_EXAMPLES} RTDoseStatisticsTest - -ADD_TEST(rttbVoxelizerToolVoxelPixelValueTest ${CORE_TEST_EXAMPLES} RTDVHTest "${TEST_DATA_ROOT}/TestDVH/dvh_test.txt") - -RTTB_CREATE_TEST_MODULE(rttbDemoappsVoxelizertool DEPENDS RTTBCore RTTBAlgorithms RTTBMasks RTTBOTBMask RTTBBoostMask RTTBIndices RTTBDicomIO RTTBVirtuosIO RTTBOtherIO RTTBModels PACKAGE_DEPENDS Litmus) - - - - - - - \ No newline at end of file +ADD_TEST(rttbVoxelizerToolIncorrectCommandsTest ${VoxelizerTool_TESTS} VoxelizerToolIncorrectCommandsTest +${EXECUTABLE_OUTPUT_PATH} ${TEST_DATA} ${TEST_DATA_ROOT}) +ADD_TEST(rttbVoxelizerToolVoxelizerAllStuctsTest ${VoxelizerTool_TESTS} VoxelizerToolVoxelizerAllStructsTest +${EXECUTABLE_OUTPUT_PATH} ${TEST_DATA} ${TEST_DATA_ROOT}) +ADD_TEST(rttbVoxelizerToolDifferentCommandsTest ${VoxelizerTool_TESTS} VoxelizerToolDifferentCommandsTest +${EXECUTABLE_OUTPUT_PATH} ${TEST_DATA} ${TEST_DATA_ROOT}) +ADD_TEST(rttbVoxelizerToolVoxelizerBoostLegacyTest ${VoxelizerTool_TESTS} VoxelizerToolVoxelizerBoostLegacy +${EXECUTABLE_OUTPUT_PATH} ${TEST_DATA} ${TEST_DATA_ROOT}) +ADD_TEST(rttbVoxelizerToolVoxelPixelValueTest ${VoxelizerTool_TESTS} VoxelizerToolVoxelPixelValue +${EXECUTABLE_OUTPUT_PATH} ${TEST_DATA} ${TEST_DATA_ROOT}) + +RTTB_CREATE_TEST_MODULE(RTTBDemoappsVoxelizertool DEPENDS RTTBITKIO RTTBCore RTTBAlgorithms RTTBMasks RTTBOTBMask RTTBBoostMask RTTBIndices RTTBDicomIO RTTBOtherIO PACKAGE_DEPENDS Litmus) diff --git a/testing/demoapps/VoxelizerTool/files.cmake b/testing/demoapps/VoxelizerTool/files.cmake index a08a587..49fd13b 100644 --- a/testing/demoapps/VoxelizerTool/files.cmake +++ b/testing/demoapps/VoxelizerTool/files.cmake @@ -1,7 +1,8 @@ SET(CPP_FILES + rttbVoxelizerToolTests.cpp rttbVoxelizerToolDifferentCommandsTest.cpp rttbVoxelizerToolIncorrectCommandsTest.cpp rttbVoxelizerToolVoxelizerAllStuctsTest.cpp rttbVoxelizerToolVoxelizerBoostLegacyTest.cpp rttbVoxelizerToolVoxelPixelValueTest.cpp ) diff --git a/testing/demoapps/VoxelizerTool/rttbVoxelizerToolDifferentCommandsTest.cpp b/testing/demoapps/VoxelizerTool/rttbVoxelizerToolDifferentCommandsTest.cpp index 807a2fa..b0f3075 100644 --- a/testing/demoapps/VoxelizerTool/rttbVoxelizerToolDifferentCommandsTest.cpp +++ b/testing/demoapps/VoxelizerTool/rttbVoxelizerToolDifferentCommandsTest.cpp @@ -1,104 +1,108 @@ // ----------------------------------------------------------------------- // 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. */ - -int main(int argc, char* argv[]) +namespace rttb { - PREPARE_DEFAULT_TEST_REPORTING; - - if (argc > 3) + namespace testing { - const std::string PathToBinaryDirectory = argv[1]; - const std::string path = argv[2]; - const std::string RTToolBoxTestingDirectory = argv[3]; - - std::vector commands; - commands.push_back(".*"); - commands.push_back(".* -m -o M.hdr"); - commands.push_back("Niere.* -m -o Test.hdr"); - commands.push_back("Leber -o Boolean.hdr -v"); - - std::vector structures; - structures.push_back("M_Aussenkontur"); - structures.push_back("M_Rueckenmark"); - structures.push_back("M_Niere re"); - structures.push_back("M_Niere li"); - structures.push_back("M_Magen_DD"); - structures.push_back("M_Leber"); - structures.push_back("M_Darm"); - structures.push_back("M_Ref.Pkt"); - structures.push_back("M_PTV"); - structures.push_back("M_Boost"); - structures.push_back("out_Aussenkontur"); - structures.push_back("Test_Niere li"); - structures.push_back("Test_Niere re"); - structures.push_back("Boolean_Leber"); - - const std::string baseCommand = PathToBinaryDirectory + - "Release/VoxelizerTool -s " + RTToolBoxTestingDirectory + - "data/DICOM/StructureSet/RS1.3.6.1.4.1.2452.6.841242143.1311652612.1170940299.4217870819.dcm -r " + - RTToolBoxTestingDirectory + "data/DICOM/TestDose/ConstantTwo.dcm -e "; - - for (int i = 0; i < commands.size(); i++) - { - std::string command = baseCommand + commands.at(i); - int returnValue = system(command.c_str()); - CHECK_EQUAL(returnValue, 0); - } - - - for (int i = 0; i < structures.size(); i++) + int VoxelizerToolDifferentCommandsTest(int argc, char* argv[]) { - std::string IMGfileName = path + "/" + structures.at(i) + ".img"; - std::string HDRfileName = path + "/" + structures.at(i) + ".hdr"; - - CHECK_EQUAL(boost::filesystem::exists(HDRfileName), true); - CHECK_EQUAL(boost::filesystem::exists(IMGfileName), true); - - boost::filesystem::path imgFile(IMGfileName); + PREPARE_DEFAULT_TEST_REPORTING; - if (boost::filesystem::exists(imgFile)) + if (argc > 3) { - boost::filesystem::remove(imgFile); - } - - boost::filesystem::path hdrFile(HDRfileName); - - if (boost::filesystem::exists(hdrFile)) - { - boost::filesystem::remove(hdrFile); + const std::string PathToBinaryDirectory = argv[1]; + const std::string path = argv[2]; + const std::string RTToolBoxTestingDirectory = argv[3]; + + std::vector commands; + commands.push_back(".*"); + commands.push_back(".* -m -o M.hdr"); + commands.push_back("Niere.* -m -o Test.hdr"); + commands.push_back("Leber -o Boolean.hdr -v"); + + std::vector structures; + structures.push_back("M_Aussenkontur"); + structures.push_back("M_Rueckenmark"); + structures.push_back("M_Niere re"); + structures.push_back("M_Niere li"); + structures.push_back("M_Magen_DD"); + structures.push_back("M_Leber"); + structures.push_back("M_Darm"); + structures.push_back("M_Ref.Pkt"); + structures.push_back("M_PTV"); + structures.push_back("M_Boost"); + structures.push_back("out_Aussenkontur"); + structures.push_back("Test_Niere li"); + structures.push_back("Test_Niere re"); + structures.push_back("Boolean_Leber"); + + const std::string baseCommand = PathToBinaryDirectory + + "/Release/RTTBVoxelizerTool -s " + RTToolBoxTestingDirectory + + "/DICOM/StructureSet/RS1.3.6.1.4.1.2452.6.841242143.1311652612.1170940299.4217870819.dcm -r " + + RTToolBoxTestingDirectory + "/DICOM/TestDose/ConstantTwo.dcm -e "; + + for (int i = 0; i < commands.size(); i++) + { + std::string command = baseCommand + commands.at(i); + int returnValue = system(command.c_str()); + CHECK_EQUAL(returnValue, 0); + } + + + for (int i = 0; i < structures.size(); i++) + { + std::string IMGfileName = path + "/" + structures.at(i) + ".img"; + std::string HDRfileName = path + "/" + structures.at(i) + ".hdr"; + + CHECK_EQUAL(boost::filesystem::exists(HDRfileName), true); + CHECK_EQUAL(boost::filesystem::exists(IMGfileName), true); + + boost::filesystem::path imgFile(IMGfileName); + + if (boost::filesystem::exists(imgFile)) + { + boost::filesystem::remove(imgFile); + } + + boost::filesystem::path hdrFile(HDRfileName); + + if (boost::filesystem::exists(hdrFile)) + { + boost::filesystem::remove(hdrFile); + } + + } } + RETURN_AND_REPORT_TEST_SUCCESS; } - } - RETURN_AND_REPORT_TEST_SUCCESS; + } } - - diff --git a/testing/demoapps/VoxelizerTool/rttbVoxelizerToolIncorrectCommandsTest.cpp b/testing/demoapps/VoxelizerTool/rttbVoxelizerToolIncorrectCommandsTest.cpp index 6baa821..5d791e1 100644 --- a/testing/demoapps/VoxelizerTool/rttbVoxelizerToolIncorrectCommandsTest.cpp +++ b/testing/demoapps/VoxelizerTool/rttbVoxelizerToolIncorrectCommandsTest.cpp @@ -1,64 +1,70 @@ // ----------------------------------------------------------------------- // 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 "litCheckMacros.h" #include #include /*! @brief VoxelizerToolTest4. Test incorrect commands with a wrong structfile, referencefile and a wrong struct. if the command return one, the program could not run to the end. return zero the command is correct */ - -int main(int argc, char* argv[]) +namespace rttb { - PREPARE_DEFAULT_TEST_REPORTING; - - if (argc > 3) + namespace testing { - const std::string PathToBinaryDirectory = argv[1]; - const std::string RTToolBoxTestingDirectory = argv[3]; - const std::string StructCommand = PathToBinaryDirectory + - "Release/VoxelizerTool -s " + RTToolBoxTestingDirectory + - "data/DICOM/StructureSet/Wrong_Data_Struct_file.dicom -r " + RTToolBoxTestingDirectory + - "data/DICOM/TestDose/ConstantTwo.dcm -e Rueckenmark"; - CHECK_EQUAL(system(StructCommand.c_str()), 1); + int VoxelizerToolIncorrectCommandsTest(int argc, char* argv[]) + { + PREPARE_DEFAULT_TEST_REPORTING; - const std::string ReferenceCommand = PathToBinaryDirectory + - "Release/VoxelizerTool -s " + RTToolBoxTestingDirectory + - "data/DICOM/StructureSet/RS1.3.6.1.4.1.2452.6.841242143.1311652612.1170940299.4217870819.dcm -r " + - RTToolBoxTestingDirectory + "data/DICOM/TestDose/Wrong_Reference_file.dicom -e Rueckenmark"; - CHECK_EQUAL(system(ReferenceCommand.c_str()), 1); + if (argc > 3) + { + const std::string PathToBinaryDirectory = argv[1]; + const std::string RTToolBoxTestingDirectory = argv[3]; - const std::string Structure = PathToBinaryDirectory + - "Release/VoxelizerTool -s " + RTToolBoxTestingDirectory + - "data/DICOM/StructureSet/RS1.3.6.1.4.1.2452.6.841242143.1311652612.1170940299.4217870819.dcm -r " + - RTToolBoxTestingDirectory + "data/DICOM/TestDose/ConstantTwo.dcm -e blablabla"; - CHECK_EQUAL(system(Structure.c_str()), 0); - } + const std::string StructCommand = PathToBinaryDirectory + + "/Release/RTTBVoxelizerTool -s " + RTToolBoxTestingDirectory + + "/DICOM/StructureSet/Wrong_Data_Struct_file.dicom -r " + + RTToolBoxTestingDirectory + "/DICOM/TestDose/ConstantTwo.dcm -e Rueckenmark"; - RETURN_AND_REPORT_TEST_SUCCESS; -} + CHECK_EQUAL(system(StructCommand.c_str()), 1); + const std::string ReferenceCommand = PathToBinaryDirectory + + "/Release/RTTBVoxelizerTool -s " + RTToolBoxTestingDirectory + + "/DICOM/StructureSet/RS1.3.6.1.4.1.2452.6.841242143.1311652612.1170940299.4217870819.dcm -r " + + RTToolBoxTestingDirectory + "/DICOM/TestDose/Wrong_Reference_file.dicom -e Rueckenmark"; + CHECK_EQUAL(system(ReferenceCommand.c_str()), 1); + const std::string Structure = PathToBinaryDirectory + + "/Release/RTTBVoxelizerTool -s " + RTToolBoxTestingDirectory + + "/DICOM/StructureSet/RS1.3.6.1.4.1.2452.6.841242143.1311652612.1170940299.4217870819.dcm -r " + + RTToolBoxTestingDirectory + "/DICOM/TestDose/ConstantTwo.dcm -e blablabla"; + CHECK_EQUAL(system(Structure.c_str()), 0); + } + + RETURN_AND_REPORT_TEST_SUCCESS; + } + + } +} diff --git a/testing/demoapps/VoxelizerTool/rttbVoxelizerToolTests.cpp b/testing/demoapps/VoxelizerTool/rttbVoxelizerToolTests.cpp new file mode 100644 index 0000000..fe93e7f --- /dev/null +++ b/testing/demoapps/VoxelizerTool/rttbVoxelizerToolTests.cpp @@ -0,0 +1,64 @@ +// ----------------------------------------------------------------------- +// 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: 707 $ (last changed revision) +// @date $Date: 2014-09-04 16:37:24 +0200 (Do, 04 Sep 2014) $ (last change date) +// @author $Author: floca $ (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 + { + void registerTests() + { + LIT_REGISTER_TEST(VoxelizerToolDifferentCommandsTest); + LIT_REGISTER_TEST(VoxelizerToolVoxelizerBoostLegacy); + LIT_REGISTER_TEST(VoxelizerToolVoxelPixelValue); + LIT_REGISTER_TEST(VoxelizerToolIncorrectCommandsTest); + LIT_REGISTER_TEST(VoxelizerToolVoxelizerAllStructsTest); + } + } +} + +int main(int argc, char* argv[]) +{ + int result = 0; + + rttb::testing::registerTests(); + + + try + { + result = lit::multiTestsMain(argc, argv); + } + + catch (...) + { + result = -1; + } + + return result; +} diff --git a/testing/demoapps/VoxelizerTool/rttbVoxelizerToolVoxelPixelValueTest.cpp b/testing/demoapps/VoxelizerTool/rttbVoxelizerToolVoxelPixelValueTest.cpp index 5acf1f6..4ff267c 100644 --- a/testing/demoapps/VoxelizerTool/rttbVoxelizerToolVoxelPixelValueTest.cpp +++ b/testing/demoapps/VoxelizerTool/rttbVoxelizerToolVoxelPixelValueTest.cpp @@ -1,123 +1,131 @@ // ----------------------------------------------------------------------- // 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 "itkImage.h" #include "itkImageFileReader.h" #include /*! @brief VoxelizerToolTest5. Search the coordinate at the Image and return the Voxel(Pixel) value. */ -int main(int argc, char* argv[]) -{ - PREPARE_DEFAULT_TEST_REPORTING; - - typedef itk::Image< double, 3 > ImageType; - typedef itk::ImageFileReader ReaderType; - if (argc > 3) +namespace rttb +{ + namespace testing { - const std::string pathToBinaryDirectory = argv[1]; - const std::string pathToTestDirectory = argv[2]; - const std::string RTToolBoxTestingDirectory = argv[3]; - const std::string StructCommand = pathToBinaryDirectory + - "Release/VoxelizerTool -s " + RTToolBoxTestingDirectory + - "data/DICOM/StructureSet/RS1.3.6.1.4.1.2452.6.841242143.1311652612.1170940299.4217870819.dcm -r " + - RTToolBoxTestingDirectory + "data/DICOM/TestDose/ConstantTwo.dcm -e Leber"; - int returnValue = system(StructCommand.c_str()); - CHECK_EQUAL(returnValue, 0); + int VoxelizerToolVoxelPixelValue(int argc, char* argv[]) + { + PREPARE_DEFAULT_TEST_REPORTING; - std::string pathToFile = pathToTestDirectory + "/out_Leber.hdr"; + typedef itk::Image< double, 3 > ImageType; + typedef itk::ImageFileReader ReaderType; - ImageType::IndexType pixelWithOne_1 = {{20, 30, 30}}; - ImageType::IndexType pixelWithOne_2 = {{30, 10, 40}}; + if (argc > 3) + { + const std::string pathToBinaryDirectory = argv[1]; + const std::string pathToTestDirectory = argv[2]; + const std::string RTToolBoxTestingDirectory = argv[3]; - ImageType::IndexType pixelWithZero_1 = {{40, 30, 30}}; - ImageType::IndexType pixelWithZero_2 = {{10, 40, 30}}; + const std::string StructCommand = pathToBinaryDirectory + + "/Release/RTTBVoxelizerTool -s " + RTToolBoxTestingDirectory + + "/DICOM/StructureSet/RS1.3.6.1.4.1.2452.6.841242143.1311652612.1170940299.4217870819.dcm -r " + + RTToolBoxTestingDirectory + "/DICOM/TestDose/ConstantTwo.dcm -e Leber"; + int returnValue = system(StructCommand.c_str()); + CHECK_EQUAL(returnValue, 0); - ImageType::IndexType pixelAtBorder_1 = {{12, 23, 27}}; - ImageType::IndexType pixelAtBorder_2 = {{34, 21, 31}}; + std::string pathToFile = pathToTestDirectory + "/out_Leber.hdr"; - std::vector pixelWithOne; - std::vector pixelWithZero; - std::vector pixelAtBorder; + ImageType::IndexType pixelWithOne_1 = {{20, 30, 30}}; + ImageType::IndexType pixelWithOne_2 = {{30, 10, 40}}; - pixelWithOne.push_back(pixelWithOne_1); - pixelWithOne.push_back(pixelWithOne_2); + ImageType::IndexType pixelWithZero_1 = {{40, 30, 30}}; + ImageType::IndexType pixelWithZero_2 = {{10, 40, 30}}; - pixelWithZero.push_back(pixelWithZero_1); - pixelWithZero.push_back(pixelWithZero_2); + ImageType::IndexType pixelAtBorder_1 = {{12, 23, 27}}; + ImageType::IndexType pixelAtBorder_2 = {{34, 21, 31}}; - pixelAtBorder.push_back(pixelAtBorder_1); - pixelAtBorder.push_back(pixelAtBorder_2); + std::vector pixelWithOne; + std::vector pixelWithZero; + std::vector pixelAtBorder; - if (boost::filesystem::exists(pathToFile)) - { - ReaderType::Pointer reader = ReaderType::New(); - reader->SetFileName(pathToFile); - reader->Update(); + pixelWithOne.push_back(pixelWithOne_1); + pixelWithOne.push_back(pixelWithOne_2); - auto image = reader->GetOutput(); - ImageType::PixelType pixelValue; + pixelWithZero.push_back(pixelWithZero_1); + pixelWithZero.push_back(pixelWithZero_2); - for (int i = 0; i < pixelWithOne.size(); i++) - { - pixelValue = image->GetPixel(pixelWithOne.at(i)); - CHECK_EQUAL(pixelValue, 1.0); - } - - for (int i = 0; i < pixelWithZero.size(); i++) - { - pixelValue = image->GetPixel(pixelWithZero.at(i)); - CHECK_EQUAL(pixelValue, 0.0); - } + pixelAtBorder.push_back(pixelAtBorder_1); + pixelAtBorder.push_back(pixelAtBorder_2); - for (int i = 0; i < pixelAtBorder.size(); i++) - { - pixelValue = image->GetPixel(pixelAtBorder.at(i)); - - if (i == 0) + if (boost::filesystem::exists(pathToFile)) { - CHECK_CLOSE(pixelValue, 0.265865, 1e-3); + ReaderType::Pointer reader = ReaderType::New(); + reader->SetFileName(pathToFile); + reader->Update(); + + auto image = reader->GetOutput(); + ImageType::PixelType pixelValue; + + for (int i = 0; i < pixelWithOne.size(); i++) + { + pixelValue = image->GetPixel(pixelWithOne.at(i)); + CHECK_EQUAL(pixelValue, 1.0); + } + + for (int i = 0; i < pixelWithZero.size(); i++) + { + pixelValue = image->GetPixel(pixelWithZero.at(i)); + CHECK_EQUAL(pixelValue, 0.0); + } + + for (int i = 0; i < pixelAtBorder.size(); i++) + { + pixelValue = image->GetPixel(pixelAtBorder.at(i)); + + if (i == 0) + { + CHECK_CLOSE(pixelValue, 0.265865, 1e-3); + } + else if (i == 1) + { + CHECK_CLOSE(pixelValue, 0.819613, 1e-3); + } + } + + if (boost::filesystem::exists(pathToTestDirectory + "/out_Leber.img")) + { + boost::filesystem::remove(pathToTestDirectory + "/out_Leber.img"); + } + + if (boost::filesystem::exists(pathToTestDirectory + "/out_Leber.hdr")) + { + boost::filesystem::remove(pathToTestDirectory + "/out_Leber.hdr"); + } } - else if (i == 1) - { - CHECK_CLOSE(pixelValue, 0.819613, 1e-3); - } - } - - if (boost::filesystem::exists(pathToTestDirectory + "/out_Leber.img")) - { - boost::filesystem::remove(pathToTestDirectory + "/out_Leber.img"); } - if (boost::filesystem::exists(pathToTestDirectory + "/out_Leber.hdr")) - { - boost::filesystem::remove(pathToTestDirectory + "/out_Leber.hdr"); - } + RETURN_AND_REPORT_TEST_SUCCESS; } } - - RETURN_AND_REPORT_TEST_SUCCESS; } \ No newline at end of file diff --git a/testing/demoapps/VoxelizerTool/rttbVoxelizerToolVoxelizerAllStuctsTest.cpp b/testing/demoapps/VoxelizerTool/rttbVoxelizerToolVoxelizerAllStuctsTest.cpp index 52992b9..95d27b7 100644 --- a/testing/demoapps/VoxelizerTool/rttbVoxelizerToolVoxelizerAllStuctsTest.cpp +++ b/testing/demoapps/VoxelizerTool/rttbVoxelizerToolVoxelizerAllStuctsTest.cpp @@ -1,106 +1,111 @@ // ----------------------------------------------------------------------- // 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. Test all structs. */ -int main(int argc, char* argv[]) +namespace rttb { - PREPARE_DEFAULT_TEST_REPORTING; - - if (argc > 3) + namespace testing { - const std::string PathToBinaryDirectory = argv[1]; - const std::string tempDirectory = argv[2]; - const std::string RTToolBoxTestingDirectory = argv[3]; - - std::vector structs; - structs.push_back("Aussenkontur"); - structs.push_back("Rueckenmark"); - structs.push_back("Niere re."); - structs.push_back("Niere li."); - structs.push_back("Magen/DD"); - structs.push_back("Leber"); - structs.push_back("Darm"); - structs.push_back("Ref.Pkt."); - structs.push_back("PTV"); - structs.push_back("Boost"); - - std::vector filenames; - filenames.push_back("Aussenkontur"); - filenames.push_back("Rueckenmark"); - filenames.push_back("Niere re"); - filenames.push_back("Niere li"); - filenames.push_back("Magen_DD"); - filenames.push_back("Leber"); - filenames.push_back("Darm"); - filenames.push_back("Ref.Pkt"); - filenames.push_back("PTV"); - filenames.push_back("Boost"); - - const std::string baseCommand = PathToBinaryDirectory + - "Release/VoxelizerTool -s " + RTToolBoxTestingDirectory + - "data/DICOM/StructureSet/RS1.3.6.1.4.1.2452.6.841242143.1311652612.1170940299.4217870819.dcm -r " + - RTToolBoxTestingDirectory + "data/DICOM/TestDose/ConstantTwo.dcm -e \""; - - - - for (int i = 0; i < structs.size(); i++) - { - std::string command = baseCommand + structs.at(i) + "\""; - int returnValue = system(command.c_str()); - - CHECK_EQUAL(returnValue, 0); - - std::string HDRfileName = tempDirectory + "\\out_" + filenames.at(i) + ".hdr"; - std::string IMGfileName = tempDirectory + "\\out_" + filenames.at(i) + ".img"; - - CHECK_EQUAL( - boost::filesystem::exists(HDRfileName), - true); - CHECK_EQUAL( - boost::filesystem::exists(IMGfileName), - true); - boost::filesystem::path imgFile(IMGfileName); + int VoxelizerToolVoxelizerAllStructsTest(int argc, char* argv[]) + { + PREPARE_DEFAULT_TEST_REPORTING; - if (boost::filesystem::exists(imgFile)) + if (argc > 3) { - boost::filesystem::remove(imgFile); + const std::string PathToBinaryDirectory = argv[1]; + const std::string tempDirectory = argv[2]; + const std::string RTToolBoxTestingDirectory = argv[3]; + + std::vector structs; + structs.push_back("Aussenkontur"); + structs.push_back("Rueckenmark"); + structs.push_back("Niere re."); + structs.push_back("Niere li."); + structs.push_back("Magen/DD"); + structs.push_back("Leber"); + structs.push_back("Darm"); + structs.push_back("Ref.Pkt."); + structs.push_back("PTV"); + structs.push_back("Boost"); + + std::vector filenames; + filenames.push_back("Aussenkontur"); + filenames.push_back("Rueckenmark"); + filenames.push_back("Niere re"); + filenames.push_back("Niere li"); + filenames.push_back("Magen_DD"); + filenames.push_back("Leber"); + filenames.push_back("Darm"); + filenames.push_back("Ref.Pkt"); + filenames.push_back("PTV"); + filenames.push_back("Boost"); + + const std::string baseCommand = PathToBinaryDirectory + + "/Release/RTTBVoxelizerTool -s " + RTToolBoxTestingDirectory + + "/DICOM/StructureSet/RS1.3.6.1.4.1.2452.6.841242143.1311652612.1170940299.4217870819.dcm -r " + + RTToolBoxTestingDirectory + "/DICOM/TestDose/ConstantTwo.dcm -e \""; + + for (int i = 0; i < structs.size(); i++) + { + std::string command = baseCommand + structs.at(i) + "\""; + int returnValue = system(command.c_str()); + + CHECK_EQUAL(returnValue, 0); + + std::string HDRfileName = tempDirectory + "\\out_" + filenames.at(i) + ".hdr"; + std::string IMGfileName = tempDirectory + "\\out_" + filenames.at(i) + ".img"; + + CHECK_EQUAL( + boost::filesystem::exists(HDRfileName), + true); + CHECK_EQUAL( + boost::filesystem::exists(IMGfileName), + true); + + boost::filesystem::path imgFile(IMGfileName); + + if (boost::filesystem::exists(imgFile)) + { + boost::filesystem::remove(imgFile); + } + + boost::filesystem::path hdrFile(HDRfileName); + + if (boost::filesystem::exists(hdrFile)) + { + boost::filesystem::remove(hdrFile); + } + } } - boost::filesystem::path hdrFile(HDRfileName); - - if (boost::filesystem::exists(hdrFile)) - { - boost::filesystem::remove(hdrFile); - } + RETURN_AND_REPORT_TEST_SUCCESS; } } - - RETURN_AND_REPORT_TEST_SUCCESS; } \ No newline at end of file diff --git a/testing/demoapps/VoxelizerTool/rttbVoxelizerToolVoxelizerBoostLegacyTest.cpp b/testing/demoapps/VoxelizerTool/rttbVoxelizerToolVoxelizerBoostLegacyTest.cpp index 5e6b1a7..28ff466 100644 --- a/testing/demoapps/VoxelizerTool/rttbVoxelizerToolVoxelizerBoostLegacyTest.cpp +++ b/testing/demoapps/VoxelizerTool/rttbVoxelizerToolVoxelizerBoostLegacyTest.cpp @@ -1,86 +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: 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 "litCheckMacros.h" #include #include #include /*! @brief VoxelizerToolTest5. Test the paramter boost and legacy Voxelization. */ -int main(int argc, char* argv[]) +namespace rttb { - PREPARE_DEFAULT_TEST_REPORTING; - - if (argc > 3) + namespace testing { - const std::string PathToBinaryDirectory = argv[1]; - const std::string PathToTestingDirectory = argv[2]; - const std::string RTToolBoxTestingDirectory = argv[3]; - std::vector OutputVoxelization; - OutputVoxelization.push_back("Rueckenmark -o Test.hdr"); - OutputVoxelization.push_back("Leber -l"); - OutputVoxelization.push_back("Darm -b"); - OutputVoxelization.push_back("Leber -o Legacy.hdr -l"); - OutputVoxelization.push_back("Darm -o Boost.hdr -b"); + int VoxelizerToolVoxelizerBoostLegacy(int argc, char* argv[]) + { + PREPARE_DEFAULT_TEST_REPORTING; - std::vector OutputFiles; - OutputFiles.push_back("/Boost_Darm.hdr"); - OutputFiles.push_back("/Boost_Darm.img"); - OutputFiles.push_back("/Legacy_Leber.hdr"); - OutputFiles.push_back("/Legacy_Leber.img"); - OutputFiles.push_back("/out_Darm.hdr"); - OutputFiles.push_back("/out_Darm.img"); - OutputFiles.push_back("/out_Leber.hdr"); - OutputFiles.push_back("/out_Leber.img"); - OutputFiles.push_back("/Test_Rueckenmark.hdr"); - OutputFiles.push_back("/Test_Rueckenmark.img"); + if (argc > 3) + { + const std::string PathToBinaryDirectory = argv[1]; + const std::string PathToTestingDirectory = argv[2]; + const std::string RTToolBoxTestingDirectory = argv[3]; - const std::string baseCommand = PathToBinaryDirectory + - "Release/VoxelizerTool -s " + RTToolBoxTestingDirectory + - "data/DICOM/StructureSet/RS1.3.6.1.4.1.2452.6.841242143.1311652612.1170940299.4217870819.dcm -r " + - RTToolBoxTestingDirectory + "data/DICOM/TestDose/ConstantTwo.dcm -e "; + std::vector OutputVoxelization; + OutputVoxelization.push_back("Rueckenmark -o Test.hdr"); + OutputVoxelization.push_back("Leber -l"); + OutputVoxelization.push_back("Darm -b"); + OutputVoxelization.push_back("Leber -o Legacy.hdr -l"); + OutputVoxelization.push_back("Darm -o Boost.hdr -b"); - for (int i = 0 ; i < OutputVoxelization.size(); i++) - { - std::string Command = baseCommand + OutputVoxelization.at(i); - int returnValue = system(Command.c_str()); - CHECK_EQUAL(returnValue, 0); - } + std::vector OutputFiles; + OutputFiles.push_back("/Boost_Darm.hdr"); + OutputFiles.push_back("/Boost_Darm.img"); + OutputFiles.push_back("/Legacy_Leber.hdr"); + OutputFiles.push_back("/Legacy_Leber.img"); + OutputFiles.push_back("/out_Darm.hdr"); + OutputFiles.push_back("/out_Darm.img"); + OutputFiles.push_back("/out_Leber.hdr"); + OutputFiles.push_back("/out_Leber.img"); + OutputFiles.push_back("/Test_Rueckenmark.hdr"); + OutputFiles.push_back("/Test_Rueckenmark.img"); - for (int i = 0; i < OutputFiles.size(); i++) - { - std::string pathToFile = PathToTestingDirectory + OutputFiles.at(i); + const std::string baseCommand = PathToBinaryDirectory + + "/Release/RTTBVoxelizerTool -s " + RTToolBoxTestingDirectory + + "/DICOM/StructureSet/RS1.3.6.1.4.1.2452.6.841242143.1311652612.1170940299.4217870819.dcm -r " + + RTToolBoxTestingDirectory + "/DICOM/TestDose/ConstantTwo.dcm -e "; - CHECK_EQUAL(boost::filesystem::exists(pathToFile), true); + for (int i = 0 ; i < OutputVoxelization.size(); i++) + { + std::string Command = baseCommand + OutputVoxelization.at(i); + int returnValue = system(Command.c_str()); + CHECK_EQUAL(returnValue, 0); + } - if (boost::filesystem::exists(pathToFile)) - { - boost::filesystem::remove(pathToFile); + for (int i = 0; i < OutputFiles.size(); i++) + { + std::string pathToFile = PathToTestingDirectory + OutputFiles.at(i); + + CHECK_EQUAL(boost::filesystem::exists(pathToFile), true); + + if (boost::filesystem::exists(pathToFile)) + { + boost::filesystem::remove(pathToFile); + } + } } + + RETURN_AND_REPORT_TEST_SUCCESS; } - } - RETURN_AND_REPORT_TEST_SUCCESS; + } } \ No newline at end of file