File indexing completed on 2026-09-22 08:57:32
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 using BVH_Set<T, N>::Box;
0036
0037 public:
0038 static const int MaxTreeDepth = BVH_Constants_MaxTreeDepth;
0039
0040
0041 BVH_PrimitiveSet()
0042 : myBVH(new BVH_Tree<T, N>()),
0043
0044 myBuilder(
0045 new BVH_BinnedBuilder<T, N, BVH_Constants_NbBinsBest>(BVH_Constants_LeafNodeSizeDefault,
0046 BVH_Constants_MaxTreeDepth))
0047 {
0048
0049 }
0050
0051
0052 BVH_PrimitiveSet(const opencascade::handle<BVH_Builder<T, N>>& theBuilder)
0053 : myBVH(new BVH_Tree<T, N>()),
0054 myBuilder(theBuilder)
0055 {
0056
0057 }
0058
0059
0060 ~BVH_PrimitiveSet() override
0061 {
0062 myBVH.Nullify();
0063 myBuilder.Nullify();
0064 }
0065
0066 public:
0067
0068 BVH_Box<T, N> Box() const 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)
0092 {
0093 myBuilder = theBuilder;
0094 }
0095
0096 protected:
0097
0098 virtual void Update()
0099 {
0100 if (BVH_Object<T, N>::myIsDirty)
0101 {
0102 myBuilder->Build(this, myBVH.operator->(), Box());
0103 BVH_Object<T, N>::myIsDirty = false;
0104 }
0105 }
0106
0107 protected:
0108 opencascade::handle<BVH_Tree<T, N>> myBVH;
0109 opencascade::handle<BVH_Builder<T, N>> myBuilder;
0110
0111 mutable BVH_Box<T, N> myBox;
0112 };
0113
0114 #endif