vtf-logo

PeanoHilbert.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 #ifndef _included_PeanoHilbert_h
00004 #define _included_PeanoHilbert_h
00005 
00010 #include "sfcIndex.h"
00011 
00012 #include <cassert>
00013 
00014 #ifndef PeanoHibertBase
00015 #define PeanoHibertBase (2)
00016 #endif
00017 
00025 class PeanoHilbert : public sfcIndex
00026   {
00027 
00028 public:
00029 
00031    inline PeanoHilbert()
00032         : sfcIndex() {}
00033 
00035    inline PeanoHilbert(const int dim, const int levs)
00036         : sfcIndex(dim,levs,PeanoHibertBase)
00037         {assert(dim<=3);}
00038 
00040    inline PeanoHilbert(PeanoHilbert const &other)
00041         : sfcIndex((sfcIndex const &)other) {}
00042 
00044 private:
00045    void Invert(int *coords) const;
00046 
00047 public:
00048    inline void SetIndex(const int index, const int idxlev)
00049      { sfcSetIndex(index,idxlev); }
00050    inline void SetIndex(const int index, const int idxlev, 
00051                         const int nlev)
00052      { sfcSetIndex(index,idxlev,nlev); }
00053 
00055    void Map(const int *coords);
00057    void Invert(int *coords, const int index);
00059    void Invert(int *coords, const int index, const int idxlev);
00061    void Invert(int *coords, const int index, 
00062                const int idxlev, const int nlev);
00063 
00067    PeanoHilbert *GetBox(const int lev, const int nlev) const;
00068    void SetBox(const int lev, const int nlev);
00069 
00071    PeanoHilbert *GetMax(const int lev, const int nlev) const;
00072    void SetMax(const int lev, const int nlev);
00073 
00075    void ResetBase(const int lev, const int nlev);
00076    
00077    /* Query routines */
00079    void GetCoords(int *coords, const int lev = 1) const;
00080    int *GetCoords(const int lev = 1) const;
00081 
00083    inline int GetCardinality(const int dim, const int lev) const
00084      {return (int)1<<(lev*dim);}
00085    inline int GetCardinality(const int lev) const
00086      {return (int)1<<(lev*sfcdim);}
00087 
00089    inline int GetDimCardinality(const int lev) const
00090      {return (int)1<<(sfclevs-lev);}
00091 
00093    inline int GetDimMax(const int lev) const
00094      {return (((int)1<<lev)-1)*((int)1<<(sfclevs-lev));}
00095    
00096 private:
00097 
00098 /*
00099 // The following operations are used to orient the seed
00100 // curve as required. The seed curve is "->"
00101 // Axis are numbered as follows:
00102 // "->" x: 1
00103 // "|"  y: 2
00104 // "/"  z: 3
00105 // Directions are numbered as follows:
00106 // "->" (positive x): 1
00107 // "|" (positive y): 2
00108 // "/" (positive z): 3
00109 // phSwapDir ->(PH) = <-(PH)
00110 // phTranslate ->(PH) = (PH)->
00111 // phRotate ->(PH) (1,2) = |(PH)
00112 // phRotate ->(PH) (1,3) = /(PH)
00113 // phRotate |(PH) (2,1) = ->(PH)
00114 // phRotate /(PH) (3,1) = ->(PH)
00115 // Note:
00116 // (1) "phRotate" is valid to/from the seed orientation only !
00117 //     i.e. "to" or "from" should be "->" or 1.
00118 // (2) Bit are numbered from 0 to DIM-1 such that the msb is 0 and
00119 //     the lsb is Dim-1.
00120 //     i.e. x = xb0 xb1 xb2 xb3 ... xbDIM-1
00121 */
00122 
00123    inline void phSwapDir(const int level, const int axis)
00124      {sfcToggleDigitWd(level,axis-1);}
00125    inline void phTranslate(const int level, const int axis)
00126      {sfcToggleDigitWd(level,axis-1);}
00127    inline void phRotate(const int level, const int from_axis, 
00128                         const int to_axis)
00129      {sfcSwapDigitWd(level,from_axis-1,to_axis-1);}
00130 
00132    void phOrient(const int level, const int pos);
00134    int phGray(const int level);
00135    int phGinv(const int level);
00136 
00137   };
00138 
00139 #endif

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