osg::EdgeIterator Class Reference
[Geometry Iterators]

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

#include <OSGEdgeIterator.h>

Inheritance diagram for osg::EdgeIterator:

osg::PrimitiveIterator

List of all members.

Public Member Functions

Constructors


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


virtual ~EdgeIterator (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)
EdgeIteratoroperator= (const EdgeIterator &source)
bool operator< (const EdgeIterator &other) const
bool operator== (const EdgeIterator &other) const
bool operator!= (const EdgeIterator &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 _edgeIndex
UInt32 _actPrimIndex
Int32 _edgePntIndex [2]

Static Private Attributes

static char cvsid [] = "@(#)$Id: OSGEdgeIterator.cpp,v 1.1 2005/01/14 11:24:21 a-m-z Exp $"


Detailed Description

The EdgeIterator iterates through the geometry one edge at a time. See Edge Iterator for a description.

See also:
PrimitiveIterator EdgeIterator

Definition at line 60 of file OSGEdgeIterator.h.


Member Typedef Documentation

Definition at line 152 of file OSGEdgeIterator.h.


Constructor & Destructor Documentation

EdgeIterator::EdgeIterator ( void   ) 

Definition at line 109 of file OSGEdgeIterator.cpp.

00109                                :  PrimitiveIterator(),
00110     _edgeIndex(0), _actPrimIndex(), _edgePntIndex()
00111 {
00112 }

EdgeIterator::EdgeIterator ( const EdgeIterator source  ) 

Definition at line 114 of file OSGEdgeIterator.cpp.

References _edgePntIndex.

00114                                                      :
00115     PrimitiveIterator(source),
00116     _edgeIndex(source._edgeIndex),
00117     _actPrimIndex(source._actPrimIndex),
00118     _edgePntIndex()
00119 {
00120     _edgePntIndex[0] = source._edgePntIndex[0];
00121     _edgePntIndex[1] = source._edgePntIndex[1];
00122 }

EdgeIterator::EdgeIterator ( 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 edge. Otherwise, use Geometry::beginEdges() resp. Geometry::endEdges() to create an iterator.

Definition at line 140 of file OSGEdgeIterator.cpp.

References osg::PrimitiveIterator::setGeo().

00140                                                  : PrimitiveIterator(),
00141     _edgeIndex(0), _actPrimIndex(), _edgePntIndex()
00142 {
00143     setGeo(geo);
00144 }

EdgeIterator::EdgeIterator ( 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 edge. Otherwise, use Geometry::beginEdges() resp. Geometry::endEdges() to create an iterator.

Definition at line 129 of file OSGEdgeIterator.cpp.

References osg::PrimitiveIterator::setGeo().

00129                                              : PrimitiveIterator(),
00130     _edgeIndex(0), _actPrimIndex(), _edgePntIndex()
00131 {
00132     setGeo(geo);
00133 }

EdgeIterator::~EdgeIterator ( void   )  [virtual]

Definition at line 147 of file OSGEdgeIterator.cpp.

00148 {
00149 }


Member Function Documentation

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 69 of file OSGEdgeIterator.h.

00069 { return "EdgeIterator"; }

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 51 of file OSGEdgeIterator.inl.

References _edgeIndex.

Referenced by seek().

00052 {
00053     return _edgeIndex;
00054 }

UInt32 osg::EdgeIterator::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 OSGEdgeIterator.inl.

References osg::PrimitiveIterator::getLength(), and osg::PrimitiveIterator::getType().

00063 {
00064     if ( getType() == GL_LINES )
00065         return 2;
00066     else
00067         return Inherited::getLength();
00068 }

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 101 of file OSGEdgeIterator.inl.

References _edgePntIndex, osg::PrimitiveIterator::getPositionIndex(), and osg::PrimitiveIterator::getType().

Referenced by getPosition().

00102 {
00103     if ( getType() == GL_LINES )
00104         return Inherited::getPositionIndex(_edgePntIndex[which]);
00105     else
00106         return Inherited::getPositionIndex(which);
00107 }

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 110 of file OSGEdgeIterator.inl.

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

00111 { 
00112     Int32 ind = getPositionIndex(which);
00113 
00114     return getGeometry()->getPositions()->getValue(ind);
00115 }

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 118 of file OSGEdgeIterator.inl.

References _edgePntIndex, osg::PrimitiveIterator::getNormalIndex(), and osg::PrimitiveIterator::getType().

Referenced by getNormal().

00119 {
00120     if ( getType() == GL_LINES )
00121         return Inherited::getNormalIndex(_edgePntIndex[which]);
00122     else
00123         return Inherited::getNormalIndex(which);
00124 }

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 127 of file OSGEdgeIterator.inl.

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

00128 { 
00129     Int32 ind = getNormalIndex(which);
00130 
00131     return getGeometry()->getNormals()->getValue(ind);
00132 }

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 135 of file OSGEdgeIterator.inl.

References _edgePntIndex, osg::PrimitiveIterator::getColorIndex(), and osg::PrimitiveIterator::getType().

Referenced by getColor().

00136 {
00137     if ( getType() == GL_LINES )
00138         return Inherited::getColorIndex(_edgePntIndex[which]);
00139     else
00140         return Inherited::getColorIndex(which);
00141 }

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 144 of file OSGEdgeIterator.inl.

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

00145 { 
00146     Int32 ind = getColorIndex(which);
00147 
00148     return getGeometry()->getColors()->getValue(ind);
00149 }

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 152 of file OSGEdgeIterator.inl.

References _edgePntIndex, osg::PrimitiveIterator::getSecondaryColorIndex(), and osg::PrimitiveIterator::getType().

Referenced by getSecondaryColor().

00153 {
00154     if ( getType() == GL_LINES )
00155         return Inherited::getSecondaryColorIndex(_edgePntIndex[which]);
00156     else
00157         return Inherited::getSecondaryColorIndex(which);
00158 }

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 161 of file OSGEdgeIterator.inl.

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

00162 { 
00163     Int32 ind = getSecondaryColorIndex(which);
00164 
00165     return getGeometry()->getSecondaryColors()->getValue(ind);
00166 }

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 169 of file OSGEdgeIterator.inl.

References _edgePntIndex, osg::PrimitiveIterator::getTexCoordsIndex(), and osg::PrimitiveIterator::getType().

Referenced by getTexCoords().

00170 {
00171     if ( getType() == GL_LINES )
00172         return Inherited::getTexCoordsIndex(_edgePntIndex[which]);
00173     else
00174         return Inherited::getTexCoordsIndex(which);
00175 }

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 178 of file OSGEdgeIterator.inl.

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

00179 { 
00180     Int32 ind = getTexCoordsIndex(which);
00181 
00182     return getGeometry()->getTexCoords()->getValue(ind);
00183 }

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 187 of file OSGEdgeIterator.inl.

References _edgePntIndex, osg::PrimitiveIterator::getTexCoordsIndex1(), and osg::PrimitiveIterator::getType().

Referenced by getTexCoords1().

00188 {
00189     if ( getType() == GL_LINES )
00190         return Inherited::getTexCoordsIndex1(_edgePntIndex[which]);
00191     else
00192         return Inherited::getTexCoordsIndex1(which);
00193 }

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 196 of file OSGEdgeIterator.inl.

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

00197 { 
00198     Int32 ind = getTexCoordsIndex1(which);
00199 
00200     return getGeometry()->getTexCoords1()->getValue(ind);
00201 }

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 204 of file OSGEdgeIterator.inl.

References _edgePntIndex, osg::PrimitiveIterator::getTexCoordsIndex2(), and osg::PrimitiveIterator::getType().

Referenced by getTexCoords2().

00205 {
00206     if ( getType() == GL_LINES )
00207         return Inherited::getTexCoordsIndex2(_edgePntIndex[which]);
00208     else
00209         return Inherited::getTexCoordsIndex2(which);
00210 }

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 213 of file OSGEdgeIterator.inl.

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

00214 { 
00215     Int32 ind = getTexCoordsIndex2(which);
00216 
00217     return getGeometry()->getTexCoords2()->getValue(ind);
00218 }

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 221 of file OSGEdgeIterator.inl.

References _edgePntIndex, osg::PrimitiveIterator::getTexCoordsIndex3(), and osg::PrimitiveIterator::getType().

Referenced by getTexCoords3().

00222 {
00223     if ( getType() == GL_LINES )
00224         return Inherited::getTexCoordsIndex3(_edgePntIndex[which]);
00225     else
00226         return Inherited::getTexCoordsIndex3(which);
00227 }

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 230 of file OSGEdgeIterator.inl.

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

00231 { 
00232     Int32 ind = getTexCoordsIndex3(which);
00233 
00234     return getGeometry()->getTexCoords3()->getValue(ind);
00235 }

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 238 of file OSGEdgeIterator.inl.

References _edgePntIndex, osg::PrimitiveIterator::getTexCoordsIndex4(), and osg::PrimitiveIterator::getType().

Referenced by getTexCoords4().

00239 {
00240     if ( getType() == GL_LINES )
00241         return Inherited::getTexCoordsIndex4(_edgePntIndex[which]);
00242     else
00243         return Inherited::getTexCoordsIndex4(which);
00244 }

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 247 of file OSGEdgeIterator.inl.

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

00248 { 
00249     Int32 ind = getTexCoordsIndex4(which);
00250 
00251     return getGeometry()->getTexCoords4()->getValue(ind);
00252 }

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 255 of file OSGEdgeIterator.inl.

References _edgePntIndex, osg::PrimitiveIterator::getTexCoordsIndex5(), and osg::PrimitiveIterator::getType().

Referenced by getTexCoords5().

00256 {
00257     if ( getType() == GL_LINES )
00258         return Inherited::getTexCoordsIndex5(_edgePntIndex[which]);
00259     else
00260         return Inherited::getTexCoordsIndex5(which);
00261 }

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 264 of file OSGEdgeIterator.inl.

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

00265 { 
00266     Int32 ind = getTexCoordsIndex5(which);
00267 
00268     return getGeometry()->getTexCoords5()->getValue(ind);
00269 }

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 272 of file OSGEdgeIterator.inl.

References _edgePntIndex, osg::PrimitiveIterator::getTexCoordsIndex6(), and osg::PrimitiveIterator::getType().

Referenced by getTexCoords6().

00273 {
00274     if ( getType() == GL_LINES )
00275         return Inherited::getTexCoordsIndex6(_edgePntIndex[which]);
00276     else
00277         return Inherited::getTexCoordsIndex6(which);
00278 }

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 281 of file OSGEdgeIterator.inl.

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

00282 { 
00283     Int32 ind = getTexCoordsIndex6(which);
00284 
00285     return getGeometry()->getTexCoords6()->getValue(ind);
00286 }

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 289 of file OSGEdgeIterator.inl.

References _edgePntIndex, osg::PrimitiveIterator::getTexCoordsIndex7(), and osg::PrimitiveIterator::getType().

Referenced by getTexCoords7().

00290 {
00291     if ( getType() == GL_LINES )
00292         return Inherited::getTexCoordsIndex7(_edgePntIndex[which]);
00293     else
00294         return Inherited::getTexCoordsIndex7(which);
00295 }

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 298 of file OSGEdgeIterator.inl.

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

00299 { 
00300     Int32 ind = getTexCoordsIndex7(which);
00301 
00302     return getGeometry()->getTexCoords7()->getValue(ind);
00303 }

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 306 of file OSGEdgeIterator.inl.

References _edgePntIndex, osg::PrimitiveIterator::getIndexIndex(), and osg::PrimitiveIterator::getType().

00307 {
00308     if ( getType() == GL_LINES )
00309         return Inherited::getIndexIndex(_edgePntIndex[which]);
00310     else
00311         return Inherited::getIndexIndex(which);
00312 }

void EdgeIterator::seek ( Int32  index  ) 

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

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 261 of file OSGEdgeIterator.cpp.

References getIndex(), and setToBegin().

00262 {
00263     setToBegin();
00264     
00265     while(getIndex() != index)
00266         ++(*this);
00267 }

void EdgeIterator::operator++ ( void   ) 

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 162 of file OSGEdgeIterator.cpp.

References _actPrimIndex, _edgeIndex, _edgePntIndex, osg::PrimitiveIterator::getLength(), osg::PrimitiveIterator::getType(), osg::PrimitiveIterator::isAtEnd(), startPrim(), and SWARNING.

00163 {
00164     // already at end?
00165     if(isAtEnd())
00166         return;
00167     
00168     ++_edgeIndex;
00169 
00170     // at end of primitive?
00171     if(_actPrimIndex >= PrimitiveIterator::getLength() ||
00172        getType() == GL_LINE_STRIP ||
00173        getType() == GL_LINE_LOOP    )  // TODO: add GL_POLYLINE here ?!?!
00174     {
00175         ++(static_cast<PrimitiveIterator&>(*this));
00176         
00177         startPrim();
00178         
00179         return;
00180     }
00181 
00182     switch(getType())
00183     {
00184     case GL_LINES:          _edgePntIndex[0] = _actPrimIndex++;
00185                             _edgePntIndex[1] = _actPrimIndex++;
00186                             break;
00187 #if 0 // probably to be implemented
00188                             
00189     case GL_POLYGON:        TODO
00190                             break;  
00191     case GL_TRIANGLES:      TODO
00192                             break;
00193     case GL_QUAD_STRIP:     TODO
00194                             break;
00195     case GL_TRIANGLE_STRIP: TODO
00196                             break;
00197     case GL_TRIANGLE_FAN:   TODO
00198                             break;
00199     case GL_QUADS:          TODO
00200                             break;
00201 #endif // probably to be implemented
00202     default:                SWARNING << "EdgeIterator::++: encountered " 
00203                                       << "unknown primitive type " 
00204                                       << getType()
00205                                       << ", ignoring!" << std::endl;
00206                             startPrim();
00207                             break;
00208     }           
00209 }

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

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

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

Definition at line 292 of file OSGEdgeIterator.cpp.

References _actPrimIndex, _edgeIndex, and _edgePntIndex.

00293 {
00294     if(this == &source)
00295         return *this;
00296     
00297     *static_cast<Inherited *>(this) = source;
00298 
00299     this->_edgeIndex            = source._edgeIndex;
00300     this->_actPrimIndex         = source._actPrimIndex;
00301     this->_edgePntIndex[0]      = source._edgePntIndex[0];
00302     this->_edgePntIndex[1]      = source._edgePntIndex[1];
00303 
00304     return *this;
00305 }

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

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

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

Definition at line 309 of file OSGEdgeIterator.cpp.

References _actPrimIndex.

00310 {
00311     return 
00312           (*static_cast<const Inherited *>(this) <  other) ||
00313         ( (*static_cast<const Inherited *>(this) == other)             &&
00314           _actPrimIndex                          <  other._actPrimIndex);
00315 }

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

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

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

Definition at line 317 of file OSGEdgeIterator.cpp.

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

00318 {
00319     if(isAtEnd() && other.isAtEnd())
00320         return true;
00321 
00322     if(isAtEnd() || other.isAtEnd())
00323         return false;
00324 
00325     return 
00326         (*static_cast<const Inherited *>(this) == other              ) &&
00327         _actPrimIndex                          == other._actPrimIndex;
00328 }

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

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

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

Definition at line 330 of file OSGEdgeIterator.cpp.

00331 {
00332     return !(*this == other);
00333 }

void EdgeIterator::setToBegin ( void   ) 

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 273 of file OSGEdgeIterator.cpp.

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

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

00274 {
00275     PrimitiveIterator::setToBegin();
00276     _edgeIndex = 0;
00277     startPrim();
00278 }

void EdgeIterator::setToEnd ( void   ) 

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 284 of file OSGEdgeIterator.cpp.

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

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

00285 {
00286     PrimitiveIterator::setToEnd();
00287     _actPrimIndex = 0;
00288 }

void EdgeIterator::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 216 of file OSGEdgeIterator.cpp.

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

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

00217 {
00218     // already at end?
00219     if(isAtEnd())
00220         return;
00221 
00222     _edgePntIndex[0] = 0;
00223     _edgePntIndex[1] = 1;
00224     _actPrimIndex = 2;
00225     
00226     // loop until you find a useful primitive or run out
00227     while(! isAtEnd())
00228     {
00229         switch(getType())
00230         {           
00231         case GL_LINES:                              
00232         case GL_LINE_STRIP: 
00233         case GL_LINE_LOOP:      if(PrimitiveIterator::getLength() >= 2)
00234                                    return;
00235                                 break; 
00236         case GL_POINTS:         // non-line types: (currently) ignored
00237         case GL_TRIANGLES: 
00238         case GL_TRIANGLE_STRIP:
00239         case GL_TRIANGLE_FAN:   
00240         case GL_POLYGON:        
00241         case GL_QUADS:
00242         case GL_QUAD_STRIP:
00243                                 break;
00244         default:            SWARNING << "EdgeIterator::startPrim: encountered " 
00245                                      << "unknown primitive type " 
00246                                      << getType()
00247                                      << ", ignoring!" << std::endl;
00248                             break;
00249         }   
00250         
00251         ++(static_cast<PrimitiveIterator&>(*this));   
00252     }       
00253 }

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 EdgeIterator(), osg::FaceIterator::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(), osg::FaceIterator::getColor(), getColor(), osg::TriangleIterator::getNormal(), osg::LineIterator::getNormal(), osg::FaceIterator::getNormal(), getNormal(), osg::TriangleIterator::getPosition(), osg::LineIterator::getPosition(), osg::FaceIterator::getPosition(), getPosition(), osg::TriangleIterator::getSecondaryColor(), osg::LineIterator::getSecondaryColor(), osg::FaceIterator::getSecondaryColor(), getSecondaryColor(), osg::TriangleIterator::getTexCoords(), osg::LineIterator::getTexCoords(), osg::FaceIterator::getTexCoords(), getTexCoords(), osg::TriangleIterator::getTexCoords1(), osg::LineIterator::getTexCoords1(), osg::FaceIterator::getTexCoords1(), getTexCoords1(), osg::TriangleIterator::getTexCoords2(), osg::LineIterator::getTexCoords2(), osg::FaceIterator::getTexCoords2(), getTexCoords2(), osg::TriangleIterator::getTexCoords3(), osg::LineIterator::getTexCoords3(), osg::FaceIterator::getTexCoords3(), getTexCoords3(), osg::TriangleIterator::getTexCoords4(), osg::LineIterator::getTexCoords4(), osg::FaceIterator::getTexCoords4(), getTexCoords4(), osg::TriangleIterator::getTexCoords5(), osg::LineIterator::getTexCoords5(), osg::FaceIterator::getTexCoords5(), getTexCoords5(), osg::TriangleIterator::getTexCoords6(), osg::LineIterator::getTexCoords6(), osg::FaceIterator::getTexCoords6(), getTexCoords6(), osg::TriangleIterator::getTexCoords7(), osg::LineIterator::getTexCoords7(), osg::FaceIterator::getTexCoords7(), and 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 EdgeIterator::cvsid = "@(#)$Id: OSGEdgeIterator.cpp,v 1.1 2005/01/14 11:24:21 a-m-z Exp $" [static, private]

Reimplemented from osg::PrimitiveIterator.

Definition at line 156 of file OSGEdgeIterator.h.

Definition at line 158 of file OSGEdgeIterator.h.

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

Definition at line 159 of file OSGEdgeIterator.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 11:13:26 2008 for OpenSG by  doxygen 1.5.5