osgEarth 2.1.1
Public Member Functions | Public Attributes

anonymous_namespace{OverlayDecorator.cpp}::CoarsePolytopeIntersector Struct Reference

Collaboration diagram for anonymous_namespace{OverlayDecorator.cpp}::CoarsePolytopeIntersector:

List of all members.

Public Member Functions

 CoarsePolytopeIntersector (const MyConvexPolyhedron &polytope, osg::BoundingBox &out_bbox)
void apply (osg::Node &node)
void apply (osg::Geode &node)
void applyDrawable (osg::Drawable *drawable)
void apply (osg::Transform &transform)

Public Attributes

osg::BoundingBox & _bbox
MyConvexPolyhedron _original
std::stack< MyConvexPolyhedron_polytopeStack
std::stack< osg::Matrixd > _matrixStack
bool _coarse

Detailed Description

Visits a scene graph (in our case, the overlay graph) and calculates a geometry bounding box that intersects the provided polytope (which in out case is the view frustum).

It's called "Coarse" because it does not traverse to the Drawable level, just to the Geode bounding sphere level.

Definition at line 80 of file OverlayDecorator.cpp.


Constructor & Destructor Documentation

anonymous_namespace{OverlayDecorator.cpp}::CoarsePolytopeIntersector::CoarsePolytopeIntersector ( const MyConvexPolyhedron polytope,
osg::BoundingBox &  out_bbox 
) [inline]

Definition at line 82 of file OverlayDecorator.cpp.

            : osg::NodeVisitor( osg::NodeVisitor::TRAVERSE_ALL_CHILDREN ),
              _bbox(out_bbox),
              _original( polytope ),
              _coarse( true )
        {
            _polytopeStack.push( polytope );
            _matrixStack.push( osg::Matrix::identity() );
        }

Member Function Documentation

void anonymous_namespace{OverlayDecorator.cpp}::CoarsePolytopeIntersector::apply ( osg::Node &  node) [inline]

Definition at line 92 of file OverlayDecorator.cpp.

        {
            const osg::BoundingSphere& bs = node.getBound();
            if ( _polytopeStack.top().intersects( bs ) )
            {
                traverse( node );
            }
        }
void anonymous_namespace{OverlayDecorator.cpp}::CoarsePolytopeIntersector::apply ( osg::Transform &  transform) [inline]

Definition at line 135 of file OverlayDecorator.cpp.

        {
            osg::Matrixd matrix;
            transform.computeLocalToWorldMatrix( matrix, this );

            _matrixStack.push( matrix );
            _polytopeStack.push( _original );
            _polytopeStack.top().transform( osg::Matrixd::inverse( matrix ), matrix );

            traverse(transform);

            _matrixStack.pop();
            _polytopeStack.pop();
        }
void anonymous_namespace{OverlayDecorator.cpp}::CoarsePolytopeIntersector::apply ( osg::Geode &  node) [inline]

Definition at line 101 of file OverlayDecorator.cpp.

        {
            const osg::BoundingSphere& bs = node.getBound();

            if ( _polytopeStack.top().intersects( bs ) )
            {
                if ( _coarse )
                {
                    _bbox.expandBy(
                        osg::BoundingSphere( bs.center() * _matrixStack.top(), bs.radius() ) );
                }
                else
                {
                    for( unsigned i=0; i < node.getNumDrawables(); ++i )
                    {
                        applyDrawable( node.getDrawable(i) );
                    }
                }
            }
        }
void anonymous_namespace{OverlayDecorator.cpp}::CoarsePolytopeIntersector::applyDrawable ( osg::Drawable *  drawable) [inline]

Definition at line 122 of file OverlayDecorator.cpp.

        {
            const osg::BoundingBox& box = drawable->getBound();

            if ( _polytopeStack.top().intersects( box ) )
            {
                osg::Vec3d bmin = osg::Vec3(box.xMin(), box.yMin(), box.zMin()) * _matrixStack.top();
                osg::Vec3d bmax = osg::Vec3(box.xMax(), box.yMax(), box.zMax()) * _matrixStack.top();
                  
                _bbox.expandBy( osg::BoundingBox(bmin, bmax) );
            }
        }

Member Data Documentation

osg::BoundingBox& anonymous_namespace{OverlayDecorator.cpp}::CoarsePolytopeIntersector::_bbox

Definition at line 150 of file OverlayDecorator.cpp.

bool anonymous_namespace{OverlayDecorator.cpp}::CoarsePolytopeIntersector::_coarse

Definition at line 154 of file OverlayDecorator.cpp.

std::stack<osg::Matrixd> anonymous_namespace{OverlayDecorator.cpp}::CoarsePolytopeIntersector::_matrixStack

Definition at line 153 of file OverlayDecorator.cpp.

MyConvexPolyhedron anonymous_namespace{OverlayDecorator.cpp}::CoarsePolytopeIntersector::_original

Definition at line 151 of file OverlayDecorator.cpp.

std::stack<MyConvexPolyhedron> anonymous_namespace{OverlayDecorator.cpp}::CoarsePolytopeIntersector::_polytopeStack

Definition at line 152 of file OverlayDecorator.cpp.


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