4269bd1b |
1 | // Created on: 2013-08-15 |
2 | // Created by: Anton POLETAEV |
d5f74e42 |
3 | // Copyright (c) 2013-2014 OPEN CASCADE SAS |
4269bd1b |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
4269bd1b |
6 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
4269bd1b |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
4269bd1b |
15 | |
16 | #ifndef _OpenGl_CappingPlaneResource_H__ |
17 | #define _OpenGl_CappingPlaneResource_H__ |
18 | |
e1c659da |
19 | #include <OpenGl_PrimitiveArray.hxx> |
4269bd1b |
20 | #include <OpenGl_Resource.hxx> |
bf5f0ca2 |
21 | #include <OpenGl_Aspects.hxx> |
4269bd1b |
22 | #include <OpenGl_Matrix.hxx> |
23 | #include <Graphic3d_ClipPlane.hxx> |
24 | |
c04c30b3 |
25 | class OpenGl_CappingPlaneResource; |
4269bd1b |
26 | DEFINE_STANDARD_HANDLE (OpenGl_CappingPlaneResource, OpenGl_Resource) |
27 | |
28 | //! Container of graphical resources for rendering capping plane |
29 | //! associated to graphical clipping plane. |
30 | //! This resource holds data necessary for OpenGl_CappingAlgo. |
31 | //! This object is implemented as OpenGl resource for the following reasons: |
32 | //! - one instance should be shared between contexts. |
33 | //! - instance associated to Graphic3d_ClipPlane data by id. |
34 | //! - should created and released within context (owns OpenGl elements and resources). |
35 | class OpenGl_CappingPlaneResource : public OpenGl_Resource |
36 | { |
37 | public: |
38 | |
39 | //! Constructor. |
40 | //! Create capping plane presentation associated to clipping plane data. |
41 | //! @param thePlane [in] the plane data. |
42 | Standard_EXPORT OpenGl_CappingPlaneResource (const Handle(Graphic3d_ClipPlane)& thePlane); |
43 | |
44 | //! Destroy object. |
45 | Standard_EXPORT virtual ~OpenGl_CappingPlaneResource(); |
46 | |
47 | //! Update resource data in the passed context. |
3e05329c |
48 | //! @param theContext [in] the context |
49 | //! @param theObjAspect [in] object aspect |
50 | Standard_EXPORT void Update (const Handle(OpenGl_Context)& theContext, |
bf5f0ca2 |
51 | const Handle(Graphic3d_Aspects)& theObjAspect); |
4269bd1b |
52 | |
53 | //! Release associated OpenGl resources. |
54 | //! @param theContext [in] the resource context. |
e1c659da |
55 | Standard_EXPORT virtual void Release (OpenGl_Context* theContext) Standard_OVERRIDE; |
4269bd1b |
56 | |
15669413 |
57 | //! Returns estimated GPU memory usage - not implemented. |
58 | virtual Standard_Size EstimatedDataSize() const Standard_OVERRIDE { return 0; } |
59 | |
3e05329c |
60 | //! Return parent clipping plane structure. |
61 | const Handle(Graphic3d_ClipPlane)& Plane() const { return myPlaneRoot; } |
62 | |
4269bd1b |
63 | //! @return aspect face for rendering capping surface. |
bf5f0ca2 |
64 | inline const OpenGl_Aspects* AspectFace() const { return myAspect; } |
4269bd1b |
65 | |
66 | //! @return evaluated orientation matrix to transform infinite plane. |
67 | inline const OpenGl_Matrix* Orientation() const { return &myOrientation; } |
68 | |
e1c659da |
69 | //! @return primitive array of vertices to render infinite plane. |
70 | inline const OpenGl_PrimitiveArray& Primitives() const { return myPrimitives; } |
71 | |
4269bd1b |
72 | private: |
73 | |
74 | //! Update precomputed plane orientation matrix. |
edc4ba21 |
75 | void updateTransform (const Handle(OpenGl_Context)& theCtx); |
4269bd1b |
76 | |
77 | //! Update resources. |
bf5f0ca2 |
78 | void updateAspect (const Handle(Graphic3d_Aspects)& theObjAspect); |
4269bd1b |
79 | |
80 | private: |
81 | |
e1c659da |
82 | OpenGl_PrimitiveArray myPrimitives; //!< vertices and texture coordinates for rendering |
4269bd1b |
83 | OpenGl_Matrix myOrientation; //!< plane transformation matrix. |
bf5f0ca2 |
84 | OpenGl_Aspects* myAspect; //!< capping face aspect. |
4269bd1b |
85 | Handle(Graphic3d_ClipPlane) myPlaneRoot; //!< parent clipping plane structure. |
bf5f0ca2 |
86 | Handle(Graphic3d_Aspects) myFillAreaAspect;//!< own capping aspect |
edc4ba21 |
87 | gp_XYZ myLocalOrigin; //!< layer origin |
4269bd1b |
88 | unsigned int myEquationMod; //!< modification counter for plane equation. |
89 | unsigned int myAspectMod; //!< modification counter for aspect. |
90 | |
91 | public: |
92 | |
92efcf78 |
93 | DEFINE_STANDARD_RTTIEXT(OpenGl_CappingPlaneResource,OpenGl_Resource) // Type definition |
4269bd1b |
94 | |
95 | }; |
96 | |
97 | #endif |