File indexing completed on 2025-01-18 10:03:19
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef BVH_Geometry_HeaderFile
0017 #define BVH_Geometry_HeaderFile
0018
0019 #include <BVH_ObjectSet.hxx>
0020 #include <BVH_Builder.hxx>
0021 #include <BVH_BinnedBuilder.hxx>
0022
0023
0024
0025
0026
0027 template<class T, int N>
0028 class BVH_Geometry : public BVH_ObjectSet<T, N>
0029 {
0030 public:
0031
0032
0033 BVH_Geometry()
0034 : myIsDirty (Standard_False),
0035 myBVH (new BVH_Tree<T, N>()),
0036
0037 myBuilder (new BVH_BinnedBuilder<T, N, BVH_Constants_NbBinsOptimal> (BVH_Constants_LeafNodeSizeSingle))
0038 {
0039
0040 }
0041
0042
0043 BVH_Geometry (const opencascade::handle<BVH_Builder<T, N> >& theBuilder)
0044 : myIsDirty (Standard_False),
0045 myBVH (new BVH_Tree<T, N>()),
0046 myBuilder (theBuilder)
0047 {
0048
0049 }
0050
0051
0052 virtual ~BVH_Geometry()
0053 {
0054 myBVH.Nullify();
0055 myBuilder.Nullify();
0056 }
0057
0058 public:
0059
0060
0061 virtual Standard_Boolean IsDirty() const { return myIsDirty; }
0062
0063
0064 virtual void MarkDirty() { myIsDirty = Standard_True; }
0065
0066
0067 using BVH_ObjectSet<T, N>::Box;
0068
0069
0070 virtual BVH_Box<T, N> Box() const Standard_OVERRIDE
0071 {
0072 if (myIsDirty)
0073 {
0074 myBox = BVH_Set<T, N>::Box();
0075 }
0076 return myBox;
0077 }
0078
0079
0080 virtual const opencascade::handle<BVH_Tree<T, N> >& BVH()
0081 {
0082 if (myIsDirty)
0083 {
0084 Update();
0085 }
0086 return myBVH;
0087 }
0088
0089
0090 virtual const opencascade::handle<BVH_Builder<T, N> >& Builder() const { return myBuilder; }
0091
0092
0093 virtual void SetBuilder (const opencascade::handle<BVH_Builder<T, N> >& theBuilder) { myBuilder = theBuilder; }
0094
0095 protected:
0096
0097
0098 virtual void Update()
0099 {
0100 if (myIsDirty)
0101 {
0102 myBuilder->Build (this, myBVH.operator->(), Box());
0103 myIsDirty = Standard_False;
0104 }
0105 }
0106
0107 protected:
0108
0109 Standard_Boolean myIsDirty;
0110 opencascade::handle<BVH_Tree<T, N> > myBVH;
0111 opencascade::handle<BVH_Builder<T, N> > myBuilder;
0112
0113 mutable BVH_Box<T, N> myBox;
0114
0115 };
0116
0117 #endif