1 // Copyright (C) 2006 SAMTECH
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // File: NMTDS_PassKey.cxx
21 // Author: Peter KURNEV
25 #include <NMTDS_PassKey.ixx>
29 #include <TColStd_ListIteratorOfListOfInteger.hxx>
32 #pragma warning( disable : 4101)
36 void SortShell(const int n, int* a);
38 Standard_Integer NormalizedId(const Standard_Integer aId,
39 const Standard_Integer aDiv);
41 //=======================================================================
44 //=======================================================================
45 NMTDS_PassKey::NMTDS_PassKey()
49 //=======================================================================
52 //=======================================================================
53 NMTDS_PassKey& NMTDS_PassKey::Assign(const NMTDS_PassKey& anOther)
55 myNbIds=anOther.myNbIds;
56 myNbMax=anOther.myNbMax;
58 memcpy(myIds, anOther.myIds, sizeof(myIds));
61 //=======================================================================
64 //=======================================================================
65 void NMTDS_PassKey::Clear()
72 for (i=0; i<myNbMax; ++i) {
76 //=======================================================================
79 //=======================================================================
80 void NMTDS_PassKey::SetIds(const Standard_Integer anId1,
81 const Standard_Integer anId2)
83 Standard_Integer aIdN1, aIdN2;
86 aIdN1=NormalizedId(anId1, myNbIds);
87 aIdN2=NormalizedId(anId2, myNbIds);
91 myIds[myNbMax-2]=anId1;
92 myIds[myNbMax-1]=anId2;
95 myIds[myNbMax-2]=anId2;
96 myIds[myNbMax-1]=anId1;
98 //=======================================================================
101 //=======================================================================
102 void NMTDS_PassKey::Ids(Standard_Integer& aId1,
103 Standard_Integer& aId2)const
108 //=======================================================================
111 //=======================================================================
112 Standard_Integer NMTDS_PassKey::NbMax()const
116 //=======================================================================
119 //=======================================================================
120 void NMTDS_PassKey::Compute()
122 SortShell(myNbIds, myIds+myNbMax-myNbIds);
124 //=======================================================================
127 //=======================================================================
128 Standard_Boolean NMTDS_PassKey::IsEqual(const NMTDS_PassKey& anOther) const
130 Standard_Integer iIsEqual;
131 Standard_Boolean bIsEqual;
133 iIsEqual=memcmp(myIds, anOther.myIds, sizeof(myIds));
134 bIsEqual=Standard_False;
140 //=======================================================================
143 //=======================================================================
144 Standard_Address NMTDS_PassKey::Key()const
146 return (Standard_Address)myIds;
148 //=======================================================================
149 //function : HashCode
151 //=======================================================================
152 Standard_Integer NMTDS_PassKey::HashCode(const Standard_Integer Upper) const
154 return ::HashCode(mySum, Upper);
156 //=======================================================================
159 //=======================================================================
160 void NMTDS_PassKey::Dump()const
164 printf(" PassKey: {");
165 for (i=0; i<myNbMax; ++i) {
166 printf(" %d", myIds[i]);
170 //=======================================================================
171 // function: NormalizedId
173 //=======================================================================
174 Standard_Integer NormalizedId(const Standard_Integer aId,
175 const Standard_Integer aDiv)
177 Standard_Integer aMax, aTresh, aIdRet;
180 aMax=::IntegerLast();
187 //=======================================================================
188 // function: SortShell
190 //=======================================================================
191 void SortShell(const int n, int* a)
193 int x, nd, i, j, l, d=1;
203 for (i=0; i<nd; ++i) {
212 if (j > -1) goto m30;
214 }//for (i=0; i<nd; ++i)