1 // Copyright (c) 2018 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #ifndef _Graphic3d_MutableIndexBuffer_HeaderFile
15 #define _Graphic3d_MutableIndexBuffer_HeaderFile
17 #include <Graphic3d_IndexBuffer.hxx>
19 //! Mutable index buffer.
20 class Graphic3d_MutableIndexBuffer : public Graphic3d_IndexBuffer
22 DEFINE_STANDARD_RTTIEXT(Graphic3d_MutableIndexBuffer, Graphic3d_IndexBuffer)
25 //! Empty constructor.
26 Graphic3d_MutableIndexBuffer (const Handle(NCollection_BaseAllocator)& theAlloc) : Graphic3d_IndexBuffer (theAlloc) {}
28 //! Return TRUE if data can be invalidated.
29 virtual Standard_Boolean IsMutable() const Standard_OVERRIDE { return Standard_True; }
31 //! Return invalidated range.
32 virtual Graphic3d_BufferRange InvalidatedRange() const Standard_OVERRIDE { return myInvalidatedRange; }
34 //! Reset invalidated range.
35 virtual void Validate() Standard_OVERRIDE { myInvalidatedRange.Clear(); }
37 //! Invalidate the entire buffer data.
38 virtual void Invalidate() Standard_OVERRIDE
40 invalidate (Graphic3d_BufferRange (0, (Standard_Integer )mySize));
43 //! Invalidate the given indexes (starting from 0)
44 void Invalidate (Standard_Integer theIndexLower, Standard_Integer theIndexUpper)
46 Standard_OutOfRange_Raise_if (theIndexLower > theIndexUpper, "Graphic3d_MutableIndexBuffer::Invalidate()");
47 invalidate (Graphic3d_BufferRange (Stride * theIndexLower, Stride * (theIndexUpper - theIndexLower + 1)));
50 //! Invalidate specified sub-range of data (as byte offsets).
51 void invalidate (const Graphic3d_BufferRange& theRange) { myInvalidatedRange.Unite (theRange); }
55 Graphic3d_BufferRange myInvalidatedRange; //!< invalidated buffer data range (as byte offsets)
59 #endif // _Graphic3d_MutableIndexBuffer_HeaderFile