0029590: Coding - avoid usage of Standard_EXPORT attribute for inline methods
[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
91d96372 19#include <gp_GTrsf.hxx>
f751596e 20#include <gp_Pnt.hxx>
21#include <gp_Pln.hxx>
22
23#include <Graphic3d_Camera.hxx>
24#include <Graphic3d_ClipPlane.hxx>
25#include <Graphic3d_SequenceOfHClipPlane.hxx>
825aa485 26#include <Graphic3d_WorldViewProjState.hxx>
f751596e 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
1f3913c6 47 Standard_EXPORT SelectMgr_BaseFrustum();
f751596e 48
bf3977c9 49 virtual ~SelectMgr_BaseFrustum() {}
f751596e 50
3fe9ce0e 51 //! Return camera definition.
52 const Handle(Graphic3d_Camera)& Camera() const { return myCamera; }
53
f751596e 54 //! Passes camera projection and orientation matrices to builder
1f3913c6 55 Standard_EXPORT void SetCamera (const Handle(Graphic3d_Camera)& theCamera);
f751596e 56
57 //! Passes camera projection and orientation matrices to builder
1f3913c6 58 Standard_EXPORT void SetCamera (const Graphic3d_Mat4d& theProjection,
59 const Graphic3d_Mat4d& theWorldView,
dde68833 60 const Standard_Boolean theIsOrthographic,
1f3913c6 61 const Graphic3d_WorldViewProjState& theWVPState = Graphic3d_WorldViewProjState());
825aa485 62
63 //! @return current camera projection transformation common for all selecting volumes
1f3913c6 64 Standard_EXPORT const Graphic3d_Mat4d& ProjectionMatrix() const;
825aa485 65
66 //! @return current camera world view transformation common for all selecting volumes
1f3913c6 67 Standard_EXPORT const Graphic3d_Mat4d& WorldViewMatrix() const;
825aa485 68
69 //! @return current camera world view projection transformation state
1f3913c6 70 Standard_EXPORT const Graphic3d_WorldViewProjState& WorldViewProjState() const;
f751596e 71
3bf9a45f 72 Standard_EXPORT void SetPixelTolerance (const Standard_Integer theTol);
f751596e 73
1f3913c6 74 Standard_EXPORT void SetWindowSize (const Standard_Integer theWidth,
75 const Standard_Integer theHeight);
f751596e 76
91d96372 77 Standard_EXPORT void WindowSize (Standard_Integer& theWidth,
099f3513 78 Standard_Integer& theHeight) const;
91d96372 79
f751596e 80 //! Passes viewport parameters to builder
1f3913c6 81 Standard_EXPORT void SetViewport (const Standard_Real theX,
82 const Standard_Real theY,
83 const Standard_Real theWidth,
84 const Standard_Real theHeight);
f751596e 85
86 //! Nullifies the builder created in the constructor and copies the pointer given
1f3913c6 87 Standard_EXPORT void SetBuilder (const Handle(SelectMgr_FrustumBuilder)& theBuilder);
f751596e 88
89
90 //! Builds volume according to the point and given pixel tolerance
bf3977c9 91 virtual void Build (const gp_Pnt2d& /*thePoint*/) {}
f751596e 92
93 //! Builds volume according to the selected rectangle
94 virtual void Build (const gp_Pnt2d& /*theMinPt*/,
bf3977c9 95 const gp_Pnt2d& /*theMaxPt*/) {}
f751596e 96
97 //! Builds volume according to the triangle given
98 virtual void Build (const gp_Pnt2d& /*theP1*/,
99 const gp_Pnt2d& /*theP2*/,
bf3977c9 100 const gp_Pnt2d& /*theP3*/) {}
f751596e 101
102 //! Builds selecting volumes set according to polyline points
bf3977c9 103 virtual void Build (const TColgp_Array1OfPnt2d& /*thePoints*/) {}
f751596e 104
3bf9a45f 105 //! IMPORTANT: Scaling makes sense only for frustum built on a single point!
106 //! Note that this method does not perform any checks on type of the frustum.
28ee613b 107 //! Returns a copy of the frustum resized according to the scale factor given
3bf9a45f 108 //! and transforms it using the matrix given.
109 //! There are no default parameters, but in case if:
110 //! - transformation only is needed: @theScaleFactor must be initialized as any negative value;
111 //! - scale only is needed: @theTrsf must be set to gp_Identity.
0f57ab75 112 virtual Handle(SelectMgr_BaseFrustum) ScaleAndTransform (const Standard_Integer /*theScaleFactor*/,
113 const gp_GTrsf& /*theTrsf*/) const
114 {
115 return NULL;
116 }
28ee613b 117
f751596e 118 //! SAT intersection test between defined volume and given axis-aligned box
3bf9a45f 119 Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theBoxMin,
120 const SelectMgr_Vec3& theBoxMax,
1f3913c6 121 Standard_Real& theDepth);
f751596e 122
123 //! Returns true if selecting volume is overlapped by axis-aligned bounding box
124 //! with minimum corner at point theMinPt and maximum at point theMaxPt
1f3913c6 125 Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theBoxMin,
126 const SelectMgr_Vec3& theBoxMax,
127 Standard_Boolean* theInside = NULL);
f751596e 128
129 //! Intersection test between defined volume and given point
3bf9a45f 130 Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt,
1f3913c6 131 Standard_Real& theDepth);
f751596e 132
3bf9a45f 133 //! Intersection test between defined volume and given point
134 //! Does not perform depth calculation, so this method is defined as
135 //! helper function for inclusion test. Therefore, its implementation
136 //! makes sense only for rectangular frustum with box selection mode activated.
137 Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt);
138
f751596e 139 //! SAT intersection test between defined volume and given ordered set of points,
140 //! representing line segments. The test may be considered of interior part or
141 //! boundary line defined by segments depending on given sensitivity type
114b7bf1 142 Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
1f3913c6 143 Select3D_TypeOfSensitivity theSensType,
144 Standard_Real& theDepth);
f751596e 145
146 //! Checks if line segment overlaps selecting frustum
3bf9a45f 147 Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
148 const gp_Pnt& thePnt2,
1f3913c6 149 Standard_Real& theDepth);
f751596e 150
151 //! SAT intersection test between defined volume and given triangle. The test may
152 //! be considered of interior part or boundary line defined by triangle vertices
153 //! depending on given sensitivity type
1f3913c6 154 Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePt1,
155 const gp_Pnt& thePt2,
156 const gp_Pnt& thePt3,
157 Select3D_TypeOfSensitivity theSensType,
158 Standard_Real& theDepth);
f751596e 159
160 //! Measures distance between 3d projection of user-picked
161 //! screen point and given point theCOG
1f3913c6 162 Standard_EXPORT virtual Standard_Real DistToGeometryCenter (const gp_Pnt& theCOG);
f751596e 163
3bf9a45f 164 Standard_EXPORT virtual gp_Pnt DetectedPoint (const Standard_Real theDepth) const;
f751596e 165
166 //! Checks if the point of sensitive in which selection was detected belongs
167 //! to the region defined by clipping planes
1f3913c6 168 Standard_EXPORT virtual Standard_Boolean IsClipped (const Graphic3d_SequenceOfHClipPlane& thePlanes,
169 const Standard_Real theDepth);
f751596e 170
e9312c0f 171 //! Valid for point selection only!
172 //! Computes depth range for global (defined for the whole view) clipping planes.
3202bf1e 173 virtual void SetViewClipping (const Handle(Graphic3d_SequenceOfHClipPlane)& /*thePlanes*/) {};
174
175 //! Set if view clipping plane is enabled or not.
176 //! @return previous value of the flag
177 virtual Standard_Boolean SetViewClippingEnabled (const Standard_Boolean /*theToEnable*/) { return Standard_False; }
e9312c0f 178
871dcdc2 179 //! Stores plane equation coefficients (in the following form:
180 //! Ax + By + Cz + D = 0) to the given vector
181 virtual void GetPlanes (NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) const
182 {
183 thePlaneEquations.Clear();
184 return;
185 }
186
92efcf78 187 DEFINE_STANDARD_RTTIEXT(SelectMgr_BaseFrustum,Standard_Transient)
c04c30b3 188
f751596e 189protected:
3bf9a45f 190 Standard_Integer myPixelTolerance; //!< Pixel tolerance
191 Standard_Boolean myIsOrthographic; //!< Defines if current camera is orthographic
f751596e 192
bf3977c9 193 Handle(SelectMgr_FrustumBuilder) myBuilder; //!< A tool implementing methods for volume build
3fe9ce0e 194 Handle(Graphic3d_Camera) myCamera; //!< camera definition
f751596e 195};
196
197#endif // _SelectMgr_BaseFrustum_HeaderFile