vtf-logo

sfcIndex.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 #ifndef _included_sfcIndex_h
00004 #define _included_sfcIndex_h
00005 
00011 #include "BitVec.h"
00012 #include "DAGHDefaults.h"
00013 
00014 #include <iosfwd>
00015 #include <cmath>
00016 
00017 #ifndef sfcBase
00018 #define sfcBase (2)
00019 #endif
00020 
00031 class sfcIndex : public BitVec
00032   {
00033    friend std::ostream& operator<<(std::ostream&, sfcIndex const &);
00034 
00035    short int sfcbasew;
00036    short int sfcdigitw;
00037 
00038 protected:
00039    short int sfcbase;
00040    short int sfcdim;
00041    short int sfclevs;
00042 
00043 public:
00044    inline sfcIndex()
00045         : BitVec(),
00046           sfcbasew(0), sfcdigitw(0), 
00047           sfcbase(0), sfcdim(0), sfclevs(0) 
00048           {} 
00049 
00050    inline sfcIndex(const int dim, const int levs, 
00051                    const int base = sfcBase)
00052         : BitVec(levs*dim*static_cast<int>(std::ceil(
00053               std::log(static_cast<double>(base))/std::log(2.0)))),
00054           sfcbase(base), sfcdim(dim), sfclevs(levs)
00055      { 
00056          sfcbasew = static_cast<int>(std::ceil(
00057              std::log(static_cast<double>(base))/std::log(2.0)));
00058          sfcdigitw = sfcdim*sfcbasew; 
00059      }
00060 
00061    inline sfcIndex(sfcIndex const &other)
00062         : BitVec((BitVec const &)other),
00063           sfcbasew(other.sfcbasew), sfcdigitw(other.sfcdigitw),
00064           sfcbase(other.sfcbase), sfcdim(other.sfcdim), 
00065           sfclevs(other.sfclevs) 
00066           {}
00067 
00069    sfcIndex const &operator= (sfcIndex const &other);
00070 
00071    int operator== (sfcIndex const &other) const;
00072    int operator!= (sfcIndex const &other) const;
00073    int operator> (sfcIndex const &other) const;
00074    int operator< (sfcIndex const &other) const;
00075    int operator>= (sfcIndex const &other) const;
00076    int operator<= (sfcIndex const &other) const;
00077 
00078    /* Operations on digits; i.e. (sfcdim*sfcbasew) bits */
00082    int sfcGetDigit(const int level) const;
00084    void sfcSetDigit(const int level, const int digit);
00086    void sfcUnsetDigit(const int level);
00088    void sfcMaxDigit(const int level);
00089 
00090    /* Operations on base sfcbase words (sfcbasew bits) within a digit */
00093    void sfcSwapDigitWd(const int level, const int pos1, const int pos2);
00095    void sfcToggleDigitWd(const int level, const int pos);
00096 
00097    /* Operations on the sfcIndex */
00099    int sfcGetIndex() const;
00101    int sfcGetIndex(const int lev) const;
00103    int sfcGetIndex(const int lev, const int nlev) const;
00104 
00106    void sfcSetIndex(const int index);
00108    void sfcSetIndex(const int index, const int lev);
00110    void sfcSetIndex(const int index, const int lev, const int nlev);
00111    void sfcMaxIndex(const int lev);
00112 
00113    /* Mapping, inverse mapping routines */
00115    void sfcCreateLocNum(const int *coords);
00117    void sfcGetCoords(int *coords) const;
00119    void sfcGetDigitArray(int *digits) const;
00120 
00122    inline int sfcGetBaseW(void) const
00123         {return sfcbasew;}
00124    inline int sfcGetDigitW(void) const
00125         {return sfcdigitw;}
00126 
00127 private:
00128    inline void sfcSetDigitBit(const int level, const int pos)
00129         { SetBit((level-1)*sfcdigitw + pos); }
00130    inline void sfcUnsetDigitBit(const int level, const int pos)
00131         { UnsetBit((level-1)*sfcdigitw + pos); }
00132    inline void sfcToggleDigitBit(const int level, const int pos)
00133         { ToggleBit((level-1)*sfcdigitw + pos); }
00134 
00135   };
00136  
00137 std::ostream& operator<<(std::ostream& os, sfcIndex const &si);
00138 
00139 #endif

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