vtf-logo

GridBoxList.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 #ifndef _included_GridBoxList_h
00004 #define _included_GridBoxList_h
00005 
00011 #include "DAGHDefaults.h"
00012 #include "BBoxList.h"
00013 #include "GridBox.h"
00014 #include "BucketType.h"
00015 #include "ObjectCounter.h"
00016 
00017 #include <iosfwd>
00018 #include <cstdlib>
00019 #include <cstring>
00020 
00021 #ifndef DefGridBoxListSize
00022 #define DefGridBoxListSize (128)
00023 #endif
00024 
00031 class GridBoxList : public Bucket<GridBox>, public ObjectCounter
00032 {
00033 public:
00034     /*************************************************************************/
00036     inline GridBoxList()
00037         : Bucket<GridBox>(DefGridBoxListSize) {}
00038 
00039     // Label constructor explicit to avoid implicit conversions to this class
00040     explicit GridBoxList(const unsigned int maxnum)
00041         : Bucket<GridBox>(maxnum) {}
00042 
00043     inline GridBoxList(const void* package, const unsigned int size, 
00044                        const int n)
00045         : Bucket<GridBox>(package, size, n) {}
00046 
00047     inline GridBoxList(const GridBoxList& other)
00048         : Bucket<GridBox>(other) {}
00049 
00050     /*************************************************************************/
00052     GridBoxList& operator=(const GridBoxList&);
00053 
00054     /*************************************************************************/
00056     inline ~GridBoxList(void) {}
00057 
00058     /*************************************************************************/
00060     inline GridBoxList* alias()
00061         { return dynamic_cast<GridBoxList*>(ObjectCounter::alias()); }
00062 
00063 public:
00064     /*************************************************************************/
00065     /*** GBL operators ***/
00066     /*************************************************************************/
00069     int difference(GridBoxList& gbl, const GridBox& lhs, const GridBox& rhs);
00072     int intersection(GridBoxList& gbl, const GridBox& lhs, const GridBox& rhs);
00075     void operator-=(const GridBoxList &rhs); 
00078     void operator*=(const GridBoxList &rhs); 
00079 
00080 public:
00081     /*************************************************************************/
00083     void intersect(const BBox& rhs, GridBoxList& gbl);
00084     void intersect(const BBox& rhs, GridBoxList& gbl, 
00085                    const int olap, const int extgh=0);
00086     void intersect(const BBoxList& rhs, GridBoxList& gbl, 
00087                    const int olap, const int extgh=0);
00088     void intersect(const BBox& rhs, GridBoxList& gbl, 
00089                    const short* olap, const int extgh=0);
00090     void intersect(const BBoxList& rhs, GridBoxList& gbl,
00091                    const short* olap, const int extgh=0);
00092 
00093     /*************************************************************************/
00094     /*** Query functions ***/
00095     /*************************************************************************/
00096 public:
00098     int maxindex(void);
00099 
00101     int index(const BBox& bbv);
00103     const GridBox& find(const BBox& bb);
00104 
00105     /*************************************************************************/
00107 public:
00108     inline void setindex(void)
00109     { 
00110         register int idx=0; 
00111         for (register GridBox* g=first(); g; g=next()) 
00112             g->index = idx++; 
00113     }
00114     inline void setowner(const int p)
00115     { 
00116         for (register GridBox* g=first(); g; g=next()) 
00117             g->owner = p; 
00118     }
00119    
00120 public:
00121     /*************************************************************************/
00123     void bboxlist(BBoxList& bbl, const int olap);
00124     void bboxlist(BBoxList& bbl, const short* olap, const int extgh);
00125 };
00126 
00128 std::ostream& operator<<(std::ostream& os, const GridBoxList& gbl);
00129 std::ofstream& operator<<(std::ofstream& ofs, const GridBoxList& gbl);
00130 std::stringstream& operator<<(std::stringstream& ofs, const GridBoxList& gbl);
00131 
00133 std::ifstream& operator>>(std::ifstream& ifs, GridBoxList& gbl);
00134 std::stringstream& operator>>(std::stringstream& ifs, GridBoxList& gbl);
00135 
00136 #endif

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