File indexing completed on 2025-01-18 10:03:18
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
0039 BVH_BoxSet()
0040 : BVH_PrimitiveSet <NumType, Dimension>()
0041 {
0042 }
0043
0044
0045 BVH_BoxSet (const opencascade::handle <BVH_Builder <NumType, Dimension> >& theBuilder)
0046 : BVH_PrimitiveSet <NumType, Dimension> (theBuilder)
0047 {
0048 }
0049
0050 public:
0051
0052
0053 virtual void SetSize (const Standard_Size theSize)
0054 {
0055 myElements.reserve (theSize);
0056 myBoxes.reserve (theSize);
0057 }
0058
0059 public:
0060
0061
0062 virtual void Add (const DataType& theElement, const BVH_Box<NumType, Dimension>& theBox)
0063 {
0064 myElements.push_back (theElement);
0065 myBoxes.push_back (theBox);
0066 BVH_Object<NumType, Dimension>::myIsDirty = Standard_True;
0067 }
0068
0069 public:
0070
0071
0072 void Build()
0073 {
0074 BVH_PrimitiveSet <NumType, Dimension>::Update();
0075 }
0076
0077 public:
0078
0079
0080 virtual void Clear()
0081 {
0082 myElements.clear();
0083 myBoxes.clear();
0084 BVH_Object<NumType, Dimension>::myIsDirty = Standard_True;
0085 }
0086
0087 public:
0088
0089
0090 using BVH_PrimitiveSet <NumType, Dimension>::Box;
0091
0092
0093 virtual BVH_Box <NumType, Dimension> Box (const Standard_Integer theIndex) const Standard_OVERRIDE
0094 {
0095 return myBoxes[theIndex];
0096 }
0097
0098
0099 virtual Standard_Real Center (const Standard_Integer theIndex,
0100 const Standard_Integer theAxis) const Standard_OVERRIDE
0101 {
0102 return Box (theIndex).Center (theAxis);
0103 }
0104
0105
0106 virtual Standard_Integer Size() const Standard_OVERRIDE
0107 {
0108 return static_cast<Standard_Integer> (myBoxes.size());
0109 }
0110
0111
0112 virtual void Swap (const Standard_Integer theIndex1,
0113 const Standard_Integer theIndex2) Standard_OVERRIDE
0114 {
0115 std::swap (myElements[theIndex1], myElements[theIndex2]);
0116 std::swap (myBoxes [theIndex1], myBoxes [theIndex2]);
0117 }
0118
0119
0120 virtual DataType Element (const Standard_Integer theIndex) const
0121 {
0122 return myElements[theIndex];
0123 }
0124
0125 protected:
0126
0127 std::vector <DataType> myElements;
0128 std::vector <BVH_Box <NumType, Dimension> > myBoxes;
0129
0130 };
0131
0132 #endif