File indexing completed on 2026-09-13 09:17:39
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef _Select3D_BVHIndexBuffer_Header
0017 #define _Select3D_BVHIndexBuffer_Header
0018
0019 #include <Graphic3d_Buffer.hxx>
0020
0021
0022 class Select3D_BVHIndexBuffer : public Graphic3d_Buffer
0023 {
0024 public:
0025
0026 Select3D_BVHIndexBuffer(const occ::handle<NCollection_BaseAllocator>& theAlloc)
0027 : Graphic3d_Buffer(theAlloc),
0028 myHasPatches(false)
0029 {
0030 }
0031
0032 bool HasPatches() const { return myHasPatches; }
0033
0034
0035 bool Init(const int theNbElems, const bool theHasPatches)
0036 {
0037 release();
0038 Stride = sizeof(unsigned int);
0039 myHasPatches = theHasPatches;
0040 if (theHasPatches)
0041 {
0042 Stride += sizeof(unsigned int);
0043 }
0044
0045 NbElements = theNbElems;
0046 NbAttributes = 0;
0047 if (NbElements != 0 && !Allocate(size_t(Stride) * size_t(NbElements)))
0048 {
0049 release();
0050 return false;
0051 }
0052 return true;
0053 }
0054
0055
0056 int Index(const int theIndex) const
0057 {
0058 return int(*reinterpret_cast<const unsigned int*>(value(theIndex)));
0059 }
0060
0061
0062 int PatchSize(const int theIndex) const
0063 {
0064 return myHasPatches
0065 ? int(*reinterpret_cast<const unsigned int*>(value(theIndex) + sizeof(unsigned int)))
0066 : 1;
0067 }
0068
0069
0070 void SetIndex(const int theIndex, const int theValue)
0071 {
0072 *reinterpret_cast<unsigned int*>(changeValue(theIndex)) = (unsigned int)theValue;
0073 }
0074
0075
0076 void SetIndex(const int theIndex, const int theValue, const int thePatchSize)
0077 {
0078 *reinterpret_cast<unsigned int*>(changeValue(theIndex)) = (unsigned int)theValue;
0079 *reinterpret_cast<unsigned int*>(changeValue(theIndex) + sizeof(unsigned int)) =
0080 (unsigned int)thePatchSize;
0081 }
0082
0083 private:
0084 bool myHasPatches;
0085
0086 public:
0087 DEFINE_STANDARD_RTTI_INLINE(Select3D_BVHIndexBuffer, Graphic3d_Buffer)
0088 };
0089
0090 #endif