1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 // File: NMTDS_Algo.cxx
22 // Created: Sat Dec 04 12:39:47 2004
23 // Author: Peter KURNEV
27 #include <NMTDS_PassKey.ixx>
31 #include <TColStd_ListIteratorOfListOfInteger.hxx>
32 #include <TColStd_ListOfInteger.hxx>
35 #pragma warning( disable : 4101)
39 Standard_Integer NormalizedId(const Standard_Integer aId,
40 const Standard_Integer aDiv);
42 //=======================================================================
45 //=======================================================================
46 NMTDS_PassKey::NMTDS_PassKey()
50 //=======================================================================
53 //=======================================================================
54 NMTDS_PassKey::NMTDS_PassKey(const NMTDS_PassKey& aOther)
56 myNbIds=aOther.myNbIds;
60 //=======================================================================
61 //function :operator =
63 //=======================================================================
64 NMTDS_PassKey& NMTDS_PassKey::operator =(const NMTDS_PassKey& aOther)
66 myNbIds=aOther.myNbIds;
71 //=======================================================================
74 //=======================================================================
75 NMTDS_PassKey::~NMTDS_PassKey()
78 //=======================================================================
81 //=======================================================================
82 void NMTDS_PassKey::Clear()
88 //=======================================================================
91 //=======================================================================
92 void NMTDS_PassKey::SetIds(const Standard_Integer aId1)
98 mySum=NormalizedId(aId1, myNbIds);
100 //=======================================================================
103 //=======================================================================
104 void NMTDS_PassKey::SetIds(const Standard_Integer aId1,
105 const Standard_Integer aId2)
107 TColStd_ListOfInteger aLI;
113 //=======================================================================
116 //=======================================================================
117 void NMTDS_PassKey::SetIds(const Standard_Integer aId1,
118 const Standard_Integer aId2,
119 const Standard_Integer aId3)
121 TColStd_ListOfInteger aLI;
128 //=======================================================================
131 //=======================================================================
132 void NMTDS_PassKey::SetIds(const Standard_Integer aId1,
133 const Standard_Integer aId2,
134 const Standard_Integer aId3,
135 const Standard_Integer aId4)
137 TColStd_ListOfInteger aLI;
145 //=======================================================================
148 //=======================================================================
149 void NMTDS_PassKey::SetIds(const TColStd_ListOfInteger& aLI)
151 Standard_Integer i, aId, aIdN;
152 TColStd_ListIteratorOfListOfInteger aIt;
156 for (; aIt.More(); aIt.Next()) {
160 myNbIds=myMap.Extent();
161 for(i=1; i<=myNbIds; ++i) {
163 aIdN=NormalizedId(aId, myNbIds);
168 //=======================================================================
171 //=======================================================================
172 Standard_Integer NMTDS_PassKey::NbIds()const
176 //=======================================================================
179 //=======================================================================
180 Standard_Integer NMTDS_PassKey::Id(const Standard_Integer aIndex) const
182 if (aIndex<1 || aIndex>myNbIds) {
185 return myMap(aIndex);
187 //=======================================================================
190 //=======================================================================
191 void NMTDS_PassKey::Ids(Standard_Integer& aId1,
192 Standard_Integer& aId2) const
201 //=======================================================================
204 //=======================================================================
205 Standard_Boolean NMTDS_PassKey::IsEqual(const NMTDS_PassKey& aOther) const
207 Standard_Boolean bRet;
208 Standard_Integer i, aId;
212 if (myNbIds!=aOther.myNbIds) {
215 for (i=1; i<=myNbIds; ++i) {
217 if (!aOther.myMap.Contains(aId)) {
223 //=======================================================================
224 //function : HashCode
226 //=======================================================================
227 Standard_Integer NMTDS_PassKey::HashCode(const Standard_Integer aUpper) const
229 return ::HashCode(mySum, aUpper);
231 //=======================================================================
234 //=======================================================================
235 void NMTDS_PassKey::Dump(const Standard_Integer )const
239 //=======================================================================
240 // function: NormalizedId
242 //=======================================================================
243 Standard_Integer NormalizedId(const Standard_Integer aId,
244 const Standard_Integer aDiv)
246 Standard_Integer aMax, aTresh, aIdRet;
249 aMax=::IntegerLast();
258 //=======================================================================
259 //function : Contains
261 //=======================================================================
262 Standard_Boolean NMTDS_PassKey::Contains(const Standard_Integer aId) const
264 return myMap.Contains(aId);
266 //=======================================================================
269 //=======================================================================
270 Standard_Boolean NMTDS_PassKey::Contains(const NMTDS_PassKey& aOther) const
272 Standard_Boolean bRet;
273 Standard_Integer i, aId;
277 if (myNbIds<aOther.myNbIds) {
280 for (i=1; i<=aOther.myNbIds; ++i) {
282 if (!myMap.Contains(aId)) {
288 //=======================================================================
289 //function :Intersected
291 //=======================================================================
292 Standard_Boolean NMTDS_PassKey::Intersected(const NMTDS_PassKey& aOther) const
294 Standard_Boolean bRet;
295 Standard_Integer i, aId;
299 for (i=1; i<=myNbIds; ++i) {
301 if (aOther.Contains(aId)) {
307 //=======================================================================
310 //=======================================================================
311 void NMTDS_PassKey::Add(const Standard_Integer aId)
313 TColStd_ListOfInteger aLI;
318 //=======================================================================
321 //=======================================================================
322 void NMTDS_PassKey::Add(const NMTDS_PassKey& aOther)
324 Standard_Integer i, aId;
325 TColStd_ListOfInteger aLS;
327 for(i=1; i<=myNbIds; ++i) {
331 for(i=1; i<=aOther.myNbIds; ++i) {
338 //=======================================================================
341 //=======================================================================
342 void NMTDS_PassKey::Add(const TColStd_ListOfInteger& aLI)
344 Standard_Integer i, aId;
345 TColStd_ListOfInteger aLS;
346 TColStd_ListIteratorOfListOfInteger aIt;
348 for(i=1; i<=myNbIds; ++i) {
353 for (; aIt.More(); aIt.Next()) {