aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@gmail.com>2012-09-16 21:12:37 -0400
committerErik Schnetter <schnetter@gmail.com>2012-09-16 21:12:37 -0400
commit6452bcc36e08f09b9ea723ce19ee15873d16b2a1 (patch)
tree47c9256ad8332bab657ec9f73b07bd5caca6b69c
parent18ca797780f241bcf6705122fa757a7d3ae1100e (diff)
CarpetLib: Implement bboxset::contains(vect)
-rw-r--r--Carpet/CarpetLib/src/bboxset.cc12
-rw-r--r--Carpet/CarpetLib/src/bboxset.hh4
2 files changed, 15 insertions, 1 deletions
diff --git a/Carpet/CarpetLib/src/bboxset.cc b/Carpet/CarpetLib/src/bboxset.cc
index abeb5c0ee..e94f17f43 100644
--- a/Carpet/CarpetLib/src/bboxset.cc
+++ b/Carpet/CarpetLib/src/bboxset.cc
@@ -283,9 +283,19 @@ typename bboxset<T,D>::size_type bboxset<T,D>::size () const
-
// Queries
+// Containment
+// cost: O(n)
+template<typename T, int D>
+bool bboxset<T,D>::contains (const vect<T,D>& x) const
+{
+ for (const_iterator bi=begin(), be=end(); bi!=be; ++bi) {
+ if ((*bi).contains(x)) return true;
+ }
+ return false;
+}
+
// Intersection
// cost: O(n)
template<typename T, int D>
diff --git a/Carpet/CarpetLib/src/bboxset.hh b/Carpet/CarpetLib/src/bboxset.hh
index 6b92bb1c4..a8e2ab0ad 100644
--- a/Carpet/CarpetLib/src/bboxset.hh
+++ b/Carpet/CarpetLib/src/bboxset.hh
@@ -122,6 +122,10 @@ public:
size_type size () const CCTK_MEMBER_ATTRIBUTE_PURE; // cost: O(n)
int setsize () const { return bs.size(); } // cost: O(1)
+ // Find out whether the bbox contains the point x
+ bool contains (const vect<T,D>& x)
+ const CCTK_MEMBER_ATTRIBUTE_PURE; // cost: O(n)
+
// Find out whether this bboxset intersects the bbox b
bool intersects (const box& b) const CCTK_MEMBER_ATTRIBUTE_PURE; // cost: O(n)