f751596e |
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_SelectingVolumeManager_HeaderFile |
17 | #define _SelectMgr_SelectingVolumeManager_HeaderFile |
18 | |
19 | #include <NCollection_Handle.hxx> |
20 | |
21 | #include <Graphic3d_Camera.hxx> |
22 | #include <Graphic3d_SequenceOfHClipPlane.hxx> |
23 | |
24 | #include <SelectMgr_BaseFrustum.hxx> |
25 | #include <SelectMgr_RectangularFrustum.hxx> |
26 | #include <SelectMgr_TriangularFrustumSet.hxx> |
27 | #include <SelectBasics_SelectingVolumeManager.hxx> |
28 | |
29 | //! This class is used to switch between active selecting volumes depending |
30 | //! on selection type chosen by the user |
31 | class SelectMgr_SelectingVolumeManager : public SelectBasics_SelectingVolumeManager |
32 | { |
33 | public: |
34 | |
35 | //! Creates instances of all available selecting volume types |
36 | Standard_EXPORT SelectMgr_SelectingVolumeManager (Standard_Boolean theToAllocateFrustums = Standard_True); |
37 | |
38 | Standard_EXPORT virtual ~SelectMgr_SelectingVolumeManager() {}; |
39 | |
40 | //! Returns a copy of active frustum transformed according to the matrix given |
41 | Standard_EXPORT virtual SelectMgr_SelectingVolumeManager Transform (const gp_Trsf& theTrsf); |
42 | |
43 | Standard_EXPORT virtual const Standard_Integer GetActiveSelectionType() const Standard_OVERRIDE; |
44 | |
45 | Standard_EXPORT void SetActiveSelectionType (const SelectionType& theType); |
46 | |
47 | //! Updates camera projection and orientation matrices in all selecting volumes |
48 | Standard_EXPORT void SetCamera (const Handle(Graphic3d_Camera) theCamera); |
49 | |
50 | //! Updates camera projection and orientation matrices in all selecting volumes |
51 | Standard_EXPORT void SetCamera (const Graphic3d_Mat4d& theProjection, |
52 | const Graphic3d_Mat4d& theOrientation, |
53 | const Standard_Boolean theIsOrthographic); |
54 | |
55 | //! Updates viewport in all selecting volumes |
56 | Standard_EXPORT void SetViewport (const Standard_Real theX, |
57 | const Standard_Real theY, |
58 | const Standard_Real theWidth, |
59 | const Standard_Real theHeight); |
60 | |
61 | //! Updates pixel tolerance in all selecting volumes |
62 | Standard_EXPORT void SetPixelTolerance (const Standard_Real theTolerance); |
63 | |
64 | //! Updates window size in all selecting volumes |
65 | Standard_EXPORT void SetWindowSize (const Standard_Integer theWidth, const Standard_Integer theHeight); |
66 | |
67 | |
68 | //! Builds rectangular selecting frustum for point selection |
69 | Standard_EXPORT void BuildSelectingVolume (const gp_Pnt2d& thePoint); |
70 | |
71 | //! Builds rectangular selecting frustum for box selection |
72 | Standard_EXPORT void BuildSelectingVolume (const gp_Pnt2d& theMinPt, |
73 | const gp_Pnt2d& theMaxPt); |
74 | |
75 | //! Builds set of triangular selecting frustums for polyline selection |
76 | Standard_EXPORT void BuildSelectingVolume (const TColgp_Array1OfPnt2d& thePoints); |
77 | |
78 | |
79 | //! SAT intersection test between defined volume and given axis-aligned box |
80 | Standard_EXPORT virtual const Standard_Boolean Overlaps (const BVH_Box<Standard_Real, 3>& theBndBox, |
81 | Standard_Real& theDepth) 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 const Standard_Boolean Overlaps (const SelectMgr_Vec3& theMinPt, |
86 | const SelectMgr_Vec3& theMaxPt) Standard_OVERRIDE; |
87 | |
88 | //! Intersection test between defined volume and given point |
89 | Standard_EXPORT virtual const Standard_Boolean Overlaps (const gp_Pnt& thePt, |
90 | Standard_Real& theDepth) Standard_OVERRIDE; |
91 | |
92 | //! SAT intersection test between defined volume and given ordered set of points, |
93 | //! representing line segments. The test may be considered of interior part or |
94 | //! boundary line defined by segments depending on given sensitivity type |
95 | Standard_EXPORT virtual const Standard_Boolean Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPts, |
96 | Standard_Integer theSensType, |
97 | Standard_Real& theDepth) Standard_OVERRIDE; |
98 | |
99 | //! Checks if line segment overlaps selecting frustum |
100 | Standard_EXPORT virtual const Standard_Boolean Overlaps (const gp_Pnt& thePt1, |
101 | const gp_Pnt& thePt2, |
102 | Standard_Real& theDepth) Standard_OVERRIDE; |
103 | |
104 | //! SAT intersection test between defined volume and given triangle. The test may |
105 | //! be considered of interior part or boundary line defined by triangle vertices |
106 | //! depending on given sensitivity type |
107 | Standard_EXPORT virtual const Standard_Boolean Overlaps (const gp_Pnt& thePt1, |
108 | const gp_Pnt& thePt2, |
109 | const gp_Pnt& thePt3, |
110 | Standard_Integer theSensType, |
111 | Standard_Real& theDepth) Standard_OVERRIDE; |
112 | |
113 | |
114 | //! Measures distance between 3d projection of user-picked |
115 | //! screen point and given point theCOG |
116 | Standard_EXPORT virtual const Standard_Real DistToGeometryCenter (const gp_Pnt& theCOG) Standard_OVERRIDE; |
117 | |
118 | //! Calculates the point on a view ray that was detected during the run of selection algo by given depth. Is valid for point |
119 | //! selection only |
120 | Standard_EXPORT virtual NCollection_Vec3<Standard_Real> DetectedPoint (const Standard_Real theDepth) const Standard_OVERRIDE; |
121 | |
122 | //! Checks if the point of sensitive in which selection was detected belongs |
123 | //! to the region defined by clipping planes |
124 | Standard_EXPORT virtual const Standard_Boolean IsClipped (const Graphic3d_SequenceOfHClipPlane& thePlanes, |
125 | const Standard_Real& theDepth); |
126 | |
127 | private: |
128 | enum { Frustum, FrustumSet, VolumeTypesNb }; //!< Defines the amount of available selecting volumes |
129 | |
130 | NCollection_Handle<SelectMgr_BaseFrustum> mySelectingVolumes[VolumeTypesNb]; //!< Array of selecting volumes |
131 | }; |
132 | |
133 | #endif |