0026403: Add missing Standard_EXPORT keyword in SelectMgr headers
[occt.git] / src / SelectMgr / SelectMgr_SelectableObjectTrsfPersSet.hxx
CommitLineData
825aa485 1// Created on: 2015-06-30
2// Created by: Anton POLETAEV
3// Copyright (c) 2015 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 _SelectMgr_SelectableObjectTrsfPersSet_HeaderFile
17#define _SelectMgr_SelectableObjectTrsfPersSet_HeaderFile
18
19#include <BVH_Builder.hxx>
20#include <BVH_Set.hxx>
21#include <BVH_Tree.hxx>
22#include <Graphic3d_Camera.hxx>
23#include <Graphic3d_WorldViewProjState.hxx>
24#include <NCollection_Handle.hxx>
25#include <NCollection_IndexedMap.hxx>
26#include <Select3D_BndBox3d.hxx>
27#include <SelectMgr_SelectableObject.hxx>
28
29//! Primitive set specialized for transformation persistent selectable objects.
30//! Provides built-in mechanism to invalidate tree when world view projection state changes.
31//! Due to frequent invalidation of BVH tree the choice of BVH tree builder is made
32//! in favor of BVH linear builder (quick rebuild).
33class SelectMgr_SelectableObjectTrsfPersSet : public BVH_Set<Standard_Real, 3>
34{
35private:
36
37 typedef NCollection_Handle<Select3D_BndBox3d> HBndBox3d;
38
39 Handle(SelectMgr_SelectableObject) EMPTY_OBJ;
40
41public:
42
43 //! Creates new empty objects set and initializes BVH tree
44 //! builder to Linear builder with 1 element per list.
45 Standard_EXPORT SelectMgr_SelectableObjectTrsfPersSet();
46
47 //! Returns size of objects set.
48 Standard_EXPORT virtual Standard_Integer Size() const Standard_OVERRIDE;
49
50 //! Returns bounding box of object with index theIndex.
51 Standard_EXPORT virtual Select3D_BndBox3d Box (const Standard_Integer theIndex) const Standard_OVERRIDE;
52
53 //! Returns center of object with index theIndex in the set along the given axis theAxis.
54 Standard_EXPORT virtual Standard_Real Center (const Standard_Integer theIndex,
55 const Standard_Integer theAxis) const Standard_OVERRIDE;
56
57 //! Swaps items with indexes theIndex1 and theIndex2 in the set.
58 Standard_EXPORT virtual void Swap (const Standard_Integer theIndex1,
59 const Standard_Integer theIndex2) Standard_OVERRIDE;
60
61 //! Adds new selectable object to the set.
62 //! @return true if structure added, otherwise returns false (structure already in the set).
63 Standard_EXPORT Standard_Boolean Append (const Handle(SelectMgr_SelectableObject)& theObject);
64
65 //! Removes selectable object from set.
66 //! @return true if structure removed, otherwise returns false (structure is not in the set).
67 Standard_EXPORT Standard_Boolean Remove (const Handle(SelectMgr_SelectableObject)& theObject);
68
69 //! Returns object from set by theIndex given.
70 const Handle(SelectMgr_SelectableObject)& GetObjectById (const Standard_Integer theIndex) const
71 {
72 return myObjects.FindKey (theIndex + 1);
73 }
74
75 //! Marks object state as outdated (needs BVH rebuilding).
76 void MarkDirty()
77 {
78 myIsDirty = Standard_True;
79 }
80
81 //! Returns true if this objects set contains theObject given
82 Standard_Boolean Contains (const Handle(SelectMgr_SelectableObject)& theObject) const
83 {
84 return myObjects.Contains (theObject);
85 }
86
87 //! Returns BVH tree for the given world view projection (builds it if necessary).
1f3913c6 88 Standard_EXPORT const NCollection_Handle<BVH_Tree<Standard_Real, 3> >& BVH (const Graphic3d_Mat4d& theProjectionMatrix,
89 const Graphic3d_Mat4d& theWorldViewMatrix,
90 const Graphic3d_WorldViewProjState& theWVPState);
825aa485 91
92private:
93
94 //! Marks internal object state as outdated.
95 Standard_Boolean myIsDirty;
96
97 //! Constructed bottom-level BVH.
98 NCollection_Handle<BVH_Tree<Standard_Real, 3> > myBVH;
99
100 //! Builder for bottom-level BVH.
101 NCollection_Handle<BVH_Builder<Standard_Real, 3> > myBuilder;
102
103 //! Set of transform persistence objects.
104 NCollection_IndexedMap<Handle(SelectMgr_SelectableObject)> myObjects;
105
106 //! Cached set of bounding boxes precomputed for transformation persistent selectable objects.
107 //! Cache exists only during computation of BVH Tree. Bounding boxes are world view projection
108 //! dependent and should by synchronized.
109 NCollection_IndexedMap<HBndBox3d> myObjectBoxes;
110
111 //! State of world view projection used for generation of transformation persistence bounding boxes.
112 Graphic3d_WorldViewProjState myObjectBoxesState;
113};
114
115#endif