Salome HOME
NRI : Change lGeometryClient by lGEOMClient.
[modules/smesh.git] / src / SMDS / SMDS_PntHasher.lxx
1 // File:        SMDS_PntHasher.lxx
2 // Created:     Wed Jan 23 14:07:00 2002
3 // Author:      Jean-Michel BOULCOURT
4 //              <jmb@coulox.paris1.matra-dtv.fr>
5
6
7 #include <gp_Pnt.hxx>
8
9 static Standard_Real tab1[3];
10 static Standard_Real tab2[3];
11
12 //=======================================================================
13 //function : HashCode
14 //purpose  : 
15 //=======================================================================
16 inline Standard_Integer  SMDS_PntHasher::HashCode
17   (const gp_Pnt& point, const Standard_Integer Upper)
18 {
19   union 
20     {
21     Standard_Real R[3];
22     Standard_Integer I[6];
23     } U;
24
25   point.Coord(U.R[0],U.R[1],U.R[2]);  
26
27   return ::HashCode(U.I[0]/23+U.I[1]/19+U.I[2]/17+U.I[3]/13+U.I[4]/11+U.I[5]/7,Upper);
28   //  return ::HashCode((U.I[0]>>4)+(U.I[1]>>3)+(U.I[2]>>2)+(U.I[3]>>1)+(U.I[4]>>4)+(U.I[5]>>3),Upper);
29
30 }
31
32 //=======================================================================
33 //function : IsEqual
34 //purpose  : 
35 //=======================================================================
36 inline Standard_Boolean  SMDS_PntHasher::IsEqual
37   (const gp_Pnt& point1, const gp_Pnt& point2)
38 {
39   point1.Coord(tab1[0],tab1[1],tab1[2]);  
40   point2.Coord(tab2[0],tab2[1],tab2[2]);  
41   return (memcmp(tab1,tab2,sizeof(tab1)) == 0);
42 }