1 // Created on: 1993-09-23
2 // Created by: Didier PIFFAULT
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _BRepMesh_Triangle_HeaderFile
18 #define _BRepMesh_Triangle_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Macro.hxx>
24 #include <BRepMesh_DegreeOfFreedom.hxx>
27 //! Light weighted structure representing triangle
28 //! of mesh consisting of oriented links.
29 class BRepMesh_Triangle
35 //! Default constructor.
40 myOrientation1(Standard_False),
41 myOrientation2(Standard_False),
42 myOrientation3(Standard_False),
43 myMovability (BRepMesh_Free)
48 //! @param theEdges array of edges of triangle.
49 //! @param theOrientations array of edge's orientations.
50 //! @param theMovability movability of triangle.
52 const Standard_Integer (&theEdges)[3],
53 const Standard_Boolean (&theOrientations)[3],
54 const BRepMesh_DegreeOfFreedom theMovability)
56 Initialize(theEdges, theOrientations, theMovability);
59 //! Initializes the triangle by the given parameters.
60 //! @param theEdges array of edges of triangle.
61 //! @param theOrientations array of edge's orientations.
62 //! @param theMovability movability of triangle.
63 inline void Initialize(
64 const Standard_Integer (&theEdges)[3],
65 const Standard_Boolean (&theOrientations)[3],
66 const BRepMesh_DegreeOfFreedom theMovability)
68 myEdge1 = theEdges[0];
69 myEdge2 = theEdges[1];
70 myEdge3 = theEdges[2];
71 myOrientation1 = theOrientations[0];
72 myOrientation2 = theOrientations[1];
73 myOrientation3 = theOrientations[2];
74 myMovability = theMovability;
77 //! Gets edges with orientations composing the triangle.
78 //! @param[out] theEdges array edges are stored to.
79 //! @param[out] theOrientations array orientations are stored to.
80 inline void Edges(Standard_Integer (&theEdges)[3],
81 Standard_Boolean (&theOrientations)[3]) const
83 theEdges[0] = myEdge1;
84 theEdges[1] = myEdge2;
85 theEdges[2] = myEdge3;
86 theOrientations[0] = myOrientation1;
87 theOrientations[1] = myOrientation2;
88 theOrientations[2] = myOrientation3;
91 //! Returns movability of the triangle.
92 inline BRepMesh_DegreeOfFreedom Movability() const
97 //! Sets movability of the triangle.
98 inline void SetMovability(const BRepMesh_DegreeOfFreedom theMovability)
100 myMovability = theMovability;
103 //! Returns hash code for this triangle.
104 //! @param theUpper upper index in the container.
105 //! @return hash code.
106 Standard_Integer HashCode(const Standard_Integer theUpper) const
108 return ::HashCode(myEdge1 + myEdge2 + myEdge3, theUpper);
111 //! Checks for equality with another triangle.
112 //! @param theOther triangle to be checked against this one.
113 //! @return TRUE if equal, FALSE if not.
114 Standard_Boolean IsEqual(const BRepMesh_Triangle& theOther) const
116 if (myMovability == BRepMesh_Deleted || theOther.myMovability == BRepMesh_Deleted)
117 return Standard_False;
119 if (myEdge1 == theOther.myEdge1 &&
120 myEdge2 == theOther.myEdge2 &&
121 myEdge3 == theOther.myEdge3)
123 return Standard_True;
126 if (myEdge1 == theOther.myEdge2 &&
127 myEdge2 == theOther.myEdge3 &&
128 myEdge3 == theOther.myEdge1)
130 return Standard_True;
133 if (myEdge1 == theOther.myEdge3 &&
134 myEdge2 == theOther.myEdge1 &&
135 myEdge3 == theOther.myEdge2)
137 return Standard_True;
140 return Standard_False;
143 //! Alias for IsEqual.
144 Standard_Boolean operator ==(const BRepMesh_Triangle& theOther) const
146 return IsEqual(theOther);
151 Standard_Integer myEdge1;
152 Standard_Integer myEdge2;
153 Standard_Integer myEdge3;
154 Standard_Boolean myOrientation1;
155 Standard_Boolean myOrientation2;
156 Standard_Boolean myOrientation3;
157 BRepMesh_DegreeOfFreedom myMovability;
160 inline Standard_Integer HashCode(const BRepMesh_Triangle& theTriangle,
161 const Standard_Integer theUpper)
163 return theTriangle.HashCode(theUpper);