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

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

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
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 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

typedef PrimitiveIterator osg::FaceIterator::Inherited [protected]
 

Definition at line 144 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]
 

Return the index of the current primitive. The index runs from 0 to the number of faces in the geometry. Its main use is as an input to seek().

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]
 

Return the position index (i.e. the number of the entry in the positions property which is used) of a point in the current primitive. which is the point to access. Must be between 0 and getLength().

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]
 

Return the position of a point in the current primitive. which is the point to access. Must be between 0 and getLength().

Reimplemented from osg::PrimitiveIterator.

Definition at line 76 of file OSGFaceIterator.inl.

References osg::PrimitiveIterator::getGeometry(), getPositionIndex(), and osg::PointInterface< Real32, VecStorage3 >::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]
 

Return the normal index (i.e. the number of the entry in the normal property which is used) of a point in the current primitive. which is the point to access. Must be between 0 and getLength().

If the geometry has no normals, -1 is returned.

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]
 

Return the normal of a point in the current primitive. which is the point to access. Must be between 0 and getLength().

If the geometry has no normals, Vec3f::Null is returned.

Reimplemented from osg::PrimitiveIterator.

Definition at line 95 of file OSGFaceIterator.inl.

References osg::PrimitiveIterator::getGeometry(), getNormalIndex(), and osg::VectorInterface< Real32, VecStorage3 >::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]
 

Return the color index (i.e. the number of the entry in the color property which is used) of a point in the current primitive. which is the point to access. Must be between 0 and getLength().

If the geometry has no colors, -1 is returned.

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]
 

Return the color of a point in the current primitive. which is the point to access. Must be between 0 and getLength().

If the geometry has no colors, Color3f::Null is returned.

Reimplemented from osg::PrimitiveIterator.

Definition at line 115 of file OSGFaceIterator.inl.

References getColorIndex(), osg::PrimitiveIterator::getGeometry(), and osg::Color3< Real32 >::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]
 

Return the secondary color index (i.e. the number of the entry in the secondary color property which is used) of a point in the current primitive. which is the point to access. Must be between 0 and getLength().

If the geometry has no secondary colors, -1 is returned.

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]
 

Return the secondary color of a point in the current primitive. which is the point to access. Must be between 0 and getLength().

If the geometry has no secondary colors, Color3f::Null is returned.

Reimplemented from osg::PrimitiveIterator.

Definition at line 135 of file OSGFaceIterator.inl.

References osg::PrimitiveIterator::getGeometry(), getSecondaryColorIndex(), and osg::Color3< Real32 >::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]
 

Return the texture coordinates index (i.e. the number of the entry in the texture coordinates property which is used) of a point in the current primitive. which is the point to access. Must be between 0 and getLength().

If the geometry has no texture coordinates, -1 is returned.

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]
 

Return the texture coordinates of a point in the current primitive. which is the point to access. Must be between 0 and getLength().

If the geometry has no texture coordinates, Vec2f::Null is returned.

Reimplemented from osg::PrimitiveIterator.

Definition at line 155 of file OSGFaceIterator.inl.

References osg::PrimitiveIterator::getGeometry(), getTexCoordsIndex(), and osg::VectorInterface< Real32, VecStorage2 >::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]
 

Return the second texture coordinates index (i.e. the number of the entry in the textureCoordinates1 property which is used) of a point in the current primitive. which is the point to access. Must be between 0 and getLength().

If the geometry has no second texture coordinates, -1 is returned.

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]
 

Return the second texture coordinates of a point in the current primitive. which is the point to access. Must be between 0 and getLength().

If the geometry has no second texture coordinates, Vec2f::Null is returned.

Reimplemented from osg::PrimitiveIterator.

Definition at line 176 of file OSGFaceIterator.inl.

References osg::PrimitiveIterator::getGeometry(), getTexCoordsIndex1(), and osg::VectorInterface< Real32, VecStorage2 >::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]
 

Return the third texture coordinates index (i.e. the number of the entry in the textureCoordinates2 property which is used) of a point in the current primitive. which is the point to access. Must be between 0 and getLength().

If the geometry has no third texture coordinates, -1 is returned.

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]
 

Return the third texture coordinates of a point in the current primitive. which is the point to access. Must be between 0 and getLength().

If the geometry has no third texture coordinates, Vec2f::Null is returned.

Reimplemented from osg::PrimitiveIterator.

Definition at line 196 of file OSGFaceIterator.inl.

References osg::PrimitiveIterator::getGeometry(), getTexCoordsIndex2(), and osg::VectorInterface< Real32, VecStorage2 >::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]
 

Return the fourth texture coordinates index (i.e. the number of the entry in the textureCoordinates3 property which is used) of a point in the current primitive. which is the point to access. Must be between 0 and getLength().

If the geometry has no fourth texture coordinates, -1 is returned.

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]
 

Return the fourth texture coordinates of a point in the current primitive. which is the point to access. Must be between 0 and getLength().

If the geometry has no fourth texture coordinates, Vec2f::Null is returned.

Reimplemented from osg::PrimitiveIterator.

Definition at line 216 of file OSGFaceIterator.inl.

References osg::PrimitiveIterator::getGeometry(), getTexCoordsIndex3(), and osg::VectorInterface< Real32, VecStorage2 >::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::getIndexIndex Int32  which  )  const [inline]
 

Return the index index of a point in the current primitive. The index index is the number of the index used for this point in the index property. which is the point to access. Must be between 0 and getLength().

For multi-indexed geometry it is the index of the beginning of the index block used. See Indexing for details on indexing.

If the geometry has no indices, -1 is returned.

Reimplemented from osg::PrimitiveIterator.

Definition at line 227 of file OSGFaceIterator.inl.

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

Referenced by osg::calcFaceNormals().

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

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 299 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().

00300 {
00301     OSG_ASSERT(geo != NullFC);
00302 
00303     _geo     = geo;
00304     _types   = geo->getTypes();
00305