Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-03 09:16:52

0001 // Created on: 2003-10-08
0002 // Created by: Alexander SOLOVYOV
0003 // Copyright (c) 2003-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef MeshVS_TwoColors_HeaderFile
0017 #define MeshVS_TwoColors_HeaderFile
0018 
0019 #include <Quantity_Color.hxx>
0020 
0021 struct MeshVS_TwoColors
0022 {
0023   unsigned int r1 : 8;
0024   unsigned int g1 : 8;
0025   unsigned int b1 : 8;
0026   unsigned int r2 : 8;
0027   unsigned int g2 : 8;
0028   unsigned int b2 : 8;
0029 
0030   bool operator==(const MeshVS_TwoColors& TwoColors) const
0031   {
0032     return (((r1 * 256 + g1) * 256 + b1)
0033               == ((TwoColors.r1 * 256 + TwoColors.g1) * 256 + TwoColors.b1)
0034             && ((r2 * 256 + g2) * 256 + b2)
0035                  == ((TwoColors.r2 * 256 + TwoColors.g2) * 256 + TwoColors.b2));
0036   }
0037 };
0038 
0039 namespace std
0040 {
0041 template <>
0042 struct hash<MeshVS_TwoColors>
0043 {
0044   size_t operator()(const MeshVS_TwoColors& TwoColors) const noexcept
0045   {
0046     unsigned int aHash = 0;
0047     meshprsHashByte(aHash, TwoColors.r1);
0048     meshprsHashByte(aHash, TwoColors.g1);
0049     meshprsHashByte(aHash, TwoColors.b1);
0050     meshprsHashByte(aHash, TwoColors.r2);
0051     meshprsHashByte(aHash, TwoColors.g2);
0052     meshprsHashByte(aHash, TwoColors.b2);
0053     return std::hash<unsigned int>{}(aHash);
0054   }
0055 
0056 private:
0057   void meshprsHashByte(unsigned int& theHash, const unsigned int theValues) const noexcept
0058   {
0059     theHash += (theValues);
0060     theHash += (theHash << 10);
0061     theHash ^= (theHash >> 6);
0062   }
0063 };
0064 } // namespace std
0065 
0066 Standard_EXPORT MeshVS_TwoColors BindTwoColors(const Quantity_Color&, const Quantity_Color&);
0067 Standard_EXPORT Quantity_Color   ExtractColor(MeshVS_TwoColors&, const int);
0068 Standard_EXPORT void             ExtractColors(MeshVS_TwoColors&, Quantity_Color&, Quantity_Color&);
0069 
0070 #endif