Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-08 09:17:19

0001 // Created on: 2014-11-24
0002 // Created by: Varvara POSKONINA
0003 // Copyright (c) 2005-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _SelectMgr_FrustumBuilder_HeaderFile
0017 #define _SelectMgr_FrustumBuilder_HeaderFile
0018 
0019 #include <Graphic3d_Camera.hxx>
0020 #include <Precision.hxx>
0021 #include <SelectMgr_VectorTypes.hxx>
0022 
0023 //! The purpose of this class is to provide unified interface for building
0024 //! selecting frustum depending on current camera projection and orientation
0025 //! matrices, window size and viewport parameters.
0026 class SelectMgr_FrustumBuilder : public Standard_Transient
0027 {
0028 public:
0029   //! Creates new frustum builder with empty matrices
0030   Standard_EXPORT SelectMgr_FrustumBuilder();
0031 
0032   //! Returns current camera
0033   const Handle(Graphic3d_Camera)& Camera() const { return myCamera; }
0034 
0035   //! Stores current camera
0036   Standard_EXPORT void SetCamera(const Handle(Graphic3d_Camera)& theCamera);
0037 
0038   //! Stores current window width and height
0039   Standard_EXPORT void SetWindowSize(const Standard_Integer theWidth,
0040                                      const Standard_Integer theHeight);
0041 
0042   //! Stores current viewport coordinates
0043   Standard_EXPORT void SetViewport(const Standard_Real theX,
0044                                    const Standard_Real theY,
0045                                    const Standard_Real theWidth,
0046                                    const Standard_Real theHeight);
0047 
0048   Standard_EXPORT void InvalidateViewport();
0049 
0050   Standard_EXPORT void WindowSize(Standard_Integer& theWidth, Standard_Integer& theHeight) const;
0051 
0052   //! Calculates signed distance between plane with equation
0053   //! theEq and point thePnt
0054   Standard_EXPORT Standard_Real SignedPlanePntDist(const SelectMgr_Vec3& theEq,
0055                                                    const SelectMgr_Vec3& thePnt) const;
0056 
0057   //! Projects 2d screen point onto view frustum plane:
0058   //! theZ = 0 - near plane,
0059   //! theZ = 1 - far plane
0060   Standard_EXPORT gp_Pnt ProjectPntOnViewPlane(const Standard_Real& theX,
0061                                                const Standard_Real& theY,
0062                                                const Standard_Real& theZ) const;
0063 
0064   DEFINE_STANDARD_RTTIEXT(SelectMgr_FrustumBuilder, Standard_Transient)
0065 
0066 private:
0067   Handle(Graphic3d_Camera)        myCamera;
0068   Standard_Integer                myWidth;
0069   Standard_Integer                myHeight;
0070   NCollection_Vec4<Standard_Real> myViewport;
0071   Standard_Boolean                myIsViewportSet;
0072 };
0073 
0074 DEFINE_STANDARD_HANDLE(SelectMgr_FrustumBuilder, Standard_Transient)
0075 
0076 #endif // _SelectMgr_FrustumBuilder_HeaderFile