Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-28 09:20:19

0001 // Copyright (c) 2014 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _Graphic3d_BoundBuffer_HeaderFile
0015 #define _Graphic3d_BoundBuffer_HeaderFile
0016 
0017 #include <Graphic3d_Buffer.hxx>
0018 
0019 //! Bounds buffer.
0020 class Graphic3d_BoundBuffer : public NCollection_Buffer
0021 {
0022   DEFINE_STANDARD_RTTIEXT(Graphic3d_BoundBuffer, NCollection_Buffer)
0023 public:
0024   //! Empty constructor.
0025   Graphic3d_BoundBuffer(const occ::handle<NCollection_BaseAllocator>& theAlloc)
0026       : NCollection_Buffer(theAlloc),
0027         Colors(nullptr),
0028         Bounds(nullptr),
0029         NbBounds(0),
0030         NbMaxBounds(0)
0031   {
0032   }
0033 
0034   //! Allocates new empty array
0035   bool Init(const int theNbBounds, const bool theHasColors)
0036   {
0037     Colors      = nullptr;
0038     Bounds      = nullptr;
0039     NbBounds    = 0;
0040     NbMaxBounds = 0;
0041     Free();
0042     if (theNbBounds < 1)
0043     {
0044       return false;
0045     }
0046 
0047     const size_t aBoundsSize = sizeof(int) * theNbBounds;
0048     const size_t aColorsSize = theHasColors ? sizeof(NCollection_Vec4<float>) * theNbBounds : 0;
0049     if (!Allocate(aColorsSize + aBoundsSize))
0050     {
0051       Free();
0052       return false;
0053     }
0054 
0055     NbBounds    = theNbBounds;
0056     NbMaxBounds = theNbBounds;
0057     Colors      = theHasColors ? reinterpret_cast<NCollection_Vec4<float>*>(myData) : nullptr;
0058     Bounds      = reinterpret_cast<int*>(theHasColors ? (myData + aColorsSize) : myData);
0059     return true;
0060   }
0061 
0062   //! Dumps the content of me into the stream
0063   void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const override
0064   {
0065     OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)
0066     OCCT_DUMP_BASE_CLASS(theOStream, theDepth, NCollection_Buffer)
0067 
0068     OCCT_DUMP_FIELD_VALUE_POINTER(theOStream, Colors)
0069     OCCT_DUMP_FIELD_VALUE_POINTER(theOStream, Bounds)
0070 
0071     OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, NbBounds)
0072     OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, NbMaxBounds)
0073   }
0074 
0075 public:
0076   NCollection_Vec4<float>* Colors;      //!< pointer to facet color values
0077   int*                     Bounds;      //!< pointer to bounds array
0078   int                      NbBounds;    //!< number of bounds
0079   int                      NbMaxBounds; //!< number of allocated bounds
0080 };
0081 
0082 #endif // _Graphic3d_BoundBuffer_HeaderFile