0022922: Clean up warnings on uninitialized / unused variables
[occt.git] / src / IFSelect / IFSelect_SelectAnyList.cxx
CommitLineData
7fd59977 1#include <IFSelect_SelectAnyList.ixx>
2#include <Interface_InterfaceError.hxx>
3#include <stdio.h>
4
5// .... Definition de liste : methodes "deferred" NbItems & FillResult
6
7
8 void IFSelect_SelectAnyList::SetRange
9 (const Handle(IFSelect_IntParam)& rankfrom,
10 const Handle(IFSelect_IntParam)& rankto)
11 { thelower = rankfrom; theupper = rankto; }
12
13 void IFSelect_SelectAnyList::SetOne (const Handle(IFSelect_IntParam)& rank)
14 { thelower = theupper = rank; }
15
16 void IFSelect_SelectAnyList::SetFrom
17 (const Handle(IFSelect_IntParam)& rankfrom)
18 { thelower = rankfrom; theupper.Nullify(); }
19
20 void IFSelect_SelectAnyList::SetUntil
21 (const Handle(IFSelect_IntParam)& rankto)
22 { thelower.Nullify(); theupper = rankto; }
23
24 Standard_Boolean IFSelect_SelectAnyList::HasLower () const
25 { return (!thelower.IsNull()); }
26
27 Handle(IFSelect_IntParam) IFSelect_SelectAnyList::Lower () const
28 { return thelower; }
29
30 Standard_Integer IFSelect_SelectAnyList::LowerValue () const
31{
32 if (thelower.IsNull()) return 0;
33 return thelower->Value();
34}
35
36 Standard_Boolean IFSelect_SelectAnyList::HasUpper () const
37 { return (!theupper.IsNull()); }
38
39 Handle(IFSelect_IntParam) IFSelect_SelectAnyList::Upper () const
40 { return theupper; }
41
42 Standard_Integer IFSelect_SelectAnyList::UpperValue () const
43{
44 if (theupper.IsNull()) return 0;
45 return theupper->Value();
46}
47
48// On prend les sous-entites de lower a upper (inclus)
49 Interface_EntityIterator IFSelect_SelectAnyList::RootResult
50 (const Interface_Graph& G) const
51{
52 Interface_EntityIterator input = InputResult(G);
53 KeepInputEntity (input); // selon type voulu
54 if (input.NbEntities() > 1) Interface_InterfaceError::Raise
55 ("SelectAnyList : more than ONE Entity in input");
56 if (input.NbEntities() == 0) return input;
57
58 Handle(Standard_Transient) ent;
59 for (input.Start(); input.More(); input.Next()) ent = input.Value();
60
61 Standard_Integer rankmax = NbItems(ent);
62 Standard_Integer rankfrom = 1;
63 if (!thelower.IsNull()) rankfrom = thelower->Value();
64 Standard_Integer rankto;
65 if (!theupper.IsNull()) rankto = theupper->Value();
66 else rankto = rankmax;
67 if (rankfrom < 1) rankfrom = 1;
68 if (rankto > rankmax) rankto = rankmax;
69
70 Interface_EntityIterator iter;
71 if (rankfrom <= rankto) FillResult(rankfrom,rankto,ent,iter);
72 return iter;
73}
74
75
76 TCollection_AsciiString IFSelect_SelectAnyList::Label () const
77{
78 char lab[30];
79 Standard_Integer rankfrom = 0;
80 if (HasLower()) rankfrom = LowerValue();
81 Standard_Integer rankto = 0;
82 if (HasUpper()) rankto = UpperValue();
83 if (rankfrom == rankto) sprintf(lab," (no %d)",rankfrom);
84 else if (rankfrom == 0) sprintf(lab," (-> %d)",rankfrom);
85 else if (rankto == 0) sprintf(lab," (%d ->)",rankto);
86 else sprintf(lab," (%d -> %d)",rankfrom,rankto);
87
88 TCollection_AsciiString labl("In List ");
89 labl.AssignCat(ListLabel());
90 labl.AssignCat(lab);
91 return labl;
92}