0030520: VIS - IVtkTools_ShapePicker::GetPickPosition() returns incorrect point
[occt.git] / src / SelectBasics / SelectBasics_SelectingVolumeManager.hxx
1 // Created on: 2014-08-21
2 // Created by: Varvara POSKONINA
3 // Copyright (c) 2005-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #ifndef _SelectBasics_SelectingVolumeManager_HeaderFile
17 #define _SelectBasics_SelectingVolumeManager_HeaderFile
18
19 #include <BVH_Box.hxx>
20 #include <gp_Pnt.hxx>
21 #include <TColgp_HArray1OfPnt.hxx>
22 #include <SelectBasics_PickResult.hxx>
23
24 class Bnd_Box;
25 class gp_Pnt;
26
27 //! This class provides an interface for selecting volume manager,
28 //! which is responsible for all overlap detection methods and
29 //! calculation of minimum depth, distance to center of geometry
30 //! and detected closest point on entity.
31 class SelectBasics_SelectingVolumeManager
32 {
33 public:
34
35   //! Available selection types
36   enum SelectionType { Point, Box, Polyline, Unknown };
37
38 public:
39
40   SelectBasics_SelectingVolumeManager() {};
41
42   virtual ~SelectBasics_SelectingVolumeManager() {};
43
44   virtual Standard_Integer GetActiveSelectionType() const = 0;
45
46   //! Returns true if selecting volume is overlapped by box theBox
47   virtual Standard_Boolean Overlaps (const NCollection_Vec3<Standard_Real>& theBoxMin,
48                                      const NCollection_Vec3<Standard_Real>& theBoxMax,
49                                      SelectBasics_PickResult& thePickResult) const = 0;
50
51   //! Returns true if selecting volume is overlapped by axis-aligned bounding box with minimum
52   //! corner at point theMinPt and maximum at point theMaxPt
53   virtual Standard_Boolean Overlaps (const NCollection_Vec3<Standard_Real>& theBoxMin,
54                                      const NCollection_Vec3<Standard_Real>& theBoxMax,
55                                      Standard_Boolean*                      theInside = NULL) const = 0;
56
57   //! Returns true if selecting volume is overlapped by point thePnt
58   virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt,
59                                      SelectBasics_PickResult& thePickResult) const = 0;
60
61   //! Returns true if selecting volume is overlapped by point thePnt.
62   //! Does not perform depth calculation, so this method is defined as
63   //! helper function for inclusion test.
64   virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt) const = 0;
65
66   //! Returns true if selecting volume is overlapped by planar convex polygon, which points
67   //! are stored in theArrayOfPts, taking into account sensitivity type theSensType
68   virtual Standard_Boolean Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPts,
69                                      Standard_Integer theSensType,
70                                      SelectBasics_PickResult& thePickResult) const = 0;
71
72   //! Returns true if selecting volume is overlapped by planar convex polygon, which points
73   //! are stored in theArrayOfPts, taking into account sensitivity type theSensType
74   virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPts,
75                                      Standard_Integer theSensType,
76                                      SelectBasics_PickResult& thePickResult) const = 0;
77
78   //! Returns true if selecting volume is overlapped by line segment with start point at thePt1
79   //! and end point at thePt2
80   virtual Standard_Boolean Overlaps (const gp_Pnt& thePt1,
81                                      const gp_Pnt& thePt2,
82                                      SelectBasics_PickResult& thePickResult) const = 0;
83
84   //! Returns true if selecting volume is overlapped by triangle with vertices thePt1,
85   //! thePt2 and thePt3, taking into account sensitivity type theSensType
86   virtual Standard_Boolean Overlaps (const gp_Pnt& thePt1,
87                                      const gp_Pnt& thePt2,
88                                      const gp_Pnt& thePt3,
89                                      Standard_Integer theSensType,
90                                      SelectBasics_PickResult& thePickResult) const = 0;
91
92   //! Calculates distance from 3d projection of user-defined selection point
93   //! to the given point theCOG
94   virtual Standard_Real DistToGeometryCenter (const gp_Pnt& theCOG) const = 0;
95
96   virtual gp_Pnt DetectedPoint (const Standard_Real theDepth) const = 0;
97
98   virtual Standard_Boolean IsOverlapAllowed() const = 0;
99
100   //! Valid only for point and rectangular selection.
101   //! Returns projection of 2d mouse picked point or projection
102   //! of center of 2d rectangle (for point and rectangular selection
103   //! correspondingly) onto near view frustum plane
104   virtual gp_Pnt GetNearPickedPnt() const = 0;
105
106   //! Valid only for point and rectangular selection.
107   //! Returns projection of 2d mouse picked point or projection
108   //! of center of 2d rectangle (for point and rectangular selection
109   //! correspondingly) onto far view frustum plane
110   virtual gp_Pnt GetFarPickedPnt() const = 0;
111
112   //! Stores plane equation coefficients (in the following form:
113   //! Ax + By + Cz + D = 0) to the given vector
114   virtual void GetPlanes (NCollection_Vector<NCollection_Vec4<Standard_Real> >& thePlaneEquations) const = 0;
115
116 protected:
117   SelectionType myActiveSelectionType;      //!< Active selection type: point, box or polyline
118 };
119
120 #endif // _SelectBasics_SelectingVolumeManager_HeaderFile