Skip to content
Snippets Groups Projects
Commit 5e935dd4 authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

RF: Handle interp/extrap settings access prior to initialisation, just by

returning the ShadowVolume settings
parent 80b14742
No related branches found
No related tags found
1 merge request!42RF: Improve thread-safety of `NEWIMAGE::volume` class
Pipeline #26647 skipped
...@@ -10,8 +10,7 @@ ...@@ -10,8 +10,7 @@
#include <cassert> #include <cassert>
#include <sstream> #include <sstream>
#include <iostream> #include <iostream>
#include <boost/utility/enable_if.hpp> #include <memory>
#include <boost/static_assert.hpp>
#include "armawrap/newmatio.h" #include "armawrap/newmatio.h"
#include "utils/threading.h" #include "utils/threading.h"
#include "newimage.h" #include "newimage.h"
...@@ -2429,10 +2428,6 @@ vector<T> calculateExtrema(const volume<T>& inputVolume, vector<int64_t>& coordi ...@@ -2429,10 +2428,6 @@ vector<T> calculateExtrema(const volume<T>& inputVolume, vector<int64_t>& coordi
template <class T> template <class T>
ReturnMatrix volume<T>::matrix(const volume<T>& mask, vector<int64_t>& voxelLabels) const 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(); voxelLabels.clear();
Matrix matv; Matrix matv;
if (this->totalElements()==0) return matv; if (this->totalElements()==0) return matv;
...@@ -2563,18 +2558,26 @@ vector<T> calculateExtrema(const volume<T>& inputVolume, vector<int64_t>& coordi ...@@ -2563,18 +2558,26 @@ vector<T> calculateExtrema(const volume<T>& inputVolume, vector<int64_t>& coordi
return *this; 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 // Getting interp/extrap settings on a ShadowVolume
// delegates to the owning volume instance // delegates to the owning volume instance
template<typename T> interpolation ShadowVolume<T>::getinterpolationmethod() const template<typename T> interpolation ShadowVolume<T>::getinterpolationmethod() const
{ return owner->getinterpolationmethod(); } { return owner().getinterpolationmethod(); }
template<typename T> extrapolation ShadowVolume<T>::getextrapolationmethod() const template<typename T> extrapolation ShadowVolume<T>::getextrapolationmethod() const
{ return owner->getextrapolationmethod(); } { return owner().getextrapolationmethod(); }
template<typename T> T ShadowVolume<T>::getpadvalue() const template<typename T> T ShadowVolume<T>::getpadvalue() const
{ return owner->getpadvalue(); } { return owner().getpadvalue(); }
template<typename T> std::vector<bool> ShadowVolume<T>::getextrapolationvalidity() const template<typename T> std::vector<bool> ShadowVolume<T>::getextrapolationvalidity() const
{ return owner->getextrapolationvalidity(); { return owner().getextrapolationvalidity(); }
} template<typename T> int ShadowVolume<T>::getsplineorder() const template<typename T> int ShadowVolume<T>::getsplineorder() const
{ return owner->getsplineorder(); } { return owner().getsplineorder(); }
// Attempts to change interp/extrap settings // Attempts to change interp/extrap settings
// on a ShadowVolume will result in an error // on a ShadowVolume will result in an error
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <iostream> #include <iostream>
#include <limits> #include <limits>
#include <map> #include <map>
#include <memory>
#include <stdexcept> #include <stdexcept>
#include <string> #include <string>
#include <type_traits> #include <type_traits>
...@@ -801,7 +802,9 @@ class ShadowVolume : public volume<T> { ...@@ -801,7 +802,9 @@ class ShadowVolume : public volume<T> {
private: private:
bool assigned; bool assigned;
const volume<T>* const owner;
const volume<T>* const _owner;
const volume<T>& owner() const;
public: public:
...@@ -841,15 +844,13 @@ public: ...@@ -841,15 +844,13 @@ public:
public: public:
const volume<T>& equals(const volume<T>& source); const volume<T>& equals(const volume<T>& source);
ShadowVolume() ShadowVolume() : assigned(false), _owner(nullptr) {};
: assigned(false),
owner(nullptr) {};
ShadowVolume(const ShadowVolume<T>& source) ShadowVolume(const ShadowVolume<T>& source)
: assigned(false), owner(source.owner) { : assigned(false), _owner(source._owner) {
this->reinitialize(source, ALIAS); this->reinitialize(source, ALIAS);
} }
ShadowVolume(const volume<T>& source) ShadowVolume(const volume<T>& source)
: assigned(false), owner(&source) { : assigned(false), _owner(&source) {
this->reinitialize(source, ALIAS); this->reinitialize(source, ALIAS);
} }
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment