Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-21 09:15:19

0001 // Copyright (c) 2013 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 _BRepMesh_OrientedEdge_HeaderFile
0015 #define _BRepMesh_OrientedEdge_HeaderFile
0016 
0017 #include <Standard.hxx>
0018 #include <Standard_HashUtils.hxx>
0019 #include <Standard_DefineAlloc.hxx>
0020 
0021 //! Light weighted structure representing simple link.
0022 class BRepMesh_OrientedEdge
0023 {
0024 public:
0025   DEFINE_STANDARD_ALLOC
0026 
0027   //! Default constructor.
0028   BRepMesh_OrientedEdge()
0029       : myFirstNode(-1),
0030         myLastNode(-1)
0031   {
0032   }
0033 
0034   //! Constructs a link between two vertices.
0035   BRepMesh_OrientedEdge(const Standard_Integer theFirstNode, const Standard_Integer theLastNode)
0036       : myFirstNode(theFirstNode),
0037         myLastNode(theLastNode)
0038   {
0039   }
0040 
0041   //! Returns index of first node of the Link.
0042   Standard_Integer FirstNode() const { return myFirstNode; }
0043 
0044   //! Returns index of last node of the Link.
0045   Standard_Integer LastNode() const { return myLastNode; }
0046 
0047   //! Checks this and other edge for equality.
0048   //! @param theOther edge to be checked against this one.
0049   //! @return TRUE if edges have the same orientation, FALSE if not.
0050   Standard_Boolean IsEqual(const BRepMesh_OrientedEdge& theOther) const
0051   {
0052     return (myFirstNode == theOther.myFirstNode && myLastNode == theOther.myLastNode);
0053   }
0054 
0055   //! Alias for IsEqual.
0056   Standard_Boolean operator==(const BRepMesh_OrientedEdge& Other) const { return IsEqual(Other); }
0057 
0058 private:
0059   Standard_Integer myFirstNode;
0060   Standard_Integer myLastNode;
0061 };
0062 
0063 namespace std
0064 {
0065 template <>
0066 struct hash<BRepMesh_OrientedEdge>
0067 {
0068   size_t operator()(const BRepMesh_OrientedEdge& theOrientedEdge) const noexcept
0069   {
0070     union Combination {
0071       unsigned short Arr[2]; // Node can be represented as a short
0072       uint32_t       Hash;
0073 
0074     } aCombination;
0075 
0076     aCombination.Arr[0] = static_cast<unsigned short>(theOrientedEdge.FirstNode());
0077     aCombination.Arr[1] = static_cast<unsigned short>(theOrientedEdge.LastNode());
0078     return static_cast<size_t>(aCombination.Hash);
0079   }
0080 };
0081 } // namespace std
0082 
0083 #endif