diff --git a/newimage.cc b/newimage.cc index 201bd34a6b6a746959fb2dbbb4dea2248c8e1492..2b6bf475f8ffdc61832d6fb19ed048c3839dfa5d 100644 --- a/newimage.cc +++ b/newimage.cc @@ -10,8 +10,7 @@ #include <cassert> #include <sstream> #include <iostream> -#include <boost/utility/enable_if.hpp> -#include <boost/static_assert.hpp> +#include <memory> #include "armawrap/newmatio.h" #include "utils/threading.h" #include "newimage.h" @@ -2429,10 +2428,6 @@ vector<T> calculateExtrema(const volume<T>& inputVolume, vector<int64_t>& coordi template <class T> ReturnMatrix volume<T>::matrix(const volume<T>& mask, vector<int64_t>& voxelLabels) const { - //typename boost::enable_if<boost::is_integral<T>, T>::type foo; - //BOOST_STATIC_ASSERT_MSG(boost::is_integral<S>::value, "matrix only specialised for long int and int64_t"); - - voxelLabels.clear(); Matrix matv; if (this->totalElements()==0) return matv; @@ -2563,18 +2558,26 @@ vector<T> calculateExtrema(const volume<T>& inputVolume, vector<int64_t>& coordi return *this; } + template <typename T> + const volume<T>& ShadowVolume<T>::owner() const { + // if _owner is null, it mearns we + // haven't been initialised yet + if (_owner == nullptr) { return *this; } + else { return *_owner; } + } + // Getting interp/extrap settings on a ShadowVolume // delegates to the owning volume instance template<typename T> interpolation ShadowVolume<T>::getinterpolationmethod() const - { return owner->getinterpolationmethod(); } + { return owner().getinterpolationmethod(); } template<typename T> extrapolation ShadowVolume<T>::getextrapolationmethod() const - { return owner->getextrapolationmethod(); } + { return owner().getextrapolationmethod(); } template<typename T> T ShadowVolume<T>::getpadvalue() const - { return owner->getpadvalue(); } + { return owner().getpadvalue(); } template<typename T> std::vector<bool> ShadowVolume<T>::getextrapolationvalidity() const - { return owner->getextrapolationvalidity(); -} template<typename T> int ShadowVolume<T>::getsplineorder() const - { return owner->getsplineorder(); } + { return owner().getextrapolationvalidity(); } + template<typename T> int ShadowVolume<T>::getsplineorder() const + { return owner().getsplineorder(); } // Attempts to change interp/extrap settings // on a ShadowVolume will result in an error diff --git a/newimage.h b/newimage.h index c2b5e26d2c1d968607d93c32aeb631d239efd865..2e7acd78579d0cb08bfc2f64585b5a420083da74 100644 --- a/newimage.h +++ b/newimage.h @@ -16,6 +16,7 @@ #include <iostream> #include <limits> #include <map> +#include <memory> #include <stdexcept> #include <string> #include <type_traits> @@ -801,7 +802,9 @@ class ShadowVolume : public volume<T> { private: bool assigned; - const volume<T>* const owner; + + const volume<T>* const _owner; + const volume<T>& owner() const; public: @@ -841,15 +844,13 @@ public: public: const volume<T>& equals(const volume<T>& source); - ShadowVolume() - : assigned(false), - owner(nullptr) {}; + ShadowVolume() : assigned(false), _owner(nullptr) {}; ShadowVolume(const ShadowVolume<T>& source) - : assigned(false), owner(source.owner) { + : assigned(false), _owner(source._owner) { this->reinitialize(source, ALIAS); } ShadowVolume(const volume<T>& source) - : assigned(false), owner(&source) { + : assigned(false), _owner(&source) { this->reinitialize(source, ALIAS); } };