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> |
b7cd4ba7 |
20 | #include <NCollection_Array1.hxx> |
385c43e7 |
21 | #include <NCollection_IndexedMap.hxx> |
b7cd4ba7 |
22 | |
b7cd4ba7 |
23 | #include <OpenGl_Structure.hxx> |
24 | |
9f112210 |
25 | //! Defines index map of OpenGL structures. |
26 | typedef NCollection_IndexedMap<const OpenGl_Structure*> OpenGl_IndexedMapOfStructure; |
27 | |
28 | //! Defines array of indexed maps of OpenGL structures. |
29 | typedef NCollection_Array1<OpenGl_IndexedMapOfStructure> OpenGl_ArrayOfIndexedMapOfStructure; |
b7cd4ba7 |
30 | |
31 | //! Set of OpenGl_Structures for building BVH tree. |
32 | class OpenGl_BVHClipPrimitiveSet : public BVH_PrimitiveSet<Standard_ShortReal, 4> |
33 | { |
34 | protected: |
35 | |
36 | using BVH_PrimitiveSet<Standard_ShortReal, 4>::Box; |
37 | |
38 | public: |
39 | |
40 | //! Creates an empty primitive set for BVH clipping. |
41 | OpenGl_BVHClipPrimitiveSet(); |
42 | |
43 | //! Returns total number of structures. |
44 | virtual Standard_Integer Size() const; |
45 | |
385c43e7 |
46 | //! Returns AABB of the structure. |
b7cd4ba7 |
47 | virtual Graphic3d_BndBox4f Box (const Standard_Integer theIdx) const; |
48 | |
385c43e7 |
49 | //! Calculates center of the AABB along given axis. |
b7cd4ba7 |
50 | virtual Standard_ShortReal Center (const Standard_Integer theIdx, |
51 | const Standard_Integer theAxis) const; |
52 | |
385c43e7 |
53 | //! Swaps structures with the given indices. |
b7cd4ba7 |
54 | virtual void Swap (const Standard_Integer theIdx1, |
55 | const Standard_Integer theIdx2); |
56 | |
57 | //! Replaces the set by the given array taking into account |
58 | //! if each structure is cullable or not. |
9f112210 |
59 | void Assign (const OpenGl_ArrayOfIndexedMapOfStructure& theStructs); |
b7cd4ba7 |
60 | |
385c43e7 |
61 | //! Adds structure to the set. |
b7cd4ba7 |
62 | void Add (const OpenGl_Structure* theStruct); |
63 | |
385c43e7 |
64 | //! Removes the given structure from the set. |
b7cd4ba7 |
65 | void Remove (const OpenGl_Structure* theStruct); |
66 | |
67 | //! Cleans the whole primitive set. |
68 | void Clear(); |
69 | |
385c43e7 |
70 | //! Returns the structure corresponding to the given ID. |
b7cd4ba7 |
71 | const OpenGl_Structure* GetStructureById (Standard_Integer theId); |
72 | |
73 | private: |
74 | |
385c43e7 |
75 | NCollection_IndexedMap<const OpenGl_Structure*> myStructs; //!< Indexed map of structures. |
b7cd4ba7 |
76 | |
77 | }; |
78 | |
79 | #endif // _OpenGl_BVHClipPrimitiveSet_HeaderFile |