Test for 0022778: Bug in BRepMesh
[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
22 #include <BRepMesh_Triangle.ixx>
23
24 BRepMesh_Triangle::BRepMesh_Triangle()
25 : Edge1(0), Edge2(0), Edge3(0), myMovability(BRepMesh_Free)
26 {}
27
28 BRepMesh_Triangle::BRepMesh_Triangle (const Standard_Integer e1, 
29                                       const Standard_Integer e2,
30                                       const Standard_Integer e3,
31                                       const Standard_Boolean o1, 
32                                       const Standard_Boolean o2,
33                                       const Standard_Boolean o3,
34                                       const BRepMesh_DegreeOfFreedom  canMove)
35                                       : Edge1(e1),  Orientation1(o1),Edge2(e2), Orientation2(o2), 
36                                       Edge3(e3), Orientation3(o3), 
37                                       myMovability(canMove)
38 {}
39
40 void  BRepMesh_Triangle::Initialize(const Standard_Integer e1,
41                                     const Standard_Integer e2,
42                                     const Standard_Integer e3,
43                                     const Standard_Boolean o1, 
44                                     const Standard_Boolean o2,
45                                     const Standard_Boolean o3,
46                                     const BRepMesh_DegreeOfFreedom  canMove)
47 {
48   Edge1        =e1;
49   Edge2        =e2;
50   Edge3        =e3;
51   Orientation1 =o1;
52   Orientation2 =o2;
53   Orientation3 =o3;
54   myMovability =canMove;
55 }
56
57 void  BRepMesh_Triangle::Edges(Standard_Integer& e1,
58                                Standard_Integer& e2,
59                                Standard_Integer& e3,
60                                Standard_Boolean& o1, 
61                                Standard_Boolean& o2,
62                                Standard_Boolean& o3)const 
63 {
64   e1=Edge1;
65   e2=Edge2;
66   e3=Edge3;
67   o1=Orientation1;
68   o2=Orientation2;
69   o3=Orientation3;
70 }
71
72 void  BRepMesh_Triangle::SetMovability(const BRepMesh_DegreeOfFreedom  Move)
73 {
74   myMovability =Move;
75 }
76
77 Standard_Integer BRepMesh_Triangle::HashCode
78 (const Standard_Integer Upper)const 
79 {
80   return ::HashCode(Edge1+Edge2+Edge3, Upper);
81 }
82
83 Standard_Boolean BRepMesh_Triangle::IsEqual
84 (const BRepMesh_Triangle& Other)const 
85 {
86   if (myMovability==BRepMesh_Deleted || Other.myMovability==BRepMesh_Deleted)
87     return Standard_False;
88   if (Edge1==Other.Edge1 && Edge2==Other.Edge2 && Edge3==Other.Edge3)
89     return Standard_True;
90   if (Edge1==Other.Edge2 && Edge2==Other.Edge3 && Edge3==Other.Edge1)
91     return Standard_True;
92   if (Edge1==Other.Edge3 && Edge2==Other.Edge1 && Edge3==Other.Edge2)
93     return Standard_True;
94   return Standard_False;
95 }