File indexing completed on 2026-07-05 08:36:24
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef _BVH_BoxSet_Header
0017 #define _BVH_BoxSet_Header
0018
0019 #include <BVH_PrimitiveSet.hxx>
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 template <class NumType, int Dimension, class DataType = Standard_Integer>
0034 class BVH_BoxSet : public BVH_PrimitiveSet<NumType, Dimension>
0035 {
0036 public:
0037
0038 BVH_BoxSet()
0039 : BVH_PrimitiveSet<NumType, Dimension>()
0040 {
0041 }
0042
0043
0044 BVH_BoxSet(const opencascade::handle<BVH_Builder<NumType, Dimension>>& theBuilder)
0045 : BVH_PrimitiveSet<NumType, Dimension>(theBuilder)
0046 {
0047 }
0048
0049 public:
0050
0051 virtual void SetSize(const Standard_Size theSize)
0052 {
0053 myElements.reserve(theSize);
0054 myBoxes.reserve(theSize);
0055 }
0056
0057 public:
0058
0059 virtual void Add(const DataType& theElement, const BVH_Box<NumType, Dimension>& theBox)
0060 {
0061 myElements.push_back(theElement);
0062 myBoxes.push_back(theBox);
0063 BVH_Object<NumType, Dimension>::myIsDirty = Standard_True;
0064 }
0065
0066 public:
0067
0068 void Build() { BVH_PrimitiveSet<NumType, Dimension>::Update(); }
0069
0070 public:
0071
0072 virtual void Clear()
0073 {
0074 myElements.clear();
0075 myBoxes.clear();
0076 BVH_Object<NumType, Dimension>::myIsDirty = Standard_True;
0077 }
0078
0079 public:
0080
0081 using BVH_PrimitiveSet<NumType, Dimension>::Box;
0082
0083
0084 virtual BVH_Box<NumType, Dimension> Box(const Standard_Integer theIndex) const Standard_OVERRIDE
0085 {
0086 return myBoxes[theIndex];
0087 }
0088
0089
0090 virtual Standard_Real Center(const Standard_Integer theIndex,
0091 const Standard_Integer theAxis) const Standard_OVERRIDE
0092 {
0093 return Box(theIndex).Center(theAxis);
0094 }
0095
0096
0097 virtual Standard_Integer Size() const Standard_OVERRIDE
0098 {
0099 return static_cast<Standard_Integer>(myBoxes.size());
0100 }
0101
0102
0103 virtual void Swap(const Standard_Integer theIndex1,
0104 const Standard_Integer theIndex2) Standard_OVERRIDE
0105 {
0106 std::swap(myElements[theIndex1], myElements[theIndex2]);
0107 std::swap(myBoxes[theIndex1], myBoxes[theIndex2]);
0108 }
0109
0110
0111 virtual DataType Element(const Standard_Integer theIndex) const { return myElements[theIndex]; }
0112
0113 protected:
0114 std::vector<DataType> myElements;
0115 std::vector<BVH_Box<NumType, Dimension>> myBoxes;
0116 };
0117
0118 #endif