osg::FaceIterator Class Reference
[Geometry Iterators]

Geometry Iterator for faces (tris and quads). See Geometry Iterators for a description. More...

#include <OSGFaceIterator.h>

Inheritance diagram for osg::FaceIterator:

osg::PrimitiveIterator

List of all members.

Public Member Functions

Constructors


 FaceIterator (void)
 FaceIterator (const FaceIterator &source)
 FaceIterator (const GeometryPtr &geo)
 FaceIterator (const NodePtr &geo)
Destructors


virtual ~FaceIterator (void)
Access


Int32 getIndex (void) const
UInt32 getLength (void) const
Int32 getPositionIndex (Int32 which) const
Pnt3f getPosition (Int32 which) const
Int32 getNormalIndex (Int32 which) const
Vec3f getNormal (Int32 which) const
Int32 getColorIndex (Int32 which) const
Color3f getColor (Int32 which) const
Int32 getSecondaryColorIndex (Int32 which) const
Color3f getSecondaryColor (Int32 which) const
Int32 getTexCoordsIndex (Int32 which) const
Vec2f getTexCoords (Int32 which) const
Int32 getTexCoordsIndex1 (Int32 which) const
Vec2f getTexCoords1 (Int32 which) const
Int32 getTexCoordsIndex2 (Int32 which) const
Vec2f getTexCoords2 (Int32 which) const
Int32 getTexCoordsIndex3 (Int32 which) const
Vec2f getTexCoords3 (Int32 which) const
Int32 getTexCoordsIndex4 (Int32 which) const
Vec2f getTexCoords4 (Int32 which) const
Int32 getTexCoordsIndex5 (Int32 which) const
Vec2f getTexCoords5 (Int32 which) const
Int32 getTexCoordsIndex6 (Int32 which) const
Vec2f getTexCoords6 (Int32 which) const
Int32 getTexCoordsIndex7 (Int32 which) const
Vec2f getTexCoords7 (Int32 which) const
Int32 getIndexIndex (Int32 which) const
Operators


void seek (Int32 index)
void operator++ (void)
FaceIteratoroperator= (const FaceIterator &source)
bool operator< (const FaceIterator &other) const
bool operator== (const FaceIterator &other) const
bool operator!= (const FaceIterator &other) const
Field Set


void setToBegin (void)
void setToEnd (void)
Set


void setGeo (const GeometryPtr &geo)
void setGeo (const NodePtr &geo)
Get


bool isAtEnd (void) const
UInt32 getType (void) const
GeometryPtr getGeometry (void) const
Operators


bool operator< (const PrimitiveIterator &other) const
bool operator== (const PrimitiveIterator &other) const
bool operator!= (const PrimitiveIterator &other) const

Static Public Member Functions

Class Get


static const char * getClassname (void)

Protected Types

typedef PrimitiveIterator Inherited

Private Member Functions

void startPrim (void)

Private Attributes

Int32 _faceIndex
UInt32 _actPrimIndex
Int32 _facePntIndex [4]

Static Private Attributes

static char cvsid [] = "@(#)$Id: OSGFaceIterator.cpp,v 1.13 2001/11/01 09:03:28 vossg Exp $"


Detailed Description

The FaceIterator iterates through the geometry one face at a time. See Face Iterator for a description.

See also:
PrimitiveIterator FaceIterator

Definition at line 60 of file OSGFaceIterator.h.


Member Typedef Documentation

Definition at line 152 of file OSGFaceIterator.h.


Constructor & Destructor Documentation

FaceIterator::FaceIterator ( void   ) 

Definition at line 109 of file OSGFaceIterator.cpp.

00109                                :  PrimitiveIterator(),
00110     _faceIndex(0), _actPrimIndex(), _facePntIndex()
00111 {
00112 }

FaceIterator::FaceIterator ( const FaceIterator source  ) 

Definition at line 114 of file OSGFaceIterator.cpp.

References _facePntIndex.

00114                                                      :
00115     PrimitiveIterator(source),
00116     _faceIndex(source._faceIndex),
00117     _actPrimIndex(source._actPrimIndex),
00118     _facePntIndex()
00119 {
00120     _facePntIndex[0] = source._facePntIndex[0];
00121     _facePntIndex[1] = source._facePntIndex[1];
00122     _facePntIndex[2] = source._facePntIndex[2];
00123     _facePntIndex[3] = source._facePntIndex[3];
00124 }

FaceIterator::FaceIterator ( const GeometryPtr geo  ) 

This constructor creates an iterator for the given geometry. It is useful to create an iterator to be used to seek() to a specific indexed face. Otherwise, use Geometry::beginFaces() resp. Geometry::endFaces() to create an iterator.

Definition at line 142 of file OSGFaceIterator.cpp.

References osg::PrimitiveIterator::setGeo().

00142                                                  : PrimitiveIterator(),
00143     _faceIndex(0), _actPrimIndex(), _facePntIndex()
00144 {
00145     setGeo(geo);
00146 }

FaceIterator::FaceIterator ( const NodePtr geo  ) 

This constructor creates an iterator for the given node. It is useful to create an iterator to be used to seek() to a specific indexed face. Otherwise, use Geometry::beginFaces() resp. Geometry::endFaces() to create an iterator.

Definition at line 131 of file OSGFaceIterator.cpp.

References osg::PrimitiveIterator::setGeo().

00131                                              : PrimitiveIterator(),
00132     _faceIndex(0), _actPrimIndex(), _facePntIndex()
00133 {
00134     setGeo(geo);
00135 }

FaceIterator::~FaceIterator ( void   )  [virtual]

Definition at line 149 of file OSGFaceIterator.cpp.

00150 {
00151 }


Member Function Documentation

static const char* osg::FaceIterator::getClassname ( void   )  [inline, static]

Reimplemented from osg::PrimitiveIterator.

Definition at line 69 of file OSGFaceIterator.h.

00069 { return "FaceIterator"; }

Int32 osg::FaceIterator::getIndex ( void   )  const [inline]

Reimplemented from osg::PrimitiveIterator.

Definition at line 51 of file OSGFaceIterator.inl.

References _faceIndex.

Referenced by seek().

00052 {
00053     return _faceIndex;
00054 }

UInt32 osg::FaceIterator::getLength ( void   )  const [inline]

Return the length of the current face. 3 or 4, depending on the current primitive.

Reimplemented from osg::PrimitiveIterator.

Definition at line 62 of file OSGFaceIterator.inl.

References _facePntIndex.

Referenced by osg::calcFaceNormals(), and osg::calcFaceNormalsGeo().

00063 {
00064     return _facePntIndex[3] == -1 ? 3 : 4;
00065 }

Int32 osg::FaceIterator::getPositionIndex ( Int32  which  )  const [inline]

Reimplemented from osg::PrimitiveIterator.

Definition at line 68 of file OSGFaceIterator.inl.

References _facePntIndex, and osg::PrimitiveIterator::getPositionIndex().

Referenced by osg::calcFaceNormals(), getPosition(), and operator++().

00069 {
00070     if(_facePntIndex[which] >= 0)
00071         return Inherited::getPositionIndex(_facePntIndex[which]);
00072     else 
00073         return -1;
00074 }

Pnt3f osg::FaceIterator::getPosition ( Int32  which  )  const [inline]

Reimplemented from osg::PrimitiveIterator.

Definition at line 76 of file OSGFaceIterator.inl.

References osg::PrimitiveIterator::getGeometry(), getPositionIndex(), and osg::PointInterface< ValueTypeT, StorageInterfaceT >::Null.

Referenced by osg::calcFaceNormals(), and osg::calcFaceNormalsGeo().

00076                                                                { Int32 ind =
00077 getPositionIndex(which);
00078 
00079     if(ind < 0)
00080         return Pnt3f::Null;
00081     
00082     return getGeometry()->getPositions()->getValue(ind);
00083 }

Int32 osg::FaceIterator::getNormalIndex ( Int32  which  )  const [inline]

Reimplemented from osg::PrimitiveIterator.

Definition at line 86 of file OSGFaceIterator.inl.

References _facePntIndex, and osg::PrimitiveIterator::getNormalIndex().

Referenced by getNormal().

00087 {
00088     if(_facePntIndex[which] >= 0)
00089         return Inherited::getNormalIndex(_facePntIndex[which]);
00090     else 
00091         return -1;
00092 }

Vec3f osg::FaceIterator::getNormal ( Int32  which  )  const [inline]

Reimplemented from osg::PrimitiveIterator.

Definition at line 95 of file OSGFaceIterator.inl.

References osg::PrimitiveIterator::getGeometry(), getNormalIndex(), and osg::VectorInterface< ValueTypeT, StorageInterfaceT >::Null.

Referenced by osg::calcFaceNormalsGeo().

00096 {   
00097     Int32 ind = getNormalIndex(which);
00098     
00099     if(ind < 0)
00100         return Vec3f::Null;
00101         
00102     return getGeometry()->getNormals()->getValue(ind);
00103 }

Int32 osg::FaceIterator::getColorIndex ( Int32  which  )  const [inline]

Reimplemented from osg::PrimitiveIterator.

Definition at line 106 of file OSGFaceIterator.inl.

References _facePntIndex, and osg::PrimitiveIterator::getColorIndex().

Referenced by getColor().

00107 {
00108     if(_facePntIndex[which] >= 0)
00109         return Inherited::getColorIndex(_facePntIndex[which]);
00110     else 
00111         return -1;
00112 }

Color3f osg::FaceIterator::getColor ( Int32  which  )  const [inline]

Reimplemented from osg::PrimitiveIterator.

Definition at line 115 of file OSGFaceIterator.inl.

References getColorIndex(), osg::PrimitiveIterator::getGeometry(), and osg::Color3< ValueTypeT >::Null.

00116 {   
00117     Int32 ind = getColorIndex(which);
00118     
00119     if(ind < 0)
00120         return Color3f::Null;
00121         
00122     return getGeometry()->getColors()->getValue(ind);
00123 }

Int32 osg::FaceIterator::getSecondaryColorIndex ( Int32  which  )  const [inline]

Reimplemented from osg::PrimitiveIterator.

Definition at line 126 of file OSGFaceIterator.inl.

References _facePntIndex, and osg::PrimitiveIterator::getSecondaryColorIndex().

Referenced by getSecondaryColor().

00127 {
00128     if(_facePntIndex[which] >= 0)
00129         return Inherited::getSecondaryColorIndex(_facePntIndex[which]);
00130     else 
00131         return -1;
00132 }

Color3f osg::FaceIterator::getSecondaryColor ( Int32  which  )  const [inline]

Reimplemented from osg::PrimitiveIterator.

Definition at line 135 of file OSGFaceIterator.inl.

References osg::PrimitiveIterator::getGeometry(), getSecondaryColorIndex(), and osg::Color3< ValueTypeT >::Null.

00136 {   
00137     Int32 ind = getSecondaryColorIndex(which);
00138     
00139     if(ind < 0)
00140         return Color3f::Null;
00141         
00142     return getGeometry()->getSecondaryColors()->getValue(ind);
00143 }

Int32 osg::FaceIterator::getTexCoordsIndex ( Int32  which  )  const [inline]

Reimplemented from osg::PrimitiveIterator.

Definition at line 146 of file OSGFaceIterator.inl.

References _facePntIndex, and osg::PrimitiveIterator::getTexCoordsIndex().

Referenced by getTexCoords().

00147 {
00148     if(_facePntIndex[which] >= 0)
00149         return Inherited::getTexCoordsIndex(_facePntIndex[which]);
00150     else 
00151         return -1;
00152 }

Vec2f osg::FaceIterator::getTexCoords ( Int32  which  )  const [inline]

Reimplemented from osg::PrimitiveIterator.

Definition at line 155 of file OSGFaceIterator.inl.

References osg::PrimitiveIterator::getGeometry(), getTexCoordsIndex(), and osg::VectorInterface< ValueTypeT, StorageInterfaceT >::Null.

00156 {   
00157     Int32 ind = getTexCoordsIndex(which);
00158     
00159     if(ind < 0)
00160         return Vec2f::Null;
00161         
00162     return getGeometry()->getTexCoords()->getValue(ind);
00163 }

Int32 osg::FaceIterator::getTexCoordsIndex1 ( Int32  which  )  const [inline]

Reimplemented from osg::PrimitiveIterator.

Definition at line 167 of file OSGFaceIterator.inl.

References _facePntIndex, and osg::PrimitiveIterator::getTexCoordsIndex1().

Referenced by getTexCoords1().

00168 {
00169     if(_facePntIndex[which] >= 0)
00170         return Inherited::getTexCoordsIndex1(_facePntIndex[which]);
00171     else 
00172         return -1;
00173 }

Vec2f osg::FaceIterator::getTexCoords1 ( Int32  which  )  const [inline]

Reimplemented from osg::PrimitiveIterator.

Definition at line 176 of file OSGFaceIterator.inl.

References osg::PrimitiveIterator::getGeometry(), getTexCoordsIndex1(), and osg::VectorInterface< ValueTypeT, StorageInterfaceT >::Null.

00177 {   
00178     Int32 ind = getTexCoordsIndex1(which);
00179     
00180     if(ind < 0)
00181         return Vec2f::Null;
00182         
00183     return getGeometry()->getTexCoords1()->getValue(ind);
00184 }

Int32 osg::FaceIterator::getTexCoordsIndex2 ( Int32  which  )  const [inline]

Reimplemented from osg::PrimitiveIterator.

Definition at line 187 of file OSGFaceIterator.inl.

References _facePntIndex, and osg::PrimitiveIterator::getTexCoordsIndex2().

Referenced by getTexCoords2().

00188 {
00189     if(_facePntIndex[which] >= 0)
00190         return Inherited::getTexCoordsIndex2(_facePntIndex[which]);
00191     else 
00192         return -1;
00193 }

Vec2f osg::FaceIterator::getTexCoords2 ( Int32  which  )  const [inline]

Reimplemented from osg::PrimitiveIterator.

Definition at line 196 of file OSGFaceIterator.inl.

References osg::PrimitiveIterator::getGeometry(), getTexCoordsIndex2(), and osg::VectorInterface< ValueTypeT, StorageInterfaceT >::Null.

00197 {   
00198     Int32 ind = getTexCoordsIndex2(which);
00199     
00200     if(ind < 0)
00201         return Vec2f::Null;
00202         
00203     return getGeometry()->getTexCoords2()->getValue(ind);
00204 }

Int32 osg::FaceIterator::getTexCoordsIndex3 ( Int32  which  )  const [inline]

Reimplemented from osg::PrimitiveIterator.

Definition at line 207 of file OSGFaceIterator.inl.

References _facePntIndex, and osg::PrimitiveIterator::getTexCoordsIndex3().

Referenced by getTexCoords3().

00208 {
00209     if(_facePntIndex[which] >= 0)
00210         return Inherited::getTexCoordsIndex3(_facePntIndex[which]);
00211     else 
00212         return -1;
00213 }

Vec2f osg::FaceIterator::getTexCoords3 ( Int32  which  )  const [inline]

Reimplemented from osg::PrimitiveIterator.

Definition at line 216 of file OSGFaceIterator.inl.

References osg::PrimitiveIterator::getGeometry(), getTexCoordsIndex3(), and osg::VectorInterface< ValueTypeT, StorageInterfaceT >::Null.

00217 {   
00218     Int32 ind = getTexCoordsIndex3(which);
00219     
00220     if(ind < 0)
00221         return Vec2f::Null;
00222         
00223     return getGeometry()->getTexCoords3()->getValue(ind);
00224 }

Int32 osg::FaceIterator::getTexCoordsIndex4 ( Int32  which  )  const [inline]

Reimplemented from osg::PrimitiveIterator.

Definition at line 227 of file OSGFaceIterator.inl.

References _facePntIndex, and osg::PrimitiveIterator::getTexCoordsIndex4().

Referenced by getTexCoords4().

00228 {
00229     if(_facePntIndex[which] >= 0)
00230         return Inherited::getTexCoordsIndex4(_facePntIndex[which]);
00231     else 
00232         return -1;
00233 }

Vec2f osg::FaceIterator::getTexCoords4 ( Int32  which  )  const [inline]

Reimplemented from osg::PrimitiveIterator.

Definition at line 236 of file OSGFaceIterator.inl.

References osg::PrimitiveIterator::getGeometry(), getTexCoordsIndex4(), and osg::VectorInterface< ValueTypeT, StorageInterfaceT >::Null.

00237 {   
00238     Int32 ind = getTexCoordsIndex4(which);
00239     
00240     if(ind < 0)
00241         return Vec2f::Null;
00242         
00243     return getGeometry()->getTexCoords4()->getValue(ind);
00244 }

Int32 osg::FaceIterator::getTexCoordsIndex5 ( Int32  which  )  const [inline]

Reimplemented from osg::PrimitiveIterator.

Definition at line 247 of file OSGFaceIterator.inl.

References _facePntIndex, and osg::PrimitiveIterator::getTexCoordsIndex5().

Referenced by getTexCoords5().

00248 {
00249     if(_facePntIndex[which] >= 0)
00250         return Inherited::getTexCoordsIndex5(_facePntIndex[which]);
00251     else 
00252         return -1;
00253 }

Vec2f osg::FaceIterator::getTexCoords5 ( Int32  which  )  const [inline]

Reimplemented from osg::PrimitiveIterator.

Definition at line 256 of file OSGFaceIterator.inl.

References osg::PrimitiveIterator::getGeometry(), getTexCoordsIndex5(), and osg::VectorInterface< ValueTypeT, StorageInterfaceT >::Null.

00257 {   
00258     Int32 ind = getTexCoordsIndex5(which);
00259     
00260     if(ind < 0)
00261         return Vec2f::Null;
00262         
00263     return getGeometry()->getTexCoords5()->getValue(ind);
00264 }

Int32 osg::FaceIterator::getTexCoordsIndex6 ( Int32  which  )  const [inline]

Reimplemented from osg::PrimitiveIterator.

Definition at line 267 of file OSGFaceIterator.inl.

References _facePntIndex, and osg::PrimitiveIterator::getTexCoordsIndex6().

Referenced by getTexCoords6().

00268 {
00269     if(_facePntIndex[which] >= 0)
00270         return Inherited::getTexCoordsIndex6(_facePntIndex[which]);
00271     else 
00272         return -1;
00273 }

Vec2f osg::FaceIterator::getTexCoords6 ( Int32  which  )  const [inline]

Reimplemented from osg::PrimitiveIterator.

Definition at line 276 of file OSGFaceIterator.inl.

References osg::PrimitiveIterator::getGeometry(), getTexCoordsIndex6(), and osg::VectorInterface< ValueTypeT, StorageInterfaceT >::Null.

00277 {   
00278     Int32 ind = getTexCoordsIndex6(which);
00279     
00280     if(ind < 0)
00281         return Vec2f::Null;
00282         
00283     return getGeometry()->getTexCoords6()->getValue(ind);
00284 }

Int32 osg::FaceIterator::getTexCoordsIndex7 ( Int32  which  )  const [inline]

Reimplemented from osg::PrimitiveIterator.

Definition at line 287 of file OSGFaceIterator.inl.

References _facePntIndex, and osg::PrimitiveIterator::getTexCoordsIndex7().

Referenced by getTexCoords7().

00288 {
00289     if(_facePntIndex[which] >= 0)
00290         return Inherited::getTexCoordsIndex7(_facePntIndex[which]);
00291     else 
00292         return -1;
00293 }

Vec2f osg::FaceIterator::getTexCoords7 ( Int32  which  )  const [inline]

Reimplemented from osg::PrimitiveIterator.

Definition at line 296 of file OSGFaceIterator.inl.

References osg::PrimitiveIterator::getGeometry(), getTexCoordsIndex7(), and osg::VectorInterface< ValueTypeT, StorageInterfaceT >::Null.

00297 {   
00298     Int32 ind = getTexCoordsIndex7(which);
00299     
00300     if(ind < 0)
00301         return Vec2f::Null;
00302         
00303     return getGeometry()->getTexCoords7()->getValue(ind);
00304 }

Int32 osg::FaceIterator::getIndexIndex ( Int32  which  )  const [inline]

Reimplemented from osg::PrimitiveIterator.

Definition at line 307 of file OSGFaceIterator.inl.

References _facePntIndex, and osg::PrimitiveIterator::getIndexIndex().

Referenced by osg::calcFaceNormals().

00308 {
00309     if(_facePntIndex[which] >= 0)
00310         return Inherited::getIndexIndex(_facePntIndex[which]);
00311     else 
00312         return -1;
00313 }

void FaceIterator::seek ( Int32  index  ) 

Seek the iterator to a specific face indicated by its index.

This is primarily used in conjunction with osg::FaceIterator::getIndex to record a position in the iteration and later return to it.

Reimplemented from osg::PrimitiveIterator.

Definition at line 307 of file OSGFaceIterator.cpp.

References getIndex(), and setToBegin().

00308 {
00309     setToBegin();
00310     
00311     while(getIndex() != index)
00312         ++(*this);
00313 }

void FaceIterator::operator++ ( void   ) 

The increment operator steps the iterator to the next face. If it is already beyond the last face it does not change.

Dev: This is the central function of the whole iterator. It changes _facePntIndex to contain the data for the next face, depending on the type of the currently active primitive and steps to the next primitive if the current one is exhausted. The only tricky part is the left/right swap for triangle strips, the rest is pretty simple.

Reimplemented from osg::PrimitiveIterator.

Definition at line 164 of file OSGFaceIterator.cpp.

References _actPrimIndex, _faceIndex, _facePntIndex, osg::PrimitiveIterator::getLength(), getPositionIndex(), osg::PrimitiveIterator::getType(), osg::PrimitiveIterator::isAtEnd(), startPrim(), and SWARNING.

00165 {
00166     // already at end?
00167     if(isAtEnd())
00168         return;
00169     
00170     ++_faceIndex;
00171 
00172     // at end of primitive?
00173     if(_actPrimIndex >= PrimitiveIterator::getLength())
00174     {
00175         ++(static_cast<PrimitiveIterator&>(*this));
00176         
00177         startPrim();
00178         
00179         return;
00180     }
00181 
00182     switch(getType())
00183     {
00184     case GL_TRIANGLES:      _facePntIndex[0] = _actPrimIndex++;
00185                             _facePntIndex[1] = _actPrimIndex++;
00186                             _facePntIndex[2] = _actPrimIndex++;
00187                             _facePntIndex[3] = -1;
00188                             break;
00189     case GL_QUAD_STRIP:     _facePntIndex[0] = _facePntIndex[3];
00190                             _facePntIndex[1] = _facePntIndex[2];
00191                             _facePntIndex[3] = _actPrimIndex++;
00192                             _facePntIndex[2] = _actPrimIndex++;
00193                             break;
00194     case GL_TRIANGLE_STRIP: if(_actPrimIndex & 1)
00195                             {
00196                                 _facePntIndex[0] = _facePntIndex[2];
00197                             }
00198                             else
00199                             {
00200                                 _facePntIndex[1] = _facePntIndex[2];
00201                             }                           
00202                             _facePntIndex[2] = _actPrimIndex++;
00203                             
00204                             if(getPositionIndex(0) == getPositionIndex(1) ||
00205                                getPositionIndex(0) == getPositionIndex(2) ||
00206                                getPositionIndex(1) == getPositionIndex(2))
00207                             {
00208                                 --_faceIndex;
00209                                 ++(*this);
00210                             }
00211                                
00212                             break;
00213     case GL_POLYGON:
00214     case GL_TRIANGLE_FAN:   _facePntIndex[1] = _facePntIndex[2];
00215                             _facePntIndex[2] = _actPrimIndex++;
00216                             break;
00217     case GL_QUADS:          _facePntIndex[0] = _actPrimIndex++;
00218                             _facePntIndex[1] = _actPrimIndex++;
00219                             _facePntIndex[2] = _actPrimIndex++;
00220                             _facePntIndex[3] = _actPrimIndex++;
00221                             break;
00222     default:                SWARNING << "FaceIterator::++: encountered " 
00223                                       << "unknown primitive type " 
00224                                       << getType()
00225                                       << ", ignoring!" << std::endl;
00226                             startPrim();
00227                             break;
00228     }           
00229 }

FaceIterator & FaceIterator::operator= ( const FaceIterator source  ) 

Seek the iterator to a specific face indicated by its index.

This is primarily used in conjunction with osg::FaceIterator::getIndex to record a position in the iteration and later return to it.

Definition at line 338 of file OSGFaceIterator.cpp.

References _actPrimIndex, _faceIndex, and _facePntIndex.

00339 {
00340     if(this == &source)
00341         return *this;
00342     
00343     *static_cast<Inherited *>(this) = source;
00344 
00345     this->_faceIndex            = source._faceIndex;
00346     this->_actPrimIndex         = source._actPrimIndex;
00347     this->_facePntIndex[0]      = source._facePntIndex[0];
00348     this->_facePntIndex[1]      = source._facePntIndex[1];
00349     this->_facePntIndex[2]      = source._facePntIndex[2];
00350     this->_facePntIndex[3]      = source._facePntIndex[3];
00351 
00352     return *this;
00353 }

bool FaceIterator::operator< ( const FaceIterator other  )  const

Seek the iterator to a specific face indicated by its index.

This is primarily used in conjunction with osg::FaceIterator::getIndex to record a position in the iteration and later return to it.

Definition at line 357 of file OSGFaceIterator.cpp.

References _actPrimIndex.

00358 {
00359     return 
00360           (*static_cast<const Inherited *>(this) <  other) ||
00361         ( (*static_cast<const Inherited *>(this) == other)             &&
00362           _actPrimIndex                          <  other._actPrimIndex);
00363 }

bool FaceIterator::operator== ( const FaceIterator other  )  const

Seek the iterator to a specific face indicated by its index.

This is primarily used in conjunction with osg::FaceIterator::getIndex to record a position in the iteration and later return to it.

Definition at line 365 of file OSGFaceIterator.cpp.

References _actPrimIndex, and osg::PrimitiveIterator::isAtEnd().

00366 {
00367     if(isAtEnd() && other.isAtEnd())
00368         return true;
00369 
00370     if(isAtEnd() || other.isAtEnd())
00371         return false;
00372 
00373     return 
00374         (*static_cast<const Inherited *>(this) == other              ) &&
00375         _actPrimIndex                          == other._actPrimIndex;
00376 }

bool FaceIterator::operator!= ( const FaceIterator other  )  const

Seek the iterator to a specific face indicated by its index.

This is primarily used in conjunction with osg::FaceIterator::getIndex to record a position in the iteration and later return to it.

Definition at line 378 of file OSGFaceIterator.cpp.

00379 {
00380     return !(*this == other);
00381 }

void FaceIterator::setToBegin ( void   ) 

Set the iterator to the beginning of the geometry. Is primarily used by osg::Geometry::beginFaces, but can also be used to quickly recycle an iterator.

Reimplemented from osg::PrimitiveIterator.

Definition at line 319 of file OSGFaceIterator.cpp.

References _faceIndex, osg::PrimitiveIterator::setToBegin(), and startPrim().

Referenced by osg::Geometry::beginFaces(), and seek().

00320 {
00321     PrimitiveIterator::setToBegin();
00322     _faceIndex = 0;
00323     startPrim();
00324 }

void FaceIterator::setToEnd ( void   ) 

Set the iterator to the end of the geometry. Is primarily used by osg::Geometry::endFaces, but can also be used to quickly recycle an iterator.

Reimplemented from osg::PrimitiveIterator.

Definition at line 330 of file OSGFaceIterator.cpp.

References _actPrimIndex, and osg::PrimitiveIterator::setToEnd().

Referenced by osg::Geometry::endFaces().

00331 {
00332     PrimitiveIterator::setToEnd();
00333     _actPrimIndex = 0;
00334 }

void FaceIterator::startPrim ( void   )  [private]

Helper function to reset all state to the beginning of a new primitive. Also skips non-polygonal primitives(lines, points) and primtiives with less than 3 points.

Definition at line 236 of file OSGFaceIterator.cpp.

References _actPrimIndex, _facePntIndex, osg::PrimitiveIterator::getLength(), osg::PrimitiveIterator::getType(), osg::PrimitiveIterator::isAtEnd(), and SWARNING.

Referenced by operator++(), and setToBegin().

00237 {
00238     // already at end?
00239     if(isAtEnd())
00240         return;
00241 
00242     _facePntIndex[0] = 0;
00243     _facePntIndex[1] = 1;
00244     _facePntIndex[2] = 2;
00245     _facePntIndex[3] = -1;
00246     _actPrimIndex = 3;
00247     
00248     // loop until you find a useful primitive or run out
00249     while(! isAtEnd())
00250     {
00251         switch(getType())
00252         {
00253         case GL_POINTS:     // non-polygon types: ignored
00254         case GL_LINES:
00255         case GL_LINE_STRIP: 
00256         case GL_LINE_LOOP:  
00257                             break;
00258         case GL_TRIANGLES: 
00259         case GL_TRIANGLE_STRIP:
00260         case GL_TRIANGLE_FAN:   
00261                                 if(PrimitiveIterator::getLength() >= 3)
00262                                     return;
00263                                 break;
00264         case GL_POLYGON:        switch(PrimitiveIterator::getLength())
00265                                 {
00266                                 case 0: 
00267                                 case 1: 
00268                                 case 2: 
00269                                             break;
00270                                 case 4:
00271                                             _facePntIndex[3] = _actPrimIndex++;     
00272                                             return;
00273                                 default:
00274                                             return;
00275                                 }
00276                                 break;
00277         case GL_QUADS:          if(PrimitiveIterator::getLength() >= 4)
00278                                 {
00279                                     _facePntIndex[3] = _actPrimIndex++;                         
00280                                     return;
00281                                 }
00282                                 break;
00283         case GL_QUAD_STRIP:         if(PrimitiveIterator::getLength() >= 4)
00284                                 {
00285                                     _facePntIndex[3] = _facePntIndex[2];                        
00286                                     _facePntIndex[2] = _actPrimIndex++;                         
00287                                     return;
00288                                 }
00289                                 break;
00290         default:            SWARNING << "FaceIterator::startPrim: encountered " 
00291                                      << "unknown primitive type " 
00292                                      << getType()
00293                                      << ", ignoring!" << std::endl;
00294                             break;
00295         }   
00296         
00297         ++(static_cast<PrimitiveIterator&>(*this));   
00298     }       
00299 }

void PrimitiveIterator::setGeo ( const GeometryPtr geo  )  [inherited]

Switch the iterator to a new geometry. Automatically sets it to the beginning.

Definition at line 339 of file OSGPrimitiveIterator.cpp.

References osg::PrimitiveIterator::_geo, osg::PrimitiveIterator::_indices, osg::PrimitiveIterator::_lengths, osg::PrimitiveIterator::_types, osg::NullFC, OSG_ASSERT, and osg::PrimitiveIterator::setToBegin().

Referenced by osg::EdgeIterator::EdgeIterator(), FaceIterator(), osg::LineIterator::LineIterator(), osg::PrimitiveIterator::PrimitiveIterator(), osg::PrimitiveIterator::setGeo(), and osg::TriangleIterator::TriangleIterator().

00340 {
00341     OSG_ASSERT(geo != NullFC);
00342 
00343     _geo     = geo;
00344     _types   = geo->getTypes();
00345     _lengths = geo->getLengths();
00346     _indices = geo->getIndices();
00347     
00348     setToBegin();
00349 }

void PrimitiveIterator::setGeo ( const NodePtr geo  )  [inherited]

Switch the iterator to a new geometry. Automatically sets it to the beginning.

Definition at line 355 of file OSGPrimitiveIterator.cpp.

References osg::AttachmentContainerPtr::dcast(), FWARNING, osg::NodePtr::getCore(), osg::NullFC, and osg::PrimitiveIterator::setGeo().

00356 {
00357     GeometryPtr gc = GeometryPtr::dcast(geo->getCore());
00358     
00359     if(gc == NullFC)
00360     {
00361         FWARNING(("PrimitiveIterator::setGeo: called for NodePtr which "
00362                   "is not a Geometry!\n"));
00363     }
00364     else
00365     {
00366         setGeo(gc);
00367     }
00368 }

bool osg::PrimitiveIterator::isAtEnd ( void   )  const [inline, inherited]

UInt32 osg::PrimitiveIterator::getType ( void   )  const [inline, inherited]

GeometryPtr osg::PrimitiveIterator::getGeometry ( void   )  const [inline, inherited]

Return the geometry the iterator is currently attached to.

Definition at line 676 of file OSGPrimitiveIterator.inl.

References osg::PrimitiveIterator::_geo.

Referenced by osg::TriangleIterator::getColor(), osg::LineIterator::getColor(), getColor(), osg::EdgeIterator::getColor(), osg::TriangleIterator::getNormal(), osg::LineIterator::getNormal(), getNormal(), osg::EdgeIterator::getNormal(), osg::TriangleIterator::getPosition(), osg::LineIterator::getPosition(), getPosition(), osg::EdgeIterator::getPosition(), osg::TriangleIterator::getSecondaryColor(), osg::LineIterator::getSecondaryColor(), getSecondaryColor(), osg::EdgeIterator::getSecondaryColor(), osg::TriangleIterator::getTexCoords(), osg::LineIterator::getTexCoords(), getTexCoords(), osg::EdgeIterator::getTexCoords(), osg::TriangleIterator::getTexCoords1(), osg::LineIterator::getTexCoords1(), getTexCoords1(), osg::EdgeIterator::getTexCoords1(), osg::TriangleIterator::getTexCoords2(), osg::LineIterator::getTexCoords2(), getTexCoords2(), osg::EdgeIterator::getTexCoords2(), osg::TriangleIterator::getTexCoords3(), osg::LineIterator::getTexCoords3(), getTexCoords3(), osg::EdgeIterator::getTexCoords3(), osg::TriangleIterator::getTexCoords4(), osg::LineIterator::getTexCoords4(), getTexCoords4(), osg::EdgeIterator::getTexCoords4(), osg::TriangleIterator::getTexCoords5(), osg::LineIterator::getTexCoords5(), getTexCoords5(), osg::EdgeIterator::getTexCoords5(), osg::TriangleIterator::getTexCoords6(), osg::LineIterator::getTexCoords6(), getTexCoords6(), osg::EdgeIterator::getTexCoords6(), osg::TriangleIterator::getTexCoords7(), osg::LineIterator::getTexCoords7(), getTexCoords7(), and osg::EdgeIterator::getTexCoords7().

00677 {
00678     return _geo;
00679 }

bool PrimitiveIterator::operator< ( const PrimitiveIterator other  )  const [inherited]

Compare two iterators. If the iterators are attached to different geometries a comparison in senseless, in that case false will be returned.

Definition at line 539 of file OSGPrimitiveIterator.cpp.

References osg::PrimitiveIterator::_geo, and osg::PrimitiveIterator::_primIndex.

00540 {
00541     return _geo       == other._geo &&
00542            _primIndex <= other._primIndex;
00543 }

bool PrimitiveIterator::operator== ( const PrimitiveIterator other  )  const [inherited]

Compare two iterators. If the iterators are attached to different geometries a comparison in senseless, in that case false will be returned.

Definition at line 548 of file OSGPrimitiveIterator.cpp.

References osg::PrimitiveIterator::_ended, osg::PrimitiveIterator::_geo, and osg::PrimitiveIterator::_primIndex.

00549 {
00550     return _ended     == other._ended &&
00551            _geo       == other._geo &&
00552            _primIndex == other._primIndex;
00553 }

bool PrimitiveIterator::operator!= ( const PrimitiveIterator other  )  const [inherited]

Compare two iterators. If the iterators are attached to different geometries a comparison in senseless, in that case false will be returned.

Definition at line 558 of file OSGPrimitiveIterator.cpp.

00559 {
00560     return !(*this == other);
00561 }


Member Data Documentation

char FaceIterator::cvsid = "@(#)$Id: OSGFaceIterator.cpp,v 1.13 2001/11/01 09:03:28 vossg Exp $" [static, private]

Reimplemented from osg::PrimitiveIterator.

Definition at line 156 of file OSGFaceIterator.h.

Simple runing face count. Returned by getIndex() and can be used as the input to seek();

Definition at line 158 of file OSGFaceIterator.h.

Referenced by getIndex(), operator++(), operator=(), and setToBegin().

The next unused point in the current primitive. Starts at 0 and indicates that the primitive is exhausted when it goes over the length of the primitive.

Definition at line 159 of file OSGFaceIterator.h.

Referenced by operator++(), operator<(), operator=(), operator==(), setToEnd(), and startPrim().


The documentation for this class was generated from the following files:

Generated on Mon Mar 17 12:06:45 2008 for OpenSG by  doxygen 1.5.5