Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:47

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 
0025   //! Empty constructor.
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   //! Allocates new empty array
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   //! Dumps the content of me into the stream
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;      //!< pointer to facet color values
0080   Standard_Integer* Bounds;      //!< pointer to bounds array
0081   Standard_Integer  NbBounds;    //!< number of bounds
0082   Standard_Integer  NbMaxBounds; //!< number of allocated bounds
0083 
0084 };
0085 
0086 DEFINE_STANDARD_HANDLE(Graphic3d_BoundBuffer, NCollection_Buffer)
0087 
0088 #endif // _Graphic3d_BoundBuffer_HeaderFile