Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-25 09:20:35

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   int First, Second;
0027 
0028   MeshVS_TwoNodes(int aFirst = 0, int aSecond = 0)
0029       : First(aFirst),
0030         Second(aSecond)
0031   {
0032   }
0033 
0034   bool operator==(const MeshVS_TwoNodes& theTwoNode) const
0035   {
0036     return ((First == theTwoNode.First) && (Second == theTwoNode.Second))
0037            || ((First == theTwoNode.Second) && (Second == theTwoNode.First));
0038   }
0039 };
0040 
0041 namespace std
0042 {
0043 template <>
0044 struct hash<MeshVS_TwoNodes>
0045 {
0046   size_t operator()(const MeshVS_TwoNodes& theTwoNodes) const noexcept
0047   {
0048     // Combine two int values into a single hash value.
0049     int aCombination[2]{theTwoNodes.First, theTwoNodes.Second};
0050     if (aCombination[0] > aCombination[1])
0051     {
0052       std::swap(aCombination[0], aCombination[1]);
0053     }
0054     return opencascade::hashBytes(aCombination, sizeof(aCombination));
0055   }
0056 };
0057 } // namespace std
0058 
0059 #endif