0023106: BRepMesh_IncrementalMesh returns wrong status
[occt.git] / src / BRepMesh / BRepMesh_Edge.hxx
CommitLineData
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
ceb418e1 22//! Light weighted structure representing simple link.
23class BRepMesh_OrientedEdge
fc9b36d6 24{
25public:
26
27 DEFINE_STANDARD_ALLOC
ceb418e1 28
fc9b36d6 29 //! Default constructor.
ceb418e1 30 Standard_EXPORT BRepMesh_OrientedEdge()
31 : myFirstNode(-1),
32 myLastNode(-1)
fc9b36d6 33 {
34 }
35
ceb418e1 36 //! Constructs a link between two vertices.
37 Standard_EXPORT BRepMesh_OrientedEdge(
38 const Standard_Integer theFirstNode,
39 const Standard_Integer theLastNode)
40 : myFirstNode(theFirstNode),
41 myLastNode(theLastNode)
fc9b36d6 42 {
43 }
44
45 //! Returns index of first node of the Link.
46 inline Standard_Integer FirstNode() const
47 {
48 return myFirstNode;
49 }
50
51 //! Returns index of last node of the Link.
52 inline Standard_Integer LastNode() const
53 {
54 return myLastNode;
55 }
ceb418e1 56
57 //! Returns hash code for this edge.
58 //! @param theUpper upper index in the container.
59 //! @return hash code.
60 Standard_EXPORT Standard_Integer HashCode(const Standard_Integer theUpper) const
61 {
62 return ::HashCode(myFirstNode + myLastNode, theUpper);
63 }
64
65 //! Checks this and other edge for equality.
66 //! @param theOther edge to be checked against this one.
67 //! @retrun TRUE if edges have the same orientation, FALSE if not.
68 inline Standard_Boolean IsEqual(const BRepMesh_OrientedEdge& theOther) const
69 {
70 return (myFirstNode == theOther.myFirstNode && myLastNode == theOther.myLastNode);
71 }
72
73 //! Alias for IsEqual.
74 Standard_Boolean operator ==(const BRepMesh_OrientedEdge& Other) const
75 {
76 return IsEqual(Other);
77 }
78
79private:
80
81 Standard_Integer myFirstNode;
82 Standard_Integer myLastNode;
83};
84
85//! Light weighted structure representing link of the mesh.
86class BRepMesh_Edge : public BRepMesh_OrientedEdge
87{
88public:
89
90 //! Default constructor.
91 Standard_EXPORT BRepMesh_Edge()
92 : BRepMesh_OrientedEdge(),
93 myMovability(BRepMesh_Deleted)
94 {
95 }
96
97 //! Constructs a link between two vertices.
98 Standard_EXPORT BRepMesh_Edge(
99 const Standard_Integer theFirstNode,
100 const Standard_Integer theLastNode,
101 const BRepMesh_DegreeOfFreedom theMovability)
102 : BRepMesh_OrientedEdge(theFirstNode, theLastNode),
103 myMovability(theMovability)
104 {
105 }
106
fc9b36d6 107 //! Returns movability flag of the Link.
108 inline BRepMesh_DegreeOfFreedom Movability() const
109 {
110 return myMovability;
111 }
ceb418e1 112
fc9b36d6 113 //! Sets movability flag of the Link.
114 //! \param theMovability flag to be set.
115 inline void SetMovability(const BRepMesh_DegreeOfFreedom theMovability)
116 {
117 myMovability = theMovability;
118 }
ceb418e1 119
fc9b36d6 120 //! Checks if the given edge and this one have the same orientation.
121 //! \param theOther edge to be checked against this one.
122 //! \retrun TRUE if edges have the same orientation, FALSE if not.
123 inline Standard_Boolean IsSameOrientation(const BRepMesh_Edge& theOther) const
124 {
ceb418e1 125 return BRepMesh_OrientedEdge::IsEqual(theOther);
fc9b36d6 126 }
ceb418e1 127
fc9b36d6 128 //! Checks for equality with another edge.
129 //! \param theOther edge to be checked against this one.
130 //! \return TRUE if equal, FALSE if not.
131 inline Standard_Boolean IsEqual(const BRepMesh_Edge& theOther) const
132 {
ceb418e1 133 if (myMovability == BRepMesh_Deleted || theOther.myMovability == BRepMesh_Deleted)
fc9b36d6 134 return Standard_False;
fc9b36d6 135
ceb418e1 136 return IsSameOrientation(theOther) ||
137 (FirstNode() == theOther.LastNode() && LastNode() == theOther.FirstNode());
fc9b36d6 138 }
139
140 //! Alias for IsEqual.
141 Standard_Boolean operator ==(const BRepMesh_Edge& Other) const
142 {
143 return IsEqual(Other);
144 }
145
146private:
147
fc9b36d6 148 BRepMesh_DegreeOfFreedom myMovability;
149};
150
ceb418e1 151inline Standard_Integer HashCode(const BRepMesh_OrientedEdge& theEdge,
152 const Standard_Integer theUpper)
153{
154 return theEdge.HashCode(theUpper);
155}
156
fc9b36d6 157inline Standard_Integer HashCode(const BRepMesh_Edge& theEdge,
158 const Standard_Integer theUpper)
159{
160 return theEdge.HashCode(theUpper);
161}
162
163#endif