Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:53

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,
0051                                    Standard_Integer& theHeight) const;
0052 
0053   //! Calculates signed distance between plane with equation
0054   //! theEq and point thePnt
0055   Standard_EXPORT Standard_Real SignedPlanePntDist (const SelectMgr_Vec3& theEq,
0056                                                     const SelectMgr_Vec3& thePnt) const;
0057 
0058   //! Projects 2d screen point onto view frustum plane:
0059   //! theZ = 0 - near plane,
0060   //! theZ = 1 - far plane
0061   Standard_EXPORT gp_Pnt ProjectPntOnViewPlane (const Standard_Real& theX,
0062                                                 const Standard_Real& theY,
0063                                                 const Standard_Real& theZ) const;
0064 
0065   DEFINE_STANDARD_RTTIEXT(SelectMgr_FrustumBuilder,Standard_Transient)
0066 
0067 private:
0068 
0069   Handle(Graphic3d_Camera)          myCamera;
0070   Standard_Integer                  myWidth;
0071   Standard_Integer                  myHeight;
0072   NCollection_Vec4<Standard_Real>   myViewport;
0073   Standard_Boolean                  myIsViewportSet;
0074 };
0075 
0076 DEFINE_STANDARD_HANDLE(SelectMgr_FrustumBuilder, Standard_Transient)
0077 
0078 #endif // _SelectMgr_FrustumBuilder_HeaderFile