File indexing completed on 2025-01-18 10:03:48
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
0026 Graphic3d_IndexBuffer (const Handle(NCollection_BaseAllocator)& theAlloc)
0027 : Graphic3d_Buffer (theAlloc) {}
0028
0029
0030 template<typename IndexType_t>
0031 bool Init (const Standard_Integer theNbElems)
0032 {
0033 release();
0034 Stride = sizeof(IndexType_t);
0035 if (Stride != sizeof(unsigned short)
0036 && Stride != sizeof(unsigned int))
0037 {
0038 return false;
0039 }
0040
0041 NbElements = theNbElems;
0042 NbAttributes = 0;
0043 if (NbElements != 0
0044 && !Allocate (size_t(Stride) * size_t(NbElements)))
0045 {
0046 release();
0047 return false;
0048 }
0049 return true;
0050 }
0051
0052
0053 bool InitInt32 (const Standard_Integer theNbElems)
0054 {
0055 return Init<int> (theNbElems);
0056 }
0057
0058
0059 Standard_Integer Index (const Standard_Integer theIndex) const
0060 {
0061 return Stride == sizeof(unsigned short)
0062 ? Standard_Integer(Value<unsigned short> (theIndex))
0063 : Standard_Integer(Value<unsigned int> (theIndex));
0064 }
0065
0066
0067 void SetIndex (const Standard_Integer theIndex,
0068 const Standard_Integer theValue)
0069 {
0070 if (Stride == sizeof(unsigned short))
0071 {
0072 ChangeValue<unsigned short> (theIndex) = (unsigned short )theValue;
0073 }
0074 else
0075 {
0076 ChangeValue<unsigned int> (theIndex) = (unsigned int )theValue;
0077 }
0078 }
0079
0080
0081 virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE
0082 {
0083 OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
0084 OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Graphic3d_Buffer)
0085 }
0086
0087 };
0088
0089 DEFINE_STANDARD_HANDLE(Graphic3d_IndexBuffer, Graphic3d_Buffer)
0090
0091 #endif