File indexing completed on 2026-09-13 09:16:36
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef _Graphic3d_IndexBuffer_HeaderFile
0015 #define _Graphic3d_IndexBuffer_HeaderFile
0016
0017 #include <Graphic3d_Buffer.hxx>
0018
0019
0020 class Graphic3d_IndexBuffer : public Graphic3d_Buffer
0021 {
0022 DEFINE_STANDARD_RTTIEXT(Graphic3d_IndexBuffer, Graphic3d_Buffer)
0023 public:
0024
0025 Graphic3d_IndexBuffer(const occ::handle<NCollection_BaseAllocator>& theAlloc)
0026 : Graphic3d_Buffer(theAlloc)
0027 {
0028 }
0029
0030
0031 template <typename IndexType_t>
0032 bool Init(const int theNbElems)
0033 {
0034 release();
0035 Stride = sizeof(IndexType_t);
0036 if (Stride != sizeof(unsigned short) && Stride != sizeof(unsigned int))
0037 {
0038 return false;
0039 }
0040
0041 NbElements = theNbElems;
0042 NbAttributes = 0;
0043 if (NbElements != 0 && !Allocate(size_t(Stride) * size_t(NbElements)))
0044 {
0045 release();
0046 return false;
0047 }
0048 return true;
0049 }
0050
0051
0052 bool InitInt32(const int theNbElems) { return Init<int>(theNbElems); }
0053
0054
0055 int Index(const int theIndex) const
0056 {
0057 return Stride == sizeof(unsigned short) ? int(Value<unsigned short>(theIndex))
0058 : int(Value<unsigned int>(theIndex));
0059 }
0060
0061
0062 void SetIndex(const int theIndex, const int theValue)
0063 {
0064 if (Stride == sizeof(unsigned short))
0065 {
0066 ChangeValue<unsigned short>(theIndex) = (unsigned short)theValue;
0067 }
0068 else
0069 {
0070 ChangeValue<unsigned int>(theIndex) = (unsigned int)theValue;
0071 }
0072 }
0073
0074
0075 void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const override
0076 {
0077 OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
0078 OCCT_DUMP_BASE_CLASS(theOStream, theDepth, Graphic3d_Buffer)
0079 }
0080 };
0081
0082 #endif