Salome HOME
New DS implementation
[modules/smesh.git] / src / SMDS / SMDS_MeshElement.lxx
1 //  SMESH SMDS : implementaion of Salome mesh data structure
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SMDS_MeshElement.lxx
25 //  Author : Jean-Michel BOULCOURT
26 //  Module : SMESH
27
28 inline Standard_Integer SMDS_MeshElement::HashCode(const Standard_Integer Upper) const
29 {
30   return (GetKey() % Upper);
31 }
32
33 //=======================================================================
34 //function : IsEqual
35 //purpose  : 
36 //=======================================================================
37
38 inline Standard_Boolean SMDS_MeshElement::IsEqual(const Handle(SMDS_MeshElement)& other) const
39 {
40   if (this->NbNodes()!=other->NbNodes())
41     return Standard_False;
42   Standard_Integer *c1,*c2;
43   Standard_Integer n = this->NbNodes();
44
45   c1 = (Standard_Integer *)this->GetConnections();
46   c2 = (Standard_Integer *)other->GetConnections();
47   if (*c1 != *c2)
48     return Standard_False;
49
50   n--;
51   c1++;
52   c2++;
53
54   for (;n--; c1++,c2++) {
55     if (*c1 != *c2) {
56       return Standard_False;
57     }
58   }
59
60   return Standard_True;
61
62 }
63
64 //=======================================================================
65 //function : IsSame
66 //purpose  : 
67 //=======================================================================
68
69 inline Standard_Boolean SMDS_MeshElement::IsSame(const Handle(SMDS_MeshElement)& other) const
70 {
71   if (this->NbNodes()!=other->NbNodes())
72     return Standard_False;
73   Standard_Integer *c1,*c2;
74   Standard_Integer n = this->NbNodes();
75
76   c1 = (Standard_Integer *)this->GetConnections();
77   c2 = (Standard_Integer *)other->GetConnections();
78   if (*c1 != *c2)
79     return Standard_False;
80
81   n--;
82   c1++;
83   c2++;
84
85   Standard_Integer off = n-1;
86
87   for (;n--; c1++,c2++) {
88     if (*c1 != *c2 && *c1 != *(c2+off)) {
89       return Standard_False;
90     }
91     off -= 2;
92   }
93
94   return Standard_True;
95 }
96
97 //=======================================================================
98 //function : IsNodeInElement
99 //purpose  : 
100 //=======================================================================
101 inline Standard_Boolean SMDS_MeshElement::IsNodeInElement(const Standard_Integer idnode) const
102 {
103   if (idnode < GetConnection(1))
104     return Standard_False;
105
106   Standard_Integer *c;
107   c = (Standard_Integer *)this->GetConnections();
108   Standard_Integer n = myNbNodes;
109
110   for (;n--; c++) {
111     if (*c == idnode)
112       return Standard_True;
113   }
114
115   return Standard_False;
116 }
117
118
119 //=======================================================================
120 //function : NbNodes
121 //purpose  : 
122 //           
123 //=======================================================================
124
125 inline Standard_Integer SMDS_MeshElement::NbNodes() const
126 {
127   return myNbNodes;
128 }
129
130 //=======================================================================
131 //function : GetID
132 //purpose  : 
133 //=======================================================================
134 inline Standard_Integer SMDS_MeshElement::GetID() const
135 {
136   return myID;
137 }
138
139 //=======================================================================
140 //function : GetType
141 //purpose  : 
142 //=======================================================================
143 inline SMDSAbs_ElementType SMDS_MeshElement::GetType() const
144 {
145   return myType;
146 }
147
148
149