Salome HOME
yfr : Merge with v1.2
[modules/smesh.git] / src / SMDS / SMDS_MeshElement.lxx
1 // File:        SMDS_MeshElement.lxx
2 // Created:     Thu Jan 24 09:45:40 2002
3 // Author:      Jean-Michel BOULCOURT
4 //              <jmb@coulox.paris1.matra-dtv.fr>
5
6 //=======================================================================
7 //function : HashCode
8 //purpose  : 
9 //=======================================================================
10 inline Standard_Integer SMDS_MeshElement::HashCode(const Standard_Integer Upper) const
11 {
12   return (GetKey() % Upper);
13 }
14
15 //=======================================================================
16 //function : IsEqual
17 //purpose  : 
18 //=======================================================================
19
20 inline Standard_Boolean SMDS_MeshElement::IsEqual(const Handle(SMDS_MeshElement)& other) const
21 {
22   if (this->NbNodes()!=other->NbNodes())
23     return Standard_False;
24   Standard_Integer *c1,*c2;
25   Standard_Integer n = this->NbNodes();
26
27   c1 = (Standard_Integer *)this->GetConnections();
28   c2 = (Standard_Integer *)other->GetConnections();
29   if (*c1 != *c2)
30     return Standard_False;
31
32   n--;
33   c1++;
34   c2++;
35
36   for (;n--; c1++,c2++) {
37     if (*c1 != *c2) {
38       return Standard_False;
39     }
40   }
41
42   return Standard_True;
43
44 }
45
46 //=======================================================================
47 //function : IsSame
48 //purpose  : 
49 //=======================================================================
50
51 inline Standard_Boolean SMDS_MeshElement::IsSame(const Handle(SMDS_MeshElement)& other) const
52 {
53   if (this->NbNodes()!=other->NbNodes())
54     return Standard_False;
55   Standard_Integer *c1,*c2;
56   Standard_Integer n = this->NbNodes();
57
58   c1 = (Standard_Integer *)this->GetConnections();
59   c2 = (Standard_Integer *)other->GetConnections();
60   if (*c1 != *c2)
61     return Standard_False;
62
63   n--;
64   c1++;
65   c2++;
66
67   Standard_Integer off = n-1;
68
69   for (;n--; c1++,c2++) {
70     if (*c1 != *c2 && *c1 != *(c2+off)) {
71       return Standard_False;
72     }
73     off -= 2;
74   }
75
76   return Standard_True;
77 }
78
79 //=======================================================================
80 //function : IsNodeInElement
81 //purpose  : 
82 //=======================================================================
83 inline Standard_Boolean SMDS_MeshElement::IsNodeInElement(const Standard_Integer idnode) const
84 {
85   if (idnode < GetConnection(1))
86     return Standard_False;
87
88   Standard_Integer *c;
89   c = (Standard_Integer *)this->GetConnections();
90   Standard_Integer n = myNbNodes;
91
92   for (;n--; c++) {
93     if (*c == idnode)
94       return Standard_True;
95   }
96
97   return Standard_False;
98 }
99
100
101 //=======================================================================
102 //function : NbNodes
103 //purpose  : 
104 //           
105 //=======================================================================
106
107 inline Standard_Integer SMDS_MeshElement::NbNodes() const
108 {
109   return myNbNodes;
110 }
111
112 //=======================================================================
113 //function : GetID
114 //purpose  : 
115 //=======================================================================
116 inline Standard_Integer SMDS_MeshElement::GetID() const
117 {
118   return myID;
119 }
120
121 //=======================================================================
122 //function : GetType
123 //purpose  : 
124 //=======================================================================
125 inline SMDSAbs_ElementType SMDS_MeshElement::GetType() const
126 {
127   return myType;
128 }
129
130
131