0026377: Passing Handle objects as arguments to functions as non-const reference...
[occt.git] / src / IFSelect / IFSelect_AppliedModifiers.cxx
CommitLineData
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
92efcf78 19IMPLEMENT_STANDARD_RTTIEXT(IFSelect_AppliedModifiers,MMgt_TShared)
20
b311480e 21IFSelect_AppliedModifiers::IFSelect_AppliedModifiers
7fd59977 22 (const Standard_Integer nbmax, const Standard_Integer nbent)
23 : thelists (nbmax+1)
24{
25 thenbent = nbent; theentcnt = 0;
26}
27
28 Standard_Boolean IFSelect_AppliedModifiers::AddModif
29 (const Handle(IFSelect_GeneralModifier)& modif)
30{
31 if (themodifs.Length() >= thelists.NbEntities()) return Standard_False;
32 themodifs.Append(modif);
33 thelists.SetNumber (themodifs.Length());
34 return Standard_True;
35}
36
37 Standard_Boolean IFSelect_AppliedModifiers::AddNum
38 (const Standard_Integer nument)
39{
40 thelists.Add (nument);
41 return Standard_True;
42}
43
44
45 Standard_Integer IFSelect_AppliedModifiers::Count () const
46 { return themodifs.Length(); }
47
48 Standard_Boolean IFSelect_AppliedModifiers::Item
49 (const Standard_Integer num,
50 Handle(IFSelect_GeneralModifier)& modif,
51 Standard_Integer& entcount)
52{
53 if (num < 1 || num > themodifs.Length()) return Standard_False;
54 modif = themodifs.Value(num);
55 thelists.SetNumber (num);
56 theentcnt = thelists.Length();
57 entcount = (theentcnt > 0 ? theentcnt : thenbent);
58 return Standard_True;
59}
60
61 Standard_Integer IFSelect_AppliedModifiers::ItemNum
62 (const Standard_Integer nument) const
63 { return (theentcnt > 0 ? thelists.Value(nument) : nument); }
64
65 Handle(TColStd_HSequenceOfInteger) IFSelect_AppliedModifiers::ItemList () const
66{
67 Handle(TColStd_HSequenceOfInteger) list = new TColStd_HSequenceOfInteger();
68 Standard_Integer i, nb = (theentcnt > 0 ? theentcnt : thenbent);
69 for (i = 1; i <= nb; i ++) list->Append (ItemNum(i));
70 return list;
71}
72
73 Standard_Boolean IFSelect_AppliedModifiers::IsForAll () const
74 { return (theentcnt == 0); }