Salome HOME
Added help page and revert some changes for a better ergonomy
[modules/geom.git] / src / NMTDS / NMTDS_Pair.cxx
1 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21
22 // File:        NMTDS_Pair.cxx
23 // Author:      Peter KURNEV
24
25 #include <NMTDS_Pair.ixx>
26
27 #include <stdio.h>
28 #include <string.h>
29 #include <TColStd_ListIteratorOfListOfInteger.hxx>
30 #include <TColStd_ListOfInteger.hxx>
31
32 #ifdef WNT
33 #pragma warning( disable : 4101) 
34 #endif
35
36 static
37   Standard_Integer NormalizedId(const Standard_Integer aId,
38                                 const Standard_Integer aDiv);
39
40 //=======================================================================
41 //function :
42 //purpose  : 
43 //=======================================================================
44 NMTDS_Pair::NMTDS_Pair()
45 {
46   Clear(); 
47 }
48 //=======================================================================
49 //function :
50 //purpose  : 
51 //=======================================================================
52 NMTDS_Pair::NMTDS_Pair(const NMTDS_Pair& aOther)
53 {
54   myId1=aOther.myId1;
55   myId2=aOther.myId2;
56 }
57 //=======================================================================
58 //function :operator =
59 //purpose  : 
60 //=======================================================================
61   NMTDS_Pair& NMTDS_Pair::operator =(const NMTDS_Pair& aOther)
62 {
63   myId1=aOther.myId1;
64   myId2=aOther.myId2;
65   return *this;
66 }
67 //=======================================================================
68 //function :~
69 //purpose  : 
70 //=======================================================================
71   NMTDS_Pair::~NMTDS_Pair()
72 {
73 }
74 //=======================================================================
75 //function :Clear
76 //purpose  : 
77 //=======================================================================
78   void NMTDS_Pair::Clear()
79 {
80   myId1=0;
81   myId2=0;
82 }
83 //=======================================================================
84 //function :SetIds
85 //purpose  : 
86 //=======================================================================
87   void NMTDS_Pair::SetIds(const Standard_Integer aId1,
88                           const Standard_Integer aId2)
89 {
90   Clear();
91   myId1=aId1;
92   myId2=aId2;
93   if (aId1>aId2) {
94     myId1=aId2;
95     myId2=aId1;
96   }
97 }
98 //=======================================================================
99 //function :Ids
100 //purpose  : 
101 //=======================================================================
102   void NMTDS_Pair::Ids(Standard_Integer& aId1,
103                        Standard_Integer& aId2) const
104 {
105   aId1=myId1;
106   aId2=myId2;
107 }
108 //=======================================================================
109 //function :IsEqual
110 //purpose  : 
111 //=======================================================================
112   Standard_Boolean NMTDS_Pair::IsEqual(const NMTDS_Pair& aOther) const
113 {
114  
115   Standard_Boolean bRet;
116   //
117   bRet=(myId1==aOther.myId1 && myId2==aOther.myId2);//ZZ
118   return bRet;
119 }
120 //=======================================================================
121 //function : HashCode
122 //purpose  : 
123 //=======================================================================
124   Standard_Integer NMTDS_Pair::HashCode(const Standard_Integer aUpper) const
125 {
126   Standard_Integer aSum;
127   //
128   aSum=0;
129   aSum+=NormalizedId(myId1, 2);
130   aSum+=NormalizedId(myId2, 2);
131   return ::HashCode(aSum, aUpper);
132 }
133 //=======================================================================
134 // function: NormalizedId
135 // purpose : 
136 //=======================================================================
137 Standard_Integer NormalizedId(const Standard_Integer aId,
138                               const Standard_Integer aDiv)
139 {
140   Standard_Integer aMax, aTresh, aIdRet;
141   //
142   aIdRet=aId;
143   aMax=::IntegerLast();
144   aTresh=aMax/aDiv;
145   if (aId>aTresh) {
146     aIdRet=aId%aTresh;
147   }
148   return aIdRet;
149 }