0029516: Visualization - eliminate redundant property Graphic3d_MaterialAspect::Refle...
[occt.git] / src / Graphic3d / Graphic3d_MutableIndexBuffer.hxx
1 // Copyright (c) 2018 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
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.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14 #ifndef _Graphic3d_MutableIndexBuffer_HeaderFile
15 #define _Graphic3d_MutableIndexBuffer_HeaderFile
16
17 #include <Graphic3d_IndexBuffer.hxx>
18
19 //! Mutable index buffer.
20 class Graphic3d_MutableIndexBuffer : public Graphic3d_IndexBuffer
21 {
22   DEFINE_STANDARD_RTTIEXT(Graphic3d_MutableIndexBuffer, Graphic3d_IndexBuffer)
23 public:
24
25   //! Empty constructor.
26   Graphic3d_MutableIndexBuffer (const Handle(NCollection_BaseAllocator)& theAlloc) : Graphic3d_IndexBuffer (theAlloc) {}
27
28   //! Return TRUE if data can be invalidated.
29   virtual Standard_Boolean IsMutable() const Standard_OVERRIDE { return Standard_True; }
30
31   //! Return invalidated range.
32   virtual Graphic3d_BufferRange InvalidatedRange() const Standard_OVERRIDE { return myInvalidatedRange; }
33
34   //! Reset invalidated range.
35   virtual void Validate() Standard_OVERRIDE { myInvalidatedRange.Clear(); }
36
37   //! Invalidate the entire buffer data.
38   virtual void Invalidate() Standard_OVERRIDE
39   {
40     invalidate (Graphic3d_BufferRange (0, (Standard_Integer )mySize));
41   }
42
43   //! Invalidate the given indexes (starting from 0)
44   void Invalidate (Standard_Integer theIndexLower, Standard_Integer theIndexUpper)
45   {
46     Standard_OutOfRange_Raise_if (theIndexLower > theIndexUpper, "Graphic3d_MutableIndexBuffer::Invalidate()");
47     invalidate (Graphic3d_BufferRange (Stride * theIndexLower, Stride * (theIndexUpper - theIndexLower + 1)));
48   }
49
50   //! Invalidate specified sub-range of data (as byte offsets).
51   void invalidate (const Graphic3d_BufferRange& theRange) { myInvalidatedRange.Unite (theRange); }
52
53 protected:
54
55   Graphic3d_BufferRange myInvalidatedRange; //!< invalidated buffer data range (as byte offsets)
56
57 };
58
59 #endif // _Graphic3d_MutableIndexBuffer_HeaderFile