region: add `encloses' test for subregions

This commit is contained in:
Danny Robson 2017-08-11 14:39:46 +10:00
parent 72f631ab4b
commit f36a14973a
2 changed files with 12 additions and 0 deletions

View File

@ -252,6 +252,15 @@ util::region<S,T>::intersection (region<S,T> rhs) const
//-----------------------------------------------------------------------------
template <size_t S, typename T>
bool
util::region<S,T>::encloses (const region<S,T> r) const noexcept
{
return all (p <= r.p) && all (p + e >= r.p + r.e);
}
///////////////////////////////////////////////////////////////////////////////
template <size_t S, typename T>
util::region<S,T>
util::region<S,T>::inset (T mag) const
{

View File

@ -83,6 +83,9 @@ namespace util {
// Compute binary region combinations
region intersection (region<S,T>) const;
// Test if a region lies completely within our space
bool encloses (region<S,T>) const noexcept;
//---------------------------------------------------------------------
// Compute a region `mag` units into the region
region inset (T mag) const;