File indexing completed on 2025-01-18 10:03:47
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef _Graphic3d_BoundBuffer_HeaderFile
0015 #define _Graphic3d_BoundBuffer_HeaderFile
0016
0017 #include <Graphic3d_Buffer.hxx>
0018
0019
0020 class Graphic3d_BoundBuffer : public NCollection_Buffer
0021 {
0022 DEFINE_STANDARD_RTTIEXT(Graphic3d_BoundBuffer, NCollection_Buffer)
0023 public:
0024
0025
0026 Graphic3d_BoundBuffer (const Handle(NCollection_BaseAllocator)& theAlloc)
0027 : NCollection_Buffer (theAlloc),
0028 Colors (NULL),
0029 Bounds (NULL),
0030 NbBounds (0),
0031 NbMaxBounds (0) {}
0032
0033
0034 bool Init (const Standard_Integer theNbBounds,
0035 const Standard_Boolean theHasColors)
0036 {
0037 Colors = NULL;
0038 Bounds = NULL;
0039 NbBounds = 0;
0040 NbMaxBounds = 0;
0041 Free();
0042 if (theNbBounds < 1)
0043 {
0044 return false;
0045 }
0046
0047 const size_t aBoundsSize = sizeof(Standard_Integer) * theNbBounds;
0048 const size_t aColorsSize = theHasColors
0049 ? sizeof(Graphic3d_Vec4) * theNbBounds
0050 : 0;
0051 if (!Allocate (aColorsSize + aBoundsSize))
0052 {
0053 Free();
0054 return false;
0055 }
0056
0057 NbBounds = theNbBounds;
0058 NbMaxBounds = theNbBounds;
0059 Colors = theHasColors ? reinterpret_cast<Graphic3d_Vec4* >(myData) : NULL;
0060 Bounds = reinterpret_cast<Standard_Integer* >(theHasColors ? (myData + aColorsSize) : myData);
0061 return true;
0062 }
0063
0064
0065 virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE
0066 {
0067 OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
0068 OCCT_DUMP_BASE_CLASS (theOStream, theDepth, NCollection_Buffer)
0069
0070 OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, Colors)
0071 OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, Bounds)
0072
0073 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, NbBounds)
0074 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, NbMaxBounds)
0075 }
0076
0077 public:
0078
0079 Graphic3d_Vec4* Colors;
0080 Standard_Integer* Bounds;
0081 Standard_Integer NbBounds;
0082 Standard_Integer NbMaxBounds;
0083
0084 };
0085
0086 DEFINE_STANDARD_HANDLE(Graphic3d_BoundBuffer, NCollection_Buffer)
0087
0088 #endif