File indexing completed on 2025-01-18 10:03:15
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #ifndef _BRepMesh_Triangle_HeaderFile
0018 #define _BRepMesh_Triangle_HeaderFile
0019
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_HashUtils.hxx>
0023
0024 #include <BRepMesh_DegreeOfFreedom.hxx>
0025
0026
0027
0028
0029 class BRepMesh_Triangle
0030 {
0031 public:
0032
0033 DEFINE_STANDARD_ALLOC
0034
0035
0036 BRepMesh_Triangle()
0037 : myMovability (BRepMesh_Free)
0038 {
0039 myEdges[0] = 0;
0040 myEdges[1] = 0;
0041 myEdges[2] = 0;
0042 myOrientations[0] = Standard_False;
0043 myOrientations[1] = Standard_False;
0044 myOrientations[2] = Standard_False;
0045 }
0046
0047
0048
0049
0050
0051 BRepMesh_Triangle(
0052 const Standard_Integer (&theEdges)[3],
0053 const Standard_Boolean (&theOrientations)[3],
0054 const BRepMesh_DegreeOfFreedom theMovability)
0055 {
0056 Initialize(theEdges, theOrientations, theMovability);
0057 }
0058
0059
0060
0061
0062
0063 void Initialize(
0064 const Standard_Integer (&theEdges)[3],
0065 const Standard_Boolean (&theOrientations)[3],
0066 const BRepMesh_DegreeOfFreedom theMovability)
0067 {
0068 memcpy(myEdges, theEdges, sizeof(theEdges));
0069 memcpy(myOrientations, theOrientations, sizeof(theOrientations));
0070 myMovability = theMovability;
0071 }
0072
0073
0074
0075
0076 void Edges(Standard_Integer (&theEdges)[3],
0077 Standard_Boolean (&theOrientations)[3]) const
0078 {
0079 memcpy(theEdges, myEdges, sizeof(myEdges));
0080 memcpy(theOrientations, myOrientations, sizeof(myOrientations));
0081 }
0082
0083
0084 BRepMesh_DegreeOfFreedom Movability() const
0085 {
0086 return myMovability;
0087 }
0088
0089
0090 void SetMovability(const BRepMesh_DegreeOfFreedom theMovability)
0091 {
0092 myMovability = theMovability;
0093 }
0094
0095
0096
0097
0098 Standard_Boolean IsEqual(const BRepMesh_Triangle& theOther) const
0099 {
0100 if (myMovability == BRepMesh_Deleted || theOther.myMovability == BRepMesh_Deleted)
0101 return Standard_False;
0102
0103 if (myEdges[0] == theOther.myEdges[0] &&
0104 myEdges[1] == theOther.myEdges[1] &&
0105 myEdges[2] == theOther.myEdges[2])
0106 {
0107 return Standard_True;
0108 }
0109
0110 if (myEdges[0] == theOther.myEdges[1] &&
0111 myEdges[1] == theOther.myEdges[2] &&
0112 myEdges[2] == theOther.myEdges[0])
0113 {
0114 return Standard_True;
0115 }
0116
0117 if (myEdges[0] == theOther.myEdges[2] &&
0118 myEdges[1] == theOther.myEdges[0] &&
0119 myEdges[2] == theOther.myEdges[1])
0120 {
0121 return Standard_True;
0122 }
0123
0124 return Standard_False;
0125 }
0126
0127
0128 Standard_Boolean operator ==(const BRepMesh_Triangle& theOther) const
0129 {
0130 return IsEqual(theOther);
0131 }
0132
0133 Standard_Integer myEdges[3];
0134 Standard_Boolean myOrientations[3];
0135 BRepMesh_DegreeOfFreedom myMovability;
0136 };
0137
0138 namespace std
0139 {
0140 template <>
0141 struct hash<BRepMesh_Triangle>
0142 {
0143 size_t operator()(const BRepMesh_Triangle& theTriangle) const noexcept
0144 {
0145 int aCombination[3] = { theTriangle.myEdges[0], theTriangle.myEdges[1], theTriangle.myEdges[2] };
0146 std::sort(aCombination, aCombination + 3);
0147 return opencascade::hashBytes(aCombination, sizeof(aCombination));
0148 }
0149 };
0150 }
0151
0152 #endif