PlaneIntersector
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSGUTIL_PLANEINTERSECTOR
#define OSGUTIL_PLANEINTERSECTOR 1
#include <osgUtil/IntersectionVisitor>
#include <osg/CoordinateSystemNode>
namespace osgUtil
{
class OSGUTIL_EXPORT PlaneIntersector : public Intersector
{
public:
PlaneIntersector(const osg::Plane& plane, const osg::Polytope& boundingPolytope=osg::Polytope());
PlaneIntersector(CoordinateFrame cf, const osg::Plane& plane, const osg::Polytope& boundingPolytope=osg::Polytope());
struct Intersection
{
Intersection() {}
bool operator < (const Intersection& rhs) const
{
if (polyline < rhs.polyline) return true;
if (rhs.polyline < polyline) return false;
if (nodePath < rhs.nodePath) return true;
if (rhs.nodePath < nodePath ) return false;
return (drawable < rhs.drawable);
}
typedef std::vector<osg::Vec3d> Polyline;
typedef std::vector<double> Attributes;
osg::NodePath nodePath;
osg::ref_ptr<osg::RefMatrix> matrix;
osg::ref_ptr<osg::Drawable> drawable;
Polyline polyline;
Attributes attributes;
};
typedef std::vector<Intersection> Intersections;
inline void insertIntersection(const Intersection& intersection) { getIntersections().push_back(intersection); }
inline Intersections& getIntersections() { return _parent ? _parent->_intersections : _intersections; }
void setRecordHeightsAsAttributes(bool flag) { _recordHeightsAsAttributes = flag; }
bool getRecordHeightsAsAttributes() const { return _recordHeightsAsAttributes; }
void setEllipsoidModel(osg::EllipsoidModel* em) { _em = em; }
const osg::EllipsoidModel* getEllipsoidModel() const { return _em.get(); }
public:
virtual Intersector* clone(osgUtil::IntersectionVisitor& iv);
virtual bool enter(const osg::Node& node);
virtual void leave();
virtual void intersect(osgUtil::IntersectionVisitor& iv, osg::Drawable* drawable);
virtual void reset();
virtual bool containsIntersections() { return !getIntersections().empty(); }
protected:
PlaneIntersector* _parent;
bool _recordHeightsAsAttributes;
osg::ref_ptr<osg::EllipsoidModel> _em;
osg::Plane _plane;
osg::Polytope _polytope;
Intersections _intersections;
};
}
#endif
CoordinateSystemNode
IntersectionVisitor
osgUtil::IntersectionVisitor
Definition IntersectionVisitor:152
osgUtil::Intersector::CoordinateFrame
CoordinateFrame
Definition IntersectionVisitor:38
osgUtil::Intersector::Intersector
Intersector(CoordinateFrame cf=MODEL, IntersectionLimit il=NO_LIMIT)
Definition IntersectionVisitor:53
osgUtil::PlaneIntersector::Intersections
std::vector< Intersection > Intersections
Definition PlaneIntersector:62
osgUtil::PlaneIntersector::PlaneIntersector
PlaneIntersector(const osg::Plane &plane, const osg::Polytope &boundingPolytope=osg::Polytope())
osgUtil::PlaneIntersector::getRecordHeightsAsAttributes
bool getRecordHeightsAsAttributes() const
Definition PlaneIntersector:71
osgUtil::PlaneIntersector::containsIntersections
virtual bool containsIntersections()
Definition PlaneIntersector:89
osgUtil::PlaneIntersector::getEllipsoidModel
const osg::EllipsoidModel * getEllipsoidModel() const
Definition PlaneIntersector:75
osgUtil::PlaneIntersector::_recordHeightsAsAttributes
bool _recordHeightsAsAttributes
Definition PlaneIntersector:95
osgUtil::PlaneIntersector::leave
virtual void leave()
osgUtil::PlaneIntersector::insertIntersection
void insertIntersection(const Intersection &intersection)
Definition PlaneIntersector:64
osgUtil::PlaneIntersector::_plane
osg::Plane _plane
Definition PlaneIntersector:98
osgUtil::PlaneIntersector::intersect
virtual void intersect(osgUtil::IntersectionVisitor &iv, osg::Drawable *drawable)
osgUtil::PlaneIntersector::PlaneIntersector
PlaneIntersector(CoordinateFrame cf, const osg::Plane &plane, const osg::Polytope &boundingPolytope=osg::Polytope())
osgUtil::PlaneIntersector::_em
osg::ref_ptr< osg::EllipsoidModel > _em
Definition PlaneIntersector:96
osgUtil::PlaneIntersector::clone
virtual Intersector * clone(osgUtil::IntersectionVisitor &iv)
osgUtil::PlaneIntersector::getIntersections
Intersections & getIntersections()
Definition PlaneIntersector:66
osgUtil::PlaneIntersector::enter
virtual bool enter(const osg::Node &node)
osgUtil::PlaneIntersector::_parent
PlaneIntersector * _parent
Definition PlaneIntersector:93
osgUtil::PlaneIntersector::reset
virtual void reset()
osgUtil::PlaneIntersector::_intersections
Intersections _intersections
Definition PlaneIntersector:101
osgUtil::PlaneIntersector::setRecordHeightsAsAttributes
void setRecordHeightsAsAttributes(bool flag)
Definition PlaneIntersector:69
osgUtil::PlaneIntersector::_polytope
osg::Polytope _polytope
Definition PlaneIntersector:99
osgUtil::PlaneIntersector::setEllipsoidModel
void setEllipsoidModel(osg::EllipsoidModel *em)
Definition PlaneIntersector:73
osg::Drawable
Definition Drawable:89
osg::EllipsoidModel
Definition CoordinateSystemNode:31
osg::Node
Definition Node:72
osg::Plane
A plane class. It can be used to represent an infinite plane.
Definition Plane:34
osg::Polytope
Definition Polytope:26
osg::ref_ptr
Definition ref_ptr:32
osgUtil
Definition NodeVisitor:25
osg::NodePath
std::vector< Node * > NodePath
Definition Node:47
OSGUTIL_EXPORT
#define OSGUTIL_EXPORT
Definition osgUtil/Export:40
osgUtil::PlaneIntersector::Intersection
Definition PlaneIntersector:37
osgUtil::PlaneIntersector::Intersection::Intersection
Intersection()
Definition PlaneIntersector:38
osgUtil::PlaneIntersector::Intersection::nodePath
osg::NodePath nodePath
Definition PlaneIntersector:54
osgUtil::PlaneIntersector::Intersection::Polyline
std::vector< osg::Vec3d > Polyline
Definition PlaneIntersector:51
osgUtil::PlaneIntersector::Intersection::polyline
Polyline polyline
Definition PlaneIntersector:57
osgUtil::PlaneIntersector::Intersection::Attributes
std::vector< double > Attributes
Definition PlaneIntersector:52
osgUtil::PlaneIntersector::Intersection::attributes
Attributes attributes
Definition PlaneIntersector:58
osgUtil::PlaneIntersector::Intersection::matrix
osg::ref_ptr< osg::RefMatrix > matrix
Definition PlaneIntersector:55
osgUtil::PlaneIntersector::Intersection::drawable
osg::ref_ptr< osg::Drawable > drawable
Definition PlaneIntersector:56