#ifndef OSGUTIL_INTERSECTVISITOR #define OSGUTIL_INTERSECTVISITOR 1 #include #include #include #include #include #include #include #include #include namespace osgUtil { class OSGUTIL_EXPORT IntersectState : public osg::Referenced { public: IntersectState(); osg::Matrix* _matrix; osg::Matrix* _inverse; typedef std::vector< std::pair > LineSegmentList; LineSegmentList _segList; typedef unsigned int LineSegmentmentMask; typedef std::vector LineSegmentmentMaskStack; LineSegmentmentMaskStack _segmentMaskStack; bool isCulled(const osg::BoundingSphere& bs,LineSegmentmentMask& segMaskOut); bool isCulled(const osg::BoundingBox& bb,LineSegmentmentMask& segMaskOut); protected: ~IntersectState(); }; class OSGUTIL_EXPORT Hit : public osg::Referenced { public: Hit(); Hit(const Hit& hit); ~Hit(); Hit& operator = (const Hit& hit); typedef std::vector VecIndexList; bool operator < (const Hit& hit) const { if (_originalLineSegmenthit._originalLineSegment) return false; return _ratio HitList; typedef std::vector HitList; typedef std::map LineSegmentHitListMap; HitList& getHitList(osg::LineSegment* seg) { return _segHitList[seg]; } int getNumHits(osg::LineSegment* seg) { return _segHitList[seg].size(); } bool hits(); virtual void apply(osg::Node&); virtual void apply(osg::Geode& node); virtual void apply(osg::Billboard& node); virtual void apply(osg::Group& node); virtual void apply(osg::Transform& node); virtual void apply(osg::Switch& node); virtual void apply(osg::LOD& node); protected: bool intersect(osg::GeoSet& gset); void pushMatrix(const osg::Matrix& matrix); void popMatrix(); bool enterNode(osg::Node& node); void leaveNode(); typedef std::vector > IntersectStateStack; IntersectStateStack _intersectStateStack; osg::NodePath _nodePath; HitReportingMode _hitReportingMode; LineSegmentHitListMap _segHitList; }; }; #endif