b7cd4ba7 |
1 | // Created on: 2013-12-25 |
2 | // Created by: Varvara POSKONINA |
3 | // Copyright (c) 1999-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 _OpenGl_BVHClipPrimitiveSet_HeaderFile |
17 | #define _OpenGl_BVHClipPrimitiveSet_HeaderFile |
18 | |
19 | #include <BVH_PrimitiveSet.hxx> |
20 | |
21 | #include <NCollection_Array1.hxx> |
22 | #include <NCollection_Sequence.hxx> |
23 | |
24 | #include <OpenGl_Vec.hxx> |
25 | #include <OpenGl_Structure.hxx> |
26 | |
27 | typedef NCollection_Sequence<const OpenGl_Structure*> OpenGl_SequenceOfStructure; |
28 | typedef NCollection_Array1<OpenGl_SequenceOfStructure> OpenGl_ArrayOfStructure; |
29 | |
30 | //! Set of OpenGl_Structures for building BVH tree. |
31 | class OpenGl_BVHClipPrimitiveSet : public BVH_PrimitiveSet<Standard_ShortReal, 4> |
32 | { |
33 | protected: |
34 | |
35 | using BVH_PrimitiveSet<Standard_ShortReal, 4>::Box; |
36 | |
37 | public: |
38 | |
39 | //! Creates an empty primitive set for BVH clipping. |
40 | OpenGl_BVHClipPrimitiveSet(); |
41 | |
42 | //! Returns total number of structures. |
43 | virtual Standard_Integer Size() const; |
44 | |
45 | //! Returns AABB of a structure. |
46 | virtual Graphic3d_BndBox4f Box (const Standard_Integer theIdx) const; |
47 | |
48 | //! Calculates center of the AABB projection onto given axis. |
49 | virtual Standard_ShortReal Center (const Standard_Integer theIdx, |
50 | const Standard_Integer theAxis) const; |
51 | |
52 | //! Swaps given AABBs. |
53 | virtual void Swap (const Standard_Integer theIdx1, |
54 | const Standard_Integer theIdx2); |
55 | |
56 | //! Replaces the set by the given array taking into account |
57 | //! if each structure is cullable or not. |
58 | void Assign (const OpenGl_ArrayOfStructure& theStructs); |
59 | |
60 | //! Adds structure theStruct to the set. |
61 | void Add (const OpenGl_Structure* theStruct); |
62 | |
63 | //! Removes the given OpenGl_Structure from the set. |
64 | void Remove (const OpenGl_Structure* theStruct); |
65 | |
66 | //! Cleans the whole primitive set. |
67 | void Clear(); |
68 | |
69 | //! Returns the structure corresponding to the given id. |
70 | const OpenGl_Structure* GetStructureById (Standard_Integer theId); |
71 | |
72 | private: |
73 | |
74 | NCollection_Sequence<const OpenGl_Structure*> myStructs; //!< Sequence of structures |
75 | |
76 | }; |
77 | |
78 | #endif // _OpenGl_BVHClipPrimitiveSet_HeaderFile |