Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:14

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 
0026   DEFINE_STANDARD_ALLOC
0027 
0028   //! Default constructor.
0029   BRepMesh_OrientedEdge()
0030     : myFirstNode(-1),
0031       myLastNode(-1)
0032   {
0033   }
0034 
0035   //! Constructs a link between two vertices.
0036   BRepMesh_OrientedEdge(
0037     const Standard_Integer theFirstNode,
0038     const Standard_Integer theLastNode)
0039     : myFirstNode(theFirstNode),
0040       myLastNode(theLastNode)
0041   {
0042   }
0043 
0044   //! Returns index of first node of the Link.
0045   Standard_Integer FirstNode() const
0046   {
0047     return myFirstNode;
0048   }
0049 
0050   //! Returns index of last node of the Link.
0051   Standard_Integer LastNode() const
0052   {
0053     return myLastNode;
0054   }
0055 
0056   //! Checks this and other edge for equality.
0057   //! @param theOther edge to be checked against this one.
0058   //! @return TRUE if edges have the same orientation, FALSE if not.
0059   Standard_Boolean IsEqual(const BRepMesh_OrientedEdge& theOther) const
0060   {
0061     return (myFirstNode == theOther.myFirstNode && myLastNode == theOther.myLastNode);
0062   }
0063 
0064   //! Alias for IsEqual.
0065   Standard_Boolean operator ==(const BRepMesh_OrientedEdge& Other) const
0066   {
0067     return IsEqual(Other);
0068   }
0069 
0070 private:
0071 
0072   Standard_Integer myFirstNode;
0073   Standard_Integer myLastNode;
0074 };
0075 
0076 namespace std
0077 {
0078   template <>
0079   struct hash<BRepMesh_OrientedEdge>
0080   {
0081     size_t operator()(const BRepMesh_OrientedEdge& theOrientedEdge) const noexcept
0082     {
0083       union Combination
0084       {
0085         unsigned short Arr[2]; // Node can be represented as a short
0086         uint32_t Hash;
0087 
0088       } aCombination;
0089       aCombination.Arr[0] = static_cast<unsigned short>(theOrientedEdge.FirstNode());
0090       aCombination.Arr[1] = static_cast<unsigned short>(theOrientedEdge.LastNode());
0091       return static_cast<size_t>(aCombination.Hash);
0092     }
0093   };
0094 }
0095 
0096 #endif