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

osg::TriangleIterator Class Reference
[Geometry Iterators]

Geometry Iterator for triangles. See Geometry Iterators for a description. More...

#include <OSGTriangleIterator.h>

Inheritance diagram for osg::TriangleIterator:

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 getLength (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
TriangleIterator (void)
 TriangleIterator (const TriangleIterator &source)
 TriangleIterator (const GeometryPtr &geo)
 TriangleIterator (const NodePtr &geo)
Destructors
*virtual ~TriangleIterator (void)
Get
*Int32 getIndex (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 operator++ (void)
void seek (Int32 index)
TriangleIteratoroperator= (const TriangleIterator &source)
bool operator< (const TriangleIterator &other) const
bool operator== (const TriangleIterator &other) const
bool operator!= (const TriangleIterator &other) const
Set
*void setGeo (const GeometryPtr &geo)
void setGeo (const NodePtr &geo)
Get
*bool isAtEnd (void) const
UInt32 getLength (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

Protected Member Functions

Set
*void setToBegin (void)
void setToEnd (void)

Private Member Functions

void startPrim (void)

Private Attributes

Fields
*Int32 _triIndex
UInt32 _actPrimIndex
Int32 _triPntIndex [3]

Static Private Attributes

static char cvsid [] = "@(#)$Id: OSGTriangleIterator.cpp,v 1.13 2001/10/15 04:52:16 vossg Exp $"

Friends

class Geometry

Detailed Description

The TriangleIterator iterates through the geometry one triangle at a time. See Triangle Iterator for details.

See also:
PrimitiveIterator FaceIterator

Definition at line 58 of file OSGTriangleIterator.h.


Member Typedef Documentation

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

Definition at line 134 of file OSGTriangleIterator.h.


Constructor & Destructor Documentation

TriangleIterator::TriangleIterator void   ) 
 

Definition at line 103 of file OSGTriangleIterator.cpp.

00103                                        : PrimitiveIterator(),
00104     _triIndex(0), _actPrimIndex(0), _triPntIndex()
00105 {
00106 }

TriangleIterator::TriangleIterator const TriangleIterator source  ) 
 

Definition at line 108 of file OSGTriangleIterator.cpp.

References _triPntIndex.

00108                                                                  : 
00109     PrimitiveIterator(source),
00110     _triIndex(source._triIndex), _actPrimIndex(source._actPrimIndex),
00111     _triPntIndex()
00112 {
00113     _triPntIndex[0] = source._triPntIndex[0];
00114     _triPntIndex[1] = source._triPntIndex[1];
00115     _triPntIndex[2] = source._triPntIndex[2];
00116 }

TriangleIterator::TriangleIterator 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 osg::Geometry::beginTriangles() resp. osg::Geometry::endTriangles() to create an iterator.

Definition at line 124 of file OSGTriangleIterator.cpp.

References osg::PrimitiveIterator::setGeo().

00124                                                          :
00125     PrimitiveIterator(),
00126     _triIndex(0), _actPrimIndex(0), _triPntIndex()
00127 {
00128     setGeo(geo);
00129 }

TriangleIterator::TriangleIterator 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 osg::Geometry::beginTriangles() resp. osg::Geometry::endTriangles() to create an iterator.

Definition at line 138 of file OSGTriangleIterator.cpp.

References osg::PrimitiveIterator::setGeo().

00138                                                      : 
00139     PrimitiveIterator(),
00140     _triIndex(0), _actPrimIndex(0), _triPntIndex()
00141 {
00142     setGeo(geo);
00143 }

TriangleIterator::~TriangleIterator void   )  [virtual]
 

Definition at line 146 of file OSGTriangleIterator.cpp.

00147 {
00148 }


Member Function Documentation

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 67 of file OSGTriangleIterator.h.

00067 { return "TriangleIterator"; }

Int32 osg::TriangleIterator::getIndex void   )  const [inline]
 

Return the index of the current face. The index runs from 0 to the number of triangles in the geometry. Its main use is as an input to osg::TriangleIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 54 of file OSGTriangleIterator.inl.

References _triIndex.

Referenced by osg::calcVertexNormals(), osg::Geometry::intersect(), and seek().

00055 {
00056     return _triIndex;
00057 }

Int32 osg::TriangleIterator::getPositionIndex Int32  which  )  const [inline]
 

Return the index of the current face. The index runs from 0 to the number of triangles in the geometry. Its main use is as an input to osg::TriangleIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 60 of file OSGTriangleIterator.inl.

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

Referenced by osg::DVRClipGeometry::buildTriangledGeometry(), osg::calcVertexNormals(), osg::calcVertexTangents(), osg::createOptimizedPrimitives(), getPosition(), operator++(), and osg::VRMLWriteAction::writeIndex().

00061 {
00062     return Inherited::getPositionIndex(_triPntIndex[which]);
00063 }

Pnt3f osg::TriangleIterator::getPosition Int32  which  )  const [inline]
 

Return the index of the current face. The index runs from 0 to the number of triangles in the geometry. Its main use is as an input to osg::TriangleIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 66 of file OSGTriangleIterator.inl.

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

Referenced by osg::calcVertexNormals(), osg::calcVertexTangents(), osg::Geometry::intersect(), and osg::TileGeometryLoad::updateGeometry().

00067 {
00068     Int32 ind = getPositionIndex(which);
00069     
00070     return getGeometry()->getPositions()->getValue(ind);
00071 }

Int32 osg::TriangleIterator::getNormalIndex Int32  which  )  const [inline]
 

Return the index of the current face. The index runs from 0 to the number of triangles in the geometry. Its main use is as an input to osg::TriangleIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 74 of file OSGTriangleIterator.inl.

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

Referenced by osg::calcVertexNormals(), getNormal(), and osg::VRMLWriteAction::writeIndex().

00075 {
00076     return Inherited::getNormalIndex(_triPntIndex[which]);
00077 }

Vec3f osg::TriangleIterator::getNormal Int32  which  )  const [inline]
 

Return the index of the current face. The index runs from 0 to the number of triangles in the geometry. Its main use is as an input to osg::TriangleIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 80 of file OSGTriangleIterator.inl.

References osg::PrimitiveIterator::getGeometry(), getNormalIndex(), and osg::VectorInterface< Real32, VecStorage3 >::Null.

Referenced by osg::DVRClipGeometry::buildTriangledGeometry(), and osg::calcVertexTangents().

00081 {   
00082     Int32 ind = getNormalIndex(which);
00083     
00084     if(ind < 0)
00085         return Vec3f::Null;
00086         
00087     return getGeometry()->getNormals()->getValue(ind);
00088 }

Int32 osg::TriangleIterator::getColorIndex Int32  which  )  const [inline]
 

Return the index of the current face. The index runs from 0 to the number of triangles in the geometry. Its main use is as an input to osg::TriangleIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 91 of file OSGTriangleIterator.inl.

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

Referenced by getColor(), and osg::VRMLWriteAction::writeIndex().

00092 {
00093     return Inherited::getColorIndex(_triPntIndex[which]);
00094 }

Color3f osg::TriangleIterator::getColor Int32  which  )  const [inline]
 

Return the index of the current face. The index runs from 0 to the number of triangles in the geometry. Its main use is as an input to osg::TriangleIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 97 of file OSGTriangleIterator.inl.

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

00098 {   
00099     Int32 ind = getColorIndex(which);
00100     
00101     if(ind < 0)
00102         return Color3f::Null;
00103         
00104     return getGeometry()->getColors()->getValue(ind);
00105 }

Int32 osg::TriangleIterator::getSecondaryColorIndex Int32  which  )  const [inline]
 

Return the index of the current face. The index runs from 0 to the number of triangles in the geometry. Its main use is as an input to osg::TriangleIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 108 of file OSGTriangleIterator.inl.

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

Referenced by getSecondaryColor().

00109 {
00110     return Inherited::getSecondaryColorIndex(_triPntIndex[which]);
00111 }

Color3f osg::TriangleIterator::getSecondaryColor Int32  which  )  const [inline]
 

Return the index of the current face. The index runs from 0 to the number of triangles in the geometry. Its main use is as an input to osg::TriangleIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 114 of file OSGTriangleIterator.inl.

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

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

Int32 osg::TriangleIterator::getTexCoordsIndex Int32  which  )  const [inline]
 

Return the index of the current face. The index runs from 0 to the number of triangles in the geometry. Its main use is as an input to osg::TriangleIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 126 of file OSGTriangleIterator.inl.

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

Referenced by getTexCoords(), and osg::VRMLWriteAction::writeIndex().

00127 {
00128     return Inherited::getTexCoordsIndex(_triPntIndex[which]);
00129 }

Vec2f osg::TriangleIterator::getTexCoords Int32  which  )  const [inline]
 

Return the index of the current face. The index runs from 0 to the number of triangles in the geometry. Its main use is as an input to osg::TriangleIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 132 of file OSGTriangleIterator.inl.

References osg::PrimitiveIterator::getGeometry(), getTexCoordsIndex(), and osg::VectorInterface< Real32, VecStorage2 >::Null.

Referenced by osg::calcVertexTangents().

00133 {   
00134     Int32 ind = getTexCoordsIndex(which);
00135     
00136     if(ind < 0)
00137         return Vec2f::Null;
00138         
00139     return getGeometry()->getTexCoords()->getValue(ind);
00140 }

Int32 osg::TriangleIterator::getTexCoordsIndex1 Int32  which  )  const [inline]
 

Return the index of the current face. The index runs from 0 to the number of triangles in the geometry. Its main use is as an input to osg::TriangleIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 144 of file OSGTriangleIterator.inl.

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

Referenced by getTexCoords1().

00145 {
00146     return Inherited::getTexCoordsIndex1(_triPntIndex[which]);
00147 }

Vec2f osg::TriangleIterator::getTexCoords1 Int32  which  )  const [inline]
 

Return the index of the current face. The index runs from 0 to the number of triangles in the geometry. Its main use is as an input to osg::TriangleIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 150 of file OSGTriangleIterator.inl.

References osg::PrimitiveIterator::getGeometry(), getTexCoordsIndex1(), and osg::VectorInterface< Real32, VecStorage2 >::Null.

Referenced by osg::calcVertexTangents().

00151 {   
00152     Int32 ind = getTexCoordsIndex1(which);
00153     
00154     if(ind < 0)
00155         return Vec2f::Null;
00156         
00157     return getGeometry()->getTexCoords1()->getValue(ind);
00158 }

Int32 osg::TriangleIterator::getTexCoordsIndex2 Int32  which  )  const [inline]
 

Return the index of the current face. The index runs from 0 to the number of triangles in the geometry. Its main use is as an input to osg::TriangleIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 162 of file OSGTriangleIterator.inl.

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

Referenced by getTexCoords2().

00163 {
00164     return Inherited::getTexCoordsIndex2(_triPntIndex[which]);
00165 }

Vec2f osg::TriangleIterator::getTexCoords2 Int32  which  )  const [inline]
 

Return the index of the current face. The index runs from 0 to the number of triangles in the geometry. Its main use is as an input to osg::TriangleIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 168 of file OSGTriangleIterator.inl.

References osg::PrimitiveIterator::getGeometry(), getTexCoordsIndex2(), and osg::VectorInterface< Real32, VecStorage2 >::Null.

Referenced by osg::calcVertexTangents().

00169 {   
00170     Int32 ind = getTexCoordsIndex2(which);
00171     
00172     if(ind < 0)
00173         return Vec2f::Null;
00174         
00175     return getGeometry()->getTexCoords2()->getValue(ind);
00176 }

Int32 osg::TriangleIterator::getTexCoordsIndex3 Int32  which  )  const [inline]
 

Return the index of the current face. The index runs from 0 to the number of triangles in the geometry. Its main use is as an input to osg::TriangleIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 180 of file OSGTriangleIterator.inl.

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

Referenced by getTexCoords3().

00181 {
00182     return Inherited::getTexCoordsIndex3(_triPntIndex[which]);
00183 }

Vec2f osg::TriangleIterator::getTexCoords3 Int32  which  )  const [inline]
 

Return the index of the current face. The index runs from 0 to the number of triangles in the geometry. Its main use is as an input to osg::TriangleIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 186 of file OSGTriangleIterator.inl.

References osg::PrimitiveIterator::getGeometry(), getTexCoordsIndex3(), and osg::VectorInterface< Real32, VecStorage2 >::Null.

Referenced by osg::calcVertexTangents().

00187 {   
00188     Int32 ind = getTexCoordsIndex3(which);
00189     
00190     if(ind < 0)
00191         return Vec2f::Null;
00192         
00193     return getGeometry()->getTexCoords3()->getValue(ind);
00194 }

Int32 osg::TriangleIterator::getIndexIndex Int32  which  )  const [inline]
 

Return the index of the current face. The index runs from 0 to the number of triangles in the geometry. Its main use is as an input to osg::TriangleIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 198 of file OSGTriangleIterator.inl.

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

Referenced by osg::calcVertexNormals(), osg::calcVertexTangents(), and osg::createOptimizedPrimitives().

00199 {
00200     if(_triPntIndex[which] >= 0)
00201         return Inherited::getIndexIndex(_triPntIndex[which]);
00202     else 
00203         return -1;
00204 }

void TriangleIterator::operator++ void   ) 
 

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 155 of file OSGTriangleIterator.cpp.

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

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

void TriangleIterator::seek Int32  index  ) 
 

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

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 276 of file OSGTriangleIterator.cpp.

References getIndex(), and setToBegin().

00277 {
00278     setToBegin();
00279     
00280     while(getIndex() != index)
00281         ++(*this);
00282 }

TriangleIterator & TriangleIterator::operator= const TriangleIterator source  ) 
 

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

Definition at line 308 of file OSGTriangleIterator.cpp.

References _actPrimIndex, _triIndex, and _triPntIndex.

00309 {
00310     if(this == &source)
00311         return *this;
00312 
00313     *static_cast<Inherited *>(this) = source;
00314     
00315     this->_triIndex         = source._triIndex;
00316     this->_actPrimIndex     = source._actPrimIndex;
00317     this->_triPntIndex[0]   = source._triPntIndex[0];
00318     this->_triPntIndex[1]   = source._triPntIndex[1];
00319     this->_triPntIndex[2]   = source._triPntIndex[2];
00320 
00321     return *this;
00322 }

bool TriangleIterator::operator< const TriangleIterator other  )  const
 

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

Definition at line 326 of file OSGTriangleIterator.cpp.

References _actPrimIndex.

00327 {
00328     return 
00329           (*static_cast<const Inherited *>(this) <  other) ||
00330         ( (*static_cast<const Inherited *>(this) == other)             &&
00331           _actPrimIndex                          <  other._actPrimIndex);
00332 }

bool TriangleIterator::operator== const TriangleIterator other  )  const
 

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

Definition at line 334 of file OSGTriangleIterator.cpp.

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

00335 {
00336     if(isAtEnd() && other.isAtEnd())
00337         return true;
00338 
00339     if(isAtEnd() || other.isAtEnd())
00340         return false;
00341 
00342     return 
00343         (*static_cast<const Inherited *>(this) == other              ) &&
00344         _actPrimIndex                          == other._actPrimIndex;
00345 }

bool TriangleIterator::operator!= const TriangleIterator other  )  const
 

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

Definition at line 347 of file OSGTriangleIterator.cpp.

00348 {
00349     return !(*this == other);
00350 }

void TriangleIterator::setToBegin void   )  [protected]
 

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 289 of file OSGTriangleIterator.cpp.

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

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

00290 {
00291     PrimitiveIterator::setToBegin();
00292     _triIndex = 0;
00293     startPrim();
00294 }

void TriangleIterator::setToEnd void   )  [protected]
 

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 300 of file OSGTriangleIterator.cpp.

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

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

00301 {
00302     PrimitiveIterator::setToEnd();
00303     _actPrimIndex = 0;
00304 }

void TriangleIterator::startPrim void   )  [private]
 

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

Definition at line 228 of file OSGTriangleIterator.cpp.

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

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

00229 {
00230     // already at end?
00231     if(isAtEnd())
00232         return;
00233         
00234     _triPntIndex[0] = 0;
00235     _triPntIndex[1] = 1;
00236     _triPntIndex[2] = 2;
00237     _actPrimIndex = 3;
00238     
00239     // loop until you find a useful primitive or run out
00240     while(! isAtEnd())
00241     {
00242         switch(getType())
00243         {
00244         case GL_POINTS:         // non-polygon types: ignored
00245         case GL_LINES:
00246         case GL_LINE_STRIP: 
00247         case GL_LINE_LOOP:  
00248                                 break;
00249         case GL_TRIANGLES:      // polygon types
00250         case GL_TRIANGLE_STRIP:
00251         case GL_TRIANGLE_FAN:
00252         case GL_QUADS:
00253         case GL_QUAD_STRIP:
00254         case GL_POLYGON:        if(getLength() >= 3)
00255                                     return;
00256                                 break;
00257         default:                SWARNING << "TriangleIterator::startPrim: "
00258                                           << "encountered " 
00259                                           << "unknown primitive type " 
00260                                           << getType()
00261                                           << ", ignoring!" << std::endl;
00262                                 break;
00263         }
00264         
00265         ++(static_cast<PrimitiveIterator&>(*this));
00266     }           
00267 }

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(), osg::FaceIterator::FaceIterator(), osg::LineIterator::LineIterator(), osg::PrimitiveIterator::PrimitiveIterator(), osg::PrimitiveIterator::setGeo(), and TriangleIterator().

00300 {
00301     OSG_ASSERT(geo != NullFC);
00302 
00303     _geo     = geo;
00304     _types   = geo->getTypes();
00305     _lengths = geo->getLengths();
00306     _indices = geo->getIndices();
00307     
00308     setToBegin();
00309 }

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

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

Definition at line 315 of file OSGPrimitiveIterator.cpp.

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

00316 {
00317     GeometryPtr gc = GeometryPtr::dcast(geo->getCore());
00318     
00319     if(gc == NullFC)
00320     {
00321         FWARNING(("PrimitiveIterator::setGeo: called for NodePtr which "
00322                   "is not a Geometry!\n"));
00323     }
00324     else
00325     {
00326         setGeo(gc);
00327     }
00328 }

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

Check if the iterator has already reached the end of the geometry.

Definition at line 55 of file OSGPrimitiveIterator.inl.

References osg::PrimitiveIterator::_ended.

Referenced by operator++(), osg::PrimitiveIterator::operator++(), osg::LineIterator::operator++(), osg::FaceIterator::operator++(), osg::EdgeIterator::operator++(), operator==(), osg::LineIterator::operator==(), osg::FaceIterator::operator==(), osg::EdgeIterator::operator==(), osg::SplitGraphOp::splitNode(), startPrim(), osg::LineIterator::startPrim(), osg::FaceIterator::startPrim(), and