1 // Created by: Peter KURNEV
2 // Copyright (c) 2010-2014 OPEN CASCADE SAS
3 // Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
4 // Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
5 // EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 // This file is part of Open CASCADE Technology software library.
9 // This library is free software; you can redistribute it and/or modify it under
10 // the terms of the GNU Lesser General Public License version 2.1 as published
11 // by the Free Software Foundation, with special exception defined in the file
12 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
13 // distribution for complete text of the license and disclaimer of any warranty.
15 // Alternatively, this file may be used under the terms of Open CASCADE
16 // commercial license or contractual agreement.
19 inline Standard_Integer NormalizedId(const Standard_Integer aId,
20 const Standard_Integer aDiv);
22 inline void SortShell(const Standard_Integer n,
25 //=======================================================================
28 //=======================================================================
29 inline BOPDS_PassKey::BOPDS_PassKey()
31 myAllocator=NCollection_BaseAllocator::CommonBaseAllocator();
35 //=======================================================================
38 //=======================================================================
39 inline BOPDS_PassKey::BOPDS_PassKey(const Handle(NCollection_BaseAllocator)& theAllocator)
41 myAllocator=theAllocator;
45 //=======================================================================
48 //=======================================================================
49 inline BOPDS_PassKey::BOPDS_PassKey(const BOPDS_PassKey& aOther)
56 myAllocator=aOther.myAllocator;
57 myNbIds=aOther.myNbIds;
61 myPtr=Allocate(myNbIds);
62 for (i=0; i<myNbIds; ++i) {
63 myPtr[i]=aOther.myPtr[i];
67 //=======================================================================
68 //function :operator =
70 //=======================================================================
71 inline BOPDS_PassKey& BOPDS_PassKey::operator =(const BOPDS_PassKey& aOther)
77 myAllocator=aOther.myAllocator;
78 myNbIds=aOther.myNbIds;
82 myPtr=Allocate(myNbIds);
83 for (i=0; i<myNbIds; ++i) {
84 myPtr[i]=aOther.myPtr[i];
90 //=======================================================================
93 //=======================================================================
94 inline BOPDS_PassKey::~BOPDS_PassKey()
98 //=======================================================================
101 //=======================================================================
102 inline BOPCol_PInteger BOPDS_PassKey::Allocate(const Standard_Integer theSize)
104 BOPCol_PInteger pPtr;
106 pPtr=(BOPCol_PInteger)myAllocator->Allocate(theSize*sizeof(Standard_Integer));
110 //=======================================================================
113 //=======================================================================
114 inline void BOPDS_PassKey::Clear()
119 myAllocator->Free(myPtr);
123 //=======================================================================
126 //=======================================================================
127 inline void BOPDS_PassKey::SetIds(const Standard_Integer aId1)
131 myPtr=Allocate(myNbIds);
133 mySum=NormalizedId(aId1, myNbIds);
136 //=======================================================================
139 //=======================================================================
140 inline void BOPDS_PassKey::SetIds(const Standard_Integer aId1,
141 const Standard_Integer aId2)
146 myPtr=Allocate(myNbIds);
157 mySum=NormalizedId(aId1, myNbIds);
158 mySum=mySum+NormalizedId(aId2, myNbIds);
160 //=======================================================================
163 //=======================================================================
164 inline void BOPDS_PassKey::SetIds(const Standard_Integer aId1,
165 const Standard_Integer aId2,
166 const Standard_Integer aId3)
171 myPtr=Allocate(myNbIds);
177 SortShell(myNbIds, myPtr);
179 mySum=NormalizedId(aId1, myNbIds);
180 mySum=mySum+NormalizedId(aId2, myNbIds);
181 mySum=mySum+NormalizedId(aId3, myNbIds);
183 //=======================================================================
186 //=======================================================================
187 inline void BOPDS_PassKey::SetIds(const Standard_Integer aId1,
188 const Standard_Integer aId2,
189 const Standard_Integer aId3,
190 const Standard_Integer aId4)
195 myPtr=Allocate(myNbIds);
202 SortShell(myNbIds, myPtr);
204 mySum=NormalizedId(aId1, myNbIds);
205 mySum=mySum+NormalizedId(aId2, myNbIds);
206 mySum=mySum+NormalizedId(aId3, myNbIds);
207 mySum=mySum+NormalizedId(aId4, myNbIds);
209 //=======================================================================
212 //=======================================================================
213 inline void BOPDS_PassKey::SetIds(const BOPCol_ListOfInteger& aLI)
215 Standard_Integer i, aId, aSum;
216 BOPCol_ListIteratorOfListOfInteger aIt;
220 myNbIds=aLI.Extent();
221 myPtr=Allocate(myNbIds);
225 for (i=0; aIt.More(); aIt.Next(), ++i) {
228 aSum+=NormalizedId(aId, myNbIds);
232 SortShell(myNbIds, myPtr);
234 //=======================================================================
237 //=======================================================================
238 inline Standard_Integer BOPDS_PassKey::NbIds()const
242 //=======================================================================
245 //=======================================================================
246 inline Standard_Integer BOPDS_PassKey::Id(const Standard_Integer aIndex) const
248 if (aIndex<0 || aIndex>myNbIds-1) {
251 return myPtr[aIndex];
253 //=======================================================================
256 //=======================================================================
257 inline void BOPDS_PassKey::Ids(Standard_Integer& aId1,
258 Standard_Integer& aId2) const
267 //=======================================================================
270 //=======================================================================
271 inline Standard_Boolean BOPDS_PassKey::IsEqual(const BOPDS_PassKey& aOther) const
273 Standard_Boolean bRet;
278 if (myNbIds!=aOther.myNbIds) {
281 for (i=0; i<myNbIds; ++i) {
282 if (myPtr[i]!=aOther.myPtr[i]) {
288 //=======================================================================
289 //function : HashCode
291 //=======================================================================
292 inline Standard_Integer BOPDS_PassKey::HashCode(const Standard_Integer aUpper) const
294 return ::HashCode(mySum, aUpper);
296 //=======================================================================
297 // function: NormalizedId
299 //=======================================================================
300 inline Standard_Integer NormalizedId(const Standard_Integer aId,
301 const Standard_Integer aDiv)
303 Standard_Integer aMax, aTresh, aIdRet;
306 aMax=::IntegerLast();
313 //=======================================================================
314 // function: SortShell
316 //=======================================================================
317 inline void SortShell(const Standard_Integer n,
320 Standard_Integer nd, i, j, l, d=1;
331 for (i=0; i<nd; ++i) {
344 }//for (i=0; i<nd; ++i)