0025154: Collections in BRepMesh package are named in non-conformant manner
[occt.git] / src / BRepMesh / BRepMesh_Triangle.hxx
CommitLineData
304c45c8 1// Created on: 1993-09-23
2// Created by: Didier PIFFAULT
3// Copyright (c) 1993-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
304c45c8 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
304c45c8 7//
d5f74e42 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
973c2be1 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.
304c45c8 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
304c45c8 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
fc9b36d6 26
27//! Light weighted structure representing triangle
28//! of mesh consisting of oriented links.
29class BRepMesh_Triangle
30{
304c45c8 31public:
32
33 DEFINE_STANDARD_ALLOC
34
fc9b36d6 35 //! Default constructor.
36 Standard_EXPORT 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.
848fa7e3 48 //! @param theEdges array of edges of triangle.
49 //! @param theOrientations array of edge's orientations.
50 //! @param theMovability movability of triangle.
fc9b36d6 51 Standard_EXPORT 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 }
304c45c8 58
fc9b36d6 59 //! Initializes the triangle by the given parameters.
848fa7e3 60 //! @param theEdges array of edges of triangle.
61 //! @param theOrientations array of edge's orientations.
62 //! @param theMovability movability of triangle.
fc9b36d6 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 }
304c45c8 76
fc9b36d6 77 //! Gets edges with orientations composing the triangle.
848fa7e3 78 //! @param[out] theEdges array edges are stored to.
79 //! @param[out] theOrientations array orientations are stored to.
fc9b36d6 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 }
304c45c8 90
fc9b36d6 91 //! Returns movability of the triangle.
304c45c8 92 inline BRepMesh_DegreeOfFreedom Movability() const
93 {
94 return myMovability;
95 }
96
fc9b36d6 97 //! Sets movability of the triangle.
98 inline void SetMovability(const BRepMesh_DegreeOfFreedom theMovability)
99 {
100 myMovability = theMovability;
101 }
304c45c8 102
fc9b36d6 103 //! Returns hash code for this triangle.
848fa7e3 104 //! @param theUpper upper index in the container.
105 //! @return hash code.
fc9b36d6 106 Standard_EXPORT Standard_Integer HashCode(const Standard_Integer theUpper) const
107 {
108 return ::HashCode(myEdge1 + myEdge2 + myEdge3, theUpper);
109 }
304c45c8 110
fc9b36d6 111 //! Checks for equality with another triangle.
848fa7e3 112 //! @param theOther triangle to be checked against this one.
113 //! @return TRUE if equal, FALSE if not.
fc9b36d6 114 Standard_EXPORT 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 }
304c45c8 142
fc9b36d6 143 //! Alias for IsEqual.
144 Standard_EXPORT Standard_Boolean operator ==(const BRepMesh_Triangle& theOther) const
304c45c8 145 {
146 return IsEqual(theOther);
147 }
148
149private:
150
151 Standard_Integer myEdge1;
304c45c8 152 Standard_Integer myEdge2;
304c45c8 153 Standard_Integer myEdge3;
eafb234b 154 Standard_Boolean myOrientation1;
155 Standard_Boolean myOrientation2;
304c45c8 156 Standard_Boolean myOrientation3;
157 BRepMesh_DegreeOfFreedom myMovability;
158};
159
304c45c8 160inline Standard_Integer HashCode(const BRepMesh_Triangle& theTriangle,
fc9b36d6 161 const Standard_Integer theUpper)
304c45c8 162{
163 return theTriangle.HashCode(theUpper);
164}
165
166#endif