aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetLib/src
diff options
context:
space:
mode:
authorschnetter <>2004-04-18 11:03:00 +0000
committerschnetter <>2004-04-18 11:03:00 +0000
commit5215c601e44097e207dac6da688abfd8403b72d0 (patch)
tree4afd5d8ab2057750ba991edc66de0bd135020d26 /Carpet/CarpetLib/src
parentffc85540493a8dd65a89d51081e671608b49a4f8 (diff)
Change the bbox iterators to be cyclic.
Change the bbox iterators to be cyclic. Update ASCII output to use the new iterators. darcs-hash:20040418110344-07bb3-1ea594b79f3031dbc38101d15a65b9aafcf3b005.gz
Diffstat (limited to 'Carpet/CarpetLib/src')
-rw-r--r--Carpet/CarpetLib/src/bbox.cc14
-rw-r--r--Carpet/CarpetLib/src/bbox.hh5
2 files changed, 12 insertions, 7 deletions
diff --git a/Carpet/CarpetLib/src/bbox.cc b/Carpet/CarpetLib/src/bbox.cc
index 9cf82183c..174fdc7e0 100644
--- a/Carpet/CarpetLib/src/bbox.cc
+++ b/Carpet/CarpetLib/src/bbox.cc
@@ -1,4 +1,4 @@
-// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/bbox.cc,v 1.22 2004/03/11 12:03:44 schnetter Exp $
+// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/bbox.cc,v 1.23 2004/04/18 13:03:44 schnetter Exp $
#include <assert.h>
@@ -34,8 +34,8 @@ bbox<T,D>::bbox (const vect<T,D>& lower, const vect<T,D>& upper,
const vect<T,D>& stride)
: _lower(lower), _upper(upper), _stride(stride)
{
- assert (all(stride>=1));
- assert (all((upper-lower)%stride == T(0)));
+ assert (all(_stride>T(0)));
+ assert (all((_upper-_lower)%_stride == T(0)));
}
// Accessors
@@ -194,7 +194,7 @@ template<class T, int D>
typename bbox<T,D>::iterator& bbox<T,D>::iterator::operator++ () {
for (int d=0; d<D; ++d) {
pos[d]+=box.stride()[d];
- if (pos[d]<=box.upper()[d]) return *this;
+ if (pos[d]<=box.upper()[d]) break;
pos[d]=box.lower()[d];
}
return *this;
@@ -207,7 +207,7 @@ typename bbox<T,D>::iterator bbox<T,D>::begin () const {
template<class T, int D>
typename bbox<T,D>::iterator bbox<T,D>::end () const {
- return iterator(*this, upper());
+ return iterator(*this, lower());
}
@@ -226,6 +226,10 @@ void bbox<T,D>::input (istream& is) {
is >> _stride;
skipws (is);
consume (is, ')');
+ cerr << "bbox " << *this << endl;
+ cerr << (_upper-_lower)%_stride << endl;
+ assert (all(_stride>T(0)));
+ assert (all((_upper-_lower)%_stride == T(0)));
}
diff --git a/Carpet/CarpetLib/src/bbox.hh b/Carpet/CarpetLib/src/bbox.hh
index d22ad33b6..e23d000ac 100644
--- a/Carpet/CarpetLib/src/bbox.hh
+++ b/Carpet/CarpetLib/src/bbox.hh
@@ -1,4 +1,4 @@
-// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/bbox.hh,v 1.14 2004/03/11 12:03:44 schnetter Exp $
+// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/bbox.hh,v 1.15 2004/04/18 13:03:44 schnetter Exp $
#ifndef BBOX_HH
#define BBOX_HH
@@ -135,7 +135,8 @@ public:
/** Create an iterator that points to the first point in a bbox. */
iterator begin () const;
- /** Create an iterator that points to the last point in a bbox. */
+ /** Create an iterator that points "after the last point" in a bbox,
+ which means that it also points to the first point. */
iterator end () const;
// Input/Output helpers