osgEarth 2.1.1
Public Member Functions | Protected Attributes

osgEarth::Symbology::LineFunctor< T > Class Template Reference

List of all members.

Public Member Functions

 LineFunctor ()
virtual ~LineFunctor ()
void setTreatVertexDataAsTemporary (bool treatVertexDataAsTemporary)
bool getTreatVertexDataAsTemporary () const
virtual void setVertexArray (unsigned int count, const osg::Vec3 *vertices)
virtual void setVertexArray (unsigned int, const osg::Vec2 *)
virtual void setVertexArray (unsigned int, const osg::Vec4 *)
virtual void setVertexArray (unsigned int, const osg::Vec2d *)
virtual void setVertexArray (unsigned int, const osg::Vec3d *)
virtual void setVertexArray (unsigned int, const osg::Vec4d *)
virtual void drawArrays (GLenum mode, GLint first, GLsizei count)
virtual void drawElements (GLenum mode, GLsizei count, const GLubyte *indicies)
virtual void drawElements (GLenum mode, GLsizei count, const GLushort *indicies)
virtual void drawElements (GLenum mode, GLsizei count, const GLuint *indicies)
virtual void begin (GLenum mode)
virtual void vertex (const osg::Vec2 &vert)
virtual void vertex (const osg::Vec3 &vert)
virtual void vertex (const osg::Vec4 &vert)
virtual void vertex (float x, float y)
virtual void vertex (float x, float y, float z)
virtual void vertex (float x, float y, float z, float w)
virtual void end ()

Protected Attributes

unsigned int _vertexArraySize
const osg::Vec3 * _vertexArrayPtr
GLenum _modeCache
std::vector< osg::Vec3 > _vertexCache
bool _treatVertexDataAsTemporary

Detailed Description

template<class T>
class osgEarth::Symbology::LineFunctor< T >

This is basically the same thing as osg::TriangleFunctor, but for lines.

Definition at line 34 of file LineFunctor.


Constructor & Destructor Documentation

template<class T>
osgEarth::Symbology::LineFunctor< T >::LineFunctor ( ) [inline]

Definition at line 38 of file LineFunctor.

template<class T>
virtual osgEarth::Symbology::LineFunctor< T >::~LineFunctor ( ) [inline, virtual]

Definition at line 46 of file LineFunctor.

{}

Member Function Documentation

template<class T>
virtual void osgEarth::Symbology::LineFunctor< T >::begin ( GLenum  mode) [inline, virtual]

Note: begin(..),vertex(..) & end() are convenience methods for adapting non vertex array primitives to vertex array based primitives. This is done to simplify the implementation of primitive functor subclasses - users only need override drawArray and drawElements.

Definition at line 262 of file LineFunctor.

        {
            _modeCache = mode;
            _vertexCache.clear();
        }
template<class T>
virtual void osgEarth::Symbology::LineFunctor< T >::drawArrays ( GLenum  mode,
GLint  first,
GLsizei  count 
) [inline, virtual]

Definition at line 64 of file LineFunctor.

        {
            if (_vertexArrayPtr==0 || count==0) return;

            switch(mode)
            {            
            case(GL_LINES):
                {
                    const osg::Vec3* vlast = &_vertexArrayPtr[first+count];
                    for(const osg::Vec3* vptr = &_vertexArrayPtr[first]; vptr<vlast; vptr+=2)
                        this->operator()( *(vptr), *(vptr+1), _treatVertexDataAsTemporary );
                }
                break;

            case(GL_LINE_STRIP):
                {
                    const osg::Vec3* vlast = &_vertexArrayPtr[first+count-1];
                    for(const osg::Vec3* vptr = &_vertexArrayPtr[first]; vptr<vlast; vptr++)
                        this->operator()( *(vptr), *(vptr+1), _treatVertexDataAsTemporary );
                }
                break;

            case(GL_LINE_LOOP):
                {
                    const osg::Vec3* vlast = &_vertexArrayPtr[first+count-1];
                    const osg::Vec3* vptr;
                    for(vptr = &_vertexArrayPtr[first]; vptr<vlast; vptr++)
                        this->operator()( *(vptr), *(vptr+1), _treatVertexDataAsTemporary );
                    if ( count >= 2 )
                        this->operator()( *vptr, _vertexArrayPtr[first], _treatVertexDataAsTemporary );
                }
                break;

            case(GL_TRIANGLES):
            case(GL_TRIANGLE_STRIP):
            case(GL_QUADS):
            case(GL_QUAD_STRIP):
            case(GL_POLYGON):
            case(GL_TRIANGLE_FAN):
            case(GL_POINTS):
            default:
                // can't be converted into to line segments.
                break;
            }
        }

Here is the caller graph for this function:

template<class T>
virtual void osgEarth::Symbology::LineFunctor< T >::drawElements ( GLenum  mode,
GLsizei  count,
const GLubyte *  indicies 
) [inline, virtual]

Definition at line 110 of file LineFunctor.

        {
            if (indicies==0 || count==0) return;

            typedef const GLubyte* IndexPointer;

            switch(mode)
            {
            case(GL_LINES):
                {
                    IndexPointer ilast = &indicies[count];
                    for(IndexPointer iptr=indicies; iptr<ilast; iptr+=2)
                        this->operator()( _vertexArrayPtr[*iptr], _vertexArrayPtr[*(iptr+1)], _treatVertexDataAsTemporary );
                }
                break;

            case(GL_LINE_STRIP):
                {
                    IndexPointer ilast = &indicies[count-1];
                    for(IndexPointer iptr=indicies; iptr<ilast; iptr++)
                        this->operator()( _vertexArrayPtr[*iptr], _vertexArrayPtr[*(iptr+1)], _treatVertexDataAsTemporary );
                }
                break;

            case(GL_LINE_LOOP):
                {
                    IndexPointer ilast = &indicies[count-1];
                    IndexPointer iptr;
                    for(iptr=indicies; iptr<ilast; iptr++)
                        this->operator()( _vertexArrayPtr[*iptr], _vertexArrayPtr[*(iptr+1)], _treatVertexDataAsTemporary );
                    if (count >= 2)
                        this->operator()( _vertexArrayPtr[*iptr], _vertexArrayPtr[indicies[0]], _treatVertexDataAsTemporary );
                }
                break;

            case(GL_TRIANGLES):
            case(GL_TRIANGLE_STRIP):
            case(GL_QUADS):
            case(GL_QUAD_STRIP):
            case(GL_POLYGON):
            case(GL_TRIANGLE_FAN):
            case(GL_POINTS):
            default:
                // can't be converted into to lines.
                break;
            }
        }    
template<class T>
virtual void osgEarth::Symbology::LineFunctor< T >::drawElements ( GLenum  mode,
GLsizei  count,
const GLushort *  indicies 
) [inline, virtual]

Definition at line 158 of file LineFunctor.

        {
            if (indicies==0 || count==0) return;

            typedef const GLushort* IndexPointer;

            switch(mode)
            {
            case(GL_LINES):
                {
                    IndexPointer ilast = &indicies[count];
                    for(IndexPointer iptr=indicies; iptr<ilast; iptr+=2)
                        this->operator()( _vertexArrayPtr[*iptr], _vertexArrayPtr[*(iptr+1)], _treatVertexDataAsTemporary );
                }
                break;

            case(GL_LINE_STRIP):
                {
                    IndexPointer ilast = &indicies[count-1];
                    for(IndexPointer iptr=indicies; iptr<ilast; iptr++)
                        this->operator()( _vertexArrayPtr[*iptr], _vertexArrayPtr[*(iptr+1)], _treatVertexDataAsTemporary );
                }
                break;

            case(GL_LINE_LOOP):
                {
                    IndexPointer ilast = &indicies[count-1];
                    IndexPointer iptr;
                    for(iptr=indicies; iptr<ilast; iptr++)
                        this->operator()( _vertexArrayPtr[*iptr], _vertexArrayPtr[*(iptr+1)], _treatVertexDataAsTemporary );
                    if (count >= 2)
                        this->operator()( _vertexArrayPtr[*iptr], _vertexArrayPtr[indicies[0]], _treatVertexDataAsTemporary );
                }
                break;

            case(GL_TRIANGLES):
            case(GL_TRIANGLE_STRIP):
            case(GL_QUADS):
            case(GL_QUAD_STRIP):
            case(GL_POLYGON):
            case(GL_TRIANGLE_FAN):
            case(GL_POINTS):
            default:
                // can't be converted into to lines.
                break;
            }
        }    
template<class T>
virtual void osgEarth::Symbology::LineFunctor< T >::drawElements ( GLenum  mode,
GLsizei  count,
const GLuint *  indicies 
) [inline, virtual]

Definition at line 206 of file LineFunctor.

        {
            if (indicies==0 || count==0) return;

            typedef const GLuint* IndexPointer;

            switch(mode)
            {
            case(GL_LINES):
                {
                    IndexPointer ilast = &indicies[count];
                    for(IndexPointer iptr=indicies; iptr<ilast; iptr+=2)
                        this->operator()( _vertexArrayPtr[*iptr], _vertexArrayPtr[*(iptr+1)], _treatVertexDataAsTemporary );
                }
                break;

            case(GL_LINE_STRIP):
                {
                    IndexPointer ilast = &indicies[count-1];
                    for(IndexPointer iptr=indicies; iptr<ilast; iptr++)
                        this->operator()( _vertexArrayPtr[*iptr], _vertexArrayPtr[*(iptr+1)], _treatVertexDataAsTemporary );
                }
                break;

            case(GL_LINE_LOOP):
                {
                    IndexPointer ilast = &indicies[count-1];
                    IndexPointer iptr;
                    for(iptr=indicies; iptr<ilast; iptr++)
                        this->operator()( _vertexArrayPtr[*iptr], _vertexArrayPtr[*(iptr+1)], _treatVertexDataAsTemporary );
                    if (count >= 2)
                        this->operator()( _vertexArrayPtr[*iptr], _vertexArrayPtr[indicies[0]], _treatVertexDataAsTemporary );
                }
                break;

            case(GL_TRIANGLES):
            case(GL_TRIANGLE_STRIP):
            case(GL_QUADS):
            case(GL_QUAD_STRIP):
            case(GL_POLYGON):
            case(GL_TRIANGLE_FAN):
            case(GL_POINTS):
            default:
                // can't be converted into to lines.
                break;
            }
        }
template<class T>
virtual void osgEarth::Symbology::LineFunctor< T >::end ( ) [inline, virtual]

Definition at line 274 of file LineFunctor.

Here is the call graph for this function:

template<class T>
bool osgEarth::Symbology::LineFunctor< T >::getTreatVertexDataAsTemporary ( ) const [inline]

Definition at line 49 of file LineFunctor.

template<class T>
void osgEarth::Symbology::LineFunctor< T >::setTreatVertexDataAsTemporary ( bool  treatVertexDataAsTemporary) [inline]

Definition at line 48 of file LineFunctor.

{ _treatVertexDataAsTemporary=treatVertexDataAsTemporary; }
template<class T>
virtual void osgEarth::Symbology::LineFunctor< T >::setVertexArray ( unsigned int  count,
const osg::Vec3 *  vertices 
) [inline, virtual]

Definition at line 52 of file LineFunctor.

        {
            _vertexArraySize = count;
            _vertexArrayPtr = vertices;
        }

Here is the caller graph for this function:

template<class T>
virtual void osgEarth::Symbology::LineFunctor< T >::setVertexArray ( unsigned  int,
const osg::Vec4d *   
) [inline, virtual]

Definition at line 62 of file LineFunctor.

{ }
template<class T>
virtual void osgEarth::Symbology::LineFunctor< T >::setVertexArray ( unsigned  int,
const osg::Vec2 *   
) [inline, virtual]

Definition at line 58 of file LineFunctor.

{ }
template<class T>
virtual void osgEarth::Symbology::LineFunctor< T >::setVertexArray ( unsigned  int,
const osg::Vec4 *   
) [inline, virtual]

Definition at line 59 of file LineFunctor.

{ }
template<class T>
virtual void osgEarth::Symbology::LineFunctor< T >::setVertexArray ( unsigned  int,
const osg::Vec2d *   
) [inline, virtual]

Definition at line 60 of file LineFunctor.

{ }
template<class T>
virtual void osgEarth::Symbology::LineFunctor< T >::setVertexArray ( unsigned  int,
const osg::Vec3d *   
) [inline, virtual]

Definition at line 61 of file LineFunctor.

{ }
template<class T>
virtual void osgEarth::Symbology::LineFunctor< T >::vertex ( const osg::Vec2 &  vert) [inline, virtual]

Definition at line 268 of file LineFunctor.

{ _vertexCache.push_back(osg::Vec3(vert[0],vert[1],0.0f)); }
template<class T>
virtual void osgEarth::Symbology::LineFunctor< T >::vertex ( float  x,
float  y,
float  z,
float  w 
) [inline, virtual]

Definition at line 273 of file LineFunctor.

{ _vertexCache.push_back(osg::Vec3(x,y,z)/w); }
template<class T>
virtual void osgEarth::Symbology::LineFunctor< T >::vertex ( const osg::Vec4 &  vert) [inline, virtual]

Definition at line 270 of file LineFunctor.

{ _vertexCache.push_back(osg::Vec3(vert[0],vert[1],vert[2])/vert[3]); }
template<class T>
virtual void osgEarth::Symbology::LineFunctor< T >::vertex ( float  x,
float  y 
) [inline, virtual]

Definition at line 271 of file LineFunctor.

{ _vertexCache.push_back(osg::Vec3(x,y,0.0f)); }
template<class T>
virtual void osgEarth::Symbology::LineFunctor< T >::vertex ( const osg::Vec3 &  vert) [inline, virtual]

Definition at line 269 of file LineFunctor.

{ _vertexCache.push_back(vert); }
template<class T>
virtual void osgEarth::Symbology::LineFunctor< T >::vertex ( float  x,
float  y,
float  z 
) [inline, virtual]

Definition at line 272 of file LineFunctor.

{ _vertexCache.push_back(osg::Vec3(x,y,z)); }

Member Data Documentation

template<class T>
GLenum osgEarth::Symbology::LineFunctor< T >::_modeCache [protected]

Definition at line 290 of file LineFunctor.

template<class T>
bool osgEarth::Symbology::LineFunctor< T >::_treatVertexDataAsTemporary [protected]

Definition at line 292 of file LineFunctor.

template<class T>
const osg::Vec3* osgEarth::Symbology::LineFunctor< T >::_vertexArrayPtr [protected]

Definition at line 288 of file LineFunctor.

template<class T>
unsigned int osgEarth::Symbology::LineFunctor< T >::_vertexArraySize [protected]

Definition at line 287 of file LineFunctor.

template<class T>
std::vector<osg::Vec3> osgEarth::Symbology::LineFunctor< T >::_vertexCache [protected]

Definition at line 291 of file LineFunctor.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines