1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
14#ifndef OSG_COMPUTEBOUNDSVISITOR
15#define OSG_COMPUTEBOUNDSVISITOR 1
17#include <osg/NodeVisitor>
18#include <osg/BoundingBox>
19#include <osg/Polytope>
23class OSG_EXPORT ComputeBoundsVisitor : public osg::NodeVisitor
27 ComputeBoundsVisitor(TraversalMode traversalMode = TRAVERSE_ALL_CHILDREN);
29 META_NodeVisitor(osg, ComputeBoundsVisitor)
33 osg::BoundingBox& getBoundingBox() { return _bb; }
35 void getPolytope(osg::Polytope& polytope, float margin=0.1) const;
37 void getBase(osg::Polytope& polytope, float margin=0.1) const;
39 void apply(osg::Drawable& drawable);
41 void apply(osg::Transform& transform);
43 inline void pushMatrix(osg::Matrix& matrix) { _matrixStack.push_back(matrix); }
45 inline void popMatrix() { _matrixStack.pop_back(); }
48 void applyBoundingBox(const osg::BoundingBox&);
50 typedef std::vector<osg::Matrix> MatrixStack;
52 const MatrixStack& getMatrixStack() const { return _matrixStack; }
55 MatrixStack _matrixStack;