Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-29 09:19:05

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 <NCollection_Vec2.hxx>
0018 
0019 #include <Standard_TypeDef.hxx>
0020 
0021 #include <NCollection_Vec3.hxx>
0022 
0023 #include <NCollection_Vec4.hxx>
0024 
0025 #include <NCollection_Mat4.hxx>
0026 #include <Standard_Integer.hxx>
0027 
0028 //! Range of values defined as Start + Length pair.
0029 struct Graphic3d_BufferRange
0030 {
0031   int Start;  //!< first element within the range
0032   int Length; //!< number of elements within the range
0033 
0034   //! Empty constructor.
0035   Graphic3d_BufferRange()
0036       : Start(0),
0037         Length(0)
0038   {
0039   }
0040 
0041   //! Constructor.
0042   Graphic3d_BufferRange(int theStart, int theLength)
0043       : Start(theStart),
0044         Length(theLength)
0045   {
0046   }
0047 
0048   //! Return TRUE if range is empty.
0049   bool IsEmpty() const { return Length == 0; }
0050 
0051   //! Return the Upper element within the range
0052   int Upper() const { return Start + Length - 1; }
0053 
0054   //! Clear the range.
0055   void Clear()
0056   {
0057     Start  = 0;
0058     Length = 0;
0059   }
0060 
0061   //! Add another range to this one.
0062   void Unite(const Graphic3d_BufferRange& theRange)
0063   {
0064     if (IsEmpty())
0065     {
0066       *this = theRange;
0067       return;
0068     }
0069     else if (theRange.IsEmpty())
0070     {
0071       return;
0072     }
0073 
0074     const int aStart = (std::min)(Start, theRange.Start);
0075     const int aLast  = (std::max)(Upper(), theRange.Upper());
0076     Start            = aStart;
0077     Length           = aLast - aStart + 1;
0078   }
0079 };
0080 
0081 #endif // _Graphic3d_BufferRange_HeaderFile