vtf-logo

GridUnitList.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 #ifndef _included_GridUnitList_h
00004 #define _included_GridUnitList_h
00005 
00011 #include "DAGHDefaults.h"
00012 #include "BBoxList.h"
00013 #include "GridUnit.h"
00014 #include "BucketType.h"
00015 #include "ObjectCounter.h"
00016 
00017 #include <iosfwd>
00018 #include <cstdlib>
00019 
00020 #ifndef DefGridUnitListSize
00021 #define DefGridUnitListSize (128)
00022 #endif
00023 
00024 #ifndef DefMinimumGUExtent
00025 #define DefMinimumGUExtent  (1)
00026 #endif
00027 
00034 class GridUnitList : public Bucket<GridUnit>, public ObjectCounter
00035 {
00036 public:
00037     /*************************************************************************/
00038     /*** Constructors ***/
00039     /*************************************************************************/
00040     inline GridUnitList()
00041         : Bucket<GridUnit>(DefGridUnitListSize) {}
00042 
00043     // Declare single-arg constructors explicit to avoid unintended conversions
00044     explicit GridUnitList(const unsigned int maxnum)
00045         : Bucket<GridUnit>(maxnum) {}
00046 
00047     inline GridUnitList(const void* package, const unsigned int size, 
00048                         const int n)
00049         : Bucket<GridUnit>(package, size, n) {}
00050 
00051     GridUnitList(const GridUnitList& other)
00052         : Bucket<GridUnit>(other) {}
00053 
00054     GridUnitList(GridUnitList**& levarray);
00055 
00056     /*************************************************************************/
00057     /*** Assignment operator ***/
00058     /*************************************************************************/
00059     GridUnitList& operator=(const GridUnitList&);
00060 
00061     /*************************************************************************/
00062     /*** The destructor ***/
00063     /*************************************************************************/
00064     inline ~GridUnitList(void) {}
00065 
00066     /*************************************************************************/
00067     /*** For the object counter ***/
00068     /*************************************************************************/
00069     inline GridUnitList* alias()
00070         { return dynamic_cast<GridUnitList*>(ObjectCounter::alias()); }
00071 
00072     /*************************************************************************/
00073     /*** GUL operators ***/
00074     /*************************************************************************/
00075     void operator-=(const GridUnitList &rhs); /* Difference */
00076     void operator*=(const GridUnitList &rhs); /* Intersaction */
00077     GridUnitList* operator-(const GridUnitList &rhs); /* Abs Difference */
00078     GridUnitList* operator*(const GridUnitList &rhs); /* Intersection */
00079     GridUnitList* operator+(const GridUnitList &rhs); /* Union */
00080 
00081     /*************************************************************************/
00082     /*** GUL operations with a BBox & BBoxList ***/
00083     /*************************************************************************/
00084 public: 
00085     void operator*=(const BBox &rhs); /* Intersection */
00086 private: 
00087     GridUnitList* operator*(const BBox &rhs); /* Intersection */
00088     GridUnitList* operator*(const BBoxList &rhs); /* Intersection */
00089  
00090     /*************************************************************************/
00091     /*** GUL intersection with a BBox & BBoxList ***/
00092     /*************************************************************************/
00093 public:
00094     void intersect(const BBox &rhs, const int lev, GridUnitList &gul, 
00095                    const int olap, const int extgh=0);
00096     void intersect(const BBoxList &rhs, const int lev, GridUnitList &gul, 
00097                    const int olap, const int extgh=0);
00098     void intersect(const BBox &rhs, const int lev, GridUnitList &gul, 
00099                    const short* olap, const int extgh=0);
00100     void intersect(const BBoxList &rhs, const int lev, GridUnitList &gul,
00101                    const short* olap, const int extgh=0);
00102 
00103     /*************************************************************************/
00104     /*** Query functions ***/
00105     /*************************************************************************/
00106 public:
00107     unsigned long load(const int olap);
00108     unsigned long load(const int lev, const int olap);
00109     unsigned long numelems(const int olap);
00110     unsigned long numelems(const int lev, const int olap);
00111   
00112     unsigned long load(const short* olap);
00113     unsigned long load(const int lev, const short* olap);
00114     unsigned long numelems(const short* olap);
00115     unsigned long numelems(const int lev, const short* olap);
00116 
00117     int levels(void);
00118     int finest(void);
00119     int smallest(const int level);
00120     int highestbaselevel();
00121     dMapIndex lowest();
00122     dMapIndex lowest(const int level, const int owner, const int index);
00123     int maxindex(void);
00124 
00125     /*************************************************************************/
00126     /*** Set list stats ***/
00127     /*************************************************************************/
00128 private:
00129     void setindex(void);
00130     void setindex(const int idx);
00131     void setindex(const GridUnitList& cgul, const int idx);
00132     void setbbox();
00133 public:
00134     void setowner(const int p);
00135     void setowner(const GridUnitList& cgul, const int p);
00136 
00137     /*************************************************************************/
00138     /*** Array of GridUnitList's for the levels ***/
00139     /*************************************************************************/
00140     void levelarray(GridUnitList **& levarray, const int levels);
00141 
00142     /*************************************************************************/
00143     /*** GridUnitList for a particular level ***/
00144     /*************************************************************************/
00145     void levellist(GridUnitList &gul, const int lev);
00146     void levellist(GridUnitList &gul, const int minlev, const int maxlev);
00147 
00148     /*************************************************************************/
00149     /*** BBoxList for a particular level ***/
00150     /*************************************************************************/
00151 public:
00152     void bboxlistfinest(BBoxList &bbl, const int lev);
00153     void bboxlist(BBoxList &bbl, const int lev, const int olap);
00154     void bboxlist(BBoxList &bbl, const int lev, const int olap, 
00155                   const int levid); 
00156     void bboxlist(BBoxList &bbl, const int lev, const short* olap,
00157                   const int extgh);
00158     void bboxlist(BBoxList &bbl, const int lev, const short* olap, 
00159                   const int levid, const int extgh);
00160     /*************************************************************************/
00162     /*************************************************************************/
00163     GridUnitList* refinelist(const int atlev, const int levs=1);
00164 
00165     /*************************************************************************/
00166     /*** Refine as per bounding box list ***/
00167     /*************************************************************************/
00168     GridUnitList* refinelist(const BBoxList &bblist, 
00169                              const int atlev, 
00170                              const int minw);
00171    
00172     void refinethislist(const BBoxList& bblist, 
00173                         const int atlev, 
00174                         const int minw);
00175 
00176     /*************************************************************************/
00177     /*** Operations on the current GridUnit ***/
00178     /*************************************************************************/
00179 private:
00180     inline void refine(const int lev = 1)
00181         { current()->guRefine(lev); }
00182     inline void coarsen(const int lev = 1)
00183         { current()->guCoarsen(lev); }
00184 
00185 public:
00186     void decompose(const int lev = 1);
00187 
00188     /*************************************************************************/
00189     /*** Functions I'd like to have.... ***/
00190     /*************************************************************************/
00191     //void merge(GridUnitList const *levellist, const int level);
00192     //void coalesce(GridUnitList**& gularray, BBoxList const &bblist, 
00193     //              int &cnt, const int lev);
00194 };
00195 
00196 // overloaded i/o functions
00197 std::ostream& operator<<(std::ostream& os, const GridUnitList& gul);
00198 std::ofstream& operator<<(std::ofstream& ofs, const GridUnitList& gul);
00199 std::ifstream& operator>>(std::ifstream& ifs, GridUnitList& gul);
00200 std::stringstream& operator<<(std::stringstream& ofs, const GridUnitList& gul);
00201 std::stringstream& operator>>(std::stringstream& ifs, GridUnitList& gul);
00202 
00203 #endif

Generated on Fri Aug 24 13:00:29 2007 for AMROC's Hierachical Data Structures - by  doxygen 1.4.7