0032337: Visualization - rename Overlaps() method in selection to more self-describab...
[occt.git] / src / SelectMgr / SelectMgr_BaseFrustum.hxx
1 // Created on: 2014-05-22
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 _SelectMgr_BaseFrustum_HeaderFile
17 #define _SelectMgr_BaseFrustum_HeaderFile
18
19 #include <SelectMgr_BaseIntersector.hxx>
20
21 //! This class is an interface for different types of selecting frustums,
22 //! defining different selection types, like point, box or polyline
23 //! selection. It contains signatures of functions for detection of
24 //! overlap by sensitive entity and initializes some data for building
25 //! the selecting frustum
26 class SelectMgr_BaseFrustum : public SelectMgr_BaseIntersector
27 {
28 public:
29
30   //! Creates new selecting volume with pixel toletance set to 2,
31   //! orthographic camera and empty frustum builder
32   Standard_EXPORT SelectMgr_BaseFrustum();
33
34   //! Destructor
35   virtual ~SelectMgr_BaseFrustum() {}
36
37   //! Nullifies the builder created in the constructor and copies the pointer given
38   Standard_EXPORT void SetBuilder (const Handle(SelectMgr_FrustumBuilder)& theBuilder);
39
40   //! Return camera definition.
41   virtual const Handle(Graphic3d_Camera)& Camera() const Standard_OVERRIDE { return myCamera; }
42
43   //! Passes camera projection and orientation matrices to builder
44   Standard_EXPORT virtual void SetCamera (const Handle(Graphic3d_Camera)& theCamera) Standard_OVERRIDE;
45
46   //! Passes camera projection and orientation matrices to builder
47   Standard_EXPORT virtual void SetCamera (const Graphic3d_Mat4d& theProjection,
48                                           const Graphic3d_Mat4d& theWorldView,
49                                           const Standard_Boolean theIsOrthographic,
50                                           const Graphic3d_WorldViewProjState& theWVPState = Graphic3d_WorldViewProjState()) Standard_OVERRIDE;
51
52   //! @return current camera projection transformation common for all selecting volumes
53   Standard_EXPORT virtual const Graphic3d_Mat4d& ProjectionMatrix() const Standard_OVERRIDE;
54
55   //! @return current camera world view transformation common for all selecting volumes
56   Standard_EXPORT virtual const Graphic3d_Mat4d& WorldViewMatrix() const Standard_OVERRIDE;
57
58   //! @return current camera world view projection transformation state
59   Standard_EXPORT virtual const Graphic3d_WorldViewProjState& WorldViewProjState() const Standard_OVERRIDE;
60
61   Standard_EXPORT virtual void SetPixelTolerance (const Standard_Integer theTol) Standard_OVERRIDE;
62
63   Standard_EXPORT virtual void SetWindowSize (const Standard_Integer theWidth,
64                                               const Standard_Integer theHeight) Standard_OVERRIDE;
65
66   Standard_EXPORT virtual void WindowSize (Standard_Integer& theWidth,
67                                            Standard_Integer& theHeight) const Standard_OVERRIDE;
68
69   //! Passes viewport parameters to builder
70   Standard_EXPORT virtual void SetViewport (const Standard_Real theX,
71                                             const Standard_Real theY,
72                                             const Standard_Real theWidth,
73                                             const Standard_Real theHeight) Standard_OVERRIDE;
74
75
76
77   //! SAT intersection test between defined volume and given axis-aligned box
78   Standard_EXPORT virtual Standard_Boolean OverlapsBox (const SelectMgr_Vec3& theBoxMin,
79                                                         const SelectMgr_Vec3& theBoxMax,
80                                                         const SelectMgr_ViewClipRange& theClipRange,
81                                                         SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
82
83   //! Returns true if selecting volume is overlapped by axis-aligned bounding box
84   //! with minimum corner at point theMinPt and maximum at point theMaxPt
85   Standard_EXPORT virtual Standard_Boolean OverlapsBox (const SelectMgr_Vec3& theBoxMin,
86                                                         const SelectMgr_Vec3& theBoxMax,
87                                                         Standard_Boolean*     theInside = NULL) const Standard_OVERRIDE;
88
89   //! Intersection test between defined volume and given point
90   Standard_EXPORT virtual Standard_Boolean OverlapsPoint (const gp_Pnt& thePnt,
91                                                           const SelectMgr_ViewClipRange& theClipRange,
92                                                           SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
93
94   //! Intersection test between defined volume and given point
95   //! Does not perform depth calculation, so this method is defined as
96   //! helper function for inclusion test. Therefore, its implementation
97   //! makes sense only for rectangular frustum with box selection mode activated.
98   Standard_EXPORT virtual Standard_Boolean OverlapsPoint (const gp_Pnt& thePnt) const Standard_OVERRIDE;
99
100   //! SAT intersection test between defined volume and given ordered set of points,
101   //! representing line segments. The test may be considered of interior part or
102   //! boundary line defined by segments depending on given sensitivity type
103   Standard_EXPORT virtual Standard_Boolean OverlapsPolygon (const TColgp_Array1OfPnt& theArrayOfPnts,
104                                                             Select3D_TypeOfSensitivity theSensType,
105                                                             const SelectMgr_ViewClipRange& theClipRange,
106                                                             SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
107
108   //! Checks if line segment overlaps selecting frustum
109   Standard_EXPORT virtual Standard_Boolean OverlapsSegment (const gp_Pnt& thePnt1,
110                                                             const gp_Pnt& thePnt2,
111                                                             const SelectMgr_ViewClipRange& theClipRange,
112                                                             SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
113
114   //! SAT intersection test between defined volume and given triangle. The test may
115   //! be considered of interior part or boundary line defined by triangle vertices
116   //! depending on given sensitivity type
117   Standard_EXPORT virtual Standard_Boolean OverlapsTriangle (const gp_Pnt& thePt1,
118                                                              const gp_Pnt& thePt2,
119                                                              const gp_Pnt& thePt3,
120                                                              Select3D_TypeOfSensitivity theSensType,
121                                                              const SelectMgr_ViewClipRange& theClipRange,
122                                                              SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
123
124   //! Dumps the content of me into the stream
125   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
126
127   DEFINE_STANDARD_RTTIEXT(SelectMgr_BaseFrustum, SelectMgr_BaseIntersector)
128
129 protected:
130   Standard_Integer    myPixelTolerance;      //!< Pixel tolerance
131   Standard_Boolean    myIsOrthographic;      //!< Defines if current camera is orthographic
132
133   Handle(SelectMgr_FrustumBuilder) myBuilder; //!< A tool implementing methods for volume build
134   Handle(Graphic3d_Camera)         myCamera;  //!< camera definition
135 };
136
137 #endif // _SelectMgr_BaseFrustum_HeaderFile