0024947: Redesign OCCT legacy type system -- automatic
[occt.git] / src / SelectMgr / SelectMgr_FrustumBuilder.hxx
CommitLineData
f751596e 1// Created on: 2014-11-24
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_FrustumBuilder_HeaderFile
17#define _SelectMgr_FrustumBuilder_HeaderFile
18
ec357c5c 19#include <Standard_Type.hxx>
bf3977c9 20
f751596e 21#include <Graphic3d_Camera.hxx>
f751596e 22#include <Precision.hxx>
23#include <SelectMgr_VectorTypes.hxx>
24
25//! The purpose of this class is to provide unified interface for building
26//! selecting frustum depending on current camera projection and orientation
27//! matrices, window size and viewport parameters.
bf3977c9 28class SelectMgr_FrustumBuilder : public Standard_Transient
f751596e 29{
30public:
31 //! Creates new frustum builder with empty matrices
32 SelectMgr_FrustumBuilder();
33
f751596e 34 //! Stores current orientation matrix
35 void SetOrientation (const Graphic3d_Mat4d& theOrientation);
36
37 //! Stores current projection matrix
38 void SetProjection (const Graphic3d_Mat4d& theProjection);
39
40 //! Stores current window width and height
41 void SetWindowSize (const Standard_Integer theWidth,
42 const Standard_Integer theHeight);
43
44 //! Stores current viewport coordinates
45 void SetViewport (const Standard_Real theX,
46 const Standard_Real theY,
47 const Standard_Real theWidth,
48 const Standard_Real theHeight);
49
50 void InvalidateViewport();
51
52 //! Calculates signed distance between plane with equation
53 //! theEq and point thePnt
54 Standard_Real SignedPlanePntDist (const SelectMgr_Vec3& theEq,
55 const SelectMgr_Vec3& thePnt) const;
56
f751596e 57 //! Projects 2d screen point onto view frustum plane:
58 //! theZ = 0 - near plane,
59 //! theZ = 1 - far plane
60 SelectMgr_Vec3 ProjectPntOnViewPlane (const Standard_Real& theX,
61 const Standard_Real& theY,
62 const Standard_Real& theZ) const;
63
ec357c5c 64 DEFINE_STANDARD_RTTI(SelectMgr_FrustumBuilder, Standard_Transient)
bf3977c9 65
f751596e 66private:
67
68 //! Unprojects point from NDC coords to 3d world space
69 SelectMgr_Vec3 unProject (const gp_Pnt& thePnt) const;
70
71private:
72
73 Graphic3d_Mat4d myOrientation;
74 Graphic3d_Mat4d myProjection;
75 Standard_Integer myWidth;
76 Standard_Integer myHeight;
77 NCollection_Vec4<Standard_Real> myViewport;
78 Standard_Boolean myIsViewportSet;
79};
80
bf3977c9 81DEFINE_STANDARD_HANDLE(SelectMgr_FrustumBuilder, Standard_Transient)
82
f751596e 83#endif // _SelectMgr_FrustumBuilder_HeaderFile