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