1 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File: NMTDS_Algo.cxx
24 // Created: Sat Dec 04 12:39:47 2004
25 // Author: Peter KURNEV
28 #include <NMTDS_PassKey.ixx>
32 #include <TColStd_ListIteratorOfListOfInteger.hxx>
33 #include <TColStd_ListOfInteger.hxx>
36 #pragma warning( disable : 4101)
40 Standard_Integer NormalizedId(const Standard_Integer aId,
41 const Standard_Integer aDiv);
43 //=======================================================================
46 //=======================================================================
47 NMTDS_PassKey::NMTDS_PassKey()
51 //=======================================================================
54 //=======================================================================
55 NMTDS_PassKey::NMTDS_PassKey(const NMTDS_PassKey& aOther)
57 myNbIds=aOther.myNbIds;
61 //=======================================================================
62 //function :operator =
64 //=======================================================================
65 NMTDS_PassKey& NMTDS_PassKey::operator =(const NMTDS_PassKey& aOther)
67 myNbIds=aOther.myNbIds;
72 //=======================================================================
75 //=======================================================================
76 NMTDS_PassKey::~NMTDS_PassKey()
79 //=======================================================================
82 //=======================================================================
83 void NMTDS_PassKey::Clear()
89 //=======================================================================
92 //=======================================================================
93 void NMTDS_PassKey::SetIds(const Standard_Integer aId1)
99 mySum=NormalizedId(aId1, myNbIds);
101 //=======================================================================
104 //=======================================================================
105 void NMTDS_PassKey::SetIds(const Standard_Integer aId1,
106 const Standard_Integer aId2)
108 TColStd_ListOfInteger aLI;
114 //=======================================================================
117 //=======================================================================
118 void NMTDS_PassKey::SetIds(const Standard_Integer aId1,
119 const Standard_Integer aId2,
120 const Standard_Integer aId3)
122 TColStd_ListOfInteger aLI;
129 //=======================================================================
132 //=======================================================================
133 void NMTDS_PassKey::SetIds(const Standard_Integer aId1,
134 const Standard_Integer aId2,
135 const Standard_Integer aId3,
136 const Standard_Integer aId4)
138 TColStd_ListOfInteger aLI;
146 //=======================================================================
149 //=======================================================================
150 void NMTDS_PassKey::SetIds(const TColStd_ListOfInteger& aLI)
152 Standard_Integer i, aId, aIdN;
153 TColStd_ListIteratorOfListOfInteger aIt;
157 for (; aIt.More(); aIt.Next()) {
161 myNbIds=myMap.Extent();
162 for(i=1; i<=myNbIds; ++i) {
164 aIdN=NormalizedId(aId, myNbIds);
169 //=======================================================================
172 //=======================================================================
173 Standard_Integer NMTDS_PassKey::NbIds()const
177 //=======================================================================
180 //=======================================================================
181 Standard_Integer NMTDS_PassKey::Id(const Standard_Integer aIndex) const
183 if (aIndex<1 || aIndex>myNbIds) {
186 return myMap(aIndex);
188 //=======================================================================
191 //=======================================================================
192 void NMTDS_PassKey::Ids(Standard_Integer& aId1,
193 Standard_Integer& aId2) const
202 //=======================================================================
205 //=======================================================================
206 Standard_Boolean NMTDS_PassKey::IsEqual(const NMTDS_PassKey& aOther) const
208 Standard_Boolean bRet;
209 Standard_Integer i, aId;
213 if (myNbIds!=aOther.myNbIds) {
216 for (i=1; i<=myNbIds; ++i) {
218 if (!aOther.myMap.Contains(aId)) {
224 //=======================================================================
225 //function : HashCode
227 //=======================================================================
228 Standard_Integer NMTDS_PassKey::HashCode(const Standard_Integer aUpper) const
230 return ::HashCode(mySum, aUpper);
232 //=======================================================================
235 //=======================================================================
236 void NMTDS_PassKey::Dump(const Standard_Integer )const
240 //=======================================================================
241 // function: NormalizedId
243 //=======================================================================
244 Standard_Integer NormalizedId(const Standard_Integer aId,
245 const Standard_Integer aDiv)
247 Standard_Integer aMax, aTresh, aIdRet;
250 aMax=::IntegerLast();
259 //=======================================================================
260 //function : Contains
262 //=======================================================================
263 Standard_Boolean NMTDS_PassKey::Contains(const Standard_Integer aId) const
265 return myMap.Contains(aId);
267 //=======================================================================
270 //=======================================================================
271 Standard_Boolean NMTDS_PassKey::Contains(const NMTDS_PassKey& aOther) const
273 Standard_Boolean bRet;
274 Standard_Integer i, aId;
278 if (myNbIds<aOther.myNbIds) {
281 for (i=1; i<=aOther.myNbIds; ++i) {
283 if (!myMap.Contains(aId)) {
289 //=======================================================================
290 //function :Intersected
292 //=======================================================================
293 Standard_Boolean NMTDS_PassKey::Intersected(const NMTDS_PassKey& aOther) const
295 Standard_Boolean bRet;
296 Standard_Integer i, aId;
300 for (i=1; i<=myNbIds; ++i) {
302 if (aOther.Contains(aId)) {
308 //=======================================================================
311 //=======================================================================
312 void NMTDS_PassKey::Add(const Standard_Integer aId)
314 TColStd_ListOfInteger aLI;
319 //=======================================================================
322 //=======================================================================
323 void NMTDS_PassKey::Add(const NMTDS_PassKey& aOther)
325 Standard_Integer i, aId;
326 TColStd_ListOfInteger aLS;
328 for(i=1; i<=myNbIds; ++i) {
332 for(i=1; i<=aOther.myNbIds; ++i) {
339 //=======================================================================
342 //=======================================================================
343 void NMTDS_PassKey::Add(const TColStd_ListOfInteger& aLI)
345 Standard_Integer i, aId;
346 TColStd_ListOfInteger aLS;
347 TColStd_ListIteratorOfListOfInteger aIt;
349 for(i=1; i<=myNbIds; ++i) {
354 for (; aIt.More(); aIt.Next()) {