File indexing completed on 2025-01-18 10:04:52
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
0027 Select3D_BVHIndexBuffer (const Handle(NCollection_BaseAllocator)& theAlloc)
0028 : Graphic3d_Buffer (theAlloc), myHasPatches (false) {}
0029
0030 bool HasPatches() const { return myHasPatches; }
0031
0032
0033 bool Init (const Standard_Integer theNbElems,
0034 const bool theHasPatches)
0035 {
0036 release();
0037 Stride = sizeof(unsigned int);
0038 myHasPatches = theHasPatches;
0039 if (theHasPatches)
0040 {
0041 Stride += sizeof(unsigned int);
0042 }
0043
0044 NbElements = theNbElems;
0045 NbAttributes = 0;
0046 if (NbElements != 0
0047 && !Allocate (size_t(Stride) * size_t(NbElements)))
0048 {
0049 release();
0050 return false;
0051 }
0052 return true;
0053 }
0054
0055
0056 Standard_Integer Index (const Standard_Integer theIndex) const
0057 {
0058 return Standard_Integer(*reinterpret_cast<const unsigned int* >(value (theIndex)));
0059 }
0060
0061
0062 Standard_Integer PatchSize (const Standard_Integer theIndex) const
0063 {
0064 return myHasPatches
0065 ? Standard_Integer(*reinterpret_cast<const unsigned int* >(value (theIndex) + sizeof(unsigned int)))
0066 : 1;
0067 }
0068
0069
0070 void SetIndex (const Standard_Integer theIndex,
0071 const Standard_Integer theValue)
0072 {
0073 *reinterpret_cast<unsigned int* >(changeValue (theIndex)) = (unsigned int )theValue;
0074 }
0075
0076
0077 void SetIndex (const Standard_Integer theIndex,
0078 const Standard_Integer theValue,
0079 const Standard_Integer thePatchSize)
0080 {
0081 *reinterpret_cast<unsigned int* >(changeValue (theIndex)) = (unsigned int )theValue;
0082 *reinterpret_cast<unsigned int* >(changeValue (theIndex) + sizeof(unsigned int)) = (unsigned int )thePatchSize;
0083 }
0084
0085 private:
0086
0087 bool myHasPatches;
0088
0089 public:
0090
0091 DEFINE_STANDARD_RTTI_INLINE(Select3D_BVHIndexBuffer,Graphic3d_Buffer)
0092
0093 };
0094
0095 DEFINE_STANDARD_HANDLE(Select3D_BVHIndexBuffer, Graphic3d_Buffer)
0096
0097 #endif