osgEarth 2.1.1
Public Member Functions | Private Member Functions | Private Attributes

osgEarth::Symbology::GeometryIterator Class Reference

Collaboration diagram for osgEarth::Symbology::GeometryIterator:

List of all members.

Public Member Functions

 GeometryIterator (Geometry *geom, bool traversePolygonHoles=true)
bool hasMore () const
Geometrynext ()

Private Member Functions

void fetchNext ()

Private Attributes

Geometry_next
std::stack< Geometry * > _stack
bool _traverseMulti
bool _traversePolyHoles

Detailed Description

Iterates over a Geometry object, returning each component Geometry in turn. The iterator automatically traverses MultiGeometry objects, returning their components. The interator NEVER returns an actual MultiGeometry object.

Definition at line 325 of file Geometry.


Constructor & Destructor Documentation

GeometryIterator::GeometryIterator ( Geometry geom,
bool  traversePolygonHoles = true 
)

New iterator.

traversePolyHoles: set to TRUE to return Polygons AND Polygon hole geometries; set to FALSE to only return Polygon (outer ring).

traverseMultiGeometry: set to TRUE to return MG children, but never an MG itself; set to FALSE to return MGs and NOT their children.

Definition at line 663 of file Geometry.cpp.

                                                               :
_next( 0L ),
_traverseMulti( true ),
_traversePolyHoles( holes )
{
    if ( geom )
    {
        _stack.push( geom );
        fetchNext();
    }
}

Here is the call graph for this function:


Member Function Documentation

void GeometryIterator::fetchNext ( ) [private]

Definition at line 690 of file Geometry.cpp.

{
    _next = 0L;
    if ( _stack.size() == 0 )
        return;

    Geometry* current = _stack.top();
    _stack.pop();

    if ( current->getType() == Geometry::TYPE_MULTI && _traverseMulti )
    {
        MultiGeometry* m = static_cast<MultiGeometry*>(current);
        for( GeometryCollection::const_iterator i = m->getComponents().begin(); i != m->getComponents().end(); ++i )
            _stack.push( i->get() );
        fetchNext();
    }
    else if ( current->getType() == Geometry::TYPE_POLYGON && _traversePolyHoles )
    {
        Polygon* p = static_cast<Polygon*>(current);
        for( RingCollection::const_iterator i = p->getHoles().begin(); i != p->getHoles().end(); ++i )
            _stack.push( i->get() );
        _next = current;
    }
    else
    {
        _next = current;
    }    
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool GeometryIterator::hasMore ( ) const

Definition at line 676 of file Geometry.cpp.

{
    return _next != 0L;
}

Here is the caller graph for this function:

Geometry * GeometryIterator::next ( )

Definition at line 682 of file Geometry.cpp.

{
    Geometry* n = _next;
    fetchNext();
    return n;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 345 of file Geometry.

Definition at line 346 of file Geometry.

Definition at line 347 of file Geometry.

Definition at line 348 of file Geometry.


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