1 #ifndef COIN_SORAYPICKACTION_H
2 #define COIN_SORAYPICKACTION_H
3 
4 /**************************************************************************\
5  * Copyright (c) Kongsberg Oil & Gas Technologies AS
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are
10  * met:
11  *
12  * Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the distribution.
18  *
19  * Neither the name of the copyright holder nor the names of its
20  * contributors may be used to endorse or promote products derived from
21  * this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 \**************************************************************************/
35 
36 #include <Inventor/actions/SoPickAction.h>
37 
38 class SbBox3f;
39 class SbLine;
40 class SbMatrix;
41 class SbVec2f;
42 class SbVec2s;
43 class SbVec3f;
44 class SbViewVolume;
45 class SbViewportRegion;
46 class SoPickedPoint;
47 class SoPickedPointList;
48 class SoRayPickActionP;
49 
50 class COIN_DLL_API SoRayPickAction : public SoPickAction {
51   typedef SoPickAction inherited;
52 
53   SO_ACTION_HEADER(SoRayPickAction);
54 
55 public:
56   SoRayPickAction(const SbViewportRegion & viewportregion);
57   virtual ~SoRayPickAction();
58   static void initClass(void);
59 
60   void setPoint(const SbVec2s & viewportPoint);
61   void setNormalizedPoint(const SbVec2f & normpoint);
62   void setRadius(const float radiusinpixels);
63   float getRadius(void) const;
64   void setRay(const SbVec3f & start, const SbVec3f & direction,
65               float neardistance = -1.0,
66               float fardistance = -1.0);
67   void setPickAll(const SbBool flag);
68   SbBool isPickAll(void) const;
69   const SoPickedPointList & getPickedPointList(void) const;
70   SoPickedPoint * getPickedPoint(const int index = 0) const;
71 
72 
73   void computeWorldSpaceRay(void);
74   SbBool hasWorldSpaceRay(void) const;
75   void setObjectSpace(void);
76   void setObjectSpace(const SbMatrix & matrix);
77   SbBool intersect(const SbVec3f & v0, const SbVec3f & v1, const SbVec3f & v2,
78                    SbVec3f & intersection, SbVec3f & barycentric,
79                    SbBool & front) const;
80   SbBool intersect(const SbVec3f & v0, const SbVec3f & v1,
81                    SbVec3f & intersection) const;
82   SbBool intersect(const SbVec3f & point) const;
83   SbBool intersect(const SbBox3f & box, const SbBool usefullviewvolume = TRUE);
84   SbBool intersect(const SbBox3f & box, SbVec3f & intersection,
85                    const SbBool usefullviewvolume = TRUE);
86   const SbViewVolume & getViewVolume(void);
87   const SbLine & getLine(void);
88   SbBool isBetweenPlanes(const SbVec3f & intersection) const;
89   SoPickedPoint * addIntersection(const SbVec3f & objectspacepoint, SbBool frontpick = TRUE);
90 
91   void reset(void);
92 
93 protected:
94   virtual void beginTraversal(SoNode * node);
95 
96 private:
97   SbPimplPtr<SoRayPickActionP> pimpl;
98 
99   // NOT IMPLEMENTED:
100   SoRayPickAction(const SoRayPickAction & rhs);
101   SoRayPickAction & operator = (const SoRayPickAction & rhs);
102 }; // SoRayPickAction
103 
104 #endif // !COIN_SORAYPICKACTION_H
105