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_BufferRange_HeaderFile
0015 #define _Graphic3d_BufferRange_HeaderFile
0016 
0017 #include <Graphic3d_Vec.hxx>
0018 #include <Standard_Integer.hxx>
0019 
0020 //! Range of values defined as Start + Length pair.
0021 struct Graphic3d_BufferRange
0022 {
0023   Standard_Integer Start;  //!< first element within the range
0024   Standard_Integer Length; //!< number of elements within the range
0025 
0026   //! Empty constructor.
0027   Graphic3d_BufferRange() : Start (0), Length (0) {}
0028 
0029   //! Constructor.
0030   Graphic3d_BufferRange (Standard_Integer theStart, Standard_Integer theLength) : Start (theStart), Length (theLength) {}
0031 
0032   //! Return TRUE if range is empty.
0033   Standard_Boolean IsEmpty() const { return Length == 0; }
0034 
0035   //! Return the Upper element within the range
0036   Standard_Integer Upper() const { return Start + Length - 1; }
0037 
0038   //! Clear the range.
0039   void Clear()
0040   {
0041     Start  = 0;
0042     Length = 0;
0043   }
0044 
0045   //! Add another range to this one.
0046   void Unite (const Graphic3d_BufferRange& theRange)
0047   {
0048     if (IsEmpty())
0049     {
0050       *this = theRange;
0051       return;
0052     }
0053     else if (theRange.IsEmpty())
0054     {
0055       return;
0056     }
0057 
0058     const Standard_Integer aStart = Min (Start,   theRange.Start);
0059     const Standard_Integer aLast  = Max (Upper(), theRange.Upper());
0060     Start  = aStart;
0061     Length = aLast - aStart + 1;
0062   }
0063 };
0064 
0065 #endif // _Graphic3d_BufferRange_HeaderFile