Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-02 08:22:16

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_Edge_HeaderFile
0015 #define _BRepMesh_Edge_HeaderFile
0016 
0017 #include <Standard.hxx>
0018 #include <BRepMesh_DegreeOfFreedom.hxx>
0019 #include <BRepMesh_OrientedEdge.hxx>
0020 #include <Standard_HashUtils.hxx>
0021 
0022 //! Light weighted structure representing link of the mesh.
0023 class BRepMesh_Edge : public BRepMesh_OrientedEdge
0024 {
0025 public:
0026   //! Default constructor.
0027   BRepMesh_Edge()
0028       : BRepMesh_OrientedEdge(),
0029         myMovability(BRepMesh_Deleted)
0030   {
0031   }
0032 
0033   //! Constructs a link between two vertices.
0034   BRepMesh_Edge(const Standard_Integer         theFirstNode,
0035                 const Standard_Integer         theLastNode,
0036                 const BRepMesh_DegreeOfFreedom theMovability)
0037       : BRepMesh_OrientedEdge(theFirstNode, theLastNode),
0038         myMovability(theMovability)
0039   {
0040   }
0041 
0042   //! Returns movability flag of the Link.
0043   BRepMesh_DegreeOfFreedom Movability() const { return myMovability; }
0044 
0045   //! Sets movability flag of the Link.
0046   //! @param theMovability flag to be set.
0047   void SetMovability(const BRepMesh_DegreeOfFreedom theMovability) { myMovability = theMovability; }
0048 
0049   //! Checks if the given edge and this one have the same orientation.
0050   //! @param theOther edge to be checked against this one.
0051   //! \return TRUE if edges have the same orientation, FALSE if not.
0052   Standard_Boolean IsSameOrientation(const BRepMesh_Edge& theOther) const
0053   {
0054     return BRepMesh_OrientedEdge::IsEqual(theOther);
0055   }
0056 
0057   //! Checks for equality with another edge.
0058   //! @param theOther edge to be checked against this one.
0059   //! @return TRUE if equal, FALSE if not.
0060   Standard_Boolean IsEqual(const BRepMesh_Edge& theOther) const
0061   {
0062     if (myMovability == BRepMesh_Deleted || theOther.myMovability == BRepMesh_Deleted)
0063       return Standard_False;
0064 
0065     return IsSameOrientation(theOther)
0066            || (FirstNode() == theOther.LastNode() && LastNode() == theOther.FirstNode());
0067   }
0068 
0069   //! Alias for IsEqual.
0070   Standard_Boolean operator==(const BRepMesh_Edge& Other) const { return IsEqual(Other); }
0071 
0072 private:
0073   BRepMesh_DegreeOfFreedom myMovability;
0074 };
0075 
0076 namespace std
0077 {
0078 template <>
0079 struct hash<BRepMesh_Edge>
0080 {
0081   size_t operator()(const BRepMesh_Edge& theEdge) const noexcept
0082   {
0083     union Combination {
0084       unsigned short Arr[2]; // Node can be represented as a short
0085       uint32_t       Hash;
0086 
0087     } aCombination;
0088 
0089     aCombination.Arr[0] = static_cast<unsigned short>(theEdge.FirstNode());
0090     aCombination.Arr[1] = static_cast<unsigned short>(theEdge.LastNode());
0091     if (aCombination.Arr[0] > aCombination.Arr[1])
0092     {
0093       std::swap(aCombination.Arr[0], aCombination.Arr[1]);
0094     }
0095     return static_cast<size_t>(aCombination.Hash);
0096   }
0097 };
0098 } // namespace std
0099 
0100 #endif