0024023: Revamp the OCCT Handle -- general
[occt.git] / src / SelectMgr / SelectMgr_BaseFrustum.hxx
CommitLineData
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_BaseFrustum_HeaderFile
17#define _SelectMgr_BaseFrustum_HeaderFile
18
19#include <Bnd_Box.hxx>
20
21#include <gp_Pnt.hxx>
22#include <gp_Pln.hxx>
23
24#include <Graphic3d_Camera.hxx>
25#include <Graphic3d_ClipPlane.hxx>
26#include <Graphic3d_SequenceOfHClipPlane.hxx>
27
f751596e 28#include <TColgp_HArray1OfPnt.hxx>
29#include <TColgp_Array1OfPnt2d.hxx>
30
31#include <Select3D_BndBox3d.hxx>
32#include <SelectMgr_FrustumBuilder.hxx>
33#include <Select3D_TypeOfSensitivity.hxx>
34#include <SelectMgr_VectorTypes.hxx>
35
36//! This class is an interface for different types of selecting frustums,
37//! defining different selection types, like point, box or polyline
38//! selection. It contains signatures of functions for detection of
39//! overlap by sensitive entity and initializes some data for building
40//! the selecting frustum
c04c30b3 41class SelectMgr_BaseFrustum : public Standard_Transient
f751596e 42{
43public:
44
45 //! Creates new selecting volume with pixel toletance set to 2,
46 //! orthographic camera and empty frustum builder
47 SelectMgr_BaseFrustum();
48
bf3977c9 49 virtual ~SelectMgr_BaseFrustum() {}
f751596e 50
51 //! Passes camera projection and orientation matrices to builder
52 void SetCamera (const Handle(Graphic3d_Camera)& theCamera);
53
54 //! Passes camera projection and orientation matrices to builder
55 void SetCamera (const Graphic3d_Mat4d& theProjection,
56 const Graphic3d_Mat4d& theOrientation,
57 const Standard_Integer theIsOrthographic);
58
59 void SetPixelTolerance (const Standard_Real theTol);
60
61 void SetWindowSize (const Standard_Integer theWidth, const Standard_Integer theHeight);
62
63 //! Passes viewport parameters to builder
64 void SetViewport (const Standard_Real theX,
65 const Standard_Real theY,
66 const Standard_Real theWidth,
67 const Standard_Real theHeight);
68
69 //! Nullifies the builder created in the constructor and copies the pointer given
bf3977c9 70 void SetBuilder (const Handle(SelectMgr_FrustumBuilder)& theBuilder);
f751596e 71
72
73 //! Builds volume according to the point and given pixel tolerance
bf3977c9 74 virtual void Build (const gp_Pnt2d& /*thePoint*/) {}
f751596e 75
76 //! Builds volume according to the selected rectangle
77 virtual void Build (const gp_Pnt2d& /*theMinPt*/,
bf3977c9 78 const gp_Pnt2d& /*theMaxPt*/) {}
f751596e 79
80 //! Builds volume according to the triangle given
81 virtual void Build (const gp_Pnt2d& /*theP1*/,
82 const gp_Pnt2d& /*theP2*/,
bf3977c9 83 const gp_Pnt2d& /*theP3*/) {}
f751596e 84
85 //! Builds selecting volumes set according to polyline points
bf3977c9 86 virtual void Build (const TColgp_Array1OfPnt2d& /*thePoints*/) {}
f751596e 87
88 virtual NCollection_Handle<SelectMgr_BaseFrustum> Transform (const gp_Trsf& /*theTrsf*/) { return NULL; }
89
28ee613b 90 //! IMPORTANT: Makes sense only for frustum built on a single point!
91 //! Returns a copy of the frustum resized according to the scale factor given
92 virtual NCollection_Handle<SelectMgr_BaseFrustum> Scale (const Standard_Real /*theScaleFactor*/) { return NULL; }
93
f751596e 94 //! SAT intersection test between defined volume and given axis-aligned box
7ab15952 95 virtual Standard_Boolean Overlaps (const BVH_Box<Standard_Real, 3>& theBndBox,
96 Standard_Real& theDepth);
f751596e 97
98 //! Returns true if selecting volume is overlapped by axis-aligned bounding box
99 //! with minimum corner at point theMinPt and maximum at point theMaxPt
2157d6ac 100 virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theBoxMin,
101 const SelectMgr_Vec3& theBoxMax,
102 Standard_Boolean* theInside = NULL);
f751596e 103
104 //! Intersection test between defined volume and given point
7ab15952 105 virtual Standard_Boolean Overlaps (const gp_Pnt& thePt,
106 Standard_Real& theDepth);
f751596e 107
108 //! SAT intersection test between defined volume and given ordered set of points,
109 //! representing line segments. The test may be considered of interior part or
110 //! boundary line defined by segments depending on given sensitivity type
7ab15952 111 virtual Standard_Boolean Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPts,
112 Select3D_TypeOfSensitivity theSensType,
113 Standard_Real& theDepth);
f751596e 114
115 //! Checks if line segment overlaps selecting frustum
7ab15952 116 virtual Standard_Boolean Overlaps (const gp_Pnt& thePt1,
117 const gp_Pnt& thePt2,
118 Standard_Real& theDepth);
f751596e 119
120 //! SAT intersection test between defined volume and given triangle. The test may
121 //! be considered of interior part or boundary line defined by triangle vertices
122 //! depending on given sensitivity type
7ab15952 123 virtual Standard_Boolean Overlaps (const gp_Pnt& thePt1,
124 const gp_Pnt& thePt2,
125 const gp_Pnt& thePt3,
126 Select3D_TypeOfSensitivity theSensType,
127 Standard_Real& theDepth);
f751596e 128
129 //! Measures distance between 3d projection of user-picked
130 //! screen point and given point theCOG
7ab15952 131 virtual Standard_Real DistToGeometryCenter (const gp_Pnt& theCOG);
f751596e 132
133 virtual SelectMgr_Vec3 DetectedPoint (const Standard_Real theDepth) const;
134
135 //! Checks if the point of sensitive in which selection was detected belongs
136 //! to the region defined by clipping planes
7ab15952 137 virtual Standard_Boolean IsClipped (const Graphic3d_SequenceOfHClipPlane& thePlanes,
138 const Standard_Real theDepth);
f751596e 139
c04c30b3 140 DEFINE_STANDARD_RTTI(SelectMgr_BaseFrustum, Standard_Transient)
141
f751596e 142protected:
143 Standard_Real myPixelTolerance; //!< Pixel tolerance
144 Standard_Boolean myIsOrthographic; //!< Defines if current camera is orthographic
145
bf3977c9 146 Handle(SelectMgr_FrustumBuilder) myBuilder; //!< A tool implementing methods for volume build
f751596e 147};
148
149#endif // _SelectMgr_BaseFrustum_HeaderFile