0023105: Exception during Meshing / Missing triangles
[occt.git] / src / BRepMesh / BRepMesh_Triangle.cxx
1 // Created on: 1993-09-23
2 // Created by: Didier PIFFAULT
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
5 //
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
10 //
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 //
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
20
21 #include <BRepMesh_Triangle.hxx>
22
23 //=======================================================================
24 //function : Constructor
25 //purpose  : 
26 //=======================================================================
27 BRepMesh_Triangle::BRepMesh_Triangle()
28 : myEdge1(0),
29   myEdge2(0),
30   myEdge3(0),
31   myMovability(BRepMesh_Free)
32 {
33 }
34
35 //=======================================================================
36 //function : Constructor
37 //purpose  : 
38 //=======================================================================
39 BRepMesh_Triangle::BRepMesh_Triangle (const Standard_Integer          theEdge1,
40                                       const Standard_Integer          theEdge2,
41                                       const Standard_Integer          theEdge3,
42                                       const Standard_Boolean          theOrientation1,
43                                       const Standard_Boolean          theOrientation2,
44                                       const Standard_Boolean          theOrientation3,
45                                       const BRepMesh_DegreeOfFreedom  isCanMove)
46 : myEdge1(theEdge1),
47   myEdge2(theEdge2),
48   myEdge3(theEdge3),
49   myOrientation1(theOrientation1),
50   myOrientation2(theOrientation2), 
51   myOrientation3(theOrientation3), 
52   myMovability(isCanMove)
53 {
54 }
55
56 //=======================================================================
57 //function : Initialize
58 //purpose  : 
59 //=======================================================================
60 void  BRepMesh_Triangle::Initialize(const Standard_Integer          theEdge1,
61                                     const Standard_Integer          theEdge2,
62                                     const Standard_Integer          theEdge3,
63                                     const Standard_Boolean          theOrientation1,
64                                     const Standard_Boolean          theOrientation2,
65                                     const Standard_Boolean          theOrientation3,
66                                     const BRepMesh_DegreeOfFreedom  isCanMove)
67 {
68   myEdge1        = theEdge1;
69   myEdge2        = theEdge2;
70   myEdge3        = theEdge3;
71   myOrientation1 = theOrientation1;
72   myOrientation2 = theOrientation2;
73   myOrientation3 = theOrientation3;
74   myMovability   = isCanMove;
75 }
76
77 //=======================================================================
78 //function : Edges
79 //purpose  : 
80 //=======================================================================
81 void  BRepMesh_Triangle::Edges(Standard_Integer& theEdge1,
82                                Standard_Integer& theEdge2,
83                                Standard_Integer& theEdge3,
84                                Standard_Boolean& theOrientation1,
85                                Standard_Boolean& theOrientation2,
86                                Standard_Boolean& theOrientation3) const
87 {
88   theEdge1        = myEdge1;
89   theEdge2        = myEdge2;
90   theEdge3        = myEdge3;
91   theOrientation1 = myOrientation1;
92   theOrientation2 = myOrientation2;
93   theOrientation3 = myOrientation3;
94 }
95
96 //=======================================================================
97 //function : SetMovability
98 //purpose  : 
99 //=======================================================================
100 void BRepMesh_Triangle::SetMovability(const BRepMesh_DegreeOfFreedom theMovability)
101 {
102   myMovability = theMovability;
103 }
104
105 //=======================================================================
106 //function : HashCode
107 //purpose  : 
108 //=======================================================================
109 Standard_Integer BRepMesh_Triangle::HashCode(const Standard_Integer theUpper)const 
110 {
111   return ::HashCode(myEdge1 + myEdge2 + myEdge3, theUpper);
112 }
113
114 //=======================================================================
115 //function : IsEqual
116 //purpose  : 
117 //=======================================================================
118 Standard_Boolean BRepMesh_Triangle::IsEqual(const BRepMesh_Triangle& theOther) const 
119 {
120   if (myMovability == BRepMesh_Deleted || theOther.myMovability == BRepMesh_Deleted)
121     return Standard_False;
122
123   if (myEdge1 == theOther.myEdge1 && 
124       myEdge2 == theOther.myEdge2 && 
125       myEdge3 == theOther.myEdge3)
126   {
127     return Standard_True;
128   }
129
130   if (myEdge1 == theOther.myEdge2 && 
131       myEdge2 == theOther.myEdge3 && 
132       myEdge3 == theOther.myEdge1)
133   {
134     return Standard_True;
135   }
136
137   if (myEdge1 == theOther.myEdge3 && 
138       myEdge2 == theOther.myEdge1 && 
139       myEdge3 == theOther.myEdge2)
140   {
141     return Standard_True;
142   }
143
144   return Standard_False;
145 }