1 // Created on: 2003-12-05
2 // Created by: Alexander SOLOVYOV
3 // Copyright (c) 2003-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
17 #include <MeshVS_ColorHasher.hxx>
18 #include <Quantity_Color.hxx>
20 //================================================================
21 // Function : HashCode
23 //================================================================
24 Standard_Integer MeshVS_ColorHasher::HashCode ( const Quantity_Color& theCol, const Standard_Integer theUpper )
26 Standard_Integer r = Standard_Integer( 255 * theCol.Red () ),
27 g = Standard_Integer( 255 * theCol.Green () ),
28 b = Standard_Integer( 255 * theCol.Blue () );
30 #define MESHPRS_HASH_BYTE(val) { \
32 aHash += (aHash << 10); \
33 aHash ^= (aHash >> 6); \
35 Standard_Integer aHash = 0;
36 MESHPRS_HASH_BYTE ( r )
37 MESHPRS_HASH_BYTE ( g )
38 MESHPRS_HASH_BYTE ( b )
39 aHash += (aHash << 3);
40 aHash ^= (aHash >> 11);
41 aHash += (aHash << 15);
42 return (( aHash & 0x7fff ) % theUpper) + 1;
43 #undef MESHPRS_HASH_BYTE
46 //================================================================
49 //================================================================
50 Standard_Boolean MeshVS_ColorHasher::IsEqual( const Quantity_Color& K1, const Quantity_Color& K2 )