/*************************************************************************** bboxset.hh - Sets of bounding boxes ------------------- begin : Sun Jun 11 2000 copyright : (C) 2000 by Erik Schnetter email : schnetter@astro.psu.edu $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/bboxset.hh,v 1.4 2001/03/22 18:42:05 eschnett Exp $ ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef BBOXSET_HH #define BBOXSET_HH #include #include #include #include "bbox.hh" #include "defs.hh" #include "vect.hh" using namespace std; // Forward definition template class bboxset; template bboxset operator- (const bbox& b1, const bbox& b2); template bboxset operator- (const bbox& b, const bboxset& s); // Output template ostream& operator<< (ostream& os, const bboxset& s); // Bounding box class template class bboxset { // Types typedef bbox box; typedef set bset; // Fields bset bs; // Invariant: // All bboxes have the same stride. // No bbox is empty. // The bboxes don't overlap. public: // Constructors bboxset (); bboxset (const box& b); bboxset (const bboxset& s); bboxset (const bset& bs); // Invariant bool invariant () const; // Normalisation void normalize (); // Accessors bool empty () const { return bs.empty(); } T size () const; // Add (bboxes that don't overlap) bboxset& operator+= (const box& b); bboxset& operator+= (const bboxset& s); bboxset operator+ (const box& b) const; bboxset operator+ (const bboxset& s) const; // Union bboxset& operator|= (const box& b); bboxset& operator|= (const bboxset& s); bboxset operator| (const box& b) const; bboxset operator| (const bboxset& s) const; // Intersection bboxset operator& (const box& b) const; bboxset operator& (const bboxset& s) const; bboxset& operator&= (const box& b); bboxset& operator&= (const bboxset& s); // Difference // friend bboxset operator- (const box& b1, const box& b2); bboxset operator- (const box& b) const; bboxset& operator-= (const box& b); bboxset& operator-= (const bboxset& s); bboxset operator- (const bboxset& s) const; // friend bboxset operator- (const box& b, const bboxset& s); // Iterators typedef typename bset::const_iterator const_iterator; typedef typename bset::iterator iterator; iterator begin () const { return bs.begin(); } iterator end () const { return bs.end(); } // Output friend ostream& operator<< <>(ostream& os, const bboxset& s); }; #if defined(TMPL_IMPLICIT) # include "bboxset.cc" #endif #endif // BBOXSET_HH