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 #include <SelectMgr_SelectionType.hxx> 24 #include <Standard_Dump.hxx> 25 26 class Bnd_Box; 27 class gp_Pnt; 28 29 //! This class provides an interface for selecting volume manager, 30 //! which is responsible for all overlap detection methods and 31 //! calculation of minimum depth, distance to center of geometry 32 //! and detected closest point on entity. 33 class SelectBasics_SelectingVolumeManager 34 { 35 public: 36 37 //! Empty constructor. 38 SelectBasics_SelectingVolumeManager(); 39 40 //! Destructor. 41 Standard_EXPORT virtual ~SelectBasics_SelectingVolumeManager(); 42 43 //! Return selection type. 44 virtual Standard_Integer GetActiveSelectionType() const = 0; 45 46 public: 47 48 //! Returns true if selecting volume is overlapped by box theBox 49 virtual Standard_Boolean OverlapsBox (const NCollection_Vec3<Standard_Real>& theBoxMin, 50 const NCollection_Vec3<Standard_Real>& theBoxMax, 51 SelectBasics_PickResult& thePickResult) const = 0; 52 53 //! Returns true if selecting volume is overlapped by axis-aligned bounding box with minimum 54 //! corner at point theMinPt and maximum at point theMaxPt 55 virtual Standard_Boolean OverlapsBox (const NCollection_Vec3<Standard_Real>& theBoxMin, 56 const NCollection_Vec3<Standard_Real>& theBoxMax, 57 Standard_Boolean* theInside = NULL) const = 0; 58 59 //! Returns true if selecting volume is overlapped by point thePnt 60 virtual Standard_Boolean OverlapsPoint (const gp_Pnt& thePnt, 61 SelectBasics_PickResult& thePickResult) const = 0; 62 63 //! Returns true if selecting volume is overlapped by point thePnt. 64 //! Does not perform depth calculation, so this method is defined as 65 //! helper function for inclusion test. 66 virtual Standard_Boolean OverlapsPoint (const gp_Pnt& thePnt) const = 0; 67 68 //! Returns true if selecting volume is overlapped by planar convex polygon, which points 69 //! are stored in theArrayOfPts, taking into account sensitivity type theSensType 70 virtual Standard_Boolean OverlapsPolygon (const TColgp_Array1OfPnt& theArrayOfPts, 71 Standard_Integer theSensType, 72 SelectBasics_PickResult& thePickResult) const = 0; 73 74 //! Returns true if selecting volume is overlapped by line segment with start point at thePt1 75 //! and end point at thePt2 76 virtual Standard_Boolean OverlapsSegment (const gp_Pnt& thePt1, 77 const gp_Pnt& thePt2, 78 SelectBasics_PickResult& thePickResult) const = 0; 79 80 //! Returns true if selecting volume is overlapped by triangle with vertices thePt1, 81 //! thePt2 and thePt3, taking into account sensitivity type theSensType 82 virtual Standard_Boolean OverlapsTriangle (const gp_Pnt& thePt1, 83 const gp_Pnt& thePt2, 84 const gp_Pnt& thePt3, 85 Standard_Integer theSensType, 86 SelectBasics_PickResult& thePickResult) const = 0; 87 88 //! Returns true if selecting volume is overlapped by sphere with center theCenter 89 //! and radius theRadius 90 virtual Standard_Boolean OverlapsSphere (const gp_Pnt& theCenter, 91 const Standard_Real theRadius, 92 SelectBasics_PickResult& thePickResult) const = 0; 93 94 //! Returns true if selecting volume is overlapped by sphere with center theCenter 95 //! and radius theRadius 96 virtual Standard_Boolean OverlapsSphere (const gp_Pnt& theCenter, 97 const Standard_Real theRadius, 98 Standard_Boolean* theInside = NULL) const = 0; 99 100 //! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses theBottomRad 101 //! and theTopRad, height theHeight and transformation to apply theTrsf. 102 virtual Standard_Boolean OverlapsCylinder (const Standard_Real theBottomRad, 103 const Standard_Real theTopRad, 104 const Standard_Real theHeight, 105 const gp_Trsf& theTrsf, 106 SelectBasics_PickResult& thePickResult) const = 0; 107 108 //! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses theBottomRad 109 //! and theTopRad, height theHeight and transformation to apply theTrsf. 110 virtual Standard_Boolean OverlapsCylinder (const Standard_Real theBottomRad, 111 const Standard_Real theTopRad, 112 const Standard_Real theHeight, 113 const gp_Trsf& theTrsf, 114 Standard_Boolean* theInside = NULL) const = 0; 115 116 public: 117 118 //! Calculates distance from 3d projection of user-defined selection point 119 //! to the given point theCOG 120 virtual Standard_Real DistToGeometryCenter (const gp_Pnt& theCOG) const = 0; 121 122 //! Return 3D point corresponding to specified depth within picking ray. 123 virtual gp_Pnt DetectedPoint (const Standard_Real theDepth) const = 0; 124 125 //! Returns flag indicating if partial overlapping of entities is allowed or should be rejected. 126 virtual Standard_Boolean IsOverlapAllowed() const = 0; 127 128 //! Valid only for point and rectangular selection. 129 //! Returns projection of 2d mouse picked point or projection 130 //! of center of 2d rectangle (for point and rectangular selection 131 //! correspondingly) onto near view frustum plane 132 virtual gp_Pnt GetNearPickedPnt() const = 0; 133 134 //! Valid only for point and rectangular selection. 135 //! Returns projection of 2d mouse picked point or projection 136 //! of center of 2d rectangle (for point and rectangular selection 137 //! correspondingly) onto far view frustum plane 138 virtual gp_Pnt GetFarPickedPnt() const = 0; 139 140 //! Valid only for point and rectangular selection. 141 //! Returns view ray direction 142 virtual gp_Dir GetViewRayDirection() const = 0; 143 144 //! Checks if it is possible to scale current active selecting volume 145 virtual Standard_Boolean IsScalableActiveVolume() const = 0; 146 147 //! Returns mouse coordinates for Point selection mode. 148 //! @return infinite point in case of unsupport of mouse position for this active selection volume. 149 virtual gp_Pnt2d GetMousePosition() const = 0; 150 151 //! Stores plane equation coefficients (in the following form: 152 //! Ax + By + Cz + D = 0) to the given vector 153 virtual void GetPlanes (NCollection_Vector<NCollection_Vec4<Standard_Real> >& thePlaneEquations) const = 0; 154 155 //! Dumps the content of me into the stream DumpJson(Standard_OStream & theOStream,Standard_Integer theDepth=-1) const156 virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const 157 { 158 (void )theOStream; 159 (void )theDepth; 160 } 161 162 public: 163 164 Standard_DEPRECATED ("Deprecated alias for OverlapsBox()") Overlaps(const NCollection_Vec3<Standard_Real> & theBoxMin,const NCollection_Vec3<Standard_Real> & theBoxMax,SelectBasics_PickResult & thePickResult) const165 Standard_Boolean Overlaps (const NCollection_Vec3<Standard_Real>& theBoxMin, 166 const NCollection_Vec3<Standard_Real>& theBoxMax, 167 SelectBasics_PickResult& thePickResult) const 168 { 169 return OverlapsBox (theBoxMin, theBoxMax, thePickResult); 170 } 171 172 Standard_DEPRECATED ("Deprecated alias for OverlapsBox()") Overlaps(const NCollection_Vec3<Standard_Real> & theBoxMin,const NCollection_Vec3<Standard_Real> & theBoxMax,Standard_Boolean * theInside=NULL) const173 Standard_Boolean Overlaps (const NCollection_Vec3<Standard_Real>& theBoxMin, 174 const NCollection_Vec3<Standard_Real>& theBoxMax, 175 Standard_Boolean* theInside = NULL) const 176 { 177 return OverlapsBox (theBoxMin, theBoxMax, theInside); 178 } 179 180 Standard_DEPRECATED ("Deprecated alias for OverlapsPoint()") Overlaps(const gp_Pnt & thePnt,SelectBasics_PickResult & thePickResult) const181 Standard_Boolean Overlaps (const gp_Pnt& thePnt, 182 SelectBasics_PickResult& thePickResult) const 183 { 184 return OverlapsPoint (thePnt, thePickResult); 185 } 186 187 Standard_DEPRECATED ("Deprecated alias for OverlapsPoint()") Overlaps(const gp_Pnt & thePnt) const188 Standard_Boolean Overlaps (const gp_Pnt& thePnt) const 189 { 190 return OverlapsPoint (thePnt); 191 } 192 193 Standard_DEPRECATED ("Deprecated alias for OverlapsPolygon()") 194 Standard_EXPORT Standard_Boolean Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPts, 195 Standard_Integer theSensType, 196 SelectBasics_PickResult& thePickResult) const; 197 198 Standard_DEPRECATED ("Deprecated alias for OverlapsPolygon()") Overlaps(const TColgp_Array1OfPnt & theArrayOfPts,Standard_Integer theSensType,SelectBasics_PickResult & thePickResult) const199 Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPts, 200 Standard_Integer theSensType, 201 SelectBasics_PickResult& thePickResult) const 202 { 203 return OverlapsPolygon (theArrayOfPts, theSensType, thePickResult); 204 } 205 206 Standard_DEPRECATED ("Deprecated alias for OverlapsSegment()") Overlaps(const gp_Pnt & thePnt1,const gp_Pnt & thePnt2,SelectBasics_PickResult & thePickResult) const207 Standard_Boolean Overlaps (const gp_Pnt& thePnt1, 208 const gp_Pnt& thePnt2, 209 SelectBasics_PickResult& thePickResult) const 210 { 211 return OverlapsSegment (thePnt1, thePnt2, thePickResult); 212 } 213 214 Standard_DEPRECATED ("Deprecated alias for OverlapsTriangle()") Overlaps(const gp_Pnt & thePnt1,const gp_Pnt & thePnt2,const gp_Pnt & thePnt3,Standard_Integer theSensType,SelectBasics_PickResult & thePickResult) const215 Standard_Boolean Overlaps (const gp_Pnt& thePnt1, 216 const gp_Pnt& thePnt2, 217 const gp_Pnt& thePnt3, 218 Standard_Integer theSensType, 219 SelectBasics_PickResult& thePickResult) const 220 { 221 return OverlapsTriangle (thePnt1, thePnt2, thePnt3, theSensType, thePickResult); 222 } 223 224 //! Deprecated static const class members aren't supported for Visual Studio prior to 2015 (vc14) 225 //! and GCC >= 5.0 and GCC < 6.3 (due to bug when warning was raised without member usage). 226 #if (!defined(_MSC_VER) || (_MSC_VER >= 1900)) && (!defined(__GNUC__) || (__GNUC__ != 5 && (__GNUC__ != 6 || __GNUC_MINOR__ >= 3))) 227 Standard_DEPRECATED("Deprecated alias - SelectMgr_SelectionType should be used instead") 228 static const SelectMgr_SelectionType Point = SelectMgr_SelectionType_Point; 229 230 Standard_DEPRECATED("Deprecated alias - SelectMgr_SelectionType should be used instead") 231 static const SelectMgr_SelectionType Box = SelectMgr_SelectionType_Box; 232 233 Standard_DEPRECATED("Deprecated alias - SelectMgr_SelectionType should be used instead") 234 static const SelectMgr_SelectionType Polyline = SelectMgr_SelectionType_Polyline; 235 236 Standard_DEPRECATED("Deprecated alias - SelectMgr_SelectionType should be used instead") 237 static const SelectMgr_SelectionType Unknown = SelectMgr_SelectionType_Unknown; 238 #endif 239 240 }; 241 242 #endif // _SelectBasics_SelectingVolumeManager_HeaderFile 243