Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

TreeNode.txx

Go to the documentation of this file.
00001 
00007 #ifdef __DEBUG__
00008 #ifndef __DEBUG_TN__
00009 #define __DEBUG_TN__
00010 #endif
00011 #endif
00012 
00013 #include "colors.h"
00014 #include <cassert>
00015 
00016 namespace ot {
00017   // Inline Functions ...
00018   inline unsigned char TreeNode::getChildNumber() const {
00019     unsigned int len = (1u << (m_uiMaxDepth - getLevel()));
00020     unsigned int len_par = (1u << (m_uiMaxDepth - getLevel() + 1u));
00021 
00022     unsigned int i = (m_uiX % len_par);
00023     unsigned int j = (m_uiY % len_par);
00024     unsigned int k = (m_uiZ % len_par);
00025     i /= len;
00026     j /= len;
00027     k /= len;
00028 
00029     unsigned char childNum = static_cast<unsigned char>(4*k + 2*j + i);
00030     return childNum;
00031 
00032   }//end function
00033 
00034   inline int TreeNode::getAnchor(unsigned int &x, unsigned int&y, unsigned int&z) const {
00035     x = m_uiX;
00036     y = m_uiY;
00037     z = m_uiZ;
00038     return 1;
00039   }
00040 
00041   inline bool TreeNode  :: operator == ( TreeNode   const & other)  const{
00042 #ifdef __DEBUG_TN__
00043     if( ((this->m_uiDim) != (other.m_uiDim)) || ((this->m_uiMaxDepth) != (other.m_uiMaxDepth)) ) {
00044       std::cout<<"Me: "<<(*this)<<" Other: "<<other<<std::endl;
00045       std::cout<<"My Dim: "<<m_uiDim<<" OthDim: "<<other.m_uiDim<<" My MaxD: "<<m_uiMaxDepth<<" othMD: "<<other.m_uiMaxDepth<<std::endl;
00046       assert( false );
00047     }
00048 #endif
00049     if( (m_uiX == other.m_uiX) && (m_uiY == other.m_uiY) && (m_uiZ == other.m_uiZ) &&
00050         ( (m_uiLevel & ot::TreeNode::MAX_LEVEL) == (other.m_uiLevel & ot::TreeNode::MAX_LEVEL) ) ) {
00051       return true;
00052     }else {
00053       return false;
00054     }
00055   }//end fn.
00056 
00057   inline bool TreeNode  :: operator != (TreeNode  const  & other)  const{
00058 #ifdef __DEBUG_TN__
00059     if( ((this->m_uiDim) != (other.m_uiDim)) || ((this->m_uiMaxDepth) != (other.m_uiMaxDepth)) ) {
00060       std::cout<<"Me: "<<(*this)<<" Other: "<<other<<std::endl;
00061       std::cout<<"My Dim: "<<m_uiDim<<" OthDim: "<<other.m_uiDim<<" My MaxD: "<<m_uiMaxDepth<<" othMD: "<<other.m_uiMaxDepth<<std::endl;
00062       assert(false);
00063     }
00064 #endif
00065     return (!((*this) == other));
00066   }//end fn.
00067 
00068   inline bool TreeNode  :: operator  < (TreeNode   const & other)  const{
00069 #ifdef __DEBUG_TN__
00070     if( ((this->m_uiDim) != (other.m_uiDim)) || ((this->m_uiMaxDepth) != (other.m_uiMaxDepth)) ) {
00071       std::cout<<"Me: "<<(*this)<<" Other: "<<other<<std::endl;
00072       std::cout<<"My Dim: "<<m_uiDim<<" OthDim: "<<other.m_uiDim<<" My MaxD: "<<m_uiMaxDepth<<" othMD: "<<other.m_uiMaxDepth<<std::endl;
00073       assert(false);
00074     }
00075 #endif
00076     // first compare the x, y, and z to determine which one dominates ...
00077     //Ancestor is smaller.
00078     if( (this->m_uiX == other.m_uiX) && (this->m_uiY == other.m_uiY) && (this->m_uiZ == other.m_uiZ) ) {
00079       return ( (this->m_uiLevel & ot::TreeNode::MAX_LEVEL) < (other.m_uiLevel & ot::TreeNode::MAX_LEVEL) );     
00080     }//end if   
00081 
00082     unsigned int x = (m_uiX^other.m_uiX);
00083     unsigned int y = (m_uiY^other.m_uiY);
00084     unsigned int z = (m_uiZ^other.m_uiZ);
00085 
00086     //Default pref: z > y > x.
00087     unsigned int maxC = z;
00088     unsigned int yOrx = y;
00089     if(yOrx < x) { if( (x^yOrx) >= yOrx ) {yOrx = x;} }
00090     if(maxC < yOrx) { if( (maxC^yOrx) >= maxC ) {maxC = yOrx;} }
00091 
00092     if(maxC == z) { return (m_uiZ < other.m_uiZ); }
00093     else if(maxC == y) {  return (m_uiY < other.m_uiY); }
00094     else {  return (m_uiX < other.m_uiX); }
00095   }//end function
00096 
00097   inline bool TreeNode  :: operator  <= ( TreeNode  const  & other)  const{
00098 #ifdef __DEBUG_TN__
00099     if( ((this->m_uiDim) != (other.m_uiDim)) || ((this->m_uiMaxDepth) != (other.m_uiMaxDepth)) ) {
00100       std::cout<<"Me: "<<(*this)<<" Other: "<<other<<std::endl;
00101       std::cout<<"My Dim: "<<m_uiDim<<" OthDim: "<<other.m_uiDim<<" My MaxD: "<<m_uiMaxDepth<<" othMD: "<<other.m_uiMaxDepth<<std::endl;
00102       assert(false);
00103     }
00104 #endif
00105     return ( ((*this) < other) || ((*this) == other) );
00106   }//end fn.
00107 
00108   inline bool TreeNode  :: operator  > (TreeNode  const  & other)  const{
00109 #ifdef __DEBUG_TN__
00110     if( ((this->m_uiDim) != (other.m_uiDim)) || ((this->m_uiMaxDepth) != (other.m_uiMaxDepth)) ) {
00111       std::cout<<"Me: "<<(*this)<<" Other: "<<other<<std::endl;
00112       std::cout<<"My Dim: "<<m_uiDim<<" OthDim: "<<other.m_uiDim<<" My MaxD: "<<m_uiMaxDepth<<" othMD: "<<other.m_uiMaxDepth<<std::endl;
00113       assert(false);
00114     }
00115 #endif
00116     return ( (!((*this) < other)) && (!((*this) == other)) );
00117   }//end fn.
00118 
00119   inline bool TreeNode  :: operator  >= ( TreeNode  const & other)  const{
00120 #ifdef __DEBUG_TN__
00121     if( ((this->m_uiDim) != (other.m_uiDim)) || ((this->m_uiMaxDepth) != (other.m_uiMaxDepth)) ) {
00122       std::cout<<"Me: "<<(*this)<<" Other: "<<other<<std::endl;
00123       std::cout<<"My Dim: "<<m_uiDim<<" OthDim: "<<other.m_uiDim<<" My MaxD: "<<m_uiMaxDepth<<" othMD: "<<other.m_uiMaxDepth<<std::endl;
00124       assert(false);
00125     }
00126 #endif
00127     return ( !((*this) < other) ) ;
00128   }//end fn.
00129 
00130   inline TreeNode TreeNode  ::getParent() const {
00131     //For any node at level l, the last (maxD-l) bits are 0. 
00132     //By convention, root's parent is also root.
00133     unsigned int parX,parY,parZ;
00134     unsigned int parLev = (( (m_uiLevel & ot::TreeNode::MAX_LEVEL) > 0)
00135         ? ((m_uiLevel & ot::TreeNode::MAX_LEVEL)-1) : 0);
00136     parX = ( ( m_uiX >> ( m_uiMaxDepth - parLev ) ) << ( m_uiMaxDepth - parLev ) );
00137     parY = ( ( m_uiY >> ( m_uiMaxDepth - parLev ) ) << ( m_uiMaxDepth - parLev ) );
00138     parZ = ( ( m_uiZ >> ( m_uiMaxDepth - parLev ) ) << ( m_uiMaxDepth - parLev ) );
00139     return TreeNode (1,parX,parY,parZ,parLev,m_uiDim,m_uiMaxDepth);
00140   }//end function
00141 
00142   inline TreeNode TreeNode  ::getAncestor(unsigned int ancLev) const {
00143     //For any node at level l, the last (maxD-l) bits are 0. 
00144     unsigned int ancX,ancY,ancZ;
00145     ancX = ( ( m_uiX >> ( m_uiMaxDepth - ancLev ) ) << ( m_uiMaxDepth - ancLev ) );
00146     ancY = ( ( m_uiY >> ( m_uiMaxDepth - ancLev ) ) << ( m_uiMaxDepth - ancLev ) );
00147     ancZ = ( ( m_uiZ >> ( m_uiMaxDepth - ancLev ) ) << ( m_uiMaxDepth - ancLev ) );
00148     return TreeNode (1,ancX,ancY,ancZ,ancLev,m_uiDim,m_uiMaxDepth);
00149   }//end function
00150 
00151   inline int TreeNode::setWeight(unsigned int w) {
00152     m_uiWeight = w;
00153     return 1;
00154   }    
00155 
00156   inline int TreeNode::addWeight(unsigned int w) {
00157     m_uiWeight += w;
00158     return 1;
00159   }    
00160 
00161   inline unsigned int TreeNode::getDim() const {
00162     return m_uiDim;
00163   }
00164 
00165   inline unsigned int TreeNode::getMaxDepth() const {
00166     return m_uiMaxDepth;
00167   }
00168 
00169   inline unsigned int TreeNode::getLevel() const { 
00170     return (m_uiLevel & ot::TreeNode::MAX_LEVEL);   
00171   }
00172 
00173   inline unsigned int TreeNode::getFlag() const { 
00174     return m_uiLevel;   
00175   }
00176 
00177   inline int TreeNode::orFlag(unsigned int w) { 
00178     m_uiLevel = (m_uiLevel | w);
00179     return 1;   
00180   }
00181 
00182   inline int TreeNode::setFlag(unsigned int w) { 
00183     m_uiLevel = w;
00184     return 1;   
00185   }
00186 
00187   inline unsigned int TreeNode::getWeight() const {
00188     return m_uiWeight;
00189   }   
00190 
00191   inline unsigned int TreeNode::getX() const {
00192     return m_uiX;
00193   }
00194 
00195   inline unsigned int TreeNode::getY() const {
00196     return m_uiY;
00197   }
00198 
00199   inline unsigned int TreeNode::getZ() const {
00200     return m_uiZ;
00201   }
00202 
00203   inline unsigned int TreeNode::getParentX() const {
00204     return getParent().getX();
00205   }
00206 
00207   inline unsigned int TreeNode::getParentY() const {
00208     return getParent().getY();
00209   }
00210 
00211   inline unsigned int TreeNode::getParentZ() const {
00212     return getParent().getZ();
00213   }
00214 
00215   inline TreeNode TreeNode  ::getDFD() const {
00216     TreeNode dfd(1,m_uiX,m_uiY,m_uiZ,m_uiMaxDepth,m_uiDim,m_uiMaxDepth);
00217     return dfd;
00218   }//end function
00219 
00220   inline TreeNode TreeNode  ::getDLD() const {
00221     TreeNode dld(1,maxX()-1,maxY()-1,maxZ()-1,m_uiMaxDepth,m_uiDim,m_uiMaxDepth);
00222     return dld;
00223   }//end function
00224 
00225   inline bool TreeNode :: isAncestor(TreeNode const & other) const {
00226 #ifdef __DEBUG_TN__
00227     if( ((this->m_uiDim) != (other.m_uiDim)) || ((this->m_uiMaxDepth) != (other.m_uiMaxDepth)) )  {
00228       std::cout<<"Me: "<<(*this)<<" Other: "<<other<<std::endl;
00229       std::cout<<"My Dim: "<<m_uiDim<<" OthDim: "<<other.m_uiDim<<" My MaxD: "<<m_uiMaxDepth<<" othMD: "<<other.m_uiMaxDepth<<std::endl;
00230       assert(false);
00231     }
00232 #endif
00233     return ( (other > (*this)) && (other <= (this->getDLD())) );
00234   }//end function
00235 
00236   inline unsigned int TreeNode   :: minX() const{       
00237     return getX();
00238   }//end fn.
00239 
00240   inline  unsigned int TreeNode   ::  minY()  const{    
00241     if(m_uiDim < 2) {return 0;}
00242     return getY();
00243   }//end fn.
00244 
00245   inline  unsigned int TreeNode   ::  minZ() const {    
00246     if(m_uiDim < 3) {return 0;}
00247     return getZ();
00248   }//end fn.
00249 
00250   inline  unsigned int TreeNode   ::  maxX() const {    
00251     unsigned int len = (1u << (m_uiMaxDepth - getLevel()));
00252     return (minX() + len);
00253   }//end fn.
00254 
00255   inline  unsigned int TreeNode   ::  maxY() const {    
00256     if(m_uiDim < 2) {return 1;}
00257     unsigned int len = (1u << (m_uiMaxDepth - getLevel()));
00258     return (minY() + len);
00259   }//end fn.
00260 
00261   inline  unsigned int TreeNode   ::  maxZ() const {    
00262     if(m_uiDim < 3) {return 1;}
00263     unsigned int len = (1u << (m_uiMaxDepth - getLevel()));
00264     return (minZ() + len);
00265   }//end fn.
00266 
00267   inline  TreeNode   TreeNode   ::  getLeft() const {
00268     //-ve X
00269     if( minX() > 0 ) {
00270       unsigned int len =  (1u << (m_uiMaxDepth - getLevel()));
00271       unsigned int xres = (minX() - len);
00272       unsigned int yres = minY();
00273       unsigned int zres = minZ();
00274       TreeNode res(1, xres, yres, zres, getLevel(), m_uiDim, m_uiMaxDepth);
00275       return res;
00276     }else {
00277       TreeNode res(m_uiDim, m_uiMaxDepth);
00278       return res;
00279     }
00280   }//end fn.
00281 
00282   inline  TreeNode   TreeNode   ::  getRight() const  {
00283     //+ve X
00284     if( maxX() < (1u << m_uiMaxDepth) ) {
00285     unsigned int xres = maxX();
00286      unsigned int yres = minY();
00287      unsigned int zres = minZ();
00288       TreeNode  res(1, xres, yres, zres, getLevel(), m_uiDim, m_uiMaxDepth);
00289       return res;
00290     }else {
00291       TreeNode res(m_uiDim, m_uiMaxDepth);
00292       return res;
00293     }
00294   }//end fn.
00295   
00296   inline  TreeNode   TreeNode   ::  getBack() const {
00297     //+ve Y
00298     if( (m_uiDim > 1) && (maxY() < (1u << m_uiMaxDepth)) ) {
00299      unsigned int xres = minX();
00300      unsigned int yres = maxY();
00301      unsigned int zres = minZ();
00302       TreeNode res(1, xres, yres, zres, getLevel(), m_uiDim, m_uiMaxDepth);
00303       return res;
00304     }else {
00305       TreeNode res (m_uiDim, m_uiMaxDepth);
00306       return res;
00307     }
00308   }//end fn.
00309 
00310   inline TreeNode   TreeNode   ::  getFront() const {
00311     //-ve Y
00312     if( minY() > 0 ) {
00313      unsigned int len =  (1u << (m_uiMaxDepth - getLevel()));
00314     unsigned int xres = minX();
00315      unsigned int yres = minY() - len;
00316      unsigned int zres = minZ();
00317       TreeNode res(1, xres, yres, zres, getLevel(), m_uiDim, m_uiMaxDepth);
00318       return res;
00319     }else {
00320       TreeNode res(m_uiDim, m_uiMaxDepth);
00321       return res;
00322     }
00323   }//end fn.
00324 
00325   inline TreeNode   TreeNode   ::  getBottom() const {
00326     //-ve Z
00327     if( minZ() > 0 ) {
00328     unsigned int len = (1u << (m_uiMaxDepth - getLevel()));
00329      unsigned int xres = minX();
00330      unsigned int yres = minY();
00331      unsigned int zres = minZ() - len;
00332       TreeNode res(1, xres, yres, zres, getLevel(), m_uiDim, m_uiMaxDepth);
00333       return res;
00334     }else {
00335       TreeNode res(m_uiDim, m_uiMaxDepth);
00336       return res;
00337     }
00338   }//end fn.
00339 
00340   inline  TreeNode   TreeNode   ::  getTop() const {
00341     //+ve Z
00342     if( (m_uiDim == 3) && (maxZ() < (1u << m_uiMaxDepth)) ) {
00343     unsigned int xres = minX();
00344      unsigned int yres = minY() ;
00345      unsigned int zres = maxZ();
00346       TreeNode res(1, xres, yres, zres, getLevel(), m_uiDim, m_uiMaxDepth);
00347       return res;
00348     }else {
00349       TreeNode res(m_uiDim, m_uiMaxDepth);
00350       return res;
00351     }
00352   }//end fn.
00353 
00354   inline  TreeNode   TreeNode   ::  getLeftBack() const {
00355     return (getLeft().getBack());
00356   }//end fn.
00357 
00358   inline  TreeNode    TreeNode   :: getRightBack()  const{
00359     return (getRight().getBack());
00360   }//end fn.
00361 
00362   inline  TreeNode   TreeNode   ::  getLeftFront() const {
00363      return (getLeft().getFront());
00364   }//end fn.
00365 
00366   inline TreeNode   TreeNode   ::  getRightFront() const {
00367      return (getRight().getFront());
00368   }//end fn.
00369 
00370   inline TreeNode   TreeNode   ::  getBottomLeft() const {
00371     return (getBottom().getLeft());
00372   }//end fn.
00373 
00374   inline  TreeNode   TreeNode   ::  getBottomRight() const {
00375     return (getBottom().getRight());
00376   }//end fn.
00377 
00378   inline  TreeNode   TreeNode   ::  getBottomBack() const {
00379     return (getBottom().getBack());
00380   }//end fn.
00381   
00382   inline TreeNode   TreeNode   ::  getBottomFront() const {
00383     return (getBottom().getFront());
00384   }//end fn.
00385 
00386   inline TreeNode   TreeNode   ::  getBottomLeftBack() const {
00387     return (getBottomLeft().getBack());
00388   }//end fn.
00389 
00390   inline  TreeNode   TreeNode   ::  getBottomRightBack() const {
00391     return (getBottomRight().getBack());
00392   }//end fn.
00393 
00394   inline  TreeNode   TreeNode   ::  getBottomLeftFront() const{
00395     return (getBottomLeft().getFront());
00396   }//end fn.
00397 
00398   inline TreeNode   TreeNode   ::  getBottomRightFront()  const{
00399     return (getBottomRight().getFront());
00400   }//end fn.
00401 
00402   inline  TreeNode   TreeNode   ::  getTopLeft() const {
00403     return (getTop().getLeft());
00404   }//end fn.
00405 
00406   inline   TreeNode    TreeNode   :: getTopRight() const {
00407     return (getTop().getRight());
00408   }//end fn.
00409 
00410   inline TreeNode    TreeNode   :: getTopBack() const {
00411     return (getTop().getBack());
00412   }//end fn.
00413 
00414   inline  TreeNode   TreeNode   ::  getTopFront() const {
00415     return (getTop().getFront());
00416   }//end fn.
00417 
00418   inline  TreeNode   TreeNode   ::  getTopLeftBack() const {
00419     return (getTopLeft().getBack());
00420   }//end fn.
00421 
00422   inline TreeNode    TreeNode   :: getTopRightBack() const {
00423     return (getTopRight().getBack());
00424   }//end fn.
00425 
00426   inline  TreeNode   TreeNode   ::  getTopLeftFront() const {
00427     return (getTopLeft().getFront());
00428   }//end fn.
00429 
00430   inline TreeNode   TreeNode   ::  getTopRightFront() const {
00431     return (getTopRight().getFront());
00432   }//end fn.
00433   
00435   //Returns a Vector of Candidates for Balanced Neigbors in a particular direction.
00436   //The results are returned in the following order: 1) Same level, 2) Parent's
00437   //level and 3) Children's level.
00438   //If there is no candidate at the parent's or child's level, then the candidate at the
00439   //same level is returned instead for that position
00440   //Note: For the neighbours at the parent's level, the dimension is not
00441   //considered explicitly. It is implicit in the childNum.
00442 
00443   inline std::vector<TreeNode >  TreeNode   :: getB_Left() const {
00444     unsigned int dim = m_uiDim;
00445 
00446 #ifdef __DEBUG_TN__
00447     std::cout<<RED<<"L"<<NRM<<std::endl;
00448 #endif
00449     std::vector<TreeNode > it;
00450     if(dim == 3) {
00451       it.resize(6);
00452     }else if(dim == 2) {
00453       it.resize(4);
00454     }else {
00455       it.resize(3);
00456     }
00457 
00458     it[0] = getLeft();
00459     unsigned int childNum = getChildNumber();
00460 
00461     //0,2,4,6
00462     if((childNum == 0) || (childNum == 2) || (childNum == 4) || (childNum == 6) ){
00463       it[1] = getParent().getLeft();    
00464     }else {
00465       it[1] = it[0]; 
00466     }   
00467 
00468     std::vector<TreeNode> children;
00469     addChildren(children);
00470     it[2] = children[0].getLeft();
00471     if(dim > 1) {
00472       it[3] = children[2].getLeft();
00473     }
00474     if(dim > 2) {
00475       it[4] = children[4].getLeft();    
00476       it[5] = children[6].getLeft();
00477     }
00478     children.clear();
00479     return it;
00480   }//end fn. 
00481 
00482 
00483   inline std::vector<TreeNode >  TreeNode   :: getB_Right() const {
00484     unsigned int dim = m_uiDim;
00485 
00486 #ifdef __DEBUG_TN__
00487     std::cout<<RED<<"R"<<NRM<<std::endl;
00488 #endif
00489     std::vector<TreeNode > it;
00490     if(dim == 3) {
00491       it.resize(6);
00492     }else if(dim == 2) {
00493       it.resize(4);
00494     }else {
00495       it.resize(3);
00496     }
00497     //1,3,5,7
00498     it[0] = getRight();
00499     unsigned int childNum = getChildNumber();
00500     if((childNum == 1) || (childNum == 3) || (childNum == 5) || (childNum == 7)){
00501       it[1] = getParent().getRight();
00502     }else {
00503       it[1] = it[0]; 
00504     }   
00505     std::vector<TreeNode> children;
00506     addChildren(children);
00507     it[2] = children[1].getRight();
00508     if(dim > 1) {
00509       it[3] = children[3].getRight();
00510     }
00511     if(dim >2) {
00512       it[4] = children[5].getRight();   
00513       it[5] = children[7].getRight();
00514     }
00515     children.clear();
00516     return it;
00517   }//end fn. 
00518 
00519 
00520   inline std::vector<TreeNode >  TreeNode   :: getB_Top() const {
00521     unsigned int dim = m_uiDim;
00522 
00523 #ifdef __DEBUG_TN__
00524     std::cout<<RED<<"T"<<NRM<<std::endl;
00525 #endif
00526     std::vector<TreeNode > it;
00527     if(dim == 3) {
00528       it.resize(6);
00529     }else if(dim == 2) {
00530       it.resize(0);
00531       return it;
00532     }else {
00533       it.resize(0);
00534       return it;
00535     }
00536     //4,5,6,7
00537     it[0] = getTop();
00538     unsigned int childNum = getChildNumber();
00539     if( (childNum  == 4) || (childNum == 5) || (childNum  == 6) || (childNum == 7) ) {
00540       it[1] = getParent().getTop();     
00541     }else {
00542       it[1] = it[0]; 
00543     }   
00544     std::vector<TreeNode> children;
00545     addChildren(children);
00546     it[2] = children[4].getTop();       
00547     it[3] = children[5].getTop();
00548     it[4] = children[6].getTop();       
00549     it[5] = children[7].getTop();
00550     children.clear();
00551     return it;
00552   }//end fn. 
00553 
00554 
00555   inline std::vector<TreeNode >  TreeNode   :: getB_Bottom() const{
00556     unsigned int dim = m_uiDim;
00557 
00558 #ifdef __DEBUG_TN__
00559     std::cout<<RED<<"Bo"<<NRM<<std::endl;
00560 #endif
00561     std::vector<TreeNode > it;
00562     if(dim == 3) {
00563       it.resize(6);
00564     }else if(dim == 2) {
00565       it.resize(0);
00566       return it;
00567     }else {
00568       it.resize(0);
00569       return it;
00570     }
00571     //0,1,2,3
00572     it[0] = getBottom();
00573     unsigned int childNum = getChildNumber();
00574     if( (childNum == 0) || (childNum == 1) || ( childNum == 2) || ( childNum == 3) ) {
00575       it[1] = getParent().getBottom();  
00576     }else {
00577       it[1] = it[0]; 
00578     }   
00579     std::vector<TreeNode> children;
00580     addChildren(children);
00581     it[2] = children[0].getBottom();     
00582     it[3] = children[1].getBottom();
00583     it[4] = children[2].getBottom();    
00584     it[5] = children[3].getBottom();
00585     children.clear();
00586     return it;
00587   }//end fn. 
00588 
00589 
00590   inline std::vector<TreeNode >  TreeNode   :: getB_Front() const{
00591     unsigned int dim = m_uiDim;
00592 
00593 #ifdef __DEBUG_TN__
00594     std::cout<<RED<<"F"<<NRM<<std::endl;
00595 #endif
00596     std::vector<TreeNode > it;
00597     if(dim == 3) {
00598       it.resize(6);
00599     }else if(dim == 2) {
00600       it.resize(4);
00601     }else {
00602       it.resize(0);
00603       return it;
00604     }
00605     //0,1,4,5
00606     it[0] = getFront();
00607     unsigned int childNum = getChildNumber();
00608     if( (childNum == 0) || (childNum == 1) ||(childNum == 4) || (childNum == 5) ) {
00609       it[1] = getParent().getFront();   
00610     }else {
00611       it[1] = it[0]; 
00612     }   
00613     std::vector<TreeNode> children;
00614     addChildren(children);
00615     it[2] = children[0].getFront();     
00616     it[3] = children[1].getFront();     
00617     if(dim >2) {
00618       it[4] = children[4].getFront();   
00619       it[5] = children[5].getFront();
00620     }
00621     children.clear();
00622     return it;
00623   }//end fn. 
00624 
00625 
00626   inline std::vector<TreeNode >  TreeNode   :: getB_Back() const{
00627     unsigned int dim = m_uiDim;
00628 
00629 #ifdef __DEBUG_TN__
00630     std::cout<<RED<<"Bk"<<NRM<<std::endl;
00631 #endif
00632     std::vector<TreeNode > it;
00633     if(dim == 3) {
00634       it.resize(6);
00635     }else if(dim == 2) {
00636       it.resize(4);
00637     }else {
00638       it.resize(0);
00639       return it;
00640     }
00641     //2,3,6,7
00642     it[0] = getBack();
00643     unsigned int childNum = getChildNumber();
00644     if( (childNum == 2) || (childNum == 3) || (childNum == 6)||(childNum == 7) ) {
00645       it[1] = getParent().getBack();
00646     }else {
00647       it[1] = it[0]; 
00648     }   
00649     std::vector<TreeNode> children;
00650     addChildren(children);
00651     it[2] = children[2].getBack();      
00652     it[3] = children[3].getBack();      
00653     if(dim == 3) {
00654       it[4] = children[6].getBack();    
00655       it[5] = children[7].getBack();
00656     }
00657     children.clear(); 
00658     return it;
00659   }//end fn. 
00660 
00661 
00662   inline std::vector<TreeNode >  TreeNode   :: getB_TopLeft() const{
00663     unsigned int dim = m_uiDim;
00664 
00665 #ifdef __DEBUG_TN__
00666     std::cout<<RED<<"TL"<<NRM<<std::endl;
00667 #endif
00668     std::vector<TreeNode > it;
00669     if(dim == 3) {
00670       it.resize(4);
00671     }else if(dim == 2) {
00672       it.resize(0);
00673       return it;
00674     }else {
00675       it.resize(0);
00676       return it;
00677     }
00678     //4,6 -> TL
00679     //5,7->T but not L
00680     //0,2->L but not T
00681     it[0] = getTopLeft();
00682     unsigned int childNum = getChildNumber();
00683     if( (childNum == 4) || (childNum == 6) ) {
00684       it[1] = getParent().getTopLeft(); 
00685     }else if( (childNum == 5) || (childNum == 7) ){
00686       it[1] = getParent().getTop();     
00687     }else if( (childNum == 0) || (childNum == 2) ){
00688       it[1] = getParent().getLeft();    
00689     }else {
00690       it[1] = it[0]; 
00691     }   
00692     std::vector<TreeNode> children;
00693     addChildren(children);
00694     it[2] = children[4].getTopLeft();
00695     it[3] = children[6].getTopLeft();
00696     children.clear();
00697     return it;
00698   }//end fn. 
00699 
00700 
00701   inline std::vector<TreeNode >  TreeNode   :: getB_TopRight() const{
00702     unsigned int dim = m_uiDim;
00703 
00704 #ifdef __DEBUG_TN__
00705     std::cout<<RED<<"TR"<<NRM<<std::endl;
00706 #endif
00707     std::vector<TreeNode > it;
00708     if(dim == 3) {
00709       it.resize(4);
00710     }else if(dim == 2) {
00711       it.resize(0);
00712       return it;
00713     }else {
00714       it.resize(0);
00715       return it;
00716     }
00717     //5,7 TR
00718     //4,6 T but not R
00719     //1,3 R but not T
00720     it[0] = getTopRight();
00721     unsigned int childNum = getChildNumber();
00722     if( (childNum == 5) || (childNum == 7) ) {
00723       it[1] = getParent().getTopRight();        
00724     }else if( (childNum == 4) || (childNum == 6) ){
00725       it[1] = getParent().getTop();     
00726     }else if( (childNum == 1) || (childNum == 3) ){
00727       it[1] = getParent().getRight();   
00728     }else {     
00729       it[1] = it[0]; 
00730     }   
00731     std::vector<TreeNode> children;
00732     addChildren(children);
00733     it[2] = children[5].getTopRight();
00734     it[3] = children[7].getTopRight();
00735     children.clear(); 
00736     return it;
00737   }//end fn. 
00738 
00739 
00740   inline std::vector<TreeNode >  TreeNode   :: getB_BottomLeft() const{ 
00741     unsigned int dim = m_uiDim;
00742 
00743 #ifdef __DEBUG_TN__
00744     std::cout<<RED<<"BoL"<<NRM<<std::endl;
00745 #endif
00746     std::vector<TreeNode > it;
00747     if(dim == 3) {
00748       it.resize(4);
00749     }else if(dim == 2) {
00750       it.resize(0);
00751       return it;
00752     }else {
00753       it.resize(0);
00754       return it;
00755     }
00756     //0,2 BL
00757     //4,6 L but not B
00758     //1,3 B but not L
00759     it[0] = getBottomLeft();
00760     unsigned int childNum = getChildNumber();
00761     if( (childNum == 0) || (childNum == 2) ) {
00762       it[1] = getParent().getBottomLeft();      
00763     }else if( (childNum == 1) || (childNum == 3) ){
00764       it[1] = getParent().getBottom();  
00765     }else if( (childNum == 4) || (childNum == 6) ){
00766       it[1] = getParent().getLeft();    
00767     }else {
00768       it[1] = it[0]; 
00769     }   
00770     std::vector<TreeNode> children;
00771     addChildren(children);
00772     it[2] = children[0].getBottomLeft();
00773     it[3] = children[2].getBottomLeft();
00774     children.clear();
00775     return it;
00776   }//end fn. 
00777 
00778 
00779   inline std::vector<TreeNode >  TreeNode   :: getB_BottomRight() const{
00780     unsigned int dim = m_uiDim;
00781 
00782 #ifdef __DEBUG_TN__
00783     std::cout<<RED<<"BoR"<<NRM<<std::endl;
00784 #endif
00785     std::vector<TreeNode > it;
00786     if(dim == 3) {
00787       it.resize(4);
00788     }else if(dim == 2) {
00789       it.resize(0);
00790       return it;
00791     }else {
00792       it.resize(0);
00793       return it;
00794     }
00795     //1,3 BR
00796     //0,2 B but not R
00797     //5,7 R but not B
00798     it[0] = getBottomRight();
00799     unsigned int childNum = getChildNumber();
00800     if( (childNum == 1) || (childNum == 3) ) {
00801       it[1] = getParent().getBottomRight();     
00802     }else if( (childNum == 0) || (childNum == 2) ){
00803       it[1] = getParent().getBottom();  
00804     }else if( (childNum == 5) || (childNum == 7) ){
00805       it[1] = getParent().getRight();   
00806     }else {
00807       it[1] = it[0]; 
00808     }   
00809     std::vector<TreeNode> children;
00810     addChildren(children);
00811     it[2] = children[1].getBottomRight();
00812     it[3] = children[3].getBottomRight();
00813     children.clear();
00814     return it;
00815   }//end fn. 
00816 
00817 
00818   inline std::vector<TreeNode >  TreeNode   :: getB_LeftFront() const{
00819     unsigned int dim = m_uiDim;
00820 
00821 #ifdef __DEBUG_TN__
00822     std::cout<<RED<<"LF"<<NRM<<std::endl;
00823 #endif
00824     std::vector<TreeNode > it;
00825     if(dim == 3) {
00826       it.resize(4);
00827     }else if(dim == 2) {
00828       it.resize(3);
00829     }else {
00830       it.resize(0);
00831       return it;
00832     }
00833     //0,4 LF
00834     //1,5 F but not L
00835     //2,6 L but not F
00836     it[0] = getLeftFront();
00837     unsigned int childNum = getChildNumber();
00838 
00839     if((childNum == 0) || (childNum == 4)) {
00840       it[1] = getParent().getLeftFront();
00841     }else if((childNum == 1) || (childNum == 5)) {
00842       it[1] = getParent().getFront();
00843     }else if((childNum == 2) || (childNum == 6)) {
00844       it[1] = getParent().getLeft();
00845     }
00846     std::vector<TreeNode> children;
00847     addChildren(children);
00848     it[2] = children[0].getLeftFront();
00849     if(dim >2) {        
00850       it[3] = children[4].getLeftFront();
00851     }
00852     children.clear();
00853     return it;
00854   }//end fn. 
00855 
00856 
00857   inline std::vector<TreeNode >  TreeNode   :: getB_RightFront() const{
00858     unsigned int dim = m_uiDim;
00859 
00860 #ifdef __DEBUG_TN__
00861     std::cout<<RED<<"RF"<<NRM<<std::endl;
00862 #endif
00863     std::vector<TreeNode > it;
00864     if(dim == 3) {
00865       it.resize(4);
00866     }else if(dim == 2) {
00867       it.resize(3);
00868     }else {
00869       it.resize(0);
00870       return it;
00871     }
00872     //1,5 RF
00873     //0,4 F but not R
00874     //3,7 R but not F
00875     it[0] = getRightFront();
00876     unsigned int childNum = getChildNumber();
00877     if( (childNum == 1) || (childNum == 5) ) {
00878       it[1] = getParent().getRightFront();      
00879     }else if( (childNum == 0) || (childNum == 4) ) {
00880       it[1] = getParent().getFront();   
00881     }else if((childNum == 3) || (childNum == 7)) {
00882       it[1] = getParent().getRight();   
00883     }   
00884 
00885     std::vector<TreeNode> children;
00886     addChildren(children);
00887     it[2] = children[1].getRightFront();
00888     if(dim > 2) {
00889       it[3] = children[5].getRightFront();
00890     }
00891     children.clear();
00892     return it;
00893   }//end fn. 
00894 
00895 
00896   inline std::vector<TreeNode >  TreeNode   :: getB_TopFront() const{
00897     unsigned int dim = m_uiDim;
00898 
00899 #ifdef __DEBUG_TN__
00900     std::cout<<RED<<"TF"<<NRM<<std::endl;
00901 #endif
00902     std::vector<TreeNode > it;
00903     if(dim == 3) {
00904       it.resize(4);
00905     }else if(dim == 2) {
00906       it.resize(0);
00907       return it;
00908     }else {
00909       it.resize(0);
00910       return it;
00911     }
00912     //4,5 TF
00913     //6,7 T but not F
00914     //0,1 F but not T
00915     it[0] = getTopFront();
00916     unsigned int childNum = getChildNumber();
00917     if( (childNum == 4) || (childNum == 5) ) {
00918       it[1] = getParent().getTopFront();        
00919     }else if( (childNum == 6) || (childNum == 7) ){
00920       it[1] = getParent().getTop();     
00921     }else if( (childNum == 0) || (childNum == 1) ){
00922       it[1] = getParent().getFront();   
00923     }else {
00924       it[1] = it[0]; 
00925     }   
00926     std::vector<TreeNode> children;
00927     addChildren(children);
00928     it[2] = children[4].getTopFront();  
00929     it[3] = children[5].getTopFront();
00930     children.clear();
00931     return it;
00932   }//end fn. 
00933 
00934 
00935   inline std::vector<TreeNode >  TreeNode   :: getB_BottomFront() const{
00936     unsigned int dim = m_uiDim;
00937 
00938 #ifdef __DEBUG_TN__
00939     std::cout<<RED<<"BoF"<<NRM<<std::endl;
00940 #endif
00941     std::vector<TreeNode > it;
00942     if(dim == 3) {
00943       it.resize(4);
00944     }else if(dim == 2) {
00945       it.resize(0);
00946       return it;
00947     }else {
00948       it.resize(0);
00949       return it;
00950     }
00951     //0,1 BoF
00952     //2,3 Bo but not F
00953     //4,5 F but not Bo
00954     it[0] = getBottomFront();
00955     unsigned int childNum = getChildNumber();
00956     if( (childNum == 0) || (childNum == 1) ) {
00957       it[1] = getParent().getBottomFront();     
00958     }else if( (childNum == 2) || (childNum == 3) ){
00959       it[1] = getParent().getBottom();  
00960     }else if( (childNum == 4) || (childNum == 5) ){
00961       it[1] = getParent().getFront();   
00962     }else {
00963       it[1] = it[0]; 
00964     }   
00965     std::vector<TreeNode> children;
00966     addChildren(children);
00967     it[2] = children[0].getBottomFront();        
00968     it[3] = children[1].getBottomFront();
00969     children.clear();
00970     return it;
00971   }//end fn. 
00972 
00973 
00974   inline std::vector<TreeNode >  TreeNode   :: getB_TopLeftFront() const{
00975     unsigned int dim = m_uiDim;
00976 
00977 #ifdef __DEBUG_TN__
00978     std::cout<<RED<<"TLF"<<NRM<<std::endl;
00979 #endif
00980     std::vector<TreeNode > it;
00981     if(dim == 3) {
00982       it.resize(3);
00983     }else if(dim == 2) {
00984       it.resize(0);
00985       return it;
00986     }else {
00987       it.resize(0);
00988       return it;
00989     }
00990     //4 TLF
00991     //6 TL but not F
00992     //0 LF but not T
00993     //5 TF but not L
00994     //7 T but not LF
00995     //2 L but not TF
00996     //1 F but not TL
00997     it[0] = getTopLeftFront();
00998     unsigned int childNum = getChildNumber();
00999     if( (childNum == 4) ) {
01000       it[1] = getParent().getTopLeftFront();    
01001     }else if( (childNum == 6) ) {
01002       it[1] = getParent().getTopLeft(); 
01003     }else if( (childNum == 0) ) {
01004       it[1] = getParent().getLeftFront();       
01005     }else if( (childNum == 5) ) {
01006       it[1] = getParent().getTopFront();        
01007     }else if( (childNum == 7) ){
01008       it[1] = getParent().getTop();     
01009     }else if( (childNum == 2) ){
01010       it[1] = getParent().getLeft();    
01011     }else if( (childNum == 1) ){
01012       it[1] = getParent().getFront();   
01013     }else {
01014       it[1] = it[0]; 
01015     }   
01016     std::vector<TreeNode> children;
01017     addChildren(children);
01018     it[2] = children[4].getTopLeftFront();
01019     children.clear();
01020     return it;
01021   }//end fn. 
01022 
01023 
01024   inline std::vector<TreeNode >  TreeNode   :: getB_TopRightFront() const{
01025     unsigned int dim = m_uiDim;
01026 
01027 #ifdef __DEBUG_TN__
01028     std::cout<<RED<<"TRF"<<NRM<<std::endl;
01029 #endif
01030     std::vector<TreeNode > it;
01031     if(dim == 3) {
01032       it.resize(3);
01033     }else if(dim == 2) {
01034       it.resize(0);
01035       return it;
01036     }else {
01037       it.resize(0);
01038       return it;
01039     }
01040     //5 TRF
01041     //7 TR but not F
01042     //1 RF but not T
01043     //4 TF but not R
01044     //6 T but not RF
01045     //3 R but not TF
01046     //0 F but not TR
01047     it[0] = getTopRightFront();
01048     unsigned int childNum = getChildNumber();
01049     if( (childNum == 5) ) {
01050       it[1] = getParent().getTopRightFront();   
01051     }else if( (childNum == 7) ) {
01052       it[1] = getParent().getTopRight();        
01053     }else if( (childNum == 1) ) {
01054       it[1] = getParent().getRightFront();      
01055     }else if( (childNum == 4) ) {
01056       it[1] = getParent().getTopFront();        
01057     }else if( (childNum == 6) ){
01058       it[1] = getParent().getTop();     
01059     }else if( (childNum == 3) ){
01060       it[1] = getParent().getRight();   
01061     }else if( (childNum == 0) ){
01062       it[1] = getParent().getFront();   
01063     }else {
01064       it[1] = it[0]; 
01065     }   
01066     std::vector<TreeNode> children;
01067     addChildren(children);
01068     it[2] = children[5].getTopRightFront();
01069     children.clear();
01070     return it;
01071   }//end fn. 
01072 
01073 
01074   inline std::vector<TreeNode >  TreeNode   :: getB_BottomLeftFront() const{
01075     unsigned int dim = m_uiDim;
01076 
01077 #ifdef __DEBUG_TN__
01078     std::cout<<RED<<"BoLF"<<NRM<<std::endl;
01079 #endif
01080     std::vector<TreeNode > it;
01081     if(dim == 3) {
01082       it.resize(3);
01083     }else if(dim == 2) {
01084       it.resize(0);
01085       return it;
01086     }else {
01087       it.resize(0);
01088       return it;
01089     }
01090     //0 BoLF
01091     //2 BoL but not F
01092     //4 LF but not Bo
01093     //1 BoF but not L
01094     //3 Bo but not LF
01095     //6 L but not BoF
01096     //5 F but not BoL
01097     it[0] = getBottomLeftFront();
01098     unsigned int childNum = getChildNumber();
01099     if( (childNum == 0) ) {
01100       it[1] = getParent().getBottomLeftFront(); 
01101     }else if( (childNum == 2) ) {
01102       it[1] = getParent().getBottomLeft();      
01103     }else if( (childNum == 4) ){
01104       it[1] = getParent().getLeftFront();       
01105     }else if( (childNum == 1) ) {
01106       it[1] = getParent().getBottomFront();     
01107     }else if( (childNum == 3) ) {
01108       it[1] = getParent().getBottom();  
01109     }else if( (childNum == 6) ){
01110       it[1] = getParent().getLeft();    
01111     }else if( (childNum == 5) ) {
01112       it[1] = getParent().getFront();   
01113     }else {
01114       it[1] = it[0]; 
01115     }   
01116     std::vector<TreeNode> children;
01117     addChildren(children);
01118     it[2] = children[0].getBottomLeftFront();
01119     children.clear();
01120     return it;
01121   }//end fn. 
01122 
01123 
01124   inline std::vector<TreeNode >  TreeNode   :: getB_BottomRightFront() const{
01125     unsigned int dim = m_uiDim;
01126 
01127 #ifdef __DEBUG_TN__
01128     std::cout<<RED<<"BoRF"<<NRM<<std::endl;
01129 #endif
01130     std::vector<TreeNode > it;
01131     if(dim == 3) {
01132       it.resize(3);
01133     }else if(dim == 2) {
01134       it.resize(0);
01135       return it;
01136     }else {
01137       it.resize(0);
01138       return it;
01139     }
01140     //1 BoRF
01141     //3 BoR
01142     //5 RF
01143     //0 BoF
01144     //2 Bo
01145     //7 R
01146     //4 F
01147     it[0] = getBottomRightFront();
01148     unsigned int childNum = getChildNumber();
01149     if( (childNum == 1) ) {
01150       it[1] = getParent().getBottomRightFront();        
01151     }else if( (childNum == 3) ) {
01152       it[1] = getParent().getBottomRight();     
01153     }else if( (childNum == 5) ) {
01154       it[1] = getParent().getRightFront();      
01155     }else if( (childNum == 0) ) {
01156       it[1] = getParent().getBottomFront();     
01157     }else if( (childNum == 2) ){
01158       it[1] = getParent().getBottom();  
01159     }else if( (childNum == 7) ){
01160       it[1] = getParent().getRight();   
01161     }else if( (childNum == 4) ){
01162       it[1] = getParent().getFront();   
01163     }else {
01164       it[1] = it[0]; 
01165     }   
01166     std::vector<TreeNode> children;
01167     addChildren(children);
01168     it[2] = children[1].getBottomRightFront();
01169     children.clear(); 
01170     return it;
01171   }//end fn. 
01172 
01173 
01174   inline std::vector<TreeNode >  TreeNode   :: getB_LeftBack() const{
01175     unsigned int dim = m_uiDim;
01176 
01177 #ifdef __DEBUG_TN__
01178     std::cout<<RED<<"LBk"<<NRM<<std::endl;
01179 #endif
01180     std::vector<TreeNode > it;
01181     if(dim == 3) {
01182       it.resize(4);
01183     }else if(dim == 2) {
01184       it.resize(3);
01185     }else {
01186       it.resize(0);
01187       return it;
01188     }
01189     //2,6 LBk
01190     //0,4 L not Bk
01191     //3,7 Bk not L
01192     it[0] = getLeftBack();
01193     unsigned int childNum = getChildNumber();
01194     if((childNum == 2) || (childNum == 6)) {
01195       it[1] = getParent().getLeftBack();        
01196     }else if( (childNum == 0) || (childNum == 4)) {
01197       it[1] = getParent().getLeft();    
01198     }else if( (childNum == 3) || (childNum == 7 )) {
01199       it[1] = getParent().getBack();    
01200     }else {
01201       it[1] = it[0]; 
01202     }   
01203     std::vector<TreeNode> children;
01204     addChildren(children);
01205     it[2] = children[2].getLeftBack();  
01206     if(dim == 3) {      
01207       it[3] = children[6].getLeftBack();
01208     }
01209     children.clear(); 
01210     return it;
01211   }//end fn. 
01212 
01213 
01214   inline std::vector<TreeNode >  TreeNode   :: getB_RightBack() const{
01215     unsigned int dim = m_uiDim;
01216 
01217 #ifdef __DEBUG_TN__
01218     std::cout<<RED<<"RBk"<<NRM<<std::endl;
01219 #endif
01220     std::vector<TreeNode > it;
01221     if(dim == 3) {
01222       it.resize(4);
01223     }else if(dim == 2) {
01224       it.resize(3);
01225     }else {
01226       it.resize(0);
01227       return it;
01228     }
01229     //3,7 RBk
01230     //1,5 R
01231     //2,6 Bk
01232     it[0] = getRightBack();
01233     unsigned int childNum = getChildNumber();
01234     if((childNum == 3) || (childNum == 7)) {
01235       it[1] = getParent().getRightBack();       
01236     }else if( (childNum == 1) || (childNum == 5) ) {
01237       it[1] = getParent().getRight();   
01238     } else if( (childNum == 2) || (childNum == 6)) {
01239       it[1] = getParent().getBack();    
01240     }else {
01241       it[1] = it[0]; 
01242     }
01243     std::vector<TreeNode> children;
01244     addChildren(children);
01245     it[2] = children[3].getRightBack(); 
01246     if(dim == 3) {
01247       it[3] = children[7].getRightBack();
01248     }
01249     children.clear();
01250     return it;
01251   }//end fn. 
01252 
01253 
01254   inline std::vector<TreeNode >  TreeNode   :: getB_TopBack() const{
01255     unsigned int dim = m_uiDim;
01256 
01257 #ifdef __DEBUG_TN__
01258     std::cout<<RED<<"TBk"<<NRM<<std::endl;
01259 #endif
01260     std::vector<TreeNode > it;
01261     if(dim == 3) {
01262       it.resize(4);
01263     }else if(dim == 2) {
01264       it.resize(0);
01265       return it;
01266     }else {
01267       it.resize(0);
01268       return it;
01269     }
01270     //6,7 TBk
01271     //4,5 T
01272     //2,3 Bk
01273     it[0] = getTopBack();
01274     unsigned int childNum = getChildNumber();
01275     if( (childNum == 6) || (childNum == 7) ) {
01276       it[1] = getParent().getTopBack(); 
01277     }else if( (childNum == 4) || (childNum == 5) ){
01278       it[1] = getParent().getTop();     
01279     }else if( (childNum == 2) || (childNum == 3) ){
01280       it[1] = getParent().getBack();    
01281     }else {
01282       it[1] = it[0]; 
01283     }   
01284     std::vector<TreeNode> children;
01285     addChildren(children);
01286     it[2] = children[6].getTopBack();   
01287     it[3] = children[7].getTopBack();
01288     children.clear();
01289     return it;
01290   }//end fn. 
01291 
01292 
01293   inline std::vector<TreeNode >  TreeNode   :: getB_BottomBack() const{
01294     unsigned int dim = m_uiDim;
01295 
01296 #ifdef __DEBUG_TN__
01297     std::cout<<RED<<"BoBk"<<NRM<<std::endl;
01298 #endif
01299     std::vector<TreeNode > it;
01300     if(dim == 3) {
01301       it.resize(4);
01302     }else if(dim == 2) {
01303       it.resize(0);
01304       return it;
01305     }else {
01306       it.resize(0);
01307       return it;
01308     }
01309     //2,3 BoBk
01310     //0,1 Bo
01311     //6,7 Bk
01312     it[0] = getBottomBack();
01313     unsigned int childNum = getChildNumber();
01314     if( (childNum == 2) || (childNum == 3) ) {
01315       it[1] = getParent().getBottomBack();      
01316     }else if( (childNum == 0) || (childNum == 1) ){
01317       it[1] = getParent().getBottom();  
01318     }else if( (childNum == 6) || (childNum == 7) ){
01319       it[1] = getParent().getBack();    
01320     }else {
01321       it[1] = it[0]; 
01322     }   
01323     std::vector<TreeNode> children;
01324     addChildren(children);
01325     it[2] = children[2].getBottomBack();         
01326     it[3] = children[3].getBottomBack();
01327     children.clear();
01328     return it;
01329   }//end fn. 
01330 
01331 
01332   inline std::vector<TreeNode >  TreeNode   :: getB_TopLeftBack() const{
01333     unsigned int dim = m_uiDim;
01334 
01335 #ifdef __DEBUG_TN__
01336     std::cout<<RED<<"TLBk"<<NRM<<std::endl;
01337 #endif
01338     std::vector<TreeNode > it;
01339     if(dim == 3) {
01340       it.resize(3);
01341     }else if(dim == 2) {
01342       it.resize(0);
01343       return it;
01344     }else {
01345       it.resize(0);
01346       return it;
01347     }
01348     //6 TLBk
01349     //4 TL
01350     //2 LBk
01351     //7 TBk
01352     //5 T
01353     //0 L
01354     //3 Bk
01355     it[0] = getTopLeftBack();
01356     unsigned int childNum = getChildNumber();
01357     if( (childNum == 6) ) {
01358       it[1] = getParent().getTopLeftBack();     
01359     }else if( (childNum == 4) ) {
01360       it[1] = getParent().getTopLeft(); 
01361     }else if( (childNum == 2) ) {
01362       it[1] = getParent().getLeftBack();        
01363     }else if( (childNum == 7) ) {
01364       it[1] = getParent().getTopBack(); 
01365     }else if( (childNum == 5) ){
01366       it[1] = getParent().getTop();     
01367     }else if( (childNum == 0) ){
01368       it[1] = getParent().getLeft();    
01369     }else if( (childNum == 3) ){
01370       it[1] = getParent().getBack();    
01371     }else {
01372       it[1] = it[0]; 
01373     }   
01374     std::vector<TreeNode> children;
01375     addChildren(children);
01376     it[2] = children[6].getTopLeftBack();
01377     children.clear();
01378     return it;
01379   }//end fn. 
01380 
01381   inline std::vector<TreeNode >  TreeNode   :: getB_TopRightBack() const{
01382     unsigned int dim = m_uiDim;
01383 
01384 #ifdef __DEBUG_TN__
01385     std::cout<<RED<<"TRBk"<<NRM<<std::endl;
01386 #endif
01387     std::vector<TreeNode > it;
01388     if(dim == 3) {
01389       it.resize(3);
01390     }else if(dim == 2) {
01391       it.resize(0);
01392       return it;
01393     }else {
01394       it.resize(0);
01395       return it;
01396     }
01397     //7 TRBk
01398     //5 TR
01399     //3 RBk
01400     //6 TBk
01401     //4 T
01402     //1 R
01403     //2 Bk
01404     it[0] = getTopRightBack();
01405     unsigned int childNum = getChildNumber();
01406     if( (childNum == 7) ) {
01407       it[1] = getParent().getTopRightBack();    
01408     }else if( (childNum == 5) ) {
01409       it[1] = getParent().getTopRight();        
01410     }else if( (childNum == 3) ) {
01411       it[1] = getParent().getRightBack();       
01412     }else if( (childNum == 6) ) {
01413       it[1] = getParent().getTopBack(); 
01414     }else if( (childNum == 4) ){
01415       it[1] = getParent().getTop();     
01416     }else if( (childNum == 1) ){
01417       it[1] = getParent().getRight();   
01418     }else if( (childNum == 2) ){
01419       it[1] = getParent().getBack();    
01420     }else {
01421       it[1] = it[0]; 
01422     }   
01423     std::vector<TreeNode> children;
01424     addChildren(children);
01425     it[2] = children[7].getTopRightBack();
01426     children.clear();
01427     return it;
01428   }//end fn. 
01429 
01430 
01431   inline std::vector<TreeNode >  TreeNode   :: getB_BottomLeftBack() const{
01432     unsigned int dim = m_uiDim;
01433 
01434 #ifdef __DEBUG_TN__
01435     std::cout<<RED<<"BoLBk"<<NRM<<std::endl;
01436 #endif
01437     std::vector<TreeNode > it;
01438     if(dim == 3) {
01439       it.resize(3);
01440     }else if(dim == 2) {
01441       it.resize(0);
01442       return it;
01443     }else {
01444       it.resize(0);
01445       return it;
01446     }
01447     //2 BoLBk
01448     //0 BoL
01449     //6 LBk
01450     //3 BoBk
01451     //1 Bo
01452     //4 L
01453     //7 Bk
01454     it[0] = getBottomLeftBack();
01455     unsigned int childNum = getChildNumber();
01456     if( (childNum == 2) ) {
01457       it[1] = getParent().getBottomLeftBack();  
01458     }else if( (childNum == 0) ) {
01459       it[1] = getParent().getBottomLeft();      
01460     }else if( (childNum == 6) ) {
01461       it[1] = getParent().getLeftBack();        
01462     }else if( (childNum == 3) ) {
01463       it[1] = getParent().getBottomBack();      
01464     }else if( (childNum == 1) ){
01465       it[1] = getParent().getBottom();  
01466     }else if( (childNum == 4) ){
01467       it[1] = getParent().getLeft();    
01468     }else if( (childNum == 7) ){
01469       it[1] = getParent().getBack();    
01470     }else {
01471       it[1] = it[0]; 
01472     }   
01473     std::vector<TreeNode> children;
01474     addChildren(children);
01475     it[2] = children[2].getBottomLeftBack();
01476     children.clear();
01477     return it;
01478   }//end fn. 
01479 
01480   inline std::vector<TreeNode >  TreeNode   :: getB_BottomRightBack() const{
01481     unsigned int dim = m_uiDim;
01482 
01483 #ifdef __DEBUG_TN__
01484     std::cout<<RED<<"BoRBk"<<NRM<<std::endl;
01485 #endif
01486     std::vector<TreeNode > it;
01487     if(dim == 3) {
01488       it.resize(3);
01489     }else if(dim == 2) {
01490       it.resize(0);
01491       return it;
01492     }else {
01493       it.resize(0);
01494       return it;
01495     }
01496     //3 BoRBk
01497     //1 BoR
01498     //7 RBk
01499     //2 BoBk
01500     //0 Bo
01501     //5 R
01502     //6 Bk
01503     it[0] = getBottomRightBack();
01504     unsigned int childNum = getChildNumber();
01505     if( (childNum == 3) ) {
01506       it[1] = getParent().getBottomRightBack(); 
01507     }else if( (childNum == 1) ) {
01508       it[1] = getParent().getBottomRight();     
01509     }else if( (childNum == 7) ) {
01510       it[1] = getParent().getRightBack();       
01511     }else if( (childNum == 2) ) {
01512       it[1] = getParent().getBottomBack();      
01513     }else if( (childNum == 0) ){
01514       it[1] = getParent().getBottom();  
01515     }else if( (childNum == 5) ){
01516       it[1] = getParent().getRight();   
01517     }else if( (childNum == 6) ){
01518       it[1] = getParent().getBack();    
01519     }else {
01520       it[1] = it[0]; 
01521     }   
01522     std::vector<TreeNode> children;
01523     addChildren(children);
01524     it[2] = children[3].getBottomRightBack();
01525     children.clear();
01526     return it;
01527   }//end fn. 
01528 
01529 }//end namespace ot
01530 

Generated on Tue Mar 24 16:14:01 2009 for DENDRO by  doxygen 1.3.9.1