File indexing completed on 2025-01-18 10:03:14
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
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
0023 class BRepMesh_Edge : public BRepMesh_OrientedEdge
0024 {
0025 public:
0026
0027
0028 BRepMesh_Edge()
0029 : BRepMesh_OrientedEdge(),
0030 myMovability(BRepMesh_Deleted)
0031 {
0032 }
0033
0034
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
0045 BRepMesh_DegreeOfFreedom Movability() const
0046 {
0047 return myMovability;
0048 }
0049
0050
0051
0052 void SetMovability(const BRepMesh_DegreeOfFreedom theMovability)
0053 {
0054 myMovability = theMovability;
0055 }
0056
0057
0058
0059
0060 Standard_Boolean IsSameOrientation(const BRepMesh_Edge& theOther) const
0061 {
0062 return BRepMesh_OrientedEdge::IsEqual(theOther);
0063 }
0064
0065
0066
0067
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
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];
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