diff --git a/RTToolboxConfigure.h.in b/RTToolboxConfigure.h.in index 34f0556..e3f92e7 100644 --- a/RTToolboxConfigure.h.in +++ b/RTToolboxConfigure.h.in @@ -1,102 +1,94 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ SIDT RT Interface // // 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$ (last changed revision) -// @date $Date$ (last change date) -// @author $Author$ (last changed by) -// -// Subversion HeadURL: $HeadURL: http://sidt-hpc1/dkfz_repository/NotMeVisLab/SIDT/RTToolbox/branch/restructure/RTToolboxConfigure.h.in $ -*/ //---------------------------------------------------------- // !!!EXPERIMENTAL CODE!!! // // This code may not be used for release. // Add #define SIDT_ENFORCE_MATURE_CODE to any release module // to ensure this policy. //---------------------------------------------------------- #ifdef SIDT_ENFORCE_MATURE_CODE #error �This code is marked as experimental code. It must not be used because this build enforces mature code.� #endif #ifndef SIDT_CONTAINS_EXPERIMENTAL_CODE #define SIDT_CONTAINS_EXPERIMENTAL_CODE 1 #endif /*! @def RTTB_BUILD_SHARED_LIBS * This define indicates if RTTB will be build as static library (define RTTB_STATIC) or as DLL (define RTTB_DLL). * By default RTTB_BUILD_SHARED_LIBS is not defined. */ #cmakedefine RTTB_BUILD_SHARED_LIBS #ifdef RTTB_BUILD_SHARED_LIBS #define RTTB_DLL #else #define RTTB_STATIC #endif #ifndef __RTTB_CONFIGURE_H #define __RTTB_CONFIGURE_H /*! @def RTTB_BUILD_SHARED_LIBS * This define indicates if RTTB will be build as static library (define RTTB_STATIC) or as DLL (define RTTB_DLL). * By default RTTB_BUILD_SHARED_LIBS is not defined. */ #cmakedefine RTTB_BUILD_SHARED_LIBS #ifdef RTTB_BUILD_SHARED_LIBS #define RTTB_DLL #else #define RTTB_STATIC #endif /*! @def RTTB_ENFORCE_MATURE_CODE * This define controls if RTToolbox should force the whole build to be mature code. * Mature code convention is part of the SIDT coding styles. * Projects that use RTToolbox are able to ensure with SIDT_ENFORCE_MATURE_CODE * that used code is guaranteed to be tested and reviewed regarding the strict * SIDT coding styles.\n * RTTB_ENFORCE_MATURE_CODE can be used to ensure that strictness when prebuilding * static or dynamic libraries. * @remark This definition should by configured via the advance options in CMake. */ #cmakedefine RTTB_ENFORCE_MATURE_CODE #ifdef RTTB_ENFORCE_MATURE_CODE #define SIDT_ENFORCE_MATURE_CODE #endif /*! @def RTTB_DISABLE_ITK_IO_FACTORY_AUTO_REGISTER * This define controls if RTToolbox should disable the auto * register functionality of the itk io factory, when RTToolbox * io reader and writer classes are used. * This is needed in cases where RTToolbox is build "dynamic" and * used in an application that also uses the ITK shared objects * under Windows systems (e.g. MITK). Loading and unloading RTToolbox * shared objects in such an application would lead to an corrupted * itk factory stack, because its implementation is not fail safe * in this scenario. * @remark This definition should by configured via the advance options in CMake. */ #cmakedefine RTTB_DISABLE_ITK_IO_FACTORY_AUTO_REGISTER #define RTTB_VERSION_MAJOR @RTToolbox_VERSION_MAJOR@ #define RTTB_VERSION_MINOR @RTToolbox_VERSION_MINOR@ #define RTTB_VERSION_PATCH @RTToolbox_VERSION_PATCH@ #define RTTB_VERSION_STRING "@RTToolbox_VERSION_STRING@" #define RTTB_FULL_VERSION_STRING "@RTToolbox_FULL_VERSION_STRING@" #endif diff --git a/cmake/moduleExports.h.in b/cmake/moduleExports.h.in index 26ba997..0e79d53 100644 --- a/cmake/moduleExports.h.in +++ b/cmake/moduleExports.h.in @@ -1,42 +1,36 @@ // ----------------------------------------------------------------------- // 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$ (last changed revision) -// @date $Date$ (last change date) -// @author $Author$ (last changed by) -*/ #include "RTToolboxConfigure.h" #ifndef @MODULE_NAME@_EXPORTS_H #define @MODULE_NAME@_EXPORTS_H #if defined(WIN32) && !defined(RTTB_STATIC) #ifdef @MODULE_PROVIDES@_EXPORTS #define @MODULE_EXPORT_DEFINE@ __declspec(dllexport) #else #define @MODULE_EXPORT_DEFINE@ __declspec(dllimport) #endif #else #define @MODULE_EXPORT_DEFINE@ #endif #ifndef _CMAKE_MODULENAME #ifdef @MODULE_PROVIDES@_EXPORTS #define _CMAKE_MODULENAME "@MODULE_NAME@" #endif #endif #endif diff --git a/code/io/helax/rttbDicomIODDoseAccessorGenerator.cpp b/code/io/helax/rttbDicomIODDoseAccessorGenerator.cpp index ceca521..ee10c34 100644 --- a/code/io/helax/rttbDicomIODDoseAccessorGenerator.cpp +++ b/code/io/helax/rttbDicomIODDoseAccessorGenerator.cpp @@ -1,58 +1,52 @@ // ----------------------------------------------------------------------- // 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$ (last changed revision) -// @date $Date$ (last change date) -// @author $Author$ (last changed by) -*/ #include <boost/make_shared.hpp> #include <boost/shared_ptr.hpp> #include "rttbDicomIODDoseAccessorGenerator.h" #include "rttbDicomDoseAccessor.h" #include "rttbNullPointerException.h" #include "rttbInvalidDoseException.h" #include "rttbDcmrtException.h" #include "rttbIndexOutOfBoundsException.h" namespace rttb { namespace io { namespace dicom { DicomIODDoseAccessorGenerator::~DicomIODDoseAccessorGenerator() {} DicomIODDoseAccessorGenerator::DicomIODDoseAccessorGenerator(DRTDoseIODPtr aDRTDoseIODP) { _doseIODPtr = aDRTDoseIODP; } core::DoseAccessorGeneratorInterface::DoseAccessorPointer DicomIODDoseAccessorGenerator::generateDoseAccessor() { _doseAccessor = boost::make_shared<io::dicom::DicomDoseAccessor>(_doseIODPtr); return _doseAccessor; } } } } diff --git a/testing/apps/DoseMap/DoseMapInvalidParametersTest.cpp b/testing/apps/DoseMap/DoseMapInvalidParametersTest.cpp index 960224d..06758ca 100644 --- a/testing/apps/DoseMap/DoseMapInvalidParametersTest.cpp +++ b/testing/apps/DoseMap/DoseMapInvalidParametersTest.cpp @@ -1,74 +1,68 @@ // ----------------------------------------------------------------------- // 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 <iostream> #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 + " -d test"; std::cout << "Command line call: " + toofewParametersCommand << std::endl; CHECK_EQUAL(system(toofewParametersCommand.c_str()) != 0, true); 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 + "-l wrongOption"; std::cout << "Command line call: " + invalidDoseLoadOption << std::endl; CHECK_EQUAL(system(invalidDoseLoadOption.c_str()) != 0, true); //call with invalid interpolator 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 90d7fb2..abe0044 100644 --- a/testing/apps/DoseMap/DoseMapSimpleTest.cpp +++ b/testing/apps/DoseMap/DoseMapSimpleTest.cpp @@ -1,109 +1,102 @@ // ----------------------------------------------------------------------- // 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 <iostream> #include "litCheckMacros.h" #include "litImageTester.h" #include "litTestImageIO.h" #include "boost/filesystem.hpp" #include "rttbITKImageAccessorConverter.h" - 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 refDoseLoadStyle; std::string inputDoseLoadStyle; std::string referenceFilename; boost::filesystem::path callingPath(_callingAppPath); if (argc > 5 ) { doseMapExecutable = argv[1]; inputFilename = argv[2]; inputDoseLoadStyle = argv[3]; regFilename = argv[4]; referenceFilename = argv[5]; } std::string defaultOutputFilename = "output.nrrd"; std::string doseMapExeWithPath = callingPath.parent_path().string() + "/" + doseMapExecutable; std::string baseCommand = doseMapExeWithPath + " \"" + inputFilename + "\" " + defaultOutputFilename; std::string defaultDoseMapCommand = baseCommand+" -l "+ inputDoseLoadStyle; std::cout << "Command line call: " + defaultDoseMapCommand << std::endl; CHECK_EQUAL(system(defaultDoseMapCommand.c_str()), 0); CHECK_EQUAL(boost::filesystem::exists(defaultOutputFilename), true); auto expectedImage = lit::TestImageIO<double, rttb::io::itk::ITKImageAccessorConverter::ITKImageType>::readImage( referenceFilename); auto actualImage = lit::TestImageIO<double, rttb::io::itk::ITKImageAccessorConverter::ITKImageType>::readImage( defaultOutputFilename); ::lit::ImageTester<io::itk::ITKImageAccessorConverter::ITKImageType, io::itk::ITKImageAccessorConverter::ITKImageType > tester; tester.setExpectedImage(expectedImage); tester.setActualImage(actualImage); CHECK_TESTER(tester); CHECK_EQUAL(std::remove(defaultOutputFilename.c_str()), 0); std::string defaultDoseMapCommandWithRegistration = defaultDoseMapCommand+ " -r \"" + regFilename + "\""; std::cout << "Command line call: " + defaultDoseMapCommandWithRegistration << std::endl; CHECK_EQUAL(system(defaultDoseMapCommandWithRegistration.c_str()), 0); CHECK_EQUAL(boost::filesystem::exists(defaultOutputFilename), true); actualImage = lit::TestImageIO<double, rttb::io::itk::ITKImageAccessorConverter::ITKImageType>::readImage( defaultOutputFilename); tester.setActualImage(actualImage); CHECK_TESTER(tester); CHECK_EQUAL(std::remove(defaultOutputFilename.c_str()), 0); RETURN_AND_REPORT_TEST_SUCCESS; } } //namespace testing } //namespace rttb diff --git a/testing/apps/DoseMap/DoseMapTests.cpp b/testing/apps/DoseMap/DoseMapTests.cpp index 6606858..18e505b 100644 --- a/testing/apps/DoseMap/DoseMapTests.cpp +++ b/testing/apps/DoseMap/DoseMapTests.cpp @@ -1,70 +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: 1374 $ (last changed revision) -// @date $Date: 2016-05-30 14:15:42 +0200 (Mo, 30 Mai 2016) $ (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" #include "RTToolboxConfigure.h" namespace rttb { namespace testing { const char* _callingAppPath = NULL; void registerTests() { LIT_REGISTER_TEST(DoseMapInvalidParametersTest); LIT_REGISTER_TEST(DoseMapSimpleTest); } } //namespace testing } //namespace map 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/io/other/OtherIOTest.cpp b/testing/io/other/OtherIOTest.cpp index 72ebc75..30f310a 100644 --- a/testing/io/other/OtherIOTest.cpp +++ b/testing/io/other/OtherIOTest.cpp @@ -1,183 +1,172 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // (c) Copyright 2007, DKFZ, Heidelberg, Germany // ALL RIGHTS RESERVED // // THIS FILE CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION OF DKFZ. // ANY DUPLICATION, MODIFICATION, DISTRIBUTION, OR // DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY PROHIBITED // WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF DKFZ. // //------------------------------------------------------------------------ -/*! -// @file -// @version $Revision$ (last changed revision) -// @date $Date$ (last change date) -// @author zhangl (last changed by) -// @author *none* (Reviewer) -// @author zhangl (Programmer) -// -// Subversion HeadURL: $HeadURL: http://sidt-hpc1/dkfz_repository/NotMeVisLab/SIDT/RTToolbox/trunk/testing/core/DVHCalculatorTest.cpp $ -*/ // this file defines the rttbCoreTests for the test driver // and all it expects is that you have a function called RegisterTests #include <boost/make_shared.hpp> #include <boost/shared_ptr.hpp> #include <boost/lexical_cast.hpp> #include "litCheckMacros.h" #include "rttbBaseType.h" #include "rttbDVH.h" #include "rttbDVHSet.h" #include "rttbDVHTxtFileReader.h" #include "rttbDVHTxtFileWriter.h" #include "rttbInvalidParameterException.h" #include "rttbNullPointerException.h" #include "../../core/DummyDVHGenerator.h" - namespace rttb { namespace testing { /*! @brief OtherIOTest - test the IO for DVH txt data 1) test writing dvh to text file 2) test reading DVH from text file 3) test reading and writing the same dvh */ int OtherIOTest(int argc, char* argv[]) { typedef core::DVHSet::DVHSetType DVHSetType; typedef core::DVH::DVHPointer DVHPointer; PREPARE_DEFAULT_TEST_REPORTING; std::string DVHTXT_FILENAME; if (argc > 1) { DVHTXT_FILENAME = argv[1]; } /* generate dummy DVH */ const IDType structureIDPrefix = "myStructure"; const IDType doseID = "myDose"; DummyDVHGenerator dvhGenerator; DVHPointer spMyDVH = boost::make_shared<core::DVH>(dvhGenerator.generateDVH(structureIDPrefix, doseID)); // 1) test writing DVH to text file DVHType typeCum = {DVHType::Cumulative}; DVHType typeDiff = {DVHType::Differential}; FileNameString fN1 = "test.txt"; CHECK_NO_THROW(io::other::DVHTxtFileWriter(fN1, typeDiff)); CHECK_NO_THROW(io::other::DVHTxtFileWriter(fN1, typeCum)); io::other::DVHTxtFileWriter dvhWriter(fN1, typeCum); CHECK_EQUAL(fN1, dvhWriter.getFileName()); FileNameString fN2 = "otherFile.txt"; CHECK_NO_THROW(dvhWriter.setFileName(fN2)); CHECK_EQUAL(fN2, dvhWriter.getFileName()); CHECK_EQUAL(DVHType::Cumulative, dvhWriter.getDVHType().Type); CHECK_NO_THROW(dvhWriter.setDVHType(typeDiff)); CHECK_EQUAL(DVHType::Differential, dvhWriter.getDVHType().Type); DVHPointer emptyDvh; CHECK_THROW_EXPLICIT(dvhWriter.writeDVH(emptyDvh), core::NullPointerException); CHECK_NO_THROW(dvhWriter.setDVHType(typeDiff)); CHECK_NO_THROW(dvhWriter.writeDVH(spMyDVH)); // 2) test reading DVH from text file CHECK_NO_THROW(io::other::DVHTxtFileReader dvhReader(fN1)); io::other::DVHTxtFileReader dvhReaderTest(fN1); CHECK_THROW_EXPLICIT(dvhReaderTest.generateDVH(), core::InvalidParameterException); CHECK_NO_THROW(io::other::DVHTxtFileReader dvhReader(fN2)); io::other::DVHTxtFileReader dvhReader(fN2); CHECK_NO_THROW(dvhReader.resetFileName(fN1)); CHECK_THROW_EXPLICIT(dvhReader.generateDVH(), core::InvalidParameterException); CHECK_NO_THROW(dvhReader.resetFileName(fN2)); CHECK_NO_THROW(dvhReader.generateDVH()); DVHPointer importedDVH = dvhReader.generateDVH(); CHECK_EQUAL(*importedDVH, *spMyDVH); // 3) test reading and writing the same dvh //read dvh from a txt file io::other::DVHTxtFileReader dvhReader_R(DVHTXT_FILENAME); rttb::core::DVHGeneratorInterface::DVHPointer dvhP_R = dvhReader_R.generateDVH(); //write the dvh to another file as cumulative io::other::DVHTxtFileWriter dvhWriter_R_Cum("test_Cum.txt", typeCum); dvhWriter_R_Cum.writeDVH(dvhP_R); //read the file io::other::DVHTxtFileReader dvhReader_W_Cum("test_Cum.txt"); rttb::core::DVHGeneratorInterface::DVHPointer dvhP_W_Cum = dvhReader_W_Cum.generateDVH(); //check equal const double errorConstant = 1e-7; CHECK_CLOSE(dvhP_R->getDeltaD(), dvhP_W_Cum->getDeltaD(), errorConstant); CHECK_CLOSE(dvhP_R->getDeltaV(), dvhP_W_Cum->getDeltaV(), errorConstant); CHECK(dvhP_R->getDoseID() == dvhP_W_Cum->getDoseID()); CHECK(dvhP_R->getStructureID() == dvhP_W_Cum->getStructureID()); CHECK_CLOSE(dvhP_R->getMaximum(), dvhP_W_Cum->getMaximum(), errorConstant); CHECK_CLOSE(dvhP_R->getMinimum(), dvhP_W_Cum->getMinimum(), errorConstant); CHECK_CLOSE(dvhP_R->getMean(), dvhP_W_Cum->getMean(), errorConstant); CHECK(dvhP_R->getDataDifferential().size() == dvhP_W_Cum->getDataDifferential().size()); for (int i = 0; i < dvhP_R->getDataDifferential().size(); i++) { CHECK_CLOSE(dvhP_R->getDataDifferential().at(i), dvhP_W_Cum->getDataDifferential().at(i), errorConstant); } //write the dvh to another file as differential io::other::DVHTxtFileWriter dvhWriter_R_Diff("test_Diff.txt", typeDiff); dvhWriter_R_Diff.writeDVH(dvhP_R); //read the file io::other::DVHTxtFileReader dvhReader_W_Diff("test_Diff.txt"); rttb::core::DVHGeneratorInterface::DVHPointer dvhP_W_Diff = dvhReader_W_Diff.generateDVH(); //check equal CHECK_CLOSE(dvhP_R->getDeltaD(), dvhP_W_Diff->getDeltaD(), errorConstant); CHECK_CLOSE(dvhP_R->getDeltaV(), dvhP_W_Diff->getDeltaV(), errorConstant); CHECK(dvhP_R->getDoseID() == dvhP_W_Diff->getDoseID()); CHECK(dvhP_R->getStructureID() == dvhP_W_Diff->getStructureID()); CHECK_CLOSE(dvhP_R->getMaximum(), dvhP_W_Diff->getMaximum(), errorConstant); CHECK_CLOSE(dvhP_R->getMinimum(), dvhP_W_Diff->getMinimum(), errorConstant); CHECK_CLOSE(dvhP_R->getMean(), dvhP_W_Diff->getMean(), errorConstant); CHECK(dvhP_R->getDataDifferential().size() == dvhP_W_Diff->getDataDifferential().size()); for (int i = 0; i < dvhP_R->getDataDifferential().size(); i++) { CHECK_CLOSE(dvhP_R->getDataDifferential().at(i), dvhP_W_Diff->getDataDifferential().at(i), errorConstant); } RETURN_AND_REPORT_TEST_SUCCESS; } }//testing }//rttb diff --git a/testing/io/rttbDoseAccessorTester.cpp b/testing/io/rttbDoseAccessorTester.cpp index 3b5a83a..a2a401a 100644 --- a/testing/io/rttbDoseAccessorTester.cpp +++ b/testing/io/rttbDoseAccessorTester.cpp @@ -1,152 +1,147 @@ // ----------------------------------------------------------------------- // 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 $ (last changed revision) -// @date $Date $ (last change date) -// @author $Author $ (last changed by) -*/ + #include <sstream> #include "rttbGeometricInfo.h" #include "rttbDoseAccessorTester.h" namespace rttb { namespace testing { DoseAccessorTester::DoseAccessorTester(DoseAccessorPointer aReferenceDose, DoseAccessorPointer aCompareDose) : _referenceDose(aReferenceDose), _compareDose(aCompareDose), _geometryIsSimilar(false), _sameGridSize(false), _conversionFailed(false), _numDifference(0) {} void DoseAccessorTester::setReferenceDose(const DoseAccessorPointer aReferenceDose) { _referenceDose = aReferenceDose; } void DoseAccessorTester::setCompareDose(const DoseAccessorPointer aCompareDose) { _compareDose = aCompareDose; } lit::StringType DoseAccessorTester::getTestDescription(void) const { return "Compare two DoseAccessors and determine if the contained doses are equal."; }; bool DoseAccessorTester::doCheck(void) const { _pResults->onTestStart(getCurrentTestLabel()); _geometryIsSimilar = (_referenceDose->getGeometricInfo() == _compareDose->getGeometricInfo()); if (!_geometryIsSimilar) { return false; } _sameGridSize = (_referenceDose->getGridSize() == _compareDose->getGridSize()); if (!_sameGridSize) { return false; } _numDifference = 0; _maxDifference = 0; VoxelGridIndex3D id3D; for (VoxelGridID id = 0; id < _referenceDose->getGridSize(); id++) { _compareDose->getGeometricInfo().convert(id, id3D); if (!_compareDose->getGeometricInfo().validIndex(id3D)) { _conversionFailed = true; _failedID = id; return false; } if ((_referenceDose-> getValueAt(id) != _referenceDose-> getValueAt(id3D)) || (_compareDose->getValueAt(id) != _compareDose-> getValueAt(id3D))) { _conversionFailed = true; _failedID = id; return false; } if ((_referenceDose->getValueAt(id) != _compareDose->getValueAt(id)) || (_referenceDose->getValueAt(id3D) != _compareDose->getValueAt(id3D))) { double tmpDifference = std::abs(_referenceDose->getValueAt(id) - _compareDose->getValueAt(id)); if (tmpDifference > _maxDifference) { _maxDifference = tmpDifference; } _numDifference++; } }//end for(VoxelGridID id = 0; id < _referenceDose->getGridSize(); id++) return (_numDifference == 0); } void DoseAccessorTester::handleSuccess(void) const { std::ostringstream stream; stream << "Both doses are equal" << std::endl; _pResults->onTestSuccess(getCurrentTestLabel(), stream.str()); } void DoseAccessorTester::handleFailure(void) const { std::ostringstream stream; stream << "Doses are different" << std::endl; if (_geometryIsSimilar) { if (_sameGridSize) { stream << std::endl << "Error voxel count: " << _numDifference << std::endl; stream << std::endl << "Maximum difference: " << _maxDifference << std::endl; if (_conversionFailed) { stream << std::endl << "Index conversion failed in: " << _failedID << std::endl; } } else { stream << "Doses have different grid sizes" << std::endl; stream << "Reference dose contains " << _referenceDose->getGridSize() << " voxels and comparison dose " << _compareDose->getGridSize() << std::endl; } } else { stream << "Doses have different geometry" << std::endl; } _pResults->onTestFailure(getCurrentTestLabel(), stream.str()); } } } \ No newline at end of file diff --git a/testing/io/rttbDoseAccessorTester.h b/testing/io/rttbDoseAccessorTester.h index 80e8e40..ff14e28 100644 --- a/testing/io/rttbDoseAccessorTester.h +++ b/testing/io/rttbDoseAccessorTester.h @@ -1,97 +1,91 @@ // ----------------------------------------------------------------------- // 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$ (last changed revision) -// @date $Date$ (last change date) -// @author $Author$ (last changed by) -*/ #ifndef __DOSE_ACCESSOR_TESTER_H #define __DOSE_ACCESSOR_TESTER_H #include <boost/shared_ptr.hpp> #include "litTesterBase.h" #include "litString.h" #include "rttbBaseType.h" #include "../../code/core/rttbDoseAccessorInterface.h" namespace rttb { namespace testing { /*! class DoseAccessorTester @brief Tester class for io classes. Compares two given DoseAccessors for similarity. These DoseAccessors are not similar if their geometry or grid size are not similar, if the conversion of a given ID is invalid for one of the accessors, or if the dose at a given ID is not the same for both accessors. */ class DoseAccessorTester: public lit::TesterBase { public: typedef core::DoseAccessorInterface::DoseAccessorPointer DoseAccessorPointer; private: DoseAccessorPointer _referenceDose; DoseAccessorPointer _compareDose; mutable double _maxDifference; mutable double _numDifference; mutable bool _geometryIsSimilar; mutable bool _sameGridSize; mutable bool _conversionFailed; mutable VoxelGridID _failedID; public: DoseAccessorTester(DoseAccessorPointer aReferenceDose, DoseAccessorPointer aCompareDose); /*! Set the dose accessor pointer for the dose comparison. */ void setReferenceDose(const DoseAccessorPointer aReferenceDose); void setCompareDose(const DoseAccessorPointer aCompareDose); /*! Returns a string that specifies the test the tester currently performs. */ lit::StringType getTestDescription(void) const; lit::StringType getTestName(void) const { return "DoseAccessorTester"; }; protected: /*! performs the test and checks the results. @result Indicates if the test was successful (true) or if it failed (false) */ bool doCheck(void) const; /*! Function will be called by check() if test was succesfull. */ void handleSuccess(void) const; /*! Function will be called by check() if test was a failure. */ void handleFailure(void) const; }; } } #endif \ No newline at end of file diff --git a/testing/masks/rttbMaskRectStructTester.cpp b/testing/masks/rttbMaskRectStructTester.cpp index 2748519..1730cf5 100644 --- a/testing/masks/rttbMaskRectStructTester.cpp +++ b/testing/masks/rttbMaskRectStructTester.cpp @@ -1,185 +1,180 @@ // ----------------------------------------------------------------------- // 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 $ (last changed revision) -// @date $Date $ (last change date) -// @author $Author $ (last changed by) -*/ + #include <sstream> #include "rttbMaskRectStructTester.h" #include "rttbGeometricInfo.h" namespace rttb { namespace testing { MaskRectStructTester::MaskRectStructTester(MaskAccessorPointer aMaskAccessor, GridIndexType z) { _maskAccessor = aMaskAccessor; _referenceList = _maskAccessor->getRelevantVoxelVector(); _differentSlice = false; _outsideStructure = false; _wrongRVF = false; _conversionFailed = false; _zIndex = z; } void MaskRectStructTester::setAccessor(const MaskAccessorPointer aMaskAccessor) { _maskAccessor = aMaskAccessor; _referenceList = _maskAccessor->getRelevantVoxelVector(); } void MaskRectStructTester::setZ(const GridIndexType z) { _zIndex = z; } lit::StringType MaskRectStructTester::getTestDescription(void) const { return "Check if generated MaskVoxelList corresponds to the given rectangular structure."; }; bool MaskRectStructTester::doCheck(void) const { _pResults->onTestStart(getCurrentTestLabel()); _differentSlice = false; _outsideStructure = false; _wrongRVF = false; _conversionFailed = false; VoxelGridIndex3D indexOTB; MaskVoxelList::iterator iterR; VoxelGridID index = 0; for (iterR = _referenceList->begin(); iterR != _referenceList->end(); ++iterR, ++index) { if (!(_maskAccessor->getGeometricInfo().convert(iterR->getVoxelGridID(), indexOTB))) { _conversionFailed = true; _failedListIndex = index; break; } if (indexOTB.z() != _zIndex) { _differentSlice = true; _failedListIndex = index; _wrongVal = indexOTB.z(); break; } //corners are [2,1],[5,1],[5,5],[2,5], relevant voxels need to lie inside else if ((indexOTB.x() < 2) || (indexOTB.x() > 5)) { _outsideStructure = true; _failedListIndex = index; break; } else if ((indexOTB.y() < 1) || (indexOTB.y() > 5)) { _outsideStructure = true; _failedListIndex = index; break; } //check corners else if ((indexOTB.x() == 2 && indexOTB.y() == 1) || (indexOTB.x() == 2 && indexOTB.y() == 5) || (indexOTB.x() == 5 && indexOTB.y() == 1) || (indexOTB.x() == 5 && indexOTB.y() == 5)) { if (0.25 != iterR->getRelevantVolumeFraction()) { _wrongRVF = true; _failedListIndex = index; _wrongVal = iterR->getRelevantVolumeFraction(); break; } } else if ((indexOTB.x() == 2) || (indexOTB.y() == 5) || (indexOTB.y() == 1) || (indexOTB.x() == 5)) { if (0.5 != iterR->getRelevantVolumeFraction()) { _wrongRVF = true; _failedListIndex = index; _wrongVal = iterR->getRelevantVolumeFraction(); break; } } //check sides else //should be inside { if (1 != iterR->getRelevantVolumeFraction()) { _wrongRVF = true; _failedListIndex = index; _wrongVal = iterR->getRelevantVolumeFraction(); break; } } }//end for(iterR = _referenceList->begin(); iterR != _referenceLi... if (_conversionFailed || _differentSlice || _outsideStructure || _wrongRVF) { return false; } return true; } void MaskRectStructTester::handleSuccess(void) const { std::ostringstream stream; stream << "The Voxelization is inside the given rectangle" << std::endl; _pResults->onTestSuccess(getCurrentTestLabel(), stream.str()); } void MaskRectStructTester::handleFailure(void) const { std::ostringstream stream; stream << "Voxelization was not correct" << std::endl; if (_conversionFailed) { stream << std::endl << "The conversion failed at position" << _failedListIndex << std::endl; } if (_differentSlice) { stream << std::endl << "The voxelisation was not in plane " << _zIndex << " at position " << _failedListIndex << " was in " << _wrongVal << std::endl; } if (_outsideStructure) { stream << std::endl << "The voxelisation was outside the rectangle at position " << _failedListIndex << std::endl; } if (_wrongRVF) { stream << std::endl << "The voxelisation had the wrong relevant volume fraction at position " << _failedListIndex << " was in " << _wrongVal << std::endl; } _pResults->onTestFailure(getCurrentTestLabel(), stream.str()); } } } \ No newline at end of file diff --git a/testing/masks/rttbMaskRectStructTester.h b/testing/masks/rttbMaskRectStructTester.h index 4b11ac3..b85638b 100644 --- a/testing/masks/rttbMaskRectStructTester.h +++ b/testing/masks/rttbMaskRectStructTester.h @@ -1,102 +1,96 @@ // ----------------------------------------------------------------------- // 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$ (last changed revision) -// @date $Date$ (last change date) -// @author $Author$ (last changed by) -*/ #ifndef __MASK_RECT_TESTER_H #define __MASK_RECT_TESTER_H #include <boost/shared_ptr.hpp> #include "litTesterBase.h" #include "litString.h" #include "rttbBaseType.h" #include "../../code/core/rttbMaskAccessorInterface.h" namespace rttb { namespace testing { /*! class MaskRectStructTester @brief Tests if masked voxel are all inside the given boundaries The boundaries are defined in DummyStructure::CreateRectangularStructureCentered @see DummyStructure */ class MaskRectStructTester: public lit::TesterBase { private: typedef core::MaskAccessorInterface::MaskVoxelListPointer MaskVoxelListPointer; typedef core::MaskAccessorInterface::MaskVoxelList MaskVoxelList; typedef core::MaskAccessorInterface::MaskAccessorPointer MaskAccessorPointer; MaskVoxelListPointer _referenceList; MaskAccessorPointer _maskAccessor; GridIndexType _zIndex; mutable bool _conversionFailed; mutable bool _differentSlice; mutable bool _outsideStructure; mutable bool _wrongRVF; mutable VoxelGridID _failedListIndex; mutable double _wrongVal; public: MaskRectStructTester(MaskAccessorPointer aMaskAccessor, GridIndexType z); /*! Set the mask accessor pointer for the dose comparison. */ void setAccessor(const MaskAccessorPointer aMaskAccessor); /*! Set index of slice containing the dummy structure. */ void setZ(const GridIndexType z); /*! Returns a string that specifies the test the tester currently performs. */ lit::StringType getTestDescription(void) const; lit::StringType getTestName(void) const { return "MaskRectStructTester"; }; protected: /*! performes the test and checks the results. @result Indicates if the test was successfull (true) or if it failed (false) */ bool doCheck(void) const; /*! Function will be called be check() if test was succesfull. */ void handleSuccess(void) const; /*! Function will be called be check() if test was a failure. */ void handleFailure(void) const; }; } } #endif \ No newline at end of file diff --git a/testing/masks/rttbMaskVoxelListTester.cpp b/testing/masks/rttbMaskVoxelListTester.cpp index be7533b..c658eda 100644 --- a/testing/masks/rttbMaskVoxelListTester.cpp +++ b/testing/masks/rttbMaskVoxelListTester.cpp @@ -1,150 +1,145 @@ // ----------------------------------------------------------------------- // 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 $ (last changed revision) -// @date $Date $ (last change date) -// @author $Author $ (last changed by) -*/ + #include <sstream> #include "rttbMaskVoxelListTester.h" namespace rttb { namespace testing { MaskVoxelListTester::MaskVoxelListTester(MaskVoxelListPointer aReferenceList, MaskVoxelListPointer aCompareList) { _referenceList = aReferenceList; _compareList = aCompareList; _sameSize = false; _masVoxelsDiffer = false; _numDifference = 0; } void MaskVoxelListTester::setReferenceList(const MaskVoxelListPointer aReferenceList) { _referenceList = aReferenceList; } void MaskVoxelListTester::setCompareList(const MaskVoxelListPointer aCompareList) { _compareList = aCompareList; } lit::StringType MaskVoxelListTester::getTestDescription(void) const { return "Compare two MaskVoxelLists and determine if the contained content is equal."; }; bool MaskVoxelListTester::doCheck(void) const { _pResults->onTestStart(getCurrentTestLabel()); _masVoxelsDiffer = false; if (_referenceList->size() == _compareList->size()) { _sameSize = true; } else { _sameSize = false; return false; } _numDifference = 0; _maxDifference = 0; MaskVoxelList::iterator iterR, iterC; iterC = _compareList->begin(); VoxelGridID index = 0; for (iterR = _referenceList->begin(); iterR != _referenceList->end(); ++iterR, ++iterC, ++index) { if (iterR->getVoxelGridID() == iterC->getVoxelGridID()) { if (iterR->getRelevantVolumeFraction() == iterC->getRelevantVolumeFraction()) { continue; } else { double diff = iterR->getRelevantVolumeFraction() - iterC->getRelevantVolumeFraction(); if (diff > _maxDifference) { _maxDifference = diff; } _numDifference++; } } else { _failedListIndex = index; _masVoxelsDiffer = true; return false; } } if (_numDifference > 0) { return false; } return true; } void MaskVoxelListTester::handleSuccess(void) const { std::ostringstream stream; stream << "Both Lists are equal" << std::endl; _pResults->onTestSuccess(getCurrentTestLabel(), stream.str()); } void MaskVoxelListTester::handleFailure(void) const { std::ostringstream stream; stream << "Lists were different" << std::endl; if (_sameSize) { stream << std::endl << "Error of volume fraction voxel count: " << _numDifference << std::endl; stream << std::endl << "Maximum difference in volume fraction: " << _maxDifference << std::endl; if (_masVoxelsDiffer) { stream << std::endl << "Mask points to different grid position in: " << _failedListIndex << std::endl; } } else { stream << "Lists have different size" << std::endl; stream << "Reference List is " << _referenceList->size() << " voxels long and comparison List " << _compareList->size() << std::endl; } _pResults->onTestFailure(getCurrentTestLabel(), stream.str()); } } } \ No newline at end of file diff --git a/testing/masks/rttbMaskVoxelListTester.h b/testing/masks/rttbMaskVoxelListTester.h index b07d312..e0aa5c2 100644 --- a/testing/masks/rttbMaskVoxelListTester.h +++ b/testing/masks/rttbMaskVoxelListTester.h @@ -1,95 +1,89 @@ // ----------------------------------------------------------------------- // 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$ (last changed revision) -// @date $Date$ (last change date) -// @author $Author$ (last changed by) -*/ #ifndef __MASK_VL_TESTER_H #define __MASK_VL_TESTER_H #include <boost/shared_ptr.hpp> #include "litTesterBase.h" #include "litString.h" #include "rttbBaseType.h" #include "../../code/core/rttbMaskAccessorInterface.h" namespace rttb { namespace testing { /*! class MaskVoxelListTester @brief Tester class for lists. Compares two given lists for similarity. Both lists need to have the same length and have equal values in each element to be considered similar. */ class MaskVoxelListTester: public lit::TesterBase { private: typedef core::MaskAccessorInterface::MaskVoxelListPointer MaskVoxelListPointer; typedef core::MaskAccessorInterface::MaskVoxelList MaskVoxelList; MaskVoxelListPointer _referenceList; MaskVoxelListPointer _compareList; mutable double _maxDifference; mutable double _numDifference; mutable bool _sameSize; mutable bool _masVoxelsDiffer; mutable VoxelGridID _failedListIndex; public: MaskVoxelListTester(MaskVoxelListPointer aReferenceList, MaskVoxelListPointer aCompareList); /*! Set the dose accessor pointer for the dose comparison. */ void setReferenceList(const MaskVoxelListPointer aReferenceList); void setCompareList(const MaskVoxelListPointer aCompareList); /*! Returns a string that specifies the test the tester currently performs. */ lit::StringType getTestDescription(void) const; lit::StringType getTestName(void) const { return "MaskVoxelListTester"; }; protected: /*! performes the test and checks the results. @result Indicates if the test was successfull (true) or if it failed (false) */ bool doCheck(void) const; /*! Function will be called be check() if test was succesfull. */ void handleSuccess(void) const; /*! Function will be called be check() if test was a failure. */ void handleFailure(void) const; }; } } #endif \ No newline at end of file