Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:16

0001 // Copyright (c) 1999-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 MeshVS_TwoNodes_HeaderFile
0015 #define MeshVS_TwoNodes_HeaderFile
0016 
0017 #include <Standard.hxx>
0018 #include <Standard_Macro.hxx>
0019 #include <Standard_HashUtils.hxx>
0020 
0021 //! Structure containing two IDs (of nodes) for using as a key in a map
0022 //! (as representation of a mesh link)
0023 //!
0024 struct MeshVS_TwoNodes
0025 {
0026   Standard_Integer First, Second;
0027 
0028   MeshVS_TwoNodes (Standard_Integer aFirst=0, Standard_Integer aSecond=0) 
0029   : First(aFirst), Second(aSecond) {}
0030 
0031   bool operator==(const MeshVS_TwoNodes& theTwoNode) const
0032   {
0033     return ((First == theTwoNode.First) && (Second == theTwoNode.Second)) ||
0034       ((First == theTwoNode.Second) && (Second == theTwoNode.First));
0035   }
0036 };
0037 
0038 namespace std
0039 {
0040   template<>
0041   struct hash<MeshVS_TwoNodes>
0042   {
0043     size_t operator()(const MeshVS_TwoNodes& theTwoNodes) const noexcept
0044     {
0045       // Combine two int values into a single hash value.
0046       int aCombination[2]{ theTwoNodes.First, theTwoNodes.Second };
0047       if (aCombination[0] > aCombination[1])
0048       {
0049         std::swap(aCombination[0], aCombination[1]);
0050       }
0051       return opencascade::hashBytes(aCombination, sizeof(aCombination));
0052     }
0053   };
0054 }
0055 
0056 #endif