osg::LineIterator Class Reference
[Geometry Iterators]

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

#include <OSGLineIterator.h>

Inheritance diagram for osg::LineIterator:
osg::PrimitiveIterator

List of all members.

Public Member Functions

Constructors



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



virtual ~LineIterator (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 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 operator++ (void)
void seek (Int32 index)
LineIteratoroperator= (const LineIterator &source)
bool operator< (const LineIterator &other) const
bool operator== (const LineIterator &other) const
bool operator!= (const LineIterator &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

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 _lineIndex
UInt32 _actPrimIndex
Int32 _linePntIndex [2]

Static Private Attributes

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

Friends

class Geometry

Detailed Description

The LineIterator iterates through the geometry one line at a time. See Line Iterator for details.

See also:
PrimitiveIterator FaceIterator

Definition at line 58 of file OSGLineIterator.h.


Member Typedef Documentation

Definition at line 142 of file OSGLineIterator.h.


Constructor & Destructor Documentation

LineIterator::LineIterator ( void   ) 

Definition at line 103 of file OSGLineIterator.cpp.

00103                                : PrimitiveIterator(),
00104     _lineIndex(0), _actPrimIndex(0), _linePntIndex()
00105 {
00106 }

LineIterator::LineIterator ( const LineIterator source  ) 

Definition at line 108 of file OSGLineIterator.cpp.

References _linePntIndex.

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

LineIterator::LineIterator ( 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 123 of file OSGLineIterator.cpp.

References osg::PrimitiveIterator::setGeo().

00123                                                  :
00124     PrimitiveIterator(),
00125     _lineIndex(0), _actPrimIndex(0), _linePntIndex()
00126 {
00127     setGeo(geo);
00128 }

LineIterator::LineIterator ( 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 137 of file OSGLineIterator.cpp.

References osg::PrimitiveIterator::setGeo().

00137                                              : 
00138     PrimitiveIterator(),
00139     _lineIndex(0), _actPrimIndex(0), _linePntIndex()
00140 {
00141     setGeo(geo);
00142 }

LineIterator::~LineIterator ( void   )  [virtual]

Definition at line 145 of file OSGLineIterator.cpp.

00146 {
00147 }


Member Function Documentation

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 67 of file OSGLineIterator.h.

00067 { return "LineIterator"; }

Int32 osg::LineIterator::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::LineIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 54 of file OSGLineIterator.inl.

References _lineIndex.

Referenced by seek().

00055 {
00056     return _lineIndex;
00057 }

Int32 osg::LineIterator::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::LineIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 60 of file OSGLineIterator.inl.

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

Referenced by getPosition().

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

Pnt3f osg::LineIterator::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::LineIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 66 of file OSGLineIterator.inl.

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

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

Int32 osg::LineIterator::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::LineIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 74 of file OSGLineIterator.inl.

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

Referenced by getNormal().

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

Vec3f osg::LineIterator::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::LineIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 80 of file OSGLineIterator.inl.

References osg::PrimitiveIterator::getGeometry(), getNormalIndex(), and osg::Vector< Real32, 3 >::Null.

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::LineIterator::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::LineIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 91 of file OSGLineIterator.inl.

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

Referenced by getColor().

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

Color3f osg::LineIterator::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::LineIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 97 of file OSGLineIterator.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::LineIterator::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::LineIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 108 of file OSGLineIterator.inl.

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

Referenced by getSecondaryColor().

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

Color3f osg::LineIterator::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::LineIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 114 of file OSGLineIterator.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::LineIterator::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::LineIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 126 of file OSGLineIterator.inl.

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

Referenced by getTexCoords().

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

Vec2f osg::LineIterator::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::LineIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 132 of file OSGLineIterator.inl.

References osg::PrimitiveIterator::getGeometry(), getTexCoordsIndex(), and osg::Vector< Real32, 2 >::Null.

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::LineIterator::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::LineIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 144 of file OSGLineIterator.inl.

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

Referenced by getTexCoords1().

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

Vec2f osg::LineIterator::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::LineIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 150 of file OSGLineIterator.inl.

References osg::PrimitiveIterator::getGeometry(), getTexCoordsIndex1(), and osg::Vector< Real32, 2 >::Null.

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::LineIterator::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::LineIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 162 of file OSGLineIterator.inl.

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

Referenced by getTexCoords2().

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

Vec2f osg::LineIterator::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::LineIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 168 of file OSGLineIterator.inl.

References osg::PrimitiveIterator::getGeometry(), getTexCoordsIndex2(), and osg::Vector< Real32, 2 >::Null.

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::LineIterator::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::LineIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 180 of file OSGLineIterator.inl.

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

Referenced by getTexCoords3().

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

Vec2f osg::LineIterator::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::LineIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 186 of file OSGLineIterator.inl.

References osg::PrimitiveIterator::getGeometry(), getTexCoordsIndex3(), and osg::Vector< Real32, 2 >::Null.

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::LineIterator::getTexCoordsIndex4 ( 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::LineIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 197 of file OSGLineIterator.inl.

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

Referenced by getTexCoords4().

00198 {
00199     return Inherited::getTexCoordsIndex4(_linePntIndex[which]);
00200 }

Vec2f osg::LineIterator::getTexCoords4 ( 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::LineIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 203 of file OSGLineIterator.inl.

References osg::PrimitiveIterator::getGeometry(), getTexCoordsIndex4(), and osg::Vector< Real32, 2 >::Null.

00204 {   
00205     Int32 ind = getTexCoordsIndex4(which);
00206     
00207     if(ind < 0)
00208         return Vec2f::Null;
00209         
00210     return getGeometry()->getTexCoords4()->getValue(ind);
00211 }

Int32 osg::LineIterator::getTexCoordsIndex5 ( 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::LineIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 214 of file OSGLineIterator.inl.

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

Referenced by getTexCoords5().

00215 {
00216     return Inherited::getTexCoordsIndex5(_linePntIndex[which]);
00217 }

Vec2f osg::LineIterator::getTexCoords5 ( 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::LineIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 220 of file OSGLineIterator.inl.

References osg::PrimitiveIterator::getGeometry(), getTexCoordsIndex5(), and osg::Vector< Real32, 2 >::Null.

00221 {   
00222     Int32 ind = getTexCoordsIndex5(which);
00223     
00224     if(ind < 0)
00225         return Vec2f::Null;
00226         
00227     return getGeometry()->getTexCoords5()->getValue(ind);
00228 }

Int32 osg::LineIterator::getTexCoordsIndex6 ( 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::LineIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 231 of file OSGLineIterator.inl.

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

Referenced by getTexCoords6().

00232 {
00233     return Inherited::getTexCoordsIndex6(_linePntIndex[which]);
00234 }

Vec2f osg::LineIterator::getTexCoords6 ( 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::LineIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 237 of file OSGLineIterator.inl.

References osg::PrimitiveIterator::getGeometry(), getTexCoordsIndex6(), and osg::Vector< Real32, 2 >::Null.

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

Int32 osg::LineIterator::getTexCoordsIndex7 ( 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::LineIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 248 of file OSGLineIterator.inl.

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

Referenced by getTexCoords7().

00249 {
00250     return Inherited::getTexCoordsIndex7(_linePntIndex[which]);
00251 }

Vec2f osg::LineIterator::getTexCoords7 ( 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::LineIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 254 of file OSGLineIterator.inl.

References osg::PrimitiveIterator::getGeometry(), getTexCoordsIndex7(), and osg::Vector< Real32, 2 >::Null.

00255 {   
00256     Int32 ind = getTexCoordsIndex7(which);
00257     
00258     if(ind < 0)
00259         return Vec2f::Null;
00260         
00261     return getGeometry()->getTexCoords7()->getValue(ind);
00262 }

Int32 osg::LineIterator::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::LineIterator::seek.

Reimplemented from osg::PrimitiveIterator.

Definition at line 265 of file OSGLineIterator.inl.

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

00266 {
00267     if(_linePntIndex[which] >= 0)
00268         return Inherited::getIndexIndex(_linePntIndex[which]);
00269     else 
00270         return -1;
00271 }

void LineIterator::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 154 of file OSGLineIterator.cpp.

References _actPrimIndex, _lineIndex, _linePntIndex, osg::PrimitiveIterator::getLength(), osg::PrimitiveIterator::getType(), osg::PrimitiveIterator::isAtEnd(), startPrim(), and SWARNING.

00155 {
00156     // already at end?
00157     if(isAtEnd())
00158         return;
00159     
00160     ++_lineIndex;
00161 
00162     // at end of primitive?
00163     if((_actPrimIndex >  getLength())                           ||
00164        (_actPrimIndex == getLength() && getType() != GL_LINE_LOOP))
00165     {
00166         ++(static_cast<PrimitiveIterator&>(*this));      
00167         startPrim();
00168         
00169         return;
00170     }
00171 
00172 
00173     switch(getType())
00174     {
00175     case GL_LINES:          _linePntIndex[0] = _actPrimIndex++;
00176                             _linePntIndex[1] = _actPrimIndex++;
00177                             break;                           
00178     case GL_LINE_STRIP:     _linePntIndex[0] = _linePntIndex[1];
00179                             _linePntIndex[1] = _actPrimIndex++;
00180                             break;
00181     case GL_LINE_LOOP:      _linePntIndex[0] = _linePntIndex[1];
00182                             if(_actPrimIndex < getLength())
00183                             {
00184                                 _linePntIndex[1] = _actPrimIndex++;
00185                             }
00186                             else
00187                             {
00188                                 _linePntIndex[1] = 0;
00189                                 _actPrimIndex++;    
00190                             }
00191                             break;
00192     default:                SWARNING << "LineIterator::++: encountered " 
00193                                       << "unknown primitive type " 
00194                                       << getType()
00195                                       << ", ignoring!" << std::endl;
00196                             startPrim();
00197                             break;
00198     }           
00199 }

void LineIterator::seek ( Int32  index  ) 

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

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 253 of file OSGLineIterator.cpp.

References getIndex(), and setToBegin().

00254 {
00255     setToBegin();
00256     
00257     while(getIndex() != index)
00258         ++(*this);
00259 }

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

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 285 of file OSGLineIterator.cpp.

References _actPrimIndex, _lineIndex, and _linePntIndex.

00286 {
00287     if(this == &source)
00288         return *this;
00289 
00290     *static_cast<Inherited *>(this) = source;
00291     
00292     this->_lineIndex        = source._lineIndex;
00293     this->_actPrimIndex     = source._actPrimIndex;
00294     this->_linePntIndex[0]  = source._linePntIndex[0];
00295     this->_linePntIndex[1]  = source._linePntIndex[1];
00296 
00297     return *this;
00298 }

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

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 302 of file OSGLineIterator.cpp.

References _actPrimIndex.

00303 {
00304     return 
00305           (*static_cast<const Inherited *>(this) <  other) ||
00306         ( (*static_cast<const Inherited *>(this) == other)             &&
00307           _actPrimIndex                          <  other._actPrimIndex);
00308 }

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

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 310 of file OSGLineIterator.cpp.

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

00311 {
00312     if(isAtEnd() && other.isAtEnd())
00313         return true;
00314 
00315     if(isAtEnd() || other.isAtEnd())
00316         return false;
00317 
00318     return 
00319         (*static_cast<const Inherited *>(this) == other              ) &&
00320         _actPrimIndex                          == other._actPrimIndex;
00321 }

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

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 323 of file OSGLineIterator.cpp.

00324 {
00325     return !(*this == other);
00326 }

void LineIterator::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 266 of file OSGLineIterator.cpp.

References _lineIndex, and startPrim().

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

00267 {
00268     PrimitiveIterator::setToBegin();
00269     _lineIndex = 0;
00270     startPrim();
00271 }

void LineIterator::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 277 of file OSGLineIterator.cpp.

References _actPrimIndex.

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

00278 {
00279     PrimitiveIterator::setToEnd();
00280     _actPrimIndex = 0;
00281 }

void LineIterator::startPrim ( void   )  [private]

Helper function to reset all state to the beginning of a new primitive. Also skips non-line primitives(triangles, quads, polygons, points) and primitives with less than 2 points.

Definition at line 206 of file OSGLineIterator.cpp.

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

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

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

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(), osg::FaceIterator::FaceIterator(), 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::getLength ( 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(), getColor(), osg::FaceIterator::getColor(), osg::EdgeIterator::getColor(), osg::TriangleIterator::getNormal(), getNormal(), osg::FaceIterator::getNormal(), osg::EdgeIterator::getNormal(), osg::TriangleIterator::getPosition(), getPosition(), osg::FaceIterator::getPosition(), osg::EdgeIterator::getPosition(), osg::TriangleIterator::getSecondaryColor(), getSecondaryColor(), osg::FaceIterator::getSecondaryColor(), osg::EdgeIterator::getSecondaryColor(), osg::TriangleIterator::getTexCoords(), getTexCoords(), osg::FaceIterator::getTexCoords(), osg::EdgeIterator::getTexCoords(), osg::TriangleIterator::getTexCoords1(), getTexCoords1(), osg::FaceIterator::getTexCoords1(), osg::EdgeIterator::getTexCoords1(), osg::TriangleIterator::getTexCoords2(), getTexCoords2(), osg::FaceIterator::getTexCoords2(), osg::EdgeIterator::getTexCoords2(), osg::TriangleIterator::getTexCoords3(), getTexCoords3(), osg::FaceIterator::getTexCoords3(), osg::EdgeIterator::getTexCoords3(), osg::TriangleIterator::getTexCoords4(), getTexCoords4(), osg::FaceIterator::getTexCoords4(), osg::EdgeIterator::getTexCoords4(), osg::TriangleIterator::getTexCoords5(), getTexCoords5(), osg::FaceIterator::getTexCoords5(), osg::EdgeIterator::getTexCoords5(), osg::TriangleIterator::getTexCoords6(), getTexCoords6(), osg::FaceIterator::getTexCoords6(), osg::EdgeIterator::getTexCoords6(), osg::TriangleIterator::getTexCoords7(), getTexCoords7(), osg::FaceIterator::getTexCoords7(), and osg::EdgeIterator::getTexCoords7().

00677 {
00678     return _geo;
00679 }


Friends And Related Function Documentation

friend class Geometry [friend]

Reimplemented from osg::PrimitiveIterator.

Definition at line 155 of file OSGLineIterator.h.


Member Data Documentation

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

Reimplemented from osg::PrimitiveIterator.

Definition at line 157 of file OSGLineIterator.h.

Running index of the lines iterated.

Definition at line 163 of file OSGLineIterator.h.

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

Index of the next point to use in the current primitive.

Definition at line 164 of file OSGLineIterator.h.

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


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

Generated on 8 Feb 2010 for OpenSG by  doxygen 1.6.1