0027562: Coding - avoid exporting of inline methods
[occt.git] / src / BRepMesh / BRepMesh_Triangle.hxx
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
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifndef _BRepMesh_Triangle_HeaderFile
18 #define _BRepMesh_Triangle_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Macro.hxx>
23
24 #include <BRepMesh_DegreeOfFreedom.hxx>
25
26
27 //! Light weighted structure representing triangle 
28 //! of mesh consisting of oriented links.
29 class BRepMesh_Triangle
30 {
31 public:
32
33   DEFINE_STANDARD_ALLOC
34
35   //! Default constructor.
36   BRepMesh_Triangle()
37   : myEdge1(0),
38     myEdge2(0),
39     myEdge3(0),
40     myOrientation1(Standard_False),
41     myOrientation2(Standard_False),
42     myOrientation3(Standard_False),
43     myMovability  (BRepMesh_Free)
44   {
45   }
46
47   //! Constructor.
48   //! @param theEdges array of edges of triangle.
49   //! @param theOrientations array of edge's orientations.
50   //! @param theMovability movability of triangle.
51   BRepMesh_Triangle(
52     const Standard_Integer          (&theEdges)[3],
53     const Standard_Boolean          (&theOrientations)[3],
54     const BRepMesh_DegreeOfFreedom  theMovability)
55   {
56     Initialize(theEdges, theOrientations, theMovability);
57   }
58   
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)
67   {
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;
75   }
76   
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
82   {
83     theEdges[0]        = myEdge1;
84     theEdges[1]        = myEdge2;
85     theEdges[2]        = myEdge3;
86     theOrientations[0] = myOrientation1;
87     theOrientations[1] = myOrientation2;
88     theOrientations[2] = myOrientation3;
89   }
90   
91   //! Returns movability of the triangle.
92   inline BRepMesh_DegreeOfFreedom Movability() const 
93   {
94     return myMovability;
95   }
96   
97   //! Sets movability of the triangle.
98   inline void SetMovability(const BRepMesh_DegreeOfFreedom theMovability)
99   {
100     myMovability = theMovability;
101   }
102   
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
107   {
108     return ::HashCode(myEdge1 + myEdge2 + myEdge3, theUpper);
109   }
110   
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
115   {
116     if (myMovability == BRepMesh_Deleted || theOther.myMovability == BRepMesh_Deleted)
117       return Standard_False;
118
119     if (myEdge1 == theOther.myEdge1 && 
120         myEdge2 == theOther.myEdge2 && 
121         myEdge3 == theOther.myEdge3)
122     {
123       return Standard_True;
124     }
125
126     if (myEdge1 == theOther.myEdge2 && 
127         myEdge2 == theOther.myEdge3 && 
128         myEdge3 == theOther.myEdge1)
129     {
130       return Standard_True;
131     }
132
133     if (myEdge1 == theOther.myEdge3 && 
134         myEdge2 == theOther.myEdge1 && 
135         myEdge3 == theOther.myEdge2)
136     {
137       return Standard_True;
138     }
139
140     return Standard_False;
141   }
142   
143   //! Alias for IsEqual.
144   Standard_Boolean operator ==(const BRepMesh_Triangle& theOther) const
145   {
146     return IsEqual(theOther);
147   }
148
149 private:
150
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;
158 };
159
160 inline Standard_Integer HashCode(const BRepMesh_Triangle& theTriangle,
161                                  const Standard_Integer   theUpper)
162 {
163  return theTriangle.HashCode(theUpper);
164 }
165
166 #endif