1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #include <IFSelect_SelectAnyList.ixx>
15 #include <Interface_InterfaceError.hxx>
18 // .... Definition de liste : methodes "deferred" NbItems & FillResult
21 void IFSelect_SelectAnyList::SetRange
22 (const Handle(IFSelect_IntParam)& rankfrom,
23 const Handle(IFSelect_IntParam)& rankto)
24 { thelower = rankfrom; theupper = rankto; }
26 void IFSelect_SelectAnyList::SetOne (const Handle(IFSelect_IntParam)& rank)
27 { thelower = theupper = rank; }
29 void IFSelect_SelectAnyList::SetFrom
30 (const Handle(IFSelect_IntParam)& rankfrom)
31 { thelower = rankfrom; theupper.Nullify(); }
33 void IFSelect_SelectAnyList::SetUntil
34 (const Handle(IFSelect_IntParam)& rankto)
35 { thelower.Nullify(); theupper = rankto; }
37 Standard_Boolean IFSelect_SelectAnyList::HasLower () const
38 { return (!thelower.IsNull()); }
40 Handle(IFSelect_IntParam) IFSelect_SelectAnyList::Lower () const
43 Standard_Integer IFSelect_SelectAnyList::LowerValue () const
45 if (thelower.IsNull()) return 0;
46 return thelower->Value();
49 Standard_Boolean IFSelect_SelectAnyList::HasUpper () const
50 { return (!theupper.IsNull()); }
52 Handle(IFSelect_IntParam) IFSelect_SelectAnyList::Upper () const
55 Standard_Integer IFSelect_SelectAnyList::UpperValue () const
57 if (theupper.IsNull()) return 0;
58 return theupper->Value();
61 // On prend les sous-entites de lower a upper (inclus)
62 Interface_EntityIterator IFSelect_SelectAnyList::RootResult
63 (const Interface_Graph& G) const
65 Interface_EntityIterator input = InputResult(G);
66 KeepInputEntity (input); // selon type voulu
67 if (input.NbEntities() > 1) Interface_InterfaceError::Raise
68 ("SelectAnyList : more than ONE Entity in input");
69 if (input.NbEntities() == 0) return input;
71 Handle(Standard_Transient) ent;
72 for (input.Start(); input.More(); input.Next()) ent = input.Value();
74 Standard_Integer rankmax = NbItems(ent);
75 Standard_Integer rankfrom = 1;
76 if (!thelower.IsNull()) rankfrom = thelower->Value();
77 Standard_Integer rankto;
78 if (!theupper.IsNull()) rankto = theupper->Value();
79 else rankto = rankmax;
80 if (rankfrom < 1) rankfrom = 1;
81 if (rankto > rankmax) rankto = rankmax;
83 Interface_EntityIterator iter;
84 if (rankfrom <= rankto) FillResult(rankfrom,rankto,ent,iter);
89 TCollection_AsciiString IFSelect_SelectAnyList::Label () const
92 Standard_Integer rankfrom = 0;
93 if (HasLower()) rankfrom = LowerValue();
94 Standard_Integer rankto = 0;
95 if (HasUpper()) rankto = UpperValue();
96 if (rankfrom == rankto) sprintf(lab," (no %d)",rankfrom);
97 else if (rankfrom == 0) sprintf(lab," (-> %d)",rankfrom);
98 else if (rankto == 0) sprintf(lab," (%d ->)",rankto);
99 else sprintf(lab," (%d -> %d)",rankfrom,rankto);
101 TCollection_AsciiString labl("In List ");
102 labl.AssignCat(ListLabel());