diff --git a/code/core/files.cmake b/code/core/files.cmake index 60d2b55..2b98a16 100644 --- a/code/core/files.cmake +++ b/code/core/files.cmake @@ -1,60 +1,62 @@ SET(CPP_FILES rttbDoseIteratorInterface.cpp rttbDVH.cpp rttbDVHCalculator.cpp rttbDVHSet.cpp rttbException.cpp rttbGenericDoseIterator.cpp rttbGenericMaskedDoseIterator.cpp rttbGeometricInfo.cpp rttbIndexOutOfBoundsException.cpp rttbInvalidDoseException.cpp rttbInvalidParameterException.cpp rttbMappingOutsideOfImageException.cpp rttbMaskedDoseIteratorInterface.cpp rttbMaskVoxel.cpp rttbNullPointerException.cpp rttbPaddingException.cpp rttbPhysicalInfo.cpp rttbStructure.cpp rttbStructureSet.cpp rttbStrVectorStructureSetGenerator.cpp + rttbDoseAccessorWithGeoInfoBase.cpp ) SET(H_FILES rttbBaseType.h rttbDoseAccessorGeneratorBase.h rttbDoseAccessorGeneratorInterface.h rttbDoseAccessorInterface.h + rttbDoseAccessorWithGeoInfoBase.h rttbDoseIteratorInterface.h rttbDVH.h rttbDVHCalculator.h rttbDVHGeneratorInterface.h rttbDVHSet.h rttbException.h rttbExceptionMacros.h rttbGenericDoseIterator.h rttbGenericMaskedDoseIterator.h rttbGeometricInfo.h rttbIndexConversionInterface.h rttbIndexOutOfBoundsException.h rttbInvalidDoseException.h rttbInvalidParameterException.h rttbMappingOutsideOfImageException.h rttbMaskAccessorGeneratorBase.h rttbMaskAccessorGeneratorInterface.h rttbMaskAccessorInterface.h rttbMaskAccessorProcessorBase.h rttbMaskAccessorProcessorInterface.h rttbMaskedDoseIteratorInterface.h rttbMaskVoxel.h rttbMutableDoseAccessorInterface.h rttbMutableMaskAccessorInterface.h rttbNullPointerException.h rttbPaddingException.h rttbPhysicalInfo.h rttbStructure.h rttbStructureSet.h rttbStructureSetGeneratorInterface.h rttbStrVectorStructureSetGenerator.h ) diff --git a/code/core/rttbDoseAccessorInterface.h b/code/core/rttbDoseAccessorInterface.h index e5f8e24..c6b1727 100644 --- a/code/core/rttbDoseAccessorInterface.h +++ b/code/core/rttbDoseAccessorInterface.h @@ -1,81 +1,92 @@ // ----------------------------------------------------------------------- // 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_INTERFACE_NEW_H #define __DOSE_ACCESSOR_INTERFACE_NEW_H #include #include "rttbBaseType.h" #include "rttbGeometricInfo.h" #include "rttbIndexConversionInterface.h" namespace rttb { - namespace core - { - - /*! @class IndexConversionInterface - @brief This class represents the conversion of 3D grid indices to 1D grid IDs. - */ - class DoseAccessorInterface: public IndexConversionInterface - { - public: - typedef boost::shared_ptr DoseAccessorPointer; - private: - DoseAccessorInterface(const DoseAccessorInterface&); //not implemented on purpose -> non-copyable - DoseAccessorInterface& operator=(const - DoseAccessorInterface&);//not implemented on purpose -> non-copyable - - public: - DoseAccessorInterface() {}; - virtual ~DoseAccessorInterface() {}; - - inline const core::GeometricInfo& getGeometricInfo() const - { - return _geoInfo; - }; - - inline GridSizeType getGridSize() const - { - return _geoInfo.getNumberOfVoxels(); - }; - - virtual DoseTypeGy getDoseAt(const VoxelGridID aID) const = 0; - - virtual DoseTypeGy getDoseAt(const VoxelGridIndex3D& aIndex) const = 0; - - /*! @brief is true if dose is on a homogeneous grid - @remarks Inhomogeneous grids are not supported at the moment, but if they will be supported in the future - the interface does not need to change. - */ - virtual bool isGridHomogeneous() const - { - return true; - } - - virtual const IDType getDoseUID() const = 0; - protected: - core::GeometricInfo _geoInfo; - }; - } + namespace core + { + + /*! @class IndexConversionInterface + @brief This class represents the conversion of 3D grid indices to 1D grid IDs. + */ + class DoseAccessorInterface: public IndexConversionInterface + { + public: + typedef boost::shared_ptr DoseAccessorPointer; + private: + DoseAccessorInterface(const DoseAccessorInterface&); //not implemented on purpose -> non-copyable + DoseAccessorInterface& operator=(const + DoseAccessorInterface&);//not implemented on purpose -> non-copyable + + public: + DoseAccessorInterface() {}; + virtual ~DoseAccessorInterface() {}; + + /*! @brief test if given ID is inside current dose grid + */ + bool validID(const VoxelGridID aID) const + { + return this->getGeometricInfo().validID(aID); + }; + + + /*! @brief test if given index is inside current dose grid + */ + bool validIndex(const VoxelGridIndex3D& aIndex) const + { + return this->getGeometricInfo().validIndex(aIndex); + }; + + virtual const core::GeometricInfo& getGeometricInfo() const = 0; + + virtual GridSizeType getGridSize() const + { + return this->getGeometricInfo().getNumberOfVoxels(); + }; + + virtual DoseTypeGy getDoseAt(const VoxelGridID aID) const = 0; + + virtual DoseTypeGy getDoseAt(const VoxelGridIndex3D& aIndex) const = 0; + + /*! @brief is true if dose is on a homogeneous grid + @remarks Inhomogeneous grids are not supported at the moment, but if they will be supported in the future + the interface does not need to change. + */ + virtual bool isGridHomogeneous() const + { + return true; + } + + virtual const IDType getDoseUID() const = 0; + + }; + } } #endif diff --git a/code/core/rttbDoseAccessorWithGeoInfoBase.cpp b/code/core/rttbDoseAccessorWithGeoInfoBase.cpp new file mode 100644 index 0000000..15b9452 --- /dev/null +++ b/code/core/rttbDoseAccessorWithGeoInfoBase.cpp @@ -0,0 +1,47 @@ +// ----------------------------------------------------------------------- +// 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: 877 $ (last changed revision) +// @date $Date: 2015-01-09 10:51:10 +0100 (Fr, 09 Jan 2015) $ (last change date) +// @author $Author: hentsch $ (last changed by) +*/ + + +#include "rttbDoseAccessorWithGeoInfoBase.h" + +namespace rttb +{ + namespace core + { + + const core::GeometricInfo& + DoseAccessorWithGeoInfoBase:: + getGeometricInfo() const + { + return _geoInfo; + } + + DoseAccessorWithGeoInfoBase::~DoseAccessorWithGeoInfoBase() + { + } + + DoseAccessorWithGeoInfoBase::DoseAccessorWithGeoInfoBase() + { + } + + } +} + diff --git a/code/core/rttbDoseAccessorWithGeoInfoBase.h b/code/core/rttbDoseAccessorWithGeoInfoBase.h new file mode 100644 index 0000000..2891d36 --- /dev/null +++ b/code/core/rttbDoseAccessorWithGeoInfoBase.h @@ -0,0 +1,50 @@ +// ----------------------------------------------------------------------- +// 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: 877 $ (last changed revision) +// @date $Date: 2015-01-09 10:51:10 +0100 (Fr, 09 Jan 2015) $ (last change date) +// @author $Author: hentsch $ (last changed by) +*/ +#ifndef __DOSE_ACCESSOR_WITH_GEO_INFO_BASE_H +#define __DOSE_ACCESSOR_WITH_GEO_INFO_BASE_H + +#include "rttbDoseAccessorInterface.h" + +namespace rttb +{ + namespace core + { + + /*! @class DoseAccessorWithGeoInfoBase + @brief Base class for all accessor implementations that have there own geometric info. + */ + class DoseAccessorWithGeoInfoBase: public core::DoseAccessorInterface + { + protected: + core::GeometricInfo _geoInfo; + + public: + ~DoseAccessorWithGeoInfoBase(); + + DoseAccessorWithGeoInfoBase(); + + virtual const core::GeometricInfo& getGeometricInfo() const; + + }; + } +} + +#endif diff --git a/code/core/rttbExceptionMacros.h b/code/core/rttbExceptionMacros.h index 70a0be8..98e8bd9 100644 --- a/code/core/rttbExceptionMacros.h +++ b/code/core/rttbExceptionMacros.h @@ -1,69 +1,109 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) */ #include #include "rttbException.h" /*!@def rttbDefaultExceptionMacro * This macro is used to throw a basic ExceptionObject within an object method. * It will generate the exception message and throw the exception.\n -* Use mapGenericDefaultExceptionMacro() for other objects that do not compli with the api or for +* Use rttbDefaultExceptionStaticMacro() for other objects that do not compli with the api or for * static functions.\n * Use rttbExceptionMacro() if you want to specifiy a arbitrary exception class that should be thrown. * Example usage looks like: * rttbDefaultExceptionMacro(<< "this is an exception" << this->SomeVariable); * @ingroup Exception -* @todo for future extension of the exception classes: Use if file and line are supported in Exception +* @todo for future extension of the exception classes: Use if file and line are supported in Exception * ::rttb::core::Exception e_(__FILE__, __LINE__, message.str().c_str()); */ #define rttbDefaultExceptionMacro(x) \ { \ - std::ostringstream message; \ - message << "Exception: " \ - << "(" << this << "): " x; \ - ::rttb::core::Exception e_(message.str().c_str()); \ - throw e_; /* Explicit naming to work around Intel compiler bug. */ \ + std::ostringstream message; \ + message << "Exception: " \ + << "(" << this << "): " x; \ + ::rttb::core::Exception e_(message.str().c_str()); \ + throw e_; /* Explicit naming to work around Intel compiler bug. */ \ } - + /*!@def mapExceptionMacro * This macro is used to throw the passed exception class within an object method. * The macro presumes that the object owns a method this->GetNameOfClass().\n * The macro will set file name, line number and function signiture to the exception * and log the exception as error in the logbook before throwing it.\n -* Use mapGenericExceptionMacro() for other objects that do not compli with the api or for +* Use rttbExceptionStaticMacro() for other objects that do not compli with the api or for * static functions.\n * @sa mapGenericExceptionMacro * * Example usage looks like: * rttbExceptionMacro(AnExceptionClass, << "this is an exception" << this->SomeVariable); * @ingroup Exception -* @todo for future extension of the exception classes: Use if file and line are supported in Exception +* @todo for future extension of the exception classes: Use if file and line are supported in Exception * EType e_(__FILE__, __LINE__, message.str().c_str()); */ #define rttbExceptionMacro( EType, x) \ { \ - std::ostringstream message; \ - message << "Exception: "\ - << "(" << this << "): " x; \ - EType e_(message.str().c_str()); \ - throw e_; /* Explicit naming to work around Intel compiler bug. */ \ + std::ostringstream message; \ + message << "Exception: "\ + << "(" << this << "): " x; \ + EType e_(message.str().c_str()); \ + throw e_; /* Explicit naming to work around Intel compiler bug. */ \ + } + +/*!@def rttbDefaultExceptionStaticMacro +* This macro is used to throw a basic ExceptionObject within a static method. +* It will generate the exception message and throw the exception.\n +* Use rttbExceptionStaticMacro() if you want to specifiy a arbitrary exception class that should be thrown. +* Example usage looks like: +* rttbDefaultExceptionMacro(<< "this is an exception" << SomeVariable); +* @ingroup Exception +* @todo for future extension of the exception classes: Use if file and line are supported in Exception +* ::rttb::core::Exception e_(__FILE__, __LINE__, message.str().c_str()); +*/ +#define rttbDefaultExceptionStaticMacro(x) \ + { \ + std::ostringstream message; \ + message << "Exception: " x; \ + ::rttb::core::Exception e_(message.str().c_str()); \ + throw e_; /* Explicit naming to work around Intel compiler bug. */ \ + } + +/*!@def rttbExceptionStaticMacro +* This macro is used to throw the passed exception class within a static method. +* The macro will set file name, line number and function signiture to the exception +* and log the exception as error in the logbook before throwing it.\n +* Use mapGenericExceptionMacro() for other objects that do not compli with the api or for +* static functions.\n +* @sa mapGenericExceptionMacro +* +* Example usage looks like: +* rttbExceptionMacro(AnExceptionClass, << "this is an exception" << this->SomeVariable); +* @ingroup Exception +* @todo for future extension of the exception classes: Use if file and line are supported in Exception +* EType e_(__FILE__, __LINE__, message.str().c_str()); +*/ +#define rttbExceptionStaticMacro( EType, x) \ + { \ + std::ostringstream message; \ + message << "Exception: " x; \ + EType e_(message.str().c_str()); \ + throw e_; /* Explicit naming to work around Intel compiler bug. */ \ } diff --git a/code/io/dicom/rttbDicomDoseAccessor.h b/code/io/dicom/rttbDicomDoseAccessor.h index 1e609fc..13f935e 100644 --- a/code/io/dicom/rttbDicomDoseAccessor.h +++ b/code/io/dicom/rttbDicomDoseAccessor.h @@ -1,101 +1,101 @@ // ----------------------------------------------------------------------- // 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 __DICOM_DOSE_ACCESSOR_H #define __DICOM_DOSE_ACCESSOR_H #include #include #include #include #include "osconfig.h" /* make sure OS specific configuration is included first */ #include "drtdose.h" -#include "rttbDoseAccessorInterface.h" +#include "rttbDoseAccessorWithGeoInfoBase.h" #include "rttbBaseType.h" namespace rttb { - namespace io - { - namespace dicom - { - - /*! @class DicomDoseAccessor - @brief This class gives access to dose information from DRTDoseIOD and DcmItem - */ - class DicomDoseAccessor: public core::DoseAccessorInterface - { - public: - typedef boost::shared_ptr DRTDoseIODPtr; - typedef boost::shared_ptr DcmItemPtr; - - private: - DRTDoseIODPtr _dose; - DcmItemPtr _dataSet; - - /*! vector of dose data(absolute Gy dose/doseGridScaling)*/ - std::vector doseData; - - double _doseGridScaling; - - IDType _doseUID; - - DicomDoseAccessor(); - - protected: - /*! @brief Initialize dose data - @exception InvalidDoseException Thrown if _dose is invalid: one of column/row/numberOfFrames/doseGridScaling/pixelSpacing=0 - @exception DcmrtException Throw if dcmrt error - @exception boost/bad_lexical_cast Thrown if the imported header tags are not numerical. - */ - bool begin(); - - /*! @brief get all required data from dicom information contained in _dose - @exception boost/bad_lexical_cast Thrown if the imported header tags are not numerical. - */ - bool assembleGeometricInfo(); - - - public: - ~DicomDoseAccessor(); - - /*! @brief Constructor. Initialisation with a boost::shared_ptr of DRTDoseIOD and of DcmItem to get the pixel data - @exception DcmrtException Throw if dcmrt error - */ - DicomDoseAccessor(DRTDoseIODPtr aDRTDoseIODP, DcmItemPtr aDcmDataset); - - DoseTypeGy getDoseAt(const VoxelGridID aID) const; - - DoseTypeGy getDoseAt(const VoxelGridIndex3D& aIndex) const; - - const IDType getDoseUID() const - { - return _doseUID; - }; - }; - } - } + namespace io + { + namespace dicom + { + + /*! @class DicomDoseAccessor + @brief This class gives access to dose information from DRTDoseIOD and DcmItem + */ + class DicomDoseAccessor: public core::DoseAccessorWithGeoInfoBase + { + public: + typedef boost::shared_ptr DRTDoseIODPtr; + typedef boost::shared_ptr DcmItemPtr; + + private: + DRTDoseIODPtr _dose; + DcmItemPtr _dataSet; + + /*! vector of dose data(absolute Gy dose/doseGridScaling)*/ + std::vector doseData; + + double _doseGridScaling; + + IDType _doseUID; + + DicomDoseAccessor(); + + protected: + /*! @brief Initialize dose data + @exception InvalidDoseException Thrown if _dose is invalid: one of column/row/numberOfFrames/doseGridScaling/pixelSpacing=0 + @exception DcmrtException Throw if dcmrt error + @exception boost/bad_lexical_cast Thrown if the imported header tags are not numerical. + */ + bool begin(); + + /*! @brief get all required data from dicom information contained in _dose + @exception boost/bad_lexical_cast Thrown if the imported header tags are not numerical. + */ + bool assembleGeometricInfo(); + + + public: + ~DicomDoseAccessor(); + + /*! @brief Constructor. Initialisation with a boost::shared_ptr of DRTDoseIOD and of DcmItem to get the pixel data + @exception DcmrtException Throw if dcmrt error + */ + DicomDoseAccessor(DRTDoseIODPtr aDRTDoseIODP, DcmItemPtr aDcmDataset); + + DoseTypeGy getDoseAt(const VoxelGridID aID) const; + + DoseTypeGy getDoseAt(const VoxelGridIndex3D& aIndex) const; + + const IDType getDoseUID() const + { + return _doseUID; + }; + }; + } + } } #endif diff --git a/code/io/helax/rttbDicomHelaxDoseAccessor.h b/code/io/helax/rttbDicomHelaxDoseAccessor.h index c08c2f8..3eee9e4 100644 --- a/code/io/helax/rttbDicomHelaxDoseAccessor.h +++ b/code/io/helax/rttbDicomHelaxDoseAccessor.h @@ -1,105 +1,105 @@ // ----------------------------------------------------------------------- // 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 __DICOM_HELAX_DOSE_ACCESSOR_H #define __DICOM_HELAX_DOSE_ACCESSOR_H #include #include #include #include #include "osconfig.h" /* make sure OS specific configuration is included first */ #include "drtdose.h" -#include "rttbDoseAccessorInterface.h" +#include "rttbDoseAccessorWithGeoInfoBase.h" #include "rttbGeometricInfo.h" #include "rttbBaseType.h" namespace rttb { - namespace io - { - namespace helax - { + namespace io + { + namespace helax + { - /*! @class DicomHelaxDoseAccessor - @brief Load dose data from a directory containing dicom dose files, each file describes the helax dose in one slice. - */ - class DicomHelaxDoseAccessor: public core::DoseAccessorInterface - { - public: - typedef boost::shared_ptr DRTDoseIODPtr; + /*! @class DicomHelaxDoseAccessor + @brief Load dose data from a directory containing dicom dose files, each file describes the helax dose in one slice. + */ + class DicomHelaxDoseAccessor: public core::DoseAccessorWithGeoInfoBase + { + public: + typedef boost::shared_ptr DRTDoseIODPtr; - private: - /*! vector of DRTDoseIOD shared pointers, each DRTDoseIOD pointer presents the dose in one slice*/ - std::vector _doseVector; + private: + /*! vector of DRTDoseIOD shared pointers, each DRTDoseIOD pointer presents the dose in one slice*/ + std::vector _doseVector; - /*! vector of dose data(absolute Gy dose/doseGridScaling)*/ - std::vector _doseData; + /*! vector of dose data(absolute Gy dose/doseGridScaling)*/ + std::vector _doseData; - double _doseGridScaling; + double _doseGridScaling; - IDType _doseUID; + IDType _doseUID; - DicomHelaxDoseAccessor(); + DicomHelaxDoseAccessor(); - protected: - /*! @brief Initialize dose data - @exception InvalidDoseException Thrown if any DRTDoseIOD pointer of _doseVector is invalid: one of column/row/numberOfFrames/doseGridScaling/pixelSpacing=0 - @exception DcmrtException Throw if dcmrt error - @exception boost/bad_lexical_cast Thrown if the imported header tags are not numerical. - */ - bool begin(); + protected: + /*! @brief Initialize dose data + @exception InvalidDoseException Thrown if any DRTDoseIOD pointer of _doseVector is invalid: one of column/row/numberOfFrames/doseGridScaling/pixelSpacing=0 + @exception DcmrtException Throw if dcmrt error + @exception boost/bad_lexical_cast Thrown if the imported header tags are not numerical. + */ + bool begin(); - /*! @brief get all required data from dicom information contained in _dose - @exception boost/bad_lexical_cast Thrown if the imported header tags are not numerical. - */ - bool assembleGeometricInfo(); + /*! @brief get all required data from dicom information contained in _dose + @exception boost/bad_lexical_cast Thrown if the imported header tags are not numerical. + */ + bool assembleGeometricInfo(); - public: + public: - ~DicomHelaxDoseAccessor(); + ~DicomHelaxDoseAccessor(); - /*! @brief Constructor. Initialisation with a vector of DRTDoseIOD pointers - @exception InvalidDoseException Thrown if any DRTDoseIOD pointer of _doseVector is invalid: one of column/row/numberOfFrames/doseGridScaling/pixelSpacing=0 - @exception DcmrtException Throw if dcmrt error - */ - DicomHelaxDoseAccessor(std::vector aDICOMRTDoseVector); + /*! @brief Constructor. Initialisation with a vector of DRTDoseIOD pointers + @exception InvalidDoseException Thrown if any DRTDoseIOD pointer of _doseVector is invalid: one of column/row/numberOfFrames/doseGridScaling/pixelSpacing=0 + @exception DcmrtException Throw if dcmrt error + */ + DicomHelaxDoseAccessor(std::vector aDICOMRTDoseVector); - DoseTypeGy getDoseAt(const VoxelGridID aID) const; + DoseTypeGy getDoseAt(const VoxelGridID aID) const; - DoseTypeGy getDoseAt(const VoxelGridIndex3D& aIndex) const; + DoseTypeGy getDoseAt(const VoxelGridIndex3D& aIndex) const; - const IDType getDoseUID() const - { - return _doseUID; - }; - }; - } - } + const IDType getDoseUID() const + { + return _doseUID; + }; + }; + } + } } #endif diff --git a/code/io/itk/rttbITKImageDoseAccessor.h b/code/io/itk/rttbITKImageDoseAccessor.h index 827795a..85c9255 100644 --- a/code/io/itk/rttbITKImageDoseAccessor.h +++ b/code/io/itk/rttbITKImageDoseAccessor.h @@ -1,97 +1,97 @@ // ----------------------------------------------------------------------- // 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 __ITK_DOSE_ACCESSOR_H #define __ITK_DOSE_ACCESSOR_H #include #include -#include "rttbDoseAccessorInterface.h" +#include "rttbDoseAccessorWithGeoInfoBase.h" #include "rttbGeometricInfo.h" #include "rttbBaseType.h" #include "itkImage.h" namespace rttb { - namespace io - { - namespace itk - { - typedef ::itk::Image ITKDoseImageType; - typedef ::itk::ImageBase<3> ITKImageBaseType; - /*! @class ITKImageDoseAccessor - @brief This class gives access to dose information stored in an itk image - @details _doseGridScaling is always 1.0. Thus, it is assumed that the values in the itkImage are absolute. - */ - class ITKImageDoseAccessor: public core::DoseAccessorInterface - { - private: - /** @brief The dose as itkImage */ - ITKDoseImageType::ConstPointer _dose; - - IDType _doseUID; - - /** @brief The dosegridscaling - * @note is always 1.0 - */ - double _doseGridScaling; - - /*! @brief constructor - @exception InvalidDoseException if _dose is NULL - */ - ITKImageDoseAccessor(); - - /*! @brief get all required data from the itk image contained in _dose - @exception InvalidDoseException if PixelSpacing is 0 or size in any dimension is 0. - */ - bool assembleGeometricInfo(); - - - public: - ~ITKImageDoseAccessor(); - - /*! @brief Constructor. Initialization with a itk image containing the dose - @pre doseImage must be a valid instance (and not null) - @note the doseImage pixels are dose (i.e. _doseGridScaling=1.0 is assumed always) - */ - ITKImageDoseAccessor(ITKDoseImageType::ConstPointer doseImage); - - /*! @brief returns the dose for an id - */ - DoseTypeGy getDoseAt(const VoxelGridID aID) const; - - /*! @brief returns the dose for an index - */ - DoseTypeGy getDoseAt(const VoxelGridIndex3D& aIndex) const; - - const IDType getDoseUID() const - { - return _doseUID; - }; - - }; - } - } + namespace io + { + namespace itk + { + typedef ::itk::Image ITKDoseImageType; + typedef ::itk::ImageBase<3> ITKImageBaseType; + /*! @class ITKImageDoseAccessor + @brief This class gives access to dose information stored in an itk image + @details _doseGridScaling is always 1.0. Thus, it is assumed that the values in the itkImage are absolute. + */ + class ITKImageDoseAccessor: public core::DoseAccessorWithGeoInfoBase + { + private: + /** @brief The dose as itkImage */ + ITKDoseImageType::ConstPointer _dose; + + IDType _doseUID; + + /** @brief The dosegridscaling + * @note is always 1.0 + */ + double _doseGridScaling; + + /*! @brief constructor + @exception InvalidDoseException if _dose is NULL + */ + ITKImageDoseAccessor(); + + /*! @brief get all required data from the itk image contained in _dose + @exception InvalidDoseException if PixelSpacing is 0 or size in any dimension is 0. + */ + bool assembleGeometricInfo(); + + + public: + ~ITKImageDoseAccessor(); + + /*! @brief Constructor. Initialization with a itk image containing the dose + @pre doseImage must be a valid instance (and not null) + @note the doseImage pixels are dose (i.e. _doseGridScaling=1.0 is assumed always) + */ + ITKImageDoseAccessor(ITKDoseImageType::ConstPointer doseImage); + + /*! @brief returns the dose for an id + */ + DoseTypeGy getDoseAt(const VoxelGridID aID) const; + + /*! @brief returns the dose for an index + */ + DoseTypeGy getDoseAt(const VoxelGridIndex3D& aIndex) const; + + const IDType getDoseUID() const + { + return _doseUID; + }; + + }; + } + } } #endif diff --git a/code/io/virtuos/rttbVirtuosDoseAccessor.cpp b/code/io/virtuos/rttbVirtuosDoseAccessor.cpp index d302bc4..84fad28 100644 --- a/code/io/virtuos/rttbVirtuosDoseAccessor.cpp +++ b/code/io/virtuos/rttbVirtuosDoseAccessor.cpp @@ -1,230 +1,228 @@ // ----------------------------------------------------------------------- // 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 "rttbVirtuosDoseAccessor.h" #include "rttbNullPointerException.h" #include "rttbInvalidDoseException.h" #include "rttbInvalidParameterException.h" #include "rttbIndexOutOfBoundsException.h" //VIRTUOS #include "pln1file.h" #include "plt_type.h" #include "rtp_type.h" namespace rttb { - namespace io - { - namespace virtuos - { - - VirtuosDoseAccessor::~VirtuosDoseAccessor() - { - if (_freeVirtuosData) - { - this->freeVirtuosData(); - } - } - - VirtuosDoseAccessor::VirtuosDoseAccessor(Cubeinfo* aPointerOnVirtuosCube, bool freeVirtuosData, - DoseTypeGy normalizationDose, DoseTypeGy prescribedDose): - _pPointerOnVirtuosCube(new Cubeinfo*), _freeVirtuosData(freeVirtuosData), _doseGridScaling(0), - _doseUID(""), _doseScalingFactor(0) - { - //initialize cube pointer - *_pPointerOnVirtuosCube = create_cubeinfo(0); - *_pPointerOnVirtuosCube = aPointerOnVirtuosCube; - - - _prescribedDose = prescribedDose; - _normalizationDose = normalizationDose; - - if (_prescribedDose == 0) - { - _prescribedDose = 1; - } - - if (_normalizationDose == 0) - { - _normalizationDose = 1; - } - - _doseScalingFactor = _prescribedDose / _normalizationDose; - std::cout << "Prescribed dose: " << _prescribedDose << std::endl; - std::cout << "Normalization dose: " << _normalizationDose << std::endl; - - //dose import - this->begin(); - - - } - - void VirtuosDoseAccessor::begin() - { - if (!_pPointerOnVirtuosCube) - { - throw core::NullPointerException(" *_pPointerOnVirtuosCube must not be NULL!"); - } - - assembleGeometricInfo(); - - //load data - if ((*_pPointerOnVirtuosCube)->data_type == 1) - { - this->importPixelData(); - } - else if ((*_pPointerOnVirtuosCube)->data_type == 2) - { - this->importPixelData(); - } - else - { - throw core::InvalidParameterException(" cube has wrong data type!"); - } - } - - template - void VirtuosDoseAccessor::importPixelData() - { - doseData.clear(); - - int dimX = (*_pPointerOnVirtuosCube)->dimx; - int dimY = (*_pPointerOnVirtuosCube)->dimy; - int dimZ = (*_pPointerOnVirtuosCube)->dimz; - - GridVolumeType pixelSpacing = (*_pPointerOnVirtuosCube)->pixdist; - GridVolumeType sliceThickness = (*_pPointerOnVirtuosCube)->slicedist; - - TPixelType** * access_pointer = (TPixelType***)(*_pPointerOnVirtuosCube)->cube_direct_access; - - for (int k = 0; k < dimZ; k++) - { - for (int j = 0; j < dimY; j++) - { - for (int i = 0; i < dimX; i++) - { - TPixelType voxel_value = access_pointer[k][j][i]; - doseData.push_back(voxel_value * _doseScalingFactor); - } - - }//end for j - }//end for k - } - - void VirtuosDoseAccessor::assembleGeometricInfo() - { - if (!_pPointerOnVirtuosCube) - { - throw core::NullPointerException(" _pPointerOnVirtuosCube must not be NULL!"); - } - - _geoInfo.setNumColumns((*_pPointerOnVirtuosCube)->dimx); - - _geoInfo.setNumRows((*_pPointerOnVirtuosCube)->dimy); - - _geoInfo.setNumSlices((*_pPointerOnVirtuosCube)->dimz); - - if (_geoInfo.getNumColumns() == 0 || _geoInfo.getNumRows() == 0 || _geoInfo.getNumSlices() == 0) - { - throw core::InvalidDoseException("Empty Virtuos dose!") ; - } - - OrientationMatrix orientation; - _geoInfo.setOrientationMatrix(orientation); - - WorldCoordinate3D imagePositionPatient; - imagePositionPatient(0) = (*this->_pPointerOnVirtuosCube)->pixdist / 2; - imagePositionPatient(1) = (*this->_pPointerOnVirtuosCube)->pixdist / 2; - - if (!((*this->_pPointerOnVirtuosCube)->pos_list)) - { - throw core::InvalidDoseException("Empty Virtuos dose!") ; - } - - imagePositionPatient(2) = (*this->_pPointerOnVirtuosCube)->pos_list[0].position; - - _geoInfo.setImagePositionPatient(imagePositionPatient); - - SpacingVectorType3D spacingVector; - spacingVector(0) = (*_pPointerOnVirtuosCube)->pixdist; - spacingVector(1) = (*_pPointerOnVirtuosCube)->pixdist; - _geoInfo.setSpacing(spacingVector); - - if (_geoInfo.getPixelSpacingRow() == 0 || _geoInfo.getPixelSpacingColumn() == 0) - { - throw core::InvalidDoseException("Pixel spacing = 0!"); - } - - spacingVector(2) = (*_pPointerOnVirtuosCube)->slicedist; - - if (spacingVector(2) == 0) - { - std::cerr << "sliceThickness == 0! It will be replaced with pixelSpacingRow=" << - _geoInfo.getPixelSpacingRow() - << "!" << std::endl; - spacingVector(2) = spacingVector(0); - } - - _geoInfo.setSpacing(spacingVector); - } - - - DoseTypeGy VirtuosDoseAccessor::getDoseAt(const VoxelGridID aID) const - { - return doseData.at(aID); - } - - DoseTypeGy VirtuosDoseAccessor::getDoseAt(const VoxelGridIndex3D& aIndex) const - { - VoxelGridID aVoxelGridID; - - if (_geoInfo.convert(aIndex, aVoxelGridID)) - { - return getDoseAt(aVoxelGridID); - } - else - { - return -1; - } - } - - void VirtuosDoseAccessor::freeVirtuosData() - { - if (*(this->_pPointerOnVirtuosCube) != NULL) - { - closecube((*(this->_pPointerOnVirtuosCube))); - nc_free_cubeinfo((*(this->_pPointerOnVirtuosCube))); - delete this->_pPointerOnVirtuosCube; - - // initialize attributes again - //this->_pPointerOnVirtuosCube = new Cubeinfo*; - //*(this->_pPointerOnVirtuosCube) = create_cubeinfo(0); - } - - } - - } - } + namespace io + { + namespace virtuos + { + + VirtuosDoseAccessor::~VirtuosDoseAccessor() + { + if (_freeVirtuosData) + { + this->freeVirtuosData(); + } + } + + VirtuosDoseAccessor::VirtuosDoseAccessor(Cubeinfo* aPointerOnVirtuosCube, bool freeVirtuosData, + DoseTypeGy normalizationDose, DoseTypeGy prescribedDose): + _pPointerOnVirtuosCube(new Cubeinfo*), _freeVirtuosData(freeVirtuosData), _doseGridScaling(0), + _doseUID(""), _doseScalingFactor(0) + { + //initialize cube pointer + *_pPointerOnVirtuosCube = create_cubeinfo(0); + *_pPointerOnVirtuosCube = aPointerOnVirtuosCube; + + + _prescribedDose = prescribedDose; + _normalizationDose = normalizationDose; + + if (_prescribedDose == 0) + { + _prescribedDose = 1; + } + + if (_normalizationDose == 0) + { + _normalizationDose = 1; + } + + _doseScalingFactor = _prescribedDose / _normalizationDose; + std::cout << "Prescribed dose: " << _prescribedDose << std::endl; + std::cout << "Normalization dose: " << _normalizationDose << std::endl; + + //dose import + this->begin(); + } + + void VirtuosDoseAccessor::begin() + { + if (!_pPointerOnVirtuosCube) + { + throw core::NullPointerException(" *_pPointerOnVirtuosCube must not be NULL!"); + } + + assembleGeometricInfo(); + + //load data + if ((*_pPointerOnVirtuosCube)->data_type == 1) + { + this->importPixelData(); + } + else if ((*_pPointerOnVirtuosCube)->data_type == 2) + { + this->importPixelData(); + } + else + { + throw core::InvalidParameterException(" cube has wrong data type!"); + } + } + + template + void VirtuosDoseAccessor::importPixelData() + { + doseData.clear(); + + int dimX = (*_pPointerOnVirtuosCube)->dimx; + int dimY = (*_pPointerOnVirtuosCube)->dimy; + int dimZ = (*_pPointerOnVirtuosCube)->dimz; + + GridVolumeType pixelSpacing = (*_pPointerOnVirtuosCube)->pixdist; + GridVolumeType sliceThickness = (*_pPointerOnVirtuosCube)->slicedist; + + TPixelType** * access_pointer = (TPixelType***)(*_pPointerOnVirtuosCube)->cube_direct_access; + + for (int k = 0; k < dimZ; k++) + { + for (int j = 0; j < dimY; j++) + { + for (int i = 0; i < dimX; i++) + { + TPixelType voxel_value = access_pointer[k][j][i]; + doseData.push_back(voxel_value * _doseScalingFactor); + } + + }//end for j + }//end for k + } + + void VirtuosDoseAccessor::assembleGeometricInfo() + { + if (!_pPointerOnVirtuosCube) + { + throw core::NullPointerException(" _pPointerOnVirtuosCube must not be NULL!"); + } + + _geoInfo.setNumColumns((*_pPointerOnVirtuosCube)->dimx); + + _geoInfo.setNumRows((*_pPointerOnVirtuosCube)->dimy); + + _geoInfo.setNumSlices((*_pPointerOnVirtuosCube)->dimz); + + if (_geoInfo.getNumColumns() == 0 || _geoInfo.getNumRows() == 0 || _geoInfo.getNumSlices() == 0) + { + throw core::InvalidDoseException("Empty Virtuos dose!") ; + } + + OrientationMatrix orientation; + _geoInfo.setOrientationMatrix(orientation); + + WorldCoordinate3D imagePositionPatient; + imagePositionPatient(0) = (*this->_pPointerOnVirtuosCube)->pixdist / 2; + imagePositionPatient(1) = (*this->_pPointerOnVirtuosCube)->pixdist / 2; + + if (!((*this->_pPointerOnVirtuosCube)->pos_list)) + { + throw core::InvalidDoseException("Empty Virtuos dose!") ; + } + + imagePositionPatient(2) = (*this->_pPointerOnVirtuosCube)->pos_list[0].position; + + _geoInfo.setImagePositionPatient(imagePositionPatient); + + SpacingVectorType3D spacingVector; + spacingVector(0) = (*_pPointerOnVirtuosCube)->pixdist; + spacingVector(1) = (*_pPointerOnVirtuosCube)->pixdist; + _geoInfo.setSpacing(spacingVector); + + if (_geoInfo.getPixelSpacingRow() == 0 || _geoInfo.getPixelSpacingColumn() == 0) + { + throw core::InvalidDoseException("Pixel spacing = 0!"); + } + + spacingVector(2) = (*_pPointerOnVirtuosCube)->slicedist; + + if (spacingVector(2) == 0) + { + std::cerr << "sliceThickness == 0! It will be replaced with pixelSpacingRow=" << + _geoInfo.getPixelSpacingRow() + << "!" << std::endl; + spacingVector(2) = spacingVector(0); + } + + _geoInfo.setSpacing(spacingVector); + } + + + DoseTypeGy VirtuosDoseAccessor::getDoseAt(const VoxelGridID aID) const + { + return doseData.at(aID); + } + + DoseTypeGy VirtuosDoseAccessor::getDoseAt(const VoxelGridIndex3D& aIndex) const + { + VoxelGridID aVoxelGridID; + + if (_geoInfo.convert(aIndex, aVoxelGridID)) + { + return getDoseAt(aVoxelGridID); + } + else + { + return -1; + } + } + + void VirtuosDoseAccessor::freeVirtuosData() + { + if (*(this->_pPointerOnVirtuosCube) != NULL) + { + closecube((*(this->_pPointerOnVirtuosCube))); + nc_free_cubeinfo((*(this->_pPointerOnVirtuosCube))); + delete this->_pPointerOnVirtuosCube; + + // initialize attributes again + //this->_pPointerOnVirtuosCube = new Cubeinfo*; + //*(this->_pPointerOnVirtuosCube) = create_cubeinfo(0); + } + + } + + } + } } diff --git a/code/io/virtuos/rttbVirtuosDoseAccessor.h b/code/io/virtuos/rttbVirtuosDoseAccessor.h index bdcf93d..36530b2 100644 --- a/code/io/virtuos/rttbVirtuosDoseAccessor.h +++ b/code/io/virtuos/rttbVirtuosDoseAccessor.h @@ -1,129 +1,129 @@ // ----------------------------------------------------------------------- // 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 __VIRTUOS_DOSE_ACCESSOR_H #define __VIRTUOS_DOSE_ACCESSOR_H #include #include #include -#include "rttbDoseAccessorInterface.h" +#include "rttbDoseAccessorWithGeoInfoBase.h" #include "rttbGeometricInfo.h" #include "rttbBaseType.h" #include "ncfile.h" namespace rttb { - namespace io - { - namespace virtuos - { + namespace io + { + namespace virtuos + { - /*! @class VirtuosDoseAccessor - @brief This class gives access to dose information from Virtuos Cubeinfo - */ - class VirtuosDoseAccessor: public core::DoseAccessorInterface - { - private: - Cubeinfo** _pPointerOnVirtuosCube; + /*! @class VirtuosDoseAccessor + @brief This class gives access to dose information from Virtuos Cubeinfo + */ + class VirtuosDoseAccessor : public core::DoseAccessorWithGeoInfoBase + { + private: + Cubeinfo** _pPointerOnVirtuosCube; - /*! absolute Gy dose/doseGridScaling*/ - std::vector doseData; + /*! absolute Gy dose/doseGridScaling*/ + std::vector doseData; - double _doseGridScaling; + double _doseGridScaling; - IDType _doseUID; + IDType _doseUID; - DoseTypeGy _prescribedDose; - DoseTypeGy _normalizationDose; + DoseTypeGy _prescribedDose; + DoseTypeGy _normalizationDose; - DoseTypeGy _doseScalingFactor; + DoseTypeGy _doseScalingFactor; - bool _freeVirtuosData;//if virtuos cube info should be closed + bool _freeVirtuosData;//if virtuos cube info should be closed - /*! close virtuos data cube. - */ - void freeVirtuosData(); + /*! close virtuos data cube. + */ + void freeVirtuosData(); - /*! load actual pixel data from virtuos cube to doseData. TPixelType is usually int but may be float for - special virtuos cubes (data_type = 2). - @pre virtuos cube contains data (dimensions are at least 1) + /*! load actual pixel data from virtuos cube to doseData. TPixelType is usually int but may be float for + special virtuos cubes (data_type = 2). + @pre virtuos cube contains data (dimensions are at least 1) - */ - template - void importPixelData(); + */ + template + void importPixelData(); - protected: - /*! @brief import dose data and relevant geometric information - @throw NullPointerException Thrown if _pPointerOnVirtuosCube is NULL - @throw InvalidDoseException Thrown if one dimension of the virtuos cube is zero - @throw InvalidParameterException Thrown if _pPointerOnVirtuosCube is invalid - */ - void begin(); + protected: + /*! @brief import dose data and relevant geometric information + @throw NullPointerException Thrown if _pPointerOnVirtuosCube is NULL + @throw InvalidDoseException Thrown if one dimension of the virtuos cube is zero + @throw InvalidParameterException Thrown if _pPointerOnVirtuosCube is invalid + */ + void begin(); - /*! @brief get all required geometrical data from virtuos cube - */ - void assembleGeometricInfo(); + /*! @brief get all required geometrical data from virtuos cube + */ + void assembleGeometricInfo(); - public: - ~VirtuosDoseAccessor(); + public: + ~VirtuosDoseAccessor(); - /*! @brief Constructor. Initialisation with a Cubeinfo pointer. - @param normalizationDose is defined as (prescribedDose*1000)/maxDoseInGy. Default is 1 Gy. - @param prescribedDose the does that was planned in the reference point in Gy. Default is 1 Gy. - @param freeVirtuoData If virtuos cube info should be closed, freeVirtuosData should be true. - @throw NullPointerException Thrown if _pPointerOnVirtuosCube is NULL - @throw InvalidDoseException Thrown if one dimension of the virtuos cube is zero - @throw InvalidParameterException Thrown if aPointerOnVirtuosCube is invalid - */ - VirtuosDoseAccessor(Cubeinfo* aPointerOnVirtuosCube, bool freeVirtuosData, - DoseTypeGy normalizationDose = 1, DoseTypeGy prescribedDose = 1); + /*! @brief Constructor. Initialisation with a Cubeinfo pointer. + @param normalizationDose is defined as (prescribedDose*1000)/maxDoseInGy. Default is 1 Gy. + @param prescribedDose the does that was planned in the reference point in Gy. Default is 1 Gy. + @param freeVirtuoData If virtuos cube info should be closed, freeVirtuosData should be true. + @throw NullPointerException Thrown if _pPointerOnVirtuosCube is NULL + @throw InvalidDoseException Thrown if one dimension of the virtuos cube is zero + @throw InvalidParameterException Thrown if aPointerOnVirtuosCube is invalid + */ + VirtuosDoseAccessor(Cubeinfo* aPointerOnVirtuosCube, bool freeVirtuosData, + DoseTypeGy normalizationDose = 1, DoseTypeGy prescribedDose = 1); - DoseTypeGy getDoseAt(const VoxelGridID aID) const; + DoseTypeGy getDoseAt(const VoxelGridID aID) const; - /*! @return dose value at given grid position. If position is invalid return -1 - */ - DoseTypeGy getDoseAt(const VoxelGridIndex3D& aIndex) const; + /*! @return dose value at given grid position. If position is invalid return -1 + */ + DoseTypeGy getDoseAt(const VoxelGridIndex3D& aIndex) const; - const IDType getDoseUID() const - { - return _doseUID; - }; + const IDType getDoseUID() const + { + return _doseUID; + }; - const DoseTypeGy getPrescribedDose() const - { - return _prescribedDose; - }; + const DoseTypeGy getPrescribedDose() const + { + return _prescribedDose; + }; - const DoseTypeGy getNormalizationDose() const - { - return _normalizationDose; - }; - }; - } - } + const DoseTypeGy getNormalizationDose() const + { + return _normalizationDose; + }; + }; + } + } } #endif diff --git a/demoapps/DoseAcc/CMakeLists.txt b/demoapps/DoseAcc/CMakeLists.txt index 8eda38d..d1a475d 100644 --- a/demoapps/DoseAcc/CMakeLists.txt +++ b/demoapps/DoseAcc/CMakeLists.txt @@ -1,3 +1,3 @@ MESSAGE (STATUS "generating demo app: DoseAcc - simple dose accumulation tool example") -RTTB_CREATE_APPLICATION(DoseAcc DEPENDS RTTBCore RTTBAlgorithms RTTBInterpolation RTTBMatchPointBinding RTTBITKIO RTTBVirtuosIO PACKAGE_DEPENDS MatchPoint ITK) \ No newline at end of file +RTTB_CREATE_APPLICATION(DoseAcc DEPENDS RTTBCore RTTBAlgorithms RTTBInterpolation RTTBMatchPointBinding RTTBITKIO RTTBVirtuosIO RTTBDicomIO RTTBHelaxIO PACKAGE_DEPENDS MatchPoint ITK) \ No newline at end of file diff --git a/demoapps/DoseAcc/DoseAcc.cpp b/demoapps/DoseAcc/DoseAcc.cpp index 27e4a82..44e53aa 100644 --- a/demoapps/DoseAcc/DoseAcc.cpp +++ b/demoapps/DoseAcc/DoseAcc.cpp @@ -1,192 +1,171 @@ // ----------------------------------------------------------------------- // 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 "DoseAccApplicationData.h" #include "DoseAccHelper.h" rttb::apps::doseAcc::ApplicationData appData; int main(int argc, char** argv) { int result = 0; std::cout << "DoseAcc - RTTB demo app for simple dose accumulation." << std::endl; switch (rttb::apps::doseAcc::ParseArgumentsForAppData(argc, argv, appData)) { - case 1: + case 1: { //showed version or help info. Done. return 1; } - case 2: + case 2: { std::cerr << "Missing Parameters. Use one of the following flags for more information:" << - std::endl; + std::endl; std::cerr << "-? or --help" << std::endl; return 2; } - case 3: + case 3: { //wrong option usage. return 3; } } if (appData._fileCount < 3) { std::cerr << "Missing Parameters. Use one of the following flags for more information:" << - std::endl; + std::endl; std::cerr << "-? or --help" << std::endl; return 1; } std::cout << std::endl << "*******************************************" << std::endl; std::cout << "Dose 1 file: " << appData._dose1FileName << std::endl; - if (!(appData._dose1VirtuosPlanFileName.empty())) - { - std::cout << " as virtuos. Plan: " << appData._dose1VirtuosPlanFileName << std::endl; - } std::cout << "Dose 2 file: " << appData._dose2FileName << std::endl; - if (!(appData._dose2VirtuosPlanFileName.empty())) - { - std::cout << " as virtuos. Plan: " << appData._dose2VirtuosPlanFileName << std::endl; - } std::cout << "Dose output file: " << appData._outputFileName << std::endl; if (!(appData._regFileName.empty())) { std::cout << "Registration file: " << appData._regFileName << std::endl; } + std::cout << "Dose 1 weight: " << appData._weightDose1 << std::endl; std::cout << "Dose 2 weight: " << appData._weightDose2 << std::endl; try { - if (appData._dose1VirtuosPlanFileName.empty()) - { - appData._Dose1 = rttb::apps::doseAcc::loadDose(appData._dose1FileName); - } - else - { - appData._Dose1 = rttb::apps::doseAcc::loadVirtuosDose(appData._dose1FileName, appData._dose1VirtuosPlanFileName); - } + appData._Dose1 = rttb::apps::doseAcc::loadDose(appData._dose1FileName, appData._dose1LoadStyle); } catch (::itk::ExceptionObject& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e << std::endl; return 4; } catch (std::exception& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e.what() << std::endl; return 4; } catch (...) { std::cerr << "Error!!! unknown error while reading input image." << std::endl; return 4; } try { - if (appData._dose2VirtuosPlanFileName.empty()) - { - appData._Dose2 = rttb::apps::doseAcc::loadDose(appData._dose2FileName); - } - else - { - appData._Dose2 = rttb::apps::doseAcc::loadVirtuosDose(appData._dose2FileName, appData._dose2VirtuosPlanFileName); - } + appData._Dose2 = rttb::apps::doseAcc::loadDose(appData._dose2FileName, appData._dose2LoadStyle); } catch (::itk::ExceptionObject& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e << std::endl; return 4; } catch (std::exception& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e.what() << std::endl; return 4; } catch (...) { std::cerr << "Error!!! unknown error while reading input image." << std::endl; return 4; } if (!(appData._regFileName.empty())) { try { appData._spReg = rttb::apps::doseAcc::loadRegistration(appData._regFileName); } catch (::itk::ExceptionObject& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e << std::endl; return 5; } catch (std::exception& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e.what() << std::endl; return 5; } catch (...) { std::cerr << "Error!!! unknown error while reading registration file." << std::endl; return 5; } } try { rttb::apps::doseAcc::processData(appData); } catch (::itk::ExceptionObject& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e << std::endl; return 9; } catch (std::exception& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e.what() << std::endl; return 9; } catch (...) { std::cerr << "Error!!! unknown error while mapping and writing image." << std::endl; return 9; } std::cout << std::endl; return result; } diff --git a/demoapps/DoseAcc/DoseAccApplicationData.cpp b/demoapps/DoseAcc/DoseAccApplicationData.cpp index 22995e8..8829e19 100644 --- a/demoapps/DoseAcc/DoseAccApplicationData.cpp +++ b/demoapps/DoseAcc/DoseAccApplicationData.cpp @@ -1,178 +1,194 @@ // ----------------------------------------------------------------------- // 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 "DoseAccApplicationData.h" #include "itksys/SystemTools.hxx" #include "itksys/CommandLineArguments.hxx" #include "RTToolboxConfigure.h" namespace rttb { - namespace apps - { - namespace doseAcc - { - - int unknown_argument(const char* argument, void* call_data) - { - std::cout << "Got unknown argument: \"" << argument << "\"" << std::endl; - return 0; - } - - ApplicationData:: - ApplicationData() - { - this->Reset(); - } - - void - ApplicationData:: - Reset() - { - _dose1FileName = ""; - _dose2FileName = ""; - _outputFileName = ""; - _regFileName = ""; - _dose1VirtuosPlanFileName = ""; - _dose2VirtuosPlanFileName = ""; - - - _showVersion = false; - _showHelp = false; - - _weightDose1 = 1.0; - _weightDose2 = 1.0; - - _fileCount = 0; - } - - unsigned int - ParseArgumentsForAppData(int argc, char** argv, ApplicationData& appData) - { - itksys::CommandLineArguments cmdParser; - - appData.Reset(); - - if (argc > 3) - { - appData._dose1FileName = argv[1]; - ++appData._fileCount; - --argc; - ++argv; - - appData._dose2FileName = argv[1]; - ++appData._fileCount; - --argc; - ++argv; - - appData._outputFileName = argv[1]; - ++appData._fileCount; - --argc; - ++argv; - } - - cmdParser.Initialize(argc, argv); - - cmdParser.SetUnknownArgumentCallback(unknown_argument); - - cmdParser.AddArgument("--weight1", itksys::CommandLineArguments::SPACE_ARGUMENT, &(appData._weightDose1), - "Specifies the weight for dose 1. If not specified the weight is 1.0."); - cmdParser.AddArgument("-w1", itksys::CommandLineArguments::SPACE_ARGUMENT, &(appData._weightDose1), - "Specifies the weight for dose 1. If not specified the weight is 1.0."); - cmdParser.AddArgument("--weight2", itksys::CommandLineArguments::SPACE_ARGUMENT, &(appData._weightDose2), - "Specifies the weight for dose 2. If not specified the weight is 1.0."); - cmdParser.AddArgument("-w2", itksys::CommandLineArguments::SPACE_ARGUMENT, &(appData._weightDose2), - "Specifies the weight for dose 2. If not specified the weight is 1.0."); - - cmdParser.AddArgument("--registration", itksys::CommandLineArguments::SPACE_ARGUMENT, &(appData._regFileName), - "Specifies name and location of the registration file that should be used to map dose 2 befor accumulating it with dose 1. Default is no mapping, thus direct accumulation. The registration should be stored as MatchPoint registration."); - cmdParser.AddArgument("-r", itksys::CommandLineArguments::SPACE_ARGUMENT, &(appData._regFileName), - "Specifies name and location of the registration file that should be used to map dose 2 befor accumulating it with dose 1. Default is no mapping, thus direct accumulation. The registration should be stored as MatchPoint registration."); - - cmdParser.AddArgument("--virtuosPlan1", itksys::CommandLineArguments::SPACE_ARGUMENT, &(appData._dose1VirtuosPlanFileName), - "Indicates that the dose file of dose 1 should be handled as Virtuos dose and specifies the plan file that should be used to load the dose."); - cmdParser.AddArgument("-v1", itksys::CommandLineArguments::SPACE_ARGUMENT, &(appData._dose1VirtuosPlanFileName), - "Indicates that the dose file of dose 1 should be handled as Virtuos dose and specifies the plan file that should be used to load the dose."); - - cmdParser.AddArgument("--virtuosPlan2", itksys::CommandLineArguments::SPACE_ARGUMENT, &(appData._dose2VirtuosPlanFileName), - "Indicates that the dose file of dose 2 should be handled as Virtuos dose and specifies the plan file that should be used to load the dose."); - cmdParser.AddArgument("-v2", itksys::CommandLineArguments::SPACE_ARGUMENT, &(appData._dose2VirtuosPlanFileName), - "Indicates that the dose file of dose 2 should be handled as Virtuos dose and specifies the plan file that should be used to load the dose."); + namespace apps + { + namespace doseAcc + { + + int unknown_argument(const char* argument, void* call_data) + { + std::cout << "Got unknown argument: \"" << argument << "\"" << std::endl; + return 0; + } + + ApplicationData:: + ApplicationData() + { + this->Reset(); + } + + void + ApplicationData:: + Reset() + { + _dose1FileName = ""; + _dose2FileName = ""; + _outputFileName = ""; + _regFileName = ""; + + _interpolatorName = "linear"; + + _showVersion = false; + _showHelp = false; + + _weightDose1 = 1.0; + _weightDose2 = 1.0; + + _fileCount = 0; + } + + unsigned int + ParseArgumentsForAppData(int argc, char** argv, ApplicationData& appData) + { + itksys::CommandLineArguments cmdParser; + + appData.Reset(); + + if (argc > 3) + { + appData._dose1FileName = argv[1]; + ++appData._fileCount; + --argc; + ++argv; + + appData._dose2FileName = argv[1]; + ++appData._fileCount; + --argc; + ++argv; + + appData._outputFileName = argv[1]; + ++appData._fileCount; + --argc; + ++argv; + } + + cmdParser.Initialize(argc, argv); + + cmdParser.SetUnknownArgumentCallback(unknown_argument); + + cmdParser.AddArgument("--interpolator", itksys::CommandLineArguments::SPACE_ARGUMENT, + &(appData._interpolatorName), + "Specifies the interpolator that should be used for mapping. Available options are: \"nn\": nearest neighbour, \"linear\": linear interpolation, \"rosu\" interpolation based on the concept of Rosu et al.. Default interpolator is \"linear\"."); + cmdParser.AddArgument("-i", itksys::CommandLineArguments::SPACE_ARGUMENT, + &(appData._interpolatorName), + "Specifies the interpolator that should be used for mapping. Available options are: \"nn\": nearest neighbour, \"linear\": linear interpolation, \"rosu\" interpolation based on the concept of Rosu et al.. Default interpolator is \"linear\"."); + + cmdParser.AddArgument("--weight1", itksys::CommandLineArguments::SPACE_ARGUMENT, + &(appData._weightDose1), + "Specifies the weight for dose 1. If not specified the weight is 1.0."); + cmdParser.AddArgument("-w1", itksys::CommandLineArguments::SPACE_ARGUMENT, &(appData._weightDose1), + "Specifies the weight for dose 1. If not specified the weight is 1.0."); + cmdParser.AddArgument("--weight2", itksys::CommandLineArguments::SPACE_ARGUMENT, + &(appData._weightDose2), + "Specifies the weight for dose 2. If not specified the weight is 1.0."); + cmdParser.AddArgument("-w2", itksys::CommandLineArguments::SPACE_ARGUMENT, &(appData._weightDose2), + "Specifies the weight for dose 2. If not specified the weight is 1.0."); + + cmdParser.AddArgument("--registration", itksys::CommandLineArguments::SPACE_ARGUMENT, + &(appData._regFileName), + "Specifies name and location of the registration file that should be used to map dose 2 befor accumulating it with dose 1. Default is no mapping, thus direct accumulation. The registration should be stored as MatchPoint registration."); + cmdParser.AddArgument("-r", itksys::CommandLineArguments::SPACE_ARGUMENT, &(appData._regFileName), + "Specifies name and location of the registration file that should be used to map dose 2 befor accumulating it with dose 1. Default is no mapping, thus direct accumulation. The registration should be stored as MatchPoint registration."); + + cmdParser.AddArgument("--loadStyle1", itksys::CommandLineArguments::MULTI_ARGUMENT, + &(appData._dose1LoadStyle), + "Indicates the load style that should be used for dose 1. Available styles: \"dicom\": normal dicom dose (default); \"virtuos\": load of a virtuos dose (This style is a multi argument. The second argument specifies the virtuos plan file, e.g. : \"--loadStyle1 virtuos myFavorite.pln\"); \"itk\": use itk image loading; \"helax\": load a helax dose (choosing this style, the dose path should only be a directory)."); + + cmdParser.AddArgument("--loadStyle2", itksys::CommandLineArguments::MULTI_ARGUMENT, + &(appData._dose2LoadStyle), + "Indicates the load style that should be used for dose 2. Available styles: \"dicom\": normal dicom dose (default); \"virtuos\": load of a virtuos dose (This style is a multi argument. The second argument specifies the virtuos plan file, e.g. : \"--loadStyle2 virtuos myFavorite.pln\"); \"itk\": use itk image loading; \"helax\": load a helax dose (choosing this style, the dose path should only be a directory)."); cmdParser.AddArgument("-v", itksys::CommandLineArguments::NO_ARGUMENT, &(appData._showVersion), - "Shows the version of the program."); - - cmdParser.AddArgument("-h", itksys::CommandLineArguments::NO_ARGUMENT, &(appData._showHelp), - "Shows this help information for the program."); - cmdParser.AddArgument("--help", itksys::CommandLineArguments::NO_ARGUMENT, &(appData._showHelp), - "Shows this help information for the program."); - cmdParser.AddArgument("-?", itksys::CommandLineArguments::NO_ARGUMENT, &(appData._showHelp), - "Shows this help information for the program."); - cmdParser.AddArgument("/h", itksys::CommandLineArguments::NO_ARGUMENT, &(appData._showHelp), - "Shows this help information for the program."); - cmdParser.AddArgument("/?", itksys::CommandLineArguments::NO_ARGUMENT, &(appData._showHelp), - "Shows this help information for the program."); - - if (!cmdParser.Parse()) - { - std::cerr << "Wrong command line option or insufficient number of arguments." << std::endl; - std::cerr << "The last correct argument was: " << argv[cmdParser.GetLastArgument()] << std::endl << - "Use one of the following flags for more information:" << std::endl; - std::cerr << "-? or --help" << std::endl; - return 3; - }; - - if (appData._showHelp) - { - std::cout << std::endl << "Usage: " << std::endl << std::endl; - std::cout << " DoseAcc [options]" << std::endl << std::endl; - std::cout << " Dose1: File path to the 1st dose." << std::endl; - std::cout << " Dose2: File path to the 2nd dose." << std::endl; - std::cout << " DoseOutput: File path where the output should be stored." << std::endl << std::endl; - std::cout << "Command-Line Options:" << std::endl << std::endl; - std::cout << cmdParser.GetHelp() << std::endl << std::endl; - std::cout << " Example:" << std::endl << std::endl; - std::cout << " DoseCalc dose1.mhd dose2.mhd result.mhd -w1 2 -r reg.mapr" << std::endl << std::endl; - std::cout << - " This will accumulate \"dose1.mhd\" and \"dose2.mhd\" by using \"reg.mapr\" to map dose 2. For the accumlation dose 1 will be multiplied by 2. The resulting dose will be stored in \"result.mhd\"." - << std::endl; - return 1; - } - - if (appData._showVersion) - { - std::cout << std::endl << "Version: " << RTT_FULL_VERSION_STRING; - return 1; - } - - if (appData._fileCount < 3) - { - return 2; - } - - return 0; - }; - - } - } + "Shows the version of the program."); + + cmdParser.AddArgument("-h", itksys::CommandLineArguments::NO_ARGUMENT, &(appData._showHelp), + "Shows this help information for the program."); + cmdParser.AddArgument("--help", itksys::CommandLineArguments::NO_ARGUMENT, &(appData._showHelp), + "Shows this help information for the program."); + cmdParser.AddArgument("-?", itksys::CommandLineArguments::NO_ARGUMENT, &(appData._showHelp), + "Shows this help information for the program."); + cmdParser.AddArgument("/h", itksys::CommandLineArguments::NO_ARGUMENT, &(appData._showHelp), + "Shows this help information for the program."); + cmdParser.AddArgument("/?", itksys::CommandLineArguments::NO_ARGUMENT, &(appData._showHelp), + "Shows this help information for the program."); + + if (!cmdParser.Parse()) + { + std::cerr << "Wrong command line option or insufficient number of arguments." << std::endl; + std::cerr << "The last correct argument was: " << argv[cmdParser.GetLastArgument()] << std::endl << + "Use one of the following flags for more information:" << std::endl; + std::cerr << "-? or --help" << std::endl; + return 3; + }; + + if (appData._showHelp) + { + std::cout << std::endl << "Usage: " << std::endl << std::endl; + std::cout << " DoseAcc [options]" << std::endl << std::endl; + std::cout << " Dose1: File path to the 1st dose." << std::endl; + std::cout << " Dose2: File path to the 2nd dose." << std::endl; + std::cout << " DoseOutput: File path where the output should be stored." << std::endl << + std::endl; + std::cout << "Command-Line Options:" << std::endl << std::endl; + std::cout << cmdParser.GetHelp() << std::endl << std::endl; + std::cout << " Example:" << std::endl << std::endl; + std::cout << + " DoseCalc dose1.mhd dose2.mhd result.mhd --loadStyle1 itk --loadStyle2 itk -w1 2 -r reg.mapr" << + std::endl << std::endl; + std::cout << + " This will accumulate \"dose1.mhd\" and \"dose2.mhd\" by using \"reg.mapr\" to map dose 2. For the accumlation dose 1 will be multiplied by 2. The resulting dose will be stored in \"result.mhd\"." + << std::endl << std::endl; + std::cout << + " DoseCalc dose1.dcm dose2.dos.gz result.mhd --loadStyle2 virtuos dose2.pln -r reg.mapr" << + std::endl << std::endl; + std::cout << + " This will accumulate \"dose1.dcm\" (using default dicom io) and \"dose2.dos.gz\" (using virtuos io and plan file dose2.pln) by using \"reg.mapr\" to map dose 2. The resulting dose will be stored in \"result.mhd\"." + << std::endl; + return 1; + } + + if (appData._showVersion) + { + std::cout << std::endl << "Version: " << RTT_FULL_VERSION_STRING; + return 1; + } + + if (appData._fileCount < 3) + { + return 2; + } + + return 0; + }; + + } + } } diff --git a/demoapps/DoseAcc/DoseAccApplicationData.h b/demoapps/DoseAcc/DoseAccApplicationData.h index 06171b2..53d503a 100644 --- a/demoapps/DoseAcc/DoseAccApplicationData.h +++ b/demoapps/DoseAcc/DoseAccApplicationData.h @@ -1,83 +1,85 @@ // ----------------------------------------------------------------------- // 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_ACCAPPLICATION_DATA_H #define __DOSE_ACCAPPLICATION_DATA_H #include "mapRegistration.h" #include "rttbBaseType.h" #include "rttbDoseAccessorInterface.h" namespace rttb { - namespace apps - { - namespace doseAcc - { + namespace apps + { + namespace doseAcc + { - class ApplicationData - { - public: + class ApplicationData + { + public: typedef map::core::Registration<3, 3> RegistrationType; - - /** Loaded Dose.*/ - core::DoseAccessorInterface::DoseAccessorPointer _Dose1; - std::string _dose1FileName; - std::string _dose1VirtuosPlanFileName; - core::DoseAccessorInterface::DoseAccessorPointer _Dose2; - std::string _dose2FileName; - std::string _dose2VirtuosPlanFileName; - RegistrationType::Pointer _spReg; - std::string _regFileName; + typedef std::vector LoadingStyleArgType; + /** Loaded Dose.*/ + core::DoseAccessorInterface::DoseAccessorPointer _Dose1; + std::string _dose1FileName; + LoadingStyleArgType _dose1LoadStyle; + core::DoseAccessorInterface::DoseAccessorPointer _Dose2; + std::string _dose2FileName; + LoadingStyleArgType _dose2LoadStyle; + RegistrationType::Pointer _spReg; + std::string _regFileName; - std::string _outputFileName; + std::string _outputFileName; - double _weightDose1; - double _weightDose2; + double _weightDose1; + double _weightDose2; - bool _showVersion; - bool _showHelp; + std::string _interpolatorName; - int _fileCount; + bool _showVersion; + bool _showHelp; - void Reset(); + int _fileCount; - ApplicationData(); - }; + void Reset(); - /** Parse the application argument passed when starting the application. - * If no error or special request occurred the return is 0. Otherwise the return values - * have the following meaning: \n - * 0: Normal parsing.\n - * 1: showed help or version (flag was set).\n - * 2: not enough required input files.\n - * 3: Parsing error.\n - * @param argc Number of parameter arguments - * @param argv Pointer to the passed arguments - * @return Result code of the parsing (see above).**/ - unsigned int ParseArgumentsForAppData(int argc, char** argv, ApplicationData& appData); - - } - } + ApplicationData(); + }; + + /** Parse the application argument passed when starting the application. + * If no error or special request occurred the return is 0. Otherwise the return values + * have the following meaning: \n + * 0: Normal parsing.\n + * 1: showed help or version (flag was set).\n + * 2: not enough required input files.\n + * 3: Parsing error.\n + * @param argc Number of parameter arguments + * @param argv Pointer to the passed arguments + * @return Result code of the parsing (see above).**/ + unsigned int ParseArgumentsForAppData(int argc, char** argv, ApplicationData& appData); + + } + } } #endif diff --git a/demoapps/DoseAcc/DoseAccHelper.cpp b/demoapps/DoseAcc/DoseAccHelper.cpp index 905eb74..02f712e 100644 --- a/demoapps/DoseAcc/DoseAccHelper.cpp +++ b/demoapps/DoseAcc/DoseAccHelper.cpp @@ -1,129 +1,218 @@ // ----------------------------------------------------------------------- // 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 "DoseAccHelper.h" #include "mapRegistrationFileReader.h" #include "itkImageFileWriter.h" +#include "rttbExceptionMacros.h" + #include "rttbVirtuosPlanFileDoseAccessorGenerator.h" +#include "rttbDicomFileDoseAccessorGenerator.h" +#include "rttbDicomHelaxFileDoseAccessorGenerator.h" #include "rttbITKImageFileDoseAccessorGenerator.h" #include "rttbSimpleMappableDoseAccessor.h" #include "rttbMatchPointTransformation.h" #include "rttbLinearInterpolation.h" +#include "rttbNearestNeighborInterpolation.h" +#include "rttbRosuMappableDoseAccessor.h" #include "rttbITKImageDoseAccessorConverter.h" #include "rttbArithmetic.h" #include "rttbBinaryFunctorDoseAccessor.h" +rttb::core::DoseAccessorInterface::DoseAccessorPointer +rttb::apps::doseAcc::loadDose(const std::string& fileName, + const rttb::apps::doseAcc::ApplicationData::LoadingStyleArgType& args) +{ + rttb::core::DoseAccessorInterface::DoseAccessorPointer result; + + std::cout << std::endl << "read dose file... "; + + if (args.empty() || args[0] == "dicom") + { + std::cout << "use RTTB dicom IO... "; + result = loadDicomDose(fileName); + } + else if (args[0] == "helax") + { + std::cout << "use RTTB Helax IO... "; + result = loadHelaxDose(fileName); + } + else if (args[0] == "itk") + { + std::cout << "use RTTB itk IO... "; + result = loadITKDose(fileName); + } + else if (args[0] == "virtuos") + { + if (args.size() < 2) + { + rttbDefaultExceptionStaticMacro( << + "Cannot load virtuos dose. Plan file is missing. Specify plan file as 2nd io stlye argument."); + } + + std::cout << "use RTTB virtuos IO... " << std::endl; + std::cout << " virtuos plan file: " << args[1] << " ... "; + result = loadVirtuosDose(fileName, args[1]); + } + else + { + rttbDefaultExceptionStaticMacro( << "Unknown io style selected. Cannot load data. Selected style: " + << args[0]); + } + + std::cout << "done." << std::endl; + + return result; +}; + +rttb::core::DoseAccessorInterface::DoseAccessorPointer +rttb::apps::doseAcc::loadDicomDose(const std::string& fileName) +{ + rttb::io::dicom::DicomFileDoseAccessorGenerator generator(fileName); + return generator.generateDoseAccessor(); +}; + +rttb::core::DoseAccessorInterface::DoseAccessorPointer +rttb::apps::doseAcc::loadHelaxDose(const std::string& path) +{ + rttb::io::helax::DicomHelaxFileDoseAccessorGenerator generator(path); + return generator.generateDoseAccessor(); +}; rttb::core::DoseAccessorInterface::DoseAccessorPointer -rttb::apps::doseAcc::loadDose(const std::string& fileName) +rttb::apps::doseAcc::loadITKDose(const std::string& fileName) { - rttb::io::itk::ITKImageFileDoseAccessorGenerator generator(fileName); - return generator.generateDoseAccessor(); + rttb::io::itk::ITKImageFileDoseAccessorGenerator generator(fileName); + return generator.generateDoseAccessor(); }; rttb::core::DoseAccessorInterface::DoseAccessorPointer rttb::apps::doseAcc::loadVirtuosDose(const std::string& fileName, const std::string& planFileName) { - rttb::io::virtuos::VirtuosPlanFileDoseAccessorGenerator generator(fileName, planFileName); - return generator.generateDoseAccessor(); + rttb::io::virtuos::VirtuosPlanFileDoseAccessorGenerator generator(fileName, planFileName); + return generator.generateDoseAccessor(); }; rttb::apps::doseAcc::ApplicationData::RegistrationType::Pointer rttb::apps::doseAcc::loadRegistration(const std::string& fileName) { - map::io::RegistrationFileReader::Pointer spRegReader = map::io::RegistrationFileReader::New(); + map::io::RegistrationFileReader::Pointer spRegReader = map::io::RegistrationFileReader::New(); - map::io::RegistrationFileReader::LoadedRegistrationPointer spReg; + map::io::RegistrationFileReader::LoadedRegistrationPointer spReg; - std::cout << std::endl << "read registration file... "; - spReg = spRegReader->read(fileName); - std::cout << "done." << std::endl; + std::cout << std::endl << "read registration file... "; + spReg = spRegReader->read(fileName); + std::cout << "done." << std::endl; - ApplicationData::RegistrationType::Pointer resultPtr = - dynamic_cast(spReg.GetPointer()); + ApplicationData::RegistrationType::Pointer resultPtr = + dynamic_cast(spReg.GetPointer()); - if (resultPtr.IsNull()) - { - mapDefaultExceptionStaticMacro( << - "Loaded registration cannot be used. Only 3D 3D registrations are allowed."); - } + if (resultPtr.IsNull()) + { + mapDefaultExceptionStaticMacro( << + "Loaded registration cannot be used. Only 3D 3D registrations are allowed."); + } - return resultPtr; + return resultPtr; }; /**Private helper function for processData(). Generates a suitable output accessor * (depending on the configuration in appData a suitable accessor pipeline is established) * which performs the accumulation of the doses and returns the output.to */ rttb::core::DoseAccessorInterface::DoseAccessorPointer assembleOutputAccessor(rttb::apps::doseAcc::ApplicationData& appData) { - rttb::core::DoseAccessorInterface::DoseAccessorPointer dose2Accessor = appData._Dose2; - - if (appData._spReg.IsNotNull()) - { - rttb::interpolation::LinearInterpolation::Pointer interpolate = - rttb::interpolation::LinearInterpolation::Pointer(new - rttb::interpolation::LinearInterpolation()); - rttb::interpolation::TransformationInterface::Pointer transform = - rttb::interpolation::TransformationInterface::Pointer(new - rttb::interpolation::MatchPointTransformation(appData._spReg)); - dose2Accessor = rttb::core::DoseAccessorInterface::DoseAccessorPointer( - new rttb::interpolation::SimpleMappableDoseAccessor(appData._Dose1->getGeometricInfo(), - appData._Dose2, transform, interpolate)); - } - - rttb::algorithms::arithmetic::doseOp::AddWeighted addOp(appData._weightDose1, appData._weightDose2); - rttb::core::DoseAccessorInterface::DoseAccessorPointer outputAccessor = - rttb::core::DoseAccessorInterface::DoseAccessorPointer(new - rttb::algorithms::BinaryFunctorDoseAccessor - (appData._Dose1, dose2Accessor, addOp)); - - return outputAccessor; + rttb::core::DoseAccessorInterface::DoseAccessorPointer dose2Accessor = appData._Dose2; + + if (appData._spReg.IsNotNull()) + { + rttb::interpolation::TransformationInterface::Pointer transform = + rttb::interpolation::TransformationInterface::Pointer(new + rttb::interpolation::MatchPointTransformation(appData._spReg)); + + if (appData._interpolatorName == "rosu") + { + dose2Accessor = rttb::core::DoseAccessorInterface::DoseAccessorPointer( + new rttb::interpolation::RosuMappableDoseAccessor(appData._Dose1->getGeometricInfo(), + appData._Dose2, transform)); + } + else + { + rttb::interpolation::InterpolationBase::Pointer interpolate = + rttb::interpolation::LinearInterpolation::Pointer(new + rttb::interpolation::LinearInterpolation()); + + if (appData._interpolatorName == "nn") + { + interpolate = rttb::interpolation::NearestNeighborInterpolation::Pointer(new + rttb::interpolation::NearestNeighborInterpolation()); + } + else if (appData._interpolatorName != "linear") + { + mapDefaultExceptionStaticMacro( << + "Unkown interpolation type selected. Cannot map dose. Interpolation type: " << + appData._interpolatorName); + } + + dose2Accessor = rttb::core::DoseAccessorInterface::DoseAccessorPointer( + new rttb::interpolation::SimpleMappableDoseAccessor(appData._Dose1->getGeometricInfo(), + appData._Dose2, transform, interpolate)); + } + + } + + rttb::algorithms::arithmetic::doseOp::AddWeighted addOp(appData._weightDose1, appData._weightDose2); + rttb::core::DoseAccessorInterface::DoseAccessorPointer outputAccessor = + rttb::core::DoseAccessorInterface::DoseAccessorPointer(new + rttb::algorithms::BinaryFunctorDoseAccessor + (appData._Dose1, dose2Accessor, addOp)); + + return outputAccessor; } void rttb::apps::doseAcc::processData(rttb::apps::doseAcc::ApplicationData& appData) { - rttb::core::DoseAccessorInterface::DoseAccessorPointer outputAccessor = assembleOutputAccessor( - appData); - - std::cout << std::endl << "generate output image... "; - io::itk::ITKImageDoseAccessorConverter converter(outputAccessor); - converter.setFailOnInvalidIDs(true); - converter.process(); - io::itk::ITKDoseImageType::Pointer itkImage = converter.getITKImage(); - std::cout << "done." << std::endl; - - typedef ::itk::ImageFileWriter WriterType; - - std::cout << std::endl << "write output image... "; - WriterType::Pointer writer = WriterType::New(); - writer->SetInput(itkImage); - writer->SetFileName(appData._outputFileName); - writer->Write(); - std::cout << "done." << std::endl; + rttb::core::DoseAccessorInterface::DoseAccessorPointer outputAccessor = assembleOutputAccessor( + appData); + + std::cout << std::endl << "generate output image... "; + io::itk::ITKImageDoseAccessorConverter converter(outputAccessor); + converter.setFailOnInvalidIDs(true); + converter.process(); + io::itk::ITKDoseImageType::Pointer itkImage = converter.getITKImage(); + std::cout << "done." << std::endl; + + typedef ::itk::ImageFileWriter WriterType; + + std::cout << std::endl << "write output image... "; + WriterType::Pointer writer = WriterType::New(); + writer->SetInput(itkImage); + writer->SetFileName(appData._outputFileName); + writer->Write(); + std::cout << "done." << std::endl; }; diff --git a/demoapps/DoseAcc/DoseAccHelper.h b/demoapps/DoseAcc/DoseAccHelper.h index 7bfb6d7..cf51430 100644 --- a/demoapps/DoseAcc/DoseAccHelper.h +++ b/demoapps/DoseAcc/DoseAccHelper.h @@ -1,49 +1,58 @@ // ----------------------------------------------------------------------- // 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_ACC_HELPER_H #define __DOSE_ACC_HELPER_H #include "DoseAccApplicationData.h" namespace rttb { namespace apps { namespace doseAcc { + /**loads the dose from a file. Throws exception if loading fails*/ + core::DoseAccessorInterface::DoseAccessorPointer loadDose(const std::string& fileName, + const rttb::apps::doseAcc::ApplicationData::LoadingStyleArgType& args); + + /**loads the dose from a file using the dicom dose generator. Throws exception if loading fails*/ + core::DoseAccessorInterface::DoseAccessorPointer loadDicomDose(const std::string& fileName); + /**loads the dose from a path using the helax io dose generator. Throws exception if loading fails*/ + core::DoseAccessorInterface::DoseAccessorPointer loadHelaxDose(const std::string& path); /**loads the dose from a file stored in an ITK supported data format. Throws exception if loading fails*/ - core::DoseAccessorInterface::DoseAccessorPointer loadDose(const std::string& fileName); + core::DoseAccessorInterface::DoseAccessorPointer loadITKDose(const std::string& fileName); /**loads the dose from a file stored in Virtuos data format. Throws exception if loading fails*/ - core::DoseAccessorInterface::DoseAccessorPointer loadVirtuosDose(const std::string& fileName, const std::string& planFileName); + core::DoseAccessorInterface::DoseAccessorPointer loadVirtuosDose(const std::string& fileName, + const std::string& planFileName); ApplicationData::RegistrationType::Pointer loadRegistration(const std::string& fileName); /**Containes the business logic for the accumulation of the doses and the storing of the result. Uses appData for the input data and the correct configuration.*/ void processData(ApplicationData& appData); } } } #endif diff --git a/testing/core/DummyDoseAccessor.h b/testing/core/DummyDoseAccessor.h index e1eaed0..241695a 100644 --- a/testing/core/DummyDoseAccessor.h +++ b/testing/core/DummyDoseAccessor.h @@ -1,80 +1,80 @@ // ----------------------------------------------------------------------- // 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 __DUMMY_DOSE_ACCESSOR_H #define __DUMMY_DOSE_ACCESSOR_H #include -#include "rttbDoseAccessorInterface.h" +#include "rttbDoseAccessorWithGeoInfoBase.h" #include "rttbGeometricInfo.h" #include "rttbBaseType.h" namespace rttb { - namespace testing - { + namespace testing + { - /*! @class DummyDoseAccessor - @brief A dummy DoseAccessor for testing filled with random dose values between 0 and 100. - The default grid size is [11,10,5] - */ - class DummyDoseAccessor: public core::DoseAccessorInterface - { + /*! @class DummyDoseAccessor + @brief A dummy DoseAccessor for testing filled with random dose values between 0 and 100. + The default grid size is [11,10,5] + */ + class DummyDoseAccessor: public core::DoseAccessorWithGeoInfoBase + { - private: - /*! vector of dose data(absolute Gy dose/doseGridScaling)*/ - std::vector doseData; + private: + /*! vector of dose data(absolute Gy dose/doseGridScaling)*/ + std::vector doseData; - IDType _doseUID; + IDType _doseUID; - public: - ~DummyDoseAccessor(); + public: + ~DummyDoseAccessor(); - /*! @brief A dummy DoseAccessor for testing filled with random dose values between 0 and 100. - The default grid size is [11,10,5] - */ - DummyDoseAccessor(); + /*! @brief A dummy DoseAccessor for testing filled with random dose values between 0 and 100. + The default grid size is [11,10,5] + */ + DummyDoseAccessor(); - /*! @brief Constructor. - Initialisation of dose with a given vector. - */ - DummyDoseAccessor(const std::vector& aDoseVector, const core::GeometricInfo& geoInfo); + /*! @brief Constructor. + Initialisation of dose with a given vector. + */ + DummyDoseAccessor(const std::vector& aDoseVector, const core::GeometricInfo& geoInfo); - const std::vector* getDoseVector() const - { - return &doseData; - }; + const std::vector* getDoseVector() const + { + return &doseData; + }; - DoseTypeGy getDoseAt(const VoxelGridID aID) const; + DoseTypeGy getDoseAt(const VoxelGridID aID) const; - DoseTypeGy getDoseAt(const VoxelGridIndex3D& aIndex) const; + DoseTypeGy getDoseAt(const VoxelGridIndex3D& aIndex) const; - const IDType getDoseUID() const - { - return _doseUID; - }; - }; - } + const IDType getDoseUID() const + { + return _doseUID; + }; + }; + } } #endif diff --git a/testing/core/DummyMutableDoseAccessor.cpp b/testing/core/DummyMutableDoseAccessor.cpp index a6acc72..3c4502b 100644 --- a/testing/core/DummyMutableDoseAccessor.cpp +++ b/testing/core/DummyMutableDoseAccessor.cpp @@ -1,113 +1,120 @@ // ----------------------------------------------------------------------- // 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 #include #include #include "DummyMutableDoseAccessor.h" #include "rttbNullPointerException.h" #include "rttbInvalidDoseException.h" #include "rttbIndexOutOfBoundsException.h" namespace rttb { - namespace testing - { - - DummyMutableDoseAccessor::~DummyMutableDoseAccessor() {} - - DummyMutableDoseAccessor::DummyMutableDoseAccessor() - { - boost::uuids::uuid id; - boost::uuids::random_generator generator; - id = generator(); - std::stringstream ss; - ss << id; - _doseUID = "DummyMutableDoseAccessor_" + ss.str(); - - SpacingVectorType3D aVector(2.5); - _geoInfo.setSpacing(aVector); - WorldCoordinate3D anOtherVector(-25, -2, 35); - _geoInfo.setImagePositionPatient(anOtherVector); - _geoInfo.setNumRows(11); - _geoInfo.setNumColumns(10); - _geoInfo.setNumSlices(5); - - OrientationMatrix unit = OrientationMatrix(); - _geoInfo.setOrientationMatrix(unit); - - for (int i = 0; i < _geoInfo.getNumberOfVoxels(); i++) - { - doseData.push_back((double(rand()) / RAND_MAX) * 1000); - } - } - - DummyMutableDoseAccessor::DummyMutableDoseAccessor(const std::vector& aDoseVector, - const core::GeometricInfo& geoInfo) - { - boost::uuids::uuid id; - boost::uuids::random_generator generator; - id = generator(); - std::stringstream ss; - ss << id; - _doseUID = "DummyMutableDoseAccessor_" + ss.str(); - - doseData = aDoseVector; - _geoInfo = geoInfo; - } - - DoseTypeGy DummyMutableDoseAccessor::getDoseAt(const VoxelGridID aID) const - { - if (!_geoInfo.validID(aID)) - { - throw core::IndexOutOfBoundsException("Not a valid Position!"); - } - - return doseData.at(aID); - } - - DoseTypeGy DummyMutableDoseAccessor::getDoseAt(const VoxelGridIndex3D& aIndex) const - { - VoxelGridID gridID = 0; - _geoInfo.convert(aIndex, gridID); - return getDoseAt(gridID); - } - - void DummyMutableDoseAccessor::setDoseAt(const VoxelGridID aID, DoseTypeGy value) - { - if (!_geoInfo.validID(aID)) - { - throw core::IndexOutOfBoundsException("Not a valid Position!"); - } - - doseData.at(aID) = value; - } - - void DummyMutableDoseAccessor::setDoseAt(const VoxelGridIndex3D& aIndex, DoseTypeGy value) - { - VoxelGridID gridID = 0; - _geoInfo.convert(aIndex, gridID); - setDoseAt(gridID, value); - } - - }//end namespace testing + namespace testing + { + + DummyMutableDoseAccessor::~DummyMutableDoseAccessor() {} + + DummyMutableDoseAccessor::DummyMutableDoseAccessor() + { + boost::uuids::uuid id; + boost::uuids::random_generator generator; + id = generator(); + std::stringstream ss; + ss << id; + _doseUID = "DummyMutableDoseAccessor_" + ss.str(); + + SpacingVectorType3D aVector(2.5); + _geoInfo.setSpacing(aVector); + WorldCoordinate3D anOtherVector(-25, -2, 35); + _geoInfo.setImagePositionPatient(anOtherVector); + _geoInfo.setNumRows(11); + _geoInfo.setNumColumns(10); + _geoInfo.setNumSlices(5); + + OrientationMatrix unit = OrientationMatrix(); + _geoInfo.setOrientationMatrix(unit); + + for (int i = 0; i < _geoInfo.getNumberOfVoxels(); i++) + { + doseData.push_back((double(rand()) / RAND_MAX) * 1000); + } + } + + DummyMutableDoseAccessor::DummyMutableDoseAccessor(const std::vector& aDoseVector, + const core::GeometricInfo& geoInfo) + { + boost::uuids::uuid id; + boost::uuids::random_generator generator; + id = generator(); + std::stringstream ss; + ss << id; + _doseUID = "DummyMutableDoseAccessor_" + ss.str(); + + doseData = aDoseVector; + _geoInfo = geoInfo; + } + + const core::GeometricInfo& + DummyMutableDoseAccessor:: + getGeometricInfo() const + { + return _geoInfo; + } + + DoseTypeGy DummyMutableDoseAccessor::getDoseAt(const VoxelGridID aID) const + { + if (!_geoInfo.validID(aID)) + { + throw core::IndexOutOfBoundsException("Not a valid Position!"); + } + + return doseData.at(aID); + } + + DoseTypeGy DummyMutableDoseAccessor::getDoseAt(const VoxelGridIndex3D& aIndex) const + { + VoxelGridID gridID = 0; + _geoInfo.convert(aIndex, gridID); + return getDoseAt(gridID); + } + + void DummyMutableDoseAccessor::setDoseAt(const VoxelGridID aID, DoseTypeGy value) + { + if (!_geoInfo.validID(aID)) + { + throw core::IndexOutOfBoundsException("Not a valid Position!"); + } + + doseData.at(aID) = value; + } + + void DummyMutableDoseAccessor::setDoseAt(const VoxelGridIndex3D& aIndex, DoseTypeGy value) + { + VoxelGridID gridID = 0; + _geoInfo.convert(aIndex, gridID); + setDoseAt(gridID, value); + } + + }//end namespace testing }//end namespace rttb \ No newline at end of file diff --git a/testing/core/DummyMutableDoseAccessor.h b/testing/core/DummyMutableDoseAccessor.h index 99bb819..496451e 100644 --- a/testing/core/DummyMutableDoseAccessor.h +++ b/testing/core/DummyMutableDoseAccessor.h @@ -1,85 +1,88 @@ // ----------------------------------------------------------------------- // 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 __DUMMY_MUTABLE_DOSE_ACCESSOR_H #define __DUMMY_MUTABLE_DOSE_ACCESSOR_H #include #include "rttbMutableDoseAccessorInterface.h" #include "rttbGeometricInfo.h" #include "rttbBaseType.h" namespace rttb { - namespace testing - { + namespace testing + { - /*! @class DummyMutableDoseAccessor - @brief A dummy MutableDoseAccessor for testing filled with random dose values between 0 and 100. - The default grid size is [11,10,5] - */ - class DummyMutableDoseAccessor: public core::MutableDoseAccessorInterface - { + /*! @class DummyMutableDoseAccessor + @brief A dummy MutableDoseAccessor for testing filled with random dose values between 0 and 100. + The default grid size is [11,10,5] + */ + class DummyMutableDoseAccessor: public core::MutableDoseAccessorInterface + { - private: - /*! vector of dose data(absolute Gy dose/doseGridScaling)*/ - std::vector doseData; + private: + /*! vector of dose data(absolute Gy dose/doseGridScaling)*/ + std::vector doseData; - IDType _doseUID; + IDType _doseUID; + core::GeometricInfo _geoInfo; - public: - ~DummyMutableDoseAccessor(); + public: + ~DummyMutableDoseAccessor(); - /*! @brief A dummy DummyMutableDoseAccessor for testing filled with random dose values between 0 and 100. - The default grid size is [11,10,5] - */ - DummyMutableDoseAccessor(); + /*! @brief A dummy DummyMutableDoseAccessor for testing filled with random dose values between 0 and 100. + The default grid size is [11,10,5] + */ + DummyMutableDoseAccessor(); - /*! @brief Constructor. - Initialisation of dose with a given vector. - */ - DummyMutableDoseAccessor(const std::vector& aDoseVector, - const core::GeometricInfo& geoInfo); + /*! @brief Constructor. + Initialisation of dose with a given vector. + */ + DummyMutableDoseAccessor(const std::vector& aDoseVector, + const core::GeometricInfo& geoInfo); - const std::vector* getDoseVector() const - { - return &doseData; - }; + const std::vector* getDoseVector() const + { + return &doseData; + }; - DoseTypeGy getDoseAt(const VoxelGridID aID) const; + virtual const core::GeometricInfo& getGeometricInfo() const; - DoseTypeGy getDoseAt(const VoxelGridIndex3D& aIndex) const; + DoseTypeGy getDoseAt(const VoxelGridID aID) const; - void setDoseAt(const VoxelGridID aID, DoseTypeGy value); + DoseTypeGy getDoseAt(const VoxelGridIndex3D& aIndex) const; - void setDoseAt(const VoxelGridIndex3D& aIndex, DoseTypeGy value); + void setDoseAt(const VoxelGridID aID, DoseTypeGy value); - const IDType getDoseUID() const - { - return _doseUID; - }; - }; - } + void setDoseAt(const VoxelGridIndex3D& aIndex, DoseTypeGy value); + + const IDType getDoseUID() const + { + return _doseUID; + }; + }; + } } #endif