1 // Copyright (c) 2014 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_BufferRange_HeaderFile
15 #define _Graphic3d_BufferRange_HeaderFile
17 #include <Graphic3d_Vec.hxx>
18 #include <Standard_Integer.hxx>
20 //! Range of values defined as Start + Length pair.
21 struct Graphic3d_BufferRange
23 Standard_Integer Start; //!< first element within the range
24 Standard_Integer Length; //!< number of elements within the range
26 //! Empty constructor.
27 Graphic3d_BufferRange() : Start (0), Length (0) {}
30 Graphic3d_BufferRange (Standard_Integer theStart, Standard_Integer theLength) : Start (theStart), Length (theLength) {}
32 //! Return TRUE if range is empty.
33 Standard_Boolean IsEmpty() const { return Length == 0; }
35 //! Return the Upper element within the range
36 Standard_Integer Upper() const { return Start + Length - 1; }
45 //! Add another range to this one.
46 void Unite (const Graphic3d_BufferRange& theRange)
53 else if (theRange.IsEmpty())
58 const Standard_Integer aStart = Min (Start, theRange.Start);
59 const Standard_Integer aLast = Max (Upper(), theRange.Upper());
61 Length = aLast - aStart + 1;
65 #endif // _Graphic3d_BufferRange_HeaderFile