region: add overload of inset for vectors

This commit is contained in:
Danny Robson 2017-08-09 17:17:55 +10:00
parent ff5e6945e3
commit fc41f0991d
2 changed files with 16 additions and 6 deletions

View File

@ -262,14 +262,23 @@ util::region<S,T>::resize (extent<S,T> _e)
//-----------------------------------------------------------------------------
template <size_t S, typename T>
util::region<S,T>
util::region<S,T>::inset (T mag)
util::region<S,T>::inset (T mag) const
{
// ensure we have enough space to inset
CHECK (min (e) >= 2 * mag);
return inset (util::vector<S,T> {mag});
}
//-----------------------------------------------------------------------------
template <size_t S, typename T>
util::region<S,T>
util::region<S,T>::inset (vector<S,T> mag) const
{
// ensure we have enough space to trim off our total extent
CHECK (all (e >= 2 * mag));
return {
p + mag,
e - static_cast<T> (2 * mag)
p + mag,
e - T{2} * mag
};
}

View File

@ -87,7 +87,8 @@ namespace util {
region& resize (extent<S,T>);
// Compute a region `mag` units into the region
region inset (T mag);
region inset (T mag) const;
region inset (vector<S,T> mag) const;
region expanded (T mag) const;
region expanded (vector<S,T>) const;