osgEarth 2.1.1
|
Public Member Functions | |
GeometryIterator (Geometry *geom, bool traversePolygonHoles=true) | |
bool | hasMore () const |
Geometry * | next () |
Private Member Functions | |
void | fetchNext () |
Private Attributes | |
Geometry * | _next |
std::stack< Geometry * > | _stack |
bool | _traverseMulti |
bool | _traversePolyHoles |
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.
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(); } }
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; } }
bool GeometryIterator::hasMore | ( | ) | const |
Definition at line 676 of file Geometry.cpp.
{ return _next != 0L; }
Geometry * GeometryIterator::next | ( | ) |
Definition at line 682 of file Geometry.cpp.
std::stack<Geometry*> osgEarth::Symbology::GeometryIterator::_stack [private] |
bool osgEarth::Symbology::GeometryIterator::_traverseMulti [private] |
bool osgEarth::Symbology::GeometryIterator::_traversePolyHoles [private] |