File indexing completed on 2026-05-20 08:16:39
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 class BRepMesh_Triangle
0029 {
0030 public:
0031 DEFINE_STANDARD_ALLOC
0032
0033
0034 BRepMesh_Triangle()
0035 : myMovability(BRepMesh_Free)
0036 {
0037 myEdges[0] = 0;
0038 myEdges[1] = 0;
0039 myEdges[2] = 0;
0040 myOrientations[0] = Standard_False;
0041 myOrientations[1] = Standard_False;
0042 myOrientations[2] = Standard_False;
0043 }
0044
0045
0046
0047
0048
0049 BRepMesh_Triangle(const Standard_Integer (&theEdges)[3],
0050 const Standard_Boolean (&theOrientations)[3],
0051 const BRepMesh_DegreeOfFreedom theMovability)
0052 {
0053 Initialize(theEdges, theOrientations, theMovability);
0054 }
0055
0056
0057
0058
0059
0060 void Initialize(const Standard_Integer (&theEdges)[3],
0061 const Standard_Boolean (&theOrientations)[3],
0062 const BRepMesh_DegreeOfFreedom theMovability)
0063 {
0064 memcpy(myEdges, theEdges, sizeof(theEdges));
0065 memcpy(myOrientations, theOrientations, sizeof(theOrientations));
0066 myMovability = theMovability;
0067 }
0068
0069
0070
0071
0072 void Edges(Standard_Integer (&theEdges)[3], Standard_Boolean (&theOrientations)[3]) const
0073 {
0074 memcpy(theEdges, myEdges, sizeof(myEdges));
0075 memcpy(theOrientations, myOrientations, sizeof(myOrientations));
0076 }
0077
0078
0079 BRepMesh_DegreeOfFreedom Movability() const { return myMovability; }
0080
0081
0082 void SetMovability(const BRepMesh_DegreeOfFreedom theMovability) { myMovability = theMovability; }
0083
0084
0085
0086
0087 Standard_Boolean IsEqual(const BRepMesh_Triangle& theOther) const
0088 {
0089 if (myMovability == BRepMesh_Deleted || theOther.myMovability == BRepMesh_Deleted)
0090 return Standard_False;
0091
0092 if (myEdges[0] == theOther.myEdges[0] && myEdges[1] == theOther.myEdges[1]
0093 && myEdges[2] == theOther.myEdges[2])
0094 {
0095 return Standard_True;
0096 }
0097
0098 if (myEdges[0] == theOther.myEdges[1] && myEdges[1] == theOther.myEdges[2]
0099 && myEdges[2] == theOther.myEdges[0])
0100 {
0101 return Standard_True;
0102 }
0103
0104 if (myEdges[0] == theOther.myEdges[2] && myEdges[1] == theOther.myEdges[0]
0105 && myEdges[2] == theOther.myEdges[1])
0106 {
0107 return Standard_True;
0108 }
0109
0110 return Standard_False;
0111 }
0112
0113
0114 Standard_Boolean operator==(const BRepMesh_Triangle& theOther) const { return IsEqual(theOther); }
0115
0116 Standard_Integer myEdges[3];
0117 Standard_Boolean myOrientations[3];
0118 BRepMesh_DegreeOfFreedom myMovability;
0119 };
0120
0121 namespace std
0122 {
0123 template <>
0124 struct hash<BRepMesh_Triangle>
0125 {
0126 size_t operator()(const BRepMesh_Triangle& theTriangle) const noexcept
0127 {
0128 int aCombination[3] = {theTriangle.myEdges[0], theTriangle.myEdges[1], theTriangle.myEdges[2]};
0129 std::sort(aCombination, aCombination + 3);
0130 return opencascade::hashBytes(aCombination, sizeof(aCombination));
0131 }
0132 };
0133 }
0134
0135 #endif