NL3D::CLayeredOrderingTable< T > Class Template Reference

#include <layered_ordering_table.h>


Detailed Description

template<class T>
class NL3D::CLayeredOrderingTable< T >

The same as an ordering table, but it allows to have several layers for the display.

Definition at line 43 of file layered_ordering_table.h.

Public Member Functions

void begin (bool forwardTraversal=true)
 CLayeredOrderingTable ()
 ctor

T * get ()
uint32 getSize ()
void init (uint32 nNbEntries)
void insert (uint layer, T *pValue, uint32 nEntryPos=0)
void next ()
void reset (uint maxElementToInsert)

Private Types

typedef std::vector< T * > TTypePtVect

Private Attributes

uint8 _CurrLayer
bool _ForwardTraversal
uint _IndexInLayer1
COrderingTable< T > _Layer0
TTypePtVect _Layer1
COrderingTable< T > _Layer2


Member Typedef Documentation

template<class T>
typedef std::vector<T *> NL3D::CLayeredOrderingTable< T >::TTypePtVect [private]
 

Definition at line 106 of file layered_ordering_table.h.


Constructor & Destructor Documentation

template<class T>
NL3D::CLayeredOrderingTable< T >::CLayeredOrderingTable  ) 
 

ctor

Definition at line 119 of file layered_ordering_table.h.

00119                                                  : _IndexInLayer1(0), _CurrLayer(0), _ForwardTraversal(true){
00120 
00121 }


Member Function Documentation

template<class T>
void NL3D::CLayeredOrderingTable< T >::begin bool  forwardTraversal = true  )  [inline]
 

Traversal operations

LayeredOrderingTable<Face> ot; ot.begin(); while( ot.get() != NULL ) { Face *pF = ot.get(); // Do the treatment you want here ot.next(); }

Parameters:
forwardTraversal true to traverse from layer 0 to layer 2 and vice versa.

Definition at line 171 of file layered_ordering_table.h.

References NL3D::CLayeredOrderingTable< T >::_CurrLayer, NL3D::CLayeredOrderingTable< T >::_ForwardTraversal, NL3D::CLayeredOrderingTable< T >::_IndexInLayer1, NL3D::CLayeredOrderingTable< T >::_Layer0, NL3D::CLayeredOrderingTable< T >::_Layer1, and NL3D::CLayeredOrderingTable< T >::_Layer2.

00172 {
00173         _ForwardTraversal = forwardTraversal;
00174         if (forwardTraversal)
00175         {                               
00176                 _Layer0.begin();
00177                 if (!_Layer0.get())
00178                 {
00179                         if (_Layer1.size() != 0)
00180                         {
00181                                 _CurrLayer = 1;
00182                                 _IndexInLayer1 = 0;
00183                         }
00184                         else
00185                         {
00186                                 _CurrLayer = 2;
00187                                 _Layer2.begin();
00188                         }
00189                 }
00190                 else
00191                 {
00192                         _CurrLayer = 0;
00193                 }
00194         }
00195         else
00196         {               
00197                 _Layer2.begin();
00198                 if (!_Layer2.get())
00199                 {
00200                         if (_Layer1.size() != 0)
00201                         {
00202                                 _CurrLayer = 1;
00203                                 _IndexInLayer1 = 0;
00204                         }
00205                         else
00206                         {
00207                                 _CurrLayer = 0;
00208                                 _Layer0.begin();
00209                         }
00210                 }
00211                 else
00212                 {
00213                         _CurrLayer = 2;
00214                 }
00215         }
00216 }

template<class T>
T * NL3D::CLayeredOrderingTable< T >::get  )  [inline]
 

Get the currently selected element.

Definition at line 220 of file layered_ordering_table.h.

References NL3D::CLayeredOrderingTable< T >::_CurrLayer, NL3D::CLayeredOrderingTable< T >::_IndexInLayer1, NL3D::CLayeredOrderingTable< T >::_Layer0, NL3D::CLayeredOrderingTable< T >::_Layer1, NL3D::CLayeredOrderingTable< T >::_Layer2, and nlassert.

00221 {
00222         switch(_CurrLayer)
00223         {
00224                 case 0:                 
00225                         return _Layer0.get();
00226                 break;
00227                 case 1:                 
00228                         return _Layer1[_IndexInLayer1];
00229                 break;
00230                 case 2:                 
00231                         return _Layer2.get();
00232                 break;
00233                 default:
00234                         nlassert(0);
00235                 break;
00236         }
00237         return NULL; // avoid warning
00238 }

template<class T>
uint32 NL3D::CLayeredOrderingTable< T >::getSize  ) 
 

Just return the number of entries in the ordering tables

Definition at line 133 of file layered_ordering_table.h.

References NL3D::CLayeredOrderingTable< T >::_Layer0, NL3D::CLayeredOrderingTable< T >::_Layer2, nlassert, and uint32.

00134 {
00135         nlassert(_Layer0.getSize() == _Layer2.getSize());
00136         return _Layer0.getSize();
00137 }

template<class T>
void NL3D::CLayeredOrderingTable< T >::init uint32  nNbEntries  ) 
 

Initialization. The ordering tables have a range from 0 to nNbEntries-1

Definition at line 125 of file layered_ordering_table.h.

References NL3D::CLayeredOrderingTable< T >::_Layer0, NL3D::CLayeredOrderingTable< T >::_Layer2, and uint32.

00126 {
00127         _Layer0.init(nNbEntries);
00128         _Layer2.init(nNbEntries);
00129 }

template<class T>
void NL3D::CLayeredOrderingTable< T >::insert uint  layer,
T *  pValue,
uint32  nEntryPos = 0
 

Insert an element in the ordering table

Parameters:
layer the layer in which to insert the object. Might be 0, 1 or 2
entry pos The position for the ordering tables. It is ignored when the layer is 1.

Definition at line 150 of file layered_ordering_table.h.

References NL3D::CLayeredOrderingTable< T >::_Layer0, NL3D::CLayeredOrderingTable< T >::_Layer1, NL3D::CLayeredOrderingTable< T >::_Layer2, nlassert, uint, and uint32.

00151 {
00152         switch (layer)
00153         {
00154                 case 0:                 
00155                         _Layer0.insert(nEntryPos, pValue);
00156                 break;
00157                 case 1:                 
00158                         _Layer1.push_back(pValue);
00159                 break;
00160                 case 2:                 
00161                         _Layer2.insert(nEntryPos, pValue);
00162                 break;
00163                 default:
00164                         nlassert(0); // invalid layer
00165                 break;
00166         }
00167 }

template<class T>
void NL3D::CLayeredOrderingTable< T >::next  )  [inline]
 

Move selection pointer to the next element

Definition at line 242 of file layered_ordering_table.h.

References NL3D::CLayeredOrderingTable< T >::_CurrLayer, NL3D::CLayeredOrderingTable< T >::_ForwardTraversal, NL3D::CLayeredOrderingTable< T >::_IndexInLayer1, NL3D::CLayeredOrderingTable< T >::_Layer0, NL3D::CLayeredOrderingTable< T >::_Layer1, and NL3D::CLayeredOrderingTable< T >::_Layer2.

00243 {
00244         if (_ForwardTraversal)
00245         {               
00246                 switch(_CurrLayer)
00247                 {
00248                         case 0:
00249                                 _Layer0.next();
00250                                 if (_Layer0.get() == NULL)
00251                                 {
00252                                         if (_Layer1.size() != 0)
00253                                         {
00254                                                 _CurrLayer = 1;
00255                                                 _IndexInLayer1 = 0;
00256                                         }
00257                                         else
00258                                         {
00259                                                 _CurrLayer = 2;
00260                                                 _Layer2.begin();
00261                                         }
00262                                 }
00263 
00264                         break;
00265                         case 1:
00266                                 ++ _IndexInLayer1;
00267                                 if (_IndexInLayer1 == _Layer1.size())
00268                                 {
00269                                         _CurrLayer = 2;
00270                                         _Layer2.begin();
00271                                 }
00272                         break;
00273                         case 2:
00274                                 _Layer2.next();
00275                         break;
00276                 }
00277         }
00278         else
00279         {               
00280                 switch(_CurrLayer)
00281                 {
00282                 
00283                         case 2:
00284                                 _Layer2.next();
00285                                 if (_Layer2.get() == NULL)
00286                                 {
00287                                         if (_Layer1.size() != 0)
00288                                         {
00289                                                 _CurrLayer = 1;
00290                                                 _IndexInLayer1 = 0;
00291                                         }
00292                                         else
00293                                         {
00294                                                 _CurrLayer = 0;
00295                                                 _Layer0.begin();
00296                                         }
00297                                 }
00298 
00299                         break;
00300                         case 1:
00301                                 ++ _IndexInLayer1;
00302                                 if (_IndexInLayer1 == _Layer1.size())
00303                                 {
00304                                         _CurrLayer = 0;
00305                                         _Layer0.begin();
00306                                 }
00307                         break;
00308                         case 0:
00309                                 _Layer0.next();
00310                         break;
00311                 }
00312         }
00313 }

template<class T>
void NL3D::CLayeredOrderingTable< T >::reset uint  maxElementToInsert  ) 
 

Put all the layers to empty

Parameters:
maxElementToInsert prepare allocator for insert by setting maximum insert() that will arise.

Definition at line 141 of file layered_ordering_table.h.

References NL3D::CLayeredOrderingTable< T >::_Layer0, NL3D::CLayeredOrderingTable< T >::_Layer1, NL3D::CLayeredOrderingTable< T >::_Layer2, and uint.

00142 {
00143         _Layer0.reset(maxElementToInsert);
00144         _Layer2.reset(maxElementToInsert);
00145         _Layer1.clear();
00146 }


Field Documentation

template<class T>
uint8 NL3D::CLayeredOrderingTable< T >::_CurrLayer [private]
 

Definition at line 111 of file layered_ordering_table.h.

Referenced by NL3D::CLayeredOrderingTable< T >::begin(), NL3D::CLayeredOrderingTable< T >::get(), and NL3D::CLayeredOrderingTable< T >::next().

template<class T>
bool NL3D::CLayeredOrderingTable< T >::_ForwardTraversal [private]
 

Definition at line 112 of file layered_ordering_table.h.

Referenced by NL3D::CLayeredOrderingTable< T >::begin(), and NL3D::CLayeredOrderingTable< T >::next().

template<class T>
uint NL3D::CLayeredOrderingTable< T >::_IndexInLayer1 [private]
 

Definition at line 110 of file layered_ordering_table.h.

Referenced by NL3D::CLayeredOrderingTable< T >::begin(), NL3D::CLayeredOrderingTable< T >::get(), and NL3D::CLayeredOrderingTable< T >::next().

template<class T>
COrderingTable<T> NL3D::CLayeredOrderingTable< T >::_Layer0 [private]
 

Definition at line 107 of file layered_ordering_table.h.

Referenced by NL3D::CLayeredOrderingTable< T >::begin(), NL3D::CLayeredOrderingTable< T >::get(), NL3D::CLayeredOrderingTable< T >::getSize(), NL3D::CLayeredOrderingTable< T >::init(), NL3D::CLayeredOrderingTable< T >::insert(), NL3D::CLayeredOrderingTable< T >::next(), and NL3D::CLayeredOrderingTable< T >::reset().

template<class T>
TTypePtVect NL3D::CLayeredOrderingTable< T >::_Layer1 [private]
 

Definition at line 108 of file layered_ordering_table.h.

Referenced by NL3D::CLayeredOrderingTable< T >::begin(), NL3D::CLayeredOrderingTable< T >::get(), NL3D::CLayeredOrderingTable< T >::insert(), NL3D::CLayeredOrderingTable< T >::next(), and NL3D::CLayeredOrderingTable< T >::reset().

template<class T>
COrderingTable<T> NL3D::CLayeredOrderingTable< T >::_Layer2 [private]
 

Definition at line 109 of file layered_ordering_table.h.

Referenced by NL3D::CLayeredOrderingTable< T >::begin(), NL3D::CLayeredOrderingTable< T >::get(), NL3D::CLayeredOrderingTable< T >::getSize(), NL3D::CLayeredOrderingTable< T >::init(), NL3D::CLayeredOrderingTable< T >::insert(), NL3D::CLayeredOrderingTable< T >::next(), and NL3D::CLayeredOrderingTable< T >::reset().


The documentation for this class was generated from the following file:
Generated on Tue Mar 16 06:49:20 2004 for NeL by doxygen 1.3.6