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_PrimitiveSet_HeaderFile
0017 #define BVH_PrimitiveSet_HeaderFile
0018
0019 #include <BVH_Object.hxx>
0020 #include <BVH_Builder.hxx>
0021 #include <BVH_BinnedBuilder.hxx>
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 template<class T, int N>
0032 class BVH_PrimitiveSet : public BVH_Object<T, N>, public BVH_Set<T, N>
0033 {
0034 protected:
0035
0036 using BVH_Set<T, N>::Box;
0037
0038 public:
0039 static const Standard_Integer MaxTreeDepth = BVH_Constants_MaxTreeDepth;
0040
0041
0042 BVH_PrimitiveSet()
0043 : myBVH (new BVH_Tree<T, N>()),
0044
0045 myBuilder (new BVH_BinnedBuilder<T, N, BVH_Constants_NbBinsBest> (BVH_Constants_LeafNodeSizeDefault, BVH_Constants_MaxTreeDepth))
0046 {
0047
0048 }
0049
0050
0051 BVH_PrimitiveSet (const opencascade::handle<BVH_Builder<T, N> >& theBuilder)
0052 : myBVH (new BVH_Tree<T, N>()),
0053 myBuilder (theBuilder)
0054 {
0055
0056 }
0057
0058
0059 virtual ~BVH_PrimitiveSet()
0060 {
0061 myBVH.Nullify();
0062 myBuilder.Nullify();
0063 }
0064
0065 public:
0066
0067
0068 virtual BVH_Box<T, N> Box() const Standard_OVERRIDE
0069 {
0070 if (BVH_Object<T, N>::myIsDirty)
0071 {
0072 myBox = BVH_Set<T, N>::Box();
0073 }
0074 return myBox;
0075 }
0076
0077
0078 virtual const opencascade::handle<BVH_Tree<T, N> >& BVH()
0079 {
0080 if (BVH_Object<T, N>::myIsDirty)
0081 {
0082 Update();
0083 }
0084 return myBVH;
0085 }
0086
0087
0088 virtual const opencascade::handle<BVH_Builder<T, N> >& Builder() const { return myBuilder; }
0089
0090
0091 virtual void SetBuilder (const opencascade::handle<BVH_Builder<T, N> >& theBuilder) { myBuilder = theBuilder; }
0092
0093 protected:
0094
0095
0096 virtual void Update()
0097 {
0098 if (BVH_Object<T, N>::myIsDirty)
0099 {
0100 myBuilder->Build (this, myBVH.operator->(), Box());
0101 BVH_Object<T, N>::myIsDirty = Standard_False;
0102 }
0103 }
0104
0105 protected:
0106
0107 opencascade::handle<BVH_Tree<T, N> > myBVH;
0108 opencascade::handle<BVH_Builder<T, N> > myBuilder;
0109
0110 mutable BVH_Box<T, N> myBox;
0111
0112 };
0113
0114 #endif