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>
|
template <size_t S, typename T>
|
||||||
util::region<S,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
|
return inset (util::vector<S,T> {mag});
|
||||||
CHECK (min (e) >= 2 * 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 {
|
return {
|
||||||
p + mag,
|
p + mag,
|
||||||
e - static_cast<T> (2 * mag)
|
e - T{2} * mag
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +87,8 @@ namespace util {
|
|||||||
region& resize (extent<S,T>);
|
region& resize (extent<S,T>);
|
||||||
|
|
||||||
// Compute a region `mag` units into the region
|
// 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 (T mag) const;
|
||||||
region expanded (vector<S,T>) const;
|
region expanded (vector<S,T>) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user