973c2be1 |
1 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
2 | // |
973c2be1 |
3 | // This file is part of Open CASCADE Technology software library. |
b311480e |
4 | // |
d5f74e42 |
5 | // This library is free software; you can redistribute it and/or modify it under |
6 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
7 | // by the Free Software Foundation, with special exception defined in the file |
8 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
9 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
10 | // |
973c2be1 |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
b311480e |
13 | |
7fd59977 |
14 | // Transfer_Iterator.gxx |
15 | #include <Standard_NoSuchObject.hxx> |
16 | |
17 | |
18 | // TheStart est suppose Handle(Standard_Transient) ou (Transfer_Finder) |
19 | // Il a servi a instancier TheList qui est une HSequence |
20 | |
21 | |
b311480e |
22 | Transfer_Iterator::Transfer_Iterator (const Standard_Boolean withstarts) |
7fd59977 |
23 | : Transfer_TransferIterator () |
24 | { if (withstarts) thestarts = new TheList(); } |
25 | |
26 | |
27 | void Transfer_Iterator::Add |
28 | (const Handle(Transfer_Binder)& binder) |
29 | { |
9775fa61 |
30 | if (!thestarts.IsNull()) throw Standard_NoSuchObject("Transfer_Iterator : Add, Starting Object required not provided"); |
7fd59977 |
31 | AddItem(binder); |
32 | } |
33 | |
34 | void Transfer_Iterator::Add |
35 | (const Handle(Transfer_Binder)& binder, const TheStart& start) |
36 | { |
37 | AddItem(binder); |
38 | if (!thestarts.IsNull()) thestarts->Append(start); |
39 | } |
40 | |
41 | void Transfer_Iterator::Filter |
42 | (const Handle(TheList)& list, const Standard_Boolean keep) |
43 | { |
44 | if (list.IsNull() || thestarts.IsNull()) return; |
45 | Standard_Integer i, j, nb = thestarts->Length(); |
46 | if (nb == 0) return; |
47 | Handle(Transfer_Binder) factice; |
48 | Transfer_TransferMap amap (nb); |
49 | for (i = 1; i <= nb; i ++) { |
50 | j = amap.Add (thestarts->Value(i),factice); |
51 | SelectItem (j,!keep); |
52 | } |
53 | |
54 | // Comparaison |
55 | nb = list->Length(); |
56 | for (i = 1; i <= nb; i ++) { |
57 | j = amap.FindIndex (list->Value(i)); |
58 | if (j > 0) SelectItem (j,keep); |
59 | } |
60 | } |
61 | |
62 | Standard_Boolean Transfer_Iterator::HasStarting () const |
63 | { return (!thestarts.IsNull()); } |
64 | |
65 | const TheStart& Transfer_Iterator::Starting () const |
66 | { |
9775fa61 |
67 | // if (thecurr == 0 || thecurr > themaxi) throw Standard_NoSuchObject |
7fd59977 |
68 | // ("TransferIterator : Starting"); |
9775fa61 |
69 | // if (theselect->Value(thecurr) == 0) throw Standard_NoSuchObject |
7fd59977 |
70 | // ("TransferIterator : Starting"); |
9775fa61 |
71 | if (thestarts.IsNull()) throw Standard_NoSuchObject("TransferIterator : No Starting defined at all"); |
7fd59977 |
72 | return thestarts->Value(thecurr); |
73 | } |