OpenCOVER
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
coIntersection.h
Go to the documentation of this file.
1 /* This file is part of COVISE.
2 
3  You can use it under the terms of the GNU Lesser General Public License
4  version 2.1 or later, see lgpl-2.1.txt.
5 
6  * License: LGPL 2+ */
7 
8 #ifndef CO_INTERSECTION_H
9 #define CO_INTERSECTION_H
10 
25 #include <osg/Matrix>
26 #include <osgUtil/LineSegmentIntersector>
27 
28 namespace osgUtil {
29 class IntersectionVisitor;
30 }
31 
32 namespace opencover
33 {
34 
35 class coIntersector;
36 
37 class COVEREXPORT IntersectionHandler: public osg::Referenced
38 {
39 public:
40  virtual ~IntersectionHandler() {}
41 
42  virtual bool canHandleDrawable(osg::Drawable *drawable) const = 0;
43  virtual void intersect(osgUtil::IntersectionVisitor &iv, coIntersector &is, osg::Drawable *drawable) = 0;
44 };
45 
46 class COVEREXPORT coIntersector: public osgUtil::LineSegmentIntersector
47 {
48 public:
49  coIntersector(const osg::Vec3& start, const osg::Vec3& end);
50 
51  virtual Intersector* clone(osgUtil::IntersectionVisitor& iv) override;
52  virtual void intersect(osgUtil::IntersectionVisitor& iv, osg::Drawable* drawable) override;
53 
54  void addHandler(osg::ref_ptr<IntersectionHandler> handler);
55 
56  bool intersectAndClip(osg::Vec3d &s, osg::Vec3d &e, const osg::BoundingBox &bb);
57 
58 protected:
59  std::vector<osg::ref_ptr<IntersectionHandler>> _handlers;
60 };
61 
62 class COVEREXPORT coIntersection : public virtual vrui::vruiIntersection
63 {
64  static coIntersection *intersector;
66 public:
67  static coIntersection *instance();
68  virtual ~coIntersection();
69 
70  coIntersector *newIntersector(const osg::Vec3 &start, const osg::Vec3 &end);
71 
72  void addHandler(osg::ref_ptr<IntersectionHandler> handler);
73 
74  virtual const char *getClassName() const;
75  virtual const char *getActionName() const;
76 
77  void isectAllNodes(bool isectAll);
78  void forceIsectAllNodes(bool isectAll);
80 
81  static bool isVerboseIntersection();
82 
83 protected:
84  virtual void intersect(); // do the intersection
85  // do the intersection
86  void intersect(const osg::Matrix &mat, bool mouseHit);
87 
90 
91  static int myFrameIndex;
92  static int myFrame;
93 
94 private:
95  std::vector<std::vector<float> > elapsedTimes;
96  std::vector<osg::ref_ptr<IntersectionHandler>> handlers;
97 };
98 }
99 #endif
static int myFrame
Definition: coIntersection.h:92
Definition: coIntersection.h:37
Definition: coIntersection.h:46
virtual ~IntersectionHandler()
Definition: coIntersection.h:40
int numIsectAllNodes
Definition: coIntersection.h:79
Definition: coIntersection.h:62
static int myFrameIndex
Definition: coIntersection.h:91
float intersectionDist
value of the PointerAppearance.Intersection config var
Definition: coIntersection.h:89
std::vector< osg::ref_ptr< IntersectionHandler > > _handlers
Definition: coIntersection.h:59
Definition: vruiIntersection.h:23