fc9b36d6 |
1 | // Copyright (c) 2013 OPEN CASCADE SAS |
2 | // |
3 | // This file is part of Open CASCADE Technology software library. |
4 | // |
5 | // This library is free software; you can redistribute it and/or modify it under |
6 | // the terms of the GNU Lesser General Public License version 2.1 as published |
7 | // by the Free Software Foundation, with special exception defined in the file |
8 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
9 | // distribution for complete text of the license and disclaimer of any warranty. |
10 | // |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
13 | |
14 | #ifndef _BRepMesh_Edge_HeaderFile |
15 | #define _BRepMesh_Edge_HeaderFile |
16 | |
17 | #include <Standard.hxx> |
18 | #include <Standard_DefineAlloc.hxx> |
19 | #include <Standard_Macro.hxx> |
20 | #include <BRepMesh_DegreeOfFreedom.hxx> |
21 | |
22 | //! Light weighted structure representing link of the mesh. |
23 | class BRepMesh_Edge |
24 | { |
25 | public: |
26 | |
27 | DEFINE_STANDARD_ALLOC |
28 | |
29 | //! Default constructor. |
30 | Standard_EXPORT BRepMesh_Edge() |
31 | : myFirstNode (-1), |
32 | myLastNode (-1), |
33 | myMovability(BRepMesh_Deleted) |
34 | { |
35 | } |
36 | |
37 | //! Contructs a link beetween two vertices. |
38 | Standard_EXPORT BRepMesh_Edge(const Standard_Integer theFirstNode, |
39 | const Standard_Integer theLastNode, |
40 | const BRepMesh_DegreeOfFreedom theMovability) |
41 | : myFirstNode (theFirstNode), |
42 | myLastNode (theLastNode), |
43 | myMovability(theMovability) |
44 | { |
45 | } |
46 | |
47 | //! Returns index of first node of the Link. |
48 | inline Standard_Integer FirstNode() const |
49 | { |
50 | return myFirstNode; |
51 | } |
52 | |
53 | //! Returns index of last node of the Link. |
54 | inline Standard_Integer LastNode() const |
55 | { |
56 | return myLastNode; |
57 | } |
58 | |
59 | //! Returns movability flag of the Link. |
60 | inline BRepMesh_DegreeOfFreedom Movability() const |
61 | { |
62 | return myMovability; |
63 | } |
64 | |
65 | //! Sets movability flag of the Link. |
66 | //! \param theMovability flag to be set. |
67 | inline void SetMovability(const BRepMesh_DegreeOfFreedom theMovability) |
68 | { |
69 | myMovability = theMovability; |
70 | } |
71 | |
72 | //! Returns hash code for this edge. |
73 | //! \param theUpper upper index in the container. |
74 | //! \return hash code. |
75 | Standard_EXPORT Standard_Integer HashCode(const Standard_Integer theUpper) const |
76 | { |
77 | return ::HashCode(myFirstNode + myLastNode, theUpper); |
78 | } |
79 | |
80 | //! Checks if the given edge and this one have the same orientation. |
81 | //! \param theOther edge to be checked against this one. |
82 | //! \retrun TRUE if edges have the same orientation, FALSE if not. |
83 | inline Standard_Boolean IsSameOrientation(const BRepMesh_Edge& theOther) const |
84 | { |
85 | return (myFirstNode == theOther.myFirstNode && myLastNode == theOther.myLastNode); |
86 | } |
87 | |
88 | //! Checks for equality with another edge. |
89 | //! \param theOther edge to be checked against this one. |
90 | //! \return TRUE if equal, FALSE if not. |
91 | inline Standard_Boolean IsEqual(const BRepMesh_Edge& theOther) const |
92 | { |
93 | if (myMovability == BRepMesh_Deleted || |
94 | theOther.myMovability == BRepMesh_Deleted) |
95 | { |
96 | return Standard_False; |
97 | } |
98 | |
99 | return IsSameOrientation(theOther) || |
100 | (myFirstNode == theOther.myLastNode && myLastNode == theOther.myFirstNode); |
101 | } |
102 | |
103 | //! Alias for IsEqual. |
104 | Standard_Boolean operator ==(const BRepMesh_Edge& Other) const |
105 | { |
106 | return IsEqual(Other); |
107 | } |
108 | |
109 | private: |
110 | |
111 | Standard_Integer myFirstNode; |
112 | Standard_Integer myLastNode; |
113 | BRepMesh_DegreeOfFreedom myMovability; |
114 | }; |
115 | |
116 | inline Standard_Integer HashCode(const BRepMesh_Edge& theEdge, |
117 | const Standard_Integer theUpper) |
118 | { |
119 | return theEdge.HashCode(theUpper); |
120 | } |
121 | |
122 | #endif |