diff --git a/src/include/stir/recon_buildblock/BackProjectorByBin.h b/src/include/stir/recon_buildblock/BackProjectorByBin.h index ce63fb2e6d..6eb29b91df 100644 --- a/src/include/stir/recon_buildblock/BackProjectorByBin.h +++ b/src/include/stir/recon_buildblock/BackProjectorByBin.h @@ -169,7 +169,17 @@ void back_project(const RelatedViewgrams&, If overriding this function in a derived class, you need to call this one. */ + virtual void check(const ProjDataInfo& proj_data_info) const; + + //! check if the arguments are the same as what was used for set_up() + /*! calls error() if anything is wrong. + + If overriding this function in a derived class, you need to call this one. + + Calls check(const ProjDataInfo&) + */ virtual void check(const ProjDataInfo& proj_data_info, const DiscretisedDensity<3,float>& density_info) const; + bool _already_set_up; //! Clone of the density sptr set with set_up() diff --git a/src/include/stir/recon_buildblock/ForwardProjectorByBin.h b/src/include/stir/recon_buildblock/ForwardProjectorByBin.h index dae51a1e51..c16c7ff881 100644 --- a/src/include/stir/recon_buildblock/ForwardProjectorByBin.h +++ b/src/include/stir/recon_buildblock/ForwardProjectorByBin.h @@ -141,7 +141,17 @@ virtual void set_up( If overriding this function in a derived class, you need to call this one. */ + virtual void check(const ProjDataInfo& proj_data_info) const; + + //! check if the arguments are the same as what was used for set_up() + /*! calls error() if anything is wrong. + + If overriding this function in a derived class, you need to call this one. + + Calls check(const ProjDataInfo&) + */ virtual void check(const ProjDataInfo& proj_data_info, const DiscretisedDensity<3,float>& density_info) const; + bool _already_set_up; //! The density ptr set with set_up() diff --git a/src/recon_buildblock/BackProjectorByBin.cxx b/src/recon_buildblock/BackProjectorByBin.cxx index d993e7afac..91e0c7d010 100644 --- a/src/recon_buildblock/BackProjectorByBin.cxx +++ b/src/recon_buildblock/BackProjectorByBin.cxx @@ -96,13 +96,20 @@ set_up(const shared_ptr& proj_data_info_sptr, void BackProjectorByBin:: -check(const ProjDataInfo& proj_data_info, const DiscretisedDensity<3,float>& density_info) const +check(const ProjDataInfo& proj_data_info) const { if (!this->_already_set_up) error("BackProjectorByBin method called without calling set_up first."); if (!(*this->_proj_data_info_sptr >= proj_data_info)) error(boost::format("BackProjectorByBin set-up with different geometry for projection data.\nSet_up was with\n%1%\nCalled with\n%2%") % this->_proj_data_info_sptr->parameter_info() % proj_data_info.parameter_info()); +} + +void +BackProjectorByBin:: +check(const ProjDataInfo& proj_data_info, const DiscretisedDensity<3,float>& density_info) const +{ + this->check(proj_data_info); if (! this->_density_sptr->has_same_characteristics(density_info)) error("BackProjectorByBin set-up with different geometry for density or volume data."); } @@ -265,7 +272,7 @@ back_project(const RelatedViewgrams& viewgrams, if (!_density_sptr) error("You need to call start_accumulating_in_new_target() before back_project()"); - check(*viewgrams.get_proj_data_info_sptr(), *_density_sptr); + check(*viewgrams.get_proj_data_info_sptr()); #ifdef STIR_OPENMP const int thread_num=omp_get_thread_num(); diff --git a/src/recon_buildblock/ForwardProjectorByBin.cxx b/src/recon_buildblock/ForwardProjectorByBin.cxx index db1eae7401..c9a436c3de 100644 --- a/src/recon_buildblock/ForwardProjectorByBin.cxx +++ b/src/recon_buildblock/ForwardProjectorByBin.cxx @@ -81,13 +81,20 @@ set_up(const shared_ptr& proj_data_info_sptr, void ForwardProjectorByBin:: -check(const ProjDataInfo& proj_data_info, const DiscretisedDensity<3,float>& density_info) const +check(const ProjDataInfo& proj_data_info) const { if (!this->_already_set_up) error("ForwardProjectorByBin method called without calling set_up first."); if (!(*this->_proj_data_info_sptr >= proj_data_info)) error(boost::format("ForwardProjectorByBin set-up with different geometry for projection data.\nSet_up was with\n%1%\nCalled with\n%2%") % this->_proj_data_info_sptr->parameter_info() % proj_data_info.parameter_info()); +} + +void +ForwardProjectorByBin:: +check(const ProjDataInfo& proj_data_info, const DiscretisedDensity<3,float>& density_info) const +{ + this->check(proj_data_info); if (! this->_density_sptr->has_same_characteristics(density_info)) error("ForwardProjectorByBin set-up with different geometry for density or volume data."); } @@ -254,7 +261,7 @@ forward_project(RelatedViewgrams& viewgrams, if (!_density_sptr) error("You need to call set_input() forward_project()"); - check(*viewgrams.get_proj_data_info_sptr(), *_density_sptr); + check(*viewgrams.get_proj_data_info_sptr()); // first check symmetries {