AMROC Main     Blockstructured Adaptive Mesh Refinement in object-oriented C++


Main Page   Class Hierarchy   Compound List   File List  

GridBoxList.h

Go to the documentation of this file.
00001 #ifndef _included_GridBoxList_h
00002 #define _included_GridBoxList_h
00003 
00009 #include "DAGHDefaults.h"
00010 #include "BBoxList.h"
00011 #include "GridBox.h"
00012 #include "BucketType.h"
00013 #include "ObjectCounter.h"
00014 
00015 #ifndef DefGridBoxListSize
00016 #define DefGridBoxListSize (128)
00017 #endif
00018 
00019 #define GridBoxListNULL ((GridBoxList *) NULL)
00020 
00021 typedef Bucket<GridBox> Bucket_GridBox;
00022 
00029 class GridBoxList : public Bucket<GridBox>, public ObjectCounter
00030   {
00031    friend ostream& operator<<(ostream&, const GridBoxList&);
00032    friend ofstream& operator<<(ofstream&, const GridBoxList&);
00033    friend ifstream& operator>>(ifstream&, GridBoxList&);
00034    friend strstream& operator<<(strstream&, const GridBoxList&);
00035    friend strstream& operator>>(strstream&, GridBoxList&);
00036 
00037    int num;
00038 
00039 private:
00040    static inline void copytypedata(GridBox* to, const GridBox* from)
00041      { memcpy((void *) to, (void *) from, sizeof(GridBox)); }
00042 
00043    /*************************************************************************/
00045    inline void setstats(void)
00046      {num=0;for (register GridBox *g=first();g;g=next())num++;}
00047 
00048 public:
00049    /*************************************************************************/
00051    inline GridBoxList()
00052      : Bucket<GridBox>(DefGridBoxListSize), num(0) {}
00053 
00054    // We need dumarg because the SP2 does implicit conversions
00055    // from anything to this class
00056    inline GridBoxList(const int maxnum, const int dumarg)
00057      : Bucket<GridBox>(maxnum), num(0) {}
00058 
00059    inline GridBoxList(const void* package, const int size, 
00060                const int n)
00061      : Bucket<GridBox>(package, size, n), num(0) { setstats(); }
00062 
00063    inline GridBoxList(const GridBoxList& other)
00064      : Bucket<GridBox>(other), num(other.num) {}
00065 
00066    /*************************************************************************/
00068    GridBoxList& operator = (const GridBoxList&);
00069 
00070    /*************************************************************************/
00072    inline ~GridBoxList(void) {}
00073 
00074    /*************************************************************************/
00076    inline GridBoxList *alias()
00077         { return((GridBoxList *) ObjectCounter::alias()); }
00078 
00079 public:
00080    /*************************************************************************/
00081    /*** GBL operators ***/
00082    /*************************************************************************/
00084    int difference(GridBoxList& gbl, const GridBox& lhs, 
00085                    const GridBox& rhs);
00087    int intersection(GridBoxList& gbl, const GridBox& lhs, 
00088                     const GridBox& rhs);
00090    void operator -= (const GridBoxList &rhs); 
00092    void operator *= (const GridBoxList &rhs); 
00093    //GridBoxList *operator - (const GridBoxList &rhs); /* Abs Difference */
00094    //GridBoxList *operator * (const GridBoxList &rhs); /* Intersection */
00095    //GridBoxList *operator + (const GridBoxList &rhs); /* Union */
00096 
00097    /*************************************************************************/
00098    /*** GBL operations with a BBox & BBoxList ***/
00099    /*************************************************************************/
00100 private: 
00101    //void operator *= (const BBox& rhs); /* Intersection */
00102    //GridBoxList *operator * (const BBox& rhs); /* Intersection */
00103    //GridBoxList *operator * (const BBoxList& rhs); /* Intersection */
00104  
00105 public:
00106    /*************************************************************************/
00108    void intersect(const BBox& rhs, GridBoxList& gbl);
00109    void intersect(const BBox& rhs, GridBoxList& gbl, 
00110                   const int olap, const int extgh=0);
00111    void intersect(const BBoxList& rhs, GridBoxList& gbl, 
00112                   const int olap, const int extgh=0);
00113    void intersect(const BBox& rhs, GridBoxList& gbl, 
00114                   const short* olap, const int extgh=0);
00115    void intersect(const BBoxList& rhs, GridBoxList& gbl,
00116                   const short* olap, const int extgh=0);
00117 
00118    /*************************************************************************/
00119    /*** Query functions ***/
00120    /*************************************************************************/
00121 public:
00122    inline int isempty() const { return(num == 0); }
00123    inline int number() const { return(num); }
00124 
00126    int maxindex(void);
00127 
00129    int index(const BBox& bbv);
00131    const GridBox& find(const BBox& bb);
00132 
00133    /*************************************************************************/
00135 public:
00136    inline void setindex(void)
00137      { register int idx=0; 
00138        for (register GridBox *g=first();g;g=next()) g->index=idx++; }
00139    inline void setowner(const int p)
00140      { for (register GridBox *g=first();g;g=next()) g->owner=p; }
00141    
00142    /*************************************************************************/
00144    inline void empty(void)
00145      { Bucket<GridBox>::empty(); num = 0; }
00146 
00147    /*************************************************************************/
00149    inline GridBox *add() 
00150      { num++; return (Bucket<GridBox>::add()); }
00151    inline GridBox *add(const GridBox& gb) 
00152      { num++; return (Bucket<GridBox>::add(gb)); }
00153    inline GridBox *insert(const GridBox& gb)
00154      { num++;  return (Bucket<GridBox>::insert(gb)); }
00155    inline void remove(void)
00156      { if (current()) { num--; Bucket<GridBox>::remove(); }}
00157 
00158 public:
00159    /*************************************************************************/
00161    void bboxlist(BBoxList& bbl, const int olap);
00162    void bboxlist(BBoxList& bbl, const short* olap, const int extgh);
00163   };
00164 
00166 ostream&  operator << (ostream& os, const GridBoxList& gbl);
00167 ofstream& operator << (ofstream& ofs, const GridBoxList& gbl);
00168 strstream& operator << (strstream& ofs, const GridBoxList& gbl);
00169 
00171 ifstream& operator >> (ifstream& ifs, GridBoxList& gbl);
00172 strstream& operator >> (strstream& ifs, GridBoxList& gbl);
00173 
00174 #endif


Quickstart     Users Guide     Programmers Reference     Installation      Examples     Download



AMROC Main      Home      Contact
last update: 06/01/04