region: add overload of inset for vectors
This commit is contained in:
parent
ff5e6945e3
commit
fc41f0991d
17
region.cpp
17
region.cpp
@ -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)
|
||||
e - T{2} * mag
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user