diff --git a/Code/Algorithms/Common/include/mapArbitraryImagePyramidesPolicy.h b/Code/Algorithms/Common/include/mapArbitraryImagePyramidesPolicy.h index f900e54..4249049 100644 --- a/Code/Algorithms/Common/include/mapArbitraryImagePyramidesPolicy.h +++ b/Code/Algorithms/Common/include/mapArbitraryImagePyramidesPolicy.h @@ -1,185 +1,185 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __ARBITRARY_IMAGE_PYRAMIDE_POLICY_H #define __ARBITRARY_IMAGE_PYRAMIDE_POLICY_H #include "mapContinuous.h" #include "mapImagePyramidesSetterInterface.h" #include "mapImagePyramidesGetterInterface.h" #include "mapModificationTimeValidator.h" #include "itkCommand.h" namespace map { namespace algorithm { /*! @class ArbitraryImagePyramidesPolicy @brief class for ArbitraryImagePyramidesPolicy. This class is a ArbitraryImagePyramidesPolicy. It is used if an algorithm implements a MultiResImageRegistrationAlgorithmBase and you want to allow that the pyramide can be set and get arbitrarily by the user (in contrary to FixedImagePyramidePolicy). @sa FixedImagePyramidePolicy @ingroup ITKPolicies */ template class ArbitraryImagePyramidesPolicy : public facet::ImagePyramidesSetterInterface, public facet::ImagePyramidesGetterInterface { public: typedef ArbitraryImagePyramidesPolicy Self; typedef facet::ImagePyramidesSetterInterface Superclass; using MovingImageType = TMovingImage; using TargetImageType = TTargetImage; itkTypeMacroNoParent(ArbitraryImagePyramidesPolicy); /** Type of the image multiresolution pyramids. */ using TargetImagePyramideBaseType = typename Superclass::TargetImagePyramideBaseType; using TargetImagePyramideBasePointer = typename Superclass::TargetImagePyramideBasePointer; using MovingImagePyramideBaseType = typename Superclass::MovingImagePyramideBaseType; using MovingImagePyramideBasePointer = typename Superclass::MovingImagePyramideBasePointer; /*! @brief sets the moving image pyramide @eguarantee strong @param pMovingMask a pointer to the moving image pyramide */ virtual void setMovingImagePyramide(MovingImagePyramideBaseType* pMovingPyramide); /*! @brief sets the target image pyramide @eguarantee strong @param pTargetMask a pointer to the moving image pyramide */ virtual void setTargetImagePyramide(TargetImagePyramideBaseType* pTargetPyramide); /*! @brief gets a pointer to the moving image pyramide @eguarantee strong @return a pointer to the moving image pyramide */ virtual MovingImagePyramideBaseType* getMovingImagePyramide(); /*! @brief gets a const pointer to the moving image pyramide @eguarantee strong @return a const pointer to the moving image pyramide */ virtual const MovingImagePyramideBaseType* getMovingImagePyramide() const; /*! @brief gets a pointer to the target image pyramide @eguarantee strong @return a pointer to the target image pyramide */ virtual TargetImagePyramideBaseType* getTargetImagePyramide(); /*! @brief gets a const pointer to the target image pyramide @eguarantee strong @return a const pointer to the target image pyramide */ virtual const TargetImagePyramideBaseType* getTargetImagePyramide() const; protected: ArbitraryImagePyramidesPolicy(); ~ArbitraryImagePyramidesPolicy(); /*! This is a command slot that can be used by any class derivering from this policy * to get informed if the moving pyramide instances is changed. \n * Two events will be invoked with this command: \n * - UnregisterAlgorithmComponentEvent * - RegisterAlgorithmComponentEvent * . * The first one is used when the current pyramide is going to be replaced (by setMovingImagePyramide). The event data in this case * is a void pointer to the current (soon outdated) object. The second event will be called when the new image pyramide was set * (by setMovingImagePyramide). In this case the event data is a pointer to the new pyramide.*/ ::itk::Command::Pointer _spOnChangeMoving; /*! This is a command slot that can be used by any class derivering from this policy * to get informed if the target pyramide instances is changed. \n * Two events will be invoked with this command: \n * - UnregisterAlgorithmComponentEvent * - RegisterAlgorithmComponentEvent * . * The first one is used when the current pyramide is going to be replaced (by setTargetImagePyramide). The event data in this case * is a void pointer to the current (soon outdated) object. The second event will be called when the new image pyramide was set * (by setTargetImagePyramide). In this case the event data is a pointer to the new pyramide.*/ ::itk::Command::Pointer _spOnChangeTarget; /*! gets the internal pyramides @eguarantee strong @return a pointer to an pyramide type */ virtual MovingImagePyramideBaseType* getMovingPyramideInternal(); virtual const MovingImagePyramideBaseType* getMovingPyramideInternal() const; virtual TargetImagePyramideBaseType* getTargetPyramideInternal(); virtual const TargetImagePyramideBaseType* getTargetPyramideInternal() const; /*! initializes the pyramides @eguarantee strong */ void preparePyramides(); /*! initializes the pyramides * after it was integrated in a controlling structur (e.g. registration algorithm) @eguarantee strong */ void preparePyramidesAfterAssembly(); /** Return this modified time of the target pyramide. */ - unsigned long getTargetPyramideMTime() const; + ::itk::ModifiedTimeType getTargetPyramideMTime() const; /** Return this modified time of the moving pyramide. */ - unsigned long getMovingPyramideMTime() const; + ::itk::ModifiedTimeType getMovingPyramideMTime() const; private: ::map::core::ModificationTimeValidator _movingPyramideMTime; ::map::core::ModificationTimeValidator _targetPyramideMTime; /*! The time stamp is used to signal changes of the policy that may effect the controlling structur (e.g. registration algorithm) * because the controlled object has changed.*/ MovingImagePyramideBasePointer _spMovingPyramide; /*! The time stamp is used to signal changes of the policy that may effect the controlling structur (e.g. registration algorithm) * because the controlled object has changed.*/ TargetImagePyramideBasePointer _spTargetPyramide; //No copy constructor allowed ArbitraryImagePyramidesPolicy(const Self& source); void operator=(const Self&); //purposely not implemented }; } // namespace algorithm } // namespace map #ifndef MatchPoint_MANUAL_TPP #include "mapArbitraryImagePyramidesPolicy.tpp" #endif #endif diff --git a/Code/Algorithms/Common/include/mapArbitraryImagePyramidesPolicy.tpp b/Code/Algorithms/Common/include/mapArbitraryImagePyramidesPolicy.tpp index 254526f..faf7954 100644 --- a/Code/Algorithms/Common/include/mapArbitraryImagePyramidesPolicy.tpp +++ b/Code/Algorithms/Common/include/mapArbitraryImagePyramidesPolicy.tpp @@ -1,205 +1,205 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #include "mapAlgorithmEvents.h" #ifndef __ARBITRARY_IMAGE_PYRAMIDE_POLICY_TPP #define __ARBITRARY_IMAGE_PYRAMIDE_POLICY_TPP namespace map { namespace algorithm { template - unsigned long + ::itk::ModifiedTimeType ArbitraryImagePyramidesPolicy:: getTargetPyramideMTime() const { - unsigned long mt = _targetPyramideMTime.getMTime(); + auto mt = _targetPyramideMTime.getMTime(); return mt; }; template - unsigned long + ::itk::ModifiedTimeType ArbitraryImagePyramidesPolicy:: getMovingPyramideMTime() const { - unsigned long mt = _movingPyramideMTime.getMTime(); + auto mt = _movingPyramideMTime.getMTime(); return mt; }; template ArbitraryImagePyramidesPolicy :: ArbitraryImagePyramidesPolicy() { } template ArbitraryImagePyramidesPolicy :: ~ArbitraryImagePyramidesPolicy() { } template typename ArbitraryImagePyramidesPolicy ::MovingImagePyramideBaseType* ArbitraryImagePyramidesPolicy :: getMovingPyramideInternal() { return _spMovingPyramide; } template const typename ArbitraryImagePyramidesPolicy ::MovingImagePyramideBaseType* ArbitraryImagePyramidesPolicy :: getMovingPyramideInternal() const { return _spMovingPyramide; } template typename ArbitraryImagePyramidesPolicy ::TargetImagePyramideBaseType* ArbitraryImagePyramidesPolicy :: getTargetPyramideInternal() { return _spTargetPyramide; } template const typename ArbitraryImagePyramidesPolicy ::TargetImagePyramideBaseType* ArbitraryImagePyramidesPolicy :: getTargetPyramideInternal() const { return _spTargetPyramide; } template typename ArbitraryImagePyramidesPolicy ::MovingImagePyramideBaseType* ArbitraryImagePyramidesPolicy :: getMovingImagePyramide() { return _spMovingPyramide; } template const typename ArbitraryImagePyramidesPolicy ::MovingImagePyramideBaseType* ArbitraryImagePyramidesPolicy :: getMovingImagePyramide() const { return _spMovingPyramide; } template typename ArbitraryImagePyramidesPolicy ::TargetImagePyramideBaseType* ArbitraryImagePyramidesPolicy :: getTargetImagePyramide() { return _spTargetPyramide; } template const typename ArbitraryImagePyramidesPolicy ::TargetImagePyramideBaseType* ArbitraryImagePyramidesPolicy :: getTargetImagePyramide() const { return _spTargetPyramide; } template void ArbitraryImagePyramidesPolicy :: setMovingImagePyramide(MovingImagePyramideBaseType* pMovingPyramide) { if (pMovingPyramide != _spMovingPyramide.GetPointer()) { //there is really the need to change if (this->_spOnChangeMoving.IsNotNull()) { ::map::events::UnregisterAlgorithmComponentEvent unRegEvent(_spMovingPyramide.GetPointer(), "Unregister current moving image pyramide"); this->_spOnChangeMoving->Execute((::itk::Object*)NULL, unRegEvent); } _movingPyramideMTime.setWatchedObject(pMovingPyramide); _spMovingPyramide = pMovingPyramide; if (this->_spOnChangeMoving.IsNotNull()) { ::map::events::RegisterAlgorithmComponentEvent regEvent(_spMovingPyramide.GetPointer(), "Register new moving image pyramide"); this->_spOnChangeMoving->Execute((::itk::Object*)NULL, regEvent); } } } template void ArbitraryImagePyramidesPolicy :: setTargetImagePyramide(TargetImagePyramideBaseType* pTargetPyramide) { if (pTargetPyramide != _spTargetPyramide.GetPointer()) { //there is really the need to change if (this->_spOnChangeTarget.IsNotNull()) { ::map::events::UnregisterAlgorithmComponentEvent unRegEvent(_spTargetPyramide.GetPointer(), "Unregister current target image pyramide"); this->_spOnChangeTarget->Execute((::itk::Object*)NULL, unRegEvent); } _targetPyramideMTime.setWatchedObject(pTargetPyramide); _spTargetPyramide = pTargetPyramide; if (this->_spOnChangeTarget.IsNotNull()) { ::map::events::RegisterAlgorithmComponentEvent regEvent(_spTargetPyramide.GetPointer(), "Register new target image pyramide"); this->_spOnChangeTarget->Execute((::itk::Object*)NULL, regEvent); } } } template void ArbitraryImagePyramidesPolicy :: preparePyramides() { //default implementation does nothing; } template void ArbitraryImagePyramidesPolicy :: preparePyramidesAfterAssembly() { //default implementation does nothing; } } // namespace algorithm } // namespace map #endif diff --git a/Code/Algorithms/Common/include/mapImageRegistrationAlgorithmBase.h b/Code/Algorithms/Common/include/mapImageRegistrationAlgorithmBase.h index 06fc1f3..3af8199 100644 --- a/Code/Algorithms/Common/include/mapImageRegistrationAlgorithmBase.h +++ b/Code/Algorithms/Common/include/mapImageRegistrationAlgorithmBase.h @@ -1,121 +1,121 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __IMAGE_REGISTRATION_ALGORITHM_BASE_H #define __IMAGE_REGISTRATION_ALGORITHM_BASE_H #include "itkIndent.h" #include "itkTimeStamp.h" #include "mapImageRegistrationAlgorithmInterface.h" namespace map { namespace algorithm { /*! @class ImageRegistrationAlgorithmBase @brief This is the interface for image registration algorithms @ingroup AlgorithmFacets @template TMovingImage Type of the moving image @template TTargetImage Type of the target image */ template class ImageRegistrationAlgorithmBase : public facet::ImageRegistrationAlgorithmInterface { public: typedef ImageRegistrationAlgorithmBase Self; using MovingImageType = TMovingImage; using TargetImageType = TTargetImage; using MovingImageConstPointer = typename MovingImageType::ConstPointer; using TargetImageConstPointer = typename TargetImageType::ConstPointer; /*! @brief gets a const pointer to the moving image @eguarantee strong @return a const pointer to the moving image */ MovingImageConstPointer getMovingImage() const; /*! @brief gets a const pointer to the target image @eguarantee strong @return a const pointer to the target image */ TargetImageConstPointer getTargetImage() const; /*! @brief sets the moving image @eguarantee strong @param pMovingImage a pointer to the moving image */ void setMovingImage(const MovingImageType* pMovingImage); /*! @brief sets the target image @eguarantee strong @param pTargetImage a pointer to the moving image */ void setTargetImage(const TargetImageType* pTargetImage); protected: /*! @brief virtual destructor */ virtual ~ImageRegistrationAlgorithmBase(); ImageRegistrationAlgorithmBase(); /*! Methods invoked by derivated classes. */ virtual void PrintSelf(std::ostream& os, ::itk::Indent indent) const; /** Return this modified time of the target image. */ - unsigned long getTargetImageMTime() const; + ::itk::ModifiedTimeType getTargetImageMTime() const; /** Return this modified time of the moving image. */ - unsigned long getMovingImageMTime() const; + ::itk::ModifiedTimeType getMovingImageMTime() const; private: MovingImageConstPointer _spMovingImage; ::itk::TimeStamp _movingImageMTime; TargetImageConstPointer _spTargetImage; ::itk::TimeStamp _targetImageMTime; //No copy constructor allowed ImageRegistrationAlgorithmBase(const Self& source); void operator=(const Self&); //purposely not implemented }; } // namespace algorithm } // namespace map #ifndef MatchPoint_MANUAL_TPP #include "mapImageRegistrationAlgorithmBase.tpp" #endif #endif diff --git a/Code/Algorithms/Common/include/mapImageRegistrationAlgorithmBase.tpp b/Code/Algorithms/Common/include/mapImageRegistrationAlgorithmBase.tpp index fe9b90c..90f0142 100644 --- a/Code/Algorithms/Common/include/mapImageRegistrationAlgorithmBase.tpp +++ b/Code/Algorithms/Common/include/mapImageRegistrationAlgorithmBase.tpp @@ -1,110 +1,110 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __IMAGE_REGISTRATION_ALGORITHM_INTERFACE_TPP #define __IMAGE_REGISTRATION_ALGORITHM_INTERFACE_TPP namespace map { namespace algorithm { template typename ImageRegistrationAlgorithmBase::MovingImageConstPointer ImageRegistrationAlgorithmBase:: getMovingImage() const { return _spMovingImage; } template typename ImageRegistrationAlgorithmBase::TargetImageConstPointer ImageRegistrationAlgorithmBase:: getTargetImage() const { return _spTargetImage; } template void ImageRegistrationAlgorithmBase:: setMovingImage(const MovingImageType* pMovingImage) { if (this->_spMovingImage != pMovingImage) { this->_spMovingImage = pMovingImage; this->_movingImageMTime.Modified(); } } template void ImageRegistrationAlgorithmBase:: setTargetImage(const TargetImageType* pTargetImage) { if (this->_spTargetImage != pTargetImage) { this->_spTargetImage = pTargetImage; this->_targetImageMTime.Modified(); } } template ImageRegistrationAlgorithmBase:: ~ImageRegistrationAlgorithmBase() {} template ImageRegistrationAlgorithmBase:: ImageRegistrationAlgorithmBase() {} template void ImageRegistrationAlgorithmBase:: PrintSelf(std::ostream& os, ::itk::Indent indent) const { os << indent << "Moving image: " << _spMovingImage.GetPointer() << std::endl; os << indent << "Target image: " << _spTargetImage.GetPointer() << std::endl; } template - unsigned long + ::itk::ModifiedTimeType ImageRegistrationAlgorithmBase:: getTargetImageMTime() const { return _targetImageMTime.GetMTime(); }; template - unsigned long + ::itk::ModifiedTimeType ImageRegistrationAlgorithmBase:: getMovingImageMTime() const { return _movingImageMTime.GetMTime(); }; } // namespace algorithm } // end namespace map #endif diff --git a/Code/Algorithms/Common/include/mapImageRegistrationAlgorithmInterfaceV2.h b/Code/Algorithms/Common/include/mapImageRegistrationAlgorithmInterfaceV2.h index 9af14a8..5d76c88 100644 --- a/Code/Algorithms/Common/include/mapImageRegistrationAlgorithmInterfaceV2.h +++ b/Code/Algorithms/Common/include/mapImageRegistrationAlgorithmInterfaceV2.h @@ -1,217 +1,217 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/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: 797 $ (last changed revision) // @date $Date: 2014-10-10 11:42:05 +0200 (Fr, 10 Okt 2014) $ (last change date) // @author $Author: floca $ (last changed by) // Subversion HeadURL: $HeadURL: https://svn.inet.dkfz-heidelberg.de/sbr/Sources/SBR-Projects/MatchPoint/trunk/Code/Algorithms/Common/include/mapImageRegistrationAlgorithmInterface.h $ */ #ifndef __IMAGE_REGISTRATION_ALGORITHM_INTERFACE_V2_H #define __IMAGE_REGISTRATION_ALGORITHM_INTERFACE_V2_H #include "mapImageRegistrationAlgorithmInterface.h" /*! @namespace */ namespace map { namespace algorithm { namespace facet { /*! @class ImageRegistrationAlgorithmInterfaceV2 @brief This is the interface for image based registration algorithms (Version 2) This version extents the first version by: 1. Allow define multiple inputs for the roles (moving / target) 2. posibility to query if the input slots are mandatory or just optional. The inputs are indexed (like itk filters) and the interface implies that all mandatory input slots of a role (moving or target) have lower indeces then optional slots of the same role. So e.g. given 4 mandatory moving input slots, by definition they will have the indeces 0..3. Optional slots will start with 4. An additional assumption is that ImageRegistrationAlgorithmInterface accesses the first slots (slot index 0). According to this assumptions the methods of ImageRegistrationAlgorithmInterface have a default implementation. @sa ImageRegistrationAlgorithmInterface @ingroup AlgorithmFacets @template TMovingImage Type of the moving image @template TTargetImage Type of the target image */ template class ImageRegistrationAlgorithmInterfaceV2 : public ImageRegistrationAlgorithmInterface { public: typedef ImageRegistrationAlgorithmInterfaceV2 Self; typedef ImageRegistrationAlgorithmInterface Superclass; typedef typename Superclass::MovingImageType MovingImageType; typedef typename Superclass::TargetImageType TargetImageType; typedef typename Superclass::MovingImageConstPointer MovingImageConstPointer; typedef typename Superclass::TargetImageConstPointer TargetImageConstPointer; typedef unsigned int SlotIndexType; itkTypeMacroNoParent(ImageRegistrationAlgorithmInterfaceV2); /*! @brief gets a const pointer to the moving image for the specified index @eguarantee strong @param index Index of the requested slot. @return a const pointer to the moving image @pre If index is out of bound an exception will be thrown. */ MovingImageConstPointer getNthMovingImage(SlotIndexType index) const { if (index >= this->getMovingImageCount()) { mapDefaultExceptionMacro(<< "Error. Index of requested moving image is out of bounds. Requested index: " << index << "; number of images: " << getMovingImageCount()); } return doGetNthMovingImage(index); }; /*! @brief gets a const pointer to the target image for the specified index @eguarantee strong @param index Index of the requested slot. @return a const pointer to the target image. If no data has been set for the index null ptr will be returned. @pre If index is out of bound an exception will be thrown. */ TargetImageConstPointer getNthTargetImage(SlotIndexType index) const { if (index >= this->getTargetImageCount()) { mapDefaultExceptionMacro(<< "Error. Index of requested target image is out of bounds. Requested index: " << index << "; number of images: " << getNthTargetImage()); } return doGetNthTargetImage(index); }; /*! @brief sets the moving image for a specified slot index @eguarantee strong @param pMovingImage a pointer to the moving image @param index Index of the slot. @pre If index is out of bound an exception will be thrown. */ void setNthMovingImage(SlotIndexType index, const MovingImageType* pMovingImage) { if (index >= this->getMovingImageCount()) { mapDefaultExceptionMacro(<< "Error. Setter index of moving image is out of bounds. Specified index: " << index << "; number of image slots: " << getMovingImageCount()); } return doSetNthMovingImage(index, pMovingImage); }; /*! @brief sets the target image for a specified slot index @eguarantee strong @param pTargetImage a pointer to the moving image @param index Index of the slot. @pre If index is out of bound an exception will be thrown. */ void setNthTargetImage(SlotIndexType index, const TargetImageType* pTargetImage) { if (index >= this->getTargetImageCount()) { mapDefaultExceptionMacro(<< "Error. Setter index of target image is out of bounds. Specified index: " << index << "; number of image slots: " << getMovingImageCount()); } return doSetNthTargetImage(index, pTargetImage); }; /*! Indicates if the target and input data of one index are coupled or not. Coupled means that if the index for one role (target or moving) is set, the other role at this index must also be set. @return True if coupled. False if not. @eguarantee strong*/ virtual bool hasCoupledImageInputs() const { return true; }; /*! Indicates if the passed index indicates a mandatory (false) or an optional (true) input.*/ virtual bool isOptionalTargetImage(SlotIndexType index) const { return false; }; /*! Indicates if the passed index indicates a mandatory (false) or an optional (true) input.*/ virtual bool isOptionalMovingImage(SlotIndexType index) const { return false; }; /*! Gets the number of target inputs (in total: onlyMandatory == false) @eguarantee strong */ virtual SlotIndexType getTargetImageCount(bool onlyMandatory = false) const { return 1; }; /*! Gets the number of moving inputs (in total: onlyMandatory == false) @eguarantee strong */ virtual SlotIndexType getMovingImageCount(bool onlyMandatory = false) const { return 1; }; /*! returns the modification time of the target image. */ - virtual unsigned long getNthTargetImageMTime(SlotIndexType index) const = 0; + virtual ::itk::ModifiedTimeType getNthTargetImageMTime(SlotIndexType index) const = 0; /*! returns the modification time of the moving image. */ - virtual unsigned long getNthMovingImageMTime(SlotIndexType index) const = 0; + virtual ::itk::ModifiedTimeType getNthMovingImageMTime(SlotIndexType index) const = 0; virtual MovingImageConstPointer getMovingImage() const override { return getNthMovingImage(0); }; virtual TargetImageConstPointer getTargetImage() const override { return getNthTargetImage(0); } virtual void setMovingImage(const MovingImageType* pMovingImage) override { setNthMovingImage(0, pMovingImage); }; virtual void setTargetImage(const TargetImageType* pTargetImage) override { setNthTargetImage(0, pTargetImage); }; - virtual unsigned long getTargetImageMTime() const override + virtual ::itk::ModifiedTimeType getTargetImageMTime() const override { return getNthTargetImageMTime(0); }; - virtual unsigned long getMovingImageMTime() const override + virtual ::itk::ModifiedTimeType getMovingImageMTime() const override { return getNthMovingImageMTime(0); }; protected: /*! @brief virtual destructor */ virtual ~ImageRegistrationAlgorithmInterfaceV2() {}; ImageRegistrationAlgorithmInterfaceV2() {}; virtual MovingImageConstPointer doGetNthMovingImage(SlotIndexType index) const = 0; virtual TargetImageConstPointer doGetNthTargetImage(SlotIndexType index) const = 0; virtual void doSetNthMovingImage(SlotIndexType index, const MovingImageType* pMovingImage) = 0; virtual void doSetNthTargetImage(SlotIndexType index, const TargetImageType* pTargetImage) = 0; private: //No copy constructor allowed ImageRegistrationAlgorithmInterfaceV2(const Self& source); void operator=(const Self&); //purposely not implemented }; } } } #endif diff --git a/Code/Algorithms/Common/include/mapMaskedRegistrationAlgorithmBase.h b/Code/Algorithms/Common/include/mapMaskedRegistrationAlgorithmBase.h index 9235a72..af4d5c9 100644 --- a/Code/Algorithms/Common/include/mapMaskedRegistrationAlgorithmBase.h +++ b/Code/Algorithms/Common/include/mapMaskedRegistrationAlgorithmBase.h @@ -1,133 +1,133 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __MASKED_REGISTRATION_ALGORITHM_BASE_H #define __MASKED_REGISTRATION_ALGORITHM_BASE_H #include "mapModificationTimeValidator.h" #include "mapMaskedRegistrationAlgorithmInterface.h" #include "itkIndent.h" #include "itkSpatialObject.h" /*! @namespace */ namespace map { namespace algorithm { /*! @class MaskedRegistrationAlgorithmBase *@brief This is the default implementation for the MaskedRegistrationAlgorithmInterface for registration algorithms that support *the definition of masks. * * The masks are composed via itk:SpatialObjects (e.g. images or geometric * primitives). The masks define which part of the moving and target space/image will be regarded * for the registration purpose. * This interface requires/assumes that the axis of the masks (top level spatial object) are aligned * with the according information space (e.g. in a image registration algorithm the axis of the target image * should be aligned with the axis of the target mask). * *@ingroup AlgorithmFacets *@template VMovingDimension Dimension of the moving space *@template VTargetDimension Dimension of the target space */ template class MaskedRegistrationAlgorithmBase : public facet::MaskedRegistrationAlgorithmInterface { public: typedef MaskedRegistrationAlgorithmBase Self; using MovingMaskBaseType = ::itk::SpatialObject; using TargetMaskBaseType = ::itk::SpatialObject; using MovingMaskBaseConstPointer = typename MovingMaskBaseType::ConstPointer; using TargetMaskBaseConstPointer = typename TargetMaskBaseType::ConstPointer; /*! @brief gets a const pointer to the moving mask @eguarantee strong @return a const pointer to the moving mask */ virtual MovingMaskBaseConstPointer getMovingMask() const; /*! @brief gets a const pointer to the target mask @eguarantee strong @return a const pointer to the target mask */ virtual TargetMaskBaseConstPointer getTargetMask() const; /*! @brief sets the moving mask @eguarantee strong @param pMovingMask a pointer to the moving mask */ virtual void setMovingMask(const MovingMaskBaseType* pMovingMask); /*! @brief sets the target mask @eguarantee strong @param pTargetMask a pointer to the moving mask */ virtual void setTargetMask(const TargetMaskBaseType* pTargetMask); protected: /*! @brief virtual destructor */ virtual ~MaskedRegistrationAlgorithmBase(); MaskedRegistrationAlgorithmBase(); /*! Methods invoked by derivated classes. */ virtual void PrintSelf(std::ostream& os, ::itk::Indent indent) const; /** Return this modified time of the target mask. */ - unsigned long getTargetMaskMTime() const; + ::itk::ModifiedTimeType getTargetMaskMTime() const; /** Return this modified time of the moving mask. */ - unsigned long getMovingMaskMTime() const; + ::itk::ModifiedTimeType getMovingMaskMTime() const; private: ::map::core::ModificationTimeValidator _movingMaskMTime; ::map::core::ModificationTimeValidator _targetMaskMTime; MovingMaskBaseConstPointer _spMovingMask; TargetMaskBaseConstPointer _spTargetMask; //No copy constructor allowed MaskedRegistrationAlgorithmBase(const Self& source); void operator=(const Self&); //purposely not implemented }; } // namespace algorithm } // namespace map #ifndef MatchPoint_MANUAL_TPP #include "mapMaskedRegistrationAlgorithmBase.tpp" #endif #endif diff --git a/Code/Algorithms/Common/include/mapMaskedRegistrationAlgorithmBase.tpp b/Code/Algorithms/Common/include/mapMaskedRegistrationAlgorithmBase.tpp index e6b427e..28a71b0 100644 --- a/Code/Algorithms/Common/include/mapMaskedRegistrationAlgorithmBase.tpp +++ b/Code/Algorithms/Common/include/mapMaskedRegistrationAlgorithmBase.tpp @@ -1,111 +1,111 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __MASKED_REGISTRATION_ALGORITHM_BASE_TPP #define __MASKED_REGISTRATION_ALGORITHM_BASE_TPP namespace map { namespace algorithm { // **** public methods **** // ************************ template typename MaskedRegistrationAlgorithmBase::MovingMaskBaseConstPointer MaskedRegistrationAlgorithmBase:: getMovingMask() const { return _spMovingMask; } template typename MaskedRegistrationAlgorithmBase::TargetMaskBaseConstPointer MaskedRegistrationAlgorithmBase:: getTargetMask() const { return _spTargetMask; } template void MaskedRegistrationAlgorithmBase:: setMovingMask(const MovingMaskBaseType* pMovingMask) { _spMovingMask = pMovingMask; _movingMaskMTime.setWatchedObject(pMovingMask); } template void MaskedRegistrationAlgorithmBase:: setTargetMask(const TargetMaskBaseType* pTargetMask) { _spTargetMask = pTargetMask; _targetMaskMTime.setWatchedObject(pTargetMask); } // **** protected methods **** // *************************** template MaskedRegistrationAlgorithmBase:: ~MaskedRegistrationAlgorithmBase() {} template MaskedRegistrationAlgorithmBase:: MaskedRegistrationAlgorithmBase() { } template void MaskedRegistrationAlgorithmBase:: PrintSelf(std::ostream& os, ::itk::Indent indent) const { os << indent << "Moving mask: " << _spMovingMask.GetPointer() << std::endl; os << indent << "Target mask: " << _spTargetMask.GetPointer() << std::endl; } template - unsigned long + ::itk::ModifiedTimeType MaskedRegistrationAlgorithmBase:: getTargetMaskMTime() const { return _targetMaskMTime.getMTime(); }; template - unsigned long + ::itk::ModifiedTimeType MaskedRegistrationAlgorithmBase:: getMovingMaskMTime() const { return _movingMaskMTime.getMTime(); }; } // namespace algorithm } // end namespace map #endif diff --git a/Code/Algorithms/Common/include/mapMetaPropertyAlgorithmBase.h b/Code/Algorithms/Common/include/mapMetaPropertyAlgorithmBase.h index f2b0c94..78e9c0f 100644 --- a/Code/Algorithms/Common/include/mapMetaPropertyAlgorithmBase.h +++ b/Code/Algorithms/Common/include/mapMetaPropertyAlgorithmBase.h @@ -1,211 +1,211 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __META_PROPERTY_ALGORITHM_BASE_H #define __META_PROPERTY_ALGORITHM_BASE_H #include "mapMetaPropertyAlgorithmInterface.h" namespace map { namespace algorithm { /*! @class MetaPropertyAlgorithmBase @brief This is the default implementation of the MetaPropertyAlgorithmInterface for algorithms that are able to grant an generic access to their properties. A algorithm implementing this interface offers a possibility to set or get values of selected properties of the algorithm. This feature is very useful to establish generic handling interfaces between a host application and algorithms.\n\n This implementation uses a meta property cache to store all properties that are set by the user. The Properties will be transfered to the internal algorithm by calling the member\n\n If you want to support the feature of sealed algorithms, its important to regard the remark on how to compile the property information (see compileInfos()). @ingroup AlgorithmFacets */ class MAPAlgorithms_EXPORT MetaPropertyAlgorithmBase : public facet::MetaPropertyAlgorithmInterface { public: using Self = MetaPropertyAlgorithmBase; using MetaPropertyVectorType = facet::MetaPropertyAlgorithmInterface::MetaPropertyVectorType; using MetaPropertyType = facet::MetaPropertyAlgorithmInterface::MetaPropertyType; using MetaPropertyPointer = facet::MetaPropertyAlgorithmInterface::MetaPropertyPointer; using MetaPropertyNameType = facet::MetaPropertyAlgorithmInterface::MetaPropertyNameType; /*! Returns the MetaPropertyInfo for the property identified by the passed name @eguarantee strong @return returns SmartPointer to the MetaPropertyInfo. SmartPointer may be null, if the passed property name is unkown. @retval NULL-pointer Property is unknown */ MetaPropertyInfo::Pointer getPropertyInfo(const MetaPropertyNameType& name) const override; /*! Returns a vector with smart pointer to MetaPropertyInfos for all known and therefor supported * properties. * @remark this method calls the protectes virtual methods compilePublicInfos() and compileProtectedInfos() * to generate the list. * @eguarantee strong * @return returns vector of smart pointer to the MetaPropertyInfos. */ MetaPropertyVectorType getPropertyInfos() const override; /*! Returns a smart pointer to the MetaProperty identified by the passed name. * This default implementation is:\n * 1. Check if getting MetaProperty is legal\n * 2. Check the cache. Return cached value if existing.\n * 3. Call doGetProperty().\n * @remark Implement doGetProperty() to realize the handling and forwarding of properties * @eguarantee strong * @return Returns a smart pointer to the requested MetaProperty. If the property is * unknown, not readable or not supported the returned smart pointer will point to NULL. * @param name Name that identifies the wanted property. */ MetaPropertyPointer getProperty(const MetaPropertyNameType& name) const override; /*! Returns a smart pointer to the MetaProperty identified by the passed name. * This default implementation is:\n * 1. Check if getting MetaProperty is legal\n * 2. Check the cache. Return cached value if existing.\n * 3. Call doGetProperty().\n * @remark Implement doGetProperty() to realize the handling and forwarding of properties * @eguarantee strong * @param pInfo Pointer to the MetaPropertyInfo that specifies the wanted property (by name). * Method will throw an exception if passed Pointer is NULL. * @return Returns a smart pointer to the requested MetaProperty. If the property is * unknown, not readable or not supported the returned smart pointer will point to NULL. * @pre The type defined in the pInfo must equal the type of the MetaProperty; otherwise an exception * will be raised. * @exception ::map::core::ExceptionObject Thrown if the precondition is not satisfied (pInfo is NULL or has wrong type). * @overload */ MetaPropertyPointer getProperty(const MetaPropertyInfo* pInfo) const override; /*! Allows the transferring and setting of instance properties via this generic interface. * This base implementation will store the property in the cache (overwrites an already cached instance * of the property if necessary). The internal algorithm will be configured with the MetaProperties by * calling configureAlgorithmByMetaProperties(). * @param name Name that identifies the property that should be set. * @param pProperty Pointer to the MetaProperty that contains the value that should be set. * Method will throw an exception if passed Pointer is NULL. * @return Indicates if the property was known and writable (true) or is not supported/writable (false). * @remark The function may raise exceptions. It depends on the implementation of the class setters * that will be used to finally integrate the passed and unwrapped property value into the instance. * @pre pProperty must point to a valid instance. * @exception ::map::core::ExceptionObject Thrown if a precondition is not satisfied * (pProperty is not valid). */ bool setProperty(const MetaPropertyNameType& name, const MetaPropertyType* pProperty) override; /*! Allows the transferring and setting of instance properties via this generic interface. * This base implementation will store the property in the cache (overwrites an already cached instance * of the property if necessary). The internal algorithm will be configured with the MetaProperties by * calling configureAlgorithmByMetaProperties(). * @param pInfo Pointer to the MetaPropertyInfo that specifies the wanted property (by name). * Method will throw an exception if passed Pointer is NULL. * @param pProperty Pointer to the MetaProperty that contains the value that should be set. * Method will throw an exception if passed Pointer is NULL. * @return Indicates if the property was known and writable (true) or is not supported/writable (false). * @remark The function may raise exceptions. It depends on the implementation of the class setters * that will be used to finally integrate the passed and unwrapped property value into the instance. * @pre pProperty must point to a valid instance. * @pre The type defined in the pInfo must equal the type of pProperty; otherwise an exception * will be raised. * @exception ::map::core::ExceptionObject Thrown if a precondition is not satisfied * (pInfo is NULL or has wrong type; pProperty is not valid). * @overload */ bool setProperty(const MetaPropertyInfo* pInfo, const MetaPropertyType* pProperty) override; protected: MetaPropertyAlgorithmBase(); ~MetaPropertyAlgorithmBase() override; /*! This method should be implemented to define how to compile MetaProperties * and add it to the passed info vector.\n\n * IMPORTANT REMINDER: You must ensure that in cases of sealed algorithms * only properties are added to the infos vector that may be accessed. Otherwise * you may have access to internals of sealed algorithms. The best way to take * care about this is to use a include guard "#ifndef MAP_SEAL_ALGORITHMS" * on the properties that should not be available for sealed algorithms * @eguarantee strong * @param infos Vector of MetaPropertyInfoPointer. The public MetaPropertyInfos * will be added to this vector by the method. */ virtual void compileInfos(MetaPropertyVectorType& infos) const = 0; /*! This method configures the algorithm with the cached MetaProperties. * The default implementation does this by calling * doSetProperty() for each MetaProperty stored in the cache. * @remark Implement doSetProperty() to realize the handling of passed new property values. * @eguarantee basic. */ virtual void configureAlgorithmByMetaProperties(); /*! Implement this Method to realize the getting of a property specified by name. @remark This method only is called by getProperty if getPropertyInfo has a valid return for the passed name and the property is identified as readable. @eguarantee strong @return Returns a smart pointer to the requested MetaProperty. @param name Name that identifies the wanted property. */ virtual MetaPropertyPointer doGetProperty(const MetaPropertyNameType& name) const = 0; /*! Implement this Method to realize the setting of a property specified by name. @remark This method only is called by setProperty if getPropertyInfo has a valid return for the passed name and the property is identified as writable. @param name Name that identifies the wanted property. @param pProperty Pointer to the MetaProperty that contains the value that should be set. @pre Passed pointer pProperty is not NULL. */ virtual void doSetProperty(const MetaPropertyNameType& name, const MetaPropertyType* pProperty) = 0; void resetMetaPropertyCache(); - unsigned long GetMTime() const; + ::itk::ModifiedTimeType GetMTime() const; private: typedef std::map MetaPropertyCacheType; /*! Cache for meta properties. The default implementation of GetProperty/SetProperty will use the cache in order to store user changes. See documentation of these members. The cache will be transfered to internal algorithm via configureAlgorithmByMetaProperties(). @sa GetProperty @sa SetProperty */ MetaPropertyCacheType _metaPropertyCache; ::itk::TimeStamp _cacheMTime; //No copy constructor allowed MetaPropertyAlgorithmBase(const Self& source) = delete; //purposely not implemented void operator=(const Self&) = delete; //purposely not implemented }; } // namespace algorithm } // namespace map #endif diff --git a/Code/Algorithms/Common/include/mapPointSetRegistrationAlgorithmBase.h b/Code/Algorithms/Common/include/mapPointSetRegistrationAlgorithmBase.h index cf8d38d..f3c5041 100644 --- a/Code/Algorithms/Common/include/mapPointSetRegistrationAlgorithmBase.h +++ b/Code/Algorithms/Common/include/mapPointSetRegistrationAlgorithmBase.h @@ -1,126 +1,126 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __POINT_SET_REGISTRATION_ALGORITHM_BASE_H #define __POINT_SET_REGISTRATION_ALGORITHM_BASE_H #include "mapModificationTimeValidator.h" #include "itkIndent.h" #include "mapPointSetRegistrationAlgorithmInterface.h" /*! @namespace */ namespace map { namespace algorithm { /*! @class PointSetRegistrationAlgorithmBase @brief This is the default implementation of the interface for point set based registration algorithms @ingroup AlgorithmFacets @template TMovingPointSet Type of the moving point set @template TTargetPointSet Type of the target point set */ template class PointSetRegistrationAlgorithmBase : public facet::PointSetRegistrationAlgorithmInterface { public: typedef PointSetRegistrationAlgorithmBase Self; typedef TMovingPointSet MovingPointSetType; typedef TTargetPointSet TargetPointSetType; typedef typename MovingPointSetType::ConstPointer MovingPointSetConstPointer; typedef typename TargetPointSetType::ConstPointer TargetPointSetConstPointer; /*! @brief gets a const pointer to the moving point set @eguarantee strong @return a const pointer to the moving point set */ virtual MovingPointSetConstPointer getMovingPointSet() const; /*! @brief gets a const pointer to the target point set @eguarantee strong @return a const pointer to the target point set */ virtual TargetPointSetConstPointer getTargetPointSet() const; /*! @brief sets the moving point set @eguarantee strong @param pMovingPointSet a pointer to the moving point set */ virtual void setMovingPointSet(const MovingPointSetType* pMovingPointSet); /*! @brief sets the target point set @eguarantee strong @param pTargetPointSet a pointer to the moving point set */ virtual void setTargetPointSet(const TargetPointSetType* pTargetPointSet); /*! returns the modification time of the target point set. */ - virtual unsigned long getTargetPointSetMTime() const; + virtual ::itk::ModifiedTimeType getTargetPointSetMTime() const; /*! returns the modification time of the moving point set. */ - virtual unsigned long getMovingPointSetMTime() const; + virtual ::itk::ModifiedTimeType getMovingPointSetMTime() const; protected: /*! @brief virtual destructor */ virtual ~PointSetRegistrationAlgorithmBase(); PointSetRegistrationAlgorithmBase(); /*! Methods invoked by derivated classes. */ virtual void PrintSelf(std::ostream& os, ::itk::Indent indent) const; private: ::map::core::ModificationTimeValidator _targetPSMTime; ::map::core::ModificationTimeValidator _movingPSMTime; MovingPointSetConstPointer _spMovingPointSet; TargetPointSetConstPointer _spTargetPointSet; //No copy constructor allowed PointSetRegistrationAlgorithmBase(const Self& source); void operator=(const Self&); //purposely not implemented }; } } #ifndef MatchPoint_MANUAL_TPP #include "mapPointSetRegistrationAlgorithmBase.tpp" #endif #endif diff --git a/Code/Algorithms/Common/include/mapPointSetRegistrationAlgorithmBase.tpp b/Code/Algorithms/Common/include/mapPointSetRegistrationAlgorithmBase.tpp index 20dfc7c..ce7eb00 100644 --- a/Code/Algorithms/Common/include/mapPointSetRegistrationAlgorithmBase.tpp +++ b/Code/Algorithms/Common/include/mapPointSetRegistrationAlgorithmBase.tpp @@ -1,108 +1,108 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __POINT_SET_REGISTRATION_ALGORITHM_INTERFACE_TPP #define __POINT_SET_REGISTRATION_ALGORITHM_INTERFACE_TPP namespace map { namespace algorithm { // **** public methods **** // ************************ template typename PointSetRegistrationAlgorithmBase::MovingPointSetConstPointer PointSetRegistrationAlgorithmBase:: getMovingPointSet() const { return _spMovingPointSet; } template typename PointSetRegistrationAlgorithmBase::TargetPointSetConstPointer PointSetRegistrationAlgorithmBase:: getTargetPointSet() const { return _spTargetPointSet; } template void PointSetRegistrationAlgorithmBase:: setMovingPointSet(const MovingPointSetType* pMovingPointSet) { _spMovingPointSet = pMovingPointSet; this->_movingPSMTime.setWatchedObject(pMovingPointSet); } template void PointSetRegistrationAlgorithmBase:: setTargetPointSet(const TargetPointSetType* pTargetPointSet) { _spTargetPointSet = pTargetPointSet; this->_targetPSMTime.setWatchedObject(pTargetPointSet); } template - unsigned long + ::itk::ModifiedTimeType map::algorithm::PointSetRegistrationAlgorithmBase::getMovingPointSetMTime() const { return _movingPSMTime.getMTime(); } template - unsigned long + ::itk::ModifiedTimeType map::algorithm::PointSetRegistrationAlgorithmBase::getTargetPointSetMTime() const { return _targetPSMTime.getMTime(); } // **** protected methods **** // *************************** template PointSetRegistrationAlgorithmBase:: ~PointSetRegistrationAlgorithmBase() {} template PointSetRegistrationAlgorithmBase:: PointSetRegistrationAlgorithmBase() {} template void PointSetRegistrationAlgorithmBase:: PrintSelf(std::ostream& os, ::itk::Indent indent) const { os << indent << "Moving point set: " << _spMovingPointSet.GetPointer() << std::endl; os << indent << "Target point set: " << _spTargetPointSet.GetPointer() << std::endl; } } // end namespace algorithms } // end namespace map #endif diff --git a/Code/Algorithms/Common/include/mapPointSetRegistrationAlgorithmInterface.h b/Code/Algorithms/Common/include/mapPointSetRegistrationAlgorithmInterface.h index 268f0d6..6dc54c6 100644 --- a/Code/Algorithms/Common/include/mapPointSetRegistrationAlgorithmInterface.h +++ b/Code/Algorithms/Common/include/mapPointSetRegistrationAlgorithmInterface.h @@ -1,109 +1,109 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __POINT_SET_REGISTRATION_ALGORITHM_INTERFACE_H #define __POINT_SET_REGISTRATION_ALGORITHM_INTERFACE_H #include "mapModificationTimeValidator.h" #include "itkIndent.h" /*! @namespace */ namespace map { namespace algorithm { namespace facet { /*! @class PointSetRegistrationAlgorithmInterface @brief This is the interface for point set based registration algorithms @ingroup AlgorithmFacets @template TMovingPointSet Type of the moving point set @template TTargetPointSet Type of the target point set */ template class PointSetRegistrationAlgorithmInterface { public: typedef PointSetRegistrationAlgorithmInterface Self; using MovingPointSetType = TMovingPointSet; using TargetPointSetType = TTargetPointSet; using MovingPointSetConstPointer = typename MovingPointSetType::ConstPointer; using TargetPointSetConstPointer = typename TargetPointSetType::ConstPointer; /*! @brief gets a const pointer to the moving point set @eguarantee strong @return a const pointer to the moving point set */ virtual MovingPointSetConstPointer getMovingPointSet() const = 0; /*! @brief gets a const pointer to the target point set @eguarantee strong @return a const pointer to the target point set */ virtual TargetPointSetConstPointer getTargetPointSet() const = 0; /*! @brief sets the moving point set @eguarantee strong @param pMovingPointSet a pointer to the moving point set */ virtual void setMovingPointSet(const MovingPointSetType* pMovingPointSet) = 0; /*! @brief sets the target point set @eguarantee strong @param pTargetPointSet a pointer to the moving point set */ virtual void setTargetPointSet(const TargetPointSetType* pTargetPointSet) = 0; /*! returns the modification time of the target point set. */ - virtual unsigned long getTargetPointSetMTime() const = 0; + virtual ::itk::ModifiedTimeType getTargetPointSetMTime() const = 0; /*! returns the modification time of the moving point set. */ - virtual unsigned long getMovingPointSetMTime() const = 0; + virtual ::itk::ModifiedTimeType getMovingPointSetMTime() const = 0; protected: /*! @brief virtual destructor */ virtual ~PointSetRegistrationAlgorithmInterface() {}; PointSetRegistrationAlgorithmInterface() {}; private: //No copy constructor allowed PointSetRegistrationAlgorithmInterface(const Self& source); void operator=(const Self&); //purposely not implemented }; } // namespace facet } // namespace algorithm } // namespace map #endif diff --git a/Code/Algorithms/Common/include/mapPointSetRegistrationAlgorithmInterfaceV2.h b/Code/Algorithms/Common/include/mapPointSetRegistrationAlgorithmInterfaceV2.h index 0816c16..06ae0fb 100644 --- a/Code/Algorithms/Common/include/mapPointSetRegistrationAlgorithmInterfaceV2.h +++ b/Code/Algorithms/Common/include/mapPointSetRegistrationAlgorithmInterfaceV2.h @@ -1,218 +1,218 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/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: 797 $ (last changed revision) // @date $Date: 2014-10-10 11:42:05 +0200 (Fr, 10 Okt 2014) $ (last change date) // @author $Author: floca $ (last changed by) // Subversion HeadURL: $HeadURL: https://svn.inet.dkfz-heidelberg.de/sbr/Sources/SBR-Projects/MatchPoint/trunk/Code/Algorithms/Common/include/mapPointSetRegistrationAlgorithmInterface.h $ */ #ifndef __POINT_SET_REGISTRATION_ALGORITHM_INTERFACE_V2_H #define __POINT_SET_REGISTRATION_ALGORITHM_INTERFACE_V2_H #include "mapPointSetRegistrationAlgorithmInterface.h" /*! @namespace */ namespace map { namespace algorithm { namespace facet { /*! @class PointSetRegistrationAlgorithmInterfaceV2 @brief This is the interface for point set based registration algorithms (Version 2) This version extents the first version by: 1. Allow define multiple inputs for the roles (moving / target) 2. posibility to query if the input slots are mandatory or just optional. The inputs are indexed (like itk filters) and the interface implies that all mandatory input slots of a role have lower indeces then optional slots of the same role. So e.g. given 4 mandatory moving input slots, by definition they will have the indeces 0..3. Optional slots will start with 4. An additional assumption is that PointSetRegistrationAlgorithmInterface accesses the first slots (slot index 0). According to this assumptions the methods of PointSetRegistrationAlgorithmInterface have a default implementation. @sa PointSetRegistrationAlgorithmInterface @ingroup AlgorithmFacets @template TMovingPointSet Type of the moving point set @template TTargetPointSet Type of the target point set */ template class PointSetRegistrationAlgorithmInterfaceV2 : public PointSetRegistrationAlgorithmInterface { public: typedef PointSetRegistrationAlgorithmInterfaceV2 Self; typedef PointSetRegistrationAlgorithmInterface Superclass; using MovingPointSetType = typename Superclass::MovingPointSetType; using TargetPointSetType = typename Superclass::TargetPointSetType; using MovingPointSetConstPointer = typename Superclass::MovingPointSetConstPointer; using TargetPointSetConstPointer = typename Superclass::TargetPointSetConstPointer; using SlotIndexType = unsigned int; itkTypeMacroNoParent(PointSetRegistrationAlgorithmInterfaceV2); /*! @brief gets a const pointer to the moving point set for the specified index @eguarantee strong @param index Index of the requested slot. @return a const pointer to the moving point set @pre If index is out of bound an exception will be thrown. */ MovingPointSetConstPointer getNthMovingPointSet(SlotIndexType index) const { if (index >= this->getMovingPointSetCount()) { mapDefaultExceptionMacro(<< "Error. Index of requested moving point set is out of bounds. Requested index: " << index << "; number of point sets: " << getMovingPointSetCount()); } return doGetNthMovingPointSet(index); }; /*! @brief gets a const pointer to the target point set for the specified index @eguarantee strong @param index Index of the requested slot. @return a const pointer to the target point set. If no data has been set for the index null ptr will be returned. @pre If index is out of bound an exception will be thrown. */ TargetPointSetConstPointer getNthTargetPointSet(SlotIndexType index) const { if (index >= this->getTargetPointSetCount()) { mapDefaultExceptionMacro(<< "Error. Index of requested target point set is out of bounds. Requested index: " << index << "; number of point sets: " << getTargetPointSetCount()); } return doGetNthTargetPointSet(index); }; /*! @brief sets the moving point set for a specified slot index @eguarantee strong @param pMovingPointSet a pointer to the moving point set @param index Index of the slot. @pre If index is out of bound an exception will be thrown. */ void setNthMovingPointSet(SlotIndexType index, const MovingPointSetType* pMovingPointSet) { if (index >= this->getMovingPointSetCount()) { mapDefaultExceptionMacro(<< "Error. Setter index of moving point set is out of bounds. Specified index: " << index << "; number of point set slots: " << getMovingPointSetCount()); } return doSetNthMovingPointSet(index, pMovingPointSet); }; /*! @brief sets the target point set for a specified slot index @eguarantee strong @param pTargetPointSet a pointer to the moving point set @param index Index of the slot. @pre If index is out of bound an exception will be thrown. */ void setNthTargetPointSet(SlotIndexType index, const TargetPointSetType* pTargetPointSet) { if (index >= this->getTargetPointSetCount()) { mapDefaultExceptionMacro(<< "Error. Setter index of target point set is out of bounds. Specified index: " << index << "; number of point set slots: " << getTargetPointSetCount()); } return doSetNthTargetPointSet(index, pTargetPointSet); }; /*! Indicates if the target and input data of one index are coupled or not. Coupled means that if the index for one role (target or moving) is set, the other role at this index must also be set. @return True if coupled. False if not. @eguarantee strong*/ virtual bool hasCoupledPointSetInputs() const { return true; }; /*! Indicates if the passed index indicates a mandatory (false) or an optional (true) input.*/ virtual bool isOptionalTargetPointSet(SlotIndexType index) const { return false; }; /*! Indicates if the passed index indicates a mandatory (false) or an optional (true) input.*/ virtual bool isOptionalMovingPointSet(SlotIndexType index) const { return false; }; /*! Gets the number of target inputs (in total: onlyMandatory == false) @eguarantee strong */ virtual SlotIndexType getTargetPointSetCount(bool onlyMandatory = false) const { return 1; }; /*! Gets the number of moving inputs (in total: onlyMandatory == false) @eguarantee strong */ virtual SlotIndexType getMovingPointSetCount(bool onlyMandatory = false) const { return 1; }; /*! returns the modification time of the target point set. */ - virtual unsigned long getNthTargetPointSetMTime(SlotIndexType index) const = 0; + virtual ::itk::ModifiedTimeType getNthTargetPointSetMTime(SlotIndexType index) const = 0; /*! returns the modification time of the moving point set. */ - virtual unsigned long getNthMovingPointSetMTime(SlotIndexType index) const = 0; + virtual ::itk::ModifiedTimeType getNthMovingPointSetMTime(SlotIndexType index) const = 0; MovingPointSetConstPointer getMovingPointSet() const override { return getNthMovingPointSet(0); }; TargetPointSetConstPointer getTargetPointSet() const override { return getNthTargetPointSet(0); } void setMovingPointSet(const MovingPointSetType* pMovingPointSet) override { setNthMovingPointSet(0, pMovingPointSet); }; void setTargetPointSet(const TargetPointSetType* pTargetPointSet) override { setNthTargetPointSet(0, pTargetPointSet); }; - unsigned long getTargetPointSetMTime() const override + ::itk::ModifiedTimeType getTargetPointSetMTime() const override { return getNthTargetPointSetMTime(0); }; - unsigned long getMovingPointSetMTime() const override + ::itk::ModifiedTimeType getMovingPointSetMTime() const override { return getNthMovingPointSetMTime(0); }; protected: /*! @brief virtual destructor */ ~PointSetRegistrationAlgorithmInterfaceV2() override {}; PointSetRegistrationAlgorithmInterfaceV2() {}; virtual MovingPointSetConstPointer doGetNthMovingPointSet(SlotIndexType index) const = 0; virtual TargetPointSetConstPointer doGetNthTargetPointSet(SlotIndexType index) const = 0; virtual void doSetNthMovingPointSet(SlotIndexType index, const MovingPointSetType* pMovingPointSet) = 0; virtual void doSetNthTargetPointSet(SlotIndexType index, const TargetPointSetType* pTargetPointSet) = 0; private: //No copy constructor allowed PointSetRegistrationAlgorithmInterfaceV2(const Self& source); void operator=(const Self&); //purposely not implemented }; } // namespace facet } // namespace algorithm } // namespace map #endif diff --git a/Code/Algorithms/Common/include/mapSealedImagePyramidesPolicy.h b/Code/Algorithms/Common/include/mapSealedImagePyramidesPolicy.h index ef479b1..1b1550d 100644 --- a/Code/Algorithms/Common/include/mapSealedImagePyramidesPolicy.h +++ b/Code/Algorithms/Common/include/mapSealedImagePyramidesPolicy.h @@ -1,189 +1,189 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __SEALED_IMAGE_PYRAMIDES_POLICY_H #define __SEALED_IMAGE_PYRAMIDES_POLICY_H #include "itkMultiResolutionPyramidImageFilter.h" #include "itkCommand.h" #include "mapNoComponentInitializationPolicy.h" #include "mapModificationTimeValidator.h" namespace map { namespace algorithm { /*! @class SealedImagePyramidesPolicy @brief class for SealedImagePyramidesPolicy. This class is a SealedImagePyramidesPolicy. It is used if an ITKImageRegistrationAlgorithm should have one specific pyramide type. With this policy the pyramide is never to be changed and sealed, so that the instance and its setting aren't public. @sa FixedImagePyramidesPolicy @sa ArbitraryImagePyramidesPolicy @ingroup ITKPolicies */ template class SealedImagePyramidesPolicy { public: typedef SealedImagePyramidesPolicy Self; using ConcreteMovingImagePyramideType = TConcreteMovingImagePyramide; using ConcreteMovingImagePyramidePointer = typename ConcreteMovingImagePyramideType::Pointer; typedef ::itk::MultiResolutionPyramidImageFilter MovingImagePyramideBaseType; using ConcreteTargetImagePyramideType = TConcreteTargetImagePyramide; using ConcreteTargetImagePyramidePointer = typename ConcreteTargetImagePyramideType::Pointer; typedef ::itk::MultiResolutionPyramidImageFilter TargetImagePyramideBaseType; using TargetImagePyramideBasePointer = typename TargetImagePyramideBaseType::Pointer; using TargetImagePyramidConstPointer = typename TargetImagePyramideBaseType::ConstPointer; using MovingImagePyramideBasePointer = typename MovingImagePyramideBaseType::Pointer; using MovingImagePyramidConstPointer = typename MovingImagePyramideBaseType::ConstPointer; using MovingImageType = typename TConcreteMovingImagePyramide::InputImageType; using TargetImageType = typename TConcreteTargetImagePyramide::InputImageType; using InitializationPolicy = TInitializationPolicy; protected: SealedImagePyramidesPolicy(); ~SealedImagePyramidesPolicy(); /*! Returns the modification time of the policy (and its controlled component). * In this case the modification time is a pass through of the internal component. @eguarantee strong @return the modification time */ - virtual unsigned long getMovingPyramideMTime() const; + virtual ::itk::ModifiedTimeType getMovingPyramideMTime() const; /*! Returns the modification time of the policy (and its controlled component). * In this case the modification time is a pass through of the internal component. @eguarantee strong @return the modification time */ - virtual unsigned long getTargetPyramideMTime() const; + virtual ::itk::ModifiedTimeType getTargetPyramideMTime() const; /*! This is a command slot that can be used by any class derivering from this policy * to get informed if the moving pyramide instances is changed. \n * Two events will be invoked with this command: \n * - UnregisterAlgorithmComponentEvent * - RegisterAlgorithmComponentEvent * . * The first one is used when the current pyramide is going to be replaced (by setMovingImagePyramide). The event data in this case * is a void pointer to the current (soon outdated) object. The second event will be called when the new image pyramide was set * (by setMovingImagePyramide). In this case the event data is a pointer to the new pyramide.*/ ::itk::Command::Pointer _spOnChangeMoving; /*! This is a command slot that can be used by any class derivering from this policy * to get informed if the target pyramide instances is changed. \n * Two events will be invoked with this command: \n * - UnregisterAlgorithmComponentEvent * - RegisterAlgorithmComponentEvent * . * The first one is used when the current pyramide is going to be replaced (by setTargetImagePyramide). The event data in this case * is a void pointer to the current (soon outdated) object. The second event will be called when the new image pyramide was set * (by setTargetImagePyramide). In this case the event data is a pointer to the new pyramide.*/ ::itk::Command::Pointer _spOnChangeTarget; /*! gets the internal pyramides @eguarantee strong @return a pointer to an pyramide type */ MovingImagePyramideBaseType* getMovingPyramideInternal(); const MovingImagePyramideBaseType* getMovingPyramideInternal() const; TargetImagePyramideBaseType* getTargetPyramideInternal(); const TargetImagePyramideBaseType* getTargetPyramideInternal() const; /*! gets the concrete moving pyramide @eguarantee strong @return a pointer to a ConcreteMovingImagePyramideType object */ const ConcreteMovingImagePyramideType* getConcreteMovingPyramide() const; /*! gets the concrete target pyramide @eguarantee strong @return a pointer to a ConcreteTargetImagePyramideType object */ const ConcreteTargetImagePyramideType* getConcreteTargetPyramide() const; /*! gets the concrete moving pyramide @eguarantee strong @return a pointer to a ConcreteMovingImagePyramideType object */ ConcreteMovingImagePyramideType* getConcreteMovingPyramide(); /*! gets the concrete target pyramide @eguarantee strong @return a pointer to a ConcreteTargetImagePyramideType object */ ConcreteTargetImagePyramideType* getConcreteTargetPyramide(); /*! initializes the pyramides @eguarantee strong */ virtual void preparePyramides(); /*! initializes the pyramides * after it was integrated in a controlling structur (e.g. registration algorithm) @eguarantee strong */ virtual void preparePyramidesAfterAssembly(); private: ::map::core::ModificationTimeValidator _movingPyramideMTime; ::map::core::ModificationTimeValidator _targetPyramideMTime; /*! The time stamp is used to signal changes of the policy that may effect the controlling structur (e.g. registration algorithm) * because the controlled object has changed.*/ ConcreteMovingImagePyramidePointer _spMovingPyramide; /*! The time stamp is used to signal changes of the policy that may effect the controlling structur (e.g. registration algorithm) * because the controlled object has changed.*/ ConcreteMovingImagePyramidePointer _spTargetPyramide; //No copy constructor allowed SealedImagePyramidesPolicy(const Self& source); void operator=(const Self&); //purposely not implemented }; } // namespace algorithm } // namespace map #ifndef MatchPoint_MANUAL_TPP #include "mapSealedImagePyramidesPolicy.tpp" #endif #endif diff --git a/Code/Algorithms/Common/include/mapSealedImagePyramidesPolicy.tpp b/Code/Algorithms/Common/include/mapSealedImagePyramidesPolicy.tpp index f717e7c..65ac300 100644 --- a/Code/Algorithms/Common/include/mapSealedImagePyramidesPolicy.tpp +++ b/Code/Algorithms/Common/include/mapSealedImagePyramidesPolicy.tpp @@ -1,163 +1,163 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __SEALED_IMAGE_PYRAMIDES_POLICY_TPP #define __SEALED_IMAGE_PYRAMIDES_POLICY_TPP namespace map { namespace algorithm { template typename SealedImagePyramidesPolicy::ConcreteMovingImagePyramideType* SealedImagePyramidesPolicy:: getConcreteMovingPyramide() { return _spMovingPyramide; }; template const typename SealedImagePyramidesPolicy::ConcreteMovingImagePyramideType* SealedImagePyramidesPolicy:: getConcreteMovingPyramide() const { return _spMovingPyramide; }; template typename SealedImagePyramidesPolicy::ConcreteTargetImagePyramideType* SealedImagePyramidesPolicy:: getConcreteTargetPyramide() { return _spTargetPyramide; }; template const typename SealedImagePyramidesPolicy::ConcreteTargetImagePyramideType* SealedImagePyramidesPolicy:: getConcreteTargetPyramide() const { return _spTargetPyramide; }; template SealedImagePyramidesPolicy:: SealedImagePyramidesPolicy() { _spTargetPyramide = ConcreteTargetImagePyramideType::New(); _spMovingPyramide = ConcreteMovingImagePyramideType::New(); InitializationPolicy::initialize(_spTargetPyramide.GetPointer()); InitializationPolicy::initialize(_spMovingPyramide.GetPointer()); }; template SealedImagePyramidesPolicy:: ~SealedImagePyramidesPolicy() { }; template typename SealedImagePyramidesPolicy::MovingImagePyramideBaseType* SealedImagePyramidesPolicy:: getMovingPyramideInternal() { return _spMovingPyramide; }; template const typename SealedImagePyramidesPolicy::MovingImagePyramideBaseType* SealedImagePyramidesPolicy:: getMovingPyramideInternal() const { return _spMovingPyramide; }; template typename SealedImagePyramidesPolicy::TargetImagePyramideBaseType* SealedImagePyramidesPolicy:: getTargetPyramideInternal() { return _spTargetPyramide; }; template const typename SealedImagePyramidesPolicy::TargetImagePyramideBaseType* SealedImagePyramidesPolicy:: getTargetPyramideInternal() const { return _spTargetPyramide; }; template void SealedImagePyramidesPolicy:: preparePyramides() { //default implementation does nothing; }; template void SealedImagePyramidesPolicy:: preparePyramidesAfterAssembly() { //default implementation does nothing; }; template - unsigned long + ::itk::ModifiedTimeType SealedImagePyramidesPolicy:: getTargetPyramideMTime() const { - unsigned long mt = _targetPyramideMTime.getMTime(); + auto mt = _targetPyramideMTime.getMTime(); return mt; }; template - unsigned long + ::itk::ModifiedTimeType SealedImagePyramidesPolicy:: getMovingPyramideMTime() const { - unsigned long mt = _movingPyramideMTime.getMTime(); + auto mt = _movingPyramideMTime.getMTime(); return mt; }; } // end namespace algorithm } // end namespace map #endif diff --git a/Code/Algorithms/Common/source/mapMetaPropertyAlgorithmBase.cpp b/Code/Algorithms/Common/source/mapMetaPropertyAlgorithmBase.cpp index f16bd04..74bbe2b 100644 --- a/Code/Algorithms/Common/source/mapMetaPropertyAlgorithmBase.cpp +++ b/Code/Algorithms/Common/source/mapMetaPropertyAlgorithmBase.cpp @@ -1,229 +1,229 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #include "mapMetaPropertyAlgorithmBase.h" namespace map { namespace algorithm { MetaPropertyInfo::Pointer MetaPropertyAlgorithmBase:: getPropertyInfo(const MetaPropertyNameType& name) const { MetaPropertyVectorType infos = getPropertyInfos(); auto pos = infos.begin(); MetaPropertyInfo::Pointer spResult = nullptr; for (pos = infos.begin(); pos != infos.end(); ++pos) { if ((*pos)->getName() == name) { spResult = *pos; break; } } return spResult; }; MetaPropertyAlgorithmBase::MetaPropertyVectorType MetaPropertyAlgorithmBase:: getPropertyInfos() const { MetaPropertyVectorType infos; compileInfos(infos); return infos; }; MetaPropertyAlgorithmBase::MetaPropertyPointer MetaPropertyAlgorithmBase:: getProperty(const MetaPropertyNameType& name) const { MetaPropertyPointer spResult = nullptr; MetaPropertyInfo::Pointer spInfo = getPropertyInfo(name); if (spInfo.IsNotNull()) { if (spInfo->isReadable()) { //check cache auto pos = _metaPropertyCache.find(name); if (pos != _metaPropertyCache.end()) { //get from cache mapLogDebugObjMacro("Get property from cache. Property: " << pos->first); spResult = pos->second; } else { //retrieve directly mapLogDebugObjMacro("Get property from internal instance. Property: " << name); spResult = doGetProperty(name); } } } return spResult; }; MetaPropertyAlgorithmBase::MetaPropertyPointer MetaPropertyAlgorithmBase:: getProperty(const MetaPropertyInfo* pInfo) const { MetaPropertyPointer spResult = nullptr; if (pInfo == nullptr) { mapDefaultExceptionStaticMacro( << "Error while getting property. Passed property info is NULL."); } spResult = getProperty(pInfo->getName()); if (spResult.IsNotNull()) { if (!(spResult->getMetaPropertyTypeInfo() == pInfo->getTypeInfo())) { mapDefaultExceptionStaticMacro( << "Error while getting property. Property value type differs from specified type in the property info. value type: " << spResult->getMetaPropertyTypeInfo().name() << "; info type: " << pInfo->getTypeInfo().name()); } } return spResult; }; bool MetaPropertyAlgorithmBase:: setProperty(const MetaPropertyNameType& name, const MetaPropertyType* pProperty) { bool result = false; if (pProperty == nullptr) { mapDefaultExceptionStaticMacro( << "Error while setting property. Passed property pointer is NULL. Property name: " << name); } MetaPropertyInfo::Pointer spInfo = getPropertyInfo(name); if (spInfo.IsNotNull()) { if (!(pProperty->getMetaPropertyTypeInfo() == spInfo->getTypeInfo())) { mapDefaultExceptionStaticMacro("Error while setting property. Property value type differs from type specified by the algorithm. value type: " << pProperty->getMetaPropertyTypeInfo().name() << "; internal type: " << spInfo->getTypeInfo().name()); } if (spInfo->isWritable()) { result = true; _metaPropertyCache[name] = pProperty->Clone(); _cacheMTime.Modified(); } } return result; }; bool MetaPropertyAlgorithmBase:: setProperty(const MetaPropertyInfo* pInfo, const MetaPropertyType* pProperty) { bool result = false; if (pInfo == nullptr) { mapDefaultExceptionStaticMacro( << "Error while setting property. Passed property info is NULL."); } if (pProperty == nullptr) { mapDefaultExceptionStaticMacro( << "Error while setting property. Passed property pointer is NULL. Property name: " << pInfo->getName()); } if (!(pProperty->getMetaPropertyTypeInfo() == pInfo->getTypeInfo())) { mapDefaultExceptionStaticMacro("Error while setting property. Property value type differs from specified type in the property info. value type: " << pProperty->getMetaPropertyTypeInfo().name() << "; info type: " << pInfo->getTypeInfo().name()); } result = setProperty(pInfo->getName(), pProperty); return result; }; void MetaPropertyAlgorithmBase:: configureAlgorithmByMetaProperties() { for (auto pos = _metaPropertyCache.begin(); pos != _metaPropertyCache.end(); ++pos) { mapLogDebugObjMacro("Set property: " << pos->first); doSetProperty(pos->first, pos->second); } }; void MetaPropertyAlgorithmBase:: resetMetaPropertyCache() { _metaPropertyCache.clear(); _cacheMTime.Modified(); }; - unsigned long + ::itk::ModifiedTimeType MetaPropertyAlgorithmBase:: GetMTime() const { return _cacheMTime.GetMTime(); }; MetaPropertyAlgorithmBase:: MetaPropertyAlgorithmBase() = default; MetaPropertyAlgorithmBase:: ~MetaPropertyAlgorithmBase() = default; } // namespace algorithm } // namespace map diff --git a/Code/Algorithms/Common/test/mapMaskedRegistrationAlgorithmBaseTest.cpp b/Code/Algorithms/Common/test/mapMaskedRegistrationAlgorithmBaseTest.cpp index 640db9a..4858c9c 100644 --- a/Code/Algorithms/Common/test/mapMaskedRegistrationAlgorithmBaseTest.cpp +++ b/Code/Algorithms/Common/test/mapMaskedRegistrationAlgorithmBaseTest.cpp @@ -1,102 +1,102 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #if defined(_MSC_VER) #pragma warning ( disable : 4786 ) #endif #include "litCheckMacros.h" #include "mapDiscreteElements.h" #include "mapMaskedRegistrationAlgorithmBase.h" #include "itkBoxSpatialObject.h" namespace map { namespace testing { namespace { template class TestMaskedRegistrationAlgorithmBase : public ::map::algorithm::MaskedRegistrationAlgorithmBase { public: TestMaskedRegistrationAlgorithmBase() {}; using algorithm::MaskedRegistrationAlgorithmBase::getTargetMaskMTime; using algorithm::MaskedRegistrationAlgorithmBase::getMovingMaskMTime; }; } int mapMaskedRegistrationAlgorithmBaseTest(int, char* []) { PREPARE_DEFAULT_TEST_REPORTING; typedef ::itk::BoxSpatialObject<2> Mask2DType; typedef ::itk::BoxSpatialObject<3> Mask3DType; TestMaskedRegistrationAlgorithmBase<2, 3> testInterface; Mask2DType::Pointer spMovingMask = Mask2DType::New(); Mask3DType::Pointer spTargetMask = Mask3DType::New(); const TestMaskedRegistrationAlgorithmBase<2, 3>::MovingMaskBaseType* pMovingBase = spMovingMask; const TestMaskedRegistrationAlgorithmBase<2, 3>::TargetMaskBaseType* pTargetBase = spTargetMask; CHECK_EQUAL(true, testInterface.getMovingMask().IsNull()); CHECK_EQUAL(true, testInterface.getTargetMask().IsNull()); - unsigned long mmt = testInterface.getMovingMaskMTime(); - unsigned long tmt = testInterface.getTargetMaskMTime(); + auto mmt = testInterface.getMovingMaskMTime(); + auto tmt = testInterface.getTargetMaskMTime(); testInterface.setMovingMask(spMovingMask); CHECK(mmt < testInterface.getMovingMaskMTime()); CHECK(tmt == testInterface.getTargetMaskMTime()); mmt = testInterface.getMovingMaskMTime(); testInterface.setTargetMask(spTargetMask); CHECK(mmt == testInterface.getMovingMaskMTime()); CHECK(tmt < testInterface.getTargetMaskMTime()); tmt = testInterface.getTargetMaskMTime(); spMovingMask->Modified(); CHECK(mmt < testInterface.getMovingMaskMTime()); CHECK(tmt == testInterface.getTargetMaskMTime()); mmt = testInterface.getMovingMaskMTime(); spTargetMask->Modified(); CHECK(mmt == testInterface.getMovingMaskMTime()); CHECK(tmt < testInterface.getTargetMaskMTime()); CHECK_EQUAL(pMovingBase, testInterface.getMovingMask().GetPointer()); CHECK_EQUAL(pTargetBase, testInterface.getTargetMask().GetPointer()); RETURN_AND_REPORT_TEST_SUCCESS; } } //namespace testing } //namespace map diff --git a/Code/Algorithms/Common/test/mapMetaPropertyAlgorithmBaseTest.cpp b/Code/Algorithms/Common/test/mapMetaPropertyAlgorithmBaseTest.cpp index 76aa3f5..38f2cff 100644 --- a/Code/Algorithms/Common/test/mapMetaPropertyAlgorithmBaseTest.cpp +++ b/Code/Algorithms/Common/test/mapMetaPropertyAlgorithmBaseTest.cpp @@ -1,265 +1,265 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #if defined(_MSC_VER) #pragma warning ( disable : 4786 ) #endif #include "litCheckMacros.h" #include "mapMetaProperty.h" #include "mapMetaPropertyAccessor.h" #include "mapTestMetaPropertyAlgorithm.h" namespace map { namespace testing { int mapMetaPropertyAlgorithmBaseTest(int, char* []) { PREPARE_DEFAULT_TEST_REPORTING; typedef TestMetaPropertyAlgorithm TestInterfaceType; TestInterfaceType testInterface; ////////////////////////////////////// //Test property info generation TestInterfaceType::MetaPropertyVectorType infos = testInterface.getPropertyInfos(); CHECK_EQUAL(5, infos.size()); CHECK_EQUAL(1, testInterface.recorder.getRecordValueCount(TestInterfaceType::compileInfosID)); ::map::algorithm::MetaPropertyInfo::Pointer spCountInfo; CHECK_NO_THROW(spCountInfo = testInterface.getPropertyInfo("Count")); CHECK(spCountInfo.IsNotNull()); CHECK("Count" == spCountInfo->getName()); //just ensure that it is realy the right info, correct setting //and getting of info attributes is tested in MetaPropertInfoTest //now the compile methods must have been executed 2 times CHECK_EQUAL(2, testInterface.recorder.getRecordValueCount(TestInterfaceType::compileInfosID)); ::map::algorithm::MetaPropertyInfo::Pointer spSecretInfo; CHECK_NO_THROW(spSecretInfo = testInterface.getPropertyInfo("SecretIngredient")); CHECK(spSecretInfo.IsNotNull()); CHECK("SecretIngredient" == spSecretInfo->getName()); ::map::algorithm::MetaPropertyInfo::Pointer spUnkownInfo; CHECK_NO_THROW(spUnkownInfo = testInterface.getPropertyInfo("UnkownProperty")); CHECK(spUnkownInfo.IsNull()); ////////////////////////////////////// //Test getProperty functions testInterface.recorder.resetRecorder(); //test overloaded version: string TestInterfaceType::MetaPropertyPointer spSize; TestInterfaceType::MetaPropertyPointer spSecret; CHECK_NO_THROW(spSize = testInterface.getProperty("Size")); CHECK(spSize.IsNotNull()); CHECK_EQUAL(1, testInterface.recorder.getRecordValueCount(TestInterfaceType::compileInfosID)); CHECK_EQUAL(1, testInterface.recorder.getRecordValueCount(TestInterfaceType::doGetPropertyID)); int testInt = 0; CHECK(::map::core::unwrapMetaProperty(spSize, testInt)); CHECK_EQUAL(testInterface._size, testInt); //check behaviour in case of nonreadable property TestInterfaceType::MetaPropertyPointer spHole; CHECK_NO_THROW(spHole = testInterface.getProperty("BlackHole")); CHECK(spHole.IsNull()); CHECK_EQUAL(2, testInterface.recorder.getRecordValueCount(TestInterfaceType::compileInfosID)); CHECK_EQUAL(1, testInterface.recorder.getRecordValueCount(TestInterfaceType::doGetPropertyID)); //check behaviour in case of unkown property TestInterfaceType::MetaPropertyPointer spUnkown; CHECK_NO_THROW(spUnkown = testInterface.getProperty("UnkownProperty")); CHECK(spUnkown.IsNull()); CHECK_EQUAL(3, testInterface.recorder.getRecordValueCount(TestInterfaceType::compileInfosID)); CHECK_EQUAL(1, testInterface.recorder.getRecordValueCount(TestInterfaceType::doGetPropertyID)); //check behaviour in case of protected property CHECK_NO_THROW(spSecret = testInterface.getProperty("SecretIngredient")); CHECK(spSecret.IsNotNull()); CHECK_EQUAL(4, testInterface.recorder.getRecordValueCount(TestInterfaceType::compileInfosID)); CHECK_EQUAL(2, testInterface.recorder.getRecordValueCount(TestInterfaceType::doGetPropertyID)); float testfloat = 0.0; CHECK(::map::core::unwrapMetaProperty(spSecret, testfloat)); CHECK_EQUAL(testInterface._secret, testfloat); //test overloaded version: MetaPropertyInfo testInterface.recorder.resetRecorder(); ::map::algorithm::MetaPropertyInfo::Pointer spHoleInfo = algorithm::MetaPropertyInfo::New("BlackHole", typeid(void*), false, true); spUnkownInfo = algorithm::MetaPropertyInfo::New("UnkownProperty", typeid(int)); ::map::algorithm::MetaPropertyInfo::Pointer spIllegalSizeInfo = algorithm::MetaPropertyInfo::New("Size", typeid(void*), true, true); TestInterfaceType::MetaPropertyPointer spCount; CHECK_NO_THROW(spCount = testInterface.getProperty(spCountInfo)); CHECK(spCount.IsNotNull()); CHECK_EQUAL(1, testInterface.recorder.getRecordValueCount(TestInterfaceType::compileInfosID)); CHECK_EQUAL(1, testInterface.recorder.getRecordValueCount(TestInterfaceType::doGetPropertyID)); CHECK(::map::core::unwrapMetaProperty(spCount, testInt)); CHECK_EQUAL(testInterface._count, testInt); //check behaviour in case of nonreadable property spHole = NULL; CHECK_NO_THROW(spHole = testInterface.getProperty(spHoleInfo)); CHECK(spHole.IsNull()); CHECK_EQUAL(2, testInterface.recorder.getRecordValueCount(TestInterfaceType::compileInfosID)); CHECK_EQUAL(1, testInterface.recorder.getRecordValueCount(TestInterfaceType::doGetPropertyID)); //check behaviour in case of unkown property spUnkown = NULL; CHECK_NO_THROW(spUnkown = testInterface.getProperty(spUnkownInfo)); CHECK(spUnkown.IsNull()); CHECK_EQUAL(3, testInterface.recorder.getRecordValueCount(TestInterfaceType::compileInfosID)); CHECK_EQUAL(1, testInterface.recorder.getRecordValueCount(TestInterfaceType::doGetPropertyID)); //check behaviour in case of illegal property spUnkown = NULL; CHECK_THROW_EXPLICIT(spUnkown = testInterface.getProperty(spIllegalSizeInfo), core::ExceptionObject); //check behaviour in case of illegal property pointer CHECK_THROW_EXPLICIT(spUnkown = testInterface.getProperty(NULL), core::ExceptionObject); ////////////////////////////////////// //Test setProperty functions including cache testInterface.recorder.resetRecorder(); //test overloaded version: string testInterface._size = 0; - unsigned long refTime = testInterface.GetMTime(); + auto refTime = testInterface.GetMTime(); CHECK(testInterface.setProperty("Size", spSize)); CHECK_EQUAL(1, testInterface.recorder.getRecordValueCount(TestInterfaceType::compileInfosID)); CHECK_EQUAL(0, testInterface.recorder.getRecordValueCount(TestInterfaceType::doSetPropertyID)); CHECK_EQUAL(0, testInterface._size); //it is not changed because it is currently stored in the cache CHECK(refTime < testInterface.GetMTime()); refTime = testInterface.GetMTime(); TestInterfaceType::MetaPropertyPointer spCachedSize; int testCachedInt = 0; CHECK_NO_THROW(spCachedSize = testInterface.getProperty("Size")); CHECK(::map::core::unwrapMetaProperty(spSize, testInt)); CHECK(::map::core::unwrapMetaProperty(spCachedSize, testCachedInt)); CHECK_EQUAL(testInt, testCachedInt); testInterface.configureAlgorithmByMetaProperties(); //now transfer values CHECK_EQUAL(1, testInterface.recorder.getRecordValueCount(TestInterfaceType::doSetPropertyID)); CHECK_EQUAL(testCachedInt, testInterface._size); //check behavior in case of nonwritable property CHECK(!testInterface.setProperty("Count", spCount)); CHECK_EQUAL(3, testInterface.recorder.getRecordValueCount(TestInterfaceType::compileInfosID)); CHECK_EQUAL(1, testInterface.recorder.getRecordValueCount(TestInterfaceType::doSetPropertyID)); CHECK_EQUAL(refTime, testInterface.GetMTime()); //check behavior in case of unknown property CHECK(!testInterface.setProperty("UnkownProperty", spCount)); CHECK_EQUAL(4, testInterface.recorder.getRecordValueCount(TestInterfaceType::compileInfosID)); CHECK_EQUAL(1, testInterface.recorder.getRecordValueCount(TestInterfaceType::doSetPropertyID)); CHECK_EQUAL(refTime, testInterface.GetMTime()); //check behavior in case of illegal property pointer CHECK_THROW_EXPLICIT(testInterface.setProperty("IllegalProperty", NULL), core::ExceptionObject); CHECK_EQUAL(4, testInterface.recorder.getRecordValueCount(TestInterfaceType::compileInfosID)); CHECK_EQUAL(1, testInterface.recorder.getRecordValueCount(TestInterfaceType::doSetPropertyID)); CHECK_EQUAL(refTime, testInterface.GetMTime()); //check behavior in case of property pointer with wrong type ::map::core::MetaPropertyBase::Pointer spWrongTypedValue = core::MetaProperty::New( false).GetPointer(); CHECK_THROW_EXPLICIT(testInterface.setProperty("Size", spWrongTypedValue), core::ExceptionObject); CHECK_EQUAL(5, testInterface.recorder.getRecordValueCount(TestInterfaceType::compileInfosID)); CHECK_EQUAL(1, testInterface.recorder.getRecordValueCount(TestInterfaceType::doSetPropertyID)); CHECK_EQUAL(refTime, testInterface.GetMTime()); //test overloaded version: MetaPropertyInfo ::map::algorithm::MetaPropertyInfo::Pointer spSizeInfo = algorithm::MetaPropertyInfo::New("Size", typeid(int), true, true); spSize = core::MetaProperty::New(21); CHECK(testInterface.setProperty(spSizeInfo, spSize)); CHECK_EQUAL(6, testInterface.recorder.getRecordValueCount(TestInterfaceType::compileInfosID)); CHECK_EQUAL(1, testInterface.recorder.getRecordValueCount(TestInterfaceType::doSetPropertyID)); CHECK(refTime < testInterface.GetMTime()); refTime = testInterface.GetMTime(); CHECK_EQUAL(testInt, testInterface._size); //it is not changed because it is currently stored in the cache CHECK_NO_THROW(spCachedSize = testInterface.getProperty("Size")); CHECK(::map::core::unwrapMetaProperty(spCachedSize, testCachedInt)); CHECK_EQUAL(21, testCachedInt); testInterface.configureAlgorithmByMetaProperties(); //now transfer values CHECK_EQUAL(2, testInterface.recorder.getRecordValueCount(TestInterfaceType::doSetPropertyID)); CHECK_EQUAL(testCachedInt, testInterface._size); //check behaviour in case of nonwritable property CHECK(!testInterface.setProperty(spCountInfo, spCount)); CHECK_EQUAL(8, testInterface.recorder.getRecordValueCount(TestInterfaceType::compileInfosID)); CHECK_EQUAL(2, testInterface.recorder.getRecordValueCount(TestInterfaceType::doSetPropertyID)); CHECK_EQUAL(refTime, testInterface.GetMTime()); //check behaviour in case of unkown property CHECK(!testInterface.setProperty(spUnkownInfo, spCount)); CHECK_EQUAL(9, testInterface.recorder.getRecordValueCount(TestInterfaceType::compileInfosID)); CHECK_EQUAL(2, testInterface.recorder.getRecordValueCount(TestInterfaceType::doSetPropertyID)); CHECK_EQUAL(refTime, testInterface.GetMTime()); //check behaviour in case of inconsistent property/propertyinfo CHECK_THROW_EXPLICIT(testInterface.setProperty(spIllegalSizeInfo, spSize), core::ExceptionObject); //check behaviour in case of illegal property pointer CHECK_THROW_EXPLICIT(testInterface.setProperty(spSizeInfo, NULL), core::ExceptionObject); CHECK_THROW_EXPLICIT(testInterface.setProperty(NULL, spSize), core::ExceptionObject); CHECK_EQUAL(9, testInterface.recorder.getRecordValueCount(TestInterfaceType::compileInfosID)); CHECK_EQUAL(2, testInterface.recorder.getRecordValueCount(TestInterfaceType::doSetPropertyID)); CHECK_EQUAL(refTime, testInterface.GetMTime()); RETURN_AND_REPORT_TEST_SUCCESS; } } //namespace testing } //namespace map diff --git a/Code/Algorithms/Common/test/mapMultiResImagedRegistrationAlgorithmInterfaceTest.cpp b/Code/Algorithms/Common/test/mapMultiResImagedRegistrationAlgorithmInterfaceTest.cpp index f7bb58d..ab99a50 100644 --- a/Code/Algorithms/Common/test/mapMultiResImagedRegistrationAlgorithmInterfaceTest.cpp +++ b/Code/Algorithms/Common/test/mapMultiResImagedRegistrationAlgorithmInterfaceTest.cpp @@ -1,142 +1,142 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #if defined(_MSC_VER) #pragma warning ( disable : 4786 ) #endif #include "litCheckMacros.h" #include "mapDiscreteElements.h" #include "mapMultiResImageRegistrationAlgorithmBase.h" #include "mapArbitraryImagePyramidesPolicy.h" #include "itkBoxSpatialObject.h" namespace map { namespace testing { namespace { template class TestMultiResRegistrationAlgorithmBase : public ::map::algorithm::MultiResImageRegistrationAlgorithmBase > { public: TestMultiResRegistrationAlgorithmBase() { _hasLevelCount = false; _doGetCurrentLevelCount = 0; }; using algorithm::MultiResImageRegistrationAlgorithmBase >::getTargetPyramideMTime; using algorithm::MultiResImageRegistrationAlgorithmBase >::getMovingPyramideMTime; typedef algorithm::MultiResImageRegistrationAlgorithmBase > Superclass; bool _hasLevelCount; mutable unsigned int _doGetCurrentLevelCount; virtual bool hasLevelCount() const { return _hasLevelCount; }; virtual typename Superclass::ResolutionLevelCountType doGetCurrentLevel() const { ++_doGetCurrentLevelCount; return 42; }; void onMovingImagePyramideChange(const itk::EventObject&) {}; void onTargetImagePyramideChange(const itk::EventObject&) {}; }; } int mapMultiResImageRegistrationAlgorithmBaseTest(int, char* []) { PREPARE_DEFAULT_TEST_REPORTING; typedef core::discrete::Elements<3>::InternalImageType ImageType; typedef core::discrete::Elements<2>::InternalImageType Image2Type; typedef ::itk::MultiResolutionPyramidImageFilter Pyramide1Type; typedef ::itk::MultiResolutionPyramidImageFilter Pyramide2Type; Pyramide1Type::Pointer spPyramide1 = Pyramide1Type::New(); Pyramide2Type::Pointer spTargetPyramide1 = Pyramide2Type::New(); TestMultiResRegistrationAlgorithmBase testInterface; CHECK(NULL == testInterface.getMovingImagePyramide()); CHECK(NULL == testInterface.getTargetImagePyramide()); - unsigned long mmt = testInterface.getMovingPyramideMTime(); - unsigned long tmt = testInterface.getTargetPyramideMTime(); + auto mmt = testInterface.getMovingPyramideMTime(); + auto tmt = testInterface.getTargetPyramideMTime(); testInterface.setMovingImagePyramide(spPyramide1); CHECK(mmt < testInterface.getMovingPyramideMTime()); CHECK(tmt == testInterface.getTargetPyramideMTime()); mmt = testInterface.getMovingPyramideMTime(); testInterface.setTargetImagePyramide(spTargetPyramide1); CHECK(mmt == testInterface.getMovingPyramideMTime()); CHECK(tmt < testInterface.getTargetPyramideMTime()); tmt = testInterface.getTargetPyramideMTime(); spPyramide1->Modified(); CHECK(mmt < testInterface.getMovingPyramideMTime()); CHECK(tmt == testInterface.getTargetPyramideMTime()); mmt = testInterface.getMovingPyramideMTime(); spTargetPyramide1->Modified(); CHECK(mmt == testInterface.getMovingPyramideMTime()); CHECK(tmt < testInterface.getTargetPyramideMTime()); CHECK_EQUAL(spPyramide1.GetPointer(), testInterface.getMovingImagePyramide()); CHECK_EQUAL(spTargetPyramide1.GetPointer(), testInterface.getTargetImagePyramide()); testInterface._hasLevelCount = false; CHECK_EQUAL(0, testInterface.getCurrentLevel()); CHECK_EQUAL(0, testInterface._doGetCurrentLevelCount); testInterface._hasLevelCount = true; CHECK_EQUAL(42, testInterface.getCurrentLevel()); CHECK_EQUAL(1, testInterface._doGetCurrentLevelCount); RETURN_AND_REPORT_TEST_SUCCESS; } } //namespace testing } //namespace map diff --git a/Code/Algorithms/ITK/include/mapArbitraryImageToImageMetricPolicy.h b/Code/Algorithms/ITK/include/mapArbitraryImageToImageMetricPolicy.h index f9d0780..633d7cd 100644 --- a/Code/Algorithms/ITK/include/mapArbitraryImageToImageMetricPolicy.h +++ b/Code/Algorithms/ITK/include/mapArbitraryImageToImageMetricPolicy.h @@ -1,138 +1,138 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __ARBITRARY_IMAGE_TO_IMAGE_METRIC_POLICY_H #define __ARBITRARY_IMAGE_TO_IMAGE_METRIC_POLICY_H #include "mapITKImageToImageMetricSetterInterface.h" #include "mapITKImageToImageMetricGetterInterface.h" #include "mapITKImageToImageMetricControlInterface.h" #include "mapModificationTimeValidator.h" #include "itkCommand.h" namespace map { namespace algorithm { namespace itk { /*! @class ArbitraryImageToImageMetricPolicy @brief class for ArbitraryImageToImageMetricPolicy. This class is a ArbitraryImageToImageMetricPolicy. It is used if an ITKImageRegistrationAlgorithm should use an arbitrary metric that is to be set by the user (in contrary to FixedImageToImageMetricPolicy). @sa FixedImageToImageMetricPolicy @ingroup ITKPolicies */ template class ArbitraryImageToImageMetricPolicy : public facet::ITKImageToImageMetricSetterInterface, public facet::ITKImageToImageMetricGetterInterface { public: typedef ArbitraryImageToImageMetricPolicy Self; typedef facet::ITKImageToImageMetricSetterInterface Superclass; itkTypeMacroNoParent(ArbitraryImageToImageMetricPolicy); typedef ITKImageToImageMetricControlInterface MetricControlType; /*! gets the metric controll @eguarantee strong @param pMetric the metric instance */ virtual const MetricControlType* getMetricControl() const; virtual MetricControlType* getMetricControl(); /*! sets the metric @eguarantee strong @param pMetric the metric instance */ virtual void setMetricControl(MetricControlType* pMetric); /*! Returns the modification time of the policy (and its controlled component). * In this case the modification time is a pass through of the internal component. @eguarantee strong @return the modification time */ - virtual unsigned long GetMTime() const; + virtual ::itk::ModifiedTimeType GetMTime() const; protected: ArbitraryImageToImageMetricPolicy(); ~ArbitraryImageToImageMetricPolicy(); /*! This is a command slot that can be used by any class derivering from this policy * to get informed if the component instances is changed. \n * Two events will be invoked with this command: \n * - UnregisterAlgorithmComponentEvent * - RegisterAlgorithmComponentEvent * . * The first one is used when the current metric is going to be replaced (by setMetricControl). The event data in this case * is a void pointer to the current (soon outdated) object. The second event will be called when the new metric was set * (by setMetricControl). In this case the event data is a pointer to the new metric.*/ ::itk::Command::Pointer _spOnChange; /*! gets the internal metric @eguarantee strong @return a pointer to a metric type */ virtual MetricControlType* getMetricInternal(); virtual const MetricControlType* getMetricInternal() const; /*! initializes the metric @eguarantee strong */ void prepareMetric(); /*! initializes the metric * after it was integrated in a controlling structur (e.g. registration algorithm) @eguarantee strong */ void prepareMetricAfterAssembly(); private: typename MetricControlType::Pointer _spMetric; /*! The time stamp is used to signal changes of the policy that may effect the controlling structur (e.g. registration algorithm) * because the controlled object has changed.*/ mutable core::ModificationTimeValidator _mTime; //No copy constructor allowed ArbitraryImageToImageMetricPolicy(const Self& source); void operator=(const Self&); //purposely not implemented }; } // namespace itk } // namespace algorithm } // namespace map #ifndef MatchPoint_MANUAL_TPP #include "mapArbitraryImageToImageMetricPolicy.tpp" #endif #endif diff --git a/Code/Algorithms/ITK/include/mapArbitraryImageToImageMetricPolicy.tpp b/Code/Algorithms/ITK/include/mapArbitraryImageToImageMetricPolicy.tpp index 1c551f7..e4cfb74 100644 --- a/Code/Algorithms/ITK/include/mapArbitraryImageToImageMetricPolicy.tpp +++ b/Code/Algorithms/ITK/include/mapArbitraryImageToImageMetricPolicy.tpp @@ -1,136 +1,136 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __ARBITRARY_IMAGE_TO_IMAGE_METRIC_POLICY_TPP #define __ARBITRARY_IMAGE_TO_IMAGE_METRIC_POLICY_TPP #include "mapAlgorithmEvents.h" namespace map { namespace algorithm { namespace itk { template - unsigned long + ::itk::ModifiedTimeType ArbitraryImageToImageMetricPolicy:: GetMTime() const { - unsigned long mt = _mTime.getMTime(); + auto mt = _mTime.getMTime(); return mt; }; template void ArbitraryImageToImageMetricPolicy:: setMetricControl(MetricControlType* pMetric) { if (pMetric != _spMetric.GetPointer()) { //there is really the need to change if (this->_spOnChange.IsNotNull()) { ::map::events::UnregisterAlgorithmComponentEvent unRegEvent(_spMetric.GetPointer(), "Unregister current metric"); this->_spOnChange->Execute((::itk::Object*)NULL, unRegEvent); } _mTime.setWatchedObject(pMetric); _spMetric = pMetric; if (this->_spOnChange.IsNotNull()) { ::map::events::RegisterAlgorithmComponentEvent regEvent(_spMetric.GetPointer(), "Register new metric"); this->_spOnChange->Execute((::itk::Object*)NULL, regEvent); } } }; template ArbitraryImageToImageMetricPolicy:: ArbitraryImageToImageMetricPolicy() { }; template ArbitraryImageToImageMetricPolicy:: ~ArbitraryImageToImageMetricPolicy() { }; template typename ArbitraryImageToImageMetricPolicy::MetricControlType* ArbitraryImageToImageMetricPolicy:: getMetricInternal() { return _spMetric; }; template const typename ArbitraryImageToImageMetricPolicy::MetricControlType* ArbitraryImageToImageMetricPolicy:: getMetricInternal() const { return _spMetric; }; template typename ArbitraryImageToImageMetricPolicy::MetricControlType* ArbitraryImageToImageMetricPolicy:: getMetricControl() { return _spMetric; }; template const typename ArbitraryImageToImageMetricPolicy::MetricControlType* ArbitraryImageToImageMetricPolicy:: getMetricControl() const { return _spMetric; }; template void ArbitraryImageToImageMetricPolicy:: prepareMetric() { //default implementation does nothing; }; template void ArbitraryImageToImageMetricPolicy:: prepareMetricAfterAssembly() { //default implementation does nothing; }; } // namespace itk } // end namespace algorithm } // end namespace map #endif diff --git a/Code/Algorithms/ITK/include/mapArbitraryInterpolatorPolicy.h b/Code/Algorithms/ITK/include/mapArbitraryInterpolatorPolicy.h index 5001796..363adbb 100644 --- a/Code/Algorithms/ITK/include/mapArbitraryInterpolatorPolicy.h +++ b/Code/Algorithms/ITK/include/mapArbitraryInterpolatorPolicy.h @@ -1,139 +1,139 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __ARBITRARY_INTERPOLATOR_POLICY_H #define __ARBITRARY_INTERPOLATOR_POLICY_H #include "mapContinuous.h" #include "mapITKInterpolatorSetterInterface.h" #include "mapITKInterpolatorGetterInterface.h" #include "mapModificationTimeValidator.h" #include "itkCommand.h" namespace map { namespace algorithm { namespace itk { /*! @class ArbitraryInterpolatorPolicy @brief class for ArbitraryInterpolatorPolicy. This class is a ArbitraryInterpolatorPolicy. It is used if an ITKImageRegistrationAlgorithm should use an arbitrary interpolator that is to be set by the user (in contrary to FixedInterpolatorPolicy). @sa FixedInterpolatorPolicy @ingroup ITKPolicies */ template class ArbitraryInterpolatorPolicy : public facet::ITKInterpolatorSetterInterface, public facet::ITKInterpolatorGetterInterface { public: typedef ArbitraryInterpolatorPolicy Self; typedef facet::ITKInterpolatorSetterInterface Superclass; itkTypeMacroNoParent(ArbitraryInterpolatorPolicy); typedef ::itk::InterpolateImageFunction InterpolatorType; using CoordRepType = TCoordRep; /*! sets the interpolator @eguarantee strong @param pInterpolator the interpolator */ virtual void setInterpolator(InterpolatorType* pInterpolator); /*! gets the interpolator @eguarantee strong @return a pointer to the interpolator */ virtual InterpolatorType* getInterpolator(); virtual const InterpolatorType* getInterpolator() const; /*! Returns the modification time of the policy (and its controlled component). * In this case the modification time is a pass through of the internal component. @eguarantee strong @return the modification time */ - virtual unsigned long GetMTime() const; + virtual ::itk::ModifiedTimeType GetMTime() const; protected: ArbitraryInterpolatorPolicy(); ~ArbitraryInterpolatorPolicy(); /*! This is a command slot that can be used by any class derivering from this policy * to get informed if the component instances is changed. \n * Two events will be invoked with this command: \n * - UnregisterAlgorithmComponentEvent * - RegisterAlgorithmComponentEvent * . * The first one is used when the current interpolator is going to be replaced (by setInterpolator). The event data in this case * is a void pointer to the current (soon outdated) object. The second event will be called when the new interpolator was set * (by setInterpolator). In this case the event data is a pointer to the new interpolator.*/ ::itk::Command::Pointer _spOnChange; /*! gets the internal interpolator @eguarantee strong @return a pointer to an interpolator type */ virtual InterpolatorType* getInterpolatorInternal(); virtual const InterpolatorType* getInterpolatorInternal() const; /*! initializes the interpolator @eguarantee strong */ void prepareInterpolator(); /*! initializes the interpolator * after it was integrated in a controlling structur (e.g. registration algorithm) @eguarantee strong */ void prepareInterpolatorAfterAssembly(); private: typename InterpolatorType::Pointer _spInterpolator; /*! The time stamp is used to signal changes of the policy that may effect the controlling structur (e.g. registration algorithm) * because the controlled object has changed.*/ mutable core::ModificationTimeValidator _mTime; //No copy constructor allowed ArbitraryInterpolatorPolicy(const Self& source); void operator=(const Self&); //purposely not implemented }; } // namespace itk } // namespace algorithm } // namespace map #ifndef MatchPoint_MANUAL_TPP #include "mapArbitraryInterpolatorPolicy.tpp" #endif #endif diff --git a/Code/Algorithms/ITK/include/mapArbitraryInterpolatorPolicy.tpp b/Code/Algorithms/ITK/include/mapArbitraryInterpolatorPolicy.tpp index f7dea71..d6dcbbd 100644 --- a/Code/Algorithms/ITK/include/mapArbitraryInterpolatorPolicy.tpp +++ b/Code/Algorithms/ITK/include/mapArbitraryInterpolatorPolicy.tpp @@ -1,137 +1,137 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #include "mapAlgorithmEvents.h" #ifndef __ARBITRARY_INTERPOLATOR_POLICY_TPP #define __ARBITRARY_INTERPOLATOR_POLICY_TPP namespace map { namespace algorithm { namespace itk { template - unsigned long + ::itk::ModifiedTimeType ArbitraryInterpolatorPolicy:: GetMTime() const { - unsigned long mt = _mTime.getMTime(); + auto mt = _mTime.getMTime(); return mt; }; template ArbitraryInterpolatorPolicy:: ArbitraryInterpolatorPolicy() { } template ArbitraryInterpolatorPolicy:: ~ArbitraryInterpolatorPolicy() { } template typename ArbitraryInterpolatorPolicy::InterpolatorType* ArbitraryInterpolatorPolicy:: getInterpolatorInternal() { return _spInterpolator; } template const typename ArbitraryInterpolatorPolicy::InterpolatorType* ArbitraryInterpolatorPolicy:: getInterpolatorInternal() const { return _spInterpolator; } template typename ArbitraryInterpolatorPolicy::InterpolatorType* ArbitraryInterpolatorPolicy:: getInterpolator() { return _spInterpolator; } template const typename ArbitraryInterpolatorPolicy::InterpolatorType* ArbitraryInterpolatorPolicy:: getInterpolator() const { return _spInterpolator; } template void ArbitraryInterpolatorPolicy:: setInterpolator(InterpolatorType* pInterpolator) { if (pInterpolator != _spInterpolator.GetPointer()) { //there is really the need to change if (this->_spOnChange.IsNotNull()) { ::map::events::UnregisterAlgorithmComponentEvent unRegEvent(_spInterpolator.GetPointer(), "Unregister current interpolator"); this->_spOnChange->Execute((::itk::Object*)NULL, unRegEvent); } _spInterpolator = pInterpolator; _mTime.setWatchedObject(pInterpolator); if (this->_spOnChange.IsNotNull()) { ::map::events::RegisterAlgorithmComponentEvent regEvent(_spInterpolator.GetPointer(), "Register new interpolator"); this->_spOnChange->Execute((::itk::Object*)NULL, regEvent); } } } template void ArbitraryInterpolatorPolicy:: prepareInterpolator() { //default implementation does nothing; } template void ArbitraryInterpolatorPolicy:: prepareInterpolatorAfterAssembly() { //default implementation does nothing; } } // namespace itk } // namespace algorithm } // namespace map #endif diff --git a/Code/Algorithms/ITK/include/mapArbitraryMVNLOptimizerPolicy.h b/Code/Algorithms/ITK/include/mapArbitraryMVNLOptimizerPolicy.h index 76d076a..f849785 100644 --- a/Code/Algorithms/ITK/include/mapArbitraryMVNLOptimizerPolicy.h +++ b/Code/Algorithms/ITK/include/mapArbitraryMVNLOptimizerPolicy.h @@ -1,145 +1,145 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __ARBITRARY_MVNL_OPTIMIZER_POLICY_H #define __ARBITRARY_MVNL_OPTIMIZER_POLICY_H #include "itkCommand.h" #include "mapITKMVNLOptimizerSetterInterface.h" #include "mapITKMVNLOptimizerGetterInterface.h" #include "mapOptimizerGetterInterface.h" #include "mapModificationTimeValidator.h" #include "mapMAPAlgorithmsITKExports.h" #include namespace map { namespace algorithm { namespace itk { /*! @class ArbitraryMVNLOptimizerPolicy @brief class for ArbitraryMVNLOptimizerPolicy. This class is a ArbitraryMVNLOptimizerPolicy. It is used if an ITKImageRegistrationAlgorithm should use an arbitrary multiple valued non linear optimizer (based on itk::MultipleValueNonLinearOptimzer)that is to be set by the user (in contrary to FixedMVNLOptimizerPolicy). By default the policy will determin the right optimization direction. You can deactivate this feature by setting AutomaticOptimizationDirection to false. @sa FixedMVNLOptimizerPolicy @ingroup ITKPolicies */ class MAPAlgorithmsITK_EXPORT ArbitraryMVNLOptimizerPolicy: public facet::ITKMVNLOptimizerSetterInterface, public facet::ITKMVNLOptimizerGetterInterface, public facet::OptimizerGetterInterface { public: using Self = ArbitraryMVNLOptimizerPolicy; using Superclass = facet::ITKMVNLOptimizerSetterInterface; itkTypeMacroNoParent(ArbitraryMVNLOptimizerPolicy); using OptimizerControlType = facet::OptimizerGetterInterface::OptimizerControlType; using ITKOptimizerControlType = Superclass::ITKOptimizerControlType; /*! gets an optimizer control object @eguarantee strong @return a pointer to an ITKMVNLOptimizerControlInterface object */ OptimizerControlType* getOptimizerControl() override; const OptimizerControlType* getOptimizerControl() const override; ITKOptimizerControlType* getITKOptimizerControl() override; const ITKOptimizerControlType* getITKOptimizerControl() const override; void setITKOptimizerControl(ITKOptimizerControlType* pOptimizer) override; void setAutomaticOptimizationDirection(bool automatic); bool getAutomaticOptimizationDirection() const; /*! Returns the modification time of the policy (and its controlled component). * In this case the modification time is a pass through of the internal component. @eguarantee strong @return the modification time */ - virtual unsigned long GetMTime() const; + virtual ::itk::ModifiedTimeType GetMTime() const; protected: ArbitraryMVNLOptimizerPolicy(); ~ArbitraryMVNLOptimizerPolicy() override; /*! This is a command slot that can be used by any class derivering from this policy * to get informed if the component instances is changed. \n * Two events will be invoked with this command: \n * - UnregisterAlgorithmComponentEvent * - RegisterAlgorithmComponentEvent * . * The first one is used when the current optimizer is going to be replaced (by setOptimizer). The event data in this case * is a void pointer to the current (soon outdated) object. The second event will be called when the new optimizer was set * (by setOptimizer). In this case the event data is a pointer to the new optimizer.*/ ::itk::Command::Pointer _spOnChange; /*! gets the internal optimizer @eguarantee no fail @return a pointer to an OptimizerControlType object */ virtual ITKOptimizerControlType* getOptimizerInternal(); virtual const ITKOptimizerControlType* getOptimizerInternal() const; /*! initializes the optimizer @eguarantee strong */ void prepareOptimizer(); /*! initializes the optimizer * after it was integrated in a controlling structur (e.g. registration algorithm) @eguarantee strong */ void prepareOptimizerAfterAssembly(bool minimizeToOptimize); private: ITKOptimizerControlType::Pointer _spOptimizerControl; /*! The time stamp validator is used to signal changes of the policy that may effect the controlling structur (e.g. registration algorithm) * because the controlled object has changed.*/ mutable core::ModificationTimeValidator _mTime; /*! Controlles if the policy sets the optimization automaticaly or * if its up to the user to specifiy the direction. Automatic direction * detaction will be performed by prepareOptimizerAfterAssembly().*/ bool _automaticOptimizationDirection{true}; //No copy constructor allowed ArbitraryMVNLOptimizerPolicy(const Self& source) = delete; void operator=(const Self&) = delete; //purposely not implemented }; } // namespace itk } // namespace algorithm } // namespace map #endif diff --git a/Code/Algorithms/ITK/include/mapArbitraryPointSetToPointSetMetricPolicy.h b/Code/Algorithms/ITK/include/mapArbitraryPointSetToPointSetMetricPolicy.h index 4d10653..91f210d 100644 --- a/Code/Algorithms/ITK/include/mapArbitraryPointSetToPointSetMetricPolicy.h +++ b/Code/Algorithms/ITK/include/mapArbitraryPointSetToPointSetMetricPolicy.h @@ -1,140 +1,140 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __ARBITRARY_POINT_SET_TO_POINT_SET_METRIC_POLICY_H #define __ARBITRARY_POINT_SET_TO_POINT_SET_METRIC_POLICY_H #include "mapITKPointSetToPointSetMetricSetterInterface.h" #include "mapITKPointSetToPointSetMetricGetterInterface.h" #include "mapITKPointSetToPointSetMetricControlInterface.h" #include "mapModificationTimeValidator.h" #include "itkCommand.h" namespace map { namespace algorithm { namespace itk { /*! @class ArbitraryPointSetToPointSetMetricPolicy @brief class for ArbitraryPointSetToPointSetMetricPolicy. This class is a ArbitraryPointSetToPointSetMetricPolicy. It is used if an ITKPointSetRegistrationAlgorithm should use an arbitrary metric that is to be set by the user (in contrary to FixedPointSetToPointSetMetricPolicy). @sa FixedPointSetToPointSetMetricPolicy @ingroup ITKPolicies */ template class ArbitraryPointSetToPointSetMetricPolicy : public facet::ITKPointSetToPointSetMetricSetterInterface, public facet::ITKPointSetToPointSetMetricGetterInterface { public: typedef ArbitraryPointSetToPointSetMetricPolicy Self; typedef facet::ITKPointSetToPointSetMetricSetterInterface Superclass; itkTypeMacroNoParent(ArbitraryPointSetToPointSetMetricPolicy); typedef ITKPointSetToPointSetMetricControlInterface MetricControlType; /*! gets the metric controll @eguarantee strong @param pMetric the metric instance */ virtual const MetricControlType* getMetricControl() const; virtual MetricControlType* getMetricControl(); /*! sets the metric @eguarantee strong @param pMetric the metric instance */ virtual void setMetricControl(MetricControlType* pMetric); /*! Returns the modification time of the policy (and its controlled component). * In this case the modification time is a pass through of the internal component. @eguarantee strong @return the modification time */ - virtual unsigned long GetMTime() const; + virtual ::itk::ModifiedTimeType GetMTime() const; protected: ArbitraryPointSetToPointSetMetricPolicy(); ~ArbitraryPointSetToPointSetMetricPolicy(); /*! This is a command slot that can be used by any class derivering from this policy * to get informed if the component instances is changed. \n * Two events will be invoked with this command: \n * - UnregisterAlgorithmComponentEvent * - RegisterAlgorithmComponentEvent * . * The first one is used when the current metric is going to be replaced (by setMetricControl). The event data in this case * is a void pointer to the current (soon outdated) object. The second event will be called when the new metric was set * (by setMetricControl). In this case the event data is a pointer to the new metric.*/ ::itk::Command::Pointer _spOnChange; /*! gets the internal metric @eguarantee strong @return a pointer to a metric type */ virtual MetricControlType* getMetricInternal(); virtual const MetricControlType* getMetricInternal() const; /*! initializes the metric @eguarantee strong */ void prepareMetric(); /*! initializes the metric * after it was integrated in a controlling structur (e.g. registration algorithm) @eguarantee strong */ void prepareMetricAfterAssembly(); private: typename MetricControlType::Pointer _spMetric; /*! The time stamp is used to signal changes of the policy that may effect the controlling structur (e.g. registration algorithm) * because the controlled object has changed.*/ mutable core::ModificationTimeValidator _mTime; //No copy constructor allowed ArbitraryPointSetToPointSetMetricPolicy(const Self& source); void operator=(const Self&); //purposely not implemented }; } } } #ifndef MatchPoint_MANUAL_TPP #include "mapArbitraryPointSetToPointSetMetricPolicy.tpp" #endif #endif diff --git a/Code/Algorithms/ITK/include/mapArbitraryPointSetToPointSetMetricPolicy.tpp b/Code/Algorithms/ITK/include/mapArbitraryPointSetToPointSetMetricPolicy.tpp index 0c78b2f..55300d4 100644 --- a/Code/Algorithms/ITK/include/mapArbitraryPointSetToPointSetMetricPolicy.tpp +++ b/Code/Algorithms/ITK/include/mapArbitraryPointSetToPointSetMetricPolicy.tpp @@ -1,139 +1,139 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __ARBITRARY_POINT_SET_TO_POINT_SET_METRIC_POLICY_TPP #define __ARBITRARY_POINT_SET_TO_POINT_SET_METRIC_POLICY_TPP #include "mapAlgorithmEvents.h" namespace map { namespace algorithm { namespace itk { template - unsigned long + ::itk::ModifiedTimeType ArbitraryPointSetToPointSetMetricPolicy:: GetMTime() const { - unsigned long mt = _mTime.getMTime(); + auto mt = _mTime.getMTime(); return mt; }; template void ArbitraryPointSetToPointSetMetricPolicy:: setMetricControl(MetricControlType* pMetric) { if (pMetric != _spMetric.GetPointer()) { //there is really the need to change if (this->_spOnChange.IsNotNull()) { ::map::events::UnregisterAlgorithmComponentEvent unRegEvent(_spMetric.GetPointer(), "Unregister current metric"); this->_spOnChange->Execute((::itk::Object*)NULL, unRegEvent); } _spMetric = pMetric; _mTime.setWatchedObject(pMetric); if (this->_spOnChange.IsNotNull()) { ::map::events::RegisterAlgorithmComponentEvent regEvent(_spMetric.GetPointer(), "Register new metric"); this->_spOnChange->Execute((::itk::Object*)NULL, regEvent); } } }; template ArbitraryPointSetToPointSetMetricPolicy:: ArbitraryPointSetToPointSetMetricPolicy() { }; template ArbitraryPointSetToPointSetMetricPolicy:: ~ArbitraryPointSetToPointSetMetricPolicy() { }; template typename ArbitraryPointSetToPointSetMetricPolicy::MetricControlType* ArbitraryPointSetToPointSetMetricPolicy:: getMetricInternal() { return _spMetric; }; template const typename ArbitraryPointSetToPointSetMetricPolicy::MetricControlType* ArbitraryPointSetToPointSetMetricPolicy:: getMetricInternal() const { return _spMetric; }; template typename ArbitraryPointSetToPointSetMetricPolicy::MetricControlType* ArbitraryPointSetToPointSetMetricPolicy:: getMetricControl() { return _spMetric; }; template const typename ArbitraryPointSetToPointSetMetricPolicy::MetricControlType* ArbitraryPointSetToPointSetMetricPolicy:: getMetricControl() const { return _spMetric; }; template void ArbitraryPointSetToPointSetMetricPolicy:: prepareMetric() { //default implementation does nothing; }; template void ArbitraryPointSetToPointSetMetricPolicy:: prepareMetricAfterAssembly() { //default implementation does nothing; }; } } // end namespace algorithm } // end namespace map #endif diff --git a/Code/Algorithms/ITK/include/mapArbitrarySVNLOptimizerPolicy.h b/Code/Algorithms/ITK/include/mapArbitrarySVNLOptimizerPolicy.h index d2fb269..fcdc9dc 100644 --- a/Code/Algorithms/ITK/include/mapArbitrarySVNLOptimizerPolicy.h +++ b/Code/Algorithms/ITK/include/mapArbitrarySVNLOptimizerPolicy.h @@ -1,150 +1,150 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __ARBITRARY_SVNL_OPTIMIZER_POLICY_H #define __ARBITRARY_SVNL_OPTIMIZER_POLICY_H #include "itkCommand.h" #include "mapITKSVNLOptimizerSetterInterface.h" #include "mapITKSVNLOptimizerGetterInterface.h" #include "mapOptimizerGetterInterface.h" #include "mapModificationTimeValidator.h" #include "mapMAPAlgorithmsITKExports.h" #include namespace map { namespace algorithm { namespace itk { /*! @class ArbitrarySVNLOptimizerPolicy @brief class for ArbitrarySVNLOptimizerPolicy. This class is a ArbitrarySVNLOptimizerPolicy. It is used if an ITKImageRegistrationAlgorithm should use an arbitrary singel value non linear optimizer (based on itk::SingleValueNonLinearOptimzer)that is to be set by the user (in contrary to FixedSVNLOptimizerPolicy). By default the policy will determin the right optimization direction. You can deactivate this feature by setting AutomaticOptimizationDirection to false. @sa FixedSVNLOptimizerPolicy @ingroup ITKPolicies */ class MAPAlgorithmsITK_EXPORT ArbitrarySVNLOptimizerPolicy: public facet::ITKSVNLOptimizerSetterInterface, public facet::ITKSVNLOptimizerGetterInterface, public facet::OptimizerGetterInterface { public: using Self = ArbitrarySVNLOptimizerPolicy; using Superclass = facet::ITKSVNLOptimizerSetterInterface; itkTypeMacroNoParent(ArbitrarySVNLOptimizerPolicy); using ITKOptimizerControlType = Superclass::ITKOptimizerControlType; using OptimizerControlType = facet::OptimizerGetterInterface::OptimizerControlType; /*! gets an optimizer control object @eguarantee strong @return a pointer to an ITKSVNLOptimizerControlInterface object */ ITKOptimizerControlType* getITKOptimizerControl() override; const ITKOptimizerControlType* getITKOptimizerControl() const override; /*! gets an optimizer control object @eguarantee strong @return a pointer to an ITKSVNLOptimizerControlInterface object */ OptimizerControlType* getOptimizerControl() override; const OptimizerControlType* getOptimizerControl() const override; void setITKOptimizerControl(ITKOptimizerControlType* pOptimizer) override; void setAutomaticOptimizationDirection(bool automatic); bool getAutomaticOptimizationDirection() const; /*! Returns the modification time of the policy (and its controlled component). * In this case the modification time is a pass through of the internal component. @eguarantee strong @return the modification time */ - virtual unsigned long GetMTime() const; + virtual ::itk::ModifiedTimeType GetMTime() const; protected: ArbitrarySVNLOptimizerPolicy(); ~ArbitrarySVNLOptimizerPolicy() override; /*! This is a command slot that can be used by any class derivering from this policy * to get informed if the component instances is changed. \n * Two events will be invoked with this command: \n * - UnregisterAlgorithmComponentEvent * - RegisterAlgorithmComponentEvent * . * The first one is used when the current optimizer is going to be replaced (by setOptimizer). The event data in this case * is a void pointer to the current (soon outdated) object. The second event will be called when the new optimizer was set * (by setOptimizer). In this case the event data is a pointer to the new optimizer.*/ ::itk::Command::Pointer _spOnChange; /*! gets the internal optimizer @eguarantee no fail @return a pointer to an ITKOptimizerControlType object */ virtual ITKOptimizerControlType* getOptimizerInternal(); virtual const ITKOptimizerControlType* getOptimizerInternal() const; /*! initializes the optimizer @eguarantee strong */ void prepareOptimizer(); /*! initializes the optimizer * after it was integrated in a controlling structur (e.g. registration algorithm) @eguarantee strong */ void prepareOptimizerAfterAssembly(bool minimizeToOptimize); private: ITKOptimizerControlType::Pointer _spOptimizerControl; /*! The time stamp validator is used to signal changes of the policy that may effect the controlling structur (e.g. registration algorithm) * because the controlled object has changed.*/ mutable core::ModificationTimeValidator _mTime; /*! Controlles if the policy sets the optimization automaticaly or * if its up to the user to specifiy the direction. Automatic direction * detaction will be performed by prepareOptimizerAfterAssembly().*/ bool _automaticOptimizationDirection{true}; //No copy constructor allowed ArbitrarySVNLOptimizerPolicy(const Self& source) = delete; void operator=(const Self&) = delete; //purposely not implemented }; } // namespace itk } // namespace algorithm } // namespace map #endif diff --git a/Code/Algorithms/ITK/include/mapArbitraryTransformPolicy.h b/Code/Algorithms/ITK/include/mapArbitraryTransformPolicy.h index 9217fff..b221e10 100644 --- a/Code/Algorithms/ITK/include/mapArbitraryTransformPolicy.h +++ b/Code/Algorithms/ITK/include/mapArbitraryTransformPolicy.h @@ -1,139 +1,139 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __ARBITRARY_TRANSFORM_POLICY_H #define __ARBITRARY_TRANSFORM_POLICY_H #include "mapITKTransformSetterInterface.h" #include "mapITKTransformGetterInterface.h" #include "mapModificationTimeValidator.h" #include "itkCommand.h" namespace map { namespace algorithm { namespace itk { /*! @class ArbitraryTransformPolicy @brief class for ArbitraryTransformPolicy. This class is a ArbitraryTransformPolicy. It is used if an ITKImageRegistrationAlgorithm should use an arbitrary transform model that is to be set by the user (in contrary to FixedTransformPolicy). @sa FixedTransformPolicy @ingroup ITKPolicies */ template class ArbitraryTransformPolicy: public facet::ITKTransformSetterInterface, public facet::ITKTransformGetterInterface { public: typedef ArbitraryTransformPolicy Self; typedef facet::ITKTransformSetterInterface Superclass; itkTypeMacroNoParent(ArbitraryTransformPolicy); using TransformType = typename Superclass::TransformType; using TransformScalarType = TScalar; /*! sets the transfrom model @eguarantee strong @param pTransform the tranform model */ virtual void setTransformModel(TransformType* pTransform); /*! gets the transformation @eguarantee strong @return a pointer to the transform */ virtual TransformType* getTransformModel(); virtual const TransformType* getTransformModel() const; /*! Returns the modification time of the policy (and its controlled component). * In this case the modification time is a pass through of the internal component. @eguarantee strong @return the modification time */ - virtual unsigned long GetMTime() const; + virtual ::itk::ModifiedTimeType GetMTime() const; protected: ArbitraryTransformPolicy(); ~ArbitraryTransformPolicy(); /*! This is a command slot that can be used by any class derivering from this policy * to get informed if the component instances is changed. \n * Two events will be invoked with this command: \n * - UnregisterAlgorithmComponentEvent * - RegisterAlgorithmComponentEvent * . * The first one is used when the current transform is going to be replaced (by setTransformModel). The event data in this case * is a void pointer to the current (soon outdated) object. The second event will be called when the new transform was set * (by setTransformModel). In this case the event data is a pointer to the new transform.*/ ::itk::Command::Pointer _spOnChange; /*! gets the internal transformation @eguarantee strong @return a pointer to a transform type */ virtual TransformType* getTransformInternal(); virtual const TransformType* getTransformInternal() const; /*! initializes the transform @eguarantee strong */ void prepareTransform(); /*! initializes the transform * after it was integrated in a controlling structur (e.g. registration algorithm) @eguarantee strong */ void prepareTransformAfterAssembly(); private: typename TransformType::Pointer _spTransformModel; /*! The time stamp is used to signal changes of the policy that may effect the controlling structur (e.g. registration algorithm) * because the controlled object has changed.*/ mutable core::ModificationTimeValidator _mTime; //No copy constructor allowed ArbitraryTransformPolicy(const Self& source); void operator=(const Self&); //purposely not implemented }; } // namespace itk } // namespace algorithm } // namespace map #ifndef MatchPoint_MANUAL_TPP #include "mapArbitraryTransformPolicy.tpp" #endif #endif diff --git a/Code/Algorithms/ITK/include/mapArbitraryTransformPolicy.tpp b/Code/Algorithms/ITK/include/mapArbitraryTransformPolicy.tpp index b137355..9a619af 100644 --- a/Code/Algorithms/ITK/include/mapArbitraryTransformPolicy.tpp +++ b/Code/Algorithms/ITK/include/mapArbitraryTransformPolicy.tpp @@ -1,139 +1,139 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __ARBITRARY_TRANSFORM_POLICY_TPP #define __ARBITRARY_TRANSFORM_POLICY_TPP #include "mapAlgorithmEvents.h" namespace map { namespace algorithm { namespace itk { template - unsigned long + ::itk::ModifiedTimeType ArbitraryTransformPolicy:: GetMTime() const { - unsigned long mt = _mTime.getMTime(); + auto mt = _mTime.getMTime(); return mt; }; template void ArbitraryTransformPolicy:: setTransformModel(TransformType* pTransform) { if (pTransform != _spTransformModel.GetPointer()) { //there is really the need to change if (this->_spOnChange.IsNotNull()) { ::map::events::UnregisterAlgorithmComponentEvent unRegEvent(_spTransformModel.GetPointer(), "Unregister current transform model"); this->_spOnChange->Execute((::itk::Object*)NULL, unRegEvent); } _spTransformModel = pTransform; _mTime.setWatchedObject(pTransform); if (this->_spOnChange.IsNotNull()) { ::map::events::RegisterAlgorithmComponentEvent regEvent(_spTransformModel.GetPointer(), "Register new transform model"); this->_spOnChange->Execute((::itk::Object*)NULL, regEvent); } } }; template ArbitraryTransformPolicy:: ArbitraryTransformPolicy() { }; template ArbitraryTransformPolicy:: ~ArbitraryTransformPolicy() { }; template typename ArbitraryTransformPolicy::TransformType* ArbitraryTransformPolicy:: getTransformInternal() { return _spTransformModel; }; template const typename ArbitraryTransformPolicy::TransformType* ArbitraryTransformPolicy:: getTransformInternal() const { return _spTransformModel; }; template typename ArbitraryTransformPolicy::TransformType* ArbitraryTransformPolicy:: getTransformModel() { return _spTransformModel; }; template const typename ArbitraryTransformPolicy::TransformType* ArbitraryTransformPolicy:: getTransformModel() const { return _spTransformModel; }; template void ArbitraryTransformPolicy:: prepareTransform() { //default implementation does nothing; }; template void ArbitraryTransformPolicy:: prepareTransformAfterAssembly() { //default implementation does nothing; }; } // namespace itk } // end namespace algorithm } // end namespace map #endif diff --git a/Code/Algorithms/ITK/include/mapITKImageToImageMetricControlBase.h b/Code/Algorithms/ITK/include/mapITKImageToImageMetricControlBase.h index 67e8986..e181aa2 100644 --- a/Code/Algorithms/ITK/include/mapITKImageToImageMetricControlBase.h +++ b/Code/Algorithms/ITK/include/mapITKImageToImageMetricControlBase.h @@ -1,111 +1,111 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __ITK_IMAGE_TO_IMAGE_METRIC_CONTROL_BASE_H #define __ITK_IMAGE_TO_IMAGE_METRIC_CONTROL_BASE_H #include "mapITKImageToImageMetricControlInterface.h" namespace map { namespace algorithm { namespace itk { /*! @class ITKImageToImageMetricControlBase This class serves as base class for all template specialization of itk::ImageToImageMetrics. It realizes some basic metric handling, to reduce the code in the control classes @remark ITKImageToImageMetricControlBase instantiates a concrete metric when constructed. You can set a new one, but ITKImageToImageMetricControlBase has always an optimizer under control. @template TConcreteMetric type of the concrete metric controlled by the class @ingroup ITK @ingroup MetricControl */ template class ITKImageToImageMetricControlBase : public ITKImageToImageMetricControlInterface { public: using Self = ITKImageToImageMetricControlBase; typedef ITKImageToImageMetricControlInterface Superclass; using MovingImageType = typename TConcreteMetric::MovingImageType; using TargetImageType = typename TConcreteMetric::FixedImageType; using Pointer = ::itk::SmartPointer; using ConstPointer = ::itk::SmartPointer; itkTypeMacro(ITKImageToImageMetricControlBase, ITKImageToImageMetricControlInterface); using ConcreteMetricType = TConcreteMetric; using ConcreteMetricPointer = typename ConcreteMetricType::Pointer; using MetricBaseType = typename Superclass::MetricBaseType; using SVMetricBaseType = typename Superclass::SVMetricBaseType; using ImageToImageMetricBaseType = typename Superclass::ImageToImageMetricBaseType; /*! setter for the optimizer @eguarantee no fail @param pMetric the ConcreteMetricType object that has to be set. Must not be NULL (otherwise an exception will be thrown). */ virtual void setMetric(ConcreteMetricType* pMetric); virtual MetricBaseType* getMetric(); virtual const MetricBaseType* getMetric() const; virtual SVMetricBaseType* getSVMetric(); virtual const SVMetricBaseType* getSVMetric() const; virtual ImageToImageMetricBaseType* getImageToImageMetric(); virtual const ImageToImageMetricBaseType* getImageToImageMetric() const; virtual ConcreteMetricType* getConcreteMetric(); virtual const ConcreteMetricType* getConcreteMetric() const; /*! The modification time (MT) of an metric controler is the the maximum of his MT * and the MT of the controlled metric. */ - virtual unsigned long GetMTime() const; + virtual ::itk::ModifiedTimeType GetMTime() const; protected: virtual ~ITKImageToImageMetricControlBase(); ITKImageToImageMetricControlBase(); ConcreteMetricPointer _spMetric; private: //No copy constructor allowed ITKImageToImageMetricControlBase(const Self& source); void operator=(const Self&); //purposely not implemented }; } // namespace itk } // namespace algorithm } // namespace map #ifndef MatchPoint_MANUAL_TPP #include "mapITKImageToImageMetricControlBase.tpp" #endif #endif diff --git a/Code/Algorithms/ITK/include/mapITKImageToImageMetricControlBase.tpp b/Code/Algorithms/ITK/include/mapITKImageToImageMetricControlBase.tpp index 74de717..a8010e1 100644 --- a/Code/Algorithms/ITK/include/mapITKImageToImageMetricControlBase.tpp +++ b/Code/Algorithms/ITK/include/mapITKImageToImageMetricControlBase.tpp @@ -1,146 +1,146 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __ITK_IMAGE_TO_IMAGE_METRIC_CONTROL_BASE_TPP #define __ITK_IMAGE_TO_IMAGE_METRIC_CONTROL_BASE_TPP #include "mapExceptionObjectMacros.h" namespace map { namespace algorithm { namespace itk { template void ITKImageToImageMetricControlBase:: setMetric(ConcreteMetricType* pMetric) { if (!pMetric) { mapDefaultExceptionMacro( << "Cannot set metric. Passed pointer to metric is NULL"); } _spMetric = pMetric; this->Modified(); } template - unsigned long + ::itk::ModifiedTimeType ITKImageToImageMetricControlBase:: GetMTime() const { - unsigned long mt = Superclass::GetMTime(); + auto mt = Superclass::GetMTime(); if (mt < _spMetric->GetMTime()) { mt = _spMetric->GetMTime(); } return mt; }; template typename ITKImageToImageMetricControlBase::MetricBaseType* ITKImageToImageMetricControlBase:: getMetric() { return _spMetric.GetPointer(); } template const typename ITKImageToImageMetricControlBase::MetricBaseType* ITKImageToImageMetricControlBase:: getMetric() const { return _spMetric.GetPointer(); } template typename ITKImageToImageMetricControlBase::SVMetricBaseType* ITKImageToImageMetricControlBase:: getSVMetric() { return _spMetric.GetPointer(); } template const typename ITKImageToImageMetricControlBase::SVMetricBaseType* ITKImageToImageMetricControlBase:: getSVMetric() const { return _spMetric.GetPointer(); } template typename ITKImageToImageMetricControlBase::ImageToImageMetricBaseType* ITKImageToImageMetricControlBase:: getImageToImageMetric() { return _spMetric.GetPointer(); } template const typename ITKImageToImageMetricControlBase::ImageToImageMetricBaseType* ITKImageToImageMetricControlBase:: getImageToImageMetric() const { return _spMetric; } template typename ITKImageToImageMetricControlBase::ConcreteMetricType* ITKImageToImageMetricControlBase:: getConcreteMetric() { return _spMetric; } template const typename ITKImageToImageMetricControlBase::ConcreteMetricType* ITKImageToImageMetricControlBase:: getConcreteMetric() const { return _spMetric; } template ITKImageToImageMetricControlBase:: ~ITKImageToImageMetricControlBase() { } template ITKImageToImageMetricControlBase:: ITKImageToImageMetricControlBase() { _spMetric = ConcreteMetricType::New(); } } // end namespace itk } // end namespace algorithm } // end namespace map #endif diff --git a/Code/Algorithms/ITK/include/mapITKMVNLOptimizerControlBase.h b/Code/Algorithms/ITK/include/mapITKMVNLOptimizerControlBase.h index 67935f1..c3fdf9e 100644 --- a/Code/Algorithms/ITK/include/mapITKMVNLOptimizerControlBase.h +++ b/Code/Algorithms/ITK/include/mapITKMVNLOptimizerControlBase.h @@ -1,133 +1,133 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __ITK_MVNL_OPTIMIZER_CONTROL_BASE_H #define __ITK_MVNL_OPTIMIZER_CONTROL_BASE_H #include "mapITKMVNLOptimizerControlInterface.h" namespace map { namespace algorithm { namespace itk { /*! @class ITKMVNLOptimizerControlBase This class serves as base class for all template specialization of itk optimizers that are single valued non linear optimizers. It realizes some basic optimizer handling, to reduce the code in the control classes @remark ITKOptimizerControl instantiates a concrete optimizer when constructed. You can set a new one, but ITKMVNLOptimizerControlBase has always an optimizer under control. @template TConcreteOptimizer type of the concrete optimizer controlled by the class @ingroup ITK @ingroup OptimizerControl */ template class ITKMVNLOptimizerControlBase : public ITKMVNLOptimizerControlInterface { public: typedef ITKMVNLOptimizerControlBase Self; typedef ITKMVNLOptimizerControlInterface Superclass; typedef ::itk::SmartPointer Pointer; typedef ::itk::SmartPointer ConstPointer; itkTypeMacro(ITKMVNLOptimizerControlBase, ITKMVNLOptimizerControlInterface); typedef TConcreteOptimizer ConcreteOptimizerType; typedef typename ConcreteOptimizerType::Pointer ConcreteOptimizerPointer; typedef ITKMVNLOptimizerControlInterface BaseInterfaceType; /*! setter for the optimizer @eguarantee no fail @param pOptimizer the OptimizerType object that has to be set. Must not be NULL (otherwise an exception will be thrown). */ virtual void setOptimizer(ConcreteOptimizerType* pOptimizer); virtual OptimizerBaseType* getOptimizer(); virtual const OptimizerBaseType* getOptimizer() const; virtual MVNLOptimizerBaseType* getMVNLOptimizer(); virtual const MVNLOptimizerBaseType* getMVNLOptimizer() const; virtual ConcreteOptimizerType* getConcreteOptimizer(); virtual const ConcreteOptimizerType* getConcreteOptimizer() const; /*! The modification time (MT) of an optimizer controler is the the maximum of his MT * and the MT of the controlled optimizer. */ - virtual unsigned long GetMTime() const; + virtual ::itk::ModifiedTimeType GetMTime() const; virtual bool hasCurrentPosition() const; virtual bool hasScales() const; /*! clones the optimizer control and the controlled optimizer. * This implementation generates an instance of ConcreteOptimizerType and uses * copyProperties() to transfer the settings. Reimplement copyProperties() to * realize special settings transfer. * @remark: The function guarantees that all settings of controlled optimizer * are cloned, but its optimization state must not be cloned as well. Thus the function * guarantees the same like instancing the same class again and transferring all properties * of the source instance to the destination instance via setter and getter. * @remark: It is a "deep" copy,so the controlled optimizer is a new instance as well. * @eguarantee strong * @remark Implement the function for special optimizer control classes. * @return Smartpointer to the cloned optimizer control.*/ virtual ITKOptimizerControlInterface::Pointer clone() const; protected: /*! Method is called by clone() to transfer the properties between the cloned * optimizer and the source. * @remark this base implementation copies the scales and the initial position.*/ virtual void copyProperties(const ConcreteOptimizerType* source, ConcreteOptimizerType* destination) const; /*! Method is called by clone() to clone the concrete control type derivated from this class. */ virtual Pointer doCloneControl() const = 0; virtual OptimizerPositionType doGetCurrentPosition() const; virtual OptimizerScalesType doGetScales() const; virtual ~ITKMVNLOptimizerControlBase(); ITKMVNLOptimizerControlBase(); ConcreteOptimizerPointer _spOptimizer; private: //No copy constructor allowed ITKMVNLOptimizerControlBase(const Self& source); void operator=(const Self&); //purposely not implemented }; } } } #ifndef MatchPoint_MANUAL_TPP #include "mapITKMVNLOptimizerControlBase.tpp" #endif #endif diff --git a/Code/Algorithms/ITK/include/mapITKMVNLOptimizerControlBase.tpp b/Code/Algorithms/ITK/include/mapITKMVNLOptimizerControlBase.tpp index 4affdcb..22f498b 100644 --- a/Code/Algorithms/ITK/include/mapITKMVNLOptimizerControlBase.tpp +++ b/Code/Algorithms/ITK/include/mapITKMVNLOptimizerControlBase.tpp @@ -1,188 +1,188 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __ITK_MVNL_OPTIMIZER_CONTROL_BASE_TPP #define __ITK_MVNL_OPTIMIZER_CONTROL_BASE_TPP #include "mapExceptionObjectMacros.h" namespace map { namespace algorithm { namespace itk { template void ITKMVNLOptimizerControlBase:: setOptimizer(ConcreteOptimizerType* pOptimizer) { if (!pOptimizer) { mapDefaultExceptionMacro( << "Cannot set optimizer. Passe pointer to optimizer is NULL"); } _spOptimizer = pOptimizer; this->Modified(); } template - unsigned long + ::itk::ModifiedTimeType ITKMVNLOptimizerControlBase:: GetMTime() const { - unsigned long mt = Superclass::GetMTime(); + auto mt = Superclass::GetMTime(); if (mt < _spOptimizer->GetMTime()) { mt = _spOptimizer->GetMTime(); } return mt; }; template bool ITKMVNLOptimizerControlBase:: hasCurrentPosition() const { return true; }; template typename ITKMVNLOptimizerControlBase::OptimizerPositionType ITKMVNLOptimizerControlBase:: doGetCurrentPosition() const { OptimizerPositionType result = _spOptimizer->GetCurrentPosition(); return result; }; template bool ITKMVNLOptimizerControlBase:: hasScales() const { return true; }; template typename ITKMVNLOptimizerControlBase::OptimizerScalesType ITKMVNLOptimizerControlBase:: doGetScales() const { OptimizerScalesType result = _spOptimizer->GetScales(); return result; }; template typename ITKMVNLOptimizerControlBase::MVNLOptimizerBaseType* ITKMVNLOptimizerControlBase:: getMVNLOptimizer() { return _spOptimizer.GetPointer(); }; template const typename ITKMVNLOptimizerControlBase::MVNLOptimizerBaseType* ITKMVNLOptimizerControlBase:: getMVNLOptimizer() const { return _spOptimizer.GetPointer(); }; template typename ITKMVNLOptimizerControlBase::OptimizerBaseType* ITKMVNLOptimizerControlBase:: getOptimizer() { return _spOptimizer.GetPointer(); }; template const typename ITKMVNLOptimizerControlBase::OptimizerBaseType* ITKMVNLOptimizerControlBase:: getOptimizer() const { return _spOptimizer.GetPointer(); }; template typename ITKMVNLOptimizerControlBase::ConcreteOptimizerType* ITKMVNLOptimizerControlBase:: getConcreteOptimizer() { return _spOptimizer.GetPointer(); }; template const typename ITKMVNLOptimizerControlBase::ConcreteOptimizerType* ITKMVNLOptimizerControlBase:: getConcreteOptimizer() const { return _spOptimizer.GetPointer(); }; template ITKOptimizerControlInterface::Pointer ITKMVNLOptimizerControlBase:: clone() const { Pointer spClone = this->doCloneControl(); this->copyProperties(_spOptimizer, spClone->getConcreteOptimizer()); ITKOptimizerControlInterface::Pointer spResult = spClone.GetPointer(); return spResult; }; template void ITKMVNLOptimizerControlBase:: copyProperties(const ConcreteOptimizerType* source, ConcreteOptimizerType* destination) const { destination->SetInitialPosition(source->GetInitialPosition()); destination->SetScales(source->GetScales()); destination->SetUseCostFunctionGradient(source->GetUseCostFunctionGradient()); }; template ITKMVNLOptimizerControlBase:: ~ITKMVNLOptimizerControlBase() { } template ITKMVNLOptimizerControlBase:: ITKMVNLOptimizerControlBase() { _spOptimizer = ConcreteOptimizerType::New(); } } // end namespace itk } // end namespace algorithm } // end namespace map #endif diff --git a/Code/Algorithms/ITK/include/mapITKPointSetToPointSetMetricControlBase.h b/Code/Algorithms/ITK/include/mapITKPointSetToPointSetMetricControlBase.h index 5429cb9..21be3c7 100644 --- a/Code/Algorithms/ITK/include/mapITKPointSetToPointSetMetricControlBase.h +++ b/Code/Algorithms/ITK/include/mapITKPointSetToPointSetMetricControlBase.h @@ -1,108 +1,108 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __ITK_POINTSET_TO_POINTSET_METRIC_CONTROL_BASE_H #define __ITK_POINTSET_TO_POINTSET_METRIC_CONTROL_BASE_H #include "mapITKPointSetToPointSetMetricControlInterface.h" namespace map { namespace algorithm { namespace itk { /*! @class ITKPointSetToPointSetMetricControlBase This class serves as base class for all template specialization of itk::PointSetToPointSetMetrics. It realizes some basic metric handling, to reduce the code in the control classes @remark ITKPointSetToPointSetMetricControlBase instantiates a concrete metric when constructed. You can set a new one, but ITKPointSetToPointSetMetricControlBase has always an optimizer under control. @template TConcreteMetric type of the concrete metric controlled by the class @ingroup ITK @ingroup MetricControl */ template class ITKPointSetToPointSetMetricControlBase : public ITKPointSetToPointSetMetricControlInterface { public: typedef ITKPointSetToPointSetMetricControlBase Self; typedef ITKPointSetToPointSetMetricControlInterface Superclass; typedef ::itk::SmartPointer Pointer; typedef ::itk::SmartPointer ConstPointer; itkTypeMacro(ITKPointSetToPointSetMetricControlBase, ITKPointSetToPointSetMetricControlInterface); typedef TConcreteMetric ConcreteMetricType; typedef typename ConcreteMetricType::Pointer ConcreteMetricPointer; typedef typename Superclass::MetricBaseType MetricBaseType; typedef typename Superclass::MVMetricBaseType MVMetricBaseType; typedef typename Superclass::PointSetToPointSetMetricBaseType PointSetToPointSetMetricBaseType; /*! setter for the optimizer @eguarantee no fail @param pMetric the ConcreteMetricType object that has to be set. Must not be NULL (otherwise an exception will be thrown). */ virtual void setMetric(ConcreteMetricType* pMetric); virtual MetricBaseType* getMetric(); virtual const MetricBaseType* getMetric() const; virtual MVMetricBaseType* getMVMetric(); virtual const MVMetricBaseType* getMVMetric() const; virtual PointSetToPointSetMetricBaseType* getPointSetToPointSetMetric(); virtual const PointSetToPointSetMetricBaseType* getPointSetToPointSetMetric() const; virtual ConcreteMetricType* getConcreteMetric(); virtual const ConcreteMetricType* getConcreteMetric() const; /*! The modification time (MT) of an metric controler is the the maximum of his MT * and the MT of the controlled metric. */ - virtual unsigned long GetMTime() const; + virtual ::itk::ModifiedTimeType GetMTime() const; protected: virtual ~ITKPointSetToPointSetMetricControlBase(); ITKPointSetToPointSetMetricControlBase(); ConcreteMetricPointer _spMetric; private: //No copy constructor allowed ITKPointSetToPointSetMetricControlBase(const Self& source); void operator=(const Self&); //purposely not implemented }; } } } #ifndef MatchPoint_MANUAL_TPP #include "mapITKPointSetToPointSetMetricControlBase.tpp" #endif #endif diff --git a/Code/Algorithms/ITK/include/mapITKPointSetToPointSetMetricControlBase.tpp b/Code/Algorithms/ITK/include/mapITKPointSetToPointSetMetricControlBase.tpp index 2dce330..90f6cbf 100644 --- a/Code/Algorithms/ITK/include/mapITKPointSetToPointSetMetricControlBase.tpp +++ b/Code/Algorithms/ITK/include/mapITKPointSetToPointSetMetricControlBase.tpp @@ -1,147 +1,147 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __ITK_POINTSET_TO_POINTSET_METRIC_CONTROL_BASE_TPP #define __ITK_POINTSET_TO_POINTSET_METRIC_CONTROL_BASE_TPP #include "mapExceptionObjectMacros.h" namespace map { namespace algorithm { namespace itk { template void ITKPointSetToPointSetMetricControlBase:: setMetric(ConcreteMetricType* pMetric) { if (!pMetric) { mapDefaultExceptionMacro( << "Cannot set metric. Passed pointer to metric is NULL"); } _spMetric = pMetric; this->Modified(); } template - unsigned long + ::itk::ModifiedTimeType ITKPointSetToPointSetMetricControlBase:: GetMTime() const { - unsigned long mt = Superclass::GetMTime(); + auto mt = Superclass::GetMTime(); if (mt < _spMetric->GetMTime()) { mt = _spMetric->GetMTime(); } return mt; }; template typename ITKPointSetToPointSetMetricControlBase::MetricBaseType* ITKPointSetToPointSetMetricControlBase:: getMetric() { return _spMetric.GetPointer(); } template const typename ITKPointSetToPointSetMetricControlBase::MetricBaseType* ITKPointSetToPointSetMetricControlBase:: getMetric() const { return _spMetric.GetPointer(); } template typename ITKPointSetToPointSetMetricControlBase::MVMetricBaseType* ITKPointSetToPointSetMetricControlBase:: getMVMetric() { return _spMetric.GetPointer(); } template const typename ITKPointSetToPointSetMetricControlBase::MVMetricBaseType* ITKPointSetToPointSetMetricControlBase:: getMVMetric() const { return _spMetric.GetPointer(); } template typename ITKPointSetToPointSetMetricControlBase::PointSetToPointSetMetricBaseType* ITKPointSetToPointSetMetricControlBase:: getPointSetToPointSetMetric() { return _spMetric.GetPointer(); } template const typename ITKPointSetToPointSetMetricControlBase::PointSetToPointSetMetricBaseType* ITKPointSetToPointSetMetricControlBase:: getPointSetToPointSetMetric() const { return _spMetric; } template typename ITKPointSetToPointSetMetricControlBase::ConcreteMetricType* ITKPointSetToPointSetMetricControlBase:: getConcreteMetric() { return _spMetric; } template const typename ITKPointSetToPointSetMetricControlBase::ConcreteMetricType* ITKPointSetToPointSetMetricControlBase:: getConcreteMetric() const { return _spMetric; } template ITKPointSetToPointSetMetricControlBase:: ~ITKPointSetToPointSetMetricControlBase() { } template ITKPointSetToPointSetMetricControlBase:: ITKPointSetToPointSetMetricControlBase() { _spMetric = ConcreteMetricType::New(); } } // end namespace itk } // end namespace algorithm } // end namespace map #endif diff --git a/Code/Algorithms/ITK/include/mapITKSVNLOptimizerControlBase.h b/Code/Algorithms/ITK/include/mapITKSVNLOptimizerControlBase.h index 967496b..647be3e 100644 --- a/Code/Algorithms/ITK/include/mapITKSVNLOptimizerControlBase.h +++ b/Code/Algorithms/ITK/include/mapITKSVNLOptimizerControlBase.h @@ -1,133 +1,133 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __ITK_SVNL_OPTIMIZER_CONTROL_BASE_H #define __ITK_SVNL_OPTIMIZER_CONTROL_BASE_H #include "mapITKSVNLOptimizerControlInterface.h" namespace map { namespace algorithm { namespace itk { /*! @class ITKSVNLOptimizerControlBase This class serves as base class for all template specialization of itk optimizers that are single valued non linear optimizers. It realizes some basic optimizer handling, to reduce the code in the control classes @remark ITKOptimizerControl instantiates a concrete optimizer when constructed. You can set a new one, but ITKSVNLOptimizerControlBase has always an optimizer under control. @template TConcreteOptimizer type of the concrete optimizer controlled by the class @ingroup ITK @ingroup OptimizerControl */ template class ITKSVNLOptimizerControlBase : public ITKSVNLOptimizerControlInterface { public: using Self = ITKSVNLOptimizerControlBase; using Superclass = ITKSVNLOptimizerControlInterface; using Pointer = ::itk::SmartPointer; using ConstPointer = ::itk::SmartPointer; itkTypeMacro(ITKSVNLOptimizerControlBase, ITKSVNLOptimizerControlInterface); using ConcreteOptimizerType = TConcreteOptimizer; using ConcreteOptimizerPointer = typename ConcreteOptimizerType::Pointer; using BaseInterfaceType = ITKSVNLOptimizerControlInterface; /*! setter for the optimizer @eguarantee no fail @param pOptimizer the OptimizerType object that has to be set. Must not be NULL (otherwise an exception will be thrown). */ virtual void setOptimizer(ConcreteOptimizerType* pOptimizer); OptimizerBaseType* getOptimizer() override; const OptimizerBaseType* getOptimizer() const override; SVNLOptimizerBaseType* getSVNLOptimizer() override; const SVNLOptimizerBaseType* getSVNLOptimizer() const override; virtual ConcreteOptimizerType* getConcreteOptimizer(); virtual const ConcreteOptimizerType* getConcreteOptimizer() const; /*! The modification time (MT) of an optimizer controler is the the maximum of his MT * and the MT of the controlled optimizer. */ - unsigned long GetMTime() const override; + ::itk::ModifiedTimeType GetMTime() const override; bool hasCurrentPosition() const override; bool hasScales() const override; /*! clones the optimizer control and the controlled optimizer. * This implementation generates an instance of ConcreteOptimizerType and uses * copyProperties() to transfer the settings. Reimplement copyProperties() to * realize special settings transfer. * @remark: The function guarantees that all settings of controlled optimizer * are cloned, but its optimization state must not be cloned as well. Thus the function * guarantees the same like instancing the same class again and transferring all properties * of the source instance to the destination instance via setter and getter. * @remark: It is a "deep" copy,so the controlled optimizer is a new instance as well. * @eguarantee strong * @remark Implement the function for special optimizer control classes. * @return Smartpointer to the cloned optimizer control.*/ ITKOptimizerControlInterface::Pointer clone() const override; protected: /*! Method is called by clone() to transfer the properties between the cloned * optimizer and the source. * @remark this base implementation copies the scales and the initial position.*/ virtual void copyProperties(const ConcreteOptimizerType* source, ConcreteOptimizerType* destination) const; /*! Method is called by clone() to clone the concrete control type derivated from this class. */ virtual Pointer doCloneControl() const = 0; OptimizerPositionType doGetCurrentPosition() const override; OptimizerScalesType doGetScales() const override; ~ITKSVNLOptimizerControlBase() override; ITKSVNLOptimizerControlBase(); ConcreteOptimizerPointer _spOptimizer; private: //No copy constructor allowed ITKSVNLOptimizerControlBase(const Self& source); void operator=(const Self&); //purposely not implemented }; } // namespace itk } // namespace algorithm } // namespace map #ifndef MatchPoint_MANUAL_TPP #include "mapITKSVNLOptimizerControlBase.tpp" #endif #endif diff --git a/Code/Algorithms/ITK/include/mapITKSVNLOptimizerControlBase.tpp b/Code/Algorithms/ITK/include/mapITKSVNLOptimizerControlBase.tpp index f4670bb..0f75e02 100644 --- a/Code/Algorithms/ITK/include/mapITKSVNLOptimizerControlBase.tpp +++ b/Code/Algorithms/ITK/include/mapITKSVNLOptimizerControlBase.tpp @@ -1,186 +1,186 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __ITK_SVNL_OPTIMIZER_CONTROL_BASE_TPP #define __ITK_SVNL_OPTIMIZER_CONTROL_BASE_TPP #include "mapExceptionObjectMacros.h" namespace map { namespace algorithm { namespace itk { template void ITKSVNLOptimizerControlBase:: setOptimizer(ConcreteOptimizerType* pOptimizer) { if (!pOptimizer) { mapDefaultExceptionMacro( << "Cannot set optimizer. Passe pointer to optimizer is NULL"); } _spOptimizer = pOptimizer; this->Modified(); } template - unsigned long + ::itk::ModifiedTimeType ITKSVNLOptimizerControlBase:: GetMTime() const { - unsigned long mt = Superclass::GetMTime(); + auto mt = Superclass::GetMTime(); if (mt < _spOptimizer->GetMTime()) { mt = _spOptimizer->GetMTime(); } return mt; }; template typename ITKSVNLOptimizerControlBase::SVNLOptimizerBaseType* ITKSVNLOptimizerControlBase:: getSVNLOptimizer() { return _spOptimizer.GetPointer(); }; template const typename ITKSVNLOptimizerControlBase::SVNLOptimizerBaseType* ITKSVNLOptimizerControlBase:: getSVNLOptimizer() const { return _spOptimizer.GetPointer(); }; template typename ITKSVNLOptimizerControlBase::OptimizerBaseType* ITKSVNLOptimizerControlBase:: getOptimizer() { return _spOptimizer.GetPointer(); }; template const typename ITKSVNLOptimizerControlBase::OptimizerBaseType* ITKSVNLOptimizerControlBase:: getOptimizer() const { return _spOptimizer.GetPointer(); }; template typename ITKSVNLOptimizerControlBase::ConcreteOptimizerType* ITKSVNLOptimizerControlBase:: getConcreteOptimizer() { return _spOptimizer.GetPointer(); }; template const typename ITKSVNLOptimizerControlBase::ConcreteOptimizerType* ITKSVNLOptimizerControlBase:: getConcreteOptimizer() const { return _spOptimizer.GetPointer(); }; template bool ITKSVNLOptimizerControlBase:: hasCurrentPosition() const { return true; }; template typename ITKSVNLOptimizerControlBase::OptimizerPositionType ITKSVNLOptimizerControlBase:: doGetCurrentPosition() const { OptimizerPositionType result = _spOptimizer->GetCurrentPosition(); return result; }; template bool ITKSVNLOptimizerControlBase:: hasScales() const { return true; }; template ITKOptimizerControlInterface::Pointer ITKSVNLOptimizerControlBase:: clone() const { Pointer spClone = this->doCloneControl(); this->copyProperties(_spOptimizer, spClone->getConcreteOptimizer()); ITKOptimizerControlInterface::Pointer spResult = spClone.GetPointer(); return spResult; }; template void ITKSVNLOptimizerControlBase:: copyProperties(const ConcreteOptimizerType* source, ConcreteOptimizerType* destination) const { destination->SetInitialPosition(source->GetInitialPosition()); destination->SetScales(source->GetScales()); }; template typename ITKSVNLOptimizerControlBase::OptimizerScalesType ITKSVNLOptimizerControlBase:: doGetScales() const { OptimizerScalesType result = _spOptimizer->GetScales(); return result; }; template ITKSVNLOptimizerControlBase:: ~ITKSVNLOptimizerControlBase() = default; template ITKSVNLOptimizerControlBase:: ITKSVNLOptimizerControlBase() { _spOptimizer = ConcreteOptimizerType::New(); } } // end namespace itk } // end namespace algorithm } // end namespace map #endif diff --git a/Code/Algorithms/ITK/include/mapSealedImageToImageMetricPolicy.h b/Code/Algorithms/ITK/include/mapSealedImageToImageMetricPolicy.h index 168347b..dcb5373 100644 --- a/Code/Algorithms/ITK/include/mapSealedImageToImageMetricPolicy.h +++ b/Code/Algorithms/ITK/include/mapSealedImageToImageMetricPolicy.h @@ -1,139 +1,139 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __SEALED_IMAGE_TO_IMAGE_METRIC_POLICY_H #define __SEALED_IMAGE_TO_IMAGE_METRIC_POLICY_H #include "mapITKMetricControl.h" #include "mapITKImageToImageMetricControlInterface.h" #include "itkCommand.h" namespace map { namespace algorithm { namespace itk { /*! @class SealedImageToImageMetricPolicy @brief class for SealedImageToImageMetricPolicy. This class is a SealedImageToImageMetricPolicy. It is used if an ITKImageRegistrationAlgorithm should have one specific metric type. With this policy the interpolator is never to be changed and sealed, so that the instance and its setting aren't public. @sa FixedImageToImageMetricPolicy @sa ArbitraryImageToImageMetricPolicy @ingroup ITKPolicies */ template class SealedImageToImageMetricPolicy { public: using Self = SealedImageToImageMetricPolicy; using ConcreteMetricType = TConcreteMetric; using ConcreteMetricControlType = ITKMetricControl; using ConcreteMetricControlPointer = typename ConcreteMetricControlType::Pointer; typedef ITKImageToImageMetricControlInterface MetricControlType; protected: SealedImageToImageMetricPolicy(); ~SealedImageToImageMetricPolicy(); /*! This is a command slot that can be used by any class derivering from this policy * to get informed if the component instances is changed. * @remark In the case of fixed policy (they don't allow the change of the instance, like this policy) * the command will invoke no event. The command is present because it is part of a general policy API that * allows policy using classes to interact in the same way with fixed and arbitrary policies. */ ::itk::Command::Pointer _spOnChange; /*! gets the internal metric @eguarantee strong @return a pointer to a metric type */ MetricControlType* getMetricInternal(); const MetricControlType* getMetricInternal() const; /*! gets the concrete interpolator @eguarantee strong @return a pointer to a ConcreteInterpolatorType object */ virtual const ConcreteMetricControlType* getConcreteMetricControl() const; /*! gets the concrete metric * @eguarantee strong * @return a pointer to a ConcreteMetricControlType object */ virtual ConcreteMetricControlType* getConcreteMetricControl(); /*! initializes the metric @eguarantee strong */ virtual void prepareMetric(); /*! initializes the metric * after it was integrated in a controlling structur (e.g. registration algorithm) @eguarantee strong */ virtual void prepareMetricAfterAssembly(); /*! Returns the modification time of the policy (and its controlled component). * In this case the modification time is a pass through of the internal component. @eguarantee strong @return the modification time */ - virtual unsigned long GetMTime() const; + virtual ::itk::ModifiedTimeType GetMTime() const; /*! This method can be used to indicate modification of the policy. */ void indicateModification() const; private: ConcreteMetricControlPointer _spMetric; /*! The time stamp is used to signal changes of the policy that may effect the controlling structur (e.g. registration algorithm) * because the initialization is going to change the intern object (e.g. prepareMetric() will change the settings of the metric)*/ mutable ::itk::TimeStamp _mTime; //No copy constructor allowed SealedImageToImageMetricPolicy(const Self& source); void operator=(const Self&); //purposely not implemented }; } // namespace itk } // namespace algorithm } // namespace map #ifndef MatchPoint_MANUAL_TPP #include "mapSealedImageToImageMetricPolicy.tpp" #endif #endif diff --git a/Code/Algorithms/ITK/include/mapSealedImageToImageMetricPolicy.tpp b/Code/Algorithms/ITK/include/mapSealedImageToImageMetricPolicy.tpp index c75ebc4..840e9f6 100644 --- a/Code/Algorithms/ITK/include/mapSealedImageToImageMetricPolicy.tpp +++ b/Code/Algorithms/ITK/include/mapSealedImageToImageMetricPolicy.tpp @@ -1,121 +1,121 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __SEALED_IMAGE_TO_IMAGE_METRIC_POLICY_TPP #define __SEALED_IMAGE_TO_IMAGE_METRIC_POLICY_TPP namespace map { namespace algorithm { namespace itk { template typename SealedImageToImageMetricPolicy::ConcreteMetricControlType* SealedImageToImageMetricPolicy:: getConcreteMetricControl() { return _spMetric; } template const typename SealedImageToImageMetricPolicy::ConcreteMetricControlType* SealedImageToImageMetricPolicy:: getConcreteMetricControl() const { return _spMetric; } template SealedImageToImageMetricPolicy:: SealedImageToImageMetricPolicy() { _spMetric = ConcreteMetricControlType::New(); } template SealedImageToImageMetricPolicy:: ~SealedImageToImageMetricPolicy() { } template typename SealedImageToImageMetricPolicy::MetricControlType* SealedImageToImageMetricPolicy:: getMetricInternal() { return _spMetric; } template const typename SealedImageToImageMetricPolicy::MetricControlType* SealedImageToImageMetricPolicy:: getMetricInternal() const { return _spMetric; } template void SealedImageToImageMetricPolicy:: prepareMetric() { //default implementation does nothing; } template void SealedImageToImageMetricPolicy:: prepareMetricAfterAssembly() { //default implementation does nothing; } template - unsigned long + ::itk::ModifiedTimeType SealedImageToImageMetricPolicy:: GetMTime() const { - unsigned long mt = _mTime.GetMTime(); + auto mt = _mTime.GetMTime(); if (mt < _spMetric->GetMTime()) { mt = _spMetric->GetMTime(); } return mt; }; template void SealedImageToImageMetricPolicy:: indicateModification() const { _mTime.Modified(); }; } // namespace itk } // end namespace algorithm } // end namespace map #endif diff --git a/Code/Algorithms/ITK/include/mapSealedInterpolatorPolicy.h b/Code/Algorithms/ITK/include/mapSealedInterpolatorPolicy.h index ffb6899..e95d2f5 100644 --- a/Code/Algorithms/ITK/include/mapSealedInterpolatorPolicy.h +++ b/Code/Algorithms/ITK/include/mapSealedInterpolatorPolicy.h @@ -1,140 +1,140 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __SEALED_INTERPOLATOR_POLICY_H #define __SEALED_INTERPOLATOR_POLICY_H #include "itkInterpolateImageFunction.h" #include "itkCommand.h" namespace map { namespace algorithm { namespace itk { /*! @class SealedInterpolatorPolicy @brief class for SealedInterpolatorPolicy. This class is a SealedInterpolatorPolicy. It is used if an ITKImageRegistrationAlgorithm should have one specific interpolator type. With this policy the metric is never to be changed and sealed, so that the instance and its setting aren't public. @sa FixedInterpolatorPolicy @sa ArbitraryInterpolatorPolicy @ingroup ITKPolicies */ template class SealedInterpolatorPolicy { public: using Self = SealedInterpolatorPolicy; using ConcreteInterpolatorType = TConcreteInterpolator; using ConcreteInterpolatorPointer = typename ConcreteInterpolatorType::Pointer; typedef ::itk::InterpolateImageFunction InterpolatorType; using CoordRepType = typename ConcreteInterpolatorType::CoordRepType; protected: SealedInterpolatorPolicy(); ~SealedInterpolatorPolicy(); /*! Returns the modification time of the policy (and its controlled component). * In this case the modification time is a pass through of the internal component. @eguarantee strong @return the modification time */ - virtual unsigned long GetMTime() const; + virtual ::itk::ModifiedTimeType GetMTime() const; /*! This method can be used to indicate modification of the policy (calls _mTime.Modify()). */ void indicateModification() const; /*! This is a command slot that can be used by any class derivering from this policy * to get informed if the component instances is changed. * @remark In the case of fixed policy (they don't allow the change of the instance, like this policy) * the command will invoke no event. The command is present because it is part of a general policy API that * allows policy using classes to interact in the same way with fixed and arbitrary policies. */ ::itk::Command::Pointer _spOnChange; /*! gets the internal interpolator @eguarantee strong @return a pointer to an interpolator type */ InterpolatorType* getInterpolatorInternal(); const InterpolatorType* getInterpolatorInternal() const; /*! gets the concrete interpolator @eguarantee strong @return a pointer to a ConcreteInterpolatorType object */ const ConcreteInterpolatorType* getConcreteInterpolator() const; /*! gets the concrete interpolator * @eguarantee strong * @return a pointer to a ConcreteInterpolatorType object */ ConcreteInterpolatorType* getConcreteInterpolator(); /*! initializes the interpolator @eguarantee strong */ virtual void prepareInterpolator(); /*! initializes the interpolator * after it was integrated in a controlling structur (e.g. registration algorithm) @eguarantee strong */ virtual void prepareInterpolatorAfterAssembly(); private: /*! The time stamp is used to signal changes of the policy that may effect the controlling structur (e.g. registration algorithm) * because the initialization is going to change the intern object (e.g. prepareMetric() will change the settings of the metric)*/ mutable ::itk::TimeStamp _mTime; ConcreteInterpolatorPointer _spInterpolator; //No copy constructor allowed SealedInterpolatorPolicy(const Self& source); void operator=(const Self&); //purposely not implemented }; } // namespace itk } // namespace algorithm } // namespace map #ifndef MatchPoint_MANUAL_TPP #include "mapSealedInterpolatorPolicy.tpp" #endif #endif diff --git a/Code/Algorithms/ITK/include/mapSealedInterpolatorPolicy.tpp b/Code/Algorithms/ITK/include/mapSealedInterpolatorPolicy.tpp index 42aa0ad..7b6cbf4 100644 --- a/Code/Algorithms/ITK/include/mapSealedInterpolatorPolicy.tpp +++ b/Code/Algorithms/ITK/include/mapSealedInterpolatorPolicy.tpp @@ -1,126 +1,126 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __SEALED_INTERPOLATOR_POLICY_TPP #define __SEALED_INTERPOLATOR_POLICY_TPP namespace map { namespace algorithm { namespace itk { template typename SealedInterpolatorPolicy::ConcreteInterpolatorType* SealedInterpolatorPolicy:: getConcreteInterpolator() { return _spInterpolator; }; template const typename SealedInterpolatorPolicy::ConcreteInterpolatorType* SealedInterpolatorPolicy:: getConcreteInterpolator() const { return _spInterpolator; }; template SealedInterpolatorPolicy:: SealedInterpolatorPolicy() { _spInterpolator = ConcreteInterpolatorType::New(); }; template SealedInterpolatorPolicy:: ~SealedInterpolatorPolicy() { }; template typename SealedInterpolatorPolicy::InterpolatorType* SealedInterpolatorPolicy:: getInterpolatorInternal() { return _spInterpolator; }; template const typename SealedInterpolatorPolicy::InterpolatorType* SealedInterpolatorPolicy:: getInterpolatorInternal() const { return _spInterpolator; }; template void SealedInterpolatorPolicy:: prepareInterpolator() { //default implementation does nothing; }; template void SealedInterpolatorPolicy:: prepareInterpolatorAfterAssembly() { //default implementation does nothing; }; template - unsigned long + ::itk::ModifiedTimeType SealedInterpolatorPolicy:: GetMTime() const { - unsigned long mt = _mTime.GetMTime(); + auto mt = _mTime.GetMTime(); if (mt < _spInterpolator->GetMTime()) { mt = _spInterpolator->GetMTime(); } return mt; }; template void SealedInterpolatorPolicy:: indicateModification() const { _mTime.Modified(); }; } // namespace itk } // end namespace algorithm } // end namespace map #endif diff --git a/Code/Algorithms/ITK/include/mapSealedOptimizerPolicy.h b/Code/Algorithms/ITK/include/mapSealedOptimizerPolicy.h index 8b69a9e..807a857 100644 --- a/Code/Algorithms/ITK/include/mapSealedOptimizerPolicy.h +++ b/Code/Algorithms/ITK/include/mapSealedOptimizerPolicy.h @@ -1,150 +1,150 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __SEALED_OPTIMIZER_POLICY_H #define __SEALED_OPTIMIZER_POLICY_H #include "mapITKOptimizerControl.h" #include "itkOptimizer.h" #include "itkCommand.h" namespace map { namespace algorithm { namespace itk { /*! @class SealedOptimizerPolicy @brief class for SealedOptimizerPolicy. This class is a SealedOptimizerPolicy. It is used if an ITKImageRegistrationAlgorithm should have one specific optimizer type. With this policy the optimizer is never to be changed and sealed, so that the instance and its setting aren't public. @sa FixedSVNLOptimizerPolicy @sa ArbitrarySVNLOptimizerPolicy @sa FixedMVNLOptimizerPolicy @sa ArbitraryMVNLOptimizerPolicy @ingroup ITKPolicies */ template class SealedOptimizerPolicy { public: using Self = SealedOptimizerPolicy; using ConcreteOptimizerType = TConcreteOptimizer; using ConcreteOptimizerPointer = typename ConcreteOptimizerType::Pointer; using OptimizerType = ::itk::Optimizer; using ConcreteOptimizerControlType = ITKOptimizerControl; using ConcreteOptimizerControlPointer = typename ConcreteOptimizerControlType::Pointer; using InternalOptimizerControlType = typename ConcreteOptimizerControlType::BaseInterfaceType; protected: SealedOptimizerPolicy(); ~SealedOptimizerPolicy(); /*! This is a command slot that can be used by any class deriving from this policy * to get informed if the component instances is changed. * @remark In the case of fixed policy (they don't allow the change of the instance, like this policy) * the command will invoke no event. The command is present because it is part of a general policy API that * allows policy using classes to interact in the same way with fixed and arbitrary policies. */ ::itk::Command::Pointer _spOnChange; /*! gets the internal optimizer @eguarantee strong @return a pointer to an OptimizerType object */ InternalOptimizerControlType* getOptimizerInternal(); const InternalOptimizerControlType* getOptimizerInternal() const; /*! gets the concrete optimizer control * @eguarantee strong * @return a pointer to a ConcreteOptimizerControlType object */ ConcreteOptimizerControlType* getConcreteOptimizerControl(); /*! gets the concrete optimizer control * @eguarantee strong * @return a pointer to a ConcreteOptimizerControlType object */ const ConcreteOptimizerControlType* getConcreteOptimizerControl() const; /*! gets the concrete wrapped optimizer * @eguarantee strong * @return a pointer to a ConcreteOptimizerType object */ ConcreteOptimizerType* getConcreteITKOptimizer(); /*! gets a concrete optimizer @eguarantee strong @return a pointer to a ConcreteOptimizerType object */ const ConcreteOptimizerType* getConcreteITKOptimizer() const; /*! initializes the optimizer Reimplement if you want to change the initialization of the optimizer in an algorithm. The default implementation does nothing. @eguarantee strong */ virtual void prepareOptimizer(); /*! initializes the optimizer * after it was integrated in a controlling structure (e.g. registration algorithm) @eguarantee strong */ virtual void prepareOptimizerAfterAssembly(bool minimizeToOptimize); /*! Returns the modification time of the policy (and its controlled component). * In this case the modification time is a pass through of the internal component. @eguarantee strong @return the modification time */ - virtual unsigned long GetMTime() const; + virtual ::itk::ModifiedTimeType GetMTime() const; /*! This method can be used to indicate modification of the policy. */ void indicateModification() const; private: /*! The time stamp is used to signal changes of the policy that may effect the controlling structur (e.g. registration algorithm) * because the initialization is going to change the intern object (e.g. prepareOptimizer() will change the settings of the optimizer)*/ mutable ::itk::TimeStamp _mTime; ConcreteOptimizerControlPointer _spOptimizerControl; //No copy constructor allowed SealedOptimizerPolicy(const Self& source); void operator=(const Self&); //purposely not implemented }; } // namespace itk } // namespace algorithm } // namespace map #ifndef MatchPoint_MANUAL_TPP #include "mapSealedOptimizerPolicy.tpp" #endif #endif diff --git a/Code/Algorithms/ITK/include/mapSealedOptimizerPolicy.tpp b/Code/Algorithms/ITK/include/mapSealedOptimizerPolicy.tpp index 5f722d6..0478e95 100644 --- a/Code/Algorithms/ITK/include/mapSealedOptimizerPolicy.tpp +++ b/Code/Algorithms/ITK/include/mapSealedOptimizerPolicy.tpp @@ -1,136 +1,136 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __SEALED_OPTIMIZER_POLICY_TPP #define __SEALED_OPTIMIZER_POLICY_TPP namespace map { namespace algorithm { namespace itk { template typename SealedOptimizerPolicy::ConcreteOptimizerType* SealedOptimizerPolicy:: getConcreteITKOptimizer() { return _spOptimizerControl->getConcreteOptimizer(); }; template const typename SealedOptimizerPolicy::ConcreteOptimizerType* SealedOptimizerPolicy:: getConcreteITKOptimizer() const { return _spOptimizerControl->getConcreteOptimizer(); }; template const typename SealedOptimizerPolicy::ConcreteOptimizerControlType* SealedOptimizerPolicy:: getConcreteOptimizerControl() const { return _spOptimizerControl; }; template typename SealedOptimizerPolicy::ConcreteOptimizerControlType* SealedOptimizerPolicy:: getConcreteOptimizerControl() { return _spOptimizerControl; }; template SealedOptimizerPolicy:: SealedOptimizerPolicy() { _spOptimizerControl = ConcreteOptimizerControlType::New(); }; template SealedOptimizerPolicy:: ~SealedOptimizerPolicy() {}; template typename SealedOptimizerPolicy::InternalOptimizerControlType* SealedOptimizerPolicy:: getOptimizerInternal() { return _spOptimizerControl; }; template const typename SealedOptimizerPolicy::InternalOptimizerControlType* SealedOptimizerPolicy:: getOptimizerInternal() const { return _spOptimizerControl; }; template void SealedOptimizerPolicy:: prepareOptimizer() { //default implementation does nothing; }; template void SealedOptimizerPolicy:: prepareOptimizerAfterAssembly(bool minimizeToOptimize) { _spOptimizerControl->setMinimize(minimizeToOptimize); }; template - unsigned long + ::itk::ModifiedTimeType SealedOptimizerPolicy:: GetMTime() const { - unsigned long mt = _mTime.GetMTime(); + auto mt = _mTime.GetMTime(); if (mt < _spOptimizerControl->GetMTime()) { mt = _spOptimizerControl->GetMTime(); } return mt; }; template void SealedOptimizerPolicy:: indicateModification() const { _mTime.Modified(); }; } // end namespace itk } // end namespace algorithm } // end namespace map #endif diff --git a/Code/Algorithms/ITK/include/mapSealedPointSetToPointSetMetricPolicy.h b/Code/Algorithms/ITK/include/mapSealedPointSetToPointSetMetricPolicy.h index e7062fe..f7748af 100644 --- a/Code/Algorithms/ITK/include/mapSealedPointSetToPointSetMetricPolicy.h +++ b/Code/Algorithms/ITK/include/mapSealedPointSetToPointSetMetricPolicy.h @@ -1,139 +1,139 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __SEALED_POINT_SET_TO_POINT_SET_METRIC_POLICY_H #define __SEALED_POINT_SET_TO_POINT_SET_METRIC_POLICY_H #include "mapITKMetricControl.h" #include "mapITKPointSetToPointSetMetricControlInterface.h" #include "itkCommand.h" namespace map { namespace algorithm { namespace itk { /*! @class SealedPointSetToPointSetMetricPolicy @brief class for SealedPointSetToPointSetMetricPolicy. This class is a SealedPointSetToPointSetMetricPolicy. It is used if an ITK registration algorithm should have one specific metric type. With this policy the interpolater is never to be changed and sealed, so that the instance and its setting aren't public. @sa FixedPointSetToPointSetMetricPolicy @sa ArbitraryPointSetToPointSetMetricPolicy @ingroup ITKPolicies */ template class SealedPointSetToPointSetMetricPolicy { public: typedef SealedPointSetToPointSetMetricPolicy Self; typedef TConcreteMetric ConcreteMetricType; typedef ITKMetricControl ConcreteMetricControlType; typedef typename ConcreteMetricControlType::Pointer ConcreteMetricControlPointer; typedef ITKPointSetToPointSetMetricControlInterface MetricControlType; protected: SealedPointSetToPointSetMetricPolicy(); ~SealedPointSetToPointSetMetricPolicy(); /*! This is a command slot that can be used by any class derivering from this policy * to get informed if the component instances is changed. * @remark In the case of fixed policy (they don't allow the change of the instance, like this policy) * the command will invoke no event. The command is present because it is part of a general policy API that * allows policy using classes to interact in the same way with fixed and arbitrary policies. */ ::itk::Command::Pointer _spOnChange; /*! gets the internal metric @eguarantee strong @return a pointer to a metric type */ MetricControlType* getMetricInternal(); const MetricControlType* getMetricInternal() const; /*! gets the concrete interpolator @eguarantee strong @return a pointer to a ConcreteInterpolatorType object */ virtual const ConcreteMetricControlType* getConcreteMetricControl() const; /*! gets the concrete metric * @eguarantee strong * @return a pointer to a ConcreteMetricControlType object */ virtual ConcreteMetricControlType* getConcreteMetricControl(); /*! initializes the metric @eguarantee strong */ virtual void prepareMetric(); /*! initializes the metric * after it was integrated in a controlling structur (e.g. registration algorithm) @eguarantee strong */ virtual void prepareMetricAfterAssembly(); /*! Returns the modification time of the policy (and its controlled component). * In this case the modification time is a pass through of the internal component. @eguarantee strong @return the modification time */ - virtual unsigned long GetMTime() const; + virtual ::itk::ModifiedTimeType GetMTime() const; /*! This method can be used to indicate modification of the policy. */ void indicateModification() const; private: ConcreteMetricControlPointer _spMetric; /*! The time stamp is used to signal changes of the policy that may effect the controlling structur (e.g. registration algorithm) * because the initialization is going to change the intern object (e.g. prepareMetric() will change the settings of the metric)*/ mutable ::itk::TimeStamp _mTime; //No copy constructor allowed SealedPointSetToPointSetMetricPolicy(const Self& source); void operator=(const Self&); //purposely not implemented }; } } } #ifndef MatchPoint_MANUAL_TPP #include "mapSealedPointSetToPointSetMetricPolicy.tpp" #endif #endif diff --git a/Code/Algorithms/ITK/include/mapSealedPointSetToPointSetMetricPolicy.tpp b/Code/Algorithms/ITK/include/mapSealedPointSetToPointSetMetricPolicy.tpp index 2d16099..aeea224 100644 --- a/Code/Algorithms/ITK/include/mapSealedPointSetToPointSetMetricPolicy.tpp +++ b/Code/Algorithms/ITK/include/mapSealedPointSetToPointSetMetricPolicy.tpp @@ -1,121 +1,121 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __SEALED_POINT_SET_TO_POINT_SET_METRIC_POLICY_TPP #define __SEALED_POINT_SET_TO_POINT_SET_METRIC_POLICY_TPP namespace map { namespace algorithm { namespace itk { template typename SealedPointSetToPointSetMetricPolicy::ConcreteMetricControlType* SealedPointSetToPointSetMetricPolicy:: getConcreteMetricControl() { return _spMetric; } template const typename SealedPointSetToPointSetMetricPolicy::ConcreteMetricControlType* SealedPointSetToPointSetMetricPolicy:: getConcreteMetricControl() const { return _spMetric; } template SealedPointSetToPointSetMetricPolicy:: SealedPointSetToPointSetMetricPolicy() { _spMetric = ConcreteMetricControlType::New(); } template SealedPointSetToPointSetMetricPolicy:: ~SealedPointSetToPointSetMetricPolicy() { } template typename SealedPointSetToPointSetMetricPolicy::MetricControlType* SealedPointSetToPointSetMetricPolicy:: getMetricInternal() { return _spMetric; } template const typename SealedPointSetToPointSetMetricPolicy::MetricControlType* SealedPointSetToPointSetMetricPolicy:: getMetricInternal() const { return _spMetric; } template void SealedPointSetToPointSetMetricPolicy:: prepareMetric() { //default implementation does nothing; } template void SealedPointSetToPointSetMetricPolicy:: prepareMetricAfterAssembly() { //default implementation does nothing; } template - unsigned long + ::itk::ModifiedTimeType SealedPointSetToPointSetMetricPolicy:: GetMTime() const { - unsigned long mt = _mTime.GetMTime(); + auto mt = _mTime.GetMTime(); if (mt < _spMetric->GetMTime()) { mt = _spMetric->GetMTime(); } return mt; }; template void SealedPointSetToPointSetMetricPolicy:: indicateModification() const { _mTime.Modified(); }; } } // end namespace algorithm } // end namespace map #endif diff --git a/Code/Algorithms/ITK/include/mapSealedTransformPolicy.h b/Code/Algorithms/ITK/include/mapSealedTransformPolicy.h index 2033d1b..eadb00f 100644 --- a/Code/Algorithms/ITK/include/mapSealedTransformPolicy.h +++ b/Code/Algorithms/ITK/include/mapSealedTransformPolicy.h @@ -1,139 +1,139 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __SEALED_TRANSFORM_POLICY_H #define __SEALED_TRANSFORM_POLICY_H #include "itkCommand.h" #include "itkTransform.h" namespace map { namespace algorithm { namespace itk { /*! @class SealedTransformPolicy @brief class for SealedTransformPolicy. This class is a SealedTransformPolicy. It is used if an ITKImageRegistrationAlgorithm should have one specific transform model type. With this policy the transform model is never to be changed and sealed, so that the instance and its setting aren't public. @sa ArbitraryTransformPolicy @sa FixedTransformPolicy @ingroup ITKPolicies */ template class SealedTransformPolicy { public: using Self = SealedTransformPolicy; using ConcreteTransformType = TConcreteITKTransform; using ConcreteTransformPointer = typename ConcreteTransformType::Pointer; typedef ::itk::Transform TransformType; using TransformScalarType = typename TransformType::ScalarType; protected: SealedTransformPolicy(); ~SealedTransformPolicy(); /*! This is a command slot that can be used by any class derivering from this policy * to get informed if the component instances is changed. * @remark In the case of fixed policy (they don't allow the change of the instance, like this policy) * the command will invoke no event. The command is present because it is part of a general policy API that * allows policy using classes to interact in the same way with fixed and arbitrary policies. */ ::itk::Command::Pointer _spOnChange; /*! gets the internal transform @eguarantee strong @return a pointer to an transform type */ TransformType* getTransformInternal(); const TransformType* getTransformInternal() const; /*! gets the concrete transform * @eguarantee strong * @return a pointer to a ConcreteTransformType object */ ConcreteTransformType* getConcreteTransformModel(); /*! gets the concrete transform @eguarantee strong @return a pointer to a ConcreteTransformType object */ const ConcreteTransformType* getConcreteTransformModel() const; /*! initializes the transform @eguarantee strong */ virtual void prepareTransform(); /*! initializes the transform * after it was integrated in a controlling structur (e.g. registration algorithm) @eguarantee strong */ virtual void prepareTransformAfterAssembly(); /*! Returns the modification time of the policy (and its controlled component). * In this case the modification time is a pass through of the internal component. @eguarantee strong @return the modification time */ - virtual unsigned long GetMTime() const; + virtual ::itk::ModifiedTimeType GetMTime() const; /*! This method can be used to indicate modification of the policy. */ void indicateModification() const; private: /*! The time stamp is used to signal changes of the policy that may effect the controlling structur (e.g. registration algorithm) * because the controlled object has changed.*/ mutable ::itk::TimeStamp _mTime; ConcreteTransformPointer _spTransformModel; //No copy constructor allowed SealedTransformPolicy(const Self& source); void operator=(const Self&); //purposely not implemented }; } // namespace itk } // namespace algorithm } // namespace map #ifndef MatchPoint_MANUAL_TPP #include "mapSealedTransformPolicy.tpp" #endif #endif diff --git a/Code/Algorithms/ITK/include/mapSealedTransformPolicy.tpp b/Code/Algorithms/ITK/include/mapSealedTransformPolicy.tpp index 5915663..58a96bc 100644 --- a/Code/Algorithms/ITK/include/mapSealedTransformPolicy.tpp +++ b/Code/Algorithms/ITK/include/mapSealedTransformPolicy.tpp @@ -1,122 +1,122 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __SEALED_TRANSFORM_POLICY_TPP #define __SEALED_TRANSFORM_POLICY_TPP namespace map { namespace algorithm { namespace itk { template typename SealedTransformPolicy::ConcreteTransformType* SealedTransformPolicy:: getConcreteTransformModel() { return _spTransformModel; } template const typename SealedTransformPolicy::ConcreteTransformType* SealedTransformPolicy:: getConcreteTransformModel() const { return _spTransformModel; } template SealedTransformPolicy:: SealedTransformPolicy() { _spTransformModel = ConcreteTransformType::New(); }; template SealedTransformPolicy:: ~SealedTransformPolicy() { }; template typename SealedTransformPolicy::TransformType* SealedTransformPolicy:: getTransformInternal() { return _spTransformModel; } template const typename SealedTransformPolicy::TransformType* SealedTransformPolicy:: getTransformInternal() const { return _spTransformModel; } template void SealedTransformPolicy:: prepareTransform() { //default implementation does nothing; }; template void SealedTransformPolicy:: prepareTransformAfterAssembly() { //default implementation does nothing; }; template - unsigned long + ::itk::ModifiedTimeType SealedTransformPolicy:: GetMTime() const { - unsigned long mt = _mTime.GetMTime(); + auto mt = _mTime.GetMTime(); if (mt < _spTransformModel->GetMTime()) { mt = _spTransformModel->GetMTime(); } return mt; }; template void SealedTransformPolicy:: indicateModification() const { _mTime.Modified(); }; } // end namespace itk } // end namespace algorithm } // end namespace map #endif diff --git a/Code/Algorithms/ITK/source/mapArbitraryMVNLOptimizerPolicy.cpp b/Code/Algorithms/ITK/source/mapArbitraryMVNLOptimizerPolicy.cpp index e95fbb6..7918a72 100644 --- a/Code/Algorithms/ITK/source/mapArbitraryMVNLOptimizerPolicy.cpp +++ b/Code/Algorithms/ITK/source/mapArbitraryMVNLOptimizerPolicy.cpp @@ -1,154 +1,154 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #include "mapArbitraryMVNLOptimizerPolicy.h" #include "mapAlgorithmEvents.h" namespace map { namespace algorithm { namespace itk { - unsigned long + ::itk::ModifiedTimeType ArbitraryMVNLOptimizerPolicy:: GetMTime() const { - unsigned long mt = _mTime.getMTime(); + auto mt = _mTime.getMTime(); return mt; }; void ArbitraryMVNLOptimizerPolicy:: setAutomaticOptimizationDirection(bool automatic) { _automaticOptimizationDirection = automatic; }; bool ArbitraryMVNLOptimizerPolicy:: getAutomaticOptimizationDirection() const { return _automaticOptimizationDirection; }; void ArbitraryMVNLOptimizerPolicy:: setITKOptimizerControl(ITKOptimizerControlType* pOptimizer) { if (pOptimizer != _spOptimizerControl.GetPointer()) { //there is really the need to change the optimizer if (this->_spOnChange.IsNotNull()) { ::map::events::UnregisterAlgorithmComponentEvent unRegEvent(_spOptimizerControl.GetPointer(), "Unregister current optimizer"); this->_spOnChange->Execute((::itk::Object*)nullptr, unRegEvent); } _mTime.setWatchedObject(pOptimizer); _spOptimizerControl = pOptimizer; if (this->_spOnChange.IsNotNull()) { ::map::events::RegisterAlgorithmComponentEvent regEvent(_spOptimizerControl.GetPointer(), "Register new optimizer"); this->_spOnChange->Execute((::itk::Object*)nullptr, regEvent); } } }; ArbitraryMVNLOptimizerPolicy:: ArbitraryMVNLOptimizerPolicy() { }; ArbitraryMVNLOptimizerPolicy:: ~ArbitraryMVNLOptimizerPolicy() = default; ArbitraryMVNLOptimizerPolicy::ITKOptimizerControlType* ArbitraryMVNLOptimizerPolicy:: getOptimizerInternal() { return _spOptimizerControl; } const ArbitraryMVNLOptimizerPolicy::ITKOptimizerControlType* ArbitraryMVNLOptimizerPolicy:: getOptimizerInternal() const { return _spOptimizerControl; } ArbitraryMVNLOptimizerPolicy::ITKOptimizerControlType* ArbitraryMVNLOptimizerPolicy:: getITKOptimizerControl() { return _spOptimizerControl; } const ArbitraryMVNLOptimizerPolicy::ITKOptimizerControlType* ArbitraryMVNLOptimizerPolicy:: getITKOptimizerControl() const { return _spOptimizerControl; } ArbitraryMVNLOptimizerPolicy::OptimizerControlType* ArbitraryMVNLOptimizerPolicy:: getOptimizerControl() { return _spOptimizerControl; } const ArbitraryMVNLOptimizerPolicy::OptimizerControlType* ArbitraryMVNLOptimizerPolicy:: getOptimizerControl() const { return _spOptimizerControl; } void ArbitraryMVNLOptimizerPolicy:: prepareOptimizer() { //default implementation does nothing; }; void ArbitraryMVNLOptimizerPolicy:: prepareOptimizerAfterAssembly(bool minimizeToOptimize) { if (_automaticOptimizationDirection) { _spOptimizerControl->setMinimize(minimizeToOptimize); } }; } // namespace itk } // namespace algorithm } // namespace map \ No newline at end of file diff --git a/Code/Algorithms/ITK/source/mapArbitrarySVNLOptimizerPolicy.cpp b/Code/Algorithms/ITK/source/mapArbitrarySVNLOptimizerPolicy.cpp index 90a1cb9..9368aa2 100644 --- a/Code/Algorithms/ITK/source/mapArbitrarySVNLOptimizerPolicy.cpp +++ b/Code/Algorithms/ITK/source/mapArbitrarySVNLOptimizerPolicy.cpp @@ -1,154 +1,154 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #include "mapArbitrarySVNLOptimizerPolicy.h" #include "mapAlgorithmEvents.h" namespace map { namespace algorithm { namespace itk { - unsigned long + ::itk::ModifiedTimeType ArbitrarySVNLOptimizerPolicy:: GetMTime() const { - unsigned long mt = _mTime.getMTime(); + auto mt = _mTime.getMTime(); return mt; }; void ArbitrarySVNLOptimizerPolicy:: setAutomaticOptimizationDirection(bool automatic) { _automaticOptimizationDirection = automatic; }; bool ArbitrarySVNLOptimizerPolicy:: getAutomaticOptimizationDirection() const { return _automaticOptimizationDirection; }; void ArbitrarySVNLOptimizerPolicy:: setITKOptimizerControl(ITKOptimizerControlType* pOptimizer) { if (pOptimizer != _spOptimizerControl.GetPointer()) { //there is really the need to change the optimizer if (this->_spOnChange.IsNotNull()) { ::map::events::UnregisterAlgorithmComponentEvent unRegEvent(_spOptimizerControl.GetPointer(), "Unregister current optimizer"); this->_spOnChange->Execute((::itk::Object*)nullptr, unRegEvent); } _mTime.setWatchedObject(pOptimizer); _spOptimizerControl = pOptimizer; if (this->_spOnChange.IsNotNull()) { ::map::events::RegisterAlgorithmComponentEvent regEvent(_spOptimizerControl.GetPointer(), "Register new optimizer"); this->_spOnChange->Execute((::itk::Object*)nullptr, regEvent); } } }; ArbitrarySVNLOptimizerPolicy:: ArbitrarySVNLOptimizerPolicy() { }; ArbitrarySVNLOptimizerPolicy:: ~ArbitrarySVNLOptimizerPolicy() = default; ArbitrarySVNLOptimizerPolicy::ITKOptimizerControlType* ArbitrarySVNLOptimizerPolicy:: getOptimizerInternal() { return _spOptimizerControl; } const ArbitrarySVNLOptimizerPolicy::ITKOptimizerControlType* ArbitrarySVNLOptimizerPolicy:: getOptimizerInternal() const { return _spOptimizerControl; } ArbitrarySVNLOptimizerPolicy::ITKOptimizerControlType* ArbitrarySVNLOptimizerPolicy:: getITKOptimizerControl() { return _spOptimizerControl; } const ArbitrarySVNLOptimizerPolicy::ITKOptimizerControlType* ArbitrarySVNLOptimizerPolicy:: getITKOptimizerControl() const { return _spOptimizerControl; } ArbitrarySVNLOptimizerPolicy::OptimizerControlType* ArbitrarySVNLOptimizerPolicy:: getOptimizerControl() { return _spOptimizerControl; } const ArbitrarySVNLOptimizerPolicy::OptimizerControlType* ArbitrarySVNLOptimizerPolicy:: getOptimizerControl() const { return _spOptimizerControl; } void ArbitrarySVNLOptimizerPolicy:: prepareOptimizer() { //default implementation does nothing; }; void ArbitrarySVNLOptimizerPolicy:: prepareOptimizerAfterAssembly(bool minimizeToOptimize) { if (_automaticOptimizationDirection) { _spOptimizerControl->setMinimize(minimizeToOptimize); } }; } // namespace itk } // namespace algorithm } // namespace map \ No newline at end of file diff --git a/Code/Algorithms/Plastimatch/include/mapPlmCLIRegistrationAlgorithmBase.h b/Code/Algorithms/Plastimatch/include/mapPlmCLIRegistrationAlgorithmBase.h index a6e17b7..82d1f1e 100644 --- a/Code/Algorithms/Plastimatch/include/mapPlmCLIRegistrationAlgorithmBase.h +++ b/Code/Algorithms/Plastimatch/include/mapPlmCLIRegistrationAlgorithmBase.h @@ -1,425 +1,425 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __MAP_PLM_CLI_REGISTRATION_ALGORITHM_BASE_H #define __MAP_PLM_CLI_REGISTRATION_ALGORITHM_BASE_H //MatchPoint #include "mapContinuous.h" #include "mapIterativeRegistrationAlgorithm.h" #include "mapImageRegistrationAlgorithmBase.h" #include "mapClassMacros.h" #include "mapPlmAlgorithmHelper.h" #include "mapMetaPropertyAlgorithmBase.h" #include "mapMaskedRegistrationAlgorithmBase.h" #include "mapPointSetRegistrationAlgorithmInterfaceV2.h" #include "mapGenericVectorFieldTransform.h" namespace map { namespace algorithm { namespace plastimatch { /*! @class CLIRegistrationAlgorithmBase @brief This is the base class for algorithms that serve as a wrapper for the registration tool "plastimatch". The algorithm is a very simple wrapper using a command line interface to facilitate plastimatch. For a registration task a temporary working directory is generated, where the algorithm stores the given moving and target image. Then the algorithms calls 'plastimatch' with appropriated command line arguments to trigger the registration as an external process and to produce a deformation field as output. This field will be loaded, converted into a MatchPoint registration object and returned. After the registration job is done, the temporary directory will be deleted by the algorithm. @remark @ingroup Algorithms @ingroup Plastimatch */ template class CLIRegistrationAlgorithmBase : public IterativeRegistrationAlgorithm, public ImageRegistrationAlgorithmBase, public MetaPropertyAlgorithmBase, public MaskedRegistrationAlgorithmBase, public facet::PointSetRegistrationAlgorithmInterfaceV2, public TIdentificationPolicy { public: typedef CLIRegistrationAlgorithmBase Self; typedef IterativeRegistrationAlgorithm Superclass; typedef ::itk::SmartPointer Pointer; typedef ::itk::SmartPointer ConstPointer; itkTypeMacro(CLIRegistrationAlgorithmBase, IterativeRegistrationAlgorithm); typedef typename Superclass::UIDType UIDType; typedef typename Superclass::UIDPointer UIDPointer; typedef typename IterativeRegistrationAlgorithm::OptimizerMeasureType OptimizerMeasureType; typedef ImageRegistrationAlgorithmBase ImageRegistrationAlgorithmBaseType; typedef typename ImageRegistrationAlgorithmBaseType::TargetImageType TargetImageType; typedef typename ImageRegistrationAlgorithmBaseType::MovingImageType MovingImageType; typedef typename Superclass::MovingRepresentationDescriptorType MovingRepresentationDescriptorType; typedef typename Superclass::TargetRepresentationDescriptorType TargetRepresentationDescriptorType; typedef typename Superclass::RegistrationPointer RegistrationPointer; typedef typename Superclass::RegistrationType RegistrationType; typedef typename Superclass::FieldRepRequirement FieldRepRequirement; typedef facet::PointSetRegistrationAlgorithmInterfaceV2 PointSetInterfaceType; typedef typename PointSetInterfaceType::MovingPointSetConstPointer MovingPointSetConstPointer; typedef typename PointSetInterfaceType::TargetPointSetConstPointer TargetPointSetConstPointer; typedef typename PointSetInterfaceType::SlotIndexType SlotIndexType; typedef typename PointSetInterfaceType::MovingPointSetType MovingPointSetType; typedef typename PointSetInterfaceType::TargetPointSetType TargetPointSetType; typedef typename MetaPropertyAlgorithmBase::MetaPropertyType MetaPropertyType; typedef typename MetaPropertyAlgorithmBase::MetaPropertyPointer MetaPropertyPointer; typedef typename MetaPropertyAlgorithmBase::MetaPropertyNameType MetaPropertyNameType; mapDefineAlgorithmIdentificationByPolicyMacro; // IterativeRegistrationAlgorithm /*! @eguarantee strong*/ virtual bool isStoppable() const; /*! has the algorithm an iteration count? @eguarantee no fail @return Indicates if the algorithm can determin its current iteration count */ virtual bool hasIterationCount() const; /*! has the algorithm an maximum iteration count? @eguarantee no fail @return Indicates if the algorithm can determin its maximum iteration count */ virtual bool hasMaxIterationCount() const; /*! This function indicates if the optimizer of the iterative registration algorithm is * able to return its current metric/optimizer value(s)? @eguarantee no fail @return Indicates if the algorithm can determin its curent value. */ virtual bool hasCurrentOptimizerValue() const; virtual typename FieldRepRequirement::Type isMovingRepresentationRequired() const; virtual typename FieldRepRequirement::Type isTargetRepresentationRequired() const; /*! @reimplemented */ virtual bool isReusable() const; mapGetMetaMacro(WorkingDirectory, core::String); mapSetMetaMacro(WorkingDirectory, core::String); mapGetMetaMacro(PlastimatchDirectory, core::String); mapSetMetaMacro(PlastimatchDirectory, core::String); mapGetMetaMacro(DeleteTempDirectory, bool); mapSetMetaMacro(DeleteTempDirectory, bool); virtual bool hasCoupledPointSetInputs() const override { return true; }; virtual bool isOptionalTargetPointSet(SlotIndexType index) const override { return true; }; virtual bool isOptionalMovingPointSet(SlotIndexType index) const override { return true; }; virtual SlotIndexType getTargetPointSetCount(bool onlyMandatory = false) const override { if (onlyMandatory) return 0; return 1; }; virtual SlotIndexType getMovingPointSetCount(bool onlyMandatory = false) const override { if (onlyMandatory) return 0; return 1; }; - virtual unsigned long getNthTargetPointSetMTime(SlotIndexType index) const override; + virtual ::itk::ModifiedTimeType getNthTargetPointSetMTime(SlotIndexType index) const override; - virtual unsigned long getNthMovingPointSetMTime(SlotIndexType index) const override; + virtual ::itk::ModifiedTimeType getNthMovingPointSetMTime(SlotIndexType index) const override; protected: CLIRegistrationAlgorithmBase(); virtual ~CLIRegistrationAlgorithmBase(); typedef typename Superclass::InterimRegistrationType InterimRegistrationType; typedef typename Superclass::InterimRegistrationPointer InterimRegistrationPointer; typedef typename Superclass::IterationCountType IterationCountType; typedef typename ImageRegistrationAlgorithmBaseType::MovingImageConstPointer MovingImageConstPointer; typedef typename ImageRegistrationAlgorithmBaseType::TargetImageConstPointer TargetImageConstPointer; typedef ::itk::GenericVectorFieldTransform< ::map::core::continuous::ScalarType, TTargetImage::ImageDimension, TTargetImage::ImageDimension> FieldTransformType; typedef typename map::core::RegistrationTopology::InverseFieldType FinalFieldType; typedef typename FinalFieldType::Pointer FinalFieldPointer; /* @reimplemented*/ virtual void configureAlgorithm(); // MetaPropertyAlgorithmBase /*! @reimplemented*/ virtual void compileInfos(MetaPropertyVectorType& infos) const; /*! @reimplemented*/ virtual MetaPropertyPointer doGetProperty(const MetaPropertyNameType& name) const; /*! @reimplemented*/ virtual void doSetProperty(const MetaPropertyNameType& name, const MetaPropertyType* pProperty); // IterativeRegistrationAlgorithmInterface /*! @brief gets the registration result that has been computed in the last iteration. This result is limited by the passed region descriptors (pMovingRepresentation, pTargetRepresentation). @pre pMovingRepresentation and pTargetRepresentation must not be null. @param [in] pMovingRepresentation Pointer to @eguarantee strong @return the interim registration result as smart pointer @retval a Registration object @sa Registration */ virtual InterimRegistrationPointer determineInterimRegistration(const MovingRepresentationDescriptorType* pMovingRepresentation, const TargetRepresentationDescriptorType* pTargetRepresentation) const; /*! * Returns the final registration @eguarantee strong */ virtual RegistrationPointer doGetRegistration() const; /*! Returns if the registration should be computed. The registration is outdated if doGetRegistration returns null * or the modification time of at least one sub component is newer then the modification time of the registration. @eguarantee strong @return true if the registration should be (re)computed. False if the registration is uptodate. */ virtual bool registrationIsOutdated() const; virtual bool doStopAlgorithm(); /*! This method should do all preparation tasks right before the algorithm is executed. At the end of this method the algorithm should be set up and ready to use.\n The method delegates the main work of initialization to several sub methods. These sub methods serve as slots that can be rewritten by an algorithm developer to alter certain aspects and keep the rest untouched.\n The sequence of slot calls is: \n - prepCheckValidity - prepPerpareInternalInputData - prepSavePlastimatchInputData - prepParameterMaps - prepFinalizePreparation @remark If you want to change the execution style, then overwrite runAlgorithm(). @eguarantee strong*/ virtual void prepareAlgorithm(); /*! This method is the slot to check if all internal components and input data are properly set. @remark The default implementation checks the moving and target image. Overload this method to alter the validity check. @remark It is assumed that the implementation of this method throws an exception if the algorithm is not configured correctly.*/ virtual void prepCheckValidity(); /*! This method is the slot for internal preprocessing of input data. This method should be reimplemented if you want to prepare the input data before they go into the internal registration method. E.g. blurring or normalizing the moving and target image before registration. @remark The default implementation does nothing. Thus the public input data will be the data used by the internal algorithm. @remark Implementations of this method should work on _spInternalMoving and _spInternalTargetImage. In the default implementation of prepSetInternalInputData() these member will be passed to the internal algorithm. @eguarantee strong*/ virtual void prepPerpareInternalInputData(); /*! This method is the slot for storing the relevant input data to the working directory of plastimatch. * @remark The default implementation stores _spInternalMoving and _spInternalTargetImage and the masks if set. @eguarantee strong */ virtual void prepSavePlastimatchInputData(); /*! This method is the slot for the generation of the configuration that should be passed to plastimatch. The base class assumes that after calling this methods the member _configurationPLM contains all parameters for all stages. @eguarantee strong */ virtual void prepConfigurationPLM() = 0; /*! This method is used after preConfifurationPLM() to ensure that parameters for input images, masks and resulting vector field are correctly set. If the parameters are already set, they will be overwritten. In addition the function removes all settings for the output of result images or xform (they are deactivated). @eguarantee strong */ void ensureCorrectGlobalConfigSettings(); /*! This method should just execute the iteration loop. * @remark If you want to change the initialization or the finalization, then overwrite prepareIteration() or finalizeAlgorithm(). * @return Indicates if the registration was successfully determined (e.g. could be * false if an iterative algorithm was stopped prematurely by the user). * @eguarantee strong */ virtual bool runAlgorithm(); /*! This method should do all the finalization work (e.g. generating the registration based on the iteration results). * @remark If you want to change the initialization or the iteration, then overwrite prepareIteration() or iterateAlgorithm(). @eguarantee strong */ virtual void finalizeAlgorithm(); /*! return the optimizer value(s) of the current iteration step. Will be called by getCurrentOptimizerValue() if hasCurrentValue() returns true. @eguarantee strong @return current measure */ virtual OptimizerMeasureType doGetCurrentOptimizerValue() const; /*! Methods invoked by derivated classes. */ virtual void PrintSelf(std::ostream& os, ::itk::Indent indent) const; /*! Feature is not supported by this wrapper. Therefore the methods returns only a dummy value (0). * @eguarantee strong*/ virtual IterationCountType doGetCurrentIteration() const; /*! Feature is not supported by this wrapper. Therefore the methods returns only a dummy value (0). @eguarantee strong */ virtual IterationCountType doGetMaxIterations() const; /*! This method generates a unique and random subdirectory contained by _workingDir. * The path to this directory is stored in _currentTempDir. * @eguarantee strong */ void initializeCurrentTempDir(); /*! Helper function that loads the deformation file generated by plastimatch. The generated file is loaded and returned by the function.*/ FinalFieldPointer generateField() const; /*! Helper function that generates the file path to the parameter file.*/ ::map::core::String getParameterFilePath() const; /*! Helper function that generates the file path to the result parameters for the final(last stage) transform. @pre Algorithm must have at least one stage.*/ ::map::core::String getFinalTransformFilePath() const; /*!Pointer to the moving image used by the algorithm internally. This is used to allow the algorithm * or its derived classes to modify the moving image without changing the public moving image pointer. * The variable is set by prepareIteration() to _spMovingImage before calling prepareInternalInputData(). * (e.g.: An algorithm always normalizes an image before registration. Then the algorithm can use the prepareInternalInputData() * function to manipulate _spInternalMovingImage before it is used by prepareIteration() to set the internal algorithm)*/ MovingImageConstPointer _spInternalMovingImage; /*!Pointer to the target image used by the algorithm internally. This is used to allow the algorithm * or its derived classes to modify the target image with out changing the public target image pointer. * The variable is set by prepareIteration() to _spTargetImage before calling prepareInternalInputData(). * (e.g.: An algorithm always normalizes an image before registration. Then the algorithm can use the prepareInternalInputData() * function to manipulate _spInternalTargetImage before it is used by prepareIteration() to set the internal algorithm)*/ TargetImageConstPointer _spInternalTargetImage; /*!Directory that can be used to store temporary data. Process must have write access to this directory*/ ::map::core::String _workingDir; /*!Directory where the plastimatch tool 'plastimatch' is located.*/ ::map::core::String _plastimatchDir; /*!Directory that is used to store temporary data on the current run*/ ::map::core::String _currentTempDir; /*!Vector with plastimatch parameter maps, each element of the vector is the parameter map for one registration stage of plastimatch*/ ConfigurationType _configurationPLM; ::map::core::String _movingImageTempPath; ::map::core::String _targetImageTempPath; ::map::core::String _finalFieldTempPath; ::map::core::String _movingMaskTempPath; ::map::core::String _targetMaskTempPath; ::map::core::String _movingPointSetTempPath; ::map::core::String _targetPointSetTempPath; bool _deleteTempDirectory; /*! This member function is called by the process executer, whenever Plastimatch generates an output on stdout.*/ void onPlmOutputEvent(::itk::Object* caller, const ::itk::EventObject& eventObject); /*! Helper method that removes the current temp dir (if it exists and _deleteTempDirectory is true). * @eguarantee no throw*/ void cleanTempDir() const; ::map::core::String _parameterFilePath; virtual MovingPointSetConstPointer doGetNthMovingPointSet(SlotIndexType index) const override; virtual TargetPointSetConstPointer doGetNthTargetPointSet(SlotIndexType index) const override; virtual void doSetNthMovingPointSet(SlotIndexType index, const MovingPointSetType* pMovingPointSet) override; virtual void doSetNthTargetPointSet(SlotIndexType index, const TargetPointSetType* pTargetPointSet) override; ::map::core::ModificationTimeValidator _targetPSMTime; ::map::core::ModificationTimeValidator _movingPSMTime; MovingPointSetConstPointer _spMovingPointSet; TargetPointSetConstPointer _spTargetPointSet; private: /*! The parameters of the registration field generated by plastimatch.*/ FinalFieldPointer _spFinalizedField; /*! Smartpointer to the finalized registration. Will be set by finalizeAlgorithm()*/ typename RegistrationType::Pointer _spFinalizedRegistration; /*! The lock is used to manage the access to the member variable _currentIterationCount.*/ mutable ::std::mutex _currentIterationLock; CLIRegistrationAlgorithmBase(const Self& source); void operator=(const Self&); //purposely not implemented }; } } } #ifndef MatchPoint_MANUAL_TPP #include "mapPlmCLIRegistrationAlgorithmBase.tpp" #endif #endif diff --git a/Code/Algorithms/Plastimatch/include/mapPlmCLIRegistrationAlgorithmBase.tpp b/Code/Algorithms/Plastimatch/include/mapPlmCLIRegistrationAlgorithmBase.tpp index ce968c2..dc93816 100644 --- a/Code/Algorithms/Plastimatch/include/mapPlmCLIRegistrationAlgorithmBase.tpp +++ b/Code/Algorithms/Plastimatch/include/mapPlmCLIRegistrationAlgorithmBase.tpp @@ -1,840 +1,840 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __MAP_PLM_CLI_REGISTRATION_ALGORITHM_BASE_TPP #define __MAP_PLM_CLI_REGISTRATION_ALGORITHM_BASE_TPP #include "itkSpatialObjectToImageFilter.h" #include "itkImage.h" #include "mapAlgorithmException.h" #include "mapPreCachedRegistrationKernel.h" #include "mapInverseRegistrationKernelGenerator.h" #include "mapRegistrationManipulator.h" #include "mapAlgorithmWrapperEvent.h" #include "mapImageWriter.h" #include "mapProcessExecutor.h" #include "mapConvert.h" #include "mapMetaProperty.h" #include "mapString.h" #include "mapFieldByFileLoadFunctor.h" #include "mapFieldDecomposer.h" #include "mapSimpleLandMarkFileWriter.h" namespace map { namespace algorithm { namespace plastimatch { template - unsigned long + ::itk::ModifiedTimeType CLIRegistrationAlgorithmBase:: getNthTargetPointSetMTime(SlotIndexType index) const { return _targetPSMTime.getMTime(); }; template - unsigned long + ::itk::ModifiedTimeType CLIRegistrationAlgorithmBase:: getNthMovingPointSetMTime(SlotIndexType index) const { return _movingPSMTime.getMTime(); }; template typename CLIRegistrationAlgorithmBase::FieldRepRequirement::Type CLIRegistrationAlgorithmBase:: isMovingRepresentationRequired() const { return FieldRepRequirement::No; }; template typename CLIRegistrationAlgorithmBase::FieldRepRequirement::Type CLIRegistrationAlgorithmBase:: isTargetRepresentationRequired() const { return FieldRepRequirement::No; }; template bool CLIRegistrationAlgorithmBase:: isStoppable() const { return false; }; template typename CLIRegistrationAlgorithmBase::IterationCountType CLIRegistrationAlgorithmBase:: doGetCurrentIteration() const { return 0; }; template typename CLIRegistrationAlgorithmBase::IterationCountType CLIRegistrationAlgorithmBase:: doGetMaxIterations() const { return 0; }; template bool CLIRegistrationAlgorithmBase:: hasIterationCount() const { return false; }; template bool CLIRegistrationAlgorithmBase:: hasMaxIterationCount() const { return false; }; template bool CLIRegistrationAlgorithmBase:: hasCurrentOptimizerValue() const { return false; }; template CLIRegistrationAlgorithmBase:: CLIRegistrationAlgorithmBase() : _deleteTempDirectory(true) { _spInternalMovingImage = NULL; _spInternalTargetImage = NULL; }; template CLIRegistrationAlgorithmBase:: ~CLIRegistrationAlgorithmBase() { }; template bool CLIRegistrationAlgorithmBase:: isReusable() const { return true; }; template void CLIRegistrationAlgorithmBase:: configureAlgorithm() { if (this->isFirstConfiguration()) { _plastimatchDir = ""; ::map::core::String envDir = ""; if (itksys::SystemTools::GetEnv("MAP_PLASTIMATCH_PATH", envDir)) { _plastimatchDir = envDir; } _workingDir = itksys::SystemTools::GetCurrentWorkingDirectory(); _deleteTempDirectory = true; } }; template void CLIRegistrationAlgorithmBase:: compileInfos(MetaPropertyVectorType& infos) const { #ifndef MAP_SEAL_ALGORITHMS infos.push_back(map::algorithm::MetaPropertyInfo::New("WorkingDirectory", typeid(map::core::String), true, true)); infos.push_back(map::algorithm::MetaPropertyInfo::New("PlastimatchDirectory", typeid(map::core::String), true, true)); infos.push_back(map::algorithm::MetaPropertyInfo::New("DeleteTempDirectory", typeid(bool), true, true)); #endif }; template typename CLIRegistrationAlgorithmBase::MetaPropertyPointer CLIRegistrationAlgorithmBase:: doGetProperty(const MetaPropertyNameType& name) const { MetaPropertyPointer spResult; if (name == "WorkingDirectory") { spResult = map::core::MetaProperty::New(this->_workingDir); } else if (name == "PlastimatchDirectory") { spResult = map::core::MetaProperty::New(this->_plastimatchDir); } else if (name == "DeleteTempDirectory") { spResult = map::core::MetaProperty::New(this->_deleteTempDirectory); } else { assert(false); //any other property name should have been excluded by the calling function. } return spResult; }; template void CLIRegistrationAlgorithmBase:: doSetProperty(const MetaPropertyNameType& name, const MetaPropertyType* pProperty) { if (name == "WorkingDirectory") { ::map::core::String dir; map::core::unwrapMetaProperty(pProperty, dir); this->_workingDir = dir; } else if (name == "PlastimatchDirectory") { ::map::core::String dir; map::core::unwrapMetaProperty(pProperty, dir); this->_plastimatchDir = dir; } else if (name == "DeleteTempDirectory") { bool del; map::core::unwrapMetaProperty(pProperty, del); this->_deleteTempDirectory = del; } else { assert(false); //any other property name should have been excluded by the calling function. } }; template typename CLIRegistrationAlgorithmBase::InterimRegistrationPointer CLIRegistrationAlgorithmBase:: determineInterimRegistration(const MovingRepresentationDescriptorType* pMovingRepresentation, const TargetRepresentationDescriptorType* pTargetRepresentation) const { InterimRegistrationPointer spResult = NULL; return spResult; }; template bool CLIRegistrationAlgorithmBase:: doStopAlgorithm() { assert(false); mapExceptionMacro(AlgorithmException, << "Cannot stop Plastimatch algorithm. Interim stop feature is not supported. Wrong usage of iterative algorithm interface"); }; template void CLIRegistrationAlgorithmBase:: initializeCurrentTempDir() { srand(time(NULL)); ::map::core::OStringStream stream; stream << itksys::SystemTools::GetCurrentDateTime("%Y-%m-%d_%H-%M-%S") << "_#" << rand(); ::map::core::String currentTempDir = core::FileDispatch::createFullPath(_workingDir, stream.str()); if (!itksys::SystemTools::MakeDirectory(currentTempDir.c_str())) { mapExceptionMacro(AlgorithmException, << "Cannot create temporary working sub dir. Please check validity of given working dir and ensure right privileges for the application. Failed temporary sub dir: " << _currentTempDir); } _currentTempDir = currentTempDir; }; template void CLIRegistrationAlgorithmBase:: prepareAlgorithm() { try { this->prepCheckValidity(); this->_spFinalizedRegistration = NULL; //initialize registration components this->InvokeEvent(::map::events::AlgorithmEvent(this, "Transfer cached MetaProperties.")); this->configureAlgorithmByMetaProperties(); this->InvokeEvent(::map::events::AlgorithmEvent(this, "Initializing registration.")); this->initializeCurrentTempDir(); //preparing data this->InvokeEvent(::map::events::AlgorithmEvent(this, "Initializing/Preparing input data.")); _spInternalMovingImage = this->getMovingImage(); _spInternalTargetImage = this->getTargetImage(); this->prepPerpareInternalInputData(); //storing temporary images this->InvokeEvent(::map::events::AlgorithmEvent(this, "Passing input data to plastimatch working directory.")); this->prepSavePlastimatchInputData(); this->InvokeEvent(::map::events::AlgorithmEvent(this, "Generating parameter maps for plastimatch.")); this->prepConfigurationPLM(); this->ensureCorrectGlobalConfigSettings(); this->InvokeEvent(::map::events::AlgorithmEvent(this, "Store plastimatch configuration.")); saveConfigurationToFile(this->_configurationPLM, this->getParameterFilePath()); } catch (...) { cleanTempDir(); throw; } }; template void CLIRegistrationAlgorithmBase:: cleanTempDir() const { try { if (itksys::SystemTools::FileExists(_currentTempDir.c_str()) && this->_deleteTempDirectory) { itksys::SystemTools::RemoveADirectory(_currentTempDir.c_str()); } } catch (...) { mapLogWarningObjMacro(<< "Cannot clean up. Exception while removing the directory. Directory" << this->_currentTempDir); } }; template void CLIRegistrationAlgorithmBase:: prepCheckValidity() { if (!this->getMovingImage()) { mapExceptionMacro(AlgorithmException, << "Cannot start algorithm; no moving image."); } if (!this->getTargetImage()) { mapExceptionMacro(AlgorithmException, << "Cannot start algorithm; no target image."); } } template void CLIRegistrationAlgorithmBase:: prepPerpareInternalInputData() { //default implementation does nothing } template void CLIRegistrationAlgorithmBase:: ensureCorrectGlobalConfigSettings() { if (this->_configurationPLM.empty()) { mapExceptionMacro(AlgorithmException, << "Cannot start algorithm; no configuration is defined."); } if (this->_configurationPLM.size() < 2) { mapExceptionMacro(AlgorithmException, << "Cannot start algorithm; invalid configuration (need at least the global section and one stage section)."); } ConfigurationType checkedConfig = this->_configurationPLM; checkedConfig[0]["moving"] = plastimatch::ParamGenerator().add(this->_movingImageTempPath); checkedConfig[0]["fixed"] = plastimatch::ParamGenerator().add(this->_targetImageTempPath); checkedConfig[0]["vf_out"] = plastimatch::ParamGenerator().add(this->_finalFieldTempPath); if (this->getMovingMask().IsNotNull()) { //add moving mask checkedConfig[0]["moving_mask"] = plastimatch::ParamGenerator().add(this->_movingMaskTempPath); } if (this->getTargetMask().IsNotNull()) { //add target mask checkedConfig[0]["fixed_mask"] = plastimatch::ParamGenerator().add(this->_targetMaskTempPath); } if (this->getMovingPointSet().IsNotNull()) { //add moving mask checkedConfig[0]["moving_landmarks"] = plastimatch::ParamGenerator().add(this->_movingPointSetTempPath); } if (this->getTargetPointSet().IsNotNull()) { //add target mask checkedConfig[0]["fixed_landmarks"] = plastimatch::ParamGenerator().add(this->_targetPointSetTempPath); } checkedConfig[0].erase("xform_out"); checkedConfig[0].erase("img_out"); checkedConfig[0].erase("img_out_fmt"); checkedConfig[0].erase("img_out_type"); this->_configurationPLM.swap(checkedConfig); } template void saveTempImage(const TImage* image, const core::String& filePath) { typedef typename ::map::io::ImageWriter < typename TImage::PixelType, typename TImage::PixelType, TImage::ImageDimension > WriterType; typename WriterType::Pointer spWriter = WriterType::New(); spWriter->setInput(image); spWriter->setFilePath(filePath); spWriter->update(); }; template typename ::itk::Image::Pointer generateMaskImage(const ::itk::SpatialObject* so, const core::FieldRepresentationDescriptor* descriptor) { assert(so); assert(descriptor); typedef ::itk::Image MaskImageType; typedef ::itk::SpatialObject ObjectType; typedef ::itk::SpatialObjectToImageFilter FilterType; typename FilterType::Pointer spFilter = FilterType::New(); spFilter->SetInput(so); typename MaskImageType::SizeType size; for (unsigned long i = 0; i < VDimension; ++i) { size[i] = static_cast (descriptor->getSize()[i] / descriptor->getSpacing()[i]); } spFilter->SetSize(size); spFilter->SetSpacing(descriptor->getSpacing()); spFilter->SetOrigin(descriptor->getOrigin()); spFilter->SetDirection(descriptor->getDirection()); spFilter->Update(); spFilter->SetInsideValue(1); spFilter->SetOutsideValue(0); return spFilter->GetOutput(); }; template void CLIRegistrationAlgorithmBase:: prepSavePlastimatchInputData() { //save the images _movingImageTempPath = core::FileDispatch::createFullPath(_currentTempDir, "moving.mhd"); _targetImageTempPath = core::FileDispatch::createFullPath(_currentTempDir, "target.mhd"); _finalFieldTempPath = core::FileDispatch::createFullPath(_currentTempDir, "deformationField.mhd"); _movingMaskTempPath = ""; _targetMaskTempPath = ""; _movingPointSetTempPath = ""; _targetPointSetTempPath = ""; this->InvokeEvent(::map::events::AlgorithmEvent(this, "Write temporary moving image. Path: " + _movingImageTempPath)); saveTempImage(_spInternalMovingImage.GetPointer(), _movingImageTempPath); this->InvokeEvent(::map::events::AlgorithmEvent(this, "Write temporary target image. Path: " + _targetImageTempPath)); saveTempImage(_spInternalTargetImage.GetPointer(), _targetImageTempPath); //save the masks if (this->getMovingMask().IsNotNull()) { typedef ::itk::Image MaskImageType; typename MaskImageType::Pointer spMovingMaskImage = generateMaskImage (this->getMovingMask(), core::createFieldRepresentation(*(_spInternalMovingImage)).GetPointer()); _movingMaskTempPath = core::FileDispatch::createFullPath(_currentTempDir, "movingMask.mhd"); this->InvokeEvent(::map::events::AlgorithmEvent(this, "Write temporary moving mask image. Path: " + _movingMaskTempPath)); saveTempImage(spMovingMaskImage.GetPointer(), _movingMaskTempPath); } if (this->getTargetMask().IsNotNull()) { typedef ::itk::Image MaskImageType; typename MaskImageType::Pointer spTargetMaskImage = generateMaskImage (this->getTargetMask(), core::createFieldRepresentation(*(_spInternalTargetImage)).GetPointer()); _targetMaskTempPath = core::FileDispatch::createFullPath(_currentTempDir, "targetMask.mhd"); this->InvokeEvent(::map::events::AlgorithmEvent(this, "Write temporary target mask image. Path: " + _targetMaskTempPath)); saveTempImage(spTargetMaskImage.GetPointer(), _targetMaskTempPath); } //save the pointsets if (this->getMovingPointSet().IsNotNull()) { _movingPointSetTempPath = core::FileDispatch::createFullPath(_currentTempDir, "movingPointSet.txt"); this->InvokeEvent(::map::events::AlgorithmEvent(this, "Write temporary moving point set. Path: " + _movingPointSetTempPath)); ::map::utilities::saveLandMarksToFile(_movingPointSetTempPath, this->getMovingPointSet().GetPointer()); } if (this->getTargetPointSet().IsNotNull()) { _targetPointSetTempPath = core::FileDispatch::createFullPath(_currentTempDir, "targetPointSet.txt"); this->InvokeEvent(::map::events::AlgorithmEvent(this, "Write temporary target point set. Path: " + _targetPointSetTempPath)); ::map::utilities::saveLandMarksToFile(_targetPointSetTempPath, this->getTargetPointSet().GetPointer()); } } template bool CLIRegistrationAlgorithmBase:: runAlgorithm() { map::utilities::ProcessExecutor::Pointer spExec = map::utilities::ProcessExecutor::New(); typename ::itk::MemberCommand::Pointer spCommand = ::itk::MemberCommand::New(); spCommand->SetCallbackFunction(this, &Self::onPlmOutputEvent); spExec->AddObserver(map::events::ExternalProcessStdOutEvent(), spCommand); map::utilities::ProcessExecutor::ArgumentListType args; args.push_back("register"); args.push_back(this->getParameterFilePath()); ::map::core::OStringStream ostr; ostr << "Calling plastimatch (" << _plastimatchDir << ") with arguments:"; for (map::utilities::ProcessExecutor::ArgumentListType::const_iterator pos = args.begin(); pos != args.end(); ++pos) { ostr << " " << *pos; } this->InvokeEvent(::map::events::AlgorithmEvent(this, ostr.str())); if (!spExec->execute(_plastimatchDir, core::FileDispatch::createFullPath(_plastimatchDir, "plastimatch"), args)) { mapExceptionMacro(AlgorithmException, << "Error when executing plastimatch to determine the registration."); } return spExec->getExitValue() == 0; }; template typename CLIRegistrationAlgorithmBase::FinalFieldPointer CLIRegistrationAlgorithmBase:: generateField() const { typedef map::core::functors::FieldByFileLoadFunctor < Superclass::TargetDimensions, Superclass::MovingDimensions > FunctorType; typename FunctorType::Pointer spFunctor = FunctorType::New(_finalFieldTempPath); FinalFieldPointer spField; ::map::core::FieldDecomposer::decomposeTransform(spFunctor->generateTransform(), spField); if (spField.IsNull()) { mapExceptionMacro(AlgorithmException, << "Error when loading Plastimatch deformation field. File name: " << _finalFieldTempPath); } return spField; }; template ::map::core::String map::algorithm::plastimatch::CLIRegistrationAlgorithmBase:: getParameterFilePath() const { ::map::core::String result = core::FileDispatch::createFullPath(_currentTempDir, "parameters.txt"); return result; }; template ::map::core::String map::algorithm::plastimatch::CLIRegistrationAlgorithmBase:: getFinalTransformFilePath() const { if (this->_configurationPLM.empty()) { mapExceptionMacro(AlgorithmException, << "Cannot determine final transform file path; no parameter maps are defined."); } ::map::core::OStringStream ostr; ostr << "TransformParameters." << this->_configurationPLM.size() - 1 << ".txt"; ::map::core::String result = core::FileDispatch::createFullPath(_currentTempDir, ostr.str()); return result; }; template void CLIRegistrationAlgorithmBase:: finalizeAlgorithm() { RegistrationPointer spResult = NULL; try { _spFinalizedField = this->generateField(); typedef typename map::core::PreCachedRegistrationKernel InverseKernelType; typename FieldTransformType::Pointer transform = FieldTransformType::New(); transform->SetDisplacementField(_spFinalizedField.GetPointer()); typename InverseKernelType::Pointer spIKernel = InverseKernelType::New(); spIKernel->setTransformModel(transform); //now build the direct kernel via inversion of the inverse kernel typedef core::InverseRegistrationKernelGenerator < RegistrationType::TargetDimensions, RegistrationType::MovingDimensions > GeneratorType; typename GeneratorType::Pointer spGenerator = GeneratorType::New(); typedef typename GeneratorType::InverseKernelBaseType DirectKernelType; typename Superclass::MovingRepresentationDescriptorType::ConstPointer spMovingRep = ::map::core::createFieldRepresentation(*(this->getMovingImage())).GetPointer(); if (this->getMovingRepresentation()) { //user has defined a representation descriptor -> use this one spMovingRep = this->getMovingRepresentation(); } typename DirectKernelType::Pointer spDKernel = spGenerator->generateInverse(* (spIKernel.GetPointer()), spMovingRep); if (spDKernel.IsNull()) { mapExceptionMacro(AlgorithmException, << "Error. Cannot determine direct mapping kernel of final registration. Current inverse kernel: " << spIKernel); } //now create the registration and set the kernels spResult = RegistrationType::New(); ::map::core::RegistrationManipulator manipulator(spResult); manipulator.setDirectMapping(spDKernel); manipulator.setInverseMapping(spIKernel); manipulator.getTagValues()[tags::AlgorithmUID] = this->getUID()->toStr(); _spFinalizedRegistration = spResult; } catch (...) { //delete temp dir even in case of an exception cleanTempDir(); throw; } //delete temp dir cleanTempDir(); _currentTempDir = ""; }; template typename CLIRegistrationAlgorithmBase::RegistrationPointer CLIRegistrationAlgorithmBase:: doGetRegistration() const { return _spFinalizedRegistration; }; template bool CLIRegistrationAlgorithmBase:: registrationIsOutdated() const { bool outdated = _spFinalizedRegistration.IsNull(); if (_spFinalizedRegistration.IsNotNull()) { if (!outdated) { outdated = _spFinalizedRegistration->GetMTime() < MetaPropertyAlgorithmBase::GetMTime(); } if (!outdated) { //check if the inputs have been changed outdated = this->_spInternalMovingImage != this->getMovingImage(); } if (!outdated) { //check if the inputs have been changed outdated = this->_spInternalTargetImage != this->getTargetImage(); } if (!outdated) { outdated = _spFinalizedRegistration->GetMTime() < this->getTargetImageMTime(); } if (!outdated) { outdated = _spFinalizedRegistration->GetMTime() < this->getMovingImageMTime(); } if (!outdated) { outdated = _spFinalizedRegistration->GetMTime() < this->getTargetPointSetMTime(); } if (!outdated) { outdated = _spFinalizedRegistration->GetMTime() < this->getMovingPointSetMTime(); } if (!outdated) { outdated = _spFinalizedRegistration->GetMTime() < this->getTargetMaskMTime(); } if (!outdated) { outdated = _spFinalizedRegistration->GetMTime() < this->getMovingMaskMTime(); } } return outdated; }; template typename CLIRegistrationAlgorithmBase::OptimizerMeasureType CLIRegistrationAlgorithmBase:: doGetCurrentOptimizerValue() const { OptimizerMeasureType result; return result; }; template void CLIRegistrationAlgorithmBase:: PrintSelf(std::ostream& os, ::itk::Indent indent) const { Superclass::PrintSelf(os, indent); ImageRegistrationAlgorithmBase::PrintSelf(os, indent); os << indent << "Finalized registration: " << _spFinalizedRegistration << std::endl; }; template void CLIRegistrationAlgorithmBase:: onPlmOutputEvent(::itk::Object* caller, const ::itk::EventObject& eventObject) { const events::ExternalProcessStdOutEvent* pStdEvent = dynamic_cast(&eventObject); if (pStdEvent) { this->InvokeEvent(::map::events::AlgorithmIterationEvent(this, pStdEvent->getComment())); } } template typename CLIRegistrationAlgorithmBase::MovingPointSetConstPointer CLIRegistrationAlgorithmBase:: doGetNthMovingPointSet(SlotIndexType index) const { return this->_spMovingPointSet; }; template typename CLIRegistrationAlgorithmBase::TargetPointSetConstPointer CLIRegistrationAlgorithmBase:: doGetNthTargetPointSet(SlotIndexType index) const { return this->_spTargetPointSet; }; template void CLIRegistrationAlgorithmBase:: doSetNthMovingPointSet(SlotIndexType index, const MovingPointSetType* pMovingPointSet) { _spMovingPointSet = pMovingPointSet; this->_movingPSMTime.setWatchedObject(pMovingPointSet); }; template void CLIRegistrationAlgorithmBase:: doSetNthTargetPointSet(SlotIndexType index, const TargetPointSetType* pTargetPointSet) { _spTargetPointSet = pTargetPointSet; this->_targetPSMTime.setWatchedObject(pTargetPointSet); }; } // end namespace plastimatch } // end namespace algorithm } // end namespace map #endif diff --git a/Code/Core/include/mapModificationTimeValidator.h b/Code/Core/include/mapModificationTimeValidator.h index 60a9497..5014492 100644 --- a/Code/Core/include/mapModificationTimeValidator.h +++ b/Code/Core/include/mapModificationTimeValidator.h @@ -1,90 +1,90 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #ifndef __MAP_MODIFICATION_TIME_VALIDTOR_H #define __MAP_MODIFICATION_TIME_VALIDTOR_H #include "itkObject.h" #include "itkTimeStamp.h" #include #include #include "mapMacros.h" #include "mapMAPCoreExports.h" namespace map { namespace core { /*! @class ModificationTimeValidator * @brief Helper class that allows to handles itk modification time consistency problems when using dll deployment for algoritms. * * When using a dll deployment strategy for algorithms (at least for windows systems) * the itk modification time (MTime) becomes inconsistent between the algorithms out of a dll * and data loaded by the host. (Reason is that dlls and host have different static variables * defining the current MTime). This leads inter alia to a false up to date conclusion * in dll deployed algorithms. This class serves as work around that helps to correctly detect * changes in modification time. Basic principle is that the MTime of an watched object is taged * by a MTime of the own context. And this "Tag" is changed, when the object or its MTime changes. * This may lead to false positives in modification detection. But it will allow to detect all * real changes. */ class MAPCore_EXPORT ModificationTimeValidator { public: /*! Standard class typedefs. */ using Self = ModificationTimeValidator; using WatchedObjectType = ::itk::Object; - using MTimeType = unsigned long; + using MTimeType = ::itk::ModifiedTimeType; /*! Constructor. * @eguarantee strong */ ModificationTimeValidator(const WatchedObjectType* obj); /*! Constructor. * @eguarantee strong */ ModificationTimeValidator(); /*! Destructor. * @eguarantee none throw*/ ~ModificationTimeValidator(); /*! Set the watched object and update the internal time stamp. * @eguarantee strong */ void setWatchedObject(const WatchedObjectType* obj); /*! Get the point defining the origin of the volume. * @eguarantee strong */ MTimeType getMTime() const; protected: WatchedObjectType::ConstPointer _spObj; mutable ::itk::TimeStamp _ownTimeStamp; mutable MTimeType _objTimeStamp; }; } // end namespace core } // end namespace map #endif diff --git a/Code/Core/test/mapModificationTimeValidatorTest.cpp b/Code/Core/test/mapModificationTimeValidatorTest.cpp index bbbe5c8..34f659e 100644 --- a/Code/Core/test/mapModificationTimeValidatorTest.cpp +++ b/Code/Core/test/mapModificationTimeValidatorTest.cpp @@ -1,168 +1,168 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision$ (last changed revision) // @date $Date$ (last change date) // @author $Author$ (last changed by) // Subversion HeadURL: $HeadURL$ */ #if defined(_MSC_VER) #pragma warning ( disable : 4786 ) #endif #include "mapModificationTimeValidator.h" #include "litCheckMacros.h" #include namespace map { namespace testing { /** Helper class that mimics an object with a different modification time context*/ class OffContextObject : public ::itk::Object { public: typedef OffContextObject Self; typedef ::itk::Object Superclass; typedef ::itk::SmartPointer Pointer; typedef ::itk::SmartPointer ConstPointer; itkTypeMacro(OffContextObject, ::itk::Object); itkFactorylessNewMacro(Self); - virtual unsigned long GetMTime() const + virtual ::itk::ModifiedTimeType GetMTime() const { return _offContextMTime; }; virtual void Modified() const { _offContextMTime++; }; OffContextObject() { _offContextMTime = 0; }; ~OffContextObject() {}; - mutable unsigned long _offContextMTime; + mutable ::itk::ModifiedTimeType _offContextMTime; }; int mapModificationTimeValidatorTest(int, char* []) { PREPARE_DEFAULT_TEST_REPORTING; ::itk::TimeStamp contextRefTS; ::itk::Object::Pointer spInContextObj = ::itk::Object::New(); OffContextObject::Pointer spOffContextObj = OffContextObject::New(); ::itk::Object::Pointer spInContextObj2 = ::itk::Object::New(); OffContextObject::Pointer spOffContextObj2 = OffContextObject::New(); //check constructors ::map::core::ModificationTimeValidator mtv; CHECK_EQUAL(contextRefTS.GetMTime(), mtv.getMTime()); ::map::core::ModificationTimeValidator mtv2(NULL); CHECK_EQUAL(contextRefTS.GetMTime(), mtv2.getMTime()); ::map::core::ModificationTimeValidator mtv3(spInContextObj); - unsigned long lastTS_MTV3 = mtv3.getMTime(); + ::itk::ModifiedTimeType lastTS_MTV3 = mtv3.getMTime(); CHECK(contextRefTS.GetMTime() < lastTS_MTV3); //check setter (NULL before); mtv.setWatchedObject(spInContextObj); - unsigned long lastTS_MTV = mtv.getMTime(); + ::itk::ModifiedTimeType lastTS_MTV = mtv.getMTime(); CHECK(contextRefTS.GetMTime() < lastTS_MTV); //////////////////////////////////////// // Check in context handling (using same time stamp) //check setter when using same obj mtv3.setWatchedObject(spInContextObj); CHECK_EQUAL(lastTS_MTV3, mtv3.getMTime()); //check setter when using same obj mtv3.setWatchedObject(spInContextObj); CHECK_EQUAL(lastTS_MTV3, mtv3.getMTime()); //check setter when using different obj mtv3.setWatchedObject(spInContextObj2); CHECK(lastTS_MTV3 < mtv3.getMTime()); lastTS_MTV3 = mtv3.getMTime(); //check getter when object is modified spInContextObj2->Modified(); CHECK(lastTS_MTV3 < mtv3.getMTime()); //////////////////////////////////////// // Check "off context handling" (external time stamp is higher) spOffContextObj->_offContextMTime = 2000; spOffContextObj2->_offContextMTime = 2020; contextRefTS.Modified(); //check setter when using same obj mtv.setWatchedObject(spOffContextObj); lastTS_MTV = mtv.getMTime(); CHECK(contextRefTS < lastTS_MTV); //check setter when using same obj mtv.setWatchedObject(spOffContextObj); CHECK_EQUAL(lastTS_MTV, mtv.getMTime()); //check setter when using different obj mtv.setWatchedObject(spOffContextObj2); CHECK(lastTS_MTV < mtv.getMTime()); lastTS_MTV = mtv.getMTime(); //check getter when object is modified spOffContextObj2->Modified(); CHECK(lastTS_MTV < mtv.getMTime()); //////////////////////////////////////// // Check "off context handling" (external time stamp is lower) spOffContextObj->_offContextMTime = 0; spOffContextObj2->_offContextMTime = 1; contextRefTS.Modified(); //check setter when using same obj mtv.setWatchedObject(spOffContextObj); lastTS_MTV = mtv.getMTime(); CHECK(contextRefTS < lastTS_MTV); //check setter when using same obj mtv.setWatchedObject(spOffContextObj); CHECK_EQUAL(lastTS_MTV, mtv.getMTime()); //check setter when using different obj mtv.setWatchedObject(spOffContextObj2); CHECK(lastTS_MTV < mtv.getMTime()); lastTS_MTV = mtv.getMTime(); //check getter when object is modified spOffContextObj2->Modified(); CHECK(lastTS_MTV < mtv.getMTime()); RETURN_AND_REPORT_TEST_SUCCESS; } } //namespace testing } //namespace map