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 | |
42cf5bc1 |
15 | #include <IFSelect_AppliedModifiers.hxx> |
16 | #include <IFSelect_GeneralModifier.hxx> |
17 | #include <Standard_Type.hxx> |
7fd59977 |
18 | |
b311480e |
19 | IFSelect_AppliedModifiers::IFSelect_AppliedModifiers |
7fd59977 |
20 | (const Standard_Integer nbmax, const Standard_Integer nbent) |
21 | : thelists (nbmax+1) |
22 | { |
23 | thenbent = nbent; theentcnt = 0; |
24 | } |
25 | |
26 | Standard_Boolean IFSelect_AppliedModifiers::AddModif |
27 | (const Handle(IFSelect_GeneralModifier)& modif) |
28 | { |
29 | if (themodifs.Length() >= thelists.NbEntities()) return Standard_False; |
30 | themodifs.Append(modif); |
31 | thelists.SetNumber (themodifs.Length()); |
32 | return Standard_True; |
33 | } |
34 | |
35 | Standard_Boolean IFSelect_AppliedModifiers::AddNum |
36 | (const Standard_Integer nument) |
37 | { |
38 | thelists.Add (nument); |
39 | return Standard_True; |
40 | } |
41 | |
42 | |
43 | Standard_Integer IFSelect_AppliedModifiers::Count () const |
44 | { return themodifs.Length(); } |
45 | |
46 | Standard_Boolean IFSelect_AppliedModifiers::Item |
47 | (const Standard_Integer num, |
48 | Handle(IFSelect_GeneralModifier)& modif, |
49 | Standard_Integer& entcount) |
50 | { |
51 | if (num < 1 || num > themodifs.Length()) return Standard_False; |
52 | modif = themodifs.Value(num); |
53 | thelists.SetNumber (num); |
54 | theentcnt = thelists.Length(); |
55 | entcount = (theentcnt > 0 ? theentcnt : thenbent); |
56 | return Standard_True; |
57 | } |
58 | |
59 | Standard_Integer IFSelect_AppliedModifiers::ItemNum |
60 | (const Standard_Integer nument) const |
61 | { return (theentcnt > 0 ? thelists.Value(nument) : nument); } |
62 | |
63 | Handle(TColStd_HSequenceOfInteger) IFSelect_AppliedModifiers::ItemList () const |
64 | { |
65 | Handle(TColStd_HSequenceOfInteger) list = new TColStd_HSequenceOfInteger(); |
66 | Standard_Integer i, nb = (theentcnt > 0 ? theentcnt : thenbent); |
67 | for (i = 1; i <= nb; i ++) list->Append (ItemNum(i)); |
68 | return list; |
69 | } |
70 | |
71 | Standard_Boolean IFSelect_AppliedModifiers::IsForAll () const |
72 | { return (theentcnt == 0); } |