diff options
author | Erik Schnetter <schnetter@cct.lsu.edu> | 2010-08-25 10:15:16 -0400 |
---|---|---|
committer | Barry Wardell <barry.wardell@gmail.com> | 2011-12-14 18:21:18 +0000 |
commit | a989c94165585c16724f02dc638c887e75a88cdc (patch) | |
tree | 15bd0f7e127be5f942f02461f1736de2f3d35af7 /Carpet/CarpetLib/src/bboxset.cc | |
parent | eac0f67696b808ae567f14a6ba7c229762d29426 (diff) |
CarpetLib: Generalise "expand" function. Implement "shift" function.
Allow expanding bboxset by multiples of a fraction of the stride.
Allow shifting bboxsets.
Diffstat (limited to 'Carpet/CarpetLib/src/bboxset.cc')
-rw-r--r-- | Carpet/CarpetLib/src/bboxset.cc | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/Carpet/CarpetLib/src/bboxset.cc b/Carpet/CarpetLib/src/bboxset.cc index 7ffd61699..a830c0b73 100644 --- a/Carpet/CarpetLib/src/bboxset.cc +++ b/Carpet/CarpetLib/src/bboxset.cc @@ -464,7 +464,9 @@ bboxset<T,D> bboxset<T,D>::pseudo_inverse (const int n) const { } template<typename T, int D> -bboxset<T,D> bboxset<T,D>::expand (const vect<T,D>& lo, const vect<T,D>& hi) const { +bboxset<T,D> bboxset<T,D>::expand (const vect<T,D>& lo, const vect<T,D>& hi) + const +{ // We don't know (yet?) how to shrink a set assert (all (lo>=0 and hi>=0)); bboxset res; @@ -475,6 +477,27 @@ bboxset<T,D> bboxset<T,D>::expand (const vect<T,D>& lo, const vect<T,D>& hi) con } template<typename T, int D> +bboxset<T,D> bboxset<T,D>::expand (const vect<T,D>& lo, const vect<T,D>& hi, + const vect<T,D>& denom) const +{ + assert (all(denom > vect<T,D>(0))); + bboxset res; + if (all (lo == -hi)) { + // Special case for shifting, since this is faster + for (const_iterator bi=begin(); bi!=end(); ++bi) { + res += (*bi).expand(lo,hi,denom); + } + } else { + // We don't know (yet?) how to shrink a set + assert (all ((lo>=0 and hi>=0) or (lo == hi))); + for (const_iterator bi=begin(); bi!=end(); ++bi) { + res |= (*bi).expand(lo,hi,denom); + } + } + return res; +} + +template<typename T, int D> bboxset<T,D> bboxset<T,D>::expanded_for (const box& b) const { bboxset res; for (const_iterator bi=begin(); bi!=end(); ++bi) { |